I am having this problem as well. I can confirm that disabling interrupts when calling into the precompiled library (cau_aes_encrypt and cau_aes_decrypt) in the mmcau_AesCrypt function of fsl_mmcau.c always gets me consistent encryption/decryption results (see the placement of DisableGlobalIRQ and EnableGlobalIRQ below). If I do not disable IRQ's during these calls, I will get intermittent encryption or decryption errors. It seems that interrupts do indeed disturb the MMCAU somehow. I am also using mmcau_2.0.0.
static status_t mmcau_AesCrypt(const uint8_t *in, const uint8_t *keySch, uint32_t aesRounds, uint8_t *out, bool encrypt)
{
status_t status;
if (((aesRounds != 10u) && (aesRounds != 12u) && (aesRounds != 14u)) || (NULL == in) || (NULL == out) ||
(NULL == keySch))
{
status = kStatus_InvalidArgument;
}
else
{
uint8_t inAlign[MMCAU_AES_BLOCK_SIZE];
uint8_t outAlign[MMCAU_AES_BLOCK_SIZE];
uint32_t keySchAlign[60];
size_t keySchSize = 0;
const uint8_t *keySchWork;
const uint8_t *inWork;
uint8_t *outWork;
bool copyOut;
if (aesRounds == 10u)
{
keySchSize = 44u;
}
else if (aesRounds == 12u)
{
keySchSize = 52u;
}
else
{
keySchSize = 60u;
}
inWork = mmcau_align_const(in, inAlign, MMCAU_AES_BLOCK_SIZE);
keySchWork = mmcau_align_const(keySch, keySchAlign, keySchSize);
outWork = mmcau_align(out, outAlign, ©Out);
uint32_t primask = DisableGlobalIRQ();
if (encrypt)
{
cau_aes_encrypt(inWork, keySchWork, aesRounds, outWork);
}
else
{
cau_aes_decrypt(inWork, keySchWork, aesRounds, outWork);
}
EnableGlobalIRQ(primask);
if (copyOut)
{
mmcau_memcpy(out, outAlign, MMCAU_AES_BLOCK_SIZE);
}
status = kStatus_Success;
}
return status;
}