From cf9fbeffb8a4be41898e4c641e7125720029718d Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 17 Aug 2020 12:26:09 +0200 Subject: openpgp: Make crypto::ecdh::decrypt_shared public. - This will be used by all the implementations of crypto::Decryptor, and if we don't want them to end up in the openpgp crate, we need to make it public. --- openpgp/src/crypto/ecdh.rs | 26 +++++++++++++------------- openpgp/src/crypto/mod.rs | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/openpgp/src/crypto/ecdh.rs b/openpgp/src/crypto/ecdh.rs index 94bab2ec..bc3aa757 100644 --- a/openpgp/src/crypto/ecdh.rs +++ b/openpgp/src/crypto/ecdh.rs @@ -11,7 +11,7 @@ use crate::packet::Key; use crate::types::{Curve, HashAlgorithm, PublicKeyAlgorithm, SymmetricAlgorithm}; use crate::utils::{read_be_u64, write_be_u64}; -pub use crate::crypto::backend::ecdh::{encrypt, decrypt}; +pub(crate) use crate::crypto::backend::ecdh::{encrypt, decrypt}; /// Wraps a session key. /// @@ -23,9 +23,9 @@ pub 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 fn encrypt_shared(recipient: &Key, - session_key: &SessionKey, VB: MPI, - S: &Protected) +pub(crate) fn encrypt_shared(recipient: &Key, + session_key: &SessionKey, VB: MPI, + S: &Protected) -> Result where R: key::KeyRole { @@ -106,7 +106,7 @@ pub fn decrypt_shared(recipient: &Key, /// See [Section 7 of RFC 6637]. /// /// [Section 7 of RFC 6637]: https://tools.ietf.org/html/rfc6637#section-7 -pub fn kdf(x: &Protected, obits: usize, hash: HashAlgorithm, param: &[u8]) +fn kdf(x: &Protected, obits: usize, hash: HashAlgorithm, param: &[u8]) -> Result { let mut hash = hash.context()?; if obits > hash.digest_size() { @@ -129,7 +129,7 @@ pub fn kdf(x: &Protected, obits: usize, hash: HashAlgorithm, param: &[u8]) /// See [Section 8 of RFC 6637]. /// /// [Section 8 of RFC 6637]: https://tools.ietf.org/html/rfc6637#section-8 -pub fn pkcs5_pad(sk: Protected, target_len: usize) -> Result { +fn pkcs5_pad(sk: Protected, target_len: usize) -> Result { if sk.len() > target_len { return Err(Error::InvalidArgument( "Plaintext data too large".into()).into()); @@ -153,7 +153,7 @@ pub fn pkcs5_pad(sk: Protected, target_len: usize) -> Result { /// See [Section 8 of RFC 6637]. /// /// [Section 8 of RFC 6637]: https://tools.ietf.org/html/rfc6637#section-8 -pub fn pkcs5_unpad(sk: Protected, target_len: usize) -> Result { +fn pkcs5_unpad(sk: Protected, target_len: usize) -> Result { if sk.len() > 0xff { return Err(Error::InvalidArgument("message too large".into()).into()); } @@ -187,9 +187,9 @@ pub fn pkcs5_unpad(sk: Protected, target_len: usize) -> Result { /// See [RFC 3394]. /// /// [RFC 3394]: https://tools.ietf.org/html/rfc3394 -pub fn aes_key_wrap(algo: SymmetricAlgorithm, key: &Protected, - plaintext: &Protected) - -> Result> { +fn aes_key_wrap(algo: SymmetricAlgorithm, key: &Protected, + plaintext: &Protected) + -> Result> { use crate::SymmetricAlgorithm::*; if plaintext.len() % 8 != 0 { @@ -266,9 +266,9 @@ pub fn aes_key_wrap(algo: SymmetricAlgorithm, key: &Protected, /// See [RFC 3394]. /// /// [RFC 3394]: https://tools.ietf.org/html/rfc3394 -pub fn aes_key_unwrap(algo: SymmetricAlgorithm, key: &Protected, - ciphertext: &[u8]) - -> Result { +fn aes_key_unwrap(algo: SymmetricAlgorithm, key: &Protected, + ciphertext: &[u8]) + -> Result { use crate::SymmetricAlgorithm::*; if ciphertext.len() % 8 != 0 { diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs index 3c31aae4..710dc5df 100644 --- a/openpgp/src/crypto/mod.rs +++ b/openpgp/src/crypto/mod.rs @@ -27,7 +27,7 @@ mod asymmetric; pub use self::asymmetric::{Signer, Decryptor, KeyPair}; mod backend; pub use backend::random; -pub(crate) mod ecdh; +pub mod ecdh; pub mod hash; mod keygrip; pub use self::keygrip::Keygrip; -- cgit v1.2.3