aboutsummaryrefslogtreecommitdiffstats
path: root/src/crypto
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-08-16 20:13:14 +0300
committerJouni Malinen <j@w1.fi>2009-08-16 20:13:14 +0300
commitac73690c06e8c05a9e36483b104a431c26171512 (patch)
treeed7f06db4091c9f1c71fed7e746f9257fd283c99 /src/crypto
parent8ef168311557982dd6b88cfcf26453aeb4dad6ac (diff)
downloadexternal_wpa_supplicant_8_ti-ac73690c06e8c05a9e36483b104a431c26171512.zip
external_wpa_supplicant_8_ti-ac73690c06e8c05a9e36483b104a431c26171512.tar.gz
external_wpa_supplicant_8_ti-ac73690c06e8c05a9e36483b104a431c26171512.tar.bz2
Move RC4 into crypto.h as a replaceable crypto function
This allows crypto library wrappers to override the internal RC4 implementation in the same way as can already be done for other crypto algorithms.
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/crypto.h16
-rw-r--r--src/crypto/crypto_internal.c1
-rw-r--r--src/crypto/crypto_libtomcrypt.c1
-rw-r--r--src/crypto/ms_funcs.c1
-rw-r--r--src/crypto/rc4.c20
-rw-r--r--src/crypto/rc4.h21
6 files changed, 21 insertions, 39 deletions
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h
index be3609e..44d0fb8 100644
--- a/src/crypto/crypto.h
+++ b/src/crypto/crypto.h
@@ -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 */
diff --git a/src/crypto/crypto_internal.c b/src/crypto/crypto_internal.c
index 98a1ddc..9501dfd 100644
--- a/src/crypto/crypto_internal.c
+++ b/src/crypto/crypto_internal.c
@@ -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"
diff --git a/src/crypto/crypto_libtomcrypt.c b/src/crypto/crypto_libtomcrypt.c
index 2ccf46d..c701f55 100644
--- a/src/crypto/crypto_libtomcrypt.c
+++ b/src/crypto/crypto_libtomcrypt.c
@@ -16,7 +16,6 @@
#include <tomcrypt.h>
#include "common.h"
-#include "rc4.h"
#include "crypto.h"
#ifndef mp_init_multi
diff --git a/src/crypto/ms_funcs.c b/src/crypto/ms_funcs.c
index 9839a7d..dae15ab 100644
--- a/src/crypto/ms_funcs.c
+++ b/src/crypto/ms_funcs.c
@@ -18,7 +18,6 @@
#include "sha1.h"
#include "ms_funcs.h"
#include "crypto.h"
-#include "rc4.h"
/**
diff --git a/src/crypto/rc4.c b/src/crypto/rc4.c
index 70c790e..5ab1be1 100644
--- a/src/crypto/rc4.c
+++ b/src/crypto/rc4.c
@@ -15,24 +15,12 @@
#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
index 35c7e41..0000000
--- a/src/crypto/rc4.h
+++ /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 */