Skip to content

Commit 052e375

Browse files
committed
nrf_securit: cracen: Fix input validation ordering
AES-CTR should not check for unprocessed_input as it can handle indivudual blocks smaller than block size. Signed-off-by: Dag Erik Gjørvad <dag.erik.gjorvad@nordicsemi.no>
1 parent df915ed commit 052e375

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

subsys/nrf_security/src/drivers/cracen/cracen_sw/src/cracen_sw_cipher.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,17 +460,17 @@ psa_status_t cracen_cipher_update(cracen_cipher_operation_t *operation, const ui
460460
return PSA_SUCCESS;
461461
}
462462

463-
if (output == NULL || output_size < input_length + operation->unprocessed_input_bytes) {
464-
return PSA_ERROR_BUFFER_TOO_SMALL;
465-
}
466-
467463
if (IS_ENABLED(PSA_NEED_CRACEN_CTR_AES)) {
468464
if (operation->alg == PSA_ALG_CTR) {
469465
return cracen_sw_aes_ctr_update(operation, input, input_length, output,
470466
output_size, output_length);
471467
}
472468
}
473469

470+
if (output == NULL || output_size < input_length + operation->unprocessed_input_bytes) {
471+
return PSA_ERROR_BUFFER_TOO_SMALL;
472+
}
473+
474474
if (IS_ENABLED(PSA_NEED_CRACEN_CBC_NO_PADDING_AES) ||
475475
IS_ENABLED(PSA_NEED_CRACEN_CBC_PKCS7_AES)) {
476476
if (operation->alg == PSA_ALG_CBC_NO_PADDING ||

0 commit comments

Comments
 (0)