mirror of
https://github.com/espressif/openthread.git
synced 2026-09-17 14:40:07 +00:00
[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:
@@ -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));
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user