summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2023-03-01 16:25:59 +0100
committerJustus Winter <justus@sequoia-pgp.org>2023-03-01 18:08:57 +0100
commit913904754ddd585d93522bc45e8d9e830d278f9a (patch)
tree14e20277ddcdde82806e55586ef8748a5af27d90 /openpgp/src/crypto
parentea5606fd9cd2096301e7e4b690f9998d6a36bff9 (diff)
openpgp: Add support for brainpoolP384r1.
- One of the brainpool curves was not included in our enum Curve, because at the time we implemented ECC support, it wasn't part of the RFC4880bis document. - Unfortunately, we failed to mark enum Curve as non-exhaustive, so we cannot add a variant without breaking the API. - We can, however, support the curve by matching on its OID.
Diffstat (limited to 'openpgp/src/crypto')
-rw-r--r--openpgp/src/crypto/backend/openssl/asymmetric.rs6
-rw-r--r--openpgp/src/crypto/mpi.rs7
2 files changed, 9 insertions, 4 deletions
diff --git a/openpgp/src/crypto/backend/openssl/asymmetric.rs b/openpgp/src/crypto/backend/openssl/asymmetric.rs
index aef777bf..5a1dc295 100644
--- a/openpgp/src/crypto/backend/openssl/asymmetric.rs
+++ b/openpgp/src/crypto/backend/openssl/asymmetric.rs
@@ -70,8 +70,12 @@ impl TryFrom<&Curve> for Nid {
Curve::NistP384 => Nid::SECP384R1,
Curve::NistP521 => Nid::SECP521R1,
Curve::BrainpoolP256 => Nid::BRAINPOOL_P256R1,
+ Curve::Unknown(_) if curve.is_brainpoolp384() => Nid::BRAINPOOL_P384R1,
Curve::BrainpoolP512 => Nid::BRAINPOOL_P512R1,
- _ => return Err(crate::Error::UnsupportedEllipticCurve(curve.clone()).into()),
+ Curve::Ed25519 | // Handled differently.
+ Curve::Cv25519 | // Handled differently.
+ Curve::Unknown(_) =>
+ return Err(crate::Error::UnsupportedEllipticCurve(curve.clone()).into()),
})
}
}
diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs
index e2a93992..7cc94206 100644
--- a/openpgp/src/crypto/mpi.rs
+++ b/openpgp/src/crypto/mpi.rs
@@ -201,10 +201,14 @@ impl MPI {
Ok((&value[1..], &[]))
},
+ Unknown(_) if ! curve.is_brainpoolp384() =>
+ Err(Error::UnsupportedEllipticCurve(curve.clone()).into()),
+
NistP256
| NistP384
| NistP521
| BrainpoolP256
+ | Unknown(_)
| BrainpoolP512
=>
{
@@ -232,9 +236,6 @@ impl MPI {
Ok((&value[1..1 + coordinate_length],
&value[1 + coordinate_length..]))
},
-
- Unknown(_) =>
- Err(Error::UnsupportedEllipticCurve(curve.clone()).into()),
}
}