[aes-ccm] only allow nonces in the length range [7, 13] in AesCcm (#13265)

AesCcm does not allow nonces with lengths outside the range [7, 13].
This commit rejects too short or too long nonces.
This commit is contained in:
Thomas
2026-07-06 13:48:26 -07:00
committed by GitHub
parent 815264e849
commit 1aeafa6b99
2 changed files with 6 additions and 6 deletions
+2 -4
View File
@@ -190,10 +190,8 @@ bool AesCcm::Config::IsValid(void) const
{
bool isValid = false;
if (mNonceLength > 0)
{
VerifyOrExit(mNonce != nullptr);
}
VerifyOrExit(IsValueInRange(mNonceLength, kMinNonceLength, kMaxNonceLength));
VerifyOrExit(mNonce != nullptr);
VerifyOrExit((mTagLength % 2) == 0);
VerifyOrExit(IsValueInRange(mTagLength, kMinTagLength, kMaxTagLength));
+4 -2
View File
@@ -61,8 +61,10 @@ namespace Crypto {
class AesCcm
{
public:
static constexpr uint8_t kMinTagLength = 4; ///< Minimum tag length (in bytes).
static constexpr uint8_t kMaxTagLength = AesEcb::kBlockSize; ///< Maximum tag length (in bytes).
static constexpr uint8_t kMinTagLength = 4; ///< Minimum tag length (in bytes).
static constexpr uint8_t kMaxTagLength = AesEcb::kBlockSize; ///< Maximum tag length (in bytes).
static constexpr uint8_t kMinNonceLength = 7; ///< Minimum nonce length (in bytes).
static constexpr uint8_t kMaxNonceLength = 13; ///< Maximum nonce length (in bytes).
/**
* Initializes the AES-CCM object.