3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

arc4: Remove and move to src/crypto.c

This commit is contained in:
Denis Kenzior 2015-02-18 21:11:37 -06:00
parent da5812c0a6
commit ad3e0b6bf2
6 changed files with 28 additions and 86 deletions

View File

@ -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

View File

@ -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 <config.h>
#endif
#define _GNU_SOURCE
#include <ell/ell.h>
#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;
}

View File

@ -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 <stdbool.h>
#include <stdint.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);

View File

@ -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)
{

View File

@ -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);

View File

@ -28,7 +28,6 @@
#include <ell/ell.h>
#include "sha1.h"
#include "arc4.h"
#include "crypto.h"
#include "eapol.h"