diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2021-09-20 12:00:50 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2021-09-28 13:46:50 +0200 |
commit | 7eeba4c3dfccdf4cb11699a6b02d7e73ccd22654 (patch) | |
tree | 095c51d119fb8baa62246118c89545444159b658 /openpgp | |
parent | fda86c1b3054b029263859b553544e4fce077fac (diff) |
openpgp: Add example that prints the supported algorithms.
- Also run this example in the CI so that we can see what algorithms
are supported by which backend.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/examples/supported-algorithms.rs | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/openpgp/examples/supported-algorithms.rs b/openpgp/examples/supported-algorithms.rs new file mode 100644 index 00000000..570cdc96 --- /dev/null +++ b/openpgp/examples/supported-algorithms.rs @@ -0,0 +1,100 @@ +//! This example prints all algorithms supported by the currently +//! selected cryptographic backend. + +use sequoia_openpgp as openpgp; +use openpgp::types::*; +use openpgp::cert::CipherSuite; + +fn main() { + println!("Cipher suites:"); + for a in &[ + CipherSuite::Cv25519, + CipherSuite::P256, + CipherSuite::P384, + CipherSuite::P521, + CipherSuite::RSA2k, + CipherSuite::RSA3k, + CipherSuite::RSA4k, + ] { + println!(" - {:70} {:?}", format!("{:?}", a), a.is_supported().is_ok()); + } + println!(); + + println!("Public-Key algorithms:"); + for a in &[ + PublicKeyAlgorithm::RSAEncryptSign, + PublicKeyAlgorithm::ElGamalEncrypt, + PublicKeyAlgorithm::DSA, + PublicKeyAlgorithm::ECDH, + PublicKeyAlgorithm::ECDSA, + PublicKeyAlgorithm::EdDSA, + ] { + println!(" - {:70} {:?}", a.to_string(), a.is_supported()); + } + println!(); + + println!("ECC algorithms:"); + for a in &[ + Curve::NistP256, + Curve::NistP384, + Curve::NistP521, + Curve::BrainpoolP256, + Curve::BrainpoolP512, + Curve::Ed25519, + Curve::Cv25519, + ] { + println!(" - {:70} {:?}", a.to_string(), a.is_supported()); + } + println!(); + + println!("Symmetric algorithms:"); + for a in &[ + SymmetricAlgorithm::IDEA, + SymmetricAlgorithm::TripleDES, + SymmetricAlgorithm::CAST5, + SymmetricAlgorithm::Blowfish, + SymmetricAlgorithm::AES128, + SymmetricAlgorithm::AES192, + SymmetricAlgorithm::AES256, + SymmetricAlgorithm::Twofish, + SymmetricAlgorithm::Camellia128, + SymmetricAlgorithm::Camellia192, + SymmetricAlgorithm::Camellia256, + ] { + println!(" - {:70} {:?}", a.to_string(), a.is_supported()); + } + println!(); + + println!("AEAD algorithms:"); + for a in &[ + AEADAlgorithm::EAX, + AEADAlgorithm::OCB, + ] { + println!(" - {:70} {:?}", a.to_string(), a.is_supported()); + } + println!(); + + println!("Hash algorithms:"); + for a in &[ + HashAlgorithm::MD5, + HashAlgorithm::SHA1, + HashAlgorithm::RipeMD, + HashAlgorithm::SHA256, + HashAlgorithm::SHA384, + HashAlgorithm::SHA512, + HashAlgorithm::SHA224, + ] { + println!(" - {:70} {:?}", a.to_string(), a.is_supported()); + } + println!(); + + println!("Compression algorithms:"); + for a in &[ + CompressionAlgorithm::Zip, + CompressionAlgorithm::Zlib, + CompressionAlgorithm::BZip2, + ] { + println!(" - {:70} {:?}", a.to_string(), a.is_supported()); + } + println!(); +} |