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
PublicKeyAlgorithm::RSAEncryptSign
.RSA Encrypt-Only, deprecated in RFC 4880.
RSASign
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
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§
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
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));
source§impl From<PublicKeyAlgorithm> for u8
impl From<PublicKeyAlgorithm> for u8
source§fn from(p: PublicKeyAlgorithm) -> u8
fn from(p: PublicKeyAlgorithm) -> u8
source§impl From<u8> for PublicKeyAlgorithm
impl From<u8> for 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 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for PublicKeyAlgorithm
impl PartialEq for PublicKeyAlgorithm
source§fn eq(&self, other: &PublicKeyAlgorithm) -> bool
fn eq(&self, other: &PublicKeyAlgorithm) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for PublicKeyAlgorithm
impl PartialOrd for PublicKeyAlgorithm
source§fn partial_cmp(&self, other: &PublicKeyAlgorithm) -> Option<Ordering>
fn partial_cmp(&self, other: &PublicKeyAlgorithm) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for PublicKeyAlgorithm
impl Eq 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 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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)