-
Notifications
You must be signed in to change notification settings - Fork 20
Add support for C_[Get|Set]OperationState functions #389
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
Open
simo5
wants to merge
8
commits into
latchset:main
Choose a base branch
from
simo5:save_digest
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Move the `aes_gcm_encrypt` and `aes_gcm_decrypt` functions from the `storage::aci` module to a new, dedicated `encryption` module. This change makes these general-purpose cryptographic helpers available for reuse in other parts of the codebase and improves modularity. Signed-off-by: Simo Sorce <simo@redhat.com>
Add a `new()` constructor for `AesMechanism` to handle the common initialization of the `CK_MECHANISM_INFO` struct. This change centralizes the setting of `ulMinKeySize` and `ulMaxKeySize`, removing significant code duplication from the `AES_MECHS` static array definition and improving readability. Signed-off-by: Simo Sorce <simo@redhat.com>
Implement the C_GetOperationState and C_SetOperationState functions. This allows clients to save the state of an active cryptographic operation and restore it later, potentially in a different session. The state of all active operations in a session is collected, serialized using ASN.1, and then encrypted with an ephemeral AES-GCM key. This key is generated once per process lifetime, ensuring the confidentiality and integrity of the saved state. While the framework supports saving the state for all operation types, only the restoration of Digest operations is currently implemented. Signed-off-by: Simo Sorce <simo@redhat.com>
This commit introduces support for OpenSSL 4.0 by adding the `ossl400` feature flag and corresponding build-time version checks. The primary change is the implementation of digest context serialization and deserialization, a feature available in OpenSSL 4.0. New methods `get_state`, `set_state`, and `get_state_size` are added to `OsslDigest` to expose this functionality, wrapping the underlying `EVP_MD_CTX_serialize` and `EVP_MD_CTX_deserialize` functions. These methods are conditionally compiled and only available when using OpenSSL 4.0 or newer. Signed-off-by: Simo Sorce <simo@redhat.com>
This change implements the `C_GetOperationState` and `C_SetOperationState` functions for multi-part digest (hashing) operations. This allows an application to save the state of a digest operation and resume it later. The OpenSSL backend is updated to use its internal state-saving capabilities. A comprehensive test is added to verify that a restored operation produces the same result as a continuous one. The `state_save` method in the `MechOperation` trait was also changed to take `&self` instead of `&mut self`, as saving the state should not mutate the operation itself. Co-authored-by: Gemini <gemini@google.com> Signed-off-by: Simo Sorce <simo@redhat.com>
Modify the GitHub Actions build workflow to check out different OpenSSL sources depending on the linking type. FIPS builds now use a specific fork and branch (`simo5/openssl@kryoptic_ossl35`) required for the FIPS provider. Static builds are updated to use the official OpenSSL repository's master branch. Previously, both build types used the same FIPS-specific branch. Signed-off-by: Simo Sorce <simo@redhat.com>
This allows to test options that are not available in older OpenSSL versions like digest (de)serialization. Signed-off-by: Simo Sorce <simo@redhat.com>
Signed-off-by: Simo Sorce <simo@redhat.com>
Jakuje
approved these changes
Jan 2, 2026
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
Currently the only way to use this is with a pre-release version of OpenSSL 4.0 which implement the required EVP_MD_CTX_serialize/deserialize functions. Only SHA2/SHA3 algorithms are supported.
Fixes #349
Checklist
Reviewer's checklist: