@@ -161,13 +161,14 @@ CHIP_ERROR AES_CCM_encrypt(const uint8_t * plaintext, size_t plaintext_length, c
161
161
// Add the aligned part of the plaintext
162
162
status = psa_aead_update (&operation, plaintext, block_aligned_length, ciphertext, block_aligned_length, &out_length);
163
163
VerifyOrReturnError (status == PSA_SUCCESS, CHIP_ERROR_INTERNAL);
164
- VerifyOrReturnError (out_length = = block_aligned_length, CHIP_ERROR_INTERNAL);
164
+ VerifyOrReturnError (out_length < = block_aligned_length, CHIP_ERROR_INTERNAL);
165
165
ciphertext_length += out_length;
166
166
167
167
if (partial_block_length > 0 )
168
168
{
169
169
// The update output should fit in the temp buffer
170
170
size_t max_output = PSA_AEAD_UPDATE_OUTPUT_SIZE (PSA_KEY_TYPE_AES, algorithm, partial_block_length);
171
+ VerifyOrReturnError (max_output <= sizeof (temp), CHIP_ERROR_INTERNAL);
171
172
172
173
// Add the non-aligned end of the plaintext
173
174
status =
@@ -254,13 +255,14 @@ CHIP_ERROR AES_CCM_decrypt(const uint8_t * ciphertext, size_t ciphertext_length,
254
255
// Add the aligned part of the ciphertext
255
256
status = psa_aead_update (&operation, ciphertext, block_aligned_length, plaintext, block_aligned_length, &out_length);
256
257
VerifyOrReturnError (status == PSA_SUCCESS, CHIP_ERROR_INTERNAL);
257
- VerifyOrReturnError (out_length = = block_aligned_length, CHIP_ERROR_INTERNAL);
258
+ VerifyOrReturnError (out_length < = block_aligned_length, CHIP_ERROR_INTERNAL);
258
259
plaintext_length += out_length;
259
260
260
261
if (partial_block_length > 0 )
261
262
{
262
263
// The update output should fit in the temp buffer
263
264
size_t max_output = PSA_AEAD_UPDATE_OUTPUT_SIZE (PSA_KEY_TYPE_AES, algorithm, partial_block_length);
265
+ VerifyOrReturnError (max_output <= sizeof (temp), CHIP_ERROR_INTERNAL);
264
266
265
267
// Add the non-aligned end of the ciphertext
266
268
status =
0 commit comments