From ad3e0b6bf25dd9d9206467ebf8a690e43812bb4f Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 18 Feb 2015 21:11:37 -0600 Subject: [PATCH] arc4: Remove and move to src/crypto.c --- Makefile.am | 7 +++---- src/arc4.c | 54 ---------------------------------------------------- src/arc4.h | 27 -------------------------- src/crypto.c | 23 ++++++++++++++++++++++ src/crypto.h | 2 ++ src/eapol.c | 1 - 6 files changed, 28 insertions(+), 86 deletions(-) delete mode 100644 src/arc4.c delete mode 100644 src/arc4.h diff --git a/Makefile.am b/Makefile.am index 19b2ff61..653765f3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,7 +45,6 @@ src_iwd_SOURCES = src/main.c linux/nl80211.h linux/kdbus.h \ src/kdbus.h src/kdbus.c \ src/netdev.h src/netdev.c \ src/wiphy.h src/wiphy.c \ - src/arc4.h src/arc4.c \ src/sha1.h src/sha1.c \ src/ie.h src/ie.c \ src/dbus.h src/dbus.c \ @@ -70,7 +69,6 @@ monitor_iwmon_SOURCES = monitor/main.c linux/nl80211.h \ src/mpdu.h src/mpdu.c \ src/util.h src/util.c \ src/sha1.h src/sha1.c \ - src/arc4.h src/arc4.c \ src/crypto.h src/crypto.c \ src/eapol.h src/eapol.c monitor_iwmon_LDADD = ell/libell-internal.la @@ -96,7 +94,9 @@ unit_test_cmac_aes_SOURCES = unit/test-cmac-aes.c \ unit_test_cmac_aes_LDADD = ell/libell-internal.la unit_test_arc4_SOURCES = unit/test-arc4.c \ - src/arc4.h src/arc4.c + src/sha1.h src/sha1.c \ + src/crypto.h src/crypto.c + unit_test_arc4_LDADD = ell/libell-internal.la unit_test_hmac_md5_SOURCES = unit/test-hmac-md5.c \ @@ -135,7 +135,6 @@ unit_test_mpdu_LDADD = ell/libell-internal.la unit_test_eapol_SOURCES = unit/test-eapol.c \ src/sha1.h src/sha1.c \ - src/arc4.h src/arc4.c \ src/crypto.h src/crypto.c \ src/eapol.h src/eapol.c unit_test_eapol_LDADD = ell/libell-internal.la diff --git a/src/arc4.c b/src/arc4.c deleted file mode 100644 index d3a7fb3d..00000000 --- a/src/arc4.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Wireless daemon for Linux - * - * Copyright (C) 2013-2014 Intel Corporation. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#define _GNU_SOURCE -#include - -#include "src/arc4.h" - -bool arc4_skip(const uint8_t *key, size_t key_len, size_t skip, - const uint8_t *in, size_t len, uint8_t *out) -{ - char skip_buf[1024]; - struct l_cipher *cipher; - - cipher = l_cipher_new(L_CIPHER_ARC4, key, key_len); - if (!cipher) - return false; - - while (skip > 0) { - size_t to_skip = - skip > sizeof(skip_buf) ? sizeof(skip_buf) : skip; - - l_cipher_decrypt(cipher, skip_buf, skip_buf, to_skip); - skip -= to_skip; - } - - l_cipher_decrypt(cipher, in, out, len); - l_cipher_free(cipher); - - return true; -} diff --git a/src/arc4.h b/src/arc4.h deleted file mode 100644 index 5c84368a..00000000 --- a/src/arc4.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * Wireless daemon for Linux - * - * Copyright (C) 2013-2015 Intel Corporation. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include -#include - -bool arc4_skip(const uint8_t *key, size_t key_len, size_t skip, - const uint8_t *in, size_t len, uint8_t *out); diff --git a/src/crypto.c b/src/crypto.c index 4ac69328..8ba4771e 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -134,6 +134,29 @@ bool aes_unwrap(const uint8_t *kek, const uint8_t *in, size_t len, return true; } +bool arc4_skip(const uint8_t *key, size_t key_len, size_t skip, + const uint8_t *in, size_t len, uint8_t *out) +{ + char skip_buf[1024]; + struct l_cipher *cipher; + + cipher = l_cipher_new(L_CIPHER_ARC4, key, key_len); + if (!cipher) + return false; + + while (skip > 0) { + size_t to_skip = + skip > sizeof(skip_buf) ? sizeof(skip_buf) : skip; + + l_cipher_decrypt(cipher, skip_buf, skip_buf, to_skip); + skip -= to_skip; + } + + l_cipher_decrypt(cipher, in, out, len); + l_cipher_free(cipher); + + return true; +} /* 802.11, Section 11.6.2, Table 11-4 */ int crypto_cipher_key_len(enum crypto_cipher cipher) { diff --git a/src/crypto.h b/src/crypto.h index 7572e54e..2a244e97 100644 --- a/src/crypto.h +++ b/src/crypto.h @@ -46,6 +46,8 @@ bool cmac_aes(const void *key, size_t key_len, bool aes_unwrap(const uint8_t *kek, const uint8_t *in, size_t len, uint8_t *out); +bool arc4_skip(const uint8_t *key, size_t key_len, size_t skip, + const uint8_t *in, size_t len, uint8_t *out); int crypto_cipher_key_len(enum crypto_cipher cipher); int crypto_cipher_tk_bits(enum crypto_cipher cipher); diff --git a/src/eapol.c b/src/eapol.c index 2a161299..62e23d48 100644 --- a/src/eapol.c +++ b/src/eapol.c @@ -28,7 +28,6 @@ #include #include "sha1.h" -#include "arc4.h" #include "crypto.h" #include "eapol.h"