I have trouble understanding inputs for AES key wrap algorithm as it is explained in section 2.2.1 of RFC3394.
- 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).
- 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).
- 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!