Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright 2014-2015, Qualcomm Atheros, Inc.
0004  */
0005 
0006 #ifndef AES_GCM_H
0007 #define AES_GCM_H
0008 
0009 #include "aead_api.h"
0010 
0011 #define GCM_AAD_LEN 32
0012 
0013 static inline int ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm,
0014                         u8 *j_0, u8 *aad,  u8 *data,
0015                         size_t data_len, u8 *mic)
0016 {
0017     return aead_encrypt(tfm, j_0, aad + 2,
0018                 be16_to_cpup((__be16 *)aad),
0019                 data, data_len, mic);
0020 }
0021 
0022 static inline int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm,
0023                         u8 *j_0, u8 *aad, u8 *data,
0024                         size_t data_len, u8 *mic)
0025 {
0026     return aead_decrypt(tfm, j_0, aad + 2,
0027                 be16_to_cpup((__be16 *)aad),
0028                 data, data_len, mic);
0029 }
0030 
0031 static inline struct crypto_aead *
0032 ieee80211_aes_gcm_key_setup_encrypt(const u8 key[], size_t key_len)
0033 {
0034     return aead_key_setup_encrypt("gcm(aes)", key,
0035                       key_len, IEEE80211_GCMP_MIC_LEN);
0036 }
0037 
0038 static inline void ieee80211_aes_gcm_key_free(struct crypto_aead *tfm)
0039 {
0040     return aead_key_free(tfm);
0041 }
0042 
0043 #endif /* AES_GCM_H */