Skip to content

Implement CKM_AES_KEY_WRAP_PKCS7 - #501

Merged
simo5 merged 4 commits into
latchset:mainfrom
simo5:aes_key_wrap_pkcs7
Sep 15, 2026
Merged

simo5 merged 4 commits into
latchset:mainfrom
simo5:aes_key_wrap_pkcs7

Conversation

@simo5

@simo5 simo5 commented Sep 10, 2026

Copy link
Copy Markdown
Member

Description

Adds the missing CKM_AES_KEY_WRAP_PKCS7 implementation, this mechanism is identical to the deprecated CKM_AES_KEY_WRAP_PAD and can be used do unwrap keys wrapped with that mechanism.

I believe this supersedes #448

Checklist

  • Test suite updated
  • Rustdoc string were added or updated
  • CHANGELOG and/or other documentation added or updated
  • This is not a code change

Reviewer's checklist:

  • Any issues marked for closing are fully addressed
  • There is a test suite reasonably covering new functionality or modifications
  • This feature/change has adequate documentation added
  • A changelog entry is added if the change is significant
  • Code conform to coding style that today cannot yet be enforced via the check style test
  • Commits have short titles and sensible text
  • Doc string are properly updated

@simo5

simo5 commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

@ab PTAL

@simo5
simo5 requested a review from Jakuje September 10, 2026 21:57
@simo5
simo5 force-pushed the aes_key_wrap_pkcs7 branch 3 times, most recently from 3b850fd to 209d2ff Compare September 11, 2026 15:49
Comment thread src/ossl/aes.rs
Comment thread src/ossl/aes.rs Outdated
@simo5
simo5 force-pushed the aes_key_wrap_pkcs7 branch from 209d2ff to 8dc60cd Compare September 14, 2026 18:54
@simo5
simo5 requested a review from Jakuje September 14, 2026 18:54
Implement the CKM_AES_KEY_WRAP_PKCS7 mechanism for AES encryption and
decryption operations. The implementation buffers data, applies PKCS#7 padding
to 8-byte boundaries before key wrapping, and verifies and strips padding
after unwrapping. Operations using this mechanism are marked as not approved
when FIPS mode is enabled. Unit tests covering round-trips, error conditions,
and test vectors are included.

Assisted-by: Gemini:Gemini 3.8 Flash
Signed-off-by: Simo Sorce <simo@redhat.com>
Rename AES_KWP_BLOCK to AES_KW_SEMIBLOCK across AES Key
Wrap implementations. In AES Key Wrap terminology, 64-bit
half-blocks are referred to as semiblocks, and the value is
used by multiple key wrap modes rather than just KWP.

Assisted-by: Gemini:Gemini 3.8 Flash
Signed-off-by: Simo Sorce <simo@redhat.com>
Replace the variable-time PKCS#7 padding check in AES key
unwrap with a constant-time evaluation of all valid padding
patterns over the final semiblock. This prevents potential
timing side channels during padding validation. Also add an
upfront buffer size check and expand test coverage to cover
all padding lengths.

Assisted-by: Gemini:Gemini 3.8 Flash
Signed-off-by: Simo Sorce <simo@redhat.com>
Signed-off-by: Simo Sorce <simo@redhat.com>
@simo5
simo5 merged commit 368008a into latchset:main Sep 15, 2026
68 checks passed
@simo5 simo5 mentioned this pull request Sep 21, 2026
3 of 11 tasks
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.

2 participants