@@ -396,11 +396,18 @@ psa_status_t cracen_aead_set_nonce(cracen_aead_operation_t *operation, const uin
396396#endif
397397}
398398
399- static void set_lengths (cracen_aead_operation_t * operation , size_t ad_length ,
399+ static psa_status_t set_lengths (cracen_aead_operation_t * operation , size_t ad_length ,
400400 size_t plaintext_length )
401401{
402+ #if defined(CRACEN_MAX_CCM_DATA_SIZE )
403+ if ((operation -> alg == PSA_ALG_CCM ) && (plaintext_length > CRACEN_MAX_CCM_DATA_SIZE )) {
404+ return PSA_ERROR_NOT_SUPPORTED ;
405+ }
406+ #endif /* CRACEN_MAX_CCM_DATA_SIZE */
407+
402408 operation -> ad_length = ad_length ;
403409 operation -> plaintext_length = plaintext_length ;
410+ return PSA_SUCCESS ;
404411}
405412
406413psa_status_t cracen_aead_set_lengths (cracen_aead_operation_t * operation , size_t ad_length ,
@@ -409,8 +416,7 @@ psa_status_t cracen_aead_set_lengths(cracen_aead_operation_t *operation, size_t
409416#ifdef CONFIG_SOC_NRF54LM20A
410417 return PSA_ERROR_NOT_SUPPORTED ;
411418#else
412- set_lengths (operation , ad_length , plaintext_length );
413- return PSA_SUCCESS ;
419+ return set_lengths (operation , ad_length , plaintext_length );
414420#endif
415421}
416422
@@ -755,7 +761,10 @@ psa_status_t cracen_aead_encrypt(const psa_key_attributes_t *attributes, const u
755761 goto error_exit ;
756762 }
757763
758- set_lengths (& operation , additional_data_length , plaintext_length );
764+ status = set_lengths (& operation , additional_data_length , plaintext_length );
765+ if (status != PSA_SUCCESS ) {
766+ goto error_exit ;
767+ }
759768
760769 /* Do not call the cracen_aead_update*() functions to avoid using
761770 * HW context switching (process_on_hw()) in single-part operations.
@@ -820,7 +829,10 @@ psa_status_t cracen_aead_decrypt(const psa_key_attributes_t *attributes, const u
820829 goto error_exit ;
821830 }
822831
823- set_lengths (& operation , additional_data_length , * plaintext_length );
832+ status = set_lengths (& operation , additional_data_length , * plaintext_length );
833+ if (status != PSA_SUCCESS ) {
834+ goto error_exit ;
835+ }
824836
825837 /* Do not call the cracen_aead_update*() functions to avoid using
826838 * HW context switching (process_on_hw()) in single-part operations.
0 commit comments