]> www.wagner.pp.ru Git - openssl-gost/engine.git/blob - gosthash2012.h
gosthash2012: Change some byte (pointers) to union uint512_u
[openssl-gost/engine.git] / gosthash2012.h
1 /*
2  * GOST R 34.11-2012 core functions definitions.
3  *
4  * Copyright (c) 2013 Cryptocom LTD.
5  * This file is distributed under the same license as OpenSSL.
6  *
7  * Author: Alexey Degtyarev <alexey@renatasystems.org>
8  *
9  */
10
11 #include <string.h>
12
13 #ifdef OPENSSL_IA32_SSE2
14 # ifdef __MMX__
15 #  ifdef __SSE2__
16 #   define __GOST3411_HAS_SSE2__
17 #  endif
18 # endif
19 #endif
20
21 #ifdef __GOST3411_HAS_SSE2__
22 # if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
23 #  undef __GOST3411_HAS_SSE2__
24 # endif
25 #endif
26
27 #ifndef L_ENDIAN
28 # define __GOST3411_BIG_ENDIAN__
29 #endif
30 #if defined __GOST3411_HAS_SSE2__
31 # include "gosthash2012_sse2.h"
32 #else
33 # include "gosthash2012_ref.h"
34 #endif
35
36 # if defined(__GNUC__) || defined(__clang__)
37 #  define RESTRICT __restrict__
38 # else
39 #  define RESTRICT
40 # endif
41
42 #ifdef _MSC_VER
43 # define ALIGN(x) __declspec(align(x))
44 #else
45 # define ALIGN(x) __attribute__ ((__aligned__(x)))
46 #endif
47
48 ALIGN(16)
49 typedef union uint512_u {
50     unsigned long long QWORD[8];
51     unsigned char B[64];
52 } uint512_u;
53
54 #include "gosthash2012_const.h"
55 #include "gosthash2012_precalc.h"
56
57 /* GOST R 34.11-2012 hash context */
58 typedef struct gost2012_hash_ctx {
59     union uint512_u buffer;
60     union uint512_u h;
61     union uint512_u N;
62     union uint512_u Sigma;
63     size_t bufsize;
64     unsigned int digest_size;
65 } gost2012_hash_ctx;
66
67 void init_gost2012_hash_ctx(gost2012_hash_ctx * CTX,
68                             const unsigned int digest_size);
69 void gost2012_hash_block(gost2012_hash_ctx * CTX,
70                          const unsigned char *data, size_t len);
71 void gost2012_finish_hash(gost2012_hash_ctx * CTX, unsigned char *digest);