Skip to content

Conversation

@mamckee
Copy link
Collaborator

@mamckee mamckee commented May 14, 2025

OpenSSL does not currently support resumable hashing, where an in-progress hash operation's state is saved, and can be loaded later to finish the hash. Some crypto libraries do support this such as golang/crypto. For libraries build as a compatibility layer on top of OpenSSL (e.g., golang-fips/openssl, there is no way through the OpenSSL APIs to support resumable hashing.

  • Adds custom parameters state (OSSL_PARAM_OCTET_STRING) and recompute_checksum (OSSL_PARAM_INTEGER) to the SymCrypt provider for MD5, SHA1, and SHA2 digests.

    • The exported hash state can be exported and imported by supplying the state parameter to EVP_MD_CTX_get_params and EVP_MD_CTX_set_params respectively.
    • If the state is constructed outside of SymCrypt, then recompute_checksum can optionally be set to tell the SymCrypt provider to recalculate the checksum SymCrypt expects at the end of the export blob.
  • Adds imported/exported digest tests to SslPlay.

  • Add an option to SslPlay to disable loading the SymCrypt engine.

    • If the engine is loaded, OpenSSL will always forward digest and cipher operations to the engine instead of the provider
  • Bump version to 1.9.0

  • Fixed typo in SymCrypt provider readme

  • Disable optimizations for debug builds

  • Fix SslPlay AES-XTS test. This test set an 8 byte IV but didn't explicitly try to change the IV size, causing a buffer overrun if the provider's default IV length was > 8

@samuel-lee-msft
Copy link
Contributor

samuel-lee-msft commented May 14, 2025

IMPLEMENT_SCOSSL_DIGEST_GENERIC(Sha3_512, sha3_512, SCOSSL_DIGEST_FLAG_ALGID_ABSENT)

Just skipped these to reduce risk of regression, or because there is something fundamentally harder about making SHA3 exportable?

If the implementation is the same shape I would go for it in this PR even if golang won't use it yet.

Overall, I think there's more risk of bugs from divergence between how we handle SCOSSL digests in the provider than from being eager with SHA3 #Resolved


Refers to: SymCryptProvider/src/digests/p_scossl_digest_generic.c:184 in 520bd0b. [](commit_id = 520bd0b, deletion_comment = False)

@mamckee
Copy link
Collaborator Author

mamckee commented May 15, 2025

IMPLEMENT_SCOSSL_DIGEST_GENERIC(Sha3_512, sha3_512, SCOSSL_DIGEST_FLAG_ALGID_ABSENT)

The PR is still a draft. I wanted to validate existing hashes with the golang-fips toolchain first. I'll be pushing SHA3 and cleanup before publishing this PR.


In reply to: 2881798636


Refers to: SymCryptProvider/src/digests/p_scossl_digest_generic.c:184 in 520bd0b. [](commit_id = 520bd0b, deletion_comment = False)

@mamckee mamckee requested a review from tobiasb-ms May 15, 2025 21:17
@mamckee mamckee marked this pull request as ready for review May 15, 2025 21:17
Copy link
Contributor

@samuel-lee-msft samuel-lee-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - assuming everything is working with the golang side, I'm happy to merge.

@mamckee mamckee requested a review from samuel-lee-msft May 21, 2025 22:24
@mamckee mamckee merged commit 7a97319 into main May 21, 2025
1 check passed
@mamckee mamckee deleted the mamckee-digest-state-export branch May 21, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants