Enum sequoia_openpgp::types::PublicKeyAlgorithm
source · [−]#[non_exhaustive]
pub enum PublicKeyAlgorithm {
RSAEncryptSign,
RSAEncrypt,
RSASign,
ElGamalEncrypt,
DSA,
ECDH,
ECDSA,
ElGamalEncryptSign,
EdDSA,
Private(u8),
Unknown(u8),
}
Expand description
The OpenPGP public key algorithms as defined in Section 9.1 of RFC 4880, and Section 5 of RFC 6637.
Note: This enum cannot be exhaustively matched to allow future extensions.
Examples
use sequoia_openpgp as openpgp;
use openpgp::cert::prelude::*;
use openpgp::types::PublicKeyAlgorithm;
let (cert, _) = CertBuilder::new()
.set_cipher_suite(CipherSuite::Cv25519)
.generate()?;
assert_eq!(cert.primary_key().pk_algo(), PublicKeyAlgorithm::EdDSA);
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
RSAEncryptSign
RSA (Encrypt or Sign)
RSAEncrypt
Use PublicKeyAlgorithm::RSAEncryptSign
.
RSA Encrypt-Only, deprecated in RFC 4880.
RSASign
Use PublicKeyAlgorithm::RSAEncryptSign
.
RSA Sign-Only, deprecated in RFC 4880.
ElGamalEncrypt
ElGamal (Encrypt-Only)
DSA
DSA (Digital Signature Algorithm)
ECDH
Elliptic curve DH
ECDSA
Elliptic curve DSA
ElGamalEncryptSign
If you really must, use PublicKeyAlgorithm::ElGamalEncrypt
.
ElGamal (Encrypt or Sign), deprecated in RFC 4880.
EdDSA
“Twisted” Edwards curve DSA
Private(u8)
Private algorithm identifier.
Unknown(u8)
Unknown algorithm identifier.
Implementations
sourceimpl PublicKeyAlgorithm
impl PublicKeyAlgorithm
sourcepub fn for_signing(&self) -> bool
pub fn for_signing(&self) -> bool
Returns true if the algorithm can sign data.
Examples
use sequoia_openpgp as openpgp;
use openpgp::types::PublicKeyAlgorithm;
assert!(PublicKeyAlgorithm::EdDSA.for_signing());
assert!(PublicKeyAlgorithm::RSAEncryptSign.for_signing());
assert!(!PublicKeyAlgorithm::ElGamalEncrypt.for_signing());
sourcepub fn for_encryption(&self) -> bool
pub fn for_encryption(&self) -> bool
Returns true if the algorithm can encrypt data.
Examples
use sequoia_openpgp as openpgp;
use openpgp::types::PublicKeyAlgorithm;
assert!(!PublicKeyAlgorithm::EdDSA.for_encryption());
assert!(PublicKeyAlgorithm::RSAEncryptSign.for_encryption());
assert!(PublicKeyAlgorithm::ElGamalEncrypt.for_encryption());
sourcepub fn is_supported(&self) -> bool
pub fn is_supported(&self) -> bool
Returns whether this algorithm is supported.
Examples
use sequoia_openpgp as openpgp;
use openpgp::types::PublicKeyAlgorithm;
assert!(PublicKeyAlgorithm::EdDSA.is_supported());
assert!(PublicKeyAlgorithm::RSAEncryptSign.is_supported());
assert!(!PublicKeyAlgorithm::Private(101).is_supported());
sourcepub fn variants() -> impl Iterator<Item = Self>
pub fn variants() -> impl Iterator<Item = Self>
Returns an iterator over all valid variants.
Returns an iterator over all known variants. This does not
include the PublicKeyAlgorithm::Private
, or
PublicKeyAlgorithm::Unknown
variants.
Trait Implementations
sourceimpl Clone for PublicKeyAlgorithm
impl Clone for PublicKeyAlgorithm
sourcefn clone(&self) -> PublicKeyAlgorithm
fn clone(&self) -> PublicKeyAlgorithm
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 PublicKeyAlgorithm
impl Debug for PublicKeyAlgorithm
sourceimpl Display for PublicKeyAlgorithm
impl Display for PublicKeyAlgorithm
Formats the public key algorithm name.
There are two ways the public key algorithm name can be formatted. By default the short name is used. The alternate format uses the full public key algorithm name.
Examples
use sequoia_openpgp as openpgp;
use openpgp::types::PublicKeyAlgorithm;
// default, short format
assert_eq!("ECDH", format!("{}", PublicKeyAlgorithm::ECDH));
// alternate, long format
assert_eq!("ECDH public key algorithm", format!("{:#}", PublicKeyAlgorithm::ECDH));
sourceimpl From<PublicKeyAlgorithm> for u8
impl From<PublicKeyAlgorithm> for u8
sourcefn from(p: PublicKeyAlgorithm) -> u8
fn from(p: PublicKeyAlgorithm) -> u8
Converts to this type from the input type.
sourceimpl From<u8> for PublicKeyAlgorithm
impl From<u8> for PublicKeyAlgorithm
sourceimpl Hash for PublicKeyAlgorithm
impl Hash for PublicKeyAlgorithm
sourceimpl Ord for PublicKeyAlgorithm
impl Ord for PublicKeyAlgorithm
sourceimpl PartialEq<PublicKeyAlgorithm> for PublicKeyAlgorithm
impl PartialEq<PublicKeyAlgorithm> for PublicKeyAlgorithm
sourcefn eq(&self, other: &PublicKeyAlgorithm) -> bool
fn eq(&self, other: &PublicKeyAlgorithm) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &PublicKeyAlgorithm) -> bool
fn ne(&self, other: &PublicKeyAlgorithm) -> bool
This method tests for !=
.
sourceimpl PartialOrd<PublicKeyAlgorithm> for PublicKeyAlgorithm
impl PartialOrd<PublicKeyAlgorithm> for PublicKeyAlgorithm
sourcefn partial_cmp(&self, other: &PublicKeyAlgorithm) -> Option<Ordering>
fn partial_cmp(&self, other: &PublicKeyAlgorithm) -> 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 Copy for PublicKeyAlgorithm
impl Eq for PublicKeyAlgorithm
impl StructuralEq for PublicKeyAlgorithm
impl StructuralPartialEq for PublicKeyAlgorithm
Auto Trait Implementations
impl RefUnwindSafe for PublicKeyAlgorithm
impl Send for PublicKeyAlgorithm
impl Sync for PublicKeyAlgorithm
impl Unpin for PublicKeyAlgorithm
impl UnwindSafe for PublicKeyAlgorithm
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