gosthash.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**********************************************************************
  2. * gosthash.h *
  3. * Copyright (c) 2005-2006 Cryptocom LTD *
  4. * This file is distributed under the same license as OpenSSL *
  5. * *
  6. * Declaration of GOST R 34.11-94 hash functions *
  7. * uses and gost89.h Doesn't need OpenSSL *
  8. **********************************************************************/
  9. #ifndef GOSTHASH_H
  10. #define GOSTHASH_H
  11. #include "gost89.h"
  12. #include <stdlib.h>
  13. #if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
  14. typedef __int64 ghosthash_len;
  15. #elif defined(__arch64__)
  16. typedef long ghosthash_len;
  17. #else
  18. typedef long long ghosthash_len;
  19. #endif
  20. typedef struct gost_hash_ctx {
  21. ghosthash_len len;
  22. gost_ctx *cipher_ctx;
  23. int left;
  24. byte H[32];
  25. byte S[32];
  26. byte remainder[32];
  27. } gost_hash_ctx;
  28. /* Initalizes gost hash ctx, including creation of gost cipher ctx */
  29. int init_gost_hash_ctx(gost_hash_ctx *ctx, const gost_subst_block *subst_block);
  30. void done_gost_hash_ctx(gost_hash_ctx *ctx);
  31. /* Cleans up all fields, except cipher ctx preparing ctx for computing
  32. * of new hash value */
  33. int start_hash(gost_hash_ctx *ctx);
  34. /* Hashes block of data */
  35. int hash_block(gost_hash_ctx *ctx, const byte *block, size_t length);
  36. /* Finalizes computation of hash and fills buffer (which should be at
  37. * least 32 bytes long) with value of computed hash. */
  38. int finish_hash(gost_hash_ctx *ctx, byte *hashval);
  39. #endif