gosthash.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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,
  30. const gost_subst_block * subst_block);
  31. void done_gost_hash_ctx(gost_hash_ctx * ctx);
  32. /*
  33. * Cleans up all fields, except cipher ctx preparing ctx for computing of new
  34. * hash value
  35. */
  36. int start_hash(gost_hash_ctx * ctx);
  37. /* Hashes block of data */
  38. int hash_block(gost_hash_ctx * ctx, const byte * block, size_t length);
  39. /*
  40. * Finalizes computation of hash and fills buffer (which should be at least
  41. * 32 bytes long) with value of computed hash.
  42. */
  43. int finish_hash(gost_hash_ctx * ctx, byte * hashval);
  44. #endif