Skip to content

Commit

Permalink
Correct plaintext size limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrezot committed Sep 20, 2022
1 parent c702042 commit afaee4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/symmetric_crypto/aes_256_gcm_pure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ const NONCE_LENGTH: usize = 12;
/// Use a 128-bit MAC tag
const MAC_LENGTH: usize = 16;

/// A 96-bit nonce restricts the plaintext size to 4096 bytes
const MAX_PLAINTEXT_LENGTH: usize = 4096;
/// Plaintext size restriction from the NIST
/// https://csrc.nist.gov/publications/detail/sp/800-38d/final
const MAX_PLAINTEXT_LENGTH: usize = (2_usize.pow(39) - 256) / 8;

/// Structure implementing `SymmetricCrypto` and the `DEM` interfaces based on
/// AES 256 GCM.
Expand Down
2 changes: 1 addition & 1 deletion src/symmetric_crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub trait Dem<const KEY_LENGTH: usize>: Debug + PartialEq {
///
/// - `rng` : secure random number generator
/// - `secret_key` : secret symmetric key
/// - `plaintext` : plaintext message
/// - `plaintext` : plaintext message
/// - `aad` : optional data to use in the authentication method,
/// must use the same for decryption
fn encrypt<R: RngCore + CryptoRng>(
Expand Down

0 comments on commit afaee4c

Please sign in to comment.