Merge branch 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / net / mac80211 / aes_gcm.h
CommitLineData
00b9cfa3
JM
1/*
2 * Copyright 2014-2015, Qualcomm Atheros, Inc.
3 *
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 */
8
9#ifndef AES_GCM_H
10#define AES_GCM_H
11
4133da73 12#include "aead_api.h"
00b9cfa3 13
f4a067f9
AB
14#define GCM_AAD_LEN 32
15
4133da73
XG
16static 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)
19{
20 return aead_encrypt(tfm, j_0, aad + 2,
21 be16_to_cpup((__be16 *)aad),
22 data, data_len, mic);
23}
24
25static 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)
28{
29 return aead_decrypt(tfm, j_0, aad + 2,
30 be16_to_cpup((__be16 *)aad),
31 data, data_len, mic);
32}
33
34static inline struct crypto_aead *
35ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], size_t key_len)
36{
37 return aead_key_setup_encrypt("gcm(aes)", key,
38 key_len, IEEE80211_GCMP_MIC_LEN);
39}
40
41static inline void ieee80211_aes_gcm_key_free(struct crypto_aead *tfm)
42{
43 return aead_key_free(tfm);
44}
00b9cfa3
JM
45
46#endif /* AES_GCM_H */