diff options
author | sam <sam@FreeBSD.org> | 2006-03-07 05:47:04 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2006-03-07 05:47:04 +0000 |
commit | 84f883d618d0eca94f2e20b3d29474005c455cc6 (patch) | |
tree | 161a6132f61b543e3759ff389bacc462dacf3d72 /contrib/hostapd/eap_psk_common.c | |
parent | f87f3cf9d3ac68ade33194941f85722ffdff2195 (diff) | |
parent | 8d55057fb42bf9070fd379acbcb6fc4ef793d2a7 (diff) | |
download | FreeBSD-src-84f883d618d0eca94f2e20b3d29474005c455cc6.zip FreeBSD-src-84f883d618d0eca94f2e20b3d29474005c455cc6.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r156373,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/hostapd/eap_psk_common.c')
-rw-r--r-- | contrib/hostapd/eap_psk_common.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/contrib/hostapd/eap_psk_common.c b/contrib/hostapd/eap_psk_common.c new file mode 100644 index 0000000..24de66c --- /dev/null +++ b/contrib/hostapd/eap_psk_common.c @@ -0,0 +1,57 @@ +/* + * WPA Supplicant / EAP-PSK shared routines + * Copyright (c) 2004-2005, Jouni Malinen <jkmaline@cc.hut.fi> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Alternatively, this software may be distributed under the terms of BSD + * license. + * + * See README and COPYING for more details. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "common.h" +#include "aes_wrap.h" +#include "eap_psk_common.h" + +#define aes_block_size 16 + + +void eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk) +{ + memset(ak, 0, aes_block_size); + aes_128_encrypt_block(psk, ak, ak); + memcpy(kdk, ak, aes_block_size); + ak[aes_block_size - 1] ^= 0x01; + kdk[aes_block_size - 1] ^= 0x02; + aes_128_encrypt_block(psk, ak, ak); + aes_128_encrypt_block(psk, kdk, kdk); +} + + +void eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek, u8 *msk) +{ + u8 hash[aes_block_size]; + u8 counter = 1; + int i; + + aes_128_encrypt_block(kdk, rand_p, hash); + + hash[aes_block_size - 1] ^= counter; + aes_128_encrypt_block(kdk, hash, tek); + hash[aes_block_size - 1] ^= counter; + counter++; + + for (i = 0; i < EAP_PSK_MSK_LEN / aes_block_size; i++) { + hash[aes_block_size - 1] ^= counter; + aes_128_encrypt_block(kdk, hash, &msk[i * aes_block_size]); + hash[aes_block_size - 1] ^= counter; + counter++; + } +} |