summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-08-17 15:26:42 +0200
committerJustus Winter <justus@sequoia-pgp.org>2020-08-17 16:19:24 +0200
commit277a867b3c5dc32a362d07526f2789fcf9783d54 (patch)
tree3f69430642c1dc0122e1bc32548b693f298769d6
parentbc93b8a039753a626406f15a346f84ecaed49583 (diff)
openpgp: Rename {en,de}crypt_shared to better reflect their use.
-rw-r--r--ipc/src/sexp.rs2
-rw-r--r--openpgp/src/crypto/backend/cng/ecdh.rs8
-rw-r--r--openpgp/src/crypto/backend/nettle/ecdh.rs8
-rw-r--r--openpgp/src/crypto/ecdh.rs8
-rw-r--r--openpgp/src/packet/key.rs2
5 files changed, 14 insertions, 14 deletions
diff --git a/ipc/src/sexp.rs b/ipc/src/sexp.rs
index 38429557..a03b8634 100644
--- a/ipc/src/sexp.rs
+++ b/ipc/src/sexp.rs
@@ -131,7 +131,7 @@ impl Sexp {
// XXX: Erase shared point from s.
// Now finish the decryption.
- openpgp::crypto::ecdh::decrypt_shared(recipient, &S, ciphertext)
+ openpgp::crypto::ecdh::decrypt_unwrap(recipient, &S, ciphertext)
},
_ =>
diff --git a/openpgp/src/crypto/backend/cng/ecdh.rs b/openpgp/src/crypto/backend/cng/ecdh.rs
index 98e5cfcc..6df62bcf 100644
--- a/openpgp/src/crypto/backend/cng/ecdh.rs
+++ b/openpgp/src/crypto/backend/cng/ecdh.rs
@@ -7,7 +7,7 @@ use crate::packet::{key, Key};
use crate::types::Curve;
use crate::{Error, Result};
-use crate::crypto::ecdh::{encrypt_shared, decrypt_shared};
+use crate::crypto::ecdh::{encrypt_wrap, decrypt_unwrap};
use win_crypto_ng as cng;
use cng::asymmetric::{Ecdh, AsymmetricKey, Export};
@@ -56,7 +56,7 @@ where
// Returned secret is little-endian, flip it to big-endian
S.reverse();
- encrypt_shared(recipient, session_key, VB, &S)
+ encrypt_wrap(recipient, session_key, VB, &S)
}
Curve::NistP256 | Curve::NistP384 | Curve::NistP521 => {
let (Rx, Ry) = q.decode_point(curve)?;
@@ -132,7 +132,7 @@ where
_ => unreachable!(),
};
- encrypt_shared(recipient, session_key, VB, &S)
+ encrypt_wrap(recipient, session_key, VB, &S)
}
// Not implemented in Nettle
@@ -280,5 +280,5 @@ where
}
};
- decrypt_shared(recipient, &S, ciphertext)
+ decrypt_unwrap(recipient, &S, ciphertext)
}
diff --git a/openpgp/src/crypto/backend/nettle/ecdh.rs b/openpgp/src/crypto/backend/nettle/ecdh.rs
index f85dbde6..29e3d448 100644
--- a/openpgp/src/crypto/backend/nettle/ecdh.rs
+++ b/openpgp/src/crypto/backend/nettle/ecdh.rs
@@ -4,7 +4,7 @@ use nettle::{curve25519, ecc, ecdh, random::Yarrow};
use crate::{Error, Result};
use crate::crypto::SessionKey;
-use crate::crypto::ecdh::{encrypt_shared, decrypt_shared};
+use crate::crypto::ecdh::{encrypt_wrap, decrypt_unwrap};
use crate::crypto::mem::Protected;
use crate::crypto::mpi::{MPI, PublicKey, SecretKeyMaterial, Ciphertext};
use crate::packet::{key, Key};
@@ -43,7 +43,7 @@ pub fn encrypt<R>(recipient: &Key<key::PublicParts, R>,
curve25519::mul(&mut S, &v, R)
.expect("buffers are of the wrong size");
- encrypt_shared(recipient, session_key, VB, &S)
+ encrypt_wrap(recipient, session_key, VB, &S)
}
Curve::NistP256 | Curve::NistP384 | Curve::NistP521 => {
// Obtain the authenticated recipient public key R and
@@ -99,7 +99,7 @@ pub fn encrypt<R>(recipient: &Key<key::PublicParts, R>,
Sx.insert(0, 0);
}
- encrypt_shared(recipient, session_key, VB, &Sx.into())
+ encrypt_wrap(recipient, session_key, VB, &Sx.into())
}
// Not implemented in Nettle
@@ -217,7 +217,7 @@ pub fn decrypt<R>(recipient: &Key<key::PublicParts, R>,
}
};
- decrypt_shared(recipient, &S, ciphertext)
+ decrypt_unwrap(recipient, &S, ciphertext)
}
_ =>
diff --git a/openpgp/src/crypto/ecdh.rs b/openpgp/src/crypto/ecdh.rs
index bc3aa757..f3533d79 100644
--- a/openpgp/src/crypto/ecdh.rs
+++ b/openpgp/src/crypto/ecdh.rs
@@ -23,9 +23,9 @@ pub(crate) use crate::crypto::backend::ecdh::{encrypt, decrypt};
/// (i.e. with the 0x40 prefix for X25519, or 0x04 for the NIST
/// curves), `S` is the shared Diffie-Hellman secret.
#[allow(non_snake_case)]
-pub(crate) fn encrypt_shared<R>(recipient: &Key<key::PublicParts, R>,
- session_key: &SessionKey, VB: MPI,
- S: &Protected)
+pub(crate) fn encrypt_wrap<R>(recipient: &Key<key::PublicParts, R>,
+ session_key: &SessionKey, VB: MPI,
+ S: &Protected)
-> Result<mpi::Ciphertext>
where R: key::KeyRole
{
@@ -70,7 +70,7 @@ pub(crate) fn encrypt_shared<R>(recipient: &Key<key::PublicParts, R>,
/// `recipient` is the message receiver's public key, `S` is the
/// shared Diffie-Hellman secret used to encrypt `ciphertext`.
#[allow(non_snake_case)]
-pub fn decrypt_shared<R>(recipient: &Key<key::PublicParts, R>,
+pub fn decrypt_unwrap<R>(recipient: &Key<key::PublicParts, R>,
S: &Protected,
ciphertext: &mpi::Ciphertext)
-> Result<SessionKey>
diff --git a/openpgp/src/packet/key.rs b/openpgp/src/packet/key.rs
index d6c97a80..9699f4ea 100644
--- a/openpgp/src/packet/key.rs
+++ b/openpgp/src/packet/key.rs
@@ -1709,7 +1709,7 @@ mod tests {
let sk = SessionKey::from(Vec::from(&dek[..]));
// Expected
- let got_enc = ecdh::encrypt_shared(&key.parts_into_public(),
+ let got_enc = ecdh::encrypt_wrap(&key.parts_into_public(),
&sk, eph_pubkey, &shared_sec)
.unwrap();