Enum sequoia_openpgp::crypto::mpi::SecretKeyMaterial
source · #[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,
},
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
.
Note: This enum cannot be exhaustively matched to allow future extensions.
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.
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 4880 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 4880 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§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SecretKeyMaterial
impl Debug for SecretKeyMaterial
source§impl From<SecretKeyMaterial> for SecretKeyMaterial
impl From<SecretKeyMaterial> for SecretKeyMaterial
source§fn from(mpis: SecretKeyMaterial) -> Self
fn from(mpis: SecretKeyMaterial) -> Self
source§impl From<SecretKeyMaterial> for Unencrypted
impl From<SecretKeyMaterial> for Unencrypted
source§fn from(mpis: SecretKeyMaterial) -> Self
fn from(mpis: SecretKeyMaterial) -> Self
source§impl Hash for SecretKeyMaterial
impl Hash for SecretKeyMaterial
source§impl Hash for SecretKeyMaterial
impl Hash for SecretKeyMaterial
source§impl Marshal for SecretKeyMaterial
impl Marshal for SecretKeyMaterial
source§impl MarshalInto for SecretKeyMaterial
impl MarshalInto for SecretKeyMaterial
source§fn serialized_len(&self) -> usize
fn serialized_len(&self) -> usize
source§fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>
fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>
source§impl Ord for SecretKeyMaterial
impl Ord for SecretKeyMaterial
source§impl PartialEq for SecretKeyMaterial
impl PartialEq for SecretKeyMaterial
source§impl PartialOrd for SecretKeyMaterial
impl PartialOrd for SecretKeyMaterial
source§fn partial_cmp(&self, other: &SecretKeyMaterial) -> Option<Ordering>
fn partial_cmp(&self, other: &SecretKeyMaterial) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for SecretKeyMaterial
Auto Trait Implementations§
impl Freeze for SecretKeyMaterial
impl RefUnwindSafe for SecretKeyMaterial
impl Send for SecretKeyMaterial
impl Sync for SecretKeyMaterial
impl Unpin for SecretKeyMaterial
impl UnwindSafe for SecretKeyMaterial
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)