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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
RSAEncryptSign
RSA (Encrypt or Sign)
RSAEncrypt
👎Deprecated: Use
PublicKeyAlgorithm::RSAEncryptSign.RSA Encrypt-Only, deprecated in RFC 4880.
RSASign
👎Deprecated: 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
👎Deprecated: 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§
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::ElGamalEncrypt.is_supported());
assert!(!PublicKeyAlgorithm::Private(101).is_supported());Trait Implementations§
source§impl Clone for PublicKeyAlgorithm
impl Clone for PublicKeyAlgorithm
source§fn clone(&self) -> PublicKeyAlgorithm
fn clone(&self) -> PublicKeyAlgorithm
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for PublicKeyAlgorithm
impl Debug for PublicKeyAlgorithm
source§impl Display for PublicKeyAlgorithm
impl Display for PublicKeyAlgorithm
source§impl From<PublicKeyAlgorithm> for u8
impl From<PublicKeyAlgorithm> for u8
source§fn from(p: PublicKeyAlgorithm) -> u8
fn from(p: PublicKeyAlgorithm) -> u8
Converts to this type from the input type.
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,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<PublicKeyAlgorithm> for PublicKeyAlgorithm
impl PartialEq<PublicKeyAlgorithm> for PublicKeyAlgorithm
source§fn 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 ==.source§impl PartialOrd<PublicKeyAlgorithm> for PublicKeyAlgorithm
impl PartialOrd<PublicKeyAlgorithm> 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
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl 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§
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
Mutably borrows from an owned value. Read more