2 * GOST R 34.11-2012 core functions definitions.
4 * Copyright (c) 2013 Cryptocom LTD.
5 * This file is distributed under the same license as OpenSSL.
7 * Author: Alexey Degtyarev <alexey@renatasystems.org>
14 # define __GOST3411_HAS_SSE2__
15 # if !defined(__x86_64__) && !defined(__e2k__)
17 * x86-64 bit Linux and Windows ABIs provide malloc function that returns
18 * 16-byte alignment memory buffers required by SSE load/store instructions.
19 * Other platforms require special trick for proper gost2012_hash_ctx structure
20 * allocation. It will be easier to switch to unaligned loadu/storeu memory
21 * access instructions in this case.
23 # define UNALIGNED_SIMD_ACCESS
24 # pragma message "Use unaligned SIMD memory access"
28 #ifdef __GOST3411_HAS_SSE2__
29 # if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
30 # undef __GOST3411_HAS_SSE2__
35 # define __GOST3411_BIG_ENDIAN__
38 #if defined __GOST3411_HAS_SSE2__
39 # include "gosthash2012_sse2.h"
41 # include "gosthash2012_ref.h"
44 # if defined(__GNUC__) || defined(__clang__)
45 # define RESTRICT __restrict__
51 # define ALIGN(x) __declspec(align(x))
53 # define ALIGN(x) __attribute__ ((__aligned__(x)))
57 typedef union uint512_u {
58 unsigned long long QWORD[8];
62 #include "gosthash2012_const.h"
63 #include "gosthash2012_precalc.h"
65 /* GOST R 34.11-2012 hash context */
66 typedef struct gost2012_hash_ctx {
67 union uint512_u buffer;
70 union uint512_u Sigma;
72 unsigned int digest_size;
75 void init_gost2012_hash_ctx(gost2012_hash_ctx * CTX,
76 const unsigned int digest_size);
77 void gost2012_hash_block(gost2012_hash_ctx * CTX,
78 const unsigned char *data, size_t len);
79 void gost2012_finish_hash(gost2012_hash_ctx * CTX, unsigned char *digest);