OpenSSL: Use library function for PBKDF2 passphrase-to-PSK

Use the OpenSSL PKCS5_PBKDF2_HMAC_SHA1() function instead of the
internal implementation in sha1-pbkdf2.c.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2012-08-16 20:13:02 +03:00
parent 6e6909a97e
commit e40c86ad27
5 changed files with 18 additions and 0 deletions

View File

@ -676,7 +676,9 @@ ifdef NEED_FIPS186_2_PRF
SHA1OBJS += src/crypto/fips_prf_internal.c SHA1OBJS += src/crypto/fips_prf_internal.c
endif endif
endif endif
ifneq ($(CONFIG_TLS), openssl)
SHA1OBJS += src/crypto/sha1-pbkdf2.c SHA1OBJS += src/crypto/sha1-pbkdf2.c
endif
ifdef NEED_T_PRF ifdef NEED_T_PRF
SHA1OBJS += src/crypto/sha1-tprf.c SHA1OBJS += src/crypto/sha1-tprf.c
endif endif

View File

@ -667,7 +667,9 @@ ifdef NEED_FIPS186_2_PRF
SHA1OBJS += ../src/crypto/fips_prf_internal.o SHA1OBJS += ../src/crypto/fips_prf_internal.o
endif endif
endif endif
ifneq ($(CONFIG_TLS), openssl)
SHA1OBJS += ../src/crypto/sha1-pbkdf2.o SHA1OBJS += ../src/crypto/sha1-pbkdf2.o
endif
ifdef NEED_T_PRF ifdef NEED_T_PRF
SHA1OBJS += ../src/crypto/sha1-tprf.o SHA1OBJS += ../src/crypto/sha1-tprf.o
endif endif

View File

@ -688,3 +688,13 @@ int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len)
return -1; return -1;
} }
int pbkdf2_sha1(const char *passphrase, const u8 *ssid, size_t ssid_len,
int iterations, u8 *buf, size_t buflen)
{
if (PKCS5_PBKDF2_HMAC_SHA1(passphrase, os_strlen(passphrase), ssid,
ssid_len, 4096, buflen, buf) != 1)
return -1;
return 0;
}

View File

@ -1064,8 +1064,10 @@ endif
ifdef CONFIG_NO_WPA_PASSPHRASE ifdef CONFIG_NO_WPA_PASSPHRASE
L_CFLAGS += -DCONFIG_NO_PBKDF2 L_CFLAGS += -DCONFIG_NO_PBKDF2
else else
ifneq ($(CONFIG_TLS), openssl)
SHA1OBJS += src/crypto/sha1-pbkdf2.c SHA1OBJS += src/crypto/sha1-pbkdf2.c
endif endif
endif
ifdef NEED_T_PRF ifdef NEED_T_PRF
SHA1OBJS += src/crypto/sha1-tprf.c SHA1OBJS += src/crypto/sha1-tprf.c
endif endif

View File

@ -1091,8 +1091,10 @@ endif
ifdef CONFIG_NO_WPA_PASSPHRASE ifdef CONFIG_NO_WPA_PASSPHRASE
CFLAGS += -DCONFIG_NO_PBKDF2 CFLAGS += -DCONFIG_NO_PBKDF2
else else
ifneq ($(CONFIG_TLS), openssl)
SHA1OBJS += ../src/crypto/sha1-pbkdf2.o SHA1OBJS += ../src/crypto/sha1-pbkdf2.o
endif endif
endif
ifdef NEED_T_PRF ifdef NEED_T_PRF
SHA1OBJS += ../src/crypto/sha1-tprf.o SHA1OBJS += ../src/crypto/sha1-tprf.o
endif endif