mac80211: use AES_BLOCK_SIZE
authorJohannes Berg <johannes.berg@intel.com>
Wed, 6 Jul 2011 20:02:14 +0000 (22:02 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 8 Jul 2011 15:11:24 +0000 (11:11 -0400)
mac80211 has a defnition of AES_BLOCK_SIZE and
multiple definitions of AES_BLOCK_LEN. Remove
them all and use crypto/aes.h.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/mac80211/aes_ccm.c
net/mac80211/aes_ccm.h
net/mac80211/aes_cmac.c
net/mac80211/key.h
net/mac80211/wpa.c

index b9b595c..0785e95 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/types.h>
 #include <linux/crypto.h>
 #include <linux/err.h>
+#include <crypto/aes.h>
 
 #include <net/mac80211.h>
 #include "key.h"
@@ -21,21 +22,21 @@ static void aes_ccm_prepare(struct crypto_cipher *tfm, u8 *scratch, u8 *a)
        int i;
        u8 *b_0, *aad, *b, *s_0;
 
-       b_0 = scratch + 3 * AES_BLOCK_LEN;
-       aad = scratch + 4 * AES_BLOCK_LEN;
+       b_0 = scratch + 3 * AES_BLOCK_SIZE;
+       aad = scratch + 4 * AES_BLOCK_SIZE;
        b = scratch;
-       s_0 = scratch + AES_BLOCK_LEN;
+       s_0 = scratch + AES_BLOCK_SIZE;
 
        crypto_cipher_encrypt_one(tfm, b, b_0);
 
        /* Extra Authenticate-only data (always two AES blocks) */
-       for (i = 0; i < AES_BLOCK_LEN; i++)
+       for (i = 0; i < AES_BLOCK_SIZE; i++)
                aad[i] ^= b[i];
        crypto_cipher_encrypt_one(tfm, b, aad);
 
-       aad += AES_BLOCK_LEN;
+       aad += AES_BLOCK_SIZE;
 
-       for (i = 0; i < AES_BLOCK_LEN; i++)
+       for (i = 0; i < AES_BLOCK_SIZE; i++)
                aad[i] ^= b[i];
        crypto_cipher_encrypt_one(tfm, a, aad);
 
@@ -57,12 +58,12 @@ void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch,
        u8 *pos, *cpos, *b, *s_0, *e, *b_0;
 
        b = scratch;
-       s_0 = scratch + AES_BLOCK_LEN;
-       e = scratch + 2 * AES_BLOCK_LEN;
-       b_0 = scratch + 3 * AES_BLOCK_LEN;
+       s_0 = scratch + AES_BLOCK_SIZE;
+       e = scratch + 2 * AES_BLOCK_SIZE;
+       b_0 = scratch + 3 * AES_BLOCK_SIZE;
 
-       num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_LEN);
-       last_len = data_len % AES_BLOCK_LEN;
+       num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_SIZE);
+       last_len = data_len % AES_BLOCK_SIZE;
        aes_ccm_prepare(tfm, scratch, b);
 
        /* Process payload blocks */
@@ -70,7 +71,7 @@ void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch,
        cpos = cdata;
        for (j = 1; j <= num_blocks; j++) {
                int blen = (j == num_blocks && last_len) ?
-                       last_len : AES_BLOCK_LEN;
+                       last_len : AES_BLOCK_SIZE;
 
                /* Authentication followed by encryption */
                for (i = 0; i < blen; i++)
@@ -96,12 +97,12 @@ int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch,
        u8 *pos, *cpos, *b, *s_0, *a, *b_0;
 
        b = scratch;
-       s_0 = scratch + AES_BLOCK_LEN;
-       a = scratch + 2 * AES_BLOCK_LEN;
-       b_0 = scratch + 3 * AES_BLOCK_LEN;
+       s_0 = scratch + AES_BLOCK_SIZE;
+       a = scratch + 2 * AES_BLOCK_SIZE;
+       b_0 = scratch + 3 * AES_BLOCK_SIZE;
 
-       num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_LEN);
-       last_len = data_len % AES_BLOCK_LEN;
+       num_blocks = DIV_ROUND_UP(data_len, AES_BLOCK_SIZE);
+       last_len = data_len % AES_BLOCK_SIZE;
        aes_ccm_prepare(tfm, scratch, a);
 
        /* Process payload blocks */
@@ -109,7 +110,7 @@ int ieee80211_aes_ccm_decrypt(struct crypto_cipher *tfm, u8 *scratch,
        pos = data;
        for (j = 1; j <= num_blocks; j++) {
                int blen = (j == num_blocks && last_len) ?
-                       last_len : AES_BLOCK_LEN;
+                       last_len : AES_BLOCK_SIZE;
 
                /* Decryption followed by authentication */
                b_0[14] = (j >> 8) & 0xff;
index 6e7820e..5b7d744 100644 (file)
@@ -12,8 +12,6 @@
 
 #include <linux/crypto.h>
 
-#define AES_BLOCK_LEN 16
-
 struct crypto_cipher *ieee80211_aes_key_setup_encrypt(const u8 key[]);
 void ieee80211_aes_ccm_encrypt(struct crypto_cipher *tfm, u8 *scratch,
                               u8 *data, size_t data_len,
index 08b0f17..8dfd70d 100644 (file)
 #include <linux/types.h>
 #include <linux/crypto.h>
 #include <linux/err.h>
+#include <crypto/aes.h>
 
 #include <net/mac80211.h>
 #include "key.h"
 #include "aes_cmac.h"
 
-#define AES_BLOCK_SIZE 16
 #define AES_CMAC_KEY_LEN 16
 #define CMAC_TLEN 8 /* CMAC TLen = 64 bits (8 octets) */
 #define AAD_LEN 20
index fcb52eb..05abab0 100644 (file)
@@ -92,9 +92,6 @@ struct ieee80211_key {
                        u8 rx_pn[NUM_RX_DATA_QUEUES + 1][6];
                        struct crypto_cipher *tfm;
                        u32 replays; /* dot11RSNAStatsCCMPReplays */
-#ifndef AES_BLOCK_LEN
-#define AES_BLOCK_LEN 16
-#endif
                } ccmp;
                struct {
                        atomic64_t tx_pn;
index 3452d5e..0168423 100644 (file)
@@ -291,10 +291,10 @@ static void ccmp_special_blocks(struct sk_buff *skb, u8 *pn, u8 *scratch,
        unsigned int hdrlen;
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
 
-       memset(scratch, 0, 6 * AES_BLOCK_LEN);
+       memset(scratch, 0, 6 * AES_BLOCK_SIZE);
 
-       b_0 = scratch + 3 * AES_BLOCK_LEN;
-       aad = scratch + 4 * AES_BLOCK_LEN;
+       b_0 = scratch + 3 * AES_BLOCK_SIZE;
+       aad = scratch + 4 * AES_BLOCK_SIZE;
 
        /*
         * Mask FC: zero subtype b4 b5 b6 (if not mgmt)
@@ -386,7 +386,7 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
        u8 *pos;
        u8 pn[6];
        u64 pn64;
-       u8 scratch[6 * AES_BLOCK_LEN];
+       u8 scratch[6 * AES_BLOCK_SIZE];
 
        if (info->control.hw_key &&
            !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
@@ -487,7 +487,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
        }
 
        if (!(status->flag & RX_FLAG_DECRYPTED)) {
-               u8 scratch[6 * AES_BLOCK_LEN];
+               u8 scratch[6 * AES_BLOCK_SIZE];
                /* hardware didn't decrypt/verify MIC */
                ccmp_special_blocks(skb, pn, scratch, 1);