Enum sequoia_openpgp::crypto::mpi::PublicKey
source · #[non_exhaustive]
pub enum PublicKey {
RSA {
e: MPI,
n: MPI,
},
DSA {
p: MPI,
q: MPI,
g: MPI,
y: MPI,
},
ElGamal {
p: MPI,
g: MPI,
y: MPI,
},
EdDSA {
curve: Curve,
q: MPI,
},
ECDSA {
curve: Curve,
q: MPI,
},
ECDH {
curve: Curve,
q: MPI,
hash: HashAlgorithm,
sym: SymmetricAlgorithm,
},
Unknown {
mpis: Box<[MPI]>,
rest: Box<[u8]>,
},
}
Expand description
A public key.
Provides a typed and structured way of storing multiple MPIs (and
the occasional elliptic curve) in Key
packets.
Note: This enum cannot be exhaustively matched to allow future extensions.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
RSA
RSA public key.
DSA
Fields
NIST DSA public key.
ElGamal
ElGamal public key.
EdDSA
DJB’s “Twisted” Edwards curve DSA public key.
ECDSA
NIST’s Elliptic Curve DSA public key.
ECDH
Fields
hash: HashAlgorithm
Algorithm used to derive the Key Encapsulation Key.
sym: SymmetricAlgorithm
Algorithm used to encapsulate the session key.
Elliptic Curve Diffie-Hellman public key.
Unknown
Unknown number of MPIs for an unknown algorithm.
Implementations§
source§impl PublicKey
impl PublicKey
sourcepub fn bits(&self) -> Option<usize>
pub fn bits(&self) -> Option<usize>
Returns the length of the public key in bits.
For finite field crypto this returns the size of the field we
operate in, for ECC it returns Curve::bits()
.
Note: This information is useless and should not be used to gauge the security of a particular key. This function exists only because some legacy PGP application like HKP need it.
Returns None
for unknown keys and curves.
sourcepub fn algo(&self) -> Option<PublicKeyAlgorithm>
pub fn algo(&self) -> Option<PublicKeyAlgorithm>
Returns, if known, the public-key algorithm for this public key.
Trait Implementations§
source§impl MarshalInto for PublicKey
impl MarshalInto for PublicKey
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 PublicKey
impl Ord for PublicKey
source§impl PartialEq<PublicKey> for PublicKey
impl PartialEq<PublicKey> for PublicKey
source§impl PartialOrd<PublicKey> for PublicKey
impl PartialOrd<PublicKey> for PublicKey
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 more