Lines Matching +full:8 +full:- +full:n +full:- +full:1
4 * Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
17 * aes_unwrap - Unwrap key with AES Key Wrap Algorithm (RFC3394)
20 * @n: Length of the plaintext key in 64-bit units; e.g., 2 = 128-bit = 16
22 * @cipher: Wrapped key to be unwrapped, (n + 1) * 64 bits
23 * @plain: Plaintext key, n * 64 bits
24 * Returns: 0 on success, -1 on failure (e.g., integrity verification failed)
26 int aes_unwrap(const u8 *kek, size_t kek_len, int n, const u8 *cipher, in aes_unwrap() argument
29 u8 a[8], *r, b[AES_BLOCK_SIZE]; in aes_unwrap()
34 /* 1) Initialize variables. */ in aes_unwrap()
35 os_memcpy(a, cipher, 8); in aes_unwrap()
37 os_memcpy(r, cipher + 8, 8 * n); in aes_unwrap()
41 return -1; in aes_unwrap()
45 * For i = n to 1 in aes_unwrap()
46 * B = AES-1(K, (A ^ t) | R[i]) where t = n*j+i in aes_unwrap()
50 for (j = 5; j >= 0; j--) { in aes_unwrap()
51 r = plain + (n - 1) * 8; in aes_unwrap()
52 for (i = n; i >= 1; i--) { in aes_unwrap()
53 os_memcpy(b, a, 8); in aes_unwrap()
54 t = n * j + i; in aes_unwrap()
56 b[6] ^= t >> 8; in aes_unwrap()
60 os_memcpy(b + 8, r, 8); in aes_unwrap()
62 os_memcpy(a, b, 8); in aes_unwrap()
63 os_memcpy(r, b + 8, 8); in aes_unwrap()
64 r -= 8; in aes_unwrap()
74 for (i = 0; i < 8; i++) { in aes_unwrap()
76 return -1; in aes_unwrap()