Repository navigation
crypto: offload OpenSSL SM4 block modes to SG2002 - #514
Closed
dormancygrace wants to merge 1 commit into
Closed
dormancygrace wants to merge 1 commit into
dormancygrace wants to merge 1 commit into
Conversation
This was referenced Oct 26, 2026
dormancygrace
commented
Oct 26, 2026
dormancygrace
left a comment
Owner
Author
There was a problem hiding this comment.
The CBC, ECB and CTR glue mirrors the AES version in #511 and is correct. cipher_sm4_sg2002.inc differs from the AES include only in names, so a shared include would help later maintenance.
| +{ | ||
| + PROV_SM4_CTX *a = (PROV_SM4_CTX *)ctx; | ||
| + return ossl_sg2002_cipher(SG2002_ALG_SM4, mode, ctx->enc, | ||
| + a->sg2002_key, ctx->keylen, ctx->iv, 16, in, out, len, SG2002_SM4_MIN); |
Owner
Author
There was a problem hiding this comment.
SM4-CTR passes counter_bytes = 16, so it relies on the same unverified assumption as AES-CTR in #511: that the engine carries the full 128-bit counter inside a request. Please apply whatever fix is chosen there, and include SM4-CTR in the on-device carry test.
Build outputsCompared with the build of main at c93fb1a; codex/openssl-tdes is at 975f969, so outputs changed since then are listed too. 3 changed, 14 added, 0 removed of 584 outputs.
|
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.
Adds
0008-sm4-dma.patchon top of #513. SM4 ECB/CBC/CTR offload a confirmed whole-block prefix through SG2002. OpenSSL retains padding, partial updates, context duplication and software continuation; CTR consumes outstanding keystream bytes before DMA. Other modes, newer RISC-V crypto implementations and FIPS stay unchanged.Validation: full warning-free RISC-V OpenSSL 3.5.9 build. Shared ASan/UBSan block-state and independent EVP-reference suites include all three SM4 modes. Native correctness, driver counter proof, CPU/RAM and crossover measurements are pending. The 1024-byte minimum is provisional; this draft claims no measured speedup.