diff options
author | Wiktor Kwapisiewicz <wiktor@metacode.biz> | 2022-06-08 09:51:01 +0200 |
---|---|---|
committer | Wiktor Kwapisiewicz <wiktor@metacode.biz> | 2022-06-08 12:08:50 +0200 |
commit | 3c68b93492661a9fcf0d229936c4413a9943238f (patch) | |
tree | 1e86243c09bfe012fbf97958d090ed98f26ab272 /openpgp/src/types | |
parent | 2a62b3fa9d2845be6a067632d616b514ad0aa12c (diff) |
openpgp: Make PublicKeyAlgorithm descriptions shorter.
- Make the previously long description available using the "alternate"
(#) format specifier.
- Make the default description short.
- Update subplot tests to use short algorithm names.
- Fixes #803.
Diffstat (limited to 'openpgp/src/types')
-rw-r--r-- | openpgp/src/types/mod.rs | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/openpgp/src/types/mod.rs b/openpgp/src/types/mod.rs index 29775a16..f3c80a4d 100644 --- a/openpgp/src/types/mod.rs +++ b/openpgp/src/types/mod.rs @@ -242,21 +242,40 @@ impl From<PublicKeyAlgorithm> for u8 { impl fmt::Display for PublicKeyAlgorithm { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use crate::PublicKeyAlgorithm::*; - #[allow(deprecated)] - match *self { - RSAEncryptSign => f.write_str("RSA (Encrypt or Sign)"), - RSAEncrypt => f.write_str("RSA Encrypt-Only"), - RSASign => f.write_str("RSA Sign-Only"), - ElGamalEncrypt => f.write_str("ElGamal (Encrypt-Only)"), - DSA => f.write_str("DSA (Digital Signature Algorithm)"), - ECDSA => f.write_str("ECDSA public key algorithm"), - ElGamalEncryptSign => f.write_str("ElGamal (Encrypt or Sign)"), - ECDH => f.write_str("ECDH public key algorithm"), - EdDSA => f.write_str("EdDSA Edwards-curve Digital Signature Algorithm"), - Private(u) => - f.write_fmt(format_args!("Private/Experimental public key algorithm {}", u)), - Unknown(u) => - f.write_fmt(format_args!("Unknown public key algorithm {}", u)), + if f.alternate() { + #[allow(deprecated)] + match *self { + RSAEncryptSign => f.write_str("RSA (Encrypt or Sign)"), + RSAEncrypt => f.write_str("RSA Encrypt-Only"), + RSASign => f.write_str("RSA Sign-Only"), + ElGamalEncrypt => f.write_str("ElGamal (Encrypt-Only)"), + DSA => f.write_str("DSA (Digital Signature Algorithm)"), + ECDSA => f.write_str("ECDSA public key algorithm"), + ElGamalEncryptSign => f.write_str("ElGamal (Encrypt or Sign)"), + ECDH => f.write_str("ECDH public key algorithm"), + EdDSA => f.write_str("EdDSA Edwards-curve Digital Signature Algorithm"), + Private(u) => + f.write_fmt(format_args!("Private/Experimental public key algorithm {}", u)), + Unknown(u) => + f.write_fmt(format_args!("Unknown public key algorithm {}", u)), + } + } else { + #[allow(deprecated)] + match *self { + RSAEncryptSign => f.write_str("RSA"), + RSAEncrypt => f.write_str("RSA"), + RSASign => f.write_str("RSA"), + ElGamalEncrypt => f.write_str("ElGamal"), + DSA => f.write_str("DSA"), + ECDSA => f.write_str("ECDSA"), + ElGamalEncryptSign => f.write_str("ElGamal"), + ECDH => f.write_str("ECDH"), + EdDSA => f.write_str("EdDSA"), + Private(u) => + f.write_fmt(format_args!("Private algo {}", u)), + Unknown(u) => + f.write_fmt(format_args!("Unknown algo {}", u)), + } } } } |