Linux 4.19.133
[linux/fpc-iii.git] / net / mac80211 / aes_gcm.h
blobd2b09603300922ac9d199a2045e93ed8a3082960
1 /*
2 * Copyright 2014-2015, Qualcomm Atheros, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
9 #ifndef AES_GCM_H
10 #define AES_GCM_H
12 #include "aead_api.h"
14 #define GCM_AAD_LEN 32
16 static inline int ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm,
17 u8 *j_0, u8 *aad, u8 *data,
18 size_t data_len, u8 *mic)
20 return aead_encrypt(tfm, j_0, aad + 2,
21 be16_to_cpup((__be16 *)aad),
22 data, data_len, mic);
25 static inline int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm,
26 u8 *j_0, u8 *aad, u8 *data,
27 size_t data_len, u8 *mic)
29 return aead_decrypt(tfm, j_0, aad + 2,
30 be16_to_cpup((__be16 *)aad),
31 data, data_len, mic);
34 static inline struct crypto_aead *
35 ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], size_t key_len)
37 return aead_key_setup_encrypt("gcm(aes)", key,
38 key_len, IEEE80211_GCMP_MIC_LEN);
41 static inline void ieee80211_aes_gcm_key_free(struct crypto_aead *tfm)
43 return aead_key_free(tfm);
46 #endif /* AES_GCM_H */