diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2023-05-12 16:22:29 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2023-05-22 12:00:10 +0200 |
commit | d7ba06e299e3f8f76a744d9728b86c80d05f19da (patch) | |
tree | 17c3c3b5e8d5f1bb17c289c082e03cba6ccd6863 /openpgp/src/crypto/backend/openssl | |
parent | 3646644294ed07a5731168ec4a0a9361e39e6793 (diff) |
openpgp: Deduplicate EdDSA signature verification.
Diffstat (limited to 'openpgp/src/crypto/backend/openssl')
-rw-r--r-- | openpgp/src/crypto/backend/openssl/asymmetric.rs | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/openpgp/src/crypto/backend/openssl/asymmetric.rs b/openpgp/src/crypto/backend/openssl/asymmetric.rs index 77ee9ff5..b5e3ab02 100644 --- a/openpgp/src/crypto/backend/openssl/asymmetric.rs +++ b/openpgp/src/crypto/backend/openssl/asymmetric.rs @@ -393,29 +393,6 @@ impl<P: key::KeyParts, R: key::KeyRole> Key<P, R> { ctx.verify_init()?; ctx.verify(&digest, &signature.to_der()?)? } - (mpi::PublicKey::EdDSA { curve, q }, mpi::Signature::EdDSA { r, s }) => match curve { - Curve::Ed25519 => { - let public = q.decode_point(&Curve::Ed25519)?.0; - - let key = PKey::public_key_from_raw_bytes(public, openssl::pkey::Id::ED25519)?; - - const SIGNATURE_LENGTH: usize = 64; - - // ed25519 expects full-sized signatures but OpenPGP allows - // for stripped leading zeroes, pad each part with zeroes. - let mut sig_bytes = [0u8; SIGNATURE_LENGTH]; - - // We need to zero-pad them at the front, because - // the MPI encoding drops leading zero bytes. - let half = SIGNATURE_LENGTH / 2; - sig_bytes[..half].copy_from_slice(&r.value_padded(half)?); - sig_bytes[half..].copy_from_slice(&s.value_padded(half)?); - - let mut verifier = Verifier::new_without_digest(&key)?; - verifier.verify_oneshot(&sig_bytes, digest)? - } - _ => return Err(crate::Error::UnsupportedEllipticCurve(curve.clone()).into()), - }, (mpi::PublicKey::ECDSA { curve, q }, mpi::Signature::ECDSA { s, r }) => { let nid = curve.try_into()?; let group = EcGroup::from_curve_name(nid)?; |