xform.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* $OpenBSD: xform.h,v 1.24 2014/12/28 10:02:37 tedu Exp $ */
  2. /*
  3. * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
  4. *
  5. * This code was written by Angelos D. Keromytis in Athens, Greece, in
  6. * February 2000. Network Security Technologies Inc. (NSTI) kindly
  7. * supported the development of this code.
  8. *
  9. * Copyright (c) 2000 Angelos D. Keromytis
  10. *
  11. * Permission to use, copy, and modify this software with or without fee
  12. * is hereby granted, provided that this entire notice is included in
  13. * all source code copies of any software which is or includes a copy or
  14. * modification of this software.
  15. *
  16. * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
  17. * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
  18. * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
  19. * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
  20. * PURPOSE.
  21. */
  22. #ifndef _CRYPTO_XFORM_H_
  23. #define _CRYPTO_XFORM_H_
  24. #include <crypto/md5.h>
  25. #include <crypto/sha1.h>
  26. #include <crypto/rmd160.h>
  27. #include <crypto/sha2.h>
  28. #include <crypto/gmac.h>
  29. /* Declarations */
  30. struct auth_hash {
  31. int type;
  32. char *name;
  33. u_int16_t keysize;
  34. u_int16_t hashsize;
  35. u_int16_t authsize;
  36. u_int16_t ctxsize;
  37. u_int16_t blocksize;
  38. void (*Init) (void *);
  39. void (*Setkey) (void *, const u_int8_t *, u_int16_t);
  40. void (*Reinit) (void *, const u_int8_t *, u_int16_t);
  41. int (*Update) (void *, const u_int8_t *, u_int16_t);
  42. void (*Final) (u_int8_t *, void *);
  43. };
  44. struct enc_xform {
  45. int type;
  46. char *name;
  47. u_int16_t blocksize;
  48. u_int16_t ivsize;
  49. u_int16_t minkey;
  50. u_int16_t maxkey;
  51. u_int16_t ctxsize;
  52. void (*encrypt) (caddr_t, u_int8_t *);
  53. void (*decrypt) (caddr_t, u_int8_t *);
  54. int (*setkey) (void *, u_int8_t *, int len);
  55. void (*reinit) (caddr_t, u_int8_t *);
  56. };
  57. struct comp_algo {
  58. int type;
  59. char *name;
  60. size_t minlen;
  61. u_int32_t (*compress) (u_int8_t *, u_int32_t, u_int8_t **);
  62. u_int32_t (*decompress) (u_int8_t *, u_int32_t, u_int8_t **);
  63. };
  64. union authctx {
  65. MD5_CTX md5ctx;
  66. SHA1_CTX sha1ctx;
  67. RMD160_CTX rmd160ctx;
  68. SHA2_CTX sha2_ctx;
  69. AES_GMAC_CTX aes_gmac_ctx;
  70. };
  71. extern struct enc_xform enc_xform_des;
  72. extern struct enc_xform enc_xform_3des;
  73. extern struct enc_xform enc_xform_blf;
  74. extern struct enc_xform enc_xform_cast5;
  75. extern struct enc_xform enc_xform_rijndael128;
  76. extern struct enc_xform enc_xform_aes_ctr;
  77. extern struct enc_xform enc_xform_aes_gcm;
  78. extern struct enc_xform enc_xform_aes_gmac;
  79. extern struct enc_xform enc_xform_aes_xts;
  80. extern struct enc_xform enc_xform_arc4;
  81. extern struct enc_xform enc_xform_null;
  82. extern struct auth_hash auth_hash_md5;
  83. extern struct auth_hash auth_hash_sha1;
  84. extern struct auth_hash auth_hash_hmac_md5_96;
  85. extern struct auth_hash auth_hash_hmac_sha1_96;
  86. extern struct auth_hash auth_hash_hmac_ripemd_160_96;
  87. extern struct auth_hash auth_hash_hmac_sha2_256_128;
  88. extern struct auth_hash auth_hash_hmac_sha2_384_192;
  89. extern struct auth_hash auth_hash_hmac_sha2_512_256;
  90. extern struct auth_hash auth_hash_gmac_aes_128;
  91. extern struct auth_hash auth_hash_gmac_aes_192;
  92. extern struct auth_hash auth_hash_gmac_aes_256;
  93. extern struct comp_algo comp_algo_deflate;
  94. extern struct comp_algo comp_algo_lzs;
  95. #endif /* _CRYPTO_XFORM_H_ */