aboutsummaryrefslogtreecommitdiff
path: root/gosthash2012.h
diff options
context:
space:
mode:
authorDmitry Belyavskiy <beldmit@gmail.com>2015-08-14 21:08:23 +0300
committerDmitry Belyavskiy <beldmit@gmail.com>2015-08-14 21:08:23 +0300
commitcba16944bff9d8c5dcf37be641822cd3de6d2ec1 (patch)
tree5c8ad3f27fcc3e0a67a53de21db39fca68b8fa9e /gosthash2012.h
parentc98ba9d03213d0c63d6874539d59f7b55fbc3fae (diff)
downloadgost-engine-cba16944bff9d8c5dcf37be641822cd3de6d2ec1.zip
gost-engine-cba16944bff9d8c5dcf37be641822cd3de6d2ec1.tar.gz
gost-engine-cba16944bff9d8c5dcf37be641822cd3de6d2ec1.tar.bz2
Initial commit providing GOST 2012 algorithms.
Diffstat (limited to 'gosthash2012.h')
-rw-r--r--gosthash2012.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/gosthash2012.h b/gosthash2012.h
new file mode 100644
index 0000000..021b7d4
--- /dev/null
+++ b/gosthash2012.h
@@ -0,0 +1,66 @@
+/*
+ * GOST R 34.11-2012 core functions definitions.
+ *
+ * Copyright (c) 2013 Cryptocom LTD.
+ * This file is distributed under the same license as OpenSSL.
+ *
+ * Author: Alexey Degtyarev <alexey@renatasystems.org>
+ *
+ */
+
+#include <string.h>
+
+#ifdef OPENSSL_IA32_SSE2
+# ifdef __MMX__
+# ifdef __SSE2__
+# define __GOST3411_HAS_SSE2__
+# endif
+# endif
+#endif
+
+#ifdef __GOST3411_HAS_SSE2__
+# if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
+# undef __GOST3411_HAS_SSE2__
+# endif
+#endif
+
+#ifndef L_ENDIAN
+# define __GOST3411_BIG_ENDIAN__
+#endif
+#if defined __GOST3411_HAS_SSE2__
+# include "gosthash2012_sse2.h"
+#else
+# include "gosthash2012_ref.h"
+#endif
+
+#ifdef _MSC_VER
+# define ALIGN(x) __declspec(align(x))
+#else
+# define ALIGN(x) __attribute__ ((__aligned__(x)))
+#endif
+
+ALIGN(16)
+typedef union uint512_u {
+ unsigned long long QWORD[8];
+} uint512_u;
+
+#include "gosthash2012_const.h"
+#include "gosthash2012_precalc.h"
+
+/* GOST R 34.11-2012 hash context */
+ALIGN(16)
+typedef struct gost2012_hash_ctx {
+ ALIGN(16) unsigned char buffer[64];
+ union uint512_u hash;
+ union uint512_u h;
+ union uint512_u N;
+ union uint512_u Sigma;
+ size_t bufsize;
+ unsigned int digest_size;
+} gost2012_hash_ctx;
+
+void init_gost2012_hash_ctx(gost2012_hash_ctx * CTX,
+ const unsigned int digest_size);
+void gost2012_hash_block(gost2012_hash_ctx * CTX,
+ const unsigned char *data, size_t len);
+void gost2012_finish_hash(gost2012_hash_ctx * CTX, unsigned char *digest);