Document the reason for the AES-GCM noce size

This commit is contained in:
Rodolphe Bréard 2024-03-29 22:11:39 +01:00
parent 360917adb8
commit b41772c045

View file

@ -4,6 +4,10 @@ use aes_gcm::aead::{Aead, KeyInit, Payload};
use aes_gcm::{Aes128Gcm, Key, Nonce}; use aes_gcm::{Aes128Gcm, Key, Nonce};
// 96 bits (12 bytes) // 96 bits (12 bytes)
// Reason: NIST Special Publication 800-38D
// https://csrc.nist.gov/pubs/sp/800/38/d/final
// Section 5.2.1.1 recommends that implementations restrict support to 96 bit.
// Section 8.2 states that nonces of 96 bits and higher may be randomly generated.
const NONCE_SIZE: usize = 12; const NONCE_SIZE: usize = 12;
pub(crate) fn aes128gcm_gen_nonce() -> Result<Vec<u8>> { pub(crate) fn aes128gcm_gen_nonce() -> Result<Vec<u8>> {