#[non_exhaustive]pub enum PublicKeyAlgorithm {
}
Expand description
The OpenPGP public key algorithms as defined in Section 9.1 of RFC 9580.
§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().key().pk_algo(), PublicKeyAlgorithm::EdDSA);
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
RSAEncryptSign
RSA (Encrypt or Sign)
RSAEncrypt
PublicKeyAlgorithm::RSAEncryptSign
.RSA Encrypt-Only, deprecated in RFC 4880.
RSASign
PublicKeyAlgorithm::RSAEncryptSign
.RSA Sign-Only, deprecated in RFC 4880.
ElGamalEncrypt
ElGamal (Encrypt-Only), deprecated in RFC 9580.
DSA
DSA (Digital Signature Algorithm)
ECDH
Elliptic curve DH
ECDSA
Elliptic curve DSA
ElGamalEncryptSign
ElGamal (Encrypt or Sign), deprecated in RFC 4880.
EdDSA
“Twisted” Edwards curve DSA
X25519
X25519 (RFC 7748).
X448
X448 (RFC 7748).
Ed25519
Ed25519 (RFC 8032).
Ed448
Ed448 (RFC 8032).
Private(u8)
Private algorithm identifier.
Unknown(u8)
Unknown algorithm identifier.
Implementations§
Source§impl 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§
Source§impl Clone for PublicKeyAlgorithm
impl Clone for PublicKeyAlgorithm
Source§fn clone(&self) -> PublicKeyAlgorithm
fn clone(&self) -> PublicKeyAlgorithm
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PublicKeyAlgorithm
impl Debug for PublicKeyAlgorithm
Source§impl Display for PublicKeyAlgorithm
Formats the public key algorithm name.
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));