wpa_enc.c revision a399b7655a1d835aa8606c2b29e4e777baac8635
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
* Sun elects to license this software under the BSD license.
* See README for more details.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "wpa_enc.h"
/*
* @kek: key encryption key (KEK)
* @n: length of the wrapped key in 64-bit units; e.g., 2 = 128-bit = 16 bytes
* @plain: plaintext key to be wrapped, n * 64 bit
* @cipher: wrapped key, (n + 1) * 64 bit
*/
void
{
uint8_t *a, *r, b[16];
int i, j;
a = cipher;
r = cipher + 8;
/* 1) Initialize variables. */
/*
* 2) Calculate intermediate values.
* For j = 0 to 5
* For i=1 to n
* B = AES(K, A | R[i])
* A = MSB(64, B) ^ t where t = (n*j)+i
* R[i] = LSB(64, B)
*/
for (j = 0; j <= 5; j++) {
r = cipher + 8;
for (i = 1; i <= n; i++) {
(void) memcpy(b, a, 8);
AES_encrypt(b, b, &key);
(void) memcpy(a, b, 8);
a[7] ^= n * j + i;
r += 8;
}
}
/*
* 3) Output the results.
*
* These are already in @cipher due to the location of temporary
* variables.
*/
}
/*
* @kek: key encryption key (KEK)
* @n: length of the wrapped key in 64-bit units; e.g., 2 = 128-bit = 16 bytes
* @cipher: wrapped key to be unwrapped, (n + 1) * 64 bit
* @plain: plaintext key, n * 64 bit
*/
int
{
int i, j;
/* 1) Initialize variables. */
r = plain;
/*
* 2) Compute intermediate values.
* For j = 5 to 0
* For i = n to 1
* B = AES-1(K, (A ^ t) | R[i]) where t = n*j+i
* A = MSB(64, B)
* R[i] = LSB(64, B)
*/
for (j = 5; j >= 0; j--) {
for (i = n; i >= 1; i--) {
(void) memcpy(b, a, 8);
b[7] ^= n * j + i;
AES_decrypt(b, b, &key);
(void) memcpy(a, b, 8);
r -= 8;
}
}
/*
* 3) Output results.
*
* These are already in @plain due to the location of temporary
* variables. Just verify that the IV matches with the expected value.
*/
for (i = 0; i < 8; i++) {
if (a[i] != 0xa6) {
return (-1);
}
}
return (0);
}
/* RFC 2104 */
void
{
unsigned int mac_len = 0;
}
void
{
int i, buf_len;
buf_len = 0;
for (i = 0; i < num_elem; i ++)
for (i = 0; i < num_elem; i ++) {
}
}
void
{
unsigned char *addr[4];
unsigned int len[4];
pos = 0;
if (plen >= SHA1_MAC_LEN) {
pos += SHA1_MAC_LEN;
} else {
break;
}
counter++;
}
}
void
{
}
void
{
}
void
{
RC4_KEY k;
}
void
{
int i, buf_len;
buf_len = 0;
for (i = 0; i < num_elem; i ++)
for (i = 0; i < num_elem; i ++) {
}
}
/* RFC 2104 */
void
{
unsigned int mac_len = 0;
}