I am using NRF52840 with SDK15
I am using AES 128 Encryption and am confused on the documentation:
- During the encryption operation with nrf_crypto_aes_crypt or nrf_crypto_aes_finalize, if padding mode is selected, the size of
p_data_outbuffer must contain extra space for padding.
Whentext_sizeis a multiple of 16 bytes,p_data_outmust be allocated with a size equal totext_size+ an additional block (that means 16 bytes for padding).
Whentext_sizeis not a multiple of 16 bytes,p_data_outmust be allocated with a size aligned to the next full 16-byte block (that means 1 - 15 bytes for padding). - When no padding mode is selected, the text for encryption must be a multiple of 16 bytes.
- Size of the message for decryption must be always a multiple of 16 bytes.
- Key must be 128 bits, 192 bits, or 256 bits, depending on the selected backend.
I am unsure if on the decryption I need to pad the output buffer to the size of the encrypted value or the size of the expected value after decryption.
uint8_t value_to_encrypt = 23;
uint8_t encrypted_value[16]; //===> padded buffer for encrypted value
uint8_t output_buffer[16]; // ====> padded in regards to the expected value after decryption
or
uint8_t output_bnuffer[32];// ====> padded in regards to the encryped value
Thanks,
Bloq