-
Notifications
You must be signed in to change notification settings - Fork 830
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
[cryptolib] Move SHA-2/HMAC computations to HMAC HWIP #22731
Comments
Because OTBN is used, right? We don't usually run multiple crypto operations as our current implementation design choices prohibits it due to other kind of shared context. The plan looks good, however we probably need 2 modes - streaming (when context is explicitly stored in memory), and "atomic" when all operations are done one after another and then only result is used. The latter is SW DRBG use case - no intermediate context load/store is needed and even more it is explicitly not needed for efficiency.
|
I agree, now that we have HW support there's no need to use the OTBN implementations. This looks like a good plan to me.
Yep, last I checked the hardware implementation was (unsurprisingly) many times faster -- the OTBN one was a temporary workaround because we didn't have context switching.
Just to clarify: I think one of these duplicate entries is probably supposed to be something like "Redirect streaming SHA-256/384/512 and HMAC-256/384/512 calls to HMAC driver", no? |
If I understand correctly, this might become an issue only if you care about the OTBN context at the time you make the HMAC/SHA-2 (except SHA-256) call. OTBN-based HMAC/SHA-2 calls preempt the current app on OTBN, which means any context stored in its DMEM (such as keys) will be removed, so that computation needs to start from scratch. Does anyone think there is a conflict here? This may be important for prioritization of the tasks here accordingly (otherwise I think most items here are P2-P3).
Sure, we can support larger key sizes by additional hash invocation from SW, I just wanted to point out the limitations of HW (compared to OTBN-based solution). Probably not that relevant. Based on your code snippet, I think the highest priority item here is to provide both streaming and one-shot HMAC-256 through HMAC HWIP.
I did not quite understand the clarification, but I assumed my wording was not precise. I also added “connect these directly to crypto-API-level SHA-2/HMAC calls.” to both items. My partitioning of the tasks might not be optimal, but I think what is really important here is that both SHA-2 and HMAC use native functions from HMAC HW instead of HMAC algorithm invoking SHA-2 algorithm. |
Yep, this describes the current setup -- the cryptolib doesn't rely on any hardware state between operations in general, but the However, either way, switching SHA-2 and HMAC to the hardware will eliminate conflict with async OTBN operations. |
There is an open PR correcting the documentation; key sizes supported are 128/256/384/512/1024-bit so long as the key size is smaller than or equal to the block size of the digest size, assuming a preliminary hash invocation would hash down a larger key to the block size before feeding it with the intended data to hash as @vsukhoml says. Atomic and streaming modes can both be supported with the HW depending on how the HW is triggered with the commands. Atomic would be triggered by |
Previously, HMAC would use OTBN for 256/384/512-bit algorithms. This commit replaces those calls with that of HMAC driver. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, only SHA-256 would run on HMAC HWIP. 384 and 512-bit variants were connected to OTBN. With this commit, cryptolib is updated such that calls are redirected to HMAC driver for all digest sizes. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, HMAC would use OTBN for 256/384/512-bit algorithms. This commit replaces those calls with that of HMAC driver. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, only SHA-256 would run on HMAC HWIP. 384 and 512-bit variants were connected to OTBN. With this commit, cryptolib is updated such that calls are redirected to HMAC driver for all digest sizes. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, HMAC would use OTBN for 256/384/512-bit algorithms. This commit replaces those calls with that of HMAC driver. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, only SHA-256 would run on HMAC HWIP. 384 and 512-bit variants were connected to OTBN. With this commit, cryptolib is updated such that calls are redirected to HMAC driver for all digest sizes. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, HMAC would use OTBN for 256/384/512-bit algorithms. This commit replaces those calls with that of HMAC driver. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, only SHA-256 would run on HMAC HWIP. 384 and 512-bit variants were connected to OTBN. With this commit, cryptolib is updated such that calls are redirected to HMAC driver for all digest sizes. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, HMAC would use OTBN for 256/384/512-bit algorithms. This commit replaces those calls with that of HMAC driver. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, only SHA-256 would run on HMAC HWIP. 384 and 512-bit variants were connected to OTBN. With this commit, cryptolib is updated such that calls are redirected to HMAC driver for all digest sizes. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, HMAC would use OTBN for 256/384/512-bit algorithms. This commit replaces those calls with that of HMAC driver. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, only SHA-256 would run on HMAC HWIP. 384 and 512-bit variants were connected to OTBN. With this commit, cryptolib is updated such that calls are redirected to HMAC driver for all digest sizes. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, HMAC would use OTBN for 256/384/512-bit algorithms. This commit replaces those calls with that of HMAC driver. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, only SHA-256 would run on HMAC HWIP. 384 and 512-bit variants were connected to OTBN. With this commit, cryptolib is updated such that calls are redirected to HMAC driver for all digest sizes. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, HMAC would use OTBN for 256/384/512-bit algorithms. This commit replaces those calls with that of HMAC driver. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, only SHA-256 would run on HMAC HWIP. 384 and 512-bit variants were connected to OTBN. With this commit, cryptolib is updated such that calls are redirected to HMAC driver for all digest sizes. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, HMAC would use OTBN for 256/384/512-bit algorithms. This commit replaces those calls with that of HMAC driver. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, only SHA-256 would run on HMAC HWIP. 384 and 512-bit variants were connected to OTBN. With this commit, cryptolib is updated such that calls are redirected to HMAC driver for all digest sizes. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, HMAC would use OTBN for 256/384/512-bit algorithms. This commit replaces those calls with that of HMAC driver. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, only SHA-256 would run on HMAC HWIP. 384 and 512-bit variants were connected to OTBN. With this commit, cryptolib is updated such that calls are redirected to HMAC driver for all digest sizes. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, HMAC would use OTBN for 256/384/512-bit algorithms. This commit replaces those calls with that of HMAC driver. See #22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, only SHA-256 would run on HMAC HWIP. 384 and 512-bit variants were connected to OTBN. With this commit, cryptolib is updated such that calls are redirected to HMAC driver for all digest sizes. See #22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Closing this issue as all variants are tied to HMAC HWIP through recent driver changes. |
Previously, HMAC would use OTBN for 256/384/512-bit algorithms. This commit replaces those calls with that of HMAC driver. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Previously, only SHA-256 would run on HMAC HWIP. 384 and 512-bit variants were connected to OTBN. With this commit, cryptolib is updated such that calls are redirected to HMAC driver for all digest sizes. See lowRISC#22731 for more context. Signed-off-by: Fatih Balli <fatihballi@google.com>
Description
I want to highlight how our current hybrid SHA-2/HMAC cryptolib+HW stack looks, so we can discuss how to move from SW implementation to HW implementation. Here is the current stack:

The arrows indicate the use of functions, for example HMAC-256 (streaming) is implemented with calls to SHA-256 (streaming). This means, for SHA-2/HMAC calls made to cryptolib:
This implies multiple changes with a goal to flatten this stack and move SHA-2/HMAC computations from OTBN to HMAC HWIP. It would imply:
HMAC HWIP also imposes certain restrictions on the key length that we also need to be aware of:
opentitan/hw/ip/hmac/README.md
Line 28 in ec71152
FYI @vsukhoml, regarding the choice of parameters available for HMAC. If you have particular parameters in mind, it might help up prioritize the tasks accordingly.
cc: @jadephilipoom @moidx @johannheyszl @gdessouky
The text was updated successfully, but these errors were encountered: