Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright 2003-2004, Instant802 Networks, Inc.
0004  * Copyright 2006, Devicescape Software, Inc.
0005  */
0006 
0007 #ifndef AES_CCM_H
0008 #define AES_CCM_H
0009 
0010 #include "aead_api.h"
0011 
0012 #define CCM_AAD_LEN 32
0013 
0014 static inline struct crypto_aead *
0015 ieee80211_aes_key_setup_encrypt(const u8 key[], size_t key_len, size_t mic_len)
0016 {
0017     return aead_key_setup_encrypt("ccm(aes)", key, key_len, mic_len);
0018 }
0019 
0020 static inline int
0021 ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm,
0022               u8 *b_0, u8 *aad, u8 *data,
0023               size_t data_len, u8 *mic)
0024 {
0025     return aead_encrypt(tfm, b_0, aad + 2,
0026                 be16_to_cpup((__be16 *)aad),
0027                 data, data_len, mic);
0028 }
0029 
0030 static inline int
0031 ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm,
0032               u8 *b_0, u8 *aad, u8 *data,
0033               size_t data_len, u8 *mic)
0034 {
0035     return aead_decrypt(tfm, b_0, aad + 2,
0036                 be16_to_cpup((__be16 *)aad),
0037                 data, data_len, mic);
0038 }
0039 
0040 static inline void ieee80211_aes_key_free(struct crypto_aead *tfm)
0041 {
0042     return aead_key_free(tfm);
0043 }
0044 
0045 #endif /* AES_CCM_H */