net: wireless: decouple cnss crypto from cnss memory pre-alloc

The cnss crypto add support for wlan host driver for security
Protocol and cipher key generation where cnss memory pre-alloc
feature enable wlan driver to use pre allocated memory
for its internal usage and release it to back to pre-allocated pool.

Decouple cnss crypto from cnss memory pre-alloc and add kernel
config flag for this  crypto module compilation and update
the defocnfig of required targets.

CRs-Fixed: 949992
Change-Id: If34819fd76076ba522a9a42ac41fdae1f541f5c8
Signed-off-by: Sarada Prasanna Garnayak <sgarna@codeaurora.org>
This commit is contained in:
Sarada Prasanna Garnayak 2015-12-10 17:05:06 +05:30 committed by David Keitel
parent 4d09f895a3
commit 06ae5fe9fc
5 changed files with 18 additions and 11 deletions

View file

@ -303,6 +303,14 @@ config WCNSS_MEM_PRE_ALLOC
for it's internal usage and release it to back to pre allocated pool.
This memory is allocated at the cold boot time.
config CNSS_CRYPTO
tristate "Enable CNSS crypto support"
---help---
Add crypto support for the WLAN driver module.
This feature enable wlan driver to use the crypto APIs exported
from cnss platform driver. This crypto APIs used to generate cipher
key and add support for the WLAN driver module security protocol.
source "drivers/net/wireless/ath/Kconfig"
source "drivers/net/wireless/b43/Kconfig"
source "drivers/net/wireless/b43legacy/Kconfig"

View file

@ -65,3 +65,4 @@ obj-$(CONFIG_WCNSS_CORE) += wcnss/
obj-y += cnss/
obj-$(CONFIG_WCNSS_MEM_PRE_ALLOC) += cnss_prealloc/
obj-$(CONFIG_CNSS_CRYPTO) += cnss_crypto/

View file

@ -0,0 +1 @@
obj-$(CONFIG_CNSS_CRYPTO) += cnss_secif.o

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2013, 2015, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@ -91,7 +91,6 @@ static inline void leftshift_onebit(const u8 *input, u8 *output)
output[i] |= overflow;
overflow = (input[i] & 0x80) ? 1 : 0;
}
return;
}
static void generate_subkey(struct crypto_cipher *tfm, u8 *k1, u8 *k2)
@ -136,7 +135,6 @@ static inline void padding(u8 *lastb, u8 *pad, u16 length)
}
}
void wcnss_wlan_cmac_calc_mic(struct crypto_cipher *tfm, u8 *m,
u16 length, u8 *mac)
{
@ -144,21 +142,21 @@ void wcnss_wlan_cmac_calc_mic(struct crypto_cipher *tfm, u8 *m,
u8 m_last[AES_BLOCK_SIZE], padded[AES_BLOCK_SIZE];
u8 k1[AES_KEYSIZE_128], k2[AES_KEYSIZE_128];
int cmpBlk;
int i, nBlocks = (length + 15)/AES_BLOCK_SIZE;
int i, nblocks = (length + 15) / AES_BLOCK_SIZE;
generate_subkey(tfm, k1, k2);
if (nBlocks == 0) {
nBlocks = 1;
if (nblocks == 0) {
nblocks = 1;
cmpBlk = 0;
} else {
cmpBlk = ((length % AES_BLOCK_SIZE) == 0) ? 1 : 0;
}
if (cmpBlk) { /* Last block is complete block */
xor_128(&m[AES_BLOCK_SIZE * (nBlocks - 1)], k1, m_last);
xor_128(&m[AES_BLOCK_SIZE * (nblocks - 1)], k1, m_last);
} else { /* Last block is not complete block */
padding(&m[AES_BLOCK_SIZE * (nBlocks - 1)], padded,
padding(&m[AES_BLOCK_SIZE * (nblocks - 1)], padded,
length % AES_BLOCK_SIZE);
xor_128(padded, k2, m_last);
}
@ -166,7 +164,7 @@ void wcnss_wlan_cmac_calc_mic(struct crypto_cipher *tfm, u8 *m,
for (i = 0; i < AES_BLOCK_SIZE; i++)
x[i] = 0;
for (i = 0; i < (nBlocks - 1); i++) {
for (i = 0; i < (nblocks - 1); i++) {
xor_128(x, &m[AES_BLOCK_SIZE * i], y); /* y = Mi (+) x */
crypto_cipher_encrypt_one(tfm, x, y); /* x = AES-128(KEY, y) */
}

View file

@ -1,2 +1 @@
cnssprealloccore-objs += cnss_prealloc.o ../wcnss/qcomwlan_secif.o
obj-$(CONFIG_WCNSS_MEM_PRE_ALLOC) += cnssprealloccore.o
obj-$(CONFIG_WCNSS_MEM_PRE_ALLOC) += cnss_prealloc.o