aes_ccm.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright 2003-2004, Instant802 Networks, Inc.
  3. * Copyright 2006, Devicescape Software, Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #ifndef AES_CCM_H
  10. #define AES_CCM_H
  11. #include "aead_api.h"
  12. #define CCM_AAD_LEN 32
  13. static inline struct crypto_aead *
  14. ieee80211_aes_key_setup_encrypt(const u8 key[], size_t key_len, size_t mic_len)
  15. {
  16. return aead_key_setup_encrypt("ccm(aes)", key, key_len, mic_len);
  17. }
  18. static inline int
  19. ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm,
  20. u8 *b_0, u8 *aad, u8 *data,
  21. size_t data_len, u8 *mic)
  22. {
  23. return aead_encrypt(tfm, b_0, aad + 2,
  24. be16_to_cpup((__be16 *)aad),
  25. data, data_len, mic);
  26. }
  27. static inline int
  28. ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm,
  29. u8 *b_0, u8 *aad, u8 *data,
  30. size_t data_len, u8 *mic)
  31. {
  32. return aead_decrypt(tfm, b_0, aad + 2,
  33. be16_to_cpup((__be16 *)aad),
  34. data, data_len, mic);
  35. }
  36. static inline void ieee80211_aes_key_free(struct crypto_aead *tfm)
  37. {
  38. return aead_key_free(tfm);
  39. }
  40. #endif /* AES_CCM_H */