xform_auth.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* $FreeBSD$ */
  2. /* $OpenBSD: xform.h,v 1.8 2001/08/28 12:20:43 ben Exp $ */
  3. /*-
  4. * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
  5. *
  6. * This code was written by Angelos D. Keromytis in Athens, Greece, in
  7. * February 2000. Network Security Technologies Inc. (NSTI) kindly
  8. * supported the development of this code.
  9. *
  10. * Copyright (c) 2000 Angelos D. Keromytis
  11. * Copyright (c) 2014 The FreeBSD Foundation
  12. * All rights reserved.
  13. *
  14. * Portions of this software were developed by John-Mark Gurney
  15. * under sponsorship of the FreeBSD Foundation and
  16. * Rubicon Communications, LLC (Netgate).
  17. *
  18. * Permission to use, copy, and modify this software without fee
  19. * is hereby granted, provided that this entire notice is included in
  20. * all source code copies of any software which is or includes a copy or
  21. * modification of this software.
  22. *
  23. * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
  24. * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
  25. * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
  26. * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
  27. * PURPOSE.
  28. */
  29. #ifndef _CRYPTO_XFORM_AUTH_H_
  30. #define _CRYPTO_XFORM_AUTH_H_
  31. #include <sys/malloc.h>
  32. #include <sys/errno.h>
  33. #include <crypto/sha1.h>
  34. #include <crypto/sha2/sha224.h>
  35. #include <crypto/sha2/sha256.h>
  36. #include <crypto/sha2/sha384.h>
  37. #include <crypto/sha2/sha512.h>
  38. #include <opencrypto/rmd160.h>
  39. #include <opencrypto/gmac.h>
  40. #include <opencrypto/cbc_mac.h>
  41. #include <opencrypto/cryptodev.h>
  42. /* XXX use a define common with other hash stuff ! */
  43. #define AH_ALEN_MAX 64 /* max authenticator hash length */
  44. /* Declarations */
  45. struct auth_hash {
  46. int type;
  47. char *name;
  48. uint16_t keysize;
  49. uint16_t hashsize;
  50. uint16_t ctxsize;
  51. uint16_t blocksize;
  52. void (*Init) (void *);
  53. void (*Setkey) (void *, const uint8_t *, u_int);
  54. void (*Reinit) (void *, const uint8_t *, u_int);
  55. int (*Update) (void *, const void *, u_int);
  56. void (*Final) (uint8_t *, void *);
  57. };
  58. extern struct auth_hash auth_hash_null;
  59. extern struct auth_hash auth_hash_hmac_sha1;
  60. extern struct auth_hash auth_hash_hmac_ripemd_160;
  61. extern struct auth_hash auth_hash_hmac_sha2_224;
  62. extern struct auth_hash auth_hash_hmac_sha2_256;
  63. extern struct auth_hash auth_hash_hmac_sha2_384;
  64. extern struct auth_hash auth_hash_hmac_sha2_512;
  65. extern struct auth_hash auth_hash_sha1;
  66. extern struct auth_hash auth_hash_sha2_224;
  67. extern struct auth_hash auth_hash_sha2_256;
  68. extern struct auth_hash auth_hash_sha2_384;
  69. extern struct auth_hash auth_hash_sha2_512;
  70. extern struct auth_hash auth_hash_nist_gmac_aes_128;
  71. extern struct auth_hash auth_hash_nist_gmac_aes_192;
  72. extern struct auth_hash auth_hash_nist_gmac_aes_256;
  73. extern struct auth_hash auth_hash_blake2b;
  74. extern struct auth_hash auth_hash_blake2s;
  75. extern struct auth_hash auth_hash_poly1305;
  76. extern struct auth_hash auth_hash_ccm_cbc_mac_128;
  77. extern struct auth_hash auth_hash_ccm_cbc_mac_192;
  78. extern struct auth_hash auth_hash_ccm_cbc_mac_256;
  79. union authctx {
  80. SHA1_CTX sha1ctx;
  81. RMD160_CTX rmd160ctx;
  82. SHA224_CTX sha224ctx;
  83. SHA256_CTX sha256ctx;
  84. SHA384_CTX sha384ctx;
  85. SHA512_CTX sha512ctx;
  86. struct aes_gmac_ctx aes_gmac_ctx;
  87. struct aes_cbc_mac_ctx aes_cbc_mac_ctx;
  88. };
  89. #endif /* _CRYPTO_XFORM_AUTH_H_ */