]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Move RC4 into crypto.h as a replaceable crypto function
authorJouni Malinen <j@w1.fi>
Sun, 16 Aug 2009 17:13:14 +0000 (20:13 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 16 Aug 2009 17:13:14 +0000 (20:13 +0300)
This allows crypto library wrappers to override the internal RC4
implementation in the same way as can already be done for other crypto
algorithms.

13 files changed:
hostapd/Makefile
hostapd/ieee802_11.c
hostapd/ieee802_1x.c
hostapd/wpa.c
src/crypto/crypto.h
src/crypto/crypto_internal.c
src/crypto/crypto_libtomcrypt.c
src/crypto/ms_funcs.c
src/crypto/rc4.c
src/crypto/rc4.h [deleted file]
src/eapol_supp/eapol_supp_sm.c
src/rsn_supp/wpa.c
wpa_supplicant/Makefile

index b09d3c32726a07884357a08621c4dc257da504ce..226f0fccb8d1288fcafad19db19ae04a3b9641a5 100644 (file)
@@ -89,7 +89,6 @@ OBJS += ctrl_iface.o
 endif
 
 OBJS += ../src/crypto/md5.o
-OBJS += ../src/crypto/rc4.o
 
 AESOBJS = # none so far
 
@@ -437,6 +436,7 @@ ifdef NEED_FIPS186_2_PRF
 OBJS += ../src/crypto/fips_prf_openssl.o
 OBJS_p += ../src/crypto/fips_prf_openssl.o
 endif
+CONFIG_INTERNAL_RC4=y
 endif
 ifeq ($(CONFIG_TLS), gnutls)
 OBJS += ../src/crypto/crypto_gnutls.o
@@ -447,12 +447,14 @@ OBJS += ../src/crypto/fips_prf_gnutls.o
 OBJS_p += ../src/crypto/fips_prf_gnutls.o
 endif
 CONFIG_INTERNAL_SHA256=y
+CONFIG_INTERNAL_RC4=y
 endif
 ifeq ($(CONFIG_TLS), internal)
 ifeq ($(CONFIG_CRYPTO), libtomcrypt)
 OBJS += ../src/crypto/crypto_libtomcrypt.o
 OBJS_p += ../src/crypto/crypto_libtomcrypt.o
 CONFIG_INTERNAL_SHA256=y
+CONFIG_INTERNAL_RC4=y
 endif
 ifeq ($(CONFIG_CRYPTO), internal)
 OBJS += ../src/crypto/crypto_internal.o ../src/tls/rsa.o ../src/tls/bignum.o
@@ -473,6 +475,7 @@ CONFIG_INTERNAL_SHA1=y
 CONFIG_INTERNAL_MD4=y
 CONFIG_INTERNAL_MD5=y
 CONFIG_INTERNAL_SHA256=y
+CONFIG_INTERNAL_RC4=y
 endif
 endif
 else
@@ -480,6 +483,7 @@ CONFIG_INTERNAL_AES=y
 CONFIG_INTERNAL_SHA1=y
 CONFIG_INTERNAL_MD5=y
 CONFIG_INTERNAL_SHA256=y
+CONFIG_INTERNAL_RC4=y
 endif
 
 ifdef CONFIG_INTERNAL_AES
@@ -500,6 +504,9 @@ endif
 ifdef CONFIG_INTERNAL_DES
 OBJS += ../src/crypto/des-internal.o
 endif
+ifdef CONFIG_INTERNAL_RC4
+OBJS += ../src/crypto/rc4.o
+endif
 
 ifdef NEED_SHA256
 OBJS += ../src/crypto/sha256.o
index 42e1e99b8cb71da7f1c1d665ef7813c0b81cba71..801048b22f24dcac920b59e53a23a9ce75f7a46f 100644 (file)
@@ -28,7 +28,7 @@
 #include "radius/radius_client.h"
 #include "ieee802_11_auth.h"
 #include "sta_info.h"
-#include "rc4.h"
+#include "crypto.h"
 #include "ieee802_1x.h"
 #include "wpa.h"
 #include "wme.h"
index 9e26521df201350bb6fdaaac79cb80605047f24c..0037f62a515e8da4aeb6284cb2322ce952344142 100644 (file)
@@ -21,7 +21,7 @@
 #include "radius/radius_client.h"
 #include "eapol_sm.h"
 #include "md5.h"
-#include "rc4.h"
+#include "crypto.h"
 #include "eloop.h"
 #include "sta_info.h"
 #include "wpa.h"
index 5ec7211fec7b9b01a34b71d0cedcef508a1903df..e7a179df01f30c195165fef195ae5ecd12fe9aea 100644 (file)
@@ -22,7 +22,6 @@
 #include "wpa.h"
 #include "sha1.h"
 #include "sha256.h"
-#include "rc4.h"
 #include "aes_wrap.h"
 #include "crypto.h"
 #include "eloop.h"
index be3609e3424306fccbcaf8fb6e37976caaf58791..44d0fb8f4199a105b6e412a7a7812330ac5a7b1f 100644 (file)
@@ -448,4 +448,20 @@ int __must_check crypto_mod_exp(const u8 *base, size_t base_len,
                                const u8 *modulus, size_t modulus_len,
                                u8 *result, size_t *result_len);
 
+/**
+ * rc4_skip - XOR RC4 stream to given data with skip-stream-start
+ * @key: RC4 key
+ * @keylen: RC4 key length
+ * @skip: number of bytes to skip from the beginning of the RC4 stream
+ * @data: data to be XOR'ed with RC4 stream
+ * @data_len: buf length
+ * Returns: 0 on success, -1 on failure
+ *
+ * Generate RC4 pseudo random stream for the given key, skip beginning of the
+ * stream, and XOR the end result with the data buffer to perform RC4
+ * encryption/decryption.
+ */
+int rc4_skip(const u8 *key, size_t keylen, size_t skip,
+            u8 *data, size_t data_len);
+
 #endif /* CRYPTO_H */
index 98a1ddcb5f8532bc915adf70dd03dbb373aca2de..9501dfd623f01a7a6b5b4980677ce64e8f70d019 100644 (file)
@@ -18,7 +18,6 @@
 #include "crypto.h"
 #include "md5.h"
 #include "sha1.h"
-#include "rc4.h"
 #include "aes.h"
 #include "tls/rsa.h"
 #include "tls/bignum.h"
index 2ccf46d8138b9814f58efef8af3f97c2be4bba06..c701f5581f36be088d9906c81fde1d42feb9be32 100644 (file)
@@ -16,7 +16,6 @@
 #include <tomcrypt.h>
 
 #include "common.h"
-#include "rc4.h"
 #include "crypto.h"
 
 #ifndef mp_init_multi
index 9839a7dd15e889a721f4725315f43d005d7952a4..dae15ab915fe75f75365e8df967c1e51ca270099 100644 (file)
@@ -18,7 +18,6 @@
 #include "sha1.h"
 #include "ms_funcs.h"
 #include "crypto.h"
-#include "rc4.h"
 
 
 /**
index 70c790e364f79a0784bc83bfffdd2ad21eebd517..5ab1be191e9a50db8a982fdcaa8daed42ba3fef9 100644 (file)
 #include "includes.h"
 
 #include "common.h"
-#include "rc4.h"
+#include "crypto.h"
 
 #define S_SWAP(a,b) do { u8 t = S[a]; S[a] = S[b]; S[b] = t; } while(0)
 
-/**
- * rc4 - XOR RC4 stream to given data with skip-stream-start
- * @key: RC4 key
- * @keylen: RC4 key length
- * @skip: number of bytes to skip from the beginning of the RC4 stream
- * @data: data to be XOR'ed with RC4 stream
- * @data_len: buf length
- *
- * Generate RC4 pseudo random stream for the given key, skip beginning of the
- * stream, and XOR the end result with the data buffer to perform RC4
- * encryption/decryption.
- */
-void rc4_skip(const u8 *key, size_t keylen, size_t skip,
-             u8 *data, size_t data_len)
+int rc4_skip(const u8 *key, size_t keylen, size_t skip,
+            u8 *data, size_t data_len)
 {
        u32 i, j, k;
        u8 S[256], *pos;
@@ -67,4 +55,6 @@ void rc4_skip(const u8 *key, size_t keylen, size_t skip,
                S_SWAP(i, j);
                *pos++ ^= S[(S[i] + S[j]) & 0xff];
        }
+
+       return 0;
 }
diff --git a/src/crypto/rc4.h b/src/crypto/rc4.h
deleted file mode 100644 (file)
index 35c7e41..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * RC4 stream cipher
- * Copyright (c) 2002-2005, 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
- * 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.
- */
-
-#ifndef RC4_H
-#define RC4_H
-
-void rc4_skip(const u8 *key, size_t keylen, size_t skip,
-             u8 *data, size_t data_len);
-
-#endif /* RC4_H */
index 58e62211af6f6590bdef390323d120582d1e4208..19d57b9c49a742e7cadd470245940abcbca525ab 100644 (file)
@@ -20,7 +20,7 @@
 #include "eloop.h"
 #include "eapol_common.h"
 #include "md5.h"
-#include "rc4.h"
+#include "crypto.h"
 #include "state_machine.h"
 #include "wpabuf.h"
 
index 16b641afe9e45103283c64b72f408a0aea508bba..7003db3402ca9f5bede65d03354886f67b1eaecf 100644 (file)
@@ -15,7 +15,7 @@
 #include "includes.h"
 
 #include "common.h"
-#include "rc4.h"
+#include "crypto.h"
 #include "aes_wrap.h"
 #include "wpa.h"
 #include "eloop.h"
index 219c5c4041048db3727fb9fb3974d763bb015dc6..ac200d2689e343beeda50e43eb14190022866afd 100644 (file)
@@ -52,7 +52,6 @@ OBJS = config.o
 OBJS += ../src/utils/common.o
 OBJS += ../src/utils/wpa_debug.o
 OBJS += ../src/utils/wpabuf.o
-OBJS += ../src/crypto/rc4.o
 OBJS_p = wpa_passphrase.o
 OBJS_p += ../src/utils/common.o
 OBJS_p += ../src/utils/wpa_debug.o
@@ -677,6 +676,7 @@ CONFIG_INTERNAL_AES=y
 CONFIG_INTERNAL_SHA1=y
 CONFIG_INTERNAL_MD5=y
 CONFIG_INTERNAL_SHA256=y
+CONFIG_INTERNAL_RC4=y
 endif
 ifdef CONFIG_SMARTCARD
 ifndef CONFIG_NATIVE_WINDOWS
@@ -732,6 +732,7 @@ OBJS_p += ../src/crypto/crypto_openssl.o
 ifdef NEED_FIPS186_2_PRF
 OBJS += ../src/crypto/fips_prf_openssl.o
 endif
+CONFIG_INTERNAL_RC4=y
 endif
 ifeq ($(CONFIG_TLS), gnutls)
 OBJS += ../src/crypto/crypto_gnutls.o
@@ -740,17 +741,20 @@ ifdef NEED_FIPS186_2_PRF
 OBJS += ../src/crypto/fips_prf_gnutls.o
 endif
 CONFIG_INTERNAL_SHA256=y
+CONFIG_INTERNAL_RC4=y
 endif
 ifeq ($(CONFIG_TLS), schannel)
 OBJS += ../src/crypto/crypto_cryptoapi.o
 OBJS_p += ../src/crypto/crypto_cryptoapi.o
 CONFIG_INTERNAL_SHA256=y
+CONFIG_INTERNAL_RC4=y
 endif
 ifeq ($(CONFIG_TLS), internal)
 ifeq ($(CONFIG_CRYPTO), libtomcrypt)
 OBJS += ../src/crypto/crypto_libtomcrypt.o
 OBJS_p += ../src/crypto/crypto_libtomcrypt.o
 CONFIG_INTERNAL_SHA256=y
+CONFIG_INTERNAL_RC4=y
 endif
 ifeq ($(CONFIG_CRYPTO), internal)
 OBJS += ../src/crypto/crypto_internal.o ../src/tls/bignum.o
@@ -771,18 +775,21 @@ CONFIG_INTERNAL_SHA1=y
 CONFIG_INTERNAL_MD4=y
 CONFIG_INTERNAL_MD5=y
 CONFIG_INTERNAL_SHA256=y
+CONFIG_INTERNAL_RC4=y
 endif
 ifeq ($(CONFIG_CRYPTO), cryptoapi)
 OBJS += ../src/crypto/crypto_cryptoapi.o
 OBJS_p += ../src/crypto/crypto_cryptoapi.o
 CFLAGS += -DCONFIG_CRYPTO_CRYPTOAPI
 CONFIG_INTERNAL_SHA256=y
+CONFIG_INTERNAL_RC4=y
 endif
 endif
 ifeq ($(CONFIG_TLS), none)
 OBJS += ../src/crypto/crypto_none.o
 OBJS_p += ../src/crypto/crypto_none.o
 CONFIG_INTERNAL_SHA256=y
+CONFIG_INTERNAL_RC4=y
 endif
 else
 CONFIG_INTERNAL_AES=y
@@ -812,6 +819,10 @@ ifdef CONFIG_INTERNAL_DES
 DESOBJS += ../src/crypto/des-internal.o
 endif
 
+ifdef CONFIG_INTERNAL_RC4
+OBJS += ../src/crypto/rc4.o
+endif
+
 ifdef CONFIG_IEEE80211R
 NEED_SHA256=y
 endif