In the IoT field, interest in encryption is increasing from the viewpoint of security or privacy.
Meanwhile, the EFM32PG /JG released by Silicon Labs is equipped with encryption hardware, and when I tried the ECDSA sample code, I was able to experience a significant reduction in processing time. (Previous article here)
This time, I would like to use the AES sample code to see the effect of hardware implementation.
Is it unusual to have AES?
There are quite a few microcomputers with AES accelerators. Each company has released compatible microcontrollers, and Silicon Labs' EFM32 family has been installed for some time.
Even though AES is a single term, there are various types of key lengths and BlockCipher modes of operation. There may not be many products that support as many configurations as the EFM32PG /JG.
Try the sample code (encryption)
Now, let's try the sample code (SLSTK3401A_aescrypt). Start with encryption hardware enabled.
The ECDSA sample code and work procedure covered in the previous article are the same, and when the binary is downloaded to EFM32PG, a message appears on Tera Term.
"Do you want to encrypt (encrypt)? Do you want to decrypt (decrypt)?" Enter "e" for encrypt. Then the following message. It looks like a sample code that progresses while interacting.
``I will use it to generate the initial vector for encryption, so please enter a short phrase'', so I will enter macnica.
The next message is "Enter the character string you want to encrypt, and press <Enter> when you are done." Enter "HelloNew World !!" and return! Instantly the encryption result (D69E3…) was displayed.
This seems to be the end. The time required for encryption processing (number of clocks, etc.) is not displayed, but is there a time difference that can be clearly seen if software processing is used? Leaving the fun aside, let's try the decryption.
Try the sample code (decryption)
You will need the result of the encryption to decrypt it, so make a copy of the previous result.
Then reset the board! In the encryption or decryption selection, select decrypt (decryption) this time and proceed.
The next message is finally "Send the message (ciphertext) you want to decrypt". Paste the encrypted result that you copied earlier.
and return. You have successfully compounded the string "HelloNew World!!". The processing time was also instant.
Is it a soft processing setting?
Next is soft processing. As in the previous article, there is no spell on the compile option
I applied (-DNO_CRYPTO_ACCELERATION) and compared.
| encryption time | decryption time | |
| hardware processing | 0.5 seconds | 0.4 seconds |
| Soft processing | 2.3 seconds | 2.1 seconds |
Opinions are divided on the results. Since USB-UART conversion is performed between the time the encryption/decryption process is performed and the result displayed on the terminal software, it may not be possible to say that the time difference that occurs is the hardware/software difference. I don't think so. To see the difference in processing time, it may be better to modify the sample code to count the number of clocks.
Cycle number comparison
When I searched for other suitable sample code, I found that the application note AN0955 "CRYPTO" contains AES sample code. Moreover, the number of clock cycles required for encryption/decryption is displayed on the LCD.
The number of clock cycles when encrypting/decrypting 128 bytes of data was as shown in the table below. AES uses a key length of 256 bits and CBC (Cipher Block Chaining) mode. In this sample code, you can try changing the data size to 64 bytes or 256 bytes, so if you have a starter kit, please try it.
| Soft processing (encryption hardware disabled) | Hard processing (encryption hardware enabled) | |
| encryption | 89182 clock | 6267 clock |
| decryption | 50962 clock | 7396 clock |
At the end
Security is said to be one of the most important issues in the spread of IoT.
Considering the model in which devices are connected to the cloud via a gateway, various services have been enhanced for Internet and cloud security. However, the security of IoT devices themselves, or the security of inter-chip communication within IoT devices, is highly dependent on chip performance, and there are many issues to be addressed.
The EFM32PG /JG family is ahead of its time, capable of hardware processing of a wide variety of ciphers. It seems that it will be a valuable existence that gives users options when considering future product designs.
If you are interested in the EFM32 series microcontrollers, please also see here
Related article
- Finally equipped with a security engine! IoT era microcomputers have come so far! (1)
- Finally equipped with a security engine! IoT era microcomputers have come so far! (2)
- Finally equipped with a security engine! IoT era microcomputers have come so far! (3)
- Finally equipped with a security engine! IoT era microcomputers have come so far! (4)
