gcm.h 867 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef _CRYPTO_GCM_H
  2. #define _CRYPTO_GCM_H
  3. #include <linux/errno.h>
  4. #define GCM_AES_IV_SIZE 12
  5. #define GCM_RFC4106_IV_SIZE 8
  6. #define GCM_RFC4543_IV_SIZE 8
  7. /*
  8. * validate authentication tag for GCM
  9. */
  10. static inline int crypto_gcm_check_authsize(unsigned int authsize)
  11. {
  12. switch (authsize) {
  13. case 4:
  14. case 8:
  15. case 12:
  16. case 13:
  17. case 14:
  18. case 15:
  19. case 16:
  20. break;
  21. default:
  22. return -EINVAL;
  23. }
  24. return 0;
  25. }
  26. /*
  27. * validate authentication tag for RFC4106
  28. */
  29. static inline int crypto_rfc4106_check_authsize(unsigned int authsize)
  30. {
  31. switch (authsize) {
  32. case 8:
  33. case 12:
  34. case 16:
  35. break;
  36. default:
  37. return -EINVAL;
  38. }
  39. return 0;
  40. }
  41. /*
  42. * validate assoclen for RFC4106/RFC4543
  43. */
  44. static inline int crypto_ipsec_check_assoclen(unsigned int assoclen)
  45. {
  46. switch (assoclen) {
  47. case 16:
  48. case 20:
  49. break;
  50. default:
  51. return -EINVAL;
  52. }
  53. return 0;
  54. }
  55. #endif