diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-07-31 16:29:17 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-07-31 17:58:01 +0200 |
commit | c078883804835ea3ec975b9e8beee8cae7f367c1 (patch) | |
tree | 4b7efd17774a1c7c931982af8a00138e08840557 | |
parent | 6fd80726a4d0aeeec263b2127366cca42936b4f0 (diff) |
openpgp: Rename MPI::new_weierstrass to MPI::new_point.
-rw-r--r-- | openpgp/src/crypto/backend/nettle/asymmetric.rs | 4 | ||||
-rw-r--r-- | openpgp/src/crypto/backend/nettle/ecdh.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/mpi.rs | 11 |
3 files changed, 12 insertions, 5 deletions
diff --git a/openpgp/src/crypto/backend/nettle/asymmetric.rs b/openpgp/src/crypto/backend/nettle/asymmetric.rs index d2f8e29b..6445fd71 100644 --- a/openpgp/src/crypto/backend/nettle/asymmetric.rs +++ b/openpgp/src/crypto/backend/nettle/asymmetric.rs @@ -548,7 +548,7 @@ impl<R> Key4<SecretParts, R> let (pub_x, pub_y) = public.as_bytes(); let public_mpis = mpi::PublicKey::ECDSA{ curve, - q: MPI::new_weierstrass(&pub_x, &pub_y, field_sz), + q: MPI::new_point(&pub_x, &pub_y, field_sz), }; let private_mpis = mpi::SecretKeyMaterial::ECDSA{ scalar: MPI::new(&private.as_bytes()).into(), @@ -585,7 +585,7 @@ impl<R> Key4<SecretParts, R> let (pub_x, pub_y) = public.as_bytes(); let public_mpis = mpi::PublicKey::ECDH{ curve, - q: MPI::new_weierstrass(&pub_x, &pub_y, field_sz), + q: MPI::new_point(&pub_x, &pub_y, field_sz), hash, sym: SymmetricAlgorithm::AES256, }; diff --git a/openpgp/src/crypto/backend/nettle/ecdh.rs b/openpgp/src/crypto/backend/nettle/ecdh.rs index 7e8f6b00..f85dbde6 100644 --- a/openpgp/src/crypto/backend/nettle/ecdh.rs +++ b/openpgp/src/crypto/backend/nettle/ecdh.rs @@ -83,7 +83,7 @@ pub fn encrypt<R>(recipient: &Key<key::PublicParts, R>, // Compute the public key. let VB = ecdh::point_mul_g(&v); let (VBx, VBy) = VB.as_bytes(); - let VB = MPI::new_weierstrass(&VBx, &VBy, field_sz); + let VB = MPI::new_point(&VBx, &VBy, field_sz); // Compute the shared point S = vR; let S = ecdh::point_mul(&v, &R)?; diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs index 1f19b382..6b5bec4b 100644 --- a/openpgp/src/crypto/mpi.rs +++ b/openpgp/src/crypto/mpi.rs @@ -55,8 +55,15 @@ impl MPI { } } - /// Creates new MPI for EC point. - pub fn new_weierstrass(x: &[u8], y: &[u8], field_bits: usize) -> Self { + /// Creates new MPI encoding an uncompressed EC point. + /// + /// Encodes the given point on a elliptic curve (see [Section 6 of + /// RFC 6637] for details). This is used to encode public keys + /// and ciphertexts for the NIST curves (`NistP256`, `NistP384`, + /// and `NistP521`). + /// + /// [Section 6 of RFC 6637]: https://tools.ietf.org/html/rfc6637#section-6 + pub fn new_point(x: &[u8], y: &[u8], field_bits: usize) -> Self { let field_sz = if field_bits % 8 > 0 { 1 } else { 0 } + field_bits / 8; let mut val = vec![0x0u8; 1 + 2 * field_sz]; let x_missing = field_sz - x.len(); |