Enum sequoia_openpgp::crypto::S2K [−][src]
#[non_exhaustive] pub enum S2K { Iterated { hash: HashAlgorithm, salt: [u8; 8], hash_bytes: u32, }, Salted { hash: HashAlgorithm, salt: [u8; 8], }, Simple { hash: HashAlgorithm, }, Private { tag: u8, parameters: Option<Box<[u8]>>, }, Unknown { tag: u8, parameters: Option<Box<[u8]>>, }, }
Expand description
String-to-Key (S2K) specifiers.
String-to-key (S2K) specifiers are used to convert password
strings into symmetric-key encryption/decryption keys. See
Section 3.7 of RFC 4880. This is used to encrypt messages with
a password (see SKESK
), and to protect secret keys (see
key::Encrypted
).
Note: This enum cannot be exhaustively matched to allow future extensions.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Repeatently hashes the password with a public salt
value.
Show fields
Fields of Iterated
hash: HashAlgorithm
Hash used for key derivation.
salt: [u8; 8]
Public salt value mixed into the password.
hash_bytes: u32
Number of bytes to hash.
This parameter increases the workload for an attacker
doing a dictionary attack. Note that not all values are
representable. See S2K::new_iterated
.
Use S2K::Iterated
.
Hashes the password with a public salt
value.
This mechanism does not use iteration to increase the time it takes to derive the key from the password. This makes dictionary attacks more feasible. Do not use this variant.
Show fields
Fields of Salted
hash: HashAlgorithm
Use S2K::Iterated
.
Hash used for key derivation.
salt: [u8; 8]
Use S2K::Iterated
.
Public salt value mixed into the password.
Use S2K::Iterated
.
Simply hashes the password.
This mechanism uses neither iteration to increase the time it takes to derive the key from the password nor does it salt the password. This makes dictionary attacks more feasible.
This mechanism has been deprecated in RFC 4880. Do not use this variant.
Show fields
Fields of Simple
Private S2K algorithm.
Show fields
Fields of Private
tag: u8
Tag identifying the private algorithm.
Tags 100 to 110 are reserved for private use.
parameters: Option<Box<[u8]>>
The parameters for the private algorithm.
This is optional, because when we parse a packet
containing an unknown S2K algorithm, we do not know how
many octets to attribute to the S2K’s parameters. In this
case, parameters
is set to None
. Note that the
information is not lost, but stored in the packet. If the
packet is serialized again, it is written out.
Unknown S2K algorithm.
Show fields
Fields of Unknown
tag: u8
Tag identifying the unknown algorithm.
parameters: Option<Box<[u8]>>
The parameters for the unknown algorithm.
This is optional, because when we parse a packet
containing an unknown S2K algorithm, we do not know how
many octets to attribute to the S2K’s parameters. In this
case, parameters
is set to None
. Note that the
information is not lost, but stored in the packet. If the
packet is serialized again, it is written out.
Implementations
Creates a new iterated S2K
object.
Usually, you should use S2K
s Default
implementation to
create S2K
objects with sane default parameters. The
parameters are chosen with contemporary machines in mind, and
should also be usable on lower-end devices like smart phones.
Using this method, you can tune the parameters for embedded devices. Note, however, that this also decreases the work factor for attackers doing dictionary attacks.
Derives a key of the given size from a password.
Returns whether this S2K mechanism is supported.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for S2K
impl UnwindSafe for S2K
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self