-
Notifications
You must be signed in to change notification settings - Fork 27
fix: Allow encrypt key usage for a CMAC operation #155
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
base: main
Are you sure you want to change the base?
fix: Allow encrypt key usage for a CMAC operation #155
Conversation
Signed-off-by: harshal.patil <[email protected]>
64c67c5
to
e7b30ee
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.
No, a key used for CMAC does not need to have the ENCRYPT or DECRYPT usage.
The implementation of CMAC may use an internal implementation of CBC or ECB under the hood, but this is an implementation detail. Such internal usage would not care about policies on the key.
No, that's not how it would work. A CMAC driver that is built on top of the block cipher in EBC mode would not call |
I envision that the CMAC calculation using Thus, the key that is supplied to the MAC module when would be passed into the cipher module would need the |
The driver can call back to the dispatch layer. We already do this in some cases, for example PBKDF2 calls the MAC dispatch layer. We're also doing this systematically for hashes, but since hashes don't involve a key, the dispatch layer is the API layer. An architecture where the driver calls back to the API layer would not work for several reasons:
|
Thanks for the detailed explanation, as I understand the major change that you are suggesting is that the The proposed workflow would be Here the issue would be the jump from
This seems to be possible only when the driver is present in |
The declarations of the dispatch functions don't directly depend on the available drivers. Some take a pointer to a context structure whose content depends on the available drivers, but that can be an incomplete type when the compiler reaches the function declaration. We probably need to reorganize header files there. It's one of the things we need to do to generalize intermediate dispatch. I haven't fully thought this through yet. |
Description
The key that would be used for MAC operations using CMAC should also have the
PSA_KEY_USAGE_ENCRYPT
flag set. CMAC operation internally performs AES/DES encryption thus the key that is used should have thePSA_KEY_USAGE_ENCRYPT
flag set.Currently this is not an issue because the
psa_mac_
APIs do not invokepsa_cipher_
API calls thus PSA key usage is not checked during the cipher operation that takes place internally. IMO ideally thepsa_mac_
APIs should internally call thepsa_cipher_
layer which would check the usage flags of the key, and thus we would need to set thePSA_KEY_USAGE_ENCRYPT
flag.Related
Mbed-TLS/TF-PSA-Crypto#211
This PR is needed for: Mbed-TLS/TF-PSA-Crypto#249
PR checklist
Please add the numbers (or links) of the associated pull requests for consuming branches. You can omit branches where this pull request is not needed.