#[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,
},
X25519 {
u: [u8; 32],
},
X448 {
u: Box<[u8; 56]>,
},
Ed25519 {
a: [u8; 32],
},
Ed448 {
a: Box<[u8; 57]>,
},
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.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
RSA
RSA public key.
DSA
NIST DSA public key.
Fields
ElGamal
ElGamal public key.
EdDSA
DJB’s “Twisted” Edwards curve DSA public key.
ECDSA
NIST’s Elliptic Curve DSA public key.
ECDH
Elliptic Curve Diffie-Hellman public key.
Fields
hash: HashAlgorithm
Algorithm used to derive the Key Encapsulation Key.
sym: SymmetricAlgorithm
Algorithm used to encapsulate the session key.
X25519
X25519 public key.
X448
X448 public key.
Ed25519
Ed25519 public key.
Ed448
Ed448 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.