#[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
p: MPI
Prime of the ring Zp.
q: MPI
Order of g
in Zp.
g: MPI
Public generator of Zp.
y: MPI
Public key g^x mod p.
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
curve: Curve
Curve we’re using.
q: MPI
Public point.
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
sourceimpl 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.
sourceimpl PublicKey
impl PublicKey
sourcepub fn parse<R: Read + Send + Sync>(
algo: PublicKeyAlgorithm,
reader: R
) -> Result<Self>
pub fn parse<R: Read + Send + Sync>(
algo: PublicKeyAlgorithm,
reader: R
) -> Result<Self>
Parses a set of OpenPGP MPIs representing a public key.
See Section 3.2 of RFC 4880 for details.
Trait Implementations
sourceimpl MarshalInto for PublicKey
impl MarshalInto for PublicKey
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 PublicKey
impl Ord for PublicKey
sourceimpl PartialOrd<PublicKey> for PublicKey
impl PartialOrd<PublicKey> for PublicKey
sourcefn partial_cmp(&self, other: &PublicKey) -> Option<Ordering>
fn partial_cmp(&self, other: &PublicKey) -> 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 PublicKey
impl StructuralEq for PublicKey
impl StructuralPartialEq for PublicKey
Auto Trait Implementations
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnwindSafe for PublicKey
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