void Encryption_CTR(const uint8_t* plaintext,\
uint8_t* ciphertext,\
const uint8_t* key,\
const uint8_t* iv,\
const uint16_t len)
{
// outSize is for output size, retval is for return value
int32_t outSize, retval;
AESCTRctx_stt AESctx_st; // The AES context
// Initialize Context Flag with default value
AESctx_st.mFlags = E_SK_DEFAULT;
// Set Iv size to 16
AESctx_st.mIvSize=16;
// Set key size to 16
AESctx_st.mKeySize=CRL_AES128_KEY;
// call init function
retval = AES_CTR_Encrypt_Init(&AESctx_st, key, iv);
if (retval != AES_SUCCESS)
{ }
//Do the finalization call (in CTR it will not return any output)
retval = AES_CTR_Encrypt_Finish(&AESctx_st, ciphertext+outSize, &outSize );
if (retval != AES_SUCCESS)
{ }
}
/**
* @brief
* @param
* @retval None
*/
void Decryption_CTR(uint8_t* plaintext,\
const uint8_t* ciphertext,\
const uint8_t* key,\
const uint8_t* iv,\
const uint16_t len)
{
// outSize is for output size, retval is for return value
int32_t outSize, retval;
AESCTRctx_stt AESctx_st; // The AES context
// Initialize Context Flag with default value
AESctx_st.mFlags = E_SK_DEFAULT;
// Set Iv size to 16
AESctx_st.mIvSize=16;
// Set key size to 16
AESctx_st.mKeySize=CRL_AES128_KEY;
// call init function
retval = AES_CTR_Decrypt_Init(&AESctx_st, key, iv);
if (retval != AES_SUCCESS)
{ }
//Do the finalization call (in CTR it will not return any output)
retval = AES_CTR_Decrypt_Finish(&AESctx_st, plaintext+outSize, &outSize );
if (retval != AES_SUCCESS)
{ }
}