algorithms.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* algorithms.h - rhash library algorithms */
  2. #ifndef RHASH_ALGORITHMS_H
  3. #define RHASH_ALGORITHMS_H
  4. #include <stddef.h> /* for ptrdiff_t */
  5. #include "rhash.h"
  6. #include "byte_order.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #ifndef RHASH_API
  11. /* modifier for RHash library functions */
  12. # define RHASH_API
  13. #endif
  14. typedef void (*pinit_t)(void*);
  15. typedef void (*pupdate_t)(void *ctx, const void* msg, size_t size);
  16. typedef void (*pfinal_t)(void*, unsigned char*);
  17. typedef void (*pcleanup_t)(void*);
  18. /**
  19. * Information about a hash function
  20. */
  21. typedef struct rhash_hash_info
  22. {
  23. rhash_info *info;
  24. size_t context_size;
  25. ptrdiff_t digest_diff;
  26. pinit_t init;
  27. pupdate_t update;
  28. pfinal_t final;
  29. pcleanup_t cleanup;
  30. } rhash_hash_info;
  31. /**
  32. * Information on a hash function and its context
  33. */
  34. typedef struct rhash_vector_item
  35. {
  36. struct rhash_hash_info* hash_info;
  37. void *context;
  38. } rhash_vector_item;
  39. /**
  40. * The rhash context containing contexts for several hash functions
  41. */
  42. typedef struct rhash_context_ext
  43. {
  44. struct rhash_context rc;
  45. unsigned hash_vector_size; /* number of contained hash sums */
  46. unsigned flags;
  47. unsigned state;
  48. void *callback, *callback_data;
  49. void *bt_ctx;
  50. rhash_vector_item vector[1]; /* contexts of contained hash sums */
  51. } rhash_context_ext;
  52. extern rhash_hash_info rhash_hash_info_default[RHASH_HASH_COUNT];
  53. extern rhash_hash_info* rhash_info_table;
  54. extern int rhash_info_size;
  55. extern unsigned rhash_uninitialized_algorithms;
  56. extern rhash_info info_crc32;
  57. extern rhash_info info_md4;
  58. extern rhash_info info_md5;
  59. extern rhash_info info_sha1;
  60. extern rhash_info info_tiger;
  61. extern rhash_info info_tth ;
  62. extern rhash_info info_btih;
  63. extern rhash_info info_ed2k;
  64. extern rhash_info info_aich;
  65. extern rhash_info info_whirlpool;
  66. extern rhash_info info_rmd160;
  67. extern rhash_info info_gost;
  68. extern rhash_info info_gostpro;
  69. extern rhash_info info_has160;
  70. extern rhash_info info_snf128;
  71. extern rhash_info info_snf256;
  72. extern rhash_info info_sha224;
  73. extern rhash_info info_sha256;
  74. extern rhash_info info_sha384;
  75. extern rhash_info info_sha512;
  76. extern rhash_info info_sha3_224;
  77. extern rhash_info info_sha3_256;
  78. extern rhash_info info_sha3_384;
  79. extern rhash_info info_sha3_512;
  80. extern rhash_info info_edr256;
  81. extern rhash_info info_edr512;
  82. /* rhash_info flags */
  83. #define F_BS32 1 /* default output in base32 */
  84. #define F_SWAP32 2 /* Big endian flag */
  85. #define F_SWAP64 4
  86. /* define endianness flags */
  87. #ifndef CPU_BIG_ENDIAN
  88. #define F_LE32 0
  89. #define F_LE64 0
  90. #define F_BE32 F_SWAP32
  91. #define F_BE64 F_SWAP64
  92. #else
  93. #define F_LE32 F_SWAP32
  94. #define F_LE64 F_SWAP64
  95. #define F_BE32 0
  96. #define F_BE64 0
  97. #endif
  98. void rhash_init_algorithms(unsigned mask);
  99. #if defined(OPENSSL_RUNTIME) && !defined(USE_OPENSSL)
  100. # define USE_OPENSSL
  101. #endif
  102. #ifdef __cplusplus
  103. } /* extern "C" */
  104. #endif /* __cplusplus */
  105. #endif /* RHASH_ALGORITHMS_H */