From 40a741e4c7ba2ec51a0c176e81aba83002d6ab8b Mon Sep 17 00:00:00 2001 From: Hugo Hakim Damer Date: Tue, 27 Aug 2024 16:45:49 +0200 Subject: [PATCH] fix: apply code review suggestions from PR #24 Co-authored-by: Falko Galperin <10247603+falko17@users.noreply.github.com> --- src/token/cose/encrypted/mod.rs | 8 ++++---- tests/dcaf_cose_examples/aes-ccm/empty_payload.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/token/cose/encrypted/mod.rs b/src/token/cose/encrypted/mod.rs index f8ae263..e7c8639 100644 --- a/src/token/cose/encrypted/mod.rs +++ b/src/token/cose/encrypted/mod.rs @@ -223,7 +223,7 @@ pub trait EncryptCryptoBackend: CryptoBackend { ))) } - /// Decrypts the given `payload` using AES-CCM with the parameters L (size of length field) + /// Decrypts the given `ciphertext_with_tag` using AES-CCM with the parameters L (size of length field) /// and M (size of authentication tag) specified for the given `algorithm` in /// [RFC 9053, section 4.2](https://datatracker.ietf.org/doc/html/rfc9053#section-4.2) and the /// given `key`. @@ -246,9 +246,9 @@ pub trait EncryptCryptoBackend: CryptoBackend { /// previous encryption as specified in /// [RFC 3610, Section 2.4](https://datatracker.ietf.org/doc/html/rfc3610#section-2.4)). /// Is guaranteed to be at least as long as the authentication tag should be. - /// * `aad` - additional authenticated data that should be included in the calculation of the + /// * `aad` - Additional authenticated data that should be included in the calculation of the /// authentication tag, but not encrypted. - /// * `iv` - Initialization vector that should be used for the encryption process. + /// * `iv` - Initialization vector that should be used for the decryption process. /// Implementations may assume that `iv` has the correct length for the given AES-CCM /// variant and panic if this is not the case. /// @@ -301,7 +301,7 @@ pub fn aes_algorithm_iv_len( match alg { // AES-GCM: Nonce is fixed at 96 bits (RFC 9053, Section 4.1) iana::Algorithm::A128GCM | iana::Algorithm::A192GCM | iana::Algorithm::A256GCM => { - Ok(AES_GCM_NONCE_SIZE) + Ok(12) } // AES-CCM: Nonce length is parameterized. iana::Algorithm::AES_CCM_16_64_128 diff --git a/tests/dcaf_cose_examples/aes-ccm/empty_payload.json b/tests/dcaf_cose_examples/aes-ccm/empty_payload.json index 5ed474b..1ccde0e 100644 --- a/tests/dcaf_cose_examples/aes-ccm/empty_payload.json +++ b/tests/dcaf_cose_examples/aes-ccm/empty_payload.json @@ -1,5 +1,5 @@ { - "title": "AES-GCM-01: Encryption with empty payload", + "title": "AES-CCM-01: Encryption with empty payload", "input": { "plaintext": "", "enveloped": {