summaryrefslogtreecommitdiffstats
path: root/openpgp/examples/supported-algorithms.rs
blob: 570cdc96a19390921d213d4f82f2ade5f1315d22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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!();
}