diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-10-06 13:24:04 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-10-06 14:56:16 +0200 |
commit | 48d18fdff5f24526c3e83789f1ebfad763fa94af (patch) | |
tree | d0aa424d9589f28a2ead700a7f5b59efe600bd4d /openpgp/src/crypto/mpi.rs | |
parent | 93d84877304486bfcb2be664a1565f835bd60cf3 (diff) |
openpgp: Implement two-octet checksums over secret key material.
- Also, rename methods to be more explicit.
Diffstat (limited to 'openpgp/src/crypto/mpi.rs')
-rw-r--r-- | openpgp/src/crypto/mpi.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs index 1c6757b2..4964425e 100644 --- a/openpgp/src/crypto/mpi.rs +++ b/openpgp/src/crypto/mpi.rs @@ -859,6 +859,27 @@ impl Arbitrary for SecretKeyMaterial { } } +/// Checksum method for secret key material. +/// +/// Secret key material may be protected by a checksum. See [Section +/// 5.5.3 of RFC 4880] for details. +/// +/// [Section 5.5.3 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.5.3 +#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] +pub enum SecretKeyChecksum { + /// SHA1 over the decrypted secret key. + SHA1, + + /// Sum of the decrypted secret key octets modulo 65536. + Sum16, +} + +impl Default for SecretKeyChecksum { + fn default() -> Self { + SecretKeyChecksum::SHA1 + } +} + /// An encrypted session key. /// /// Provides a typed and structured way of storing multiple MPIs in |