]> www.wagner.pp.ru Git - openssl-gost/engine.git/blob - gost_grasshopper_defines.h
tcl_tests: ca.try: Ignore openssl crl exit status for 'corrupted CRL' test
[openssl-gost/engine.git] / gost_grasshopper_defines.h
1 /*
2  * Maxim Tishkov 2016
3  * This file is distributed under the same license as OpenSSL
4  */
5
6 #ifndef GOST_GRASSHOPPER_DEFINES_H
7 #define GOST_GRASSHOPPER_DEFINES_H
8
9 #if defined(__cplusplus)
10 extern "C" {
11 #endif
12
13 #include <stdbool.h>
14 #include <stdint.h>
15
16 # if !defined(inline) && !defined(__cplusplus)
17 #  if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
18 #   define GRASSHOPPER_INLINE inline
19 #  elif defined(__GNUC__) && __GNUC__ >= 2
20 #   define GRASSHOPPER_INLINE __inline__
21 #   define likely(x) __builtin_expect(!!(x), 1)
22 #  elif defined(_MSC_VER)
23 #   define GRASSHOPPER_INLINE __inline
24 #  else
25 #   define GRASSHOPPER_INLINE
26 #  endif
27 # else
28 #  define GRASSHOPPER_INLINE inline
29 # endif
30
31 # if !defined(likely)
32 #   define likely(x) x
33 # endif
34
35 typedef union {
36     uint8_t b[16];
37     uint64_t q[2];
38     uint32_t d[4];
39     uint16_t w[8];
40 } grasshopper_w128_t;
41
42 typedef union {
43     uint8_t b[32];
44     uint64_t q[4];
45     uint32_t d[8];
46     uint16_t w[16];
47     grasshopper_w128_t k[2];
48 } grasshopper_w256_t;
49
50 typedef struct {
51     grasshopper_w256_t k;
52 } grasshopper_key_t;
53
54 #define GRASSHOPPER_ROUND_KEYS_COUNT 10
55
56 typedef struct {
57     grasshopper_w128_t k[GRASSHOPPER_ROUND_KEYS_COUNT];
58 } grasshopper_round_keys_t;
59
60 extern const uint8_t grasshopper_pi[0x100];
61
62 extern const uint8_t grasshopper_pi_inv[0x100];
63
64 extern const uint8_t grasshopper_lvec[16];
65
66 #define GRASSHOPPER_BLOCK_SIZE (128/8)
67 #define GRASSHOPPER_KEY_SIZE (256/8)
68
69 #if defined(__cplusplus)
70 }
71 #endif
72
73 #endif