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
| 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
| 10# define GOSTHASH_H 11# include "gost89.h" 12# include <stdlib.h>
|
13
| 13
|
14#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
| 14# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
|
15typedef __int64 ghosthash_len;
| 15typedef __int64 ghosthash_len;
|
16#elif defined(__arch64__)
| 16# elif defined(__arch64__)
|
17typedef long ghosthash_len;
| 17typedef long ghosthash_len;
|
18#else
| 18# else
|
19typedef long long ghosthash_len;
| 19typedef long long ghosthash_len;
|
20#endif
| 20# endif
|
21 22typedef struct gost_hash_ctx {
| 21 22typedef struct gost_hash_ctx {
|
23 ghosthash_len len; 24 gost_ctx *cipher_ctx; 25 int left; 26 byte H[32]; 27 byte S[32]; 28 byte remainder[32]; 29} gost_hash_ctx;
| 23 ghosthash_len len; 24 gost_ctx *cipher_ctx; 25 int left; 26 byte H[32]; 27 byte S[32]; 28 byte remainder[32]; 29} gost_hash_ctx;
|
30
| 30
|
31
| |
32/* Initalizes gost hash ctx, including creation of gost cipher ctx */ 33
| 31/* Initalizes gost hash ctx, including creation of gost cipher ctx */ 32
|
34int init_gost_hash_ctx(gost_hash_ctx *ctx, const gost_subst_block *subst_block); 35void done_gost_hash_ctx(gost_hash_ctx *ctx);
| 33int init_gost_hash_ctx(gost_hash_ctx * ctx, 34 const gost_subst_block * subst_block); 35void done_gost_hash_ctx(gost_hash_ctx * ctx);
|
36
| 36
|
37/* Cleans up all fields, except cipher ctx preparing ctx for computing 38 * of new hash value */ 39int start_hash(gost_hash_ctx *ctx);
| 37/* 38 * Cleans up all fields, except cipher ctx preparing ctx for computing of new 39 * hash value 40 */ 41int start_hash(gost_hash_ctx * ctx);
|
40 41/* Hashes block of data */
| 42 43/* Hashes block of data */
|
42int hash_block(gost_hash_ctx *ctx, const byte *block, size_t length);
| 44int hash_block(gost_hash_ctx * ctx, const byte * block, size_t length);
|
43
| 45
|
44/* Finalizes computation of hash and fills buffer (which should be at 45 * least 32 bytes long) with value of computed hash. */ 46int finish_hash(gost_hash_ctx *ctx, byte *hashval);
| 46/* 47 * Finalizes computation of hash and fills buffer (which should be at least 48 * 32 bytes long) with value of computed hash. 49 */ 50int finish_hash(gost_hash_ctx * ctx, byte * hashval);
|
47
| 51
|
48#endif
| 52#endif
|
| |