Merge tag 'arm-drivers-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-microblaze.git] / net / mac80211 / aes_cmac.c
index 57748ca..b31f102 100644 (file)
@@ -26,12 +26,20 @@ void ieee80211_aes_cmac(struct crypto_shash *tfm, const u8 *aad,
 {
        SHASH_DESC_ON_STACK(desc, tfm);
        u8 out[AES_BLOCK_SIZE];
+       const __le16 *fc;
 
        desc->tfm = tfm;
 
        crypto_shash_init(desc);
        crypto_shash_update(desc, aad, AAD_LEN);
-       crypto_shash_update(desc, data, data_len - CMAC_TLEN);
+       fc = (const __le16 *)aad;
+       if (ieee80211_is_beacon(*fc)) {
+               /* mask Timestamp field to zero */
+               crypto_shash_update(desc, zero, 8);
+               crypto_shash_update(desc, data + 8, data_len - 8 - CMAC_TLEN);
+       } else {
+               crypto_shash_update(desc, data, data_len - CMAC_TLEN);
+       }
        crypto_shash_finup(desc, zero, CMAC_TLEN, out);
 
        memcpy(mic, out, CMAC_TLEN);
@@ -41,12 +49,21 @@ void ieee80211_aes_cmac_256(struct crypto_shash *tfm, const u8 *aad,
                            const u8 *data, size_t data_len, u8 *mic)
 {
        SHASH_DESC_ON_STACK(desc, tfm);
+       const __le16 *fc;
 
        desc->tfm = tfm;
 
        crypto_shash_init(desc);
        crypto_shash_update(desc, aad, AAD_LEN);
-       crypto_shash_update(desc, data, data_len - CMAC_TLEN_256);
+       fc = (const __le16 *)aad;
+       if (ieee80211_is_beacon(*fc)) {
+               /* mask Timestamp field to zero */
+               crypto_shash_update(desc, zero, 8);
+               crypto_shash_update(desc, data + 8,
+                                   data_len - 8 - CMAC_TLEN_256);
+       } else {
+               crypto_shash_update(desc, data, data_len - CMAC_TLEN_256);
+       }
        crypto_shash_finup(desc, zero, CMAC_TLEN_256, mic);
 }