Add AES Key Wrapping and Key Wrapping with Padding support#31
Add AES Key Wrapping and Key Wrapping with Padding support#31groumage wants to merge 6 commits intoquarkslab:mainfrom
Conversation
…n of the C library
- raw test vector files retrieved from https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/cavp-testing-block-cipher-modes - parsing of raw test vectors files to get pb2 files
|
Hi @groumage, thank you for the PR! I'll do a proper review later this week but from a quick glance it looks good. :) I do have some remarks in the meantime:
|
|
Hi @JulioLoayzaM,
For the last point, I think wrap/unwrap and seal/unseal nomenclature are here to emphasize that besides encrypt/decrypt, AES KW and KWP primitives manage the 8-byte block for integrity which is prepend to the key (= plaintext). When encrypt, this block is prepended and when decrypt, the value of this block is verified (in my PR, all of this are done in the AES C code). Maybe creating a new AES protocol would be too much as, even if there is this 8-byte block management, the high-level protocol is "encrypt a plaintext with a key", there is no additional elements. That being said, it is relevant to follow pycryptodome and pyca/cryptography nomenclature. My suggestion is to keep all the same AES protocols but replace # ECB / KW / KW_INV / KWP / KWP_INV
@overload
def _encrypt(mode: Literal[Mode.ECB, Mode.KW, Mode.KW_INV, Mode.KWP, Mode.KWP_INV],
key: bytes,
plaintext: bytes) -> bytes: ...with something like # ECB
@overload
def _encrypt(mode: Literal[Mode.ECB],
key: bytes,
plaintext: bytes) -> bytes: ...
# KW / KW_INV / KWP / KWP_INV
@overload
def _seal(mode: LiteralMode.KW, Mode.KW_INV, Mode.KWP, Mode.KWP_INV],
key: bytes,
plaintext: bytes) -> bytes: ...to emphasize that with |
|
Hi @JulioLoayzaM, I hope you doing well. Do you have any more insight about my PR? I stay available for further discussions if needed. |
Hi, this PR add AES Key Wrapping (AES-KW) and AES Key Wrapping with Padding (AES-KWP) feature for crypto-condor. I implemented key wrapping algorithms on the C library of AES to follow the existing structure. I followed SP 800-38F (https://csrc.nist.gov/pubs/sp/800/38/f/final) and RFC 3394 (https://datatracker.ietf.org/doc/html/rfc3394) to create the implementation.
The test vectors I added to crypto-condor come from both NIST test vector (https://csrc.nist.gov/Projects/cryptographic-algorithm-validation-program/cavp-testing-block-cipher-modes) and wycheproof test vectors for AES-KWP (https://github.com/C2SP/wycheproof/blob/main/testvectors_v1/aes_kwp_test.json).
make allis working and returns no errors or warnings.