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
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.
RSA secret key.
DSA
Fields
x: ProtectedMPI
Secret key log_g(y) in Zp.
NIST DSA secret key.
ElGamal
Fields
x: ProtectedMPI
Secret key log_g(y) in Zp.
ElGamal secret key.
EdDSA
Fields
scalar: ProtectedMPI
Secret scalar.
DJB’s “Twisted” Edwards curve DSA secret key.
ECDSA
Fields
scalar: ProtectedMPI
Secret scalar.
NIST’s Elliptic Curve DSA secret key.
ECDH
Fields
scalar: ProtectedMPI
Secret scalar.
Elliptic Curve Diffie-Hellman public key.
Unknown
Fields
mpis: Box<[ProtectedMPI]>
The successfully parsed MPIs.
rest: Protected
Any data that failed to parse.
Unknown number of MPIs for an unknown algorithm.
Implementations
sourceimpl 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.
sourceimpl 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>
Leaks secrets into the heap, use [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>
Leaks secrets into the heap, use [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.
sourceimpl 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
sourceimpl Clone for SecretKeyMaterial
impl Clone for SecretKeyMaterial
sourcefn clone(&self) -> SecretKeyMaterial
fn clone(&self) -> SecretKeyMaterial
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SecretKeyMaterial
impl Debug for SecretKeyMaterial
sourceimpl From<SecretKeyMaterial> for SecretKeyMaterial
impl From<SecretKeyMaterial> for SecretKeyMaterial
sourcefn from(mpis: SecretKeyMaterial) -> Self
fn from(mpis: SecretKeyMaterial) -> Self
Converts to this type from the input type.
sourceimpl From<SecretKeyMaterial> for Unencrypted
impl From<SecretKeyMaterial> for Unencrypted
sourcefn from(mpis: SecretKeyMaterial) -> Self
fn from(mpis: SecretKeyMaterial) -> Self
Converts to this type from the input type.
sourceimpl Hash for SecretKeyMaterial
impl Hash for SecretKeyMaterial
sourceimpl Hash for SecretKeyMaterial
impl Hash for SecretKeyMaterial
sourceimpl Marshal for SecretKeyMaterial
impl Marshal for SecretKeyMaterial
sourceimpl MarshalInto for SecretKeyMaterial
impl MarshalInto for SecretKeyMaterial
sourcefn serialized_len(&self) -> usize
fn serialized_len(&self) -> usize
Computes the maximal length of the serialized representation. Read more
sourcefn serialize_into(&self, buf: &mut [u8]) -> Result<usize>
fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>
Serializes into the given buffer. Read more
sourceimpl Ord for SecretKeyMaterial
impl Ord for SecretKeyMaterial
sourceimpl PartialOrd<SecretKeyMaterial> for SecretKeyMaterial
impl PartialOrd<SecretKeyMaterial> for SecretKeyMaterial
sourcefn partial_cmp(&self, other: &SecretKeyMaterial) -> Option<Ordering>
fn partial_cmp(&self, other: &SecretKeyMaterial) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for SecretKeyMaterial
Auto Trait Implementations
impl RefUnwindSafe for SecretKeyMaterial
impl Send for SecretKeyMaterial
impl Sync for SecretKeyMaterial
impl Unpin for SecretKeyMaterial
impl UnwindSafe for SecretKeyMaterial
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more