#[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
Use PublicKeyAlgorithm::RSAEncryptSign.
RSA Encrypt-Only, deprecated in RFC 4880.
RSASign
Use PublicKeyAlgorithm::RSAEncryptSign.
RSA Sign-Only, deprecated in RFC 4880.
ElGamalEncrypt
Use a newer public key algorithm instead.
ElGamal (Encrypt-Only), deprecated in RFC 9580.
DSA
Use a newer public key algorithm instead.
DSA (Digital Signature Algorithm)
ECDH
Elliptic curve DH
ECDSA
Elliptic curve DSA
ElGamalEncryptSign
Use a newer public key algorithm instead.
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).
MLDSA65_Ed25519
Composite signature algorithm using ML-DSA-65 and Ed25519.
MLDSA87_Ed448
Composite signature algorithm using ML-DSA-87 and Ed448.
SLHDSA128s
SLH-DSA-SHAKE signature algorithm 128 bit, small signatures.
Note: RFC 9980 only specifies the SHAKE variant of the SLH-DSA algorithm.
SLHDSA128f
SLH-DSA-SHAKE signature algorithm 128 bit, fast signatures.
Note: RFC 9980 only specifies the SHAKE variant of the SLH-DSA algorithm.
SLHDSA256s
SLH-DSA-SHAKE signature algorithm 256 bit, small signatures.
Note: RFC 9980 only specifies the SHAKE variant of the SLH-DSA algorithm.
MLKEM768_X25519
Composite KEM using ML-KEM-768 and X25519.
MLKEM1024_X448
Composite KEM using ML-KEM-1024 and X448.
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 = PublicKeyAlgorithm>
pub fn variants() -> impl Iterator<Item = PublicKeyAlgorithm>
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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PublicKeyAlgorithm
Source§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));impl Eq for PublicKeyAlgorithm
Source§impl From<u8> for PublicKeyAlgorithm
impl From<u8> for PublicKeyAlgorithm
Source§fn from(u: u8) -> PublicKeyAlgorithm
fn from(u: u8) -> PublicKeyAlgorithm
Source§impl Hash for PublicKeyAlgorithm
impl Hash for PublicKeyAlgorithm
Source§impl Ord for PublicKeyAlgorithm
impl Ord for PublicKeyAlgorithm
Source§fn cmp(&self, other: &PublicKeyAlgorithm) -> Ordering
fn cmp(&self, other: &PublicKeyAlgorithm) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PublicKeyAlgorithm
impl PartialEq for PublicKeyAlgorithm
Source§impl PartialOrd for PublicKeyAlgorithm
impl PartialOrd for PublicKeyAlgorithm
impl StructuralPartialEq for PublicKeyAlgorithm
Auto Trait Implementations§
impl Freeze for PublicKeyAlgorithm
impl RefUnwindSafe for PublicKeyAlgorithm
impl Send for PublicKeyAlgorithm
impl Sync for PublicKeyAlgorithm
impl Unpin for PublicKeyAlgorithm
impl UnsafeUnpin for PublicKeyAlgorithm
impl UnwindSafe for PublicKeyAlgorithm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSend for T
impl<T> MaybeSync for T
impl<T> Package for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more