AES-KW and AES-KWP
AES key wrap with and without padding.
from oxcrypto import InvalidTag
from oxcrypto.keywrap.aes_kw import AES_KW
kek = bytes.fromhex("000102030405060708090a0b0c0d0e0f")
key = bytes.fromhex("00112233445566778899aabbccddeeff")
wrapped = AES_KW.KW_AES128.wrap(kek, key)
assert wrapped.hex() == "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5"
assert AES_KW.KW_AES128.unwrap(kek, wrapped) == key
try:
AES_KW.KW_AES128.unwrap(bytes(16), wrapped)
except InvalidTag:
passVariants: KW_AES128, KW_AES192, KW_AES256 (RFC 3394; key material is a multiple of 8 bytes, at least 16) and KWP_AES128, KWP_AES192, KWP_AES256 (RFC 5649; any length from 1 byte). The key-encryption key length matches the AES variant.