1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/// The `Choice` struct represents a choice for use in conditional
/// assignment.
///
/// It is a wrapper around a `u8`, which should have the value either
/// `1` (true) or `0` (false).
///
/// The conversion from `u8` to `Choice` passes the value through an
/// optimization barrier, as a best-effort attempt to prevent the
/// compiler from inferring that the `Choice` value is a boolean. This
/// strategy is based on Tim Maclean's
/// [work on `rust-timing-shield`][rust-timing-shield], which attempts
/// to provide a more comprehensive approach for preventing software
/// side-channels in Rust code.
///
/// The `Choice` struct implements operators for AND, OR, XOR, and NOT,
/// to allow combining `Choice` values. These operations do not
/// short-circuit.
///
/// [rust-timing-shield]:
/// https://www.chosenplaintext.ca/open-source/rust-timing-shield/security
;