Part Number: LAUNCHCC3220MODASF
Hello,
I was trying usage of the encryption functions/APIs like:
CryptoCC32XX_init, CryptoCC32XX_open, CryptoCC32XX_encrypt, CryptoCC32XX_decrypt
for AES encryption.
At first CryptoCC32XX_encrypt/decrypt calls were failing.
On using debug it turned out that there was a loop as follows in the function "CryptoCC32XX_aesProcess" of file "CryptoCC32XX.c".
The value of "CryptoCC32XX_CONTEXT_READY_MAX_COUNTER" is 1000.
/* Wait for the context in flag, the flag will be set in the Interrupt handler. */
while((!g_bAESReadyFlag) && (count > 0))
{
count --;
}
if (count == 0)
{
return CryptoCC32XX_STATUS_ERROR;
}
The context interrupt wasn't raised within these 1000 iterations and the function therefore returned failure.
We decided to try making this loop an infinite loop (by commenting out "count --" statement).
However the Tera term had somehow become unresponsive.
We had to reboot our PC.
After this reboot, the change of loop to infinite loop gave us a success in encrypt.
Later on I wanted to see if instead of an infinite loop we could have a value of "count" that would have the interrupt getting detected and therefore make encrypt successful. I tried 100000 and 10000 loops. The things worked. Then even at the value of 1000 the context was obtained i.e. encrypt was successful.
Here are my questions:
- Could the PC reboot have somehow solved the problem? That is, no change was necessary in the above mentioned loop, it was just misbehaving because CCS and/or PC needed a restart?
- What is the importance of this loop? Why are we waiting for context to be available, what is this AES context?
- What/who/when makes available this context? What does encrypt function need it for?
- What are the pros/cons of having this loop as a limited one vs. an infinite one?
- This loop is sort of introducing unpredictability if I want to use it for sending encrypted data. Because if this loop fails, the encrypt fails, and this failure can happen any time. Transmission of unencrypted data may happen. How do I tackle this unpredictability?
NOTE:
I did observe the following too about this loop:
There is a corresponding function "AESCrypt" in the CC3200 "aes" example.
This function has this loop as an infinite loop. Whereas, in CC3220 this loop has a finite number of iterations.
--
Regards,
Neeraj Sallh