summaryrefslogtreecommitdiffstats
path: root/openpgp/src/constants.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-04-04 14:31:26 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-04-24 11:11:03 +0200
commit0f8fa3961c60b575765e5aec598ac552b78b7e17 (patch)
tree0d25a9f3aab8add2e97e4734584f9bde1e65b43b /openpgp/src/constants.rs
parent36f757acfe2dcef3352527c2850379771b16bee4 (diff)
openpgp: Make {PublicKey,Curve}::bits() return key lengths.
- Clarify the documentation. - Fix the length of DSA and {Ed,Cv}25519 keys. - Add a test. - Fixes #244.
Diffstat (limited to 'openpgp/src/constants.rs')
-rw-r--r--openpgp/src/constants.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/openpgp/src/constants.rs b/openpgp/src/constants.rs
index d20decaa..308d1684 100644
--- a/openpgp/src/constants.rs
+++ b/openpgp/src/constants.rs
@@ -181,12 +181,14 @@ pub enum Curve {
}
impl Curve {
- /// Returns the 'bits' of the curve.
+ /// Returns the length of public keys over this curve in bits.
///
- /// For the Kobliz curves this is the size of the underlying finite field.
- /// For X25519 it's 128. This information is useless and should not be used
- /// to gauge the security of a particular curve. This function exists only
- /// because some legacy PGP application like HKP need it.
+ /// For the Kobliz curves this is the size of the underlying
+ /// finite field. For X25519 it is 256.
+ ///
+ /// Note: This information is useless and should not be used to
+ /// gauge the security of a particular curve. This function exists
+ /// only because some legacy PGP application like HKP need it.
pub fn bits(&self) -> usize {
use self::Curve::*;
@@ -196,8 +198,8 @@ impl Curve {
NistP521 => 521,
BrainpoolP256 => 256,
BrainpoolP512 => 512,
- Ed25519 => 128,
- Cv25519 => 128,
+ Ed25519 => 256,
+ Cv25519 => 256,
Unknown(_) => 0,
}
}