summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto
diff options
context:
space:
mode:
authorWiktor Kwapisiewicz <wiktor@metacode.biz>2022-05-12 10:43:52 +0200
committerWiktor Kwapisiewicz <wiktor@metacode.biz>2022-05-12 13:32:30 +0200
commitb1fdd0e62e12c936206db8aa9b567678a23c4708 (patch)
tree366fb6178c3eca43ff58ca008ec963ece677a7bf /openpgp/src/crypto
parent8f8e46bf43b9908827f576e4f8b3629df01ed3ee (diff)
openpgp: Rename `iv_size` to `nonce_size` leaving `iv_size`.
- Rename `iv_size` to `nonce_size`. - Introduce `iv_size` that forwards to `nonce_size` for compatibility reasons. - Change all calls to `iv_size` to `nonce_size`.
Diffstat (limited to 'openpgp/src/crypto')
-rw-r--r--openpgp/src/crypto/aead.rs14
-rw-r--r--openpgp/src/crypto/mem.rs4
2 files changed, 13 insertions, 5 deletions
diff --git a/openpgp/src/crypto/aead.rs b/openpgp/src/crypto/aead.rs
index f9d5149a..b225c6be 100644
--- a/openpgp/src/crypto/aead.rs
+++ b/openpgp/src/crypto/aead.rs
@@ -93,8 +93,8 @@ impl AEADAlgorithm {
}
}
- /// Returns the initialization vector size of the AEAD algorithm.
- pub fn iv_size(&self) -> Result<usize> {
+ /// Returns the nonce size of the AEAD algorithm.
+ pub fn nonce_size(&self) -> Result<usize> {
use self::AEADAlgorithm::*;
match self {
// According to RFC4880bis, Section 5.16.1.
@@ -106,6 +106,14 @@ impl AEADAlgorithm {
_ => Err(Error::UnsupportedAEADAlgorithm(*self).into()),
}
}
+
+ /// Returns the initialization vector size of the AEAD algorithm.
+ ///
+ /// This function is deprecated. Please use
+ /// [`AEADAlgorithm::nonce_size`].
+ pub fn iv_size(&self) -> Result<usize> {
+ self.nonce_size()
+ }
}
/// Schedules nonce and additional authenticated data for use with
@@ -862,7 +870,7 @@ mod tests {
let mut key = vec![0; sym_algo.key_size().unwrap()];
crate::crypto::random(&mut key);
let key: SessionKey = key.into();
- let mut iv = vec![0; aead.iv_size().unwrap()];
+ let mut iv = vec![0; aead.nonce_size().unwrap()];
crate::crypto::random(&mut iv);
let mut ciphertext = Vec::new();
diff --git a/openpgp/src/crypto/mem.rs b/openpgp/src/crypto/mem.rs
index 30a0ab66..af7c5cfa 100644
--- a/openpgp/src/crypto/mem.rs
+++ b/openpgp/src/crypto/mem.rs
@@ -342,7 +342,7 @@ mod has_access_to_prekey {
{
// The nonce is a simple counter.
let mut nonce_store = [0u8; aead::MAX_NONCE_LEN];
- let nonce_len = AEAD_ALGO.iv_size()
+ let nonce_len = AEAD_ALGO.nonce_size()
.expect("Mandatory algorithm unsupported");
assert!(nonce_len >= 8);
let nonce = &mut nonce_store[..nonce_len];
@@ -359,7 +359,7 @@ mod has_access_to_prekey {
{
// The nonce is a simple counter.
let mut nonce_store = [0u8; aead::MAX_NONCE_LEN];
- let nonce_len = AEAD_ALGO.iv_size()
+ let nonce_len = AEAD_ALGO.nonce_size()
.expect("Mandatory algorithm unsupported");
assert!(nonce_len >= 8);
let nonce = &mut nonce_store[..nonce_len];