summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2022-06-28 16:20:34 +0200
committerJustus Winter <justus@sequoia-pgp.org>2022-07-05 10:35:39 +0200
commit3175bd519b2cd83f45d40a56c79b6c09ac11da5b (patch)
tree70bae2be868519a04bdb193c2dc38c8ac5b5ddff
parent279f3fce87e2f6f04526a94c2de26ab199d7103e (diff)
openpgp: Make crypto::ecdh::aes_key_{,un}wrap public.
- This is the AES Key Wrap algorithm described in RFC 3394. It is used in OpenPGP's ECDH, but has uses besides that (for example, the gpg-agent uses it to wrap keys in transit).
-rw-r--r--openpgp/NEWS2
-rw-r--r--openpgp/src/crypto/ecdh.rs12
2 files changed, 8 insertions, 6 deletions
diff --git a/openpgp/NEWS b/openpgp/NEWS
index ba6d00b2..1a4ec42d 100644
--- a/openpgp/NEWS
+++ b/openpgp/NEWS
@@ -6,6 +6,8 @@
** New functionality
- Cert::insert_packets2
- Cert::insert_packets_merge
+ - crypto::ecdh::aes_key_wrap
+ - crypto::ecdh::aes_key_unwrap
- Error::UnsupportedCert2
- TryFrom<Packet> for Unknown
- types::{Curve, SymmetricAlgorithm, AEADAlgorithm,
diff --git a/openpgp/src/crypto/ecdh.rs b/openpgp/src/crypto/ecdh.rs
index a4c73985..2092ad07 100644
--- a/openpgp/src/crypto/ecdh.rs
+++ b/openpgp/src/crypto/ecdh.rs
@@ -229,9 +229,9 @@ fn pkcs5_unpad(sk: Protected, target_len: usize) -> Result<Protected> {
/// See [RFC 3394].
///
/// [RFC 3394]: https://tools.ietf.org/html/rfc3394
-fn aes_key_wrap(algo: SymmetricAlgorithm, key: &Protected,
- plaintext: &Protected)
- -> Result<Vec<u8>> {
+pub fn aes_key_wrap(algo: SymmetricAlgorithm, key: &Protected,
+ plaintext: &Protected)
+ -> Result<Vec<u8>> {
if plaintext.len() % 8 != 0 {
return Err(Error::InvalidArgument(
"Plaintext must be a multiple of 8".into()).into());
@@ -299,9 +299,9 @@ fn aes_key_wrap(algo: SymmetricAlgorithm, key: &Protected,
/// See [RFC 3394].
///
/// [RFC 3394]: https://tools.ietf.org/html/rfc3394
-fn aes_key_unwrap(algo: SymmetricAlgorithm, key: &Protected,
- ciphertext: &[u8])
- -> Result<Protected> {
+pub fn aes_key_unwrap(algo: SymmetricAlgorithm, key: &Protected,
+ ciphertext: &[u8])
+ -> Result<Protected> {
if ciphertext.len() % 8 != 0 {
return Err(Error::InvalidArgument(
"Ciphertext must be a multiple of 8".into()).into());