Add support fot CKM_HOTP and OTP key factory#461
Open
simo5 wants to merge 2 commits into
Open
Conversation
Introduce the `OTPKeyFactory` trait and implement handling for `CKO_OTP_KEY` objects. This adds support for One-Time Password keys by defining their specific PKCS#11 attributes and applying standard key protections (e.g., sensitivity and extractability defaults) similar to private and secret keys. Assisted-by: Gemini <gemini@google.com> Signed-off-by: Simo Sorce <simo@redhat.com>
This introduces support for the HMAC-based One-Time Password (HOTP) mechanism behind a new `hotp` feature flag. It implements `CKM_HOTP_KEY_GEN` for key generation and `CKM_HOTP` for generating and verifying OTP signatures. To support the stateful nature of HOTP keys, which require incrementing a counter (`CKA_OTP_COUNTER`) upon usage, a new `updates_object` method is added to the `Sign` and `Verify` traits. This allows mechanisms to request attribute updates on the underlying token objects after an operation completes. Integration tests are also added to ensure correct generation, verification, and look-ahead functionality. Assisted-by: Gemini <gemini@google.com> Signed-off-by: Simo Sorce <simo@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I was curious to implement HOTP because it was the simplest thing that would allow me to consider the problem of stateful keys (keys that need to update state on token after an operation)
This PR implements OTP Keys factory and provide a simple implementation of an HOTP token mechanism that uses Sign/Verify APIs to generate/verify an HOTP using a CKK_HOTP key object as the HOTP token state.
Checklist
Reviewer's checklist: