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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! Marker traits to allow types to be contained as secrets.
//!
//! Example: compare two values in constant time
//!
//! ```rust
//! # use secrets::traits::ConstantEq;
//! assert!(!8u32.constant_eq(&4u32));
//! ```
//!
//! Example: randomize the contents of some bytes
//!
//! ```rust
//! # use secrets::traits::Randomizable;
//! let mut bytes = [0u64; 2];
//! bytes.randomize();
//!
//! assert_ne!(bytes, [0, 0])
//! ```
//!
//! Example: zero out the contents of some bytes
//!
//! ```rust
//! # use secrets::traits::Zeroable;
//! let mut bytes = [1u8, 2, 3, 4];
//! bytes.zero();
//!
//! assert_eq!(bytes, [0, 0, 0, 0]);
//! ```
//!
//! Example: copy bytes into a target, zeroing out the original bytes
//!
//! ```rust
//! # use secrets::traits::Zeroable;
//! let mut src = [4u8; 4];
//! let mut dst = [1u8; 4];
//!
//! unsafe { src.transfer(&mut dst) };
//!
//! assert_eq!(src, [0, 0, 0, 0]);
//! assert_eq!(dst, [4, 4, 4, 4]);
//! ```
// `clippy` currently warns when trait functions could be `const fn`s, but this
// is not actually allowed by the language
/// Traits for types that are considered buckets of bytes.
/// Traits for types that should be compared for equality in constant
/// time.
/// Traits for types that can have their underlying storage safely set
/// to any arbitrary bytes.
/// Traits for types that can have their underlying storage safely
/// zeroed.
pub use ;
pub use ConstantEq;
pub use Randomizable;
pub use Zeroable;
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe