I have trouble understanding inputs for AES key wrap algorithm as it is explained in section 2.2.1 of RFC3394.


  1. I have a data encryption key (DEK) for AES-128 with CTR, which is used to encrypt a database file on a mobile device. DEK is device specific and has limited lifetime (1 year) as key rollover is applied. DEK is generated with help of salt and secret values generated on the server when authenticated user provides some random value (constant as long as mobile application is installed).
  2. I have a key-encryption key (KEK, AES-128), that is derived from user's passphrase and is used to encrypt the DEK (encrypted DEK is stored in plaintext).
  3. DEK and KEK never leave the device.

Above scheme helps me keep DEK unchanged in case user changes her passphrase and allows users working with the application in offline mode (correct passphrase recreates KEK which decrypts DEK which next allows working with database).

My question is how should I apply AES key wrap? The RFC states:

The inputs to the key wrapping process are the KEK and the plaintext to be wrapped. The plaintext consists of n 64-bit blocks, containing the key data being wrapped.

What are plaintext and KEK here? My DEK is plaintext and my KEK is the KEK? Or it should be passphrase (plaintext) and my DEK as KEK? I'm pretty confused and would appreciate any guidance here. Thanks!


1 Answer 1


The DEK is indeed the "plaintext" and the KEK, derived from the user's pass phrase in your case, is the KEK.

A passphrase is not a key and should never be directly used as a key; you should use a password based key derivation function (such as PBKDF2) to derive a key from a passphrase.

  • $\begingroup$ Yes, I understand passwords cannot be used as is - I always do at least 20k iterations of PBKDF2(salt, secret) with PRF algorithm. Anyway, thank you for clearing up my confusion (indeed my first intuition was correct). I'll accept your answer soon. $\endgroup$
    – matm
    Commented Dec 7, 2017 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.