#[non_exhaustive]pub enum SecretKeyMaterial {
RSA {
d: ProtectedMPI,
p: ProtectedMPI,
q: ProtectedMPI,
u: ProtectedMPI,
},
DSA {
x: ProtectedMPI,
},
ElGamal {
x: ProtectedMPI,
},
EdDSA {
scalar: ProtectedMPI,
},
ECDSA {
scalar: ProtectedMPI,
},
ECDH {
scalar: ProtectedMPI,
},
X25519 {
x: Protected,
},
X448 {
x: Protected,
},
Ed25519 {
x: Protected,
},
Ed448 {
x: Protected,
},
Unknown {
mpis: Box<[ProtectedMPI]>,
rest: Protected,
},
}
Expand description
A secret key.
Provides a typed and structured way of storing multiple MPIs in
Key
packets. Secret key components are protected by storing
them using ProtectedMPI
.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
RSA
RSA secret key.
Fields
d: ProtectedMPI
Secret exponent, inverse of e in Phi(N).
p: ProtectedMPI
Smaller secret prime.
q: ProtectedMPI
Larger secret prime.
u: ProtectedMPI
Inverse of p mod q.
DSA
NIST DSA secret key.
Fields
x: ProtectedMPI
Secret key log_g(y) in Zp.
ElGamal
ElGamal secret key.
Fields
x: ProtectedMPI
Secret key log_g(y) in Zp.
EdDSA
DJB’s “Twisted” Edwards curve DSA secret key.
Fields
scalar: ProtectedMPI
Secret scalar.
ECDSA
NIST’s Elliptic Curve DSA secret key.
Fields
scalar: ProtectedMPI
Secret scalar.
ECDH
Elliptic Curve Diffie-Hellman secret key.
Fields
scalar: ProtectedMPI
Secret scalar.
X25519
X25519 secret key.
X448
X448 secret key.
Ed25519
Ed25519 secret key.
Ed448
Ed448 secret key.
Unknown
Unknown number of MPIs for an unknown algorithm.
Fields
mpis: Box<[ProtectedMPI]>
The successfully parsed MPIs.
Implementations§
Source§impl SecretKeyMaterial
impl SecretKeyMaterial
Sourcepub fn algo(&self) -> Option<PublicKeyAlgorithm>
pub fn algo(&self) -> Option<PublicKeyAlgorithm>
Returns, if known, the public-key algorithm for this secret key.
Source§impl SecretKeyMaterial
impl SecretKeyMaterial
Sourcepub fn parse_with_checksum<R: Read + Send + Sync>(
algo: PublicKeyAlgorithm,
reader: R,
checksum: SecretKeyChecksum,
) -> Result<Self>
👎Deprecated since 1.14.0: Leaks secrets into the heap, use [SecretKeyMaterial::from_bytes_with_checksum
]
pub fn parse_with_checksum<R: Read + Send + Sync>( algo: PublicKeyAlgorithm, reader: R, checksum: SecretKeyChecksum, ) -> Result<Self>
SecretKeyMaterial::from_bytes_with_checksum
]Parses secret key MPIs for algo
plus their SHA1 checksum.
Fails if the checksum is wrong.
Sourcepub fn from_bytes_with_checksum(
algo: PublicKeyAlgorithm,
bytes: &[u8],
checksum: SecretKeyChecksum,
) -> Result<Self>
pub fn from_bytes_with_checksum( algo: PublicKeyAlgorithm, bytes: &[u8], checksum: SecretKeyChecksum, ) -> Result<Self>
Parses secret key MPIs for algo
plus their SHA1 checksum.
Fails if the checksum is wrong.
Sourcepub fn parse<R: Read + Send + Sync>(
algo: PublicKeyAlgorithm,
reader: R,
) -> Result<Self>
👎Deprecated since 1.14.0: Leaks secrets into the heap, use [SecretKeyMaterial::from_bytes
]
pub fn parse<R: Read + Send + Sync>( algo: PublicKeyAlgorithm, reader: R, ) -> Result<Self>
SecretKeyMaterial::from_bytes
]Parses a set of OpenPGP MPIs representing a secret key.
See Section 3.2 of RFC 9580 for details.
Sourcepub fn from_bytes(algo: PublicKeyAlgorithm, buf: &[u8]) -> Result<Self>
pub fn from_bytes(algo: PublicKeyAlgorithm, buf: &[u8]) -> Result<Self>
Parses a set of OpenPGP MPIs representing a secret key.
See Section 3.2 of RFC 9580 for details.
Source§impl SecretKeyMaterial
impl SecretKeyMaterial
Sourcepub fn serialize_with_checksum(
&self,
w: &mut dyn Write,
checksum: SecretKeyChecksum,
) -> Result<()>
pub fn serialize_with_checksum( &self, w: &mut dyn Write, checksum: SecretKeyChecksum, ) -> Result<()>
Writes this secret key with a checksum to w
.
Trait Implementations§
Source§impl Clone for SecretKeyMaterial
impl Clone for SecretKeyMaterial
Source§fn clone(&self) -> SecretKeyMaterial
fn clone(&self) -> SecretKeyMaterial
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more