-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Add crypto support to TI cc23x0 SoC #84523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add crypto support to TI cc23x0 SoC #84523
Conversation
The following west manifest projects have changed revision in this Pull Request:
✅ All manifest checks OK Note: This message is automatically posted and updated by the Manifest GitHub Action. |
ad39107
to
da7684f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall implementation looks good to me. I only left few suggestions for improvements (some of which are also optional)
One last suggestion: it could be nice to extend |
da7684f
to
f68a815
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing my comments. LGTM :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have only one concern about the semaphore usage across crypto operations because I don't know how the hw operates.
From the driver interface perspective it looks good.
} | ||
|
||
/* Load key */ | ||
AESWriteKEY(ctx->key.bit_stream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if you shouldn't protect this call with the semaphore. What happens if another thread changes the key while there is an operation happening ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your time Flavio.
You're right, that's something that must be addressed. That's also the case for the whole encrypt/decrypt operation (not only for the key).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I read more carefully the documentation about "mutexes VS semaphores". and it seems to me that I should replace the existing mutex (currently used to protect the session) with a semaphore. The mutex I'm using to protect the session may not do the trick, since it can be locked twice by the same thread. I will double-check with @valeriosetti .
IOW, there will probably be 2 semaphores: 1 for the session, and 1 for the access to HW (similarly to crypto_stm32.c
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some internal discussion we agreed to:
- remove the session semaphore/mutex. Rationale: we don´t care if multiple thread start multiple sessions; we only care not to use AES HW at the same time.
- change
device_sem
to be a mutex and set it to protect any access to the AES HW (mutex over semaphore in this case because mutexes are thread-aware). - keep the aes_done of course for HW synchronization.
This is the same as crypto_si32.c
and crypto_stm32.c
.
f68a815
to
3d850a4
Compare
As a complement, using the sample that is part of this PR:
|
3d850a4
to
9048839
Compare
Add support for AES module to cc23x0 SoC. The driver supports the following modes: - ECB encryption only (since decryption is not supported by the HW) - CTR - CCM Signed-off-by: Stoyan Bogdanov <[email protected]> Signed-off-by: Julien Panis <[email protected]>
Add support for AES module to cc23x0 SoC. Signed-off-by: Stoyan Bogdanov <[email protected]> Signed-off-by: Julien Panis <[email protected]>
Enable AES module. Signed-off-by: Stoyan Bogdanov <[email protected]> Signed-off-by: Julien Panis <[email protected]>
For the CCM mode, increase slightly the output buffer size because the cc23x0 directly fills this buffer with 16-byte blocks. This prevents from doing unnecessary memcpy that would have an impact on the driver's performance. Signed-off-by: Julien Panis <[email protected]>
9048839
to
0e205aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks guys !
This series adds crypto support to TI cc23x0 SoC.
Datasheet: https://www.ti.com/lit/ds/symlink/cc2340r5.pdf