AES key wrapping

The key value in AES tokens are wrapped using the AES algorithm and cipher block chaining (CBC) mode of encryption.

The key value is left-aligned in a 32-byte block, padded on the right with zero, and encrypted.

The enhanced wrapping of an AES key (*K) using an AES *MK is defined as:
e*MK(*K) = ecbcMK(*K)
where:
e*k(m) or e*kek(*k)
message m is encrypted (e) with key *k or key *k is encrypted with key encrypting key *kek
ecbc*k(m)
message m is encrypted (e) with key *k using the cipher block chaining (cbc) mode of operation