1238384Sjkim/********************************************************************** 2238384Sjkim * gosthash.h * 3238384Sjkim * Copyright (c) 2005-2006 Cryptocom LTD * 4238384Sjkim * This file is distributed under the same license as OpenSSL * 5238384Sjkim * * 6238384Sjkim * Declaration of GOST R 34.11-94 hash functions * 7238384Sjkim * uses and gost89.h Doesn't need OpenSSL * 8238384Sjkim **********************************************************************/ 9238384Sjkim#ifndef GOSTHASH_H 10280304Sjkim# define GOSTHASH_H 11280304Sjkim# include "gost89.h" 12280304Sjkim# include <stdlib.h> 13238384Sjkim 14280304Sjkim# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) 15238384Sjkimtypedef __int64 ghosthash_len; 16280304Sjkim# elif defined(__arch64__) 17238384Sjkimtypedef long ghosthash_len; 18280304Sjkim# else 19238384Sjkimtypedef long long ghosthash_len; 20280304Sjkim# endif 21238384Sjkim 22238384Sjkimtypedef struct gost_hash_ctx { 23280304Sjkim ghosthash_len len; 24280304Sjkim gost_ctx *cipher_ctx; 25280304Sjkim int left; 26280304Sjkim byte H[32]; 27280304Sjkim byte S[32]; 28280304Sjkim byte remainder[32]; 29280304Sjkim} gost_hash_ctx; 30238384Sjkim 31238384Sjkim/* Initalizes gost hash ctx, including creation of gost cipher ctx */ 32238384Sjkim 33280304Sjkimint init_gost_hash_ctx(gost_hash_ctx * ctx, 34280304Sjkim const gost_subst_block * subst_block); 35280304Sjkimvoid done_gost_hash_ctx(gost_hash_ctx * ctx); 36238384Sjkim 37280304Sjkim/* 38280304Sjkim * Cleans up all fields, except cipher ctx preparing ctx for computing of new 39280304Sjkim * hash value 40280304Sjkim */ 41280304Sjkimint start_hash(gost_hash_ctx * ctx); 42238384Sjkim 43238384Sjkim/* Hashes block of data */ 44280304Sjkimint hash_block(gost_hash_ctx * ctx, const byte * block, size_t length); 45238384Sjkim 46280304Sjkim/* 47280304Sjkim * Finalizes computation of hash and fills buffer (which should be at least 48280304Sjkim * 32 bytes long) with value of computed hash. 49280304Sjkim */ 50280304Sjkimint finish_hash(gost_hash_ctx * ctx, byte * hashval); 51238384Sjkim 52280304Sjkim#endif 53