/* Encrypts the len-bytes in the specified data-array, using the specified 256-bit (32 bytes) key. The results are written back into the same array.  */
void TbxCryptoAes256Encrypt(uint8_t *data, size_t len, uint8_t const *key)
/* Encrypts the len-bytes in the specified data-array, using the specified 256-bit (32 bytes) key. The results are written back into the same array.  */
void TbxCryptoAes256Encrypt(uint8_t *data, size_t len, uint8_t const *key)
{
  tbx_aes256_context ctx;
  TBX_ASSERT(data != NULL);
  TBX_ASSERT(len > 0U);
  TBX_ASSERT(key != NULL);
  TBX_ASSERT((len % TBX_CRYPTO_AES_BLOCK_SIZE) == 0U);
  if ( (data != NULL) && (len > 0U) && (key != NULL) && \
       ((len % TBX_CRYPTO_AES_BLOCK_SIZE) == 0U) )
  {
    tbx_aes256_init(&ctx, key);
    for (size_t idx = 0U; idx < (len / TBX_CRYPTO_AES_BLOCK_SIZE); idx++)
    {
      tbx_aes256_encrypt_ecb(&ctx, &data[idx * TBX_CRYPTO_AES_BLOCK_SIZE]);
    }
    tbx_aes256_done(&ctx);
  }
}