Key Wrapping and Unwrapping in Message Authentication CODE
Background
This uses AES or triple DES as the underlying encryption algorithm. The purpose of key wrapping is to securely exchange a symmetric key to be shared by two parties using a symmetric key already by those parties. The latter key is called a key encryption key (kek).
The Key Wrapping Algorithm
The key wrapping algorithm operates on blocks of 64 bits. The input to the algorithm consists a 64-bit constant, discussed subsequently, and a plaintext key that is divided into blocks of 64 bits. We use the following notation:
MSB64(W) = most significant 64 bits of W.
LSB64(W) = least significant 64 bits of W.
W = temporary value; output of encryption function
|| = concatenation
K = key encryption key
n = number of 64-bit key data blocks.
s = number of stages in the wrapping process; s = 6n
Pi = ith plaintext key data block;
1<=i<=n
Ci = ith ciphertext data block;
0<=i<=n
A(t) = 64-bit integrity check register after encryption
stage t; 1<=t<=s
A(0) = initial integrity check value (ICV); in hexadecimal:
A6A6A6A6A6A6A6A6
R(t,i) = 64-bit register i after encryption stage t; 1<=t<=s; 1<=i<=n
We now describe the key wrapping algorithm:
Inputs : Plaintext, n 64-bit values (P1, P2, P3,----,Pn) ; Key Encryption Key, K Outputs : Ciphertext, (n+1) 64-bit values (C0,C1,C2,…,Cn) |
1. Initialize variables A(0) = A6A6A6A6A6A6A6A6 for i = 1 to n R(0, i) = Pi 2. Calculate intermediate values for t=1 to s W = E(K, [A(t-1) || R(t-1, 1)]) A(t) = t xor MSB64(W) R(t,n) = LSB64(W) for i = 1 to n-1 R(t, i) = R(t-1, i+1) 3. Output results C0 = A(s) for i = 1 to n Ci = R(s, i) |
Here Fig.1 explains the key wrapping operation on 256-bit key value.
Note 1 : Ciphertext is one block larger than the plaintext key to accommodate the ICV. Upon wrapping (decryption), both 64 bit ICV and plaintext key are recovered. If recovered ICV differs from the input value of hexadecimal A6A6A6A6A6A6A6A6, then an error on alteration has been detected and the plaintext key is rejected.
Key Unwrapping
The key Unwrapping algorithm can be defined as follows:
Inputs : Ciphertext, (n+1) 64-bit values (C0,C1,C2,---Cn)
; Key encryption Key, K Outputs : Plaintext, n 64-bit values (P1,P2,----,Pn),
ICV |
1. Initialize variables A(s) = C0 for i = 1 to n R(s, i) = Ci 2. Calculate intermediate values for t = s to 1 W = D(K, [A(t) xor t) || R(t, n)]) A(t-1) = MSB64(W) R(t-1,1) = LSB64(W) for i = 2 to n R(t-1, i) = R(t, i-1) 3. Output results if A(0) = A6A6A6A6A6A6A6A6 then for i = 1 to n P(i) = R(0, i) else return error |
*************************************************************************************************************
Comments
Post a Comment