diff options
author | sam <sam@FreeBSD.org> | 2007-07-11 15:48:36 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2007-07-11 15:48:36 +0000 |
commit | 752f54d1e6282a9ab07c3c1b8873e85478e1b5d2 (patch) | |
tree | d28146a5e4f221b71b1c40614e1cdb3257099603 /contrib/wpa_supplicant/eap_psk_common.c | |
parent | 5bd0ea9607199051ba241aacc8154d5258e42a50 (diff) | |
parent | 35aef052ff21baa52c4cec68b512986c21f70a48 (diff) | |
download | FreeBSD-src-752f54d1e6282a9ab07c3c1b8873e85478e1b5d2.zip FreeBSD-src-752f54d1e6282a9ab07c3c1b8873e85478e1b5d2.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r171366,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/wpa_supplicant/eap_psk_common.c')
-rw-r--r-- | contrib/wpa_supplicant/eap_psk_common.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/contrib/wpa_supplicant/eap_psk_common.c b/contrib/wpa_supplicant/eap_psk_common.c index 24de66c..8d896ae 100644 --- a/contrib/wpa_supplicant/eap_psk_common.c +++ b/contrib/wpa_supplicant/eap_psk_common.c @@ -1,6 +1,6 @@ /* - * WPA Supplicant / EAP-PSK shared routines - * Copyright (c) 2004-2005, Jouni Malinen <jkmaline@cc.hut.fi> + * EAP server/peer: EAP-PSK shared routines + * Copyright (c) 2004-2006, Jouni Malinen <j@w1.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 @@ -12,12 +12,11 @@ * See README and COPYING for more details. */ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> +#include "includes.h" #include "common.h" #include "aes_wrap.h" +#include "eap_defs.h" #include "eap_psk_common.h" #define aes_block_size 16 @@ -25,9 +24,9 @@ void eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk) { - memset(ak, 0, aes_block_size); + os_memset(ak, 0, aes_block_size); aes_128_encrypt_block(psk, ak, ak); - memcpy(kdk, ak, aes_block_size); + os_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); @@ -35,7 +34,8 @@ void eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk) } -void eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek, u8 *msk) +void eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek, u8 *msk, + u8 *emsk) { u8 hash[aes_block_size]; u8 counter = 1; @@ -48,10 +48,17 @@ void eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek, u8 *msk) hash[aes_block_size - 1] ^= counter; counter++; - for (i = 0; i < EAP_PSK_MSK_LEN / aes_block_size; i++) { + for (i = 0; i < EAP_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++; } + + for (i = 0; i < EAP_EMSK_LEN / aes_block_size; i++) { + hash[aes_block_size - 1] ^= counter; + aes_128_encrypt_block(kdk, hash, &emsk[i * aes_block_size]); + hash[aes_block_size - 1] ^= counter; + counter++; + } } |