]> www.wagner.pp.ru Git - openssl-gost/engine.git/blob - gost_grasshopper_defines.h
Merge remote-tracking branch 'origin/openssl_1_1_0'
[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 #  elif defined(_MSC_VER)
22 #   define GRASSHOPPER_INLINE __inline
23 #  else
24 #   define GRASSHOPPER_INLINE
25 #  endif
26 # else
27 #  define GRASSHOPPER_INLINE inline
28 # endif
29
30 typedef union {
31     uint8_t b[16];
32     uint64_t q[2];
33     uint32_t d[4];
34     uint16_t w[8];
35 } grasshopper_w128_t;
36
37 typedef union {
38     uint8_t b[32];
39     uint64_t q[4];
40     uint32_t d[8];
41     uint16_t w[16];
42     grasshopper_w128_t k[2];
43 } grasshopper_w256_t;
44
45 typedef struct {
46     grasshopper_w256_t k;
47 } grasshopper_key_t;
48
49 #define GRASSHOPPER_ROUND_KEYS_COUNT 10
50
51 typedef struct {
52     grasshopper_w128_t k[GRASSHOPPER_ROUND_KEYS_COUNT];
53 } grasshopper_round_keys_t;
54
55 extern const uint8_t grasshopper_pi[0x100];
56
57 extern const uint8_t grasshopper_pi_inv[0x100];
58
59 extern const uint8_t grasshopper_lvec[16];
60
61 #define GRASSHOPPER_BLOCK_SIZE (128/8)
62 #define GRASSHOPPER_KEY_SIZE (256/8)
63
64 #if defined(__cplusplus)
65 }
66 #endif
67
68 #endif