AES CCM Crypto with PSA and different tag length

Hi,

I am currently trying out the mbed crypto example on https://os.mbed.com/docs/mbed-os/v5.15/apis/mbed-crypto.html. There I wanted to change the tag length in the void authenticate_and_encrypt_a_message(void) function from 16 to 4 which is supported by AES CCM encryption by setting size_t tag_length = 4;. Unfortunately I get an PSA_ERROR_INSUFFICIENT_MEMORY error when calling psa_aead_encrypt.
So I tried to set the tag length to 4 by changing psa_set_key_algorithm(&attributes, PSA_ALG_CCM); to psa_set_key_algorithm(&attributes, PSA_ALG_AEAD_WITH_TAG_LENGTH(PSA_ALG_CCM, 4));. This lead to an PSA_ERROR_NOT_PERMITTED error.

So Is there any possibility I can change the tag length to 4?