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
//! Owned passphrase type consumed by every passphrase-based operation.
use Zeroizing;
/// A passphrase held in a buffer that is wiped when the value drops.
///
/// Every operation that takes a passphrase consumes a `Passphrase`:
/// [`Encryptor::with_passphrase`](crate::Encryptor::with_passphrase),
/// [`PassphraseDecryptor::decrypt`](crate::PassphraseDecryptor::decrypt),
/// [`PrivateKey::from_key_file`](crate::PrivateKey::from_key_file),
/// [`KeyPairGenerator::with_passphrase`](crate::KeyPairGenerator::with_passphrase),
/// and [`generate_key_pair`](crate::generate_key_pair).
///
/// The text is readable only inside the crate. There is no public
/// accessor, `Debug` prints `Passphrase(<redacted>)`, and the type
/// implements neither `Display` nor `Clone`, so a passphrase cannot
/// leak through formatting and each operation consumes a value built
/// for it.
///
/// Wiping covers the buffer this value owns. A copy that existed
/// before construction — a prompt library's buffer, a `String` the
/// caller still holds — is outside its reach, so build the
/// `Passphrase` as early as practical and let the source value drop.
/// The wipe also acts only inside this process: it cannot stop the
/// operating system from paging the memory to swap or including it in
/// a crash dump while the value is alive.
///
/// There is no way to derive a second value from one secret. A caller
/// that needs the same passphrase for two operations reads it from its
/// source again for each; holding the text in a `String` between them
/// would leave a copy this type cannot wipe.
;