GOST 28147-89 is the data encryption standard for Russia (old, but still used). English translation is provided in RFC 5830. It defines a 64-bit cipher, ECB, CFB and counter (CNT) modes on top of it and a special mode of basic transformation that is used for MAC construction called "Imitovstavka" (IMIT).
For GOST 28147-89 several S-boxes are defined (standard itself has defined "test" S-box, another "test" S-box is defined in GOST R 34.11-94 (RFC 5831), RFC 4357 defines several CryptoPro S-Boxes and finally TC26 has defined TC26-Z S-Box (RFC 7836)).
Before finalizing documentation I'd like to hear your opinion on the GOST 28147-89 cipher and MAC interface.
From: Dmitry Eremin-Solenikov dbaryshkov@gmail.com
Signed-off-by: Dmitry Eremin-Solenikov dbaryshkov@gmail.com --- Makefile.in | 3 +- gost28147-internal.h | 3 + gost28147-meta.c | 49 +++++++++++++++ gost28147.c | 85 +++++++++++++++++++++++++ gost28147.h | 30 +++++++++ nettle-meta-ciphers.c | 1 + nettle-meta.h | 2 + nettle.texinfo | 38 +++++++++++ testsuite/.gitignore | 1 + testsuite/.test-rules.make | 3 + testsuite/Makefile.in | 1 + testsuite/gost28147-test.c | 119 +++++++++++++++++++++++++++++++++++ testsuite/meta-cipher-test.c | 1 + 13 files changed, 335 insertions(+), 1 deletion(-) create mode 100644 gost28147-meta.c create mode 100644 testsuite/gost28147-test.c
diff --git a/Makefile.in b/Makefile.in index 9f5b065a706a..c6e40a74ad4f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -103,7 +103,8 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \ gcm-camellia128.c gcm-camellia128-meta.c \ gcm-camellia256.c gcm-camellia256-meta.c \ cmac.c cmac64.c cmac-aes128.c cmac-aes256.c cmac-des3.c \ - gost28147.c gosthash94.c gosthash94-meta.c \ + gost28147.c gost28147-meta.c \ + gosthash94.c gosthash94-meta.c \ hmac.c hmac-gosthash94.c hmac-md5.c hmac-ripemd160.c \ hmac-sha1.c hmac-sha224.c hmac-sha256.c hmac-sha384.c \ hmac-sha512.c \ diff --git a/gost28147-internal.h b/gost28147-internal.h index 7f5c6f8c63c0..2c3f5857a8d4 100644 --- a/gost28147-internal.h +++ b/gost28147-internal.h @@ -35,8 +35,11 @@ #define NETTLE_GOST28147_INTERNAL_H_INCLUDED
#define _gost28147_encrypt_block _nettle_gost28147_encrypt_block +#define _gost28147_decrypt_block _nettle_gost28147_decrypt_block
void _gost28147_encrypt_block (const uint32_t *key, const uint32_t sbox[4][256], const uint32_t *in, uint32_t *out); +void _gost28147_decrypt_block (const uint32_t *key, const uint32_t sbox[4][256], + const uint32_t *in, uint32_t *out);
#endif /* NETTLE_GOST28147_INTERNAL_H_INCLUDED */ diff --git a/gost28147-meta.c b/gost28147-meta.c new file mode 100644 index 000000000000..69e4d265e453 --- /dev/null +++ b/gost28147-meta.c @@ -0,0 +1,49 @@ +/* gost28147-meta.c + + Copyright (C) 2016 Dmitry Eremin-Solenikov + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#if HAVE_CONFIG_H +# include "config.h" +#endif + +#include <assert.h> + +#include "nettle-meta.h" + +#include "gost28147.h" + +const struct nettle_cipher nettle_gost28147 = + { "gost28147", sizeof(struct gost28147_ctx), + GOST28147_BLOCK_SIZE, GOST28147_KEY_SIZE, + (nettle_set_key_func *) gost28147_set_key, + (nettle_set_key_func *) gost28147_set_key, + (nettle_cipher_func *) gost28147_encrypt, + (nettle_cipher_func *) gost28147_decrypt + }; diff --git a/gost28147.c b/gost28147.c index 15d314c86c17..6ccdcb6a353c 100644 --- a/gost28147.c +++ b/gost28147.c @@ -32,6 +32,8 @@ #include "config.h" #endif
+#include <assert.h> + #include "macros.h" #include "gost28147.h" #include "gost28147-internal.h" @@ -615,3 +617,86 @@ void _gost28147_encrypt_block (const uint32_t *key, const uint32_t sbox[4][256], GOST_ENCRYPT_ROUND(l, r, key[1], key[0], sbox); *out = l, *(out + 1) = r; } + +void _gost28147_decrypt_block (const uint32_t *key, const uint32_t sbox[4][256], + const uint32_t *in, uint32_t *out) +{ + uint32_t l, r; + + r = in[0], l = in[1]; + GOST_ENCRYPT_ROUND(l, r, key[0], key[1], sbox); + GOST_ENCRYPT_ROUND(l, r, key[2], key[3], sbox); + GOST_ENCRYPT_ROUND(l, r, key[4], key[5], sbox); + GOST_ENCRYPT_ROUND(l, r, key[6], key[7], sbox); + GOST_ENCRYPT_ROUND(l, r, key[7], key[6], sbox); + GOST_ENCRYPT_ROUND(l, r, key[5], key[4], sbox); + GOST_ENCRYPT_ROUND(l, r, key[3], key[2], sbox); + GOST_ENCRYPT_ROUND(l, r, key[1], key[0], sbox); + GOST_ENCRYPT_ROUND(l, r, key[7], key[6], sbox); + GOST_ENCRYPT_ROUND(l, r, key[5], key[4], sbox); + GOST_ENCRYPT_ROUND(l, r, key[3], key[2], sbox); + GOST_ENCRYPT_ROUND(l, r, key[1], key[0], sbox); + GOST_ENCRYPT_ROUND(l, r, key[7], key[6], sbox); + GOST_ENCRYPT_ROUND(l, r, key[5], key[4], sbox); + GOST_ENCRYPT_ROUND(l, r, key[3], key[2], sbox); + GOST_ENCRYPT_ROUND(l, r, key[1], key[0], sbox); + *out = l, *(out + 1) = r; +} + +void +gost28147_set_key(struct gost28147_ctx *ctx, const uint8_t *key) +{ + unsigned i; + + assert(key); + for (i = 0; i < 8; i++, key += 4) + ctx->key[i] = LE_READ_UINT32(key); + gost28147_set_param(ctx, &gost28147_param_TC26_Z); +} + +void +gost28147_set_param(struct gost28147_ctx *ctx, const struct gost28147_param *param) +{ + assert(param); + ctx->sbox = param->sbox; +} + +void +gost28147_encrypt(const struct gost28147_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src) +{ + uint32_t block[2]; + + assert(!(length % GOST28147_BLOCK_SIZE)); + + while (length) + { + block[0] = LE_READ_UINT32(src); src += 4; + block[1] = LE_READ_UINT32(src); src += 4; + _gost28147_encrypt_block(ctx->key, ctx->sbox, block, block); + LE_WRITE_UINT32(dst, block[0]); dst += 4; + LE_WRITE_UINT32(dst, block[1]); dst += 4; + length -= GOST28147_BLOCK_SIZE; + } +} + +void +gost28147_decrypt(const struct gost28147_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src) +{ + uint32_t block[2]; + + assert(!(length % GOST28147_BLOCK_SIZE)); + + while (length) + { + block[0] = LE_READ_UINT32(src); src += 4; + block[1] = LE_READ_UINT32(src); src += 4; + _gost28147_decrypt_block(ctx->key, ctx->sbox, block, block); + LE_WRITE_UINT32(dst, block[0]); dst += 4; + LE_WRITE_UINT32(dst, block[1]); dst += 4; + length -= GOST28147_BLOCK_SIZE; + } +} diff --git a/gost28147.h b/gost28147.h index 32e7d5e81eb8..5fff34e859d2 100644 --- a/gost28147.h +++ b/gost28147.h @@ -43,6 +43,20 @@ extern "C" { #define gost28147_param_test_3411 nettle_gost28147_param_test_3411 #define gost28147_param_CryptoPro_3411 nettle_gost28147_param_CryptoPro_3411
+#define gost28147_set_key nettle_gost28147_set_key +#define gost28147_set_param nettle_gost28147_set_param +#define gost28147_encrypt nettle_gost28147_encrypt +#define gost28147_decrypt nettle_gost28147_decrypt + +#define GOST28147_KEY_SIZE 32 +#define GOST28147_BLOCK_SIZE 8 + +struct gost28147_ctx +{ + uint32_t key[GOST28147_KEY_SIZE/4]; + const uint32_t (*sbox)[256]; +}; + struct gost28147_param { uint32_t sbox[4][256]; @@ -51,6 +65,22 @@ struct gost28147_param extern const struct gost28147_param gost28147_param_test_3411; extern const struct gost28147_param gost28147_param_CryptoPro_3411;
+void +gost28147_set_key(struct gost28147_ctx *ctx, const uint8_t *key); + +void +gost28147_set_param(struct gost28147_ctx *ctx, + const struct gost28147_param *param); + +void +gost28147_encrypt(const struct gost28147_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); +void +gost28147_decrypt(const struct gost28147_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); + #ifdef __cplusplus } #endif diff --git a/nettle-meta-ciphers.c b/nettle-meta-ciphers.c index 49cb47a70243..3a48f2f4b2c8 100644 --- a/nettle-meta-ciphers.c +++ b/nettle-meta-ciphers.c @@ -54,6 +54,7 @@ const struct nettle_cipher * const _nettle_ciphers[] = { &nettle_arctwo64, &nettle_arctwo128, &nettle_arctwo_gutmann128, + &nettle_gost28147, NULL };
diff --git a/nettle-meta.h b/nettle-meta.h index b4cdb8f3e378..9075224a57f4 100644 --- a/nettle-meta.h +++ b/nettle-meta.h @@ -89,6 +89,8 @@ extern const struct nettle_cipher nettle_arctwo64; extern const struct nettle_cipher nettle_arctwo128; extern const struct nettle_cipher nettle_arctwo_gutmann128;
+extern const struct nettle_cipher nettle_gost28147; + struct nettle_hash { const char *name; diff --git a/nettle.texinfo b/nettle.texinfo index 9a3ca04e0a7f..b77e28506a52 100644 --- a/nettle.texinfo +++ b/nettle.texinfo @@ -1793,6 +1793,44 @@ in any other way. Analogous to @code{des_encrypt} @end deftypefun
+@subsection GOST 28147-89 (Magma) +GOST 28147-89 (also called Magma) is the Russian standard cipher. It uses a +block size of 64 bits (8 octets), and a key size of 256 bits. Nettle defines +GOST28147 in @file{<nettle/gost28147.h>}. + +@deftp {Context struct} {struct gost28147_ctx} +@end deftp + +@defvr Constant GOST28147_BLOCK_SIZE +The GOST28147 block-size, 8. +@end defvr + +@defvr Constant GOST28147_KEY_SIZE +GOST28147 key size, 32. +@end defvr + +@deftypefun void gost28147_set_key (struct gost28147_ctx *@var{ctx}, const uint8_t *@var{key}) +Initialize the cipher. The same function is used for both encryption and +decryption. +@end deftypefun + +@deftypefun void gost28147_set_sbox (struct gost28147_ctx *@var{ctx}, const uint32_t *@var{sbox}) +Initialize the cipher S-BOX. The same function is used for both encryption and +decryption. +@end deftypefun + +@deftypefun void gost28147_encrypt (struct gost28147_ctx *@var{ctx}, size_t @var{length}, uint8_t *@var{dst}, const uint8_t *@var{src}) +Encryption function. @var{length} must be an integral multiple of the +block size. If it is more than one block, the data is processed in ECB +mode. @code{src} and @code{dst} may be equal, but they must not overlap +in any other way. +@end deftypefun + +@deftypefun void gost28147_decrypt (struct gost28147_ctx *@var{ctx}, size_t @var{length}, uint8_t *@var{dst}, const uint8_t *@var{src}) +Analogous to @code{gost28147_encrypt} +@end deftypefun + + @subsection Salsa20 @cindex Salsa20 Salsa20 is a fairly recent stream cipher designed by D. J. Bernstein. It diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 066bcee2fb23..ef234e34e1ac 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -42,6 +42,7 @@ /eddsa-sign-test /eddsa-verify-test /gcm-test +/gost28147-test /gosthash94-test /hkdf-test /hmac-test diff --git a/testsuite/.test-rules.make b/testsuite/.test-rules.make index efb7df3cbf7a..3e9bfd185e33 100644 --- a/testsuite/.test-rules.make +++ b/testsuite/.test-rules.make @@ -34,6 +34,9 @@ des-test$(EXEEXT): des-test.$(OBJEXT) des3-test$(EXEEXT): des3-test.$(OBJEXT) $(LINK) des3-test.$(OBJEXT) $(TEST_OBJS) -o des3-test$(EXEEXT)
+gost28147-test$(EXEEXT): gost28147-test.$(OBJEXT) + $(LINK) gost28147-test.$(OBJEXT) $(TEST_OBJS) -o gost28147-test$(EXEEXT) + md2-test$(EXEEXT): md2-test.$(OBJEXT) $(LINK) md2-test.$(OBJEXT) $(TEST_OBJS) -o md2-test$(EXEEXT)
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in index f8f85701ef35..043b778a9ed4 100644 --- a/testsuite/Makefile.in +++ b/testsuite/Makefile.in @@ -16,6 +16,7 @@ TS_NETTLE_SOURCES = aes-test.c arcfour-test.c arctwo-test.c \ camellia-test.c chacha-test.c \ cnd-memcpy-test.c \ des-test.c des3-test.c \ + gost28147-test.c \ md2-test.c md4-test.c md5-test.c md5-compat-test.c \ memeql-test.c memxor-test.c gosthash94-test.c \ ripemd160-test.c hkdf-test.c \ diff --git a/testsuite/gost28147-test.c b/testsuite/gost28147-test.c new file mode 100644 index 000000000000..3f8046e19e3f --- /dev/null +++ b/testsuite/gost28147-test.c @@ -0,0 +1,119 @@ +#include "testutils.h" +#include "gost28147.h" + +static void +test_gost28147(const struct gost28147_param *param, + const struct tstring *key, + const struct tstring *cleartext, + const struct tstring *ciphertext) +{ + struct gost28147_ctx ctx; + uint8_t *data = xalloc(cleartext->length); + size_t length; + + ASSERT (cleartext->length == ciphertext->length); + length = cleartext->length; + + gost28147_set_key(&ctx, key->data); + gost28147_set_param(&ctx, param); + gost28147_encrypt(&ctx, length, data, cleartext->data); + + if (!MEMEQ(length, data, ciphertext->data)) + { + fprintf(stderr, "Encrypt failed:\nInput:"); + tstring_print_hex(cleartext); + fprintf(stderr, "\nOutput: "); + print_hex(length, data); + fprintf(stderr, "\nExpected:"); + tstring_print_hex(ciphertext); + fprintf(stderr, "\n"); + FAIL(); + } + + gost28147_set_key(&ctx, key->data); + gost28147_set_param(&ctx, param); + gost28147_decrypt(&ctx, length, data, data); + + if (!MEMEQ(length, data, cleartext->data)) + { + fprintf(stderr, "Decrypt failed:\nInput:"); + tstring_print_hex(ciphertext); + fprintf(stderr, "\nOutput: "); + print_hex(length, data); + fprintf(stderr, "\nExpected:"); + tstring_print_hex(cleartext); + fprintf(stderr, "\n"); + FAIL(); + } + + free(data); +} + +void test_main(void) +{ + /* Examples from GOST R 34.11-94 standard */ + test_gost28147(&gost28147_param_test_3411, + SHEX("546D2033 68656C32 69736520 73736E62 20616779 69677474 73656865 202C3D73"), + SHEX("00000000 00000000"), + SHEX("1B0BBC32 CEBCAB42")); + + test_gost28147(&gost28147_param_test_3411, + SHEX("2033394D 6C320D09 65201A16 6E62001D 67794106 74740E13 6865160D 3D730C11"), + SHEX("00000000 00000000"), + SHEX("FDCF9B5D C8EB0352")); + + test_gost28147(&gost28147_param_test_3411, + SHEX("39B213F5 F209A13F 1AE9BA3A FF1D0C62 41F9E1C7 F1130085 16F20D73 F311B180"), + SHEX("00000000 00000000"), + SHEX("280EFF00 9958348D")); + + test_gost28147(&gost28147_param_test_3411, + SHEX("EC0A8BA1 5EC004A8 BAC50CAC 0C621DEE E1C7B8E7 007AE2EC F2731BFF 4E80E2A0 "), + SHEX("00000000 00000000"), + SHEX("2D562A0D 190486E7 ")); + + test_gost28147(&gost28147_param_test_3411, + SHEX("8182838485868788 898a8b8c8d8e8f80 d1d2d3d4d5d6d7d8 d9dadbdcdddedfd0"), + SHEX("0102030405060708 f1f2f3f4f5f6f7f8"), + SHEX("ced52a7ff7f260d5 bc81a80bb5e65976")); + + test_gost28147(&gost28147_param_CryptoPro_3411, + SHEX("8182838485868788 898a8b8c8d8e8f80 d1d2d3d4d5d6d7d8 d9dadbdcdddedfd0"), + SHEX("0102030405060708 f1f2f3f4f5f6f7f8"), + SHEX("e42175e16922d0a8 48e59157d7106518")); + + test_gost28147(&gost28147_param_Test_89, + SHEX("8182838485868788 898a8b8c8d8e8f80 d1d2d3d4d5d6d7d8 d9dadbdcdddedfd0"), + SHEX("0102030405060708 f1f2f3f4f5f6f7f8"), + SHEX("9856cf8bfcc282f4 3f465801c6539a5c")); + + test_gost28147(&gost28147_param_CryptoPro_A, + SHEX("8182838485868788 898a8b8c8d8e8f80 d1d2d3d4d5d6d7d8 d9dadbdcdddedfd0"), + SHEX("0102030405060708 f1f2f3f4f5f6f7f8"), + SHEX("668184aedc48c917 4164347058845cac")); + + test_gost28147(&gost28147_param_CryptoPro_B, + SHEX("8182838485868788 898a8b8c8d8e8f80 d1d2d3d4d5d6d7d8 d9dadbdcdddedfd0"), + SHEX("0102030405060708 f1f2f3f4f5f6f7f8"), + SHEX("dbee81147b74b0f2 db5ef00eff4bd528")); + + test_gost28147(&gost28147_param_CryptoPro_C, + SHEX("8182838485868788 898a8b8c8d8e8f80 d1d2d3d4d5d6d7d8 d9dadbdcdddedfd0"), + SHEX("0102030405060708 f1f2f3f4f5f6f7f8"), + SHEX("31a3859d0aeeb80e 4afbd6ce7798ffa9")); + + test_gost28147(&gost28147_param_CryptoPro_D, + SHEX("8182838485868788 898a8b8c8d8e8f80 d1d2d3d4d5d6d7d8 d9dadbdcdddedfd0"), + SHEX("0102030405060708 f1f2f3f4f5f6f7f8"), + SHEX("b1323e0b2173cbd1 c5282f2461e97aa8")); + + test_gost28147(&gost28147_param_TC26_Z, + SHEX("8182838485868788 898a8b8c8d8e8f80 d1d2d3d4d5d6d7d8 d9dadbdcdddedfd0"), + SHEX("0102030405060708 f1f2f3f4f5f6f7f8"), + SHEX("ce5a5ed7e0577a5f d0cc85ce31635b8b")); + + test_gost28147(&gost28147_param_TC26_Z, + SHEX("ccddeeff8899aabb4455667700112233f3f2f1f0f7f6f5f4fbfaf9f8fffefdfc"), + SHEX("1032547698badcfe"), + SHEX("3dcad8c2e501e94e")); +} diff --git a/testsuite/meta-cipher-test.c b/testsuite/meta-cipher-test.c index f949fd76aabb..8c435cb5d3a9 100644 --- a/testsuite/meta-cipher-test.c +++ b/testsuite/meta-cipher-test.c @@ -13,6 +13,7 @@ const char* ciphers[] = { "camellia192", "camellia256", "cast128", + "gost28147", "serpent128", "serpent192", "serpent256",
From: Dmitry Eremin-Solenikov dbaryshkov@gmail.com
Signed-off-by: Dmitry Eremin-Solenikov dbaryshkov@gmail.com --- gost28147.c | 1602 +++++++++++++++++++++++++++++++++++++++++++++++++++ gost28147.h | 13 + 2 files changed, 1615 insertions(+)
diff --git a/gost28147.c b/gost28147.c index 6ccdcb6a353c..9fe31043a3ff 100644 --- a/gost28147.c +++ b/gost28147.c @@ -573,6 +573,1608 @@ const struct gost28147_param gost28147_param_CryptoPro_3411 = } };
+const struct gost28147_param gost28147_param_Test_89 = +{ + { + { /* 0 */ + 0x00062000, 0x00061000, 0x00067800, 0x00062800, + 0x00064800, 0x00060800, 0x00060000, 0x00064000, + 0x00067000, 0x00061800, 0x00065800, 0x00066000, + 0x00066800, 0x00063800, 0x00065000, 0x00063000, + 0x0004a000, 0x00049000, 0x0004f800, 0x0004a800, + 0x0004c800, 0x00048800, 0x00048000, 0x0004c000, + 0x0004f000, 0x00049800, 0x0004d800, 0x0004e000, + 0x0004e800, 0x0004b800, 0x0004d000, 0x0004b000, + 0x0007a000, 0x00079000, 0x0007f800, 0x0007a800, + 0x0007c800, 0x00078800, 0x00078000, 0x0007c000, + 0x0007f000, 0x00079800, 0x0007d800, 0x0007e000, + 0x0007e800, 0x0007b800, 0x0007d000, 0x0007b000, + 0x00072000, 0x00071000, 0x00077800, 0x00072800, + 0x00074800, 0x00070800, 0x00070000, 0x00074000, + 0x00077000, 0x00071800, 0x00075800, 0x00076000, + 0x00076800, 0x00073800, 0x00075000, 0x00073000, + 0x00042000, 0x00041000, 0x00047800, 0x00042800, + 0x00044800, 0x00040800, 0x00040000, 0x00044000, + 0x00047000, 0x00041800, 0x00045800, 0x00046000, + 0x00046800, 0x00043800, 0x00045000, 0x00043000, + 0x0000a000, 0x00009000, 0x0000f800, 0x0000a800, + 0x0000c800, 0x00008800, 0x00008000, 0x0000c000, + 0x0000f000, 0x00009800, 0x0000d800, 0x0000e000, + 0x0000e800, 0x0000b800, 0x0000d000, 0x0000b000, + 0x0001a000, 0x00019000, 0x0001f800, 0x0001a800, + 0x0001c800, 0x00018800, 0x00018000, 0x0001c000, + 0x0001f000, 0x00019800, 0x0001d800, 0x0001e000, + 0x0001e800, 0x0001b800, 0x0001d000, 0x0001b000, + 0x00052000, 0x00051000, 0x00057800, 0x00052800, + 0x00054800, 0x00050800, 0x00050000, 0x00054000, + 0x00057000, 0x00051800, 0x00055800, 0x00056000, + 0x00056800, 0x00053800, 0x00055000, 0x00053000, + 0x00012000, 0x00011000, 0x00017800, 0x00012800, + 0x00014800, 0x00010800, 0x00010000, 0x00014000, + 0x00017000, 0x00011800, 0x00015800, 0x00016000, + 0x00016800, 0x00013800, 0x00015000, 0x00013000, + 0x0003a000, 0x00039000, 0x0003f800, 0x0003a800, + 0x0003c800, 0x00038800, 0x00038000, 0x0003c000, + 0x0003f000, 0x00039800, 0x0003d800, 0x0003e000, + 0x0003e800, 0x0003b800, 0x0003d000, 0x0003b000, + 0x00022000, 0x00021000, 0x00027800, 0x00022800, + 0x00024800, 0x00020800, 0x00020000, 0x00024000, + 0x00027000, 0x00021800, 0x00025800, 0x00026000, + 0x00026800, 0x00023800, 0x00025000, 0x00023000, + 0x0006a000, 0x00069000, 0x0006f800, 0x0006a800, + 0x0006c800, 0x00068800, 0x00068000, 0x0006c000, + 0x0006f000, 0x00069800, 0x0006d800, 0x0006e000, + 0x0006e800, 0x0006b800, 0x0006d000, 0x0006b000, + 0x00032000, 0x00031000, 0x00037800, 0x00032800, + 0x00034800, 0x00030800, 0x00030000, 0x00034000, + 0x00037000, 0x00031800, 0x00035800, 0x00036000, + 0x00036800, 0x00033800, 0x00035000, 0x00033000, + 0x00002000, 0x00001000, 0x00007800, 0x00002800, + 0x00004800, 0x00000800, 0x00000000, 0x00004000, + 0x00007000, 0x00001800, 0x00005800, 0x00006000, + 0x00006800, 0x00003800, 0x00005000, 0x00003000, + 0x0005a000, 0x00059000, 0x0005f800, 0x0005a800, + 0x0005c800, 0x00058800, 0x00058000, 0x0005c000, + 0x0005f000, 0x00059800, 0x0005d800, 0x0005e000, + 0x0005e800, 0x0005b800, 0x0005d000, 0x0005b000, + 0x0002a000, 0x00029000, 0x0002f800, 0x0002a800, + 0x0002c800, 0x00028800, 0x00028000, 0x0002c000, + 0x0002f000, 0x00029800, 0x0002d800, 0x0002e000, + 0x0002e800, 0x0002b800, 0x0002d000, 0x0002b000, + }, { /* 1 */ + 0x07680000, 0x07400000, 0x07700000, 0x07600000, + 0x07380000, 0x07180000, 0x07480000, 0x07500000, + 0x07080000, 0x07280000, 0x07100000, 0x07200000, + 0x07300000, 0x07780000, 0x07000000, 0x07580000, + 0x04e80000, 0x04c00000, 0x04f00000, 0x04e00000, + 0x04b80000, 0x04980000, 0x04c80000, 0x04d00000, + 0x04880000, 0x04a80000, 0x04900000, 0x04a00000, + 0x04b00000, 0x04f80000, 0x04800000, 0x04d80000, + 0x05e80000, 0x05c00000, 0x05f00000, 0x05e00000, + 0x05b80000, 0x05980000, 0x05c80000, 0x05d00000, + 0x05880000, 0x05a80000, 0x05900000, 0x05a00000, + 0x05b00000, 0x05f80000, 0x05800000, 0x05d80000, + 0x01680000, 0x01400000, 0x01700000, 0x01600000, + 0x01380000, 0x01180000, 0x01480000, 0x01500000, + 0x01080000, 0x01280000, 0x01100000, 0x01200000, + 0x01300000, 0x01780000, 0x01000000, 0x01580000, + 0x02e80000, 0x02c00000, 0x02f00000, 0x02e00000, + 0x02b80000, 0x02980000, 0x02c80000, 0x02d00000, + 0x02880000, 0x02a80000, 0x02900000, 0x02a00000, + 0x02b00000, 0x02f80000, 0x02800000, 0x02d80000, + 0x07e80000, 0x07c00000, 0x07f00000, 0x07e00000, + 0x07b80000, 0x07980000, 0x07c80000, 0x07d00000, + 0x07880000, 0x07a80000, 0x07900000, 0x07a00000, + 0x07b00000, 0x07f80000, 0x07800000, 0x07d80000, + 0x03e80000, 0x03c00000, 0x03f00000, 0x03e00000, + 0x03b80000, 0x03980000, 0x03c80000, 0x03d00000, + 0x03880000, 0x03a80000, 0x03900000, 0x03a00000, + 0x03b00000, 0x03f80000, 0x03800000, 0x03d80000, + 0x00e80000, 0x00c00000, 0x00f00000, 0x00e00000, + 0x00b80000, 0x00980000, 0x00c80000, 0x00d00000, + 0x00880000, 0x00a80000, 0x00900000, 0x00a00000, + 0x00b00000, 0x00f80000, 0x00800000, 0x00d80000, + 0x00680000, 0x00400000, 0x00700000, 0x00600000, + 0x00380000, 0x00180000, 0x00480000, 0x00500000, + 0x00080000, 0x00280000, 0x00100000, 0x00200000, + 0x00300000, 0x00780000, 0x00000000, 0x00580000, + 0x06e80000, 0x06c00000, 0x06f00000, 0x06e00000, + 0x06b80000, 0x06980000, 0x06c80000, 0x06d00000, + 0x06880000, 0x06a80000, 0x06900000, 0x06a00000, + 0x06b00000, 0x06f80000, 0x06800000, 0x06d80000, + 0x06680000, 0x06400000, 0x06700000, 0x06600000, + 0x06380000, 0x06180000, 0x06480000, 0x06500000, + 0x06080000, 0x06280000, 0x06100000, 0x06200000, + 0x06300000, 0x06780000, 0x06000000, 0x06580000, + 0x03680000, 0x03400000, 0x03700000, 0x03600000, + 0x03380000, 0x03180000, 0x03480000, 0x03500000, + 0x03080000, 0x03280000, 0x03100000, 0x03200000, + 0x03300000, 0x03780000, 0x03000000, 0x03580000, + 0x05680000, 0x05400000, 0x05700000, 0x05600000, + 0x05380000, 0x05180000, 0x05480000, 0x05500000, + 0x05080000, 0x05280000, 0x05100000, 0x05200000, + 0x05300000, 0x05780000, 0x05000000, 0x05580000, + 0x02680000, 0x02400000, 0x02700000, 0x02600000, + 0x02380000, 0x02180000, 0x02480000, 0x02500000, + 0x02080000, 0x02280000, 0x02100000, 0x02200000, + 0x02300000, 0x02780000, 0x02000000, 0x02580000, + 0x01e80000, 0x01c00000, 0x01f00000, 0x01e00000, + 0x01b80000, 0x01980000, 0x01c80000, 0x01d00000, + 0x01880000, 0x01a80000, 0x01900000, 0x01a00000, + 0x01b00000, 0x01f80000, 0x01800000, 0x01d80000, + 0x04680000, 0x04400000, 0x04700000, 0x04600000, + 0x04380000, 0x04180000, 0x04480000, 0x04500000, + 0x04080000, 0x04280000, 0x04100000, 0x04200000, + 0x04300000, 0x04780000, 0x04000000, 0x04580000, + }, { /* 2 */ + 0x18000004, 0x70000004, 0x28000004, 0x48000004, + 0x30000004, 0x40000004, 0x00000004, 0x68000004, + 0x50000004, 0x58000004, 0x38000004, 0x60000004, + 0x10000004, 0x08000004, 0x78000004, 0x20000004, + 0x98000007, 0xf0000007, 0xa8000007, 0xc8000007, + 0xb0000007, 0xc0000007, 0x80000007, 0xe8000007, + 0xd0000007, 0xd8000007, 0xb8000007, 0xe0000007, + 0x90000007, 0x88000007, 0xf8000007, 0xa0000007, + 0x18000003, 0x70000003, 0x28000003, 0x48000003, + 0x30000003, 0x40000003, 0x00000003, 0x68000003, + 0x50000003, 0x58000003, 0x38000003, 0x60000003, + 0x10000003, 0x08000003, 0x78000003, 0x20000003, + 0x98000005, 0xf0000005, 0xa8000005, 0xc8000005, + 0xb0000005, 0xc0000005, 0x80000005, 0xe8000005, + 0xd0000005, 0xd8000005, 0xb8000005, 0xe0000005, + 0x90000005, 0x88000005, 0xf8000005, 0xa0000005, + 0x98000000, 0xf0000000, 0xa8000000, 0xc8000000, + 0xb0000000, 0xc0000000, 0x80000000, 0xe8000000, + 0xd0000000, 0xd8000000, 0xb8000000, 0xe0000000, + 0x90000000, 0x88000000, 0xf8000000, 0xa0000000, + 0x98000004, 0xf0000004, 0xa8000004, 0xc8000004, + 0xb0000004, 0xc0000004, 0x80000004, 0xe8000004, + 0xd0000004, 0xd8000004, 0xb8000004, 0xe0000004, + 0x90000004, 0x88000004, 0xf8000004, 0xa0000004, + 0x18000006, 0x70000006, 0x28000006, 0x48000006, + 0x30000006, 0x40000006, 0x00000006, 0x68000006, + 0x50000006, 0x58000006, 0x38000006, 0x60000006, + 0x10000006, 0x08000006, 0x78000006, 0x20000006, + 0x98000002, 0xf0000002, 0xa8000002, 0xc8000002, + 0xb0000002, 0xc0000002, 0x80000002, 0xe8000002, + 0xd0000002, 0xd8000002, 0xb8000002, 0xe0000002, + 0x90000002, 0x88000002, 0xf8000002, 0xa0000002, + 0x98000006, 0xf0000006, 0xa8000006, 0xc8000006, + 0xb0000006, 0xc0000006, 0x80000006, 0xe8000006, + 0xd0000006, 0xd8000006, 0xb8000006, 0xe0000006, + 0x90000006, 0x88000006, 0xf8000006, 0xa0000006, + 0x98000001, 0xf0000001, 0xa8000001, 0xc8000001, + 0xb0000001, 0xc0000001, 0x80000001, 0xe8000001, + 0xd0000001, 0xd8000001, 0xb8000001, 0xe0000001, + 0x90000001, 0x88000001, 0xf8000001, 0xa0000001, + 0x98000003, 0xf0000003, 0xa8000003, 0xc8000003, + 0xb0000003, 0xc0000003, 0x80000003, 0xe8000003, + 0xd0000003, 0xd8000003, 0xb8000003, 0xe0000003, + 0x90000003, 0x88000003, 0xf8000003, 0xa0000003, + 0x18000005, 0x70000005, 0x28000005, 0x48000005, + 0x30000005, 0x40000005, 0x00000005, 0x68000005, + 0x50000005, 0x58000005, 0x38000005, 0x60000005, + 0x10000005, 0x08000005, 0x78000005, 0x20000005, + 0x18000000, 0x70000000, 0x28000000, 0x48000000, + 0x30000000, 0x40000000, 0x00000000, 0x68000000, + 0x50000000, 0x58000000, 0x38000000, 0x60000000, + 0x10000000, 0x08000000, 0x78000000, 0x20000000, + 0x18000007, 0x70000007, 0x28000007, 0x48000007, + 0x30000007, 0x40000007, 0x00000007, 0x68000007, + 0x50000007, 0x58000007, 0x38000007, 0x60000007, + 0x10000007, 0x08000007, 0x78000007, 0x20000007, + 0x18000001, 0x70000001, 0x28000001, 0x48000001, + 0x30000001, 0x40000001, 0x00000001, 0x68000001, + 0x50000001, 0x58000001, 0x38000001, 0x60000001, + 0x10000001, 0x08000001, 0x78000001, 0x20000001, + 0x18000002, 0x70000002, 0x28000002, 0x48000002, + 0x30000002, 0x40000002, 0x00000002, 0x68000002, + 0x50000002, 0x58000002, 0x38000002, 0x60000002, + 0x10000002, 0x08000002, 0x78000002, 0x20000002, + }, { /* 3 */ + 0x00000648, 0x00000658, 0x00000660, 0x00000600, + 0x00000618, 0x00000630, 0x00000638, 0x00000628, + 0x00000620, 0x00000640, 0x00000670, 0x00000678, + 0x00000608, 0x00000650, 0x00000610, 0x00000668, + 0x00000348, 0x00000358, 0x00000360, 0x00000300, + 0x00000318, 0x00000330, 0x00000338, 0x00000328, + 0x00000320, 0x00000340, 0x00000370, 0x00000378, + 0x00000308, 0x00000350, 0x00000310, 0x00000368, + 0x000002c8, 0x000002d8, 0x000002e0, 0x00000280, + 0x00000298, 0x000002b0, 0x000002b8, 0x000002a8, + 0x000002a0, 0x000002c0, 0x000002f0, 0x000002f8, + 0x00000288, 0x000002d0, 0x00000290, 0x000002e8, + 0x00000148, 0x00000158, 0x00000160, 0x00000100, + 0x00000118, 0x00000130, 0x00000138, 0x00000128, + 0x00000120, 0x00000140, 0x00000170, 0x00000178, + 0x00000108, 0x00000150, 0x00000110, 0x00000168, + 0x000005c8, 0x000005d8, 0x000005e0, 0x00000580, + 0x00000598, 0x000005b0, 0x000005b8, 0x000005a8, + 0x000005a0, 0x000005c0, 0x000005f0, 0x000005f8, + 0x00000588, 0x000005d0, 0x00000590, 0x000005e8, + 0x00000048, 0x00000058, 0x00000060, 0x00000000, + 0x00000018, 0x00000030, 0x00000038, 0x00000028, + 0x00000020, 0x00000040, 0x00000070, 0x00000078, + 0x00000008, 0x00000050, 0x00000010, 0x00000068, + 0x000004c8, 0x000004d8, 0x000004e0, 0x00000480, + 0x00000498, 0x000004b0, 0x000004b8, 0x000004a8, + 0x000004a0, 0x000004c0, 0x000004f0, 0x000004f8, + 0x00000488, 0x000004d0, 0x00000490, 0x000004e8, + 0x000006c8, 0x000006d8, 0x000006e0, 0x00000680, + 0x00000698, 0x000006b0, 0x000006b8, 0x000006a8, + 0x000006a0, 0x000006c0, 0x000006f0, 0x000006f8, + 0x00000688, 0x000006d0, 0x00000690, 0x000006e8, + 0x000001c8, 0x000001d8, 0x000001e0, 0x00000180, + 0x00000198, 0x000001b0, 0x000001b8, 0x000001a8, + 0x000001a0, 0x000001c0, 0x000001f0, 0x000001f8, + 0x00000188, 0x000001d0, 0x00000190, 0x000001e8, + 0x00000748, 0x00000758, 0x00000760, 0x00000700, + 0x00000718, 0x00000730, 0x00000738, 0x00000728, + 0x00000720, 0x00000740, 0x00000770, 0x00000778, + 0x00000708, 0x00000750, 0x00000710, 0x00000768, + 0x000003c8, 0x000003d8, 0x000003e0, 0x00000380, + 0x00000398, 0x000003b0, 0x000003b8, 0x000003a8, + 0x000003a0, 0x000003c0, 0x000003f0, 0x000003f8, + 0x00000388, 0x000003d0, 0x00000390, 0x000003e8, + 0x00000548, 0x00000558, 0x00000560, 0x00000500, + 0x00000518, 0x00000530, 0x00000538, 0x00000528, + 0x00000520, 0x00000540, 0x00000570, 0x00000578, + 0x00000508, 0x00000550, 0x00000510, 0x00000568, + 0x000007c8, 0x000007d8, 0x000007e0, 0x00000780, + 0x00000798, 0x000007b0, 0x000007b8, 0x000007a8, + 0x000007a0, 0x000007c0, 0x000007f0, 0x000007f8, + 0x00000788, 0x000007d0, 0x00000790, 0x000007e8, + 0x00000248, 0x00000258, 0x00000260, 0x00000200, + 0x00000218, 0x00000230, 0x00000238, 0x00000228, + 0x00000220, 0x00000240, 0x00000270, 0x00000278, + 0x00000208, 0x00000250, 0x00000210, 0x00000268, + 0x000000c8, 0x000000d8, 0x000000e0, 0x00000080, + 0x00000098, 0x000000b0, 0x000000b8, 0x000000a8, + 0x000000a0, 0x000000c0, 0x000000f0, 0x000000f8, + 0x00000088, 0x000000d0, 0x00000090, 0x000000e8, + 0x00000448, 0x00000458, 0x00000460, 0x00000400, + 0x00000418, 0x00000430, 0x00000438, 0x00000428, + 0x00000420, 0x00000440, 0x00000470, 0x00000478, + 0x00000408, 0x00000450, 0x00000410, 0x00000468, + } + } +}; + +const struct gost28147_param gost28147_param_CryptoPro_A = +{ + { + { /* 0 */ + 0x0001c800, 0x0001b000, 0x00019800, 0x00019000, + 0x0001c000, 0x0001d800, 0x00018800, 0x0001b800, + 0x0001d000, 0x0001a000, 0x0001f000, 0x0001f800, + 0x0001e000, 0x00018000, 0x0001e800, 0x0001a800, + 0x0003c800, 0x0003b000, 0x00039800, 0x00039000, + 0x0003c000, 0x0003d800, 0x00038800, 0x0003b800, + 0x0003d000, 0x0003a000, 0x0003f000, 0x0003f800, + 0x0003e000, 0x00038000, 0x0003e800, 0x0003a800, + 0x00074800, 0x00073000, 0x00071800, 0x00071000, + 0x00074000, 0x00075800, 0x00070800, 0x00073800, + 0x00075000, 0x00072000, 0x00077000, 0x00077800, + 0x00076000, 0x00070000, 0x00076800, 0x00072800, + 0x0004c800, 0x0004b000, 0x00049800, 0x00049000, + 0x0004c000, 0x0004d800, 0x00048800, 0x0004b800, + 0x0004d000, 0x0004a000, 0x0004f000, 0x0004f800, + 0x0004e000, 0x00048000, 0x0004e800, 0x0004a800, + 0x00044800, 0x00043000, 0x00041800, 0x00041000, + 0x00044000, 0x00045800, 0x00040800, 0x00043800, + 0x00045000, 0x00042000, 0x00047000, 0x00047800, + 0x00046000, 0x00040000, 0x00046800, 0x00042800, + 0x00054800, 0x00053000, 0x00051800, 0x00051000, + 0x00054000, 0x00055800, 0x00050800, 0x00053800, + 0x00055000, 0x00052000, 0x00057000, 0x00057800, + 0x00056000, 0x00050000, 0x00056800, 0x00052800, + 0x0007c800, 0x0007b000, 0x00079800, 0x00079000, + 0x0007c000, 0x0007d800, 0x00078800, 0x0007b800, + 0x0007d000, 0x0007a000, 0x0007f000, 0x0007f800, + 0x0007e000, 0x00078000, 0x0007e800, 0x0007a800, + 0x00004800, 0x00003000, 0x00001800, 0x00001000, + 0x00004000, 0x00005800, 0x00000800, 0x00003800, + 0x00005000, 0x00002000, 0x00007000, 0x00007800, + 0x00006000, 0x00000000, 0x00006800, 0x00002800, + 0x0002c800, 0x0002b000, 0x00029800, 0x00029000, + 0x0002c000, 0x0002d800, 0x00028800, 0x0002b800, + 0x0002d000, 0x0002a000, 0x0002f000, 0x0002f800, + 0x0002e000, 0x00028000, 0x0002e800, 0x0002a800, + 0x00014800, 0x00013000, 0x00011800, 0x00011000, + 0x00014000, 0x00015800, 0x00010800, 0x00013800, + 0x00015000, 0x00012000, 0x00017000, 0x00017800, + 0x00016000, 0x00010000, 0x00016800, 0x00012800, + 0x00034800, 0x00033000, 0x00031800, 0x00031000, + 0x00034000, 0x00035800, 0x00030800, 0x00033800, + 0x00035000, 0x00032000, 0x00037000, 0x00037800, + 0x00036000, 0x00030000, 0x00036800, 0x00032800, + 0x00064800, 0x00063000, 0x00061800, 0x00061000, + 0x00064000, 0x00065800, 0x00060800, 0x00063800, + 0x00065000, 0x00062000, 0x00067000, 0x00067800, + 0x00066000, 0x00060000, 0x00066800, 0x00062800, + 0x0005c800, 0x0005b000, 0x00059800, 0x00059000, + 0x0005c000, 0x0005d800, 0x00058800, 0x0005b800, + 0x0005d000, 0x0005a000, 0x0005f000, 0x0005f800, + 0x0005e000, 0x00058000, 0x0005e800, 0x0005a800, + 0x00024800, 0x00023000, 0x00021800, 0x00021000, + 0x00024000, 0x00025800, 0x00020800, 0x00023800, + 0x00025000, 0x00022000, 0x00027000, 0x00027800, + 0x00026000, 0x00020000, 0x00026800, 0x00022800, + 0x0006c800, 0x0006b000, 0x00069800, 0x00069000, + 0x0006c000, 0x0006d800, 0x00068800, 0x0006b800, + 0x0006d000, 0x0006a000, 0x0006f000, 0x0006f800, + 0x0006e000, 0x00068000, 0x0006e800, 0x0006a800, + 0x0000c800, 0x0000b000, 0x00009800, 0x00009000, + 0x0000c000, 0x0000d800, 0x00008800, 0x0000b800, + 0x0000d000, 0x0000a000, 0x0000f000, 0x0000f800, + 0x0000e000, 0x00008000, 0x0000e800, 0x0000a800, + }, { /* 1 */ + 0x07700000, 0x07200000, 0x07300000, 0x07100000, + 0x07580000, 0x07180000, 0x07680000, 0x07400000, + 0x07600000, 0x07780000, 0x07280000, 0x07500000, + 0x07000000, 0x07380000, 0x07080000, 0x07480000, + 0x03f00000, 0x03a00000, 0x03b00000, 0x03900000, + 0x03d80000, 0x03980000, 0x03e80000, 0x03c00000, + 0x03e00000, 0x03f80000, 0x03a80000, 0x03d00000, + 0x03800000, 0x03b80000, 0x03880000, 0x03c80000, + 0x05700000, 0x05200000, 0x05300000, 0x05100000, + 0x05580000, 0x05180000, 0x05680000, 0x05400000, + 0x05600000, 0x05780000, 0x05280000, 0x05500000, + 0x05000000, 0x05380000, 0x05080000, 0x05480000, + 0x06700000, 0x06200000, 0x06300000, 0x06100000, + 0x06580000, 0x06180000, 0x06680000, 0x06400000, + 0x06600000, 0x06780000, 0x06280000, 0x06500000, + 0x06000000, 0x06380000, 0x06080000, 0x06480000, + 0x06f00000, 0x06a00000, 0x06b00000, 0x06900000, + 0x06d80000, 0x06980000, 0x06e80000, 0x06c00000, + 0x06e00000, 0x06f80000, 0x06a80000, 0x06d00000, + 0x06800000, 0x06b80000, 0x06880000, 0x06c80000, + 0x00f00000, 0x00a00000, 0x00b00000, 0x00900000, + 0x00d80000, 0x00980000, 0x00e80000, 0x00c00000, + 0x00e00000, 0x00f80000, 0x00a80000, 0x00d00000, + 0x00800000, 0x00b80000, 0x00880000, 0x00c80000, + 0x01f00000, 0x01a00000, 0x01b00000, 0x01900000, + 0x01d80000, 0x01980000, 0x01e80000, 0x01c00000, + 0x01e00000, 0x01f80000, 0x01a80000, 0x01d00000, + 0x01800000, 0x01b80000, 0x01880000, 0x01c80000, + 0x04f00000, 0x04a00000, 0x04b00000, 0x04900000, + 0x04d80000, 0x04980000, 0x04e80000, 0x04c00000, + 0x04e00000, 0x04f80000, 0x04a80000, 0x04d00000, + 0x04800000, 0x04b80000, 0x04880000, 0x04c80000, + 0x00700000, 0x00200000, 0x00300000, 0x00100000, + 0x00580000, 0x00180000, 0x00680000, 0x00400000, + 0x00600000, 0x00780000, 0x00280000, 0x00500000, + 0x00000000, 0x00380000, 0x00080000, 0x00480000, + 0x01700000, 0x01200000, 0x01300000, 0x01100000, + 0x01580000, 0x01180000, 0x01680000, 0x01400000, + 0x01600000, 0x01780000, 0x01280000, 0x01500000, + 0x01000000, 0x01380000, 0x01080000, 0x01480000, + 0x05f00000, 0x05a00000, 0x05b00000, 0x05900000, + 0x05d80000, 0x05980000, 0x05e80000, 0x05c00000, + 0x05e00000, 0x05f80000, 0x05a80000, 0x05d00000, + 0x05800000, 0x05b80000, 0x05880000, 0x05c80000, + 0x02700000, 0x02200000, 0x02300000, 0x02100000, + 0x02580000, 0x02180000, 0x02680000, 0x02400000, + 0x02600000, 0x02780000, 0x02280000, 0x02500000, + 0x02000000, 0x02380000, 0x02080000, 0x02480000, + 0x07f00000, 0x07a00000, 0x07b00000, 0x07900000, + 0x07d80000, 0x07980000, 0x07e80000, 0x07c00000, + 0x07e00000, 0x07f80000, 0x07a80000, 0x07d00000, + 0x07800000, 0x07b80000, 0x07880000, 0x07c80000, + 0x04700000, 0x04200000, 0x04300000, 0x04100000, + 0x04580000, 0x04180000, 0x04680000, 0x04400000, + 0x04600000, 0x04780000, 0x04280000, 0x04500000, + 0x04000000, 0x04380000, 0x04080000, 0x04480000, + 0x02f00000, 0x02a00000, 0x02b00000, 0x02900000, + 0x02d80000, 0x02980000, 0x02e80000, 0x02c00000, + 0x02e00000, 0x02f80000, 0x02a80000, 0x02d00000, + 0x02800000, 0x02b80000, 0x02880000, 0x02c80000, + 0x03700000, 0x03200000, 0x03300000, 0x03100000, + 0x03580000, 0x03180000, 0x03680000, 0x03400000, + 0x03600000, 0x03780000, 0x03280000, 0x03500000, + 0x03000000, 0x03380000, 0x03080000, 0x03480000, + }, { /* 2 */ + 0xd8000001, 0xa8000001, 0x88000001, 0xc8000001, + 0xc0000001, 0xe8000001, 0xf8000001, 0x80000001, + 0xf0000001, 0xa0000001, 0x90000001, 0x98000001, + 0xe0000001, 0xb8000001, 0xd0000001, 0xb0000001, + 0x58000005, 0x28000005, 0x08000005, 0x48000005, + 0x40000005, 0x68000005, 0x78000005, 0x00000005, + 0x70000005, 0x20000005, 0x10000005, 0x18000005, + 0x60000005, 0x38000005, 0x50000005, 0x30000005, + 0xd8000006, 0xa8000006, 0x88000006, 0xc8000006, + 0xc0000006, 0xe8000006, 0xf8000006, 0x80000006, + 0xf0000006, 0xa0000006, 0x90000006, 0x98000006, + 0xe0000006, 0xb8000006, 0xd0000006, 0xb0000006, + 0x58000006, 0x28000006, 0x08000006, 0x48000006, + 0x40000006, 0x68000006, 0x78000006, 0x00000006, + 0x70000006, 0x20000006, 0x10000006, 0x18000006, + 0x60000006, 0x38000006, 0x50000006, 0x30000006, + 0xd8000000, 0xa8000000, 0x88000000, 0xc8000000, + 0xc0000000, 0xe8000000, 0xf8000000, 0x80000000, + 0xf0000000, 0xa0000000, 0x90000000, 0x98000000, + 0xe0000000, 0xb8000000, 0xd0000000, 0xb0000000, + 0x58000001, 0x28000001, 0x08000001, 0x48000001, + 0x40000001, 0x68000001, 0x78000001, 0x00000001, + 0x70000001, 0x20000001, 0x10000001, 0x18000001, + 0x60000001, 0x38000001, 0x50000001, 0x30000001, + 0x58000000, 0x28000000, 0x08000000, 0x48000000, + 0x40000000, 0x68000000, 0x78000000, 0x00000000, + 0x70000000, 0x20000000, 0x10000000, 0x18000000, + 0x60000000, 0x38000000, 0x50000000, 0x30000000, + 0xd8000005, 0xa8000005, 0x88000005, 0xc8000005, + 0xc0000005, 0xe8000005, 0xf8000005, 0x80000005, + 0xf0000005, 0xa0000005, 0x90000005, 0x98000005, + 0xe0000005, 0xb8000005, 0xd0000005, 0xb0000005, + 0xd8000003, 0xa8000003, 0x88000003, 0xc8000003, + 0xc0000003, 0xe8000003, 0xf8000003, 0x80000003, + 0xf0000003, 0xa0000003, 0x90000003, 0x98000003, + 0xe0000003, 0xb8000003, 0xd0000003, 0xb0000003, + 0xd8000002, 0xa8000002, 0x88000002, 0xc8000002, + 0xc0000002, 0xe8000002, 0xf8000002, 0x80000002, + 0xf0000002, 0xa0000002, 0x90000002, 0x98000002, + 0xe0000002, 0xb8000002, 0xd0000002, 0xb0000002, + 0xd8000004, 0xa8000004, 0x88000004, 0xc8000004, + 0xc0000004, 0xe8000004, 0xf8000004, 0x80000004, + 0xf0000004, 0xa0000004, 0x90000004, 0x98000004, + 0xe0000004, 0xb8000004, 0xd0000004, 0xb0000004, + 0x58000002, 0x28000002, 0x08000002, 0x48000002, + 0x40000002, 0x68000002, 0x78000002, 0x00000002, + 0x70000002, 0x20000002, 0x10000002, 0x18000002, + 0x60000002, 0x38000002, 0x50000002, 0x30000002, + 0x58000004, 0x28000004, 0x08000004, 0x48000004, + 0x40000004, 0x68000004, 0x78000004, 0x00000004, + 0x70000004, 0x20000004, 0x10000004, 0x18000004, + 0x60000004, 0x38000004, 0x50000004, 0x30000004, + 0xd8000007, 0xa8000007, 0x88000007, 0xc8000007, + 0xc0000007, 0xe8000007, 0xf8000007, 0x80000007, + 0xf0000007, 0xa0000007, 0x90000007, 0x98000007, + 0xe0000007, 0xb8000007, 0xd0000007, 0xb0000007, + 0x58000007, 0x28000007, 0x08000007, 0x48000007, + 0x40000007, 0x68000007, 0x78000007, 0x00000007, + 0x70000007, 0x20000007, 0x10000007, 0x18000007, + 0x60000007, 0x38000007, 0x50000007, 0x30000007, + 0x58000003, 0x28000003, 0x08000003, 0x48000003, + 0x40000003, 0x68000003, 0x78000003, 0x00000003, + 0x70000003, 0x20000003, 0x10000003, 0x18000003, + 0x60000003, 0x38000003, 0x50000003, 0x30000003, + }, { /* 3 */ + 0x00000588, 0x000005e8, 0x00000590, 0x000005c8, + 0x000005b8, 0x000005d0, 0x000005b0, 0x00000580, + 0x000005c0, 0x000005e0, 0x000005a0, 0x000005a8, + 0x000005f8, 0x00000598, 0x000005d8, 0x000005f0, + 0x00000508, 0x00000568, 0x00000510, 0x00000548, + 0x00000538, 0x00000550, 0x00000530, 0x00000500, + 0x00000540, 0x00000560, 0x00000520, 0x00000528, + 0x00000578, 0x00000518, 0x00000558, 0x00000570, + 0x00000788, 0x000007e8, 0x00000790, 0x000007c8, + 0x000007b8, 0x000007d0, 0x000007b0, 0x00000780, + 0x000007c0, 0x000007e0, 0x000007a0, 0x000007a8, + 0x000007f8, 0x00000798, 0x000007d8, 0x000007f0, + 0x00000288, 0x000002e8, 0x00000290, 0x000002c8, + 0x000002b8, 0x000002d0, 0x000002b0, 0x00000280, + 0x000002c0, 0x000002e0, 0x000002a0, 0x000002a8, + 0x000002f8, 0x00000298, 0x000002d8, 0x000002f0, + 0x00000008, 0x00000068, 0x00000010, 0x00000048, + 0x00000038, 0x00000050, 0x00000030, 0x00000000, + 0x00000040, 0x00000060, 0x00000020, 0x00000028, + 0x00000078, 0x00000018, 0x00000058, 0x00000070, + 0x00000608, 0x00000668, 0x00000610, 0x00000648, + 0x00000638, 0x00000650, 0x00000630, 0x00000600, + 0x00000640, 0x00000660, 0x00000620, 0x00000628, + 0x00000678, 0x00000618, 0x00000658, 0x00000670, + 0x00000708, 0x00000768, 0x00000710, 0x00000748, + 0x00000738, 0x00000750, 0x00000730, 0x00000700, + 0x00000740, 0x00000760, 0x00000720, 0x00000728, + 0x00000778, 0x00000718, 0x00000758, 0x00000770, + 0x00000408, 0x00000468, 0x00000410, 0x00000448, + 0x00000438, 0x00000450, 0x00000430, 0x00000400, + 0x00000440, 0x00000460, 0x00000420, 0x00000428, + 0x00000478, 0x00000418, 0x00000458, 0x00000470, + 0x00000308, 0x00000368, 0x00000310, 0x00000348, + 0x00000338, 0x00000350, 0x00000330, 0x00000300, + 0x00000340, 0x00000360, 0x00000320, 0x00000328, + 0x00000378, 0x00000318, 0x00000358, 0x00000370, + 0x00000108, 0x00000168, 0x00000110, 0x00000148, + 0x00000138, 0x00000150, 0x00000130, 0x00000100, + 0x00000140, 0x00000160, 0x00000120, 0x00000128, + 0x00000178, 0x00000118, 0x00000158, 0x00000170, + 0x00000188, 0x000001e8, 0x00000190, 0x000001c8, + 0x000001b8, 0x000001d0, 0x000001b0, 0x00000180, + 0x000001c0, 0x000001e0, 0x000001a0, 0x000001a8, + 0x000001f8, 0x00000198, 0x000001d8, 0x000001f0, + 0x00000488, 0x000004e8, 0x00000490, 0x000004c8, + 0x000004b8, 0x000004d0, 0x000004b0, 0x00000480, + 0x000004c0, 0x000004e0, 0x000004a0, 0x000004a8, + 0x000004f8, 0x00000498, 0x000004d8, 0x000004f0, + 0x00000088, 0x000000e8, 0x00000090, 0x000000c8, + 0x000000b8, 0x000000d0, 0x000000b0, 0x00000080, + 0x000000c0, 0x000000e0, 0x000000a0, 0x000000a8, + 0x000000f8, 0x00000098, 0x000000d8, 0x000000f0, + 0x00000388, 0x000003e8, 0x00000390, 0x000003c8, + 0x000003b8, 0x000003d0, 0x000003b0, 0x00000380, + 0x000003c0, 0x000003e0, 0x000003a0, 0x000003a8, + 0x000003f8, 0x00000398, 0x000003d8, 0x000003f0, + 0x00000688, 0x000006e8, 0x00000690, 0x000006c8, + 0x000006b8, 0x000006d0, 0x000006b0, 0x00000680, + 0x000006c0, 0x000006e0, 0x000006a0, 0x000006a8, + 0x000006f8, 0x00000698, 0x000006d8, 0x000006f0, + 0x00000208, 0x00000268, 0x00000210, 0x00000248, + 0x00000238, 0x00000250, 0x00000230, 0x00000200, + 0x00000240, 0x00000260, 0x00000220, 0x00000228, + 0x00000278, 0x00000218, 0x00000258, 0x00000270, + } + } +}; + +const struct gost28147_param gost28147_param_CryptoPro_B = +{ + { + { /* 0 */ + 0x00004000, 0x00002000, 0x00005800, 0x00000800, + 0x00001800, 0x00002800, 0x00000000, 0x00004800, + 0x00001000, 0x00007000, 0x00005000, 0x00006000, + 0x00006800, 0x00003000, 0x00003800, 0x00007800, + 0x0000c000, 0x0000a000, 0x0000d800, 0x00008800, + 0x00009800, 0x0000a800, 0x00008000, 0x0000c800, + 0x00009000, 0x0000f000, 0x0000d000, 0x0000e000, + 0x0000e800, 0x0000b000, 0x0000b800, 0x0000f800, + 0x00014000, 0x00012000, 0x00015800, 0x00010800, + 0x00011800, 0x00012800, 0x00010000, 0x00014800, + 0x00011000, 0x00017000, 0x00015000, 0x00016000, + 0x00016800, 0x00013000, 0x00013800, 0x00017800, + 0x00054000, 0x00052000, 0x00055800, 0x00050800, + 0x00051800, 0x00052800, 0x00050000, 0x00054800, + 0x00051000, 0x00057000, 0x00055000, 0x00056000, + 0x00056800, 0x00053000, 0x00053800, 0x00057800, + 0x00024000, 0x00022000, 0x00025800, 0x00020800, + 0x00021800, 0x00022800, 0x00020000, 0x00024800, + 0x00021000, 0x00027000, 0x00025000, 0x00026000, + 0x00026800, 0x00023000, 0x00023800, 0x00027800, + 0x0006c000, 0x0006a000, 0x0006d800, 0x00068800, + 0x00069800, 0x0006a800, 0x00068000, 0x0006c800, + 0x00069000, 0x0006f000, 0x0006d000, 0x0006e000, + 0x0006e800, 0x0006b000, 0x0006b800, 0x0006f800, + 0x0002c000, 0x0002a000, 0x0002d800, 0x00028800, + 0x00029800, 0x0002a800, 0x00028000, 0x0002c800, + 0x00029000, 0x0002f000, 0x0002d000, 0x0002e000, + 0x0002e800, 0x0002b000, 0x0002b800, 0x0002f800, + 0x00064000, 0x00062000, 0x00065800, 0x00060800, + 0x00061800, 0x00062800, 0x00060000, 0x00064800, + 0x00061000, 0x00067000, 0x00065000, 0x00066000, + 0x00066800, 0x00063000, 0x00063800, 0x00067800, + 0x0004c000, 0x0004a000, 0x0004d800, 0x00048800, + 0x00049800, 0x0004a800, 0x00048000, 0x0004c800, + 0x00049000, 0x0004f000, 0x0004d000, 0x0004e000, + 0x0004e800, 0x0004b000, 0x0004b800, 0x0004f800, + 0x0003c000, 0x0003a000, 0x0003d800, 0x00038800, + 0x00039800, 0x0003a800, 0x00038000, 0x0003c800, + 0x00039000, 0x0003f000, 0x0003d000, 0x0003e000, + 0x0003e800, 0x0003b000, 0x0003b800, 0x0003f800, + 0x0001c000, 0x0001a000, 0x0001d800, 0x00018800, + 0x00019800, 0x0001a800, 0x00018000, 0x0001c800, + 0x00019000, 0x0001f000, 0x0001d000, 0x0001e000, + 0x0001e800, 0x0001b000, 0x0001b800, 0x0001f800, + 0x0007c000, 0x0007a000, 0x0007d800, 0x00078800, + 0x00079800, 0x0007a800, 0x00078000, 0x0007c800, + 0x00079000, 0x0007f000, 0x0007d000, 0x0007e000, + 0x0007e800, 0x0007b000, 0x0007b800, 0x0007f800, + 0x0005c000, 0x0005a000, 0x0005d800, 0x00058800, + 0x00059800, 0x0005a800, 0x00058000, 0x0005c800, + 0x00059000, 0x0005f000, 0x0005d000, 0x0005e000, + 0x0005e800, 0x0005b000, 0x0005b800, 0x0005f800, + 0x00044000, 0x00042000, 0x00045800, 0x00040800, + 0x00041800, 0x00042800, 0x00040000, 0x00044800, + 0x00041000, 0x00047000, 0x00045000, 0x00046000, + 0x00046800, 0x00043000, 0x00043800, 0x00047800, + 0x00034000, 0x00032000, 0x00035800, 0x00030800, + 0x00031800, 0x00032800, 0x00030000, 0x00034800, + 0x00031000, 0x00037000, 0x00035000, 0x00036000, + 0x00036800, 0x00033000, 0x00033800, 0x00037800, + 0x00074000, 0x00072000, 0x00075800, 0x00070800, + 0x00071800, 0x00072800, 0x00070000, 0x00074800, + 0x00071000, 0x00077000, 0x00075000, 0x00076000, + 0x00076800, 0x00073000, 0x00073800, 0x00077800, + }, { /* 1 */ + 0x03f00000, 0x03e00000, 0x03800000, 0x03d00000, + 0x03c80000, 0x03900000, 0x03e80000, 0x03d80000, + 0x03b80000, 0x03a80000, 0x03c00000, 0x03f80000, + 0x03980000, 0x03b00000, 0x03880000, 0x03a00000, + 0x02f00000, 0x02e00000, 0x02800000, 0x02d00000, + 0x02c80000, 0x02900000, 0x02e80000, 0x02d80000, + 0x02b80000, 0x02a80000, 0x02c00000, 0x02f80000, + 0x02980000, 0x02b00000, 0x02880000, 0x02a00000, + 0x00700000, 0x00600000, 0x00000000, 0x00500000, + 0x00480000, 0x00100000, 0x00680000, 0x00580000, + 0x00380000, 0x00280000, 0x00400000, 0x00780000, + 0x00180000, 0x00300000, 0x00080000, 0x00200000, + 0x06f00000, 0x06e00000, 0x06800000, 0x06d00000, + 0x06c80000, 0x06900000, 0x06e80000, 0x06d80000, + 0x06b80000, 0x06a80000, 0x06c00000, 0x06f80000, + 0x06980000, 0x06b00000, 0x06880000, 0x06a00000, + 0x05f00000, 0x05e00000, 0x05800000, 0x05d00000, + 0x05c80000, 0x05900000, 0x05e80000, 0x05d80000, + 0x05b80000, 0x05a80000, 0x05c00000, 0x05f80000, + 0x05980000, 0x05b00000, 0x05880000, 0x05a00000, + 0x03700000, 0x03600000, 0x03000000, 0x03500000, + 0x03480000, 0x03100000, 0x03680000, 0x03580000, + 0x03380000, 0x03280000, 0x03400000, 0x03780000, + 0x03180000, 0x03300000, 0x03080000, 0x03200000, + 0x00f00000, 0x00e00000, 0x00800000, 0x00d00000, + 0x00c80000, 0x00900000, 0x00e80000, 0x00d80000, + 0x00b80000, 0x00a80000, 0x00c00000, 0x00f80000, + 0x00980000, 0x00b00000, 0x00880000, 0x00a00000, + 0x01700000, 0x01600000, 0x01000000, 0x01500000, + 0x01480000, 0x01100000, 0x01680000, 0x01580000, + 0x01380000, 0x01280000, 0x01400000, 0x01780000, + 0x01180000, 0x01300000, 0x01080000, 0x01200000, + 0x01f00000, 0x01e00000, 0x01800000, 0x01d00000, + 0x01c80000, 0x01900000, 0x01e80000, 0x01d80000, + 0x01b80000, 0x01a80000, 0x01c00000, 0x01f80000, + 0x01980000, 0x01b00000, 0x01880000, 0x01a00000, + 0x05700000, 0x05600000, 0x05000000, 0x05500000, + 0x05480000, 0x05100000, 0x05680000, 0x05580000, + 0x05380000, 0x05280000, 0x05400000, 0x05780000, + 0x05180000, 0x05300000, 0x05080000, 0x05200000, + 0x06700000, 0x06600000, 0x06000000, 0x06500000, + 0x06480000, 0x06100000, 0x06680000, 0x06580000, + 0x06380000, 0x06280000, 0x06400000, 0x06780000, + 0x06180000, 0x06300000, 0x06080000, 0x06200000, + 0x07f00000, 0x07e00000, 0x07800000, 0x07d00000, + 0x07c80000, 0x07900000, 0x07e80000, 0x07d80000, + 0x07b80000, 0x07a80000, 0x07c00000, 0x07f80000, + 0x07980000, 0x07b00000, 0x07880000, 0x07a00000, + 0x02700000, 0x02600000, 0x02000000, 0x02500000, + 0x02480000, 0x02100000, 0x02680000, 0x02580000, + 0x02380000, 0x02280000, 0x02400000, 0x02780000, + 0x02180000, 0x02300000, 0x02080000, 0x02200000, + 0x07700000, 0x07600000, 0x07000000, 0x07500000, + 0x07480000, 0x07100000, 0x07680000, 0x07580000, + 0x07380000, 0x07280000, 0x07400000, 0x07780000, + 0x07180000, 0x07300000, 0x07080000, 0x07200000, + 0x04f00000, 0x04e00000, 0x04800000, 0x04d00000, + 0x04c80000, 0x04900000, 0x04e80000, 0x04d80000, + 0x04b80000, 0x04a80000, 0x04c00000, 0x04f80000, + 0x04980000, 0x04b00000, 0x04880000, 0x04a00000, + 0x04700000, 0x04600000, 0x04000000, 0x04500000, + 0x04480000, 0x04100000, 0x04680000, 0x04580000, + 0x04380000, 0x04280000, 0x04400000, 0x04780000, + 0x04180000, 0x04300000, 0x04080000, 0x04200000, + }, { /* 2 */ + 0x10000004, 0x38000004, 0x60000004, 0x78000004, + 0x48000004, 0x28000004, 0x50000004, 0x58000004, + 0x08000004, 0x20000004, 0x00000004, 0x68000004, + 0x30000004, 0x40000004, 0x70000004, 0x18000004, + 0x90000001, 0xb8000001, 0xe0000001, 0xf8000001, + 0xc8000001, 0xa8000001, 0xd0000001, 0xd8000001, + 0x88000001, 0xa0000001, 0x80000001, 0xe8000001, + 0xb0000001, 0xc0000001, 0xf0000001, 0x98000001, + 0x10000001, 0x38000001, 0x60000001, 0x78000001, + 0x48000001, 0x28000001, 0x50000001, 0x58000001, + 0x08000001, 0x20000001, 0x00000001, 0x68000001, + 0x30000001, 0x40000001, 0x70000001, 0x18000001, + 0x10000003, 0x38000003, 0x60000003, 0x78000003, + 0x48000003, 0x28000003, 0x50000003, 0x58000003, + 0x08000003, 0x20000003, 0x00000003, 0x68000003, + 0x30000003, 0x40000003, 0x70000003, 0x18000003, + 0x10000002, 0x38000002, 0x60000002, 0x78000002, + 0x48000002, 0x28000002, 0x50000002, 0x58000002, + 0x08000002, 0x20000002, 0x00000002, 0x68000002, + 0x30000002, 0x40000002, 0x70000002, 0x18000002, + 0x90000006, 0xb8000006, 0xe0000006, 0xf8000006, + 0xc8000006, 0xa8000006, 0xd0000006, 0xd8000006, + 0x88000006, 0xa0000006, 0x80000006, 0xe8000006, + 0xb0000006, 0xc0000006, 0xf0000006, 0x98000006, + 0x10000007, 0x38000007, 0x60000007, 0x78000007, + 0x48000007, 0x28000007, 0x50000007, 0x58000007, + 0x08000007, 0x20000007, 0x00000007, 0x68000007, + 0x30000007, 0x40000007, 0x70000007, 0x18000007, + 0x90000005, 0xb8000005, 0xe0000005, 0xf8000005, + 0xc8000005, 0xa8000005, 0xd0000005, 0xd8000005, + 0x88000005, 0xa0000005, 0x80000005, 0xe8000005, + 0xb0000005, 0xc0000005, 0xf0000005, 0x98000005, + 0x10000006, 0x38000006, 0x60000006, 0x78000006, + 0x48000006, 0x28000006, 0x50000006, 0x58000006, + 0x08000006, 0x20000006, 0x00000006, 0x68000006, + 0x30000006, 0x40000006, 0x70000006, 0x18000006, + 0x90000000, 0xb8000000, 0xe0000000, 0xf8000000, + 0xc8000000, 0xa8000000, 0xd0000000, 0xd8000000, + 0x88000000, 0xa0000000, 0x80000000, 0xe8000000, + 0xb0000000, 0xc0000000, 0xf0000000, 0x98000000, + 0x90000003, 0xb8000003, 0xe0000003, 0xf8000003, + 0xc8000003, 0xa8000003, 0xd0000003, 0xd8000003, + 0x88000003, 0xa0000003, 0x80000003, 0xe8000003, + 0xb0000003, 0xc0000003, 0xf0000003, 0x98000003, + 0x90000007, 0xb8000007, 0xe0000007, 0xf8000007, + 0xc8000007, 0xa8000007, 0xd0000007, 0xd8000007, + 0x88000007, 0xa0000007, 0x80000007, 0xe8000007, + 0xb0000007, 0xc0000007, 0xf0000007, 0x98000007, + 0x10000005, 0x38000005, 0x60000005, 0x78000005, + 0x48000005, 0x28000005, 0x50000005, 0x58000005, + 0x08000005, 0x20000005, 0x00000005, 0x68000005, + 0x30000005, 0x40000005, 0x70000005, 0x18000005, + 0x10000000, 0x38000000, 0x60000000, 0x78000000, + 0x48000000, 0x28000000, 0x50000000, 0x58000000, + 0x08000000, 0x20000000, 0x00000000, 0x68000000, + 0x30000000, 0x40000000, 0x70000000, 0x18000000, + 0x90000004, 0xb8000004, 0xe0000004, 0xf8000004, + 0xc8000004, 0xa8000004, 0xd0000004, 0xd8000004, + 0x88000004, 0xa0000004, 0x80000004, 0xe8000004, + 0xb0000004, 0xc0000004, 0xf0000004, 0x98000004, + 0x90000002, 0xb8000002, 0xe0000002, 0xf8000002, + 0xc8000002, 0xa8000002, 0xd0000002, 0xd8000002, + 0x88000002, 0xa0000002, 0x80000002, 0xe8000002, + 0xb0000002, 0xc0000002, 0xf0000002, 0x98000002, + }, { /* 3 */ + 0x00000028, 0x00000010, 0x00000050, 0x00000058, + 0x00000048, 0x00000008, 0x00000060, 0x00000018, + 0x00000038, 0x00000020, 0x00000068, 0x00000000, + 0x00000030, 0x00000078, 0x00000040, 0x00000070, + 0x00000228, 0x00000210, 0x00000250, 0x00000258, + 0x00000248, 0x00000208, 0x00000260, 0x00000218, + 0x00000238, 0x00000220, 0x00000268, 0x00000200, + 0x00000230, 0x00000278, 0x00000240, 0x00000270, + 0x000005a8, 0x00000590, 0x000005d0, 0x000005d8, + 0x000005c8, 0x00000588, 0x000005e0, 0x00000598, + 0x000005b8, 0x000005a0, 0x000005e8, 0x00000580, + 0x000005b0, 0x000005f8, 0x000005c0, 0x000005f0, + 0x00000728, 0x00000710, 0x00000750, 0x00000758, + 0x00000748, 0x00000708, 0x00000760, 0x00000718, + 0x00000738, 0x00000720, 0x00000768, 0x00000700, + 0x00000730, 0x00000778, 0x00000740, 0x00000770, + 0x00000428, 0x00000410, 0x00000450, 0x00000458, + 0x00000448, 0x00000408, 0x00000460, 0x00000418, + 0x00000438, 0x00000420, 0x00000468, 0x00000400, + 0x00000430, 0x00000478, 0x00000440, 0x00000470, + 0x000001a8, 0x00000190, 0x000001d0, 0x000001d8, + 0x000001c8, 0x00000188, 0x000001e0, 0x00000198, + 0x000001b8, 0x000001a0, 0x000001e8, 0x00000180, + 0x000001b0, 0x000001f8, 0x000001c0, 0x000001f0, + 0x000003a8, 0x00000390, 0x000003d0, 0x000003d8, + 0x000003c8, 0x00000388, 0x000003e0, 0x00000398, + 0x000003b8, 0x000003a0, 0x000003e8, 0x00000380, + 0x000003b0, 0x000003f8, 0x000003c0, 0x000003f0, + 0x000000a8, 0x00000090, 0x000000d0, 0x000000d8, + 0x000000c8, 0x00000088, 0x000000e0, 0x00000098, + 0x000000b8, 0x000000a0, 0x000000e8, 0x00000080, + 0x000000b0, 0x000000f8, 0x000000c0, 0x000000f0, + 0x00000528, 0x00000510, 0x00000550, 0x00000558, + 0x00000548, 0x00000508, 0x00000560, 0x00000518, + 0x00000538, 0x00000520, 0x00000568, 0x00000500, + 0x00000530, 0x00000578, 0x00000540, 0x00000570, + 0x00000128, 0x00000110, 0x00000150, 0x00000158, + 0x00000148, 0x00000108, 0x00000160, 0x00000118, + 0x00000138, 0x00000120, 0x00000168, 0x00000100, + 0x00000130, 0x00000178, 0x00000140, 0x00000170, + 0x000004a8, 0x00000490, 0x000004d0, 0x000004d8, + 0x000004c8, 0x00000488, 0x000004e0, 0x00000498, + 0x000004b8, 0x000004a0, 0x000004e8, 0x00000480, + 0x000004b0, 0x000004f8, 0x000004c0, 0x000004f0, + 0x00000328, 0x00000310, 0x00000350, 0x00000358, + 0x00000348, 0x00000308, 0x00000360, 0x00000318, + 0x00000338, 0x00000320, 0x00000368, 0x00000300, + 0x00000330, 0x00000378, 0x00000340, 0x00000370, + 0x000007a8, 0x00000790, 0x000007d0, 0x000007d8, + 0x000007c8, 0x00000788, 0x000007e0, 0x00000798, + 0x000007b8, 0x000007a0, 0x000007e8, 0x00000780, + 0x000007b0, 0x000007f8, 0x000007c0, 0x000007f0, + 0x000006a8, 0x00000690, 0x000006d0, 0x000006d8, + 0x000006c8, 0x00000688, 0x000006e0, 0x00000698, + 0x000006b8, 0x000006a0, 0x000006e8, 0x00000680, + 0x000006b0, 0x000006f8, 0x000006c0, 0x000006f0, + 0x000002a8, 0x00000290, 0x000002d0, 0x000002d8, + 0x000002c8, 0x00000288, 0x000002e0, 0x00000298, + 0x000002b8, 0x000002a0, 0x000002e8, 0x00000280, + 0x000002b0, 0x000002f8, 0x000002c0, 0x000002f0, + 0x00000628, 0x00000610, 0x00000650, 0x00000658, + 0x00000648, 0x00000608, 0x00000660, 0x00000618, + 0x00000638, 0x00000620, 0x00000668, 0x00000600, + 0x00000630, 0x00000678, 0x00000640, 0x00000670, + } + } +}; + +const struct gost28147_param gost28147_param_CryptoPro_C = +{ + { + { /* 0 */ + 0x00000800, 0x00005800, 0x00006000, 0x00001000, + 0x00004800, 0x00006800, 0x00000000, 0x00007800, + 0x00002000, 0x00002800, 0x00004000, 0x00007000, + 0x00005000, 0x00003800, 0x00003000, 0x00001800, + 0x00008800, 0x0000d800, 0x0000e000, 0x00009000, + 0x0000c800, 0x0000e800, 0x00008000, 0x0000f800, + 0x0000a000, 0x0000a800, 0x0000c000, 0x0000f000, + 0x0000d000, 0x0000b800, 0x0000b000, 0x00009800, + 0x00038800, 0x0003d800, 0x0003e000, 0x00039000, + 0x0003c800, 0x0003e800, 0x00038000, 0x0003f800, + 0x0003a000, 0x0003a800, 0x0003c000, 0x0003f000, + 0x0003d000, 0x0003b800, 0x0003b000, 0x00039800, + 0x00068800, 0x0006d800, 0x0006e000, 0x00069000, + 0x0006c800, 0x0006e800, 0x00068000, 0x0006f800, + 0x0006a000, 0x0006a800, 0x0006c000, 0x0006f000, + 0x0006d000, 0x0006b800, 0x0006b000, 0x00069800, + 0x00058800, 0x0005d800, 0x0005e000, 0x00059000, + 0x0005c800, 0x0005e800, 0x00058000, 0x0005f800, + 0x0005a000, 0x0005a800, 0x0005c000, 0x0005f000, + 0x0005d000, 0x0005b800, 0x0005b000, 0x00059800, + 0x00020800, 0x00025800, 0x00026000, 0x00021000, + 0x00024800, 0x00026800, 0x00020000, 0x00027800, + 0x00022000, 0x00022800, 0x00024000, 0x00027000, + 0x00025000, 0x00023800, 0x00023000, 0x00021800, + 0x00028800, 0x0002d800, 0x0002e000, 0x00029000, + 0x0002c800, 0x0002e800, 0x00028000, 0x0002f800, + 0x0002a000, 0x0002a800, 0x0002c000, 0x0002f000, + 0x0002d000, 0x0002b800, 0x0002b000, 0x00029800, + 0x00010800, 0x00015800, 0x00016000, 0x00011000, + 0x00014800, 0x00016800, 0x00010000, 0x00017800, + 0x00012000, 0x00012800, 0x00014000, 0x00017000, + 0x00015000, 0x00013800, 0x00013000, 0x00011800, + 0x00040800, 0x00045800, 0x00046000, 0x00041000, + 0x00044800, 0x00046800, 0x00040000, 0x00047800, + 0x00042000, 0x00042800, 0x00044000, 0x00047000, + 0x00045000, 0x00043800, 0x00043000, 0x00041800, + 0x00070800, 0x00075800, 0x00076000, 0x00071000, + 0x00074800, 0x00076800, 0x00070000, 0x00077800, + 0x00072000, 0x00072800, 0x00074000, 0x00077000, + 0x00075000, 0x00073800, 0x00073000, 0x00071800, + 0x00078800, 0x0007d800, 0x0007e000, 0x00079000, + 0x0007c800, 0x0007e800, 0x00078000, 0x0007f800, + 0x0007a000, 0x0007a800, 0x0007c000, 0x0007f000, + 0x0007d000, 0x0007b800, 0x0007b000, 0x00079800, + 0x00060800, 0x00065800, 0x00066000, 0x00061000, + 0x00064800, 0x00066800, 0x00060000, 0x00067800, + 0x00062000, 0x00062800, 0x00064000, 0x00067000, + 0x00065000, 0x00063800, 0x00063000, 0x00061800, + 0x00048800, 0x0004d800, 0x0004e000, 0x00049000, + 0x0004c800, 0x0004e800, 0x00048000, 0x0004f800, + 0x0004a000, 0x0004a800, 0x0004c000, 0x0004f000, + 0x0004d000, 0x0004b800, 0x0004b000, 0x00049800, + 0x00050800, 0x00055800, 0x00056000, 0x00051000, + 0x00054800, 0x00056800, 0x00050000, 0x00057800, + 0x00052000, 0x00052800, 0x00054000, 0x00057000, + 0x00055000, 0x00053800, 0x00053000, 0x00051800, + 0x00030800, 0x00035800, 0x00036000, 0x00031000, + 0x00034800, 0x00036800, 0x00030000, 0x00037800, + 0x00032000, 0x00032800, 0x00034000, 0x00037000, + 0x00035000, 0x00033800, 0x00033000, 0x00031800, + 0x00018800, 0x0001d800, 0x0001e000, 0x00019000, + 0x0001c800, 0x0001e800, 0x00018000, 0x0001f800, + 0x0001a000, 0x0001a800, 0x0001c000, 0x0001f000, + 0x0001d000, 0x0001b800, 0x0001b000, 0x00019800, + }, { /* 1 */ + 0x01c00000, 0x01900000, 0x01a80000, 0x01800000, + 0x01a00000, 0x01c80000, 0x01f80000, 0x01d00000, + 0x01980000, 0x01b80000, 0x01e00000, 0x01e80000, + 0x01b00000, 0x01f00000, 0x01880000, 0x01d80000, + 0x03400000, 0x03100000, 0x03280000, 0x03000000, + 0x03200000, 0x03480000, 0x03780000, 0x03500000, + 0x03180000, 0x03380000, 0x03600000, 0x03680000, + 0x03300000, 0x03700000, 0x03080000, 0x03580000, + 0x00400000, 0x00100000, 0x00280000, 0x00000000, + 0x00200000, 0x00480000, 0x00780000, 0x00500000, + 0x00180000, 0x00380000, 0x00600000, 0x00680000, + 0x00300000, 0x00700000, 0x00080000, 0x00580000, + 0x00c00000, 0x00900000, 0x00a80000, 0x00800000, + 0x00a00000, 0x00c80000, 0x00f80000, 0x00d00000, + 0x00980000, 0x00b80000, 0x00e00000, 0x00e80000, + 0x00b00000, 0x00f00000, 0x00880000, 0x00d80000, + 0x02c00000, 0x02900000, 0x02a80000, 0x02800000, + 0x02a00000, 0x02c80000, 0x02f80000, 0x02d00000, + 0x02980000, 0x02b80000, 0x02e00000, 0x02e80000, + 0x02b00000, 0x02f00000, 0x02880000, 0x02d80000, + 0x06c00000, 0x06900000, 0x06a80000, 0x06800000, + 0x06a00000, 0x06c80000, 0x06f80000, 0x06d00000, + 0x06980000, 0x06b80000, 0x06e00000, 0x06e80000, + 0x06b00000, 0x06f00000, 0x06880000, 0x06d80000, + 0x05400000, 0x05100000, 0x05280000, 0x05000000, + 0x05200000, 0x05480000, 0x05780000, 0x05500000, + 0x05180000, 0x05380000, 0x05600000, 0x05680000, + 0x05300000, 0x05700000, 0x05080000, 0x05580000, + 0x04400000, 0x04100000, 0x04280000, 0x04000000, + 0x04200000, 0x04480000, 0x04780000, 0x04500000, + 0x04180000, 0x04380000, 0x04600000, 0x04680000, + 0x04300000, 0x04700000, 0x04080000, 0x04580000, + 0x05c00000, 0x05900000, 0x05a80000, 0x05800000, + 0x05a00000, 0x05c80000, 0x05f80000, 0x05d00000, + 0x05980000, 0x05b80000, 0x05e00000, 0x05e80000, + 0x05b00000, 0x05f00000, 0x05880000, 0x05d80000, + 0x01400000, 0x01100000, 0x01280000, 0x01000000, + 0x01200000, 0x01480000, 0x01780000, 0x01500000, + 0x01180000, 0x01380000, 0x01600000, 0x01680000, + 0x01300000, 0x01700000, 0x01080000, 0x01580000, + 0x04c00000, 0x04900000, 0x04a80000, 0x04800000, + 0x04a00000, 0x04c80000, 0x04f80000, 0x04d00000, + 0x04980000, 0x04b80000, 0x04e00000, 0x04e80000, + 0x04b00000, 0x04f00000, 0x04880000, 0x04d80000, + 0x03c00000, 0x03900000, 0x03a80000, 0x03800000, + 0x03a00000, 0x03c80000, 0x03f80000, 0x03d00000, + 0x03980000, 0x03b80000, 0x03e00000, 0x03e80000, + 0x03b00000, 0x03f00000, 0x03880000, 0x03d80000, + 0x07400000, 0x07100000, 0x07280000, 0x07000000, + 0x07200000, 0x07480000, 0x07780000, 0x07500000, + 0x07180000, 0x07380000, 0x07600000, 0x07680000, + 0x07300000, 0x07700000, 0x07080000, 0x07580000, + 0x07c00000, 0x07900000, 0x07a80000, 0x07800000, + 0x07a00000, 0x07c80000, 0x07f80000, 0x07d00000, + 0x07980000, 0x07b80000, 0x07e00000, 0x07e80000, + 0x07b00000, 0x07f00000, 0x07880000, 0x07d80000, + 0x06400000, 0x06100000, 0x06280000, 0x06000000, + 0x06200000, 0x06480000, 0x06780000, 0x06500000, + 0x06180000, 0x06380000, 0x06600000, 0x06680000, + 0x06300000, 0x06700000, 0x06080000, 0x06580000, + 0x02400000, 0x02100000, 0x02280000, 0x02000000, + 0x02200000, 0x02480000, 0x02780000, 0x02500000, + 0x02180000, 0x02380000, 0x02600000, 0x02680000, + 0x02300000, 0x02700000, 0x02080000, 0x02580000, + }, { /* 2 */ + 0x40000006, 0x68000006, 0x58000006, 0x00000006, + 0x20000006, 0x28000006, 0x08000006, 0x10000006, + 0x48000006, 0x18000006, 0x60000006, 0x70000006, + 0x30000006, 0x78000006, 0x50000006, 0x38000006, + 0xc0000004, 0xe8000004, 0xd8000004, 0x80000004, + 0xa0000004, 0xa8000004, 0x88000004, 0x90000004, + 0xc8000004, 0x98000004, 0xe0000004, 0xf0000004, + 0xb0000004, 0xf8000004, 0xd0000004, 0xb8000004, + 0xc0000005, 0xe8000005, 0xd8000005, 0x80000005, + 0xa0000005, 0xa8000005, 0x88000005, 0x90000005, + 0xc8000005, 0x98000005, 0xe0000005, 0xf0000005, + 0xb0000005, 0xf8000005, 0xd0000005, 0xb8000005, + 0xc0000000, 0xe8000000, 0xd8000000, 0x80000000, + 0xa0000000, 0xa8000000, 0x88000000, 0x90000000, + 0xc8000000, 0x98000000, 0xe0000000, 0xf0000000, + 0xb0000000, 0xf8000000, 0xd0000000, 0xb8000000, + 0x40000004, 0x68000004, 0x58000004, 0x00000004, + 0x20000004, 0x28000004, 0x08000004, 0x10000004, + 0x48000004, 0x18000004, 0x60000004, 0x70000004, + 0x30000004, 0x78000004, 0x50000004, 0x38000004, + 0x40000007, 0x68000007, 0x58000007, 0x00000007, + 0x20000007, 0x28000007, 0x08000007, 0x10000007, + 0x48000007, 0x18000007, 0x60000007, 0x70000007, + 0x30000007, 0x78000007, 0x50000007, 0x38000007, + 0x40000001, 0x68000001, 0x58000001, 0x00000001, + 0x20000001, 0x28000001, 0x08000001, 0x10000001, + 0x48000001, 0x18000001, 0x60000001, 0x70000001, + 0x30000001, 0x78000001, 0x50000001, 0x38000001, + 0x40000002, 0x68000002, 0x58000002, 0x00000002, + 0x20000002, 0x28000002, 0x08000002, 0x10000002, + 0x48000002, 0x18000002, 0x60000002, 0x70000002, + 0x30000002, 0x78000002, 0x50000002, 0x38000002, + 0xc0000003, 0xe8000003, 0xd8000003, 0x80000003, + 0xa0000003, 0xa8000003, 0x88000003, 0x90000003, + 0xc8000003, 0x98000003, 0xe0000003, 0xf0000003, + 0xb0000003, 0xf8000003, 0xd0000003, 0xb8000003, + 0xc0000001, 0xe8000001, 0xd8000001, 0x80000001, + 0xa0000001, 0xa8000001, 0x88000001, 0x90000001, + 0xc8000001, 0x98000001, 0xe0000001, 0xf0000001, + 0xb0000001, 0xf8000001, 0xd0000001, 0xb8000001, + 0x40000003, 0x68000003, 0x58000003, 0x00000003, + 0x20000003, 0x28000003, 0x08000003, 0x10000003, + 0x48000003, 0x18000003, 0x60000003, 0x70000003, + 0x30000003, 0x78000003, 0x50000003, 0x38000003, + 0xc0000002, 0xe8000002, 0xd8000002, 0x80000002, + 0xa0000002, 0xa8000002, 0x88000002, 0x90000002, + 0xc8000002, 0x98000002, 0xe0000002, 0xf0000002, + 0xb0000002, 0xf8000002, 0xd0000002, 0xb8000002, + 0x40000005, 0x68000005, 0x58000005, 0x00000005, + 0x20000005, 0x28000005, 0x08000005, 0x10000005, + 0x48000005, 0x18000005, 0x60000005, 0x70000005, + 0x30000005, 0x78000005, 0x50000005, 0x38000005, + 0x40000000, 0x68000000, 0x58000000, 0x00000000, + 0x20000000, 0x28000000, 0x08000000, 0x10000000, + 0x48000000, 0x18000000, 0x60000000, 0x70000000, + 0x30000000, 0x78000000, 0x50000000, 0x38000000, + 0xc0000007, 0xe8000007, 0xd8000007, 0x80000007, + 0xa0000007, 0xa8000007, 0x88000007, 0x90000007, + 0xc8000007, 0x98000007, 0xe0000007, 0xf0000007, + 0xb0000007, 0xf8000007, 0xd0000007, 0xb8000007, + 0xc0000006, 0xe8000006, 0xd8000006, 0x80000006, + 0xa0000006, 0xa8000006, 0x88000006, 0x90000006, + 0xc8000006, 0x98000006, 0xe0000006, 0xf0000006, + 0xb0000006, 0xf8000006, 0xd0000006, 0xb8000006, + }, { /* 3 */ + 0x000003d0, 0x000003c8, 0x000003b0, 0x000003c0, + 0x000003e8, 0x000003f0, 0x00000390, 0x00000380, + 0x000003f8, 0x00000398, 0x000003a8, 0x000003d8, + 0x000003a0, 0x00000388, 0x000003e0, 0x000003b8, + 0x00000250, 0x00000248, 0x00000230, 0x00000240, + 0x00000268, 0x00000270, 0x00000210, 0x00000200, + 0x00000278, 0x00000218, 0x00000228, 0x00000258, + 0x00000220, 0x00000208, 0x00000260, 0x00000238, + 0x00000050, 0x00000048, 0x00000030, 0x00000040, + 0x00000068, 0x00000070, 0x00000010, 0x00000000, + 0x00000078, 0x00000018, 0x00000028, 0x00000058, + 0x00000020, 0x00000008, 0x00000060, 0x00000038, + 0x000002d0, 0x000002c8, 0x000002b0, 0x000002c0, + 0x000002e8, 0x000002f0, 0x00000290, 0x00000280, + 0x000002f8, 0x00000298, 0x000002a8, 0x000002d8, + 0x000002a0, 0x00000288, 0x000002e0, 0x000002b8, + 0x00000550, 0x00000548, 0x00000530, 0x00000540, + 0x00000568, 0x00000570, 0x00000510, 0x00000500, + 0x00000578, 0x00000518, 0x00000528, 0x00000558, + 0x00000520, 0x00000508, 0x00000560, 0x00000538, + 0x00000150, 0x00000148, 0x00000130, 0x00000140, + 0x00000168, 0x00000170, 0x00000110, 0x00000100, + 0x00000178, 0x00000118, 0x00000128, 0x00000158, + 0x00000120, 0x00000108, 0x00000160, 0x00000138, + 0x000007d0, 0x000007c8, 0x000007b0, 0x000007c0, + 0x000007e8, 0x000007f0, 0x00000790, 0x00000780, + 0x000007f8, 0x00000798, 0x000007a8, 0x000007d8, + 0x000007a0, 0x00000788, 0x000007e0, 0x000007b8, + 0x00000750, 0x00000748, 0x00000730, 0x00000740, + 0x00000768, 0x00000770, 0x00000710, 0x00000700, + 0x00000778, 0x00000718, 0x00000728, 0x00000758, + 0x00000720, 0x00000708, 0x00000760, 0x00000738, + 0x00000650, 0x00000648, 0x00000630, 0x00000640, + 0x00000668, 0x00000670, 0x00000610, 0x00000600, + 0x00000678, 0x00000618, 0x00000628, 0x00000658, + 0x00000620, 0x00000608, 0x00000660, 0x00000638, + 0x00000350, 0x00000348, 0x00000330, 0x00000340, + 0x00000368, 0x00000370, 0x00000310, 0x00000300, + 0x00000378, 0x00000318, 0x00000328, 0x00000358, + 0x00000320, 0x00000308, 0x00000360, 0x00000338, + 0x000000d0, 0x000000c8, 0x000000b0, 0x000000c0, + 0x000000e8, 0x000000f0, 0x00000090, 0x00000080, + 0x000000f8, 0x00000098, 0x000000a8, 0x000000d8, + 0x000000a0, 0x00000088, 0x000000e0, 0x000000b8, + 0x000005d0, 0x000005c8, 0x000005b0, 0x000005c0, + 0x000005e8, 0x000005f0, 0x00000590, 0x00000580, + 0x000005f8, 0x00000598, 0x000005a8, 0x000005d8, + 0x000005a0, 0x00000588, 0x000005e0, 0x000005b8, + 0x000006d0, 0x000006c8, 0x000006b0, 0x000006c0, + 0x000006e8, 0x000006f0, 0x00000690, 0x00000680, + 0x000006f8, 0x00000698, 0x000006a8, 0x000006d8, + 0x000006a0, 0x00000688, 0x000006e0, 0x000006b8, + 0x000004d0, 0x000004c8, 0x000004b0, 0x000004c0, + 0x000004e8, 0x000004f0, 0x00000490, 0x00000480, + 0x000004f8, 0x00000498, 0x000004a8, 0x000004d8, + 0x000004a0, 0x00000488, 0x000004e0, 0x000004b8, + 0x000001d0, 0x000001c8, 0x000001b0, 0x000001c0, + 0x000001e8, 0x000001f0, 0x00000190, 0x00000180, + 0x000001f8, 0x00000198, 0x000001a8, 0x000001d8, + 0x000001a0, 0x00000188, 0x000001e0, 0x000001b8, + 0x00000450, 0x00000448, 0x00000430, 0x00000440, + 0x00000468, 0x00000470, 0x00000410, 0x00000400, + 0x00000478, 0x00000418, 0x00000428, 0x00000458, + 0x00000420, 0x00000408, 0x00000460, 0x00000438, + } + } +}; + +const struct gost28147_param gost28147_param_CryptoPro_D = +{ + { + { /* 0 */ + 0x0005f800, 0x0005e000, 0x00059000, 0x0005d000, + 0x0005b000, 0x0005a000, 0x0005a800, 0x00058000, + 0x0005b800, 0x0005c800, 0x0005f000, 0x0005e800, + 0x00058800, 0x0005d800, 0x0005c000, 0x00059800, + 0x00037800, 0x00036000, 0x00031000, 0x00035000, + 0x00033000, 0x00032000, 0x00032800, 0x00030000, + 0x00033800, 0x00034800, 0x00037000, 0x00036800, + 0x00030800, 0x00035800, 0x00034000, 0x00031800, + 0x0001f800, 0x0001e000, 0x00019000, 0x0001d000, + 0x0001b000, 0x0001a000, 0x0001a800, 0x00018000, + 0x0001b800, 0x0001c800, 0x0001f000, 0x0001e800, + 0x00018800, 0x0001d800, 0x0001c000, 0x00019800, + 0x00027800, 0x00026000, 0x00021000, 0x00025000, + 0x00023000, 0x00022000, 0x00022800, 0x00020000, + 0x00023800, 0x00024800, 0x00027000, 0x00026800, + 0x00020800, 0x00025800, 0x00024000, 0x00021800, + 0x00067800, 0x00066000, 0x00061000, 0x00065000, + 0x00063000, 0x00062000, 0x00062800, 0x00060000, + 0x00063800, 0x00064800, 0x00067000, 0x00066800, + 0x00060800, 0x00065800, 0x00064000, 0x00061800, + 0x0007f800, 0x0007e000, 0x00079000, 0x0007d000, + 0x0007b000, 0x0007a000, 0x0007a800, 0x00078000, + 0x0007b800, 0x0007c800, 0x0007f000, 0x0007e800, + 0x00078800, 0x0007d800, 0x0007c000, 0x00079800, + 0x00077800, 0x00076000, 0x00071000, 0x00075000, + 0x00073000, 0x00072000, 0x00072800, 0x00070000, + 0x00073800, 0x00074800, 0x00077000, 0x00076800, + 0x00070800, 0x00075800, 0x00074000, 0x00071800, + 0x00017800, 0x00016000, 0x00011000, 0x00015000, + 0x00013000, 0x00012000, 0x00012800, 0x00010000, + 0x00013800, 0x00014800, 0x00017000, 0x00016800, + 0x00010800, 0x00015800, 0x00014000, 0x00011800, + 0x0003f800, 0x0003e000, 0x00039000, 0x0003d000, + 0x0003b000, 0x0003a000, 0x0003a800, 0x00038000, + 0x0003b800, 0x0003c800, 0x0003f000, 0x0003e800, + 0x00038800, 0x0003d800, 0x0003c000, 0x00039800, + 0x0006f800, 0x0006e000, 0x00069000, 0x0006d000, + 0x0006b000, 0x0006a000, 0x0006a800, 0x00068000, + 0x0006b800, 0x0006c800, 0x0006f000, 0x0006e800, + 0x00068800, 0x0006d800, 0x0006c000, 0x00069800, + 0x00047800, 0x00046000, 0x00041000, 0x00045000, + 0x00043000, 0x00042000, 0x00042800, 0x00040000, + 0x00043800, 0x00044800, 0x00047000, 0x00046800, + 0x00040800, 0x00045800, 0x00044000, 0x00041800, + 0x00007800, 0x00006000, 0x00001000, 0x00005000, + 0x00003000, 0x00002000, 0x00002800, 0x00000000, + 0x00003800, 0x00004800, 0x00007000, 0x00006800, + 0x00000800, 0x00005800, 0x00004000, 0x00001800, + 0x0002f800, 0x0002e000, 0x00029000, 0x0002d000, + 0x0002b000, 0x0002a000, 0x0002a800, 0x00028000, + 0x0002b800, 0x0002c800, 0x0002f000, 0x0002e800, + 0x00028800, 0x0002d800, 0x0002c000, 0x00029800, + 0x00057800, 0x00056000, 0x00051000, 0x00055000, + 0x00053000, 0x00052000, 0x00052800, 0x00050000, + 0x00053800, 0x00054800, 0x00057000, 0x00056800, + 0x00050800, 0x00055800, 0x00054000, 0x00051800, + 0x0004f800, 0x0004e000, 0x00049000, 0x0004d000, + 0x0004b000, 0x0004a000, 0x0004a800, 0x00048000, + 0x0004b800, 0x0004c800, 0x0004f000, 0x0004e800, + 0x00048800, 0x0004d800, 0x0004c000, 0x00049800, + 0x0000f800, 0x0000e000, 0x00009000, 0x0000d000, + 0x0000b000, 0x0000a000, 0x0000a800, 0x00008000, + 0x0000b800, 0x0000c800, 0x0000f000, 0x0000e800, + 0x00008800, 0x0000d800, 0x0000c000, 0x00009800, + }, { /* 1 */ + 0x00880000, 0x00e00000, 0x00d80000, 0x00800000, + 0x00f80000, 0x00f00000, 0x00b00000, 0x00a80000, + 0x00d00000, 0x00e80000, 0x00a00000, 0x00c00000, + 0x00c80000, 0x00980000, 0x00b80000, 0x00900000, + 0x02880000, 0x02e00000, 0x02d80000, 0x02800000, + 0x02f80000, 0x02f00000, 0x02b00000, 0x02a80000, + 0x02d00000, 0x02e80000, 0x02a00000, 0x02c00000, + 0x02c80000, 0x02980000, 0x02b80000, 0x02900000, + 0x07080000, 0x07600000, 0x07580000, 0x07000000, + 0x07780000, 0x07700000, 0x07300000, 0x07280000, + 0x07500000, 0x07680000, 0x07200000, 0x07400000, + 0x07480000, 0x07180000, 0x07380000, 0x07100000, + 0x06080000, 0x06600000, 0x06580000, 0x06000000, + 0x06780000, 0x06700000, 0x06300000, 0x06280000, + 0x06500000, 0x06680000, 0x06200000, 0x06400000, + 0x06480000, 0x06180000, 0x06380000, 0x06100000, + 0x05080000, 0x05600000, 0x05580000, 0x05000000, + 0x05780000, 0x05700000, 0x05300000, 0x05280000, + 0x05500000, 0x05680000, 0x05200000, 0x05400000, + 0x05480000, 0x05180000, 0x05380000, 0x05100000, + 0x03880000, 0x03e00000, 0x03d80000, 0x03800000, + 0x03f80000, 0x03f00000, 0x03b00000, 0x03a80000, + 0x03d00000, 0x03e80000, 0x03a00000, 0x03c00000, + 0x03c80000, 0x03980000, 0x03b80000, 0x03900000, + 0x00080000, 0x00600000, 0x00580000, 0x00000000, + 0x00780000, 0x00700000, 0x00300000, 0x00280000, + 0x00500000, 0x00680000, 0x00200000, 0x00400000, + 0x00480000, 0x00180000, 0x00380000, 0x00100000, + 0x06880000, 0x06e00000, 0x06d80000, 0x06800000, + 0x06f80000, 0x06f00000, 0x06b00000, 0x06a80000, + 0x06d00000, 0x06e80000, 0x06a00000, 0x06c00000, + 0x06c80000, 0x06980000, 0x06b80000, 0x06900000, + 0x03080000, 0x03600000, 0x03580000, 0x03000000, + 0x03780000, 0x03700000, 0x03300000, 0x03280000, + 0x03500000, 0x03680000, 0x03200000, 0x03400000, + 0x03480000, 0x03180000, 0x03380000, 0x03100000, + 0x01080000, 0x01600000, 0x01580000, 0x01000000, + 0x01780000, 0x01700000, 0x01300000, 0x01280000, + 0x01500000, 0x01680000, 0x01200000, 0x01400000, + 0x01480000, 0x01180000, 0x01380000, 0x01100000, + 0x05880000, 0x05e00000, 0x05d80000, 0x05800000, + 0x05f80000, 0x05f00000, 0x05b00000, 0x05a80000, + 0x05d00000, 0x05e80000, 0x05a00000, 0x05c00000, + 0x05c80000, 0x05980000, 0x05b80000, 0x05900000, + 0x02080000, 0x02600000, 0x02580000, 0x02000000, + 0x02780000, 0x02700000, 0x02300000, 0x02280000, + 0x02500000, 0x02680000, 0x02200000, 0x02400000, + 0x02480000, 0x02180000, 0x02380000, 0x02100000, + 0x04880000, 0x04e00000, 0x04d80000, 0x04800000, + 0x04f80000, 0x04f00000, 0x04b00000, 0x04a80000, + 0x04d00000, 0x04e80000, 0x04a00000, 0x04c00000, + 0x04c80000, 0x04980000, 0x04b80000, 0x04900000, + 0x01880000, 0x01e00000, 0x01d80000, 0x01800000, + 0x01f80000, 0x01f00000, 0x01b00000, 0x01a80000, + 0x01d00000, 0x01e80000, 0x01a00000, 0x01c00000, + 0x01c80000, 0x01980000, 0x01b80000, 0x01900000, + 0x07880000, 0x07e00000, 0x07d80000, 0x07800000, + 0x07f80000, 0x07f00000, 0x07b00000, 0x07a80000, + 0x07d00000, 0x07e80000, 0x07a00000, 0x07c00000, + 0x07c80000, 0x07980000, 0x07b80000, 0x07900000, + 0x04080000, 0x04600000, 0x04580000, 0x04000000, + 0x04780000, 0x04700000, 0x04300000, 0x04280000, + 0x04500000, 0x04680000, 0x04200000, 0x04400000, + 0x04480000, 0x04180000, 0x04380000, 0x04100000, + }, { /* 2 */ + 0x00000004, 0x60000004, 0x40000004, 0x48000004, + 0x68000004, 0x10000004, 0x50000004, 0x58000004, + 0x38000004, 0x18000004, 0x30000004, 0x28000004, + 0x20000004, 0x70000004, 0x78000004, 0x08000004, + 0x00000000, 0x60000000, 0x40000000, 0x48000000, + 0x68000000, 0x10000000, 0x50000000, 0x58000000, + 0x38000000, 0x18000000, 0x30000000, 0x28000000, + 0x20000000, 0x70000000, 0x78000000, 0x08000000, + 0x80000007, 0xe0000007, 0xc0000007, 0xc8000007, + 0xe8000007, 0x90000007, 0xd0000007, 0xd8000007, + 0xb8000007, 0x98000007, 0xb0000007, 0xa8000007, + 0xa0000007, 0xf0000007, 0xf8000007, 0x88000007, + 0x80000001, 0xe0000001, 0xc0000001, 0xc8000001, + 0xe8000001, 0x90000001, 0xd0000001, 0xd8000001, + 0xb8000001, 0x98000001, 0xb0000001, 0xa8000001, + 0xa0000001, 0xf0000001, 0xf8000001, 0x88000001, + 0x00000001, 0x60000001, 0x40000001, 0x48000001, + 0x68000001, 0x10000001, 0x50000001, 0x58000001, + 0x38000001, 0x18000001, 0x30000001, 0x28000001, + 0x20000001, 0x70000001, 0x78000001, 0x08000001, + 0x80000002, 0xe0000002, 0xc0000002, 0xc8000002, + 0xe8000002, 0x90000002, 0xd0000002, 0xd8000002, + 0xb8000002, 0x98000002, 0xb0000002, 0xa8000002, + 0xa0000002, 0xf0000002, 0xf8000002, 0x88000002, + 0x00000007, 0x60000007, 0x40000007, 0x48000007, + 0x68000007, 0x10000007, 0x50000007, 0x58000007, + 0x38000007, 0x18000007, 0x30000007, 0x28000007, + 0x20000007, 0x70000007, 0x78000007, 0x08000007, + 0x80000005, 0xe0000005, 0xc0000005, 0xc8000005, + 0xe8000005, 0x90000005, 0xd0000005, 0xd8000005, + 0xb8000005, 0x98000005, 0xb0000005, 0xa8000005, + 0xa0000005, 0xf0000005, 0xf8000005, 0x88000005, + 0x80000000, 0xe0000000, 0xc0000000, 0xc8000000, + 0xe8000000, 0x90000000, 0xd0000000, 0xd8000000, + 0xb8000000, 0x98000000, 0xb0000000, 0xa8000000, + 0xa0000000, 0xf0000000, 0xf8000000, 0x88000000, + 0x00000005, 0x60000005, 0x40000005, 0x48000005, + 0x68000005, 0x10000005, 0x50000005, 0x58000005, + 0x38000005, 0x18000005, 0x30000005, 0x28000005, + 0x20000005, 0x70000005, 0x78000005, 0x08000005, + 0x00000002, 0x60000002, 0x40000002, 0x48000002, + 0x68000002, 0x10000002, 0x50000002, 0x58000002, + 0x38000002, 0x18000002, 0x30000002, 0x28000002, + 0x20000002, 0x70000002, 0x78000002, 0x08000002, + 0x80000003, 0xe0000003, 0xc0000003, 0xc8000003, + 0xe8000003, 0x90000003, 0xd0000003, 0xd8000003, + 0xb8000003, 0x98000003, 0xb0000003, 0xa8000003, + 0xa0000003, 0xf0000003, 0xf8000003, 0x88000003, + 0x00000006, 0x60000006, 0x40000006, 0x48000006, + 0x68000006, 0x10000006, 0x50000006, 0x58000006, + 0x38000006, 0x18000006, 0x30000006, 0x28000006, + 0x20000006, 0x70000006, 0x78000006, 0x08000006, + 0x80000004, 0xe0000004, 0xc0000004, 0xc8000004, + 0xe8000004, 0x90000004, 0xd0000004, 0xd8000004, + 0xb8000004, 0x98000004, 0xb0000004, 0xa8000004, + 0xa0000004, 0xf0000004, 0xf8000004, 0x88000004, + 0x80000006, 0xe0000006, 0xc0000006, 0xc8000006, + 0xe8000006, 0x90000006, 0xd0000006, 0xd8000006, + 0xb8000006, 0x98000006, 0xb0000006, 0xa8000006, + 0xa0000006, 0xf0000006, 0xf8000006, 0x88000006, + 0x00000003, 0x60000003, 0x40000003, 0x48000003, + 0x68000003, 0x10000003, 0x50000003, 0x58000003, + 0x38000003, 0x18000003, 0x30000003, 0x28000003, + 0x20000003, 0x70000003, 0x78000003, 0x08000003, + }, { /* 3 */ + 0x00000098, 0x00000080, 0x000000b0, 0x000000f8, + 0x00000088, 0x000000f0, 0x000000c8, 0x00000090, + 0x000000e8, 0x000000c0, 0x000000e0, 0x000000a0, + 0x000000d8, 0x000000d0, 0x000000a8, 0x000000b8, + 0x00000518, 0x00000500, 0x00000530, 0x00000578, + 0x00000508, 0x00000570, 0x00000548, 0x00000510, + 0x00000568, 0x00000540, 0x00000560, 0x00000520, + 0x00000558, 0x00000550, 0x00000528, 0x00000538, + 0x00000318, 0x00000300, 0x00000330, 0x00000378, + 0x00000308, 0x00000370, 0x00000348, 0x00000310, + 0x00000368, 0x00000340, 0x00000360, 0x00000320, + 0x00000358, 0x00000350, 0x00000328, 0x00000338, + 0x00000418, 0x00000400, 0x00000430, 0x00000478, + 0x00000408, 0x00000470, 0x00000448, 0x00000410, + 0x00000468, 0x00000440, 0x00000460, 0x00000420, + 0x00000458, 0x00000450, 0x00000428, 0x00000438, + 0x00000798, 0x00000780, 0x000007b0, 0x000007f8, + 0x00000788, 0x000007f0, 0x000007c8, 0x00000790, + 0x000007e8, 0x000007c0, 0x000007e0, 0x000007a0, + 0x000007d8, 0x000007d0, 0x000007a8, 0x000007b8, + 0x00000598, 0x00000580, 0x000005b0, 0x000005f8, + 0x00000588, 0x000005f0, 0x000005c8, 0x00000590, + 0x000005e8, 0x000005c0, 0x000005e0, 0x000005a0, + 0x000005d8, 0x000005d0, 0x000005a8, 0x000005b8, + 0x00000018, 0x00000000, 0x00000030, 0x00000078, + 0x00000008, 0x00000070, 0x00000048, 0x00000010, + 0x00000068, 0x00000040, 0x00000060, 0x00000020, + 0x00000058, 0x00000050, 0x00000028, 0x00000038, + 0x00000218, 0x00000200, 0x00000230, 0x00000278, + 0x00000208, 0x00000270, 0x00000248, 0x00000210, + 0x00000268, 0x00000240, 0x00000260, 0x00000220, + 0x00000258, 0x00000250, 0x00000228, 0x00000238, + 0x00000618, 0x00000600, 0x00000630, 0x00000678, + 0x00000608, 0x00000670, 0x00000648, 0x00000610, + 0x00000668, 0x00000640, 0x00000660, 0x00000620, + 0x00000658, 0x00000650, 0x00000628, 0x00000638, + 0x00000198, 0x00000180, 0x000001b0, 0x000001f8, + 0x00000188, 0x000001f0, 0x000001c8, 0x00000190, + 0x000001e8, 0x000001c0, 0x000001e0, 0x000001a0, + 0x000001d8, 0x000001d0, 0x000001a8, 0x000001b8, + 0x00000298, 0x00000280, 0x000002b0, 0x000002f8, + 0x00000288, 0x000002f0, 0x000002c8, 0x00000290, + 0x000002e8, 0x000002c0, 0x000002e0, 0x000002a0, + 0x000002d8, 0x000002d0, 0x000002a8, 0x000002b8, + 0x00000498, 0x00000480, 0x000004b0, 0x000004f8, + 0x00000488, 0x000004f0, 0x000004c8, 0x00000490, + 0x000004e8, 0x000004c0, 0x000004e0, 0x000004a0, + 0x000004d8, 0x000004d0, 0x000004a8, 0x000004b8, + 0x00000398, 0x00000380, 0x000003b0, 0x000003f8, + 0x00000388, 0x000003f0, 0x000003c8, 0x00000390, + 0x000003e8, 0x000003c0, 0x000003e0, 0x000003a0, + 0x000003d8, 0x000003d0, 0x000003a8, 0x000003b8, + 0x00000698, 0x00000680, 0x000006b0, 0x000006f8, + 0x00000688, 0x000006f0, 0x000006c8, 0x00000690, + 0x000006e8, 0x000006c0, 0x000006e0, 0x000006a0, + 0x000006d8, 0x000006d0, 0x000006a8, 0x000006b8, + 0x00000118, 0x00000100, 0x00000130, 0x00000178, + 0x00000108, 0x00000170, 0x00000148, 0x00000110, + 0x00000168, 0x00000140, 0x00000160, 0x00000120, + 0x00000158, 0x00000150, 0x00000128, 0x00000138, + 0x00000718, 0x00000700, 0x00000730, 0x00000778, + 0x00000708, 0x00000770, 0x00000748, 0x00000710, + 0x00000768, 0x00000740, 0x00000760, 0x00000720, + 0x00000758, 0x00000750, 0x00000728, 0x00000738, + } + } +}; + +const struct gost28147_param gost28147_param_TC26_Z = +{ + { + { /* 0 */ + 0x00036000, 0x00032000, 0x00033000, 0x00031000, + 0x00035000, 0x00032800, 0x00035800, 0x00034800, + 0x00037000, 0x00034000, 0x00036800, 0x00033800, + 0x00030000, 0x00031800, 0x00037800, 0x00030800, + 0x00046000, 0x00042000, 0x00043000, 0x00041000, + 0x00045000, 0x00042800, 0x00045800, 0x00044800, + 0x00047000, 0x00044000, 0x00046800, 0x00043800, + 0x00040000, 0x00041800, 0x00047800, 0x00040800, + 0x00016000, 0x00012000, 0x00013000, 0x00011000, + 0x00015000, 0x00012800, 0x00015800, 0x00014800, + 0x00017000, 0x00014000, 0x00016800, 0x00013800, + 0x00010000, 0x00011800, 0x00017800, 0x00010800, + 0x0001e000, 0x0001a000, 0x0001b000, 0x00019000, + 0x0001d000, 0x0001a800, 0x0001d800, 0x0001c800, + 0x0001f000, 0x0001c000, 0x0001e800, 0x0001b800, + 0x00018000, 0x00019800, 0x0001f800, 0x00018800, + 0x0004e000, 0x0004a000, 0x0004b000, 0x00049000, + 0x0004d000, 0x0004a800, 0x0004d800, 0x0004c800, + 0x0004f000, 0x0004c000, 0x0004e800, 0x0004b800, + 0x00048000, 0x00049800, 0x0004f800, 0x00048800, + 0x00056000, 0x00052000, 0x00053000, 0x00051000, + 0x00055000, 0x00052800, 0x00055800, 0x00054800, + 0x00057000, 0x00054000, 0x00056800, 0x00053800, + 0x00050000, 0x00051800, 0x00057800, 0x00050800, + 0x0002e000, 0x0002a000, 0x0002b000, 0x00029000, + 0x0002d000, 0x0002a800, 0x0002d800, 0x0002c800, + 0x0002f000, 0x0002c000, 0x0002e800, 0x0002b800, + 0x00028000, 0x00029800, 0x0002f800, 0x00028800, + 0x00066000, 0x00062000, 0x00063000, 0x00061000, + 0x00065000, 0x00062800, 0x00065800, 0x00064800, + 0x00067000, 0x00064000, 0x00066800, 0x00063800, + 0x00060000, 0x00061800, 0x00067800, 0x00060800, + 0x0000e000, 0x0000a000, 0x0000b000, 0x00009000, + 0x0000d000, 0x0000a800, 0x0000d800, 0x0000c800, + 0x0000f000, 0x0000c000, 0x0000e800, 0x0000b800, + 0x00008000, 0x00009800, 0x0000f800, 0x00008800, + 0x00076000, 0x00072000, 0x00073000, 0x00071000, + 0x00075000, 0x00072800, 0x00075800, 0x00074800, + 0x00077000, 0x00074000, 0x00076800, 0x00073800, + 0x00070000, 0x00071800, 0x00077800, 0x00070800, + 0x00026000, 0x00022000, 0x00023000, 0x00021000, + 0x00025000, 0x00022800, 0x00025800, 0x00024800, + 0x00027000, 0x00024000, 0x00026800, 0x00023800, + 0x00020000, 0x00021800, 0x00027800, 0x00020800, + 0x0003e000, 0x0003a000, 0x0003b000, 0x00039000, + 0x0003d000, 0x0003a800, 0x0003d800, 0x0003c800, + 0x0003f000, 0x0003c000, 0x0003e800, 0x0003b800, + 0x00038000, 0x00039800, 0x0003f800, 0x00038800, + 0x0005e000, 0x0005a000, 0x0005b000, 0x00059000, + 0x0005d000, 0x0005a800, 0x0005d800, 0x0005c800, + 0x0005f000, 0x0005c000, 0x0005e800, 0x0005b800, + 0x00058000, 0x00059800, 0x0005f800, 0x00058800, + 0x0006e000, 0x0006a000, 0x0006b000, 0x00069000, + 0x0006d000, 0x0006a800, 0x0006d800, 0x0006c800, + 0x0006f000, 0x0006c000, 0x0006e800, 0x0006b800, + 0x00068000, 0x00069800, 0x0006f800, 0x00068800, + 0x00006000, 0x00002000, 0x00003000, 0x00001000, + 0x00005000, 0x00002800, 0x00005800, 0x00004800, + 0x00007000, 0x00004000, 0x00006800, 0x00003800, + 0x00000000, 0x00001800, 0x00007800, 0x00000800, + 0x0007e000, 0x0007a000, 0x0007b000, 0x00079000, + 0x0007d000, 0x0007a800, 0x0007d800, 0x0007c800, + 0x0007f000, 0x0007c000, 0x0007e800, 0x0007b800, + 0x00078000, 0x00079800, 0x0007f800, 0x00078800, + }, { /* 1 */ + 0x06580000, 0x06180000, 0x06280000, 0x06400000, + 0x06100000, 0x06780000, 0x06500000, 0x06680000, + 0x06700000, 0x06080000, 0x06380000, 0x06200000, + 0x06600000, 0x06480000, 0x06300000, 0x06000000, + 0x04580000, 0x04180000, 0x04280000, 0x04400000, + 0x04100000, 0x04780000, 0x04500000, 0x04680000, + 0x04700000, 0x04080000, 0x04380000, 0x04200000, + 0x04600000, 0x04480000, 0x04300000, 0x04000000, + 0x01580000, 0x01180000, 0x01280000, 0x01400000, + 0x01100000, 0x01780000, 0x01500000, 0x01680000, + 0x01700000, 0x01080000, 0x01380000, 0x01200000, + 0x01600000, 0x01480000, 0x01300000, 0x01000000, + 0x00d80000, 0x00980000, 0x00a80000, 0x00c00000, + 0x00900000, 0x00f80000, 0x00d00000, 0x00e80000, + 0x00f00000, 0x00880000, 0x00b80000, 0x00a00000, + 0x00e00000, 0x00c80000, 0x00b00000, 0x00800000, + 0x06d80000, 0x06980000, 0x06a80000, 0x06c00000, + 0x06900000, 0x06f80000, 0x06d00000, 0x06e80000, + 0x06f00000, 0x06880000, 0x06b80000, 0x06a00000, + 0x06e00000, 0x06c80000, 0x06b00000, 0x06800000, + 0x02580000, 0x02180000, 0x02280000, 0x02400000, + 0x02100000, 0x02780000, 0x02500000, 0x02680000, + 0x02700000, 0x02080000, 0x02380000, 0x02200000, + 0x02600000, 0x02480000, 0x02300000, 0x02000000, + 0x07d80000, 0x07980000, 0x07a80000, 0x07c00000, + 0x07900000, 0x07f80000, 0x07d00000, 0x07e80000, + 0x07f00000, 0x07880000, 0x07b80000, 0x07a00000, + 0x07e00000, 0x07c80000, 0x07b00000, 0x07800000, + 0x03580000, 0x03180000, 0x03280000, 0x03400000, + 0x03100000, 0x03780000, 0x03500000, 0x03680000, + 0x03700000, 0x03080000, 0x03380000, 0x03200000, + 0x03600000, 0x03480000, 0x03300000, 0x03000000, + 0x03d80000, 0x03980000, 0x03a80000, 0x03c00000, + 0x03900000, 0x03f80000, 0x03d00000, 0x03e80000, + 0x03f00000, 0x03880000, 0x03b80000, 0x03a00000, + 0x03e00000, 0x03c80000, 0x03b00000, 0x03800000, + 0x00580000, 0x00180000, 0x00280000, 0x00400000, + 0x00100000, 0x00780000, 0x00500000, 0x00680000, + 0x00700000, 0x00080000, 0x00380000, 0x00200000, + 0x00600000, 0x00480000, 0x00300000, 0x00000000, + 0x05580000, 0x05180000, 0x05280000, 0x05400000, + 0x05100000, 0x05780000, 0x05500000, 0x05680000, + 0x05700000, 0x05080000, 0x05380000, 0x05200000, + 0x05600000, 0x05480000, 0x05300000, 0x05000000, + 0x02d80000, 0x02980000, 0x02a80000, 0x02c00000, + 0x02900000, 0x02f80000, 0x02d00000, 0x02e80000, + 0x02f00000, 0x02880000, 0x02b80000, 0x02a00000, + 0x02e00000, 0x02c80000, 0x02b00000, 0x02800000, + 0x01d80000, 0x01980000, 0x01a80000, 0x01c00000, + 0x01900000, 0x01f80000, 0x01d00000, 0x01e80000, + 0x01f00000, 0x01880000, 0x01b80000, 0x01a00000, + 0x01e00000, 0x01c80000, 0x01b00000, 0x01800000, + 0x07580000, 0x07180000, 0x07280000, 0x07400000, + 0x07100000, 0x07780000, 0x07500000, 0x07680000, + 0x07700000, 0x07080000, 0x07380000, 0x07200000, + 0x07600000, 0x07480000, 0x07300000, 0x07000000, + 0x04d80000, 0x04980000, 0x04a80000, 0x04c00000, + 0x04900000, 0x04f80000, 0x04d00000, 0x04e80000, + 0x04f00000, 0x04880000, 0x04b80000, 0x04a00000, + 0x04e00000, 0x04c80000, 0x04b00000, 0x04800000, + 0x05d80000, 0x05980000, 0x05a80000, 0x05c00000, + 0x05900000, 0x05f80000, 0x05d00000, 0x05e80000, + 0x05f00000, 0x05880000, 0x05b80000, 0x05a00000, + 0x05e00000, 0x05c80000, 0x05b00000, 0x05800000, + }, { /* 2 */ + 0xb8000002, 0xf8000002, 0xa8000002, 0xd0000002, + 0xc0000002, 0x88000002, 0xb0000002, 0xe8000002, + 0x80000002, 0xc8000002, 0x98000002, 0xf0000002, + 0xd8000002, 0xa0000002, 0x90000002, 0xe0000002, + 0xb8000006, 0xf8000006, 0xa8000006, 0xd0000006, + 0xc0000006, 0x88000006, 0xb0000006, 0xe8000006, + 0x80000006, 0xc8000006, 0x98000006, 0xf0000006, + 0xd8000006, 0xa0000006, 0x90000006, 0xe0000006, + 0xb8000007, 0xf8000007, 0xa8000007, 0xd0000007, + 0xc0000007, 0x88000007, 0xb0000007, 0xe8000007, + 0x80000007, 0xc8000007, 0x98000007, 0xf0000007, + 0xd8000007, 0xa0000007, 0x90000007, 0xe0000007, + 0x38000003, 0x78000003, 0x28000003, 0x50000003, + 0x40000003, 0x08000003, 0x30000003, 0x68000003, + 0x00000003, 0x48000003, 0x18000003, 0x70000003, + 0x58000003, 0x20000003, 0x10000003, 0x60000003, + 0xb8000004, 0xf8000004, 0xa8000004, 0xd0000004, + 0xc0000004, 0x88000004, 0xb0000004, 0xe8000004, + 0x80000004, 0xc8000004, 0x98000004, 0xf0000004, + 0xd8000004, 0xa0000004, 0x90000004, 0xe0000004, + 0x38000001, 0x78000001, 0x28000001, 0x50000001, + 0x40000001, 0x08000001, 0x30000001, 0x68000001, + 0x00000001, 0x48000001, 0x18000001, 0x70000001, + 0x58000001, 0x20000001, 0x10000001, 0x60000001, + 0x38000006, 0x78000006, 0x28000006, 0x50000006, + 0x40000006, 0x08000006, 0x30000006, 0x68000006, + 0x00000006, 0x48000006, 0x18000006, 0x70000006, + 0x58000006, 0x20000006, 0x10000006, 0x60000006, + 0x38000005, 0x78000005, 0x28000005, 0x50000005, + 0x40000005, 0x08000005, 0x30000005, 0x68000005, + 0x00000005, 0x48000005, 0x18000005, 0x70000005, + 0x58000005, 0x20000005, 0x10000005, 0x60000005, + 0xb8000005, 0xf8000005, 0xa8000005, 0xd0000005, + 0xc0000005, 0x88000005, 0xb0000005, 0xe8000005, + 0x80000005, 0xc8000005, 0x98000005, 0xf0000005, + 0xd8000005, 0xa0000005, 0x90000005, 0xe0000005, + 0xb8000003, 0xf8000003, 0xa8000003, 0xd0000003, + 0xc0000003, 0x88000003, 0xb0000003, 0xe8000003, + 0x80000003, 0xc8000003, 0x98000003, 0xf0000003, + 0xd8000003, 0xa0000003, 0x90000003, 0xe0000003, + 0x38000004, 0x78000004, 0x28000004, 0x50000004, + 0x40000004, 0x08000004, 0x30000004, 0x68000004, + 0x00000004, 0x48000004, 0x18000004, 0x70000004, + 0x58000004, 0x20000004, 0x10000004, 0x60000004, + 0xb8000000, 0xf8000000, 0xa8000000, 0xd0000000, + 0xc0000000, 0x88000000, 0xb0000000, 0xe8000000, + 0x80000000, 0xc8000000, 0x98000000, 0xf0000000, + 0xd8000000, 0xa0000000, 0x90000000, 0xe0000000, + 0x38000002, 0x78000002, 0x28000002, 0x50000002, + 0x40000002, 0x08000002, 0x30000002, 0x68000002, + 0x00000002, 0x48000002, 0x18000002, 0x70000002, + 0x58000002, 0x20000002, 0x10000002, 0x60000002, + 0xb8000001, 0xf8000001, 0xa8000001, 0xd0000001, + 0xc0000001, 0x88000001, 0xb0000001, 0xe8000001, + 0x80000001, 0xc8000001, 0x98000001, 0xf0000001, + 0xd8000001, 0xa0000001, 0x90000001, 0xe0000001, + 0x38000007, 0x78000007, 0x28000007, 0x50000007, + 0x40000007, 0x08000007, 0x30000007, 0x68000007, + 0x00000007, 0x48000007, 0x18000007, 0x70000007, + 0x58000007, 0x20000007, 0x10000007, 0x60000007, + 0x38000000, 0x78000000, 0x28000000, 0x50000000, + 0x40000000, 0x08000000, 0x30000000, 0x68000000, + 0x00000000, 0x48000000, 0x18000000, 0x70000000, + 0x58000000, 0x20000000, 0x10000000, 0x60000000, + }, { /* 3 */ + 0x000000c0, 0x000000f0, 0x00000090, 0x000000a8, + 0x000000b0, 0x000000c8, 0x00000088, 0x000000e0, + 0x000000f8, 0x000000a0, 0x000000d8, 0x00000080, + 0x000000e8, 0x000000d0, 0x00000098, 0x000000b8, + 0x000003c0, 0x000003f0, 0x00000390, 0x000003a8, + 0x000003b0, 0x000003c8, 0x00000388, 0x000003e0, + 0x000003f8, 0x000003a0, 0x000003d8, 0x00000380, + 0x000003e8, 0x000003d0, 0x00000398, 0x000003b8, + 0x00000740, 0x00000770, 0x00000710, 0x00000728, + 0x00000730, 0x00000748, 0x00000708, 0x00000760, + 0x00000778, 0x00000720, 0x00000758, 0x00000700, + 0x00000768, 0x00000750, 0x00000718, 0x00000738, + 0x000006c0, 0x000006f0, 0x00000690, 0x000006a8, + 0x000006b0, 0x000006c8, 0x00000688, 0x000006e0, + 0x000006f8, 0x000006a0, 0x000006d8, 0x00000680, + 0x000006e8, 0x000006d0, 0x00000698, 0x000006b8, + 0x00000040, 0x00000070, 0x00000010, 0x00000028, + 0x00000030, 0x00000048, 0x00000008, 0x00000060, + 0x00000078, 0x00000020, 0x00000058, 0x00000000, + 0x00000068, 0x00000050, 0x00000018, 0x00000038, + 0x000002c0, 0x000002f0, 0x00000290, 0x000002a8, + 0x000002b0, 0x000002c8, 0x00000288, 0x000002e0, + 0x000002f8, 0x000002a0, 0x000002d8, 0x00000280, + 0x000002e8, 0x000002d0, 0x00000298, 0x000002b8, + 0x00000440, 0x00000470, 0x00000410, 0x00000428, + 0x00000430, 0x00000448, 0x00000408, 0x00000460, + 0x00000478, 0x00000420, 0x00000458, 0x00000400, + 0x00000468, 0x00000450, 0x00000418, 0x00000438, + 0x000001c0, 0x000001f0, 0x00000190, 0x000001a8, + 0x000001b0, 0x000001c8, 0x00000188, 0x000001e0, + 0x000001f8, 0x000001a0, 0x000001d8, 0x00000180, + 0x000001e8, 0x000001d0, 0x00000198, 0x000001b8, + 0x00000240, 0x00000270, 0x00000210, 0x00000228, + 0x00000230, 0x00000248, 0x00000208, 0x00000260, + 0x00000278, 0x00000220, 0x00000258, 0x00000200, + 0x00000268, 0x00000250, 0x00000218, 0x00000238, + 0x000007c0, 0x000007f0, 0x00000790, 0x000007a8, + 0x000007b0, 0x000007c8, 0x00000788, 0x000007e0, + 0x000007f8, 0x000007a0, 0x000007d8, 0x00000780, + 0x000007e8, 0x000007d0, 0x00000798, 0x000007b8, + 0x00000540, 0x00000570, 0x00000510, 0x00000528, + 0x00000530, 0x00000548, 0x00000508, 0x00000560, + 0x00000578, 0x00000520, 0x00000558, 0x00000500, + 0x00000568, 0x00000550, 0x00000518, 0x00000538, + 0x00000340, 0x00000370, 0x00000310, 0x00000328, + 0x00000330, 0x00000348, 0x00000308, 0x00000360, + 0x00000378, 0x00000320, 0x00000358, 0x00000300, + 0x00000368, 0x00000350, 0x00000318, 0x00000338, + 0x000004c0, 0x000004f0, 0x00000490, 0x000004a8, + 0x000004b0, 0x000004c8, 0x00000488, 0x000004e0, + 0x000004f8, 0x000004a0, 0x000004d8, 0x00000480, + 0x000004e8, 0x000004d0, 0x00000498, 0x000004b8, + 0x00000640, 0x00000670, 0x00000610, 0x00000628, + 0x00000630, 0x00000648, 0x00000608, 0x00000660, + 0x00000678, 0x00000620, 0x00000658, 0x00000600, + 0x00000668, 0x00000650, 0x00000618, 0x00000638, + 0x000005c0, 0x000005f0, 0x00000590, 0x000005a8, + 0x000005b0, 0x000005c8, 0x00000588, 0x000005e0, + 0x000005f8, 0x000005a0, 0x000005d8, 0x00000580, + 0x000005e8, 0x000005d0, 0x00000598, 0x000005b8, + 0x00000140, 0x00000170, 0x00000110, 0x00000128, + 0x00000130, 0x00000148, 0x00000108, 0x00000160, + 0x00000178, 0x00000120, 0x00000158, 0x00000100, + 0x00000168, 0x00000150, 0x00000118, 0x00000138, + } + } +}; + /* * A macro that performs a full encryption round of GOST 28147-89. */ diff --git a/gost28147.h b/gost28147.h index 5fff34e859d2..37633d9fd874 100644 --- a/gost28147.h +++ b/gost28147.h @@ -40,8 +40,15 @@ extern "C" { #endif
+/* S-Boxes & parameters */ #define gost28147_param_test_3411 nettle_gost28147_param_test_3411 #define gost28147_param_CryptoPro_3411 nettle_gost28147_param_CryptoPro_3411 +#define gost28147_param_Test_89 nettle_gost28147_param_Test_89 +#define gost28147_param_CryptoPro_A nettle_gost28147_param_CryptoPro_A +#define gost28147_param_CryptoPro_B nettle_gost28147_param_CryptoPro_B +#define gost28147_param_CryptoPro_C nettle_gost28147_param_CryptoPro_C +#define gost28147_param_CryptoPro_D nettle_gost28147_param_CryptoPro_D +#define gost28147_param_TC26_Z nettle_gost28147_param_TC26_Z
#define gost28147_set_key nettle_gost28147_set_key #define gost28147_set_param nettle_gost28147_set_param @@ -64,6 +71,12 @@ struct gost28147_param
extern const struct gost28147_param gost28147_param_test_3411; extern const struct gost28147_param gost28147_param_CryptoPro_3411; +extern const struct gost28147_param gost28147_param_Test_89; +extern const struct gost28147_param gost28147_param_CryptoPro_A; +extern const struct gost28147_param gost28147_param_CryptoPro_B; +extern const struct gost28147_param gost28147_param_CryptoPro_C; +extern const struct gost28147_param gost28147_param_CryptoPro_D; +extern const struct gost28147_param gost28147_param_TC26_Z;
void gost28147_set_key(struct gost28147_ctx *ctx, const uint8_t *key);
From: Dmitry Eremin-Solenikov dbaryshkov@gmail.com
Signed-off-by: Dmitry Eremin-Solenikov dbaryshkov@gmail.com --- gost28147.c | 85 +++++++++++++++++++--- gost28147.h | 8 +++ testsuite/gost28147-test.c | 143 +++++++++++++++++++++++++++++++++++++ 3 files changed, 228 insertions(+), 8 deletions(-)
diff --git a/gost28147.c b/gost28147.c index 9fe31043a3ff..ac94dfaa2ed8 100644 --- a/gost28147.c +++ b/gost28147.c @@ -33,6 +33,7 @@ #endif
#include <assert.h> +#include <string.h>
#include "macros.h" #include "gost28147.h" @@ -303,7 +304,8 @@ const struct gost28147_param gost28147_param_test_3411 = 0x00000600, 0x00000650, 0x00000670, 0x00000638, 0x00000630, 0x00000640, 0x00000610, 0x00000660, } - } + }, + 0 };
const struct gost28147_param gost28147_param_CryptoPro_3411 = @@ -570,7 +572,8 @@ const struct gost28147_param gost28147_param_CryptoPro_3411 = 0x00000618, 0x00000660, 0x00000640, 0x00000678, 0x00000630, 0x00000610, 0x00000648, 0x00000658, } - } + }, + 0 };
const struct gost28147_param gost28147_param_Test_89 = @@ -837,7 +840,8 @@ const struct gost28147_param gost28147_param_Test_89 = 0x00000420, 0x00000440, 0x00000470, 0x00000478, 0x00000408, 0x00000450, 0x00000410, 0x00000468, } - } + }, + 1 };
const struct gost28147_param gost28147_param_CryptoPro_A = @@ -1104,7 +1108,8 @@ const struct gost28147_param gost28147_param_CryptoPro_A = 0x00000240, 0x00000260, 0x00000220, 0x00000228, 0x00000278, 0x00000218, 0x00000258, 0x00000270, } - } + }, + 1 };
const struct gost28147_param gost28147_param_CryptoPro_B = @@ -1371,7 +1376,8 @@ const struct gost28147_param gost28147_param_CryptoPro_B = 0x00000638, 0x00000620, 0x00000668, 0x00000600, 0x00000630, 0x00000678, 0x00000640, 0x00000670, } - } + }, + 1 };
const struct gost28147_param gost28147_param_CryptoPro_C = @@ -1638,7 +1644,8 @@ const struct gost28147_param gost28147_param_CryptoPro_C = 0x00000478, 0x00000418, 0x00000428, 0x00000458, 0x00000420, 0x00000408, 0x00000460, 0x00000438, } - } + }, + 1 };
const struct gost28147_param gost28147_param_CryptoPro_D = @@ -1905,7 +1912,8 @@ const struct gost28147_param gost28147_param_CryptoPro_D = 0x00000768, 0x00000740, 0x00000760, 0x00000720, 0x00000758, 0x00000750, 0x00000728, 0x00000738, } - } + }, + 1 };
const struct gost28147_param gost28147_param_TC26_Z = @@ -2172,7 +2180,8 @@ const struct gost28147_param gost28147_param_TC26_Z = 0x00000178, 0x00000120, 0x00000158, 0x00000100, 0x00000168, 0x00000150, 0x00000118, 0x00000138, } - } + }, + 1 };
/* @@ -2245,6 +2254,37 @@ void _gost28147_decrypt_block (const uint32_t *key, const uint32_t sbox[4][256], *out = l, *(out + 1) = r; }
+static const uint32_t gost28147_key_mesh_cryptopro_data[GOST28147_KEY_SIZE / 4] = { + 0x22720069, 0x2304c964, + 0x96db3a8d, 0xc42ae946, + 0x94acfe18, 0x1207ed00, + 0xc2dc86c0, 0x2ba94cef, +}; + +static void gost28147_key_mesh_cryptopro(struct gost28147_ctx *ctx) +{ + uint32_t newkey[GOST28147_KEY_SIZE/4]; + + _gost28147_decrypt_block(ctx->key, ctx->sbox, + &gost28147_key_mesh_cryptopro_data[0], + &newkey[0]); + + _gost28147_decrypt_block(ctx->key, ctx->sbox, + &gost28147_key_mesh_cryptopro_data[2], + &newkey[2]); + + _gost28147_decrypt_block(ctx->key, ctx->sbox, + &gost28147_key_mesh_cryptopro_data[4], + &newkey[4]); + + _gost28147_decrypt_block(ctx->key, ctx->sbox, + &gost28147_key_mesh_cryptopro_data[6], + &newkey[6]); + + memcpy(ctx->key, newkey, sizeof(newkey)); + ctx->key_count = 0; +} + void gost28147_set_key(struct gost28147_ctx *ctx, const uint8_t *key) { @@ -2253,6 +2293,7 @@ gost28147_set_key(struct gost28147_ctx *ctx, const uint8_t *key) assert(key); for (i = 0; i < 8; i++, key += 4) ctx->key[i] = LE_READ_UINT32(key); + ctx->key_count = 0; gost28147_set_param(ctx, &gost28147_param_TC26_Z); }
@@ -2261,6 +2302,7 @@ gost28147_set_param(struct gost28147_ctx *ctx, const struct gost28147_param *par { assert(param); ctx->sbox = param->sbox; + ctx->key_meshing = param->key_meshing; }
void @@ -2302,3 +2344,30 @@ gost28147_decrypt(const struct gost28147_ctx *ctx, length -= GOST28147_BLOCK_SIZE; } } + +void +gost28147_encrypt_for_cfb(struct gost28147_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src) +{ + uint32_t block[2]; + + assert(!(length % GOST28147_BLOCK_SIZE)); + + while (length) + { + block[0] = LE_READ_UINT32(src); src += 4; + block[1] = LE_READ_UINT32(src); src += 4; + if (ctx->key_meshing && ctx->key_count == 1024) + { + gost28147_key_mesh_cryptopro(ctx); + _gost28147_encrypt_block(ctx->key, ctx->sbox, block, block); + ctx->key_count = 0; + } + _gost28147_encrypt_block(ctx->key, ctx->sbox, block, block); + LE_WRITE_UINT32(dst, block[0]); dst += 4; + LE_WRITE_UINT32(dst, block[1]); dst += 4; + length -= GOST28147_BLOCK_SIZE; + ctx->key_count += GOST28147_BLOCK_SIZE; + } +} diff --git a/gost28147.h b/gost28147.h index 37633d9fd874..241c1e136fbc 100644 --- a/gost28147.h +++ b/gost28147.h @@ -53,6 +53,7 @@ extern "C" { #define gost28147_set_key nettle_gost28147_set_key #define gost28147_set_param nettle_gost28147_set_param #define gost28147_encrypt nettle_gost28147_encrypt +#define gost28147_encrypt_for_cfb nettle_gost28147_encrypt_for_cfb #define gost28147_decrypt nettle_gost28147_decrypt
#define GOST28147_KEY_SIZE 32 @@ -62,11 +63,14 @@ struct gost28147_ctx { uint32_t key[GOST28147_KEY_SIZE/4]; const uint32_t (*sbox)[256]; + int key_meshing; + int key_count; /* Used for key meshing */ };
struct gost28147_param { uint32_t sbox[4][256]; + int key_meshing; };
extern const struct gost28147_param gost28147_param_test_3411; @@ -93,6 +97,10 @@ void gost28147_decrypt(const struct gost28147_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src); +void +gost28147_encrypt_for_cfb(struct gost28147_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src);
#ifdef __cplusplus } diff --git a/testsuite/gost28147-test.c b/testsuite/gost28147-test.c index 3f8046e19e3f..939bedee9c66 100644 --- a/testsuite/gost28147-test.c +++ b/testsuite/gost28147-test.c @@ -1,5 +1,6 @@ #include "testutils.h" #include "gost28147.h" +#include "cfb.h"
static void test_gost28147(const struct gost28147_param *param, @@ -49,6 +50,60 @@ test_gost28147(const struct gost28147_param *param, free(data); }
+static void +test_gost28147_cfb(const struct gost28147_param *param, + const struct tstring *key, + const struct tstring *iv, + const struct tstring *cleartext, + const struct tstring *ciphertext) +{ + struct ctx CFB_CTX(struct gost28147_ctx, GOST28147_BLOCK_SIZE) ctx; + uint8_t *data = xalloc(cleartext->length); + size_t length; + + ASSERT (cleartext->length == ciphertext->length); + length = cleartext->length; + + gost28147_set_key(&ctx.ctx, key->data); + gost28147_set_param(&ctx.ctx, param); + CFB_SET_IV(&ctx, iv->data); + + CFB_ENCRYPT(&ctx, gost28147_encrypt_for_cfb, length, + data, cleartext->data); + + if (!MEMEQ(length, data, ciphertext->data)) + { + fprintf(stderr, "Encrypt failed:\nInput:"); + tstring_print_hex(cleartext); + fprintf(stderr, "\nOutput: "); + print_hex(length, data); + fprintf(stderr, "\nExpected:"); + tstring_print_hex(ciphertext); + fprintf(stderr, "\n"); + FAIL(); + } + + gost28147_set_key(&ctx.ctx, key->data); + gost28147_set_param(&ctx.ctx, param); + CFB_SET_IV(&ctx, iv->data); + CFB_DECRYPT(&ctx, gost28147_encrypt_for_cfb, length, + data, data); + + if (!MEMEQ(length, data, cleartext->data)) + { + fprintf(stderr, "Decrypt failed:\nInput:"); + tstring_print_hex(ciphertext); + fprintf(stderr, "\nOutput: "); + print_hex(length, data); + fprintf(stderr, "\nExpected:"); + tstring_print_hex(cleartext); + fprintf(stderr, "\n"); + FAIL(); + } + + free(data); +} + void test_main(void) { /* Examples from GOST R 34.11-94 standard */ @@ -116,4 +171,92 @@ void test_main(void) SHEX("ccddeeff8899aabb4455667700112233f3f2f1f0f7f6f5f4fbfaf9f8fffefdfc"), SHEX("1032547698badcfe"), SHEX("3dcad8c2e501e94e")); + + test_gost28147_cfb(&gost28147_param_CryptoPro_A, + SHEX("8d5a2c83a7c70a61 d61b34b51fdf4268 6671a35d874cfd84 993663b61ed60dad"), + SHEX("46606f0d8834235a"), + SHEX("d2fdf83ac1b43923 2eaacc980a02da33"), + SHEX("88b7751674a5ee2d 14fe9167d05ccc40")); + + test_gost28147_cfb(&gost28147_param_CryptoPro_C, + SHEX("77c3458ef642e704 8efc08e47096d605 9359026d6f97cae9 cf89444bde6c221d"), + SHEX("437c3e8e2f2a0098"), + SHEX("079c91be"), + SHEX("19358134")); + + test_gost28147_cfb(&gost28147_param_CryptoPro_D, + SHEX("389fe837ff9c5d29 fc4855a087eae840 20875bb2011555a7 e32dcb3dd6590473"), + SHEX("c5a2d21f2fdfb8eb"), + SHEX("2f31d883b420e86e da"), + SHEX("6da4ed40088871ad 16")); + + test_gost28147_cfb(&gost28147_param_CryptoPro_B, + SHEX("480c741b026b55d5 b66dd71d4048056b 6deb3c290f848023 ee0d4777e3fe61c9"), + SHEX("1f3f821e0dd81e22"), + SHEX("8c9c4435fbe9a5a3 a0ae285691108e1e d2bb185381270da6 685936c581629a8e" + "7d50f16f976229ec 8051e37d6cc40795 2863dcb4b92db813 b105b5f9eb75374e" + "f7bf51f1988643c4 e43d3ea762ec4159 e0bdfbb6fdece077 13d25990a1b8976b" + "3d8b7dfc9dca8273 32700a7403c60c26 7f56f09db2eb7140 d7c3b1a7c51e2017" + "b3501d8a6e19cbbe 20862bd61cfdb4b7 5d9ab3e37d157a35 019f5d65894b34c6" + "f4813f7830cfe915 909af9deba63d019 14663cb9a4b28494 02cfce20cf76e7c5" + "48f7693a5decaf41 a7126483f5991e9e b2ab861600238ee6 d9800b6dc593e25c" + "8cd85e5aae4a85fd 7601ea30f3783410 7251bc9f76ce1fd4 8f335034c74d7bcf" + "91637d829ea12345 f545ac987a48ff64 d55947de2b3ffaec 50e081608bc3fc80" + "9817c7a3c2573dab 9167f5c4ab92c8d6 3b6b3fff156bcf53 6502f174caa9be24" + "d2f0b726a8d76ded 90367b3e41a97fa3 1bf443c551be2859 e94526493832f8f3" + "926e30ccb0a0f901 14c8bad9f02a29e2 529a76953a1632ec f410ecee47007019" + "e472356644532da2 f3aa7e8a3313cdc8 bf0e409000e442c3 0984e16617a2af03" + "ab6ba1ecfb177281 fe9a9ff4b2331fae 0cd16aae19b8afec e3ea00f8ac87075f" + "6db0ac6b224836bf 2218b0039f6c7045 36f06bc6c2a5722c d8e0273dec560705" + "7d83a1657d415bcd 7724e5aa7647d050 f6e7b559753127ef d8a64e7fb840b1df" + "5314edf1685ffc3f 02db05eb31e42c7f 32b5708e7585a45c 162337f21079cbdc" + "f81c25c2a13d9c33 6cedc3e7f3028782 4efbacb32dfcf80d 1d4a39d4b309bbe9" + "25c7ec6a877284ed 12601964eb162a5b 107627ff7be4aee5 a404027fbb0ab5f4" + "05a5561c53317a93 ba1615ab6260fcde 72366e28af980de6 f4de60a77e060786" + "f394b66d0d93a6bc 607033ac3fa1a84a 2061b6b543a3155a 00be76985772ab7a" + "0e1893823a18786e 717b784f7e8cde7a 62b50a7c451d16d5 c38c9b25b45090cd" + "9693ad0fd443cb49 0ffc5a31f419b7d4 eb4d4058d03bc8e0 4a542fdb22c3297b" + "40906143d37ee230 2b483cce9093b18b 3196656d578b9d4d 53f0831ce5a19d55" + "e3bf7eca1a746614 cc4743d9bbef977d b76efff122f8102d 3fcd4996d90911b8" + "33d0239afa16cb50 2657245c0ebaf03f 372fa3f718574848 95cfef87672ae9b6" + "8a21367fff486c46 3557f2bc48678f63 2378112bc208de51 e88b9229f99a9ead" + "ed0feba2d24092d4 de629576fd6e3cbf c0d70de51ba4c718 e158a456ef2e171b" + "75cbbcf92a9571a7 1d7fe77363056b19 4cf42214c4598866 9286615c6aaeec58" + "ffc9f244d4a2f598 eb5f09bc8abf3cb4 3eb120054496790a 40927f9dd1afbc90" + "950a81d4a7c6b8e0 e439301d79c0e5fa b4e963b409723b3e d9f6d91021187ee5" + "ad81d7d582d08c3b 3895f89201a99200 70d1a788771f3aeb b5e4f59dc73786b2" + "12463419728cf58c f67898e07cd3f4"), + SHEX("23c67f20a12358bc 7b05db2115cf9641 c788ef765c49db42 bff3c0f5bd5dd98e" + "af3df4e4da88bdbc 475d7607c95f541d 1d6aa12e18d66084 021837929215ab21" + "ee21cc716e51d92b cc81973feb4599b8 1bdaff90d341069c 3ffbe4b2dcc9030d" + "a7aed77d02b832ab f365a3656c4ee4a2 5e9eeecdde79366b 1be13cdf10ad4f02" + "e114aa09b40b76eb 69382002cb8ec0df ca4874c331ad422c 519bd06ac136d721" + "dfb045baca7f3520 28bbc176fd435d23 7d31841a974d83aa 7ef1c4e683ac0def" + "ef3ca47c48e4c8ca 0d7dea7c45d77350 251d01c4021acde0 385ba85a169a1059" + "74d719c6f3b517f6 598d62af44e8dce9 c176f1d0bd29d7ec 1dac57db1a3fd8f6" + "6eb6e6df36e789ce 5635431c7d57790e d8f4d7a70dc68f91 6667820f49c9c565" + "81a1395a539f02a5 d53622a8a81c370e 7646dfbd6adbfc1b bd10b8b1bc724c58" + "4ada6d6600da7a66 a0e73b39a3f70507 fa214bc794c0d37b 19025d4a10f1c20f" + "196827c77dbf5503 577daf77ae802f7a e61f4bdc1518c062 a1e8d91c9e8c9639" + "c1c488f70ce10484 6851cef190da7f76 c8c088ef8e15253e 7be479b5662d9cd1" + "13dad0d546d58d46 1807eed8c964e3be 0e6827099626f6e2 19613ff458270aeb" + "ce7cb66892e7123b 31d448df358df486 422a154be8191f26 659ba8da4b791f8e" + "e6137e498fc1cedc 5e6474ce0278e0cf a0ed5e3174d1d0b4 ee7019143c8f16a6" + "cf12931588eb9165 7698fda19430ba43 62654004779ed6ab 8b0d9380505fa276" + "20a7d69c271527bc a55abfe9928205a8 41e9b560d5c0d74b ad38b2e9d1e5515f" + "2478249a23d2c248 bd0ef137729187b0 4ebd996b2c01b679 69ec0cede53f5064" + "7cb9dde19281b5d0 cb1783868bea4f93 08bc220cefe80df5 9e23e1f9b76b450b" + "cba9b64d2825ba3e 86f275475d9d6bf6 8a0558733d00defd 69b16116f52eb09f" + "316a00b9ef716347 a3cae040a87e0204 fee5ce4873e394cf e2ff297ef632bbb7" + "5512217a9c75040c b47cb03d40b3119a 7a9a13fb77a75168 f705473b0f525ce6" + "c2993a37545c4f2b a7010874bc91e3e2 fe6594fd3d18e0f0 62edc210829c587f" + "b2a3878a74d9c1fb 842817c72bcb531f 4e8a82fcb43fc147 25f321dc4c2d08fa" + "e70f03a968de6b41 a0f9416c574d3a0e ea51ca9f97117df6 8e886367c96513ca" + "38ed35bef427a9fc a9e6c34086083972 37eeb2870996b740 873692c15d6a2c43" + "ca25c835372db5a9 274450f26d227541 772adbb18c6d05e8 c999c708f9148f78" + "a98fc25a7a65c5d8 86bb72696b6b4583 5bb1f7cd1673eee9 8085fe8ee1ae538f" + "debe488b59eff67e d8b5a847c04e1558 cad32ff86ca63d78 4d7a54d610e5cc05" + "e229b58607397d78 8e5a8f834ce73d68 3ee502e6644f5eb4 4977f0c0fa6fc8fb" + "9f846f55fb305e89 93a9f3a6a3d726bb d8a8d9951dfefcd7 a893662f04530664" + "7f3129aeb79fbac4 6d68d12432f411")); }
From: Dmitry Eremin-Solenikov dbaryshkov@gmail.com
Signed-off-by: Dmitry Eremin-Solenikov dbaryshkov@gmail.com --- gost28147.c | 86 ++++++++++++++++++++ gost28147.h | 24 ++++++ testsuite/gost28147-test.c | 161 +++++++++++++++++++++++++++++++++++++ 3 files changed, 271 insertions(+)
diff --git a/gost28147.c b/gost28147.c index ac94dfaa2ed8..f718a202a56b 100644 --- a/gost28147.c +++ b/gost28147.c @@ -38,6 +38,7 @@ #include "macros.h" #include "gost28147.h" #include "gost28147-internal.h" +#include "memxor.h"
/* pre-initialized GOST lookup tables based on rotated S-Box */ const struct gost28147_param gost28147_param_test_3411 = @@ -2371,3 +2372,88 @@ gost28147_encrypt_for_cfb(struct gost28147_ctx *ctx, ctx->key_count += GOST28147_BLOCK_SIZE; } } + +static void +gost28147_cnt_next_iv(struct gost28147_cnt_ctx *ctx, + uint8_t *out) +{ + uint32_t block[2]; + uint32_t temp; + + if (ctx->ctx.key_meshing && ctx->ctx.key_count == 1024) + { + gost28147_key_mesh_cryptopro(&ctx->ctx); + _gost28147_encrypt_block(ctx->ctx.key, ctx->ctx.sbox, ctx->iv, ctx->iv); + ctx->ctx.key_count = 0; + } + + ctx->iv[0] += 0x01010101; + temp = ctx->iv[1] + 0x01010104; + if (temp < ctx->iv[1]) + ctx->iv[1] = temp + 1; /* Overflow */ + else + ctx->iv[1] = temp; + + _gost28147_encrypt_block(ctx->ctx.key, ctx->ctx.sbox, ctx->iv, block); + + LE_WRITE_UINT32(out + 0, block[0]); + LE_WRITE_UINT32(out + 4, block[1]); + + ctx->ctx.key_count += GOST28147_BLOCK_SIZE; +} + +void +gost28147_cnt_init(struct gost28147_cnt_ctx *ctx, + const uint8_t *key, + const struct gost28147_param *param) +{ + gost28147_set_key(&ctx->ctx, key); + gost28147_set_param(&ctx->ctx, param); + ctx->bytes = 0; +} + +void +gost28147_cnt_set_iv(struct gost28147_cnt_ctx *ctx, + const uint8_t *iv) +{ + uint32_t block[2]; + + block[0] = LE_READ_UINT32(iv + 0); + block[1] = LE_READ_UINT32(iv + 4); + + _gost28147_encrypt_block(ctx->ctx.key, ctx->ctx.sbox, block, ctx->iv); +} + +void +gost28147_cnt_crypt(struct gost28147_cnt_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src) +{ + size_t block_size = GOST28147_BLOCK_SIZE; + + if (ctx->bytes) + { + size_t part = ctx->bytes < length ? ctx->bytes : length; + memxor3(dst, src, ctx->buffer + block_size - ctx->bytes, part); + dst += part; + src += part; + length -= part; + ctx->bytes -= part; + ctx->bytes %= block_size; + } + while (length >= block_size) + { + gost28147_cnt_next_iv(ctx, ctx->buffer); + memxor3(dst, src, ctx->buffer, block_size); + length -= block_size; + src += block_size; + dst += block_size; + } + + if (length != 0) + { + gost28147_cnt_next_iv(ctx, ctx->buffer); + memxor3(dst, src, ctx->buffer, length); + ctx->bytes = block_size - length; + } +} diff --git a/gost28147.h b/gost28147.h index 241c1e136fbc..08189067983c 100644 --- a/gost28147.h +++ b/gost28147.h @@ -56,6 +56,10 @@ extern "C" { #define gost28147_encrypt_for_cfb nettle_gost28147_encrypt_for_cfb #define gost28147_decrypt nettle_gost28147_decrypt
+#define gost28147_cnt_init nettle_gost28147_cnt_init +#define gost28147_cnt_set_iv nettle_gost28147_cnt_set_iv +#define gost28147_cnt_crypt nettle_gost28147_cnt_crypt + #define GOST28147_KEY_SIZE 32 #define GOST28147_BLOCK_SIZE 8
@@ -102,6 +106,26 @@ gost28147_encrypt_for_cfb(struct gost28147_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src);
+struct gost28147_cnt_ctx { + struct gost28147_ctx ctx; + size_t bytes; + uint32_t iv[2]; + uint8_t buffer[GOST28147_BLOCK_SIZE]; +}; + +void +gost28147_cnt_init(struct gost28147_cnt_ctx *ctx, + const uint8_t *key, + const struct gost28147_param *param); + +void +gost28147_cnt_set_iv(struct gost28147_cnt_ctx *ctx, + const uint8_t *iv); + +void +gost28147_cnt_crypt(struct gost28147_cnt_ctx *ctx, + size_t length, uint8_t *dst, + const uint8_t *src); #ifdef __cplusplus } #endif diff --git a/testsuite/gost28147-test.c b/testsuite/gost28147-test.c index 939bedee9c66..42441969a467 100644 --- a/testsuite/gost28147-test.c +++ b/testsuite/gost28147-test.c @@ -1,6 +1,7 @@ #include "testutils.h" #include "gost28147.h" #include "cfb.h" +#include "macros.h"
static void test_gost28147(const struct gost28147_param *param, @@ -104,6 +105,82 @@ test_gost28147_cfb(const struct gost28147_param *param, free(data); }
+static void +test_gost28147_cnt(const struct gost28147_param *param, + const struct tstring *key, + const struct tstring *start_iv, + const struct tstring *end_iv, + const struct tstring *cleartext, + const struct tstring *ciphertext) +{ + struct gost28147_cnt_ctx ctx; + uint8_t *data = xalloc(cleartext->length); + uint8_t iv[GOST28147_BLOCK_SIZE]; + size_t length; + + ASSERT (cleartext->length == ciphertext->length); + length = cleartext->length; + + gost28147_cnt_init(&ctx, key->data, param); + gost28147_cnt_set_iv(&ctx, start_iv->data); + gost28147_cnt_crypt(&ctx, length, data, cleartext->data); + + if (!MEMEQ(length, data, ciphertext->data)) + { + fprintf(stderr, "Encrypt failed:\nInput:"); + tstring_print_hex(cleartext); + fprintf(stderr, "\nOutput: "); + print_hex(length, data); + fprintf(stderr, "\nExpected:"); + tstring_print_hex(ciphertext); + fprintf(stderr, "\n"); + FAIL(); + } + + LE_WRITE_UINT32(iv + 0, ctx.iv[0]); + LE_WRITE_UINT32(iv + 4, ctx.iv[1]); + + if (!MEMEQ(GOST28147_BLOCK_SIZE, iv, end_iv->data)) + { + fprintf(stderr, "Encrypt failed IV check:\nOutput:"); + print_hex(GOST28147_BLOCK_SIZE, iv); + fprintf(stderr, "\nExpected:"); + tstring_print_hex(end_iv); + fprintf(stderr, "\n"); + FAIL(); + } + + gost28147_cnt_init(&ctx, key->data, param); + gost28147_cnt_set_iv(&ctx, start_iv->data); + gost28147_cnt_crypt(&ctx, length, data, data); + + if (!MEMEQ(length, data, cleartext->data)) + { + fprintf(stderr, "Decrypt failed:\nOutput:"); + print_hex(length, data); + fprintf(stderr, "\nExpected:"); + tstring_print_hex(cleartext); + fprintf(stderr, "\n"); + FAIL(); + } + + LE_WRITE_UINT32(iv + 0, ctx.iv[0]); + LE_WRITE_UINT32(iv + 4, ctx.iv[1]); + + if (!MEMEQ(GOST28147_BLOCK_SIZE, iv, end_iv->data)) + { + fprintf(stderr, "Decrypt failed IV check:\nInput:"); + fprintf(stderr, "\nOutput: "); + print_hex(GOST28147_BLOCK_SIZE, iv); + fprintf(stderr, "\nExpected:"); + tstring_print_hex(end_iv); + fprintf(stderr, "\n"); + FAIL(); + } + + free(data); +} + void test_main(void) { /* Examples from GOST R 34.11-94 standard */ @@ -259,4 +336,88 @@ void test_main(void) "e229b58607397d78 8e5a8f834ce73d68 3ee502e6644f5eb4 4977f0c0fa6fc8fb" "9f846f55fb305e89 93a9f3a6a3d726bb d8a8d9951dfefcd7 a893662f04530664" "7f3129aeb79fbac4 6d68d12432f411")); + + test_gost28147_cnt(&gost28147_param_CryptoPro_A, + SHEX("599f84bac3f3d2f1 60e1e3f26a961af9 9c48b24ebcbbbf7c d8f3accd968d286a"), + SHEX("8dafa8d158ed058d"), + SHEX("f1a0e3294f65be75"), + SHEX("90a23966ae01b9a3 524ec8ed6cdd8830"), + SHEX("6e7262cce3593690 833afea91bc9bece")); + test_gost28147_cnt(&gost28147_param_CryptoPro_A, + SHEX("1b5ddb77cff9ec95 5ecc679f5d28ad4a 27f432c6b2cbb145 6a88140c9b9b5f48"), + SHEX("71588ce155f4f6b3"), + SHEX("6aeaa0a59e10e0ce"), + SHEX("3d0b69f7a8e4fc99 222eeed16312fea8 9dcb6c4d488ce8bd 8b60f1bf7be379d5" + "2b259713ef35daf4 bc77ceeae93fa4b6 01d5732958dad767 17ace4752f5723ac" + "9621c7622df732b5 445f72b15fba1b1e db4a098c9261a2b0 4968e5b3a28f134b" + "f54d84daaba0b6d1 5a6319e8a209f676 6f9b480a155db720 219a2eb96dfa1ec2" + "0eef15ab5901fe43 90f262ca4a9a4838 ab6f9d21b3ada760 46e3efd0e31dc5e1" + "b8a1e29920c576cc aa8aa94555a07800 64decf5bdf2648cd ba8ab5fbfd4ad5c4" + "e043a67190a48bca 2e887bacb2dcf201 cbda6e9127284488 9ad212f1a6f5b761" + "ce7962523ce61473 d1419250bddc3bd0 a7118c3ae42df252 d32f7c8e54904e23" + "aeb3a0f3257e66aa 0f6f817277bbd347 e805ffe15bc93750 334917afab1de115" + "f2e5985e2d051f0d 5597edff5ee00fc3 9cbd82c206be4566 ae33be2848e92d1a" + "e6658edf7603734b c08071f9acbaa0b0 191a0ad435128876 05758f7cb5f01975" + "6d05cb0dbc8de9f0 d4db3c3c298e2c32 1df7b649cfdb63ee 3cfa33736fe4974e" + "2fc94c5c65feeafb c6ddc11c473ff450 2fde1b5b0b16cab6 4644f2c10da11da6" + "dbf03db16c053185 8e74aef23926f7c1 e74cdd9d40b8f3c5 c216646baadb4b82" + "5cd302d38f26798d b0787019580cb431 88441c916ff45239 a8f5c01bfef20e4b" + "ac0ac27e9c9beb5d 4e4f42d8710a9727 031496a63d04ea9f 1414274cd9a2895f" + "654ae19d2cb8f8d4 8f2a5736cc069c2c c51316dffcae2216 a82b716f1db34754" + "3f2d0a689f2ef690 d8a12109d497b97b 7f9b6aedd1f0e3b6 28c7628200c938a1" + "8278ce87c853ac4f 2e31b9507f36004a 32e6d8bb59450e91 1b38a9bcb95e6c6a" + "9c03011cdee81f1e e3de25a25679e1bd 58c493e6d08a4d08 abf7aac37dc1ee68" + "37bc780b19682b2b 2e6dc46faa3bc619 cbf158b9608545ae 5297ba2432137216" + "6e7bc198acb1edb4 cc6ccf45fc508980 8e7aa4d364506337 c96cf1c43dfbde5a" + "5ca82135e62e8c2a 3c1217799a0d2e79 eb671f2bf86ecac1 fa45189edf6ae6cb" + "e95cc309af935813 bf90848775d68228 8de72fa3fb97742a 730482067669b10b" + "19fcaeb3dd2ae5c1 05d88095229071fc c29242fdf170b468 88a49e0a244013c8" + "a2564f39e606f1dc f5130ead9c8bafe9 e38872ffa06dda08 70b92e83c5bb32a5" + "74c7fb7b76af02bb 2bb85e6502fe0ea0 99ce013b35e1b022 e594bddd8ebbf675" + "bfbfee7ab158b481 b8393eb61ededa1b d5f7dd7d659caa56 93b8af4853c722e4" + "1cdfe979b42089cc 2a792c09be78cfcc f290d665c529fcda 69fcc0d67099613f" + "6002d81222c834c6 3bb3c233a15c8f4c d15272f242058e18 1f16dab853a15f01" + "321b90b3539bd085 612d17ed0aa4a527 09757cbc30f75e59 9a07968428864ba7" + "223528c7ed0dc3ce 98cc2decd498098e 525f2b9a13be9916 73d11f81e5a20878" + "cb0c20d4a5ea4b5b 955a929a52"), + SHEX("8ecd8fc8ace11548 2dae248ac7fbba0f 1d8a95a243efcbdc 5957a7c70ee3e2b9" + "0d862962cb834d07 0c40d47b2ecababf 4a603b3198c88847 d982abfc8f48e246" + "abd3a1ab8a05228c f4ec9a1e76ab1a60 d9256bb856e5b2ea 10f36204325eaa3b" + "7b57bc3b8b4347f2 d5037e5101ff7728 ca90a3fe7e2e7016 751844f01b8505ea" + "e321f72686763c67 9dfcbc107f77e4ed d312f883001f4b92 95925cf35af3b7d0" + "a95ff218c46662c1 840e66e8807d1ff0 ba019b71ae93cc27 54349abdcaee5209" + "929db0d5d9ba2fb9 96dcfabdceea1a7b 9a1d13a711e29a64 f6d3eec633b76eef" + "259e1e7ce31f2c6e a9c0f8c1bf3bf834 039ba1405b0c3c09 669d63e2e2048f06" + "847468b25c3b4cad 0b3f03b3078a64a7 3656263966dae96d 1bd588e85caf5a4c" + "49f7f5b778f0deec cd16239e8c13be6b 6f9b07e5bbcc3a1b 6f43dfff462aae47" + "19189a2509c92440 0c4ba7da5e0deefa 62458ecc2f23081d 92f0fe820fd71160" + "7e0b0b75f4f53bc0 a4e872a5b6fa5aad 5a4f39b5a212960a 3284b2a106685657" + "97a37b2261765d30 1a31ab9906c51a96 cfcf14ffb2c4cc2b bf0c9d918f795bbc" + "a96b916ab4935c7b 5dc28a75c0c108fa 99f94d5e0c066460 a9014a340f338495" + "6930c11c36f8fc30 23b271e5524d121a c9beeec9cb0185f3 db30f941a940b006" + "2977cdc5ec580248 8353446ad2ca05d8 5a08eba9f4e6c79d d57b740b31b7a557" + "7c7afd1a0ed79741 bfddc6196c778c18 525783ba7125ee39 bbe243a014dc0e84" + "b42bde3ee536b7a2 929805b896e5d08c 089335c281e0fc59 71e244495ddafb9c" + "aa709f43a8a5d967 d98fa31ebe0eecdf 122b6ae71c1217e7 c46d50c9527ad5e8" + "7fbc0715acdb9366 b1f0a77b2fe9ecd0 47695987f14c3e4b 9b117913e496f656" + "046e0b33fc40f6c7 c143b1bf0eb387fd 0b1c63463ad3a017 5925946c9c3d0c81" + "ce82724228f9376a 6de412f421aaf7fe 2755401a14c3395b bf63c25f101f1425" + "d0cef3144813a50b 4d38cf0d34c00a11 b4b572c84bc26fe7 9d93f7dfb843727e" + "da3e201fbc212ace 00fa969f3de58896 ef2984df6c1c96d8 5847aa92f307e5fb" + "afea957e0b71cd81 0fb70a598f314dd1 c3f32f705c591897 af77955eaf400612" + "816186084ebc8946 072e5b10aa12f0a7 84e29a08f1de59e3 0e474bffc3c918af" + "959c672ade8a7a99 04c4b8974c042971 05dab3d6db6c71e6 e803bf947dde3dc8" + "44fa7d62b43603ee 365264b4856dd578 f06f672d0ee02c88 9b55192940f68c12" + "bb2c839640c036f5 77ff708c75920bad 059b7ea2fca9d164 768213ba225e330e" + "2670a9be7428f5e2 c496ee3abc97a62c 2ae0648d35c61aca f492fac3f11f98e4" + "4388693a09bf63e5 96290b9b6223148a 95e41c5c0aa9c5b9 6f4f2b256f741e18" + "d5fe277d3f6e552c 67e6deb5ccc02dff c4e40621a5c8d3d6 6ca1c3fb8892b11d" + "90e135059b296dba f1f41e232e")); + + test_gost28147_cnt(&gost28147_param_TC26_Z, + SHEX("599f84bac3f3d2f1 60e1e3f26a961af9 9c48b24ebcbbbf7c d8f3accd968d286a"), + SHEX("8dafa8d158ed058d"), + SHEX("626804b2e7ba1be2"), + SHEX("90a23966ae01b9a3 524ec8ed6cdd8830"), + SHEX("e8b14fc730dc25bb 36ba643c17dbff99")); }
From: Dmitry Eremin-Solenikov dbaryshkov@gmail.com
Signed-off-by: Dmitry Eremin-Solenikov dbaryshkov@gmail.com --- gost28147.c | 107 +++++++++++++++++++++++++++++++++++-- gost28147.h | 47 ++++++++++++++++ testsuite/gost28147-test.c | 102 +++++++++++++++++++++++++++++++++++ 3 files changed, 253 insertions(+), 3 deletions(-)
diff --git a/gost28147.c b/gost28147.c index f718a202a56b..c7f5f1413695 100644 --- a/gost28147.c +++ b/gost28147.c @@ -36,6 +36,7 @@ #include <string.h>
#include "macros.h" +#include "nettle-write.h" #include "gost28147.h" #include "gost28147-internal.h" #include "memxor.h" @@ -2286,15 +2287,21 @@ static void gost28147_key_mesh_cryptopro(struct gost28147_ctx *ctx) ctx->key_count = 0; }
-void -gost28147_set_key(struct gost28147_ctx *ctx, const uint8_t *key) +static void +_gost28147_set_key(struct gost28147_ctx *ctx, const uint8_t *key) { unsigned i;
- assert(key); for (i = 0; i < 8; i++, key += 4) ctx->key[i] = LE_READ_UINT32(key); ctx->key_count = 0; +} + +void +gost28147_set_key(struct gost28147_ctx *ctx, const uint8_t *key) +{ + assert(key); + _gost28147_set_key(ctx, key); gost28147_set_param(ctx, &gost28147_param_TC26_Z); }
@@ -2457,3 +2464,97 @@ gost28147_cnt_crypt(struct gost28147_cnt_ctx *ctx, ctx->bytes = block_size - length; } } + +void +gost28147_imit_init(struct gost28147_imit_ctx *ctx) +{ + memset(ctx->state, 0, GOST28147_BLOCK_SIZE); + ctx->index = 0; + ctx->count = 0; + gost28147_set_param(&ctx->cctx, &gost28147_param_TC26_Z); /* Default */ +} + +void +gost28147_imit_set_key(struct gost28147_imit_ctx *ctx, + size_t length, + const uint8_t *key) +{ + assert(length == GOST28147_IMIT_KEY_SIZE); + assert(key); + + _gost28147_set_key(&ctx->cctx, key); + /* Do not reset param here */ +} + +void +gost28147_imit_set_nonce(struct gost28147_imit_ctx *ctx, const uint8_t *nonce) +{ + ctx->state[0] = LE_READ_UINT32(nonce + 0); + ctx->state[1] = LE_READ_UINT32(nonce + 4); +} + +void +gost28147_imit_set_param(struct gost28147_imit_ctx *ctx, + const struct gost28147_param *param) +{ + assert(param); + gost28147_set_param(&ctx->cctx, param); +} + +static void +gost28147_imit_compress(struct gost28147_imit_ctx *ctx, + const uint8_t *data) +{ + uint32_t l, r; + + if (ctx->cctx.key_meshing && ctx->cctx.key_count == 1024) + gost28147_key_mesh_cryptopro(&ctx->cctx); + + r = LE_READ_UINT32(data + 0) ^ ctx->state[0]; + l = LE_READ_UINT32(data + 4) ^ ctx->state[1]; + + GOST_ENCRYPT_ROUND(l, r, ctx->cctx.key[0], ctx->cctx.key[1], ctx->cctx.sbox); + GOST_ENCRYPT_ROUND(l, r, ctx->cctx.key[2], ctx->cctx.key[3], ctx->cctx.sbox); + GOST_ENCRYPT_ROUND(l, r, ctx->cctx.key[4], ctx->cctx.key[5], ctx->cctx.sbox); + GOST_ENCRYPT_ROUND(l, r, ctx->cctx.key[6], ctx->cctx.key[7], ctx->cctx.sbox); + GOST_ENCRYPT_ROUND(l, r, ctx->cctx.key[0], ctx->cctx.key[1], ctx->cctx.sbox); + GOST_ENCRYPT_ROUND(l, r, ctx->cctx.key[2], ctx->cctx.key[3], ctx->cctx.sbox); + GOST_ENCRYPT_ROUND(l, r, ctx->cctx.key[4], ctx->cctx.key[5], ctx->cctx.sbox); + GOST_ENCRYPT_ROUND(l, r, ctx->cctx.key[6], ctx->cctx.key[7], ctx->cctx.sbox); + + ctx->state[0] = r; + ctx->state[1] = l; + + ctx->cctx.key_count += 8; +} + +void +gost28147_imit_update(struct gost28147_imit_ctx *ctx, + size_t length, + const uint8_t *data) +{ + MD_UPDATE(ctx, length, data, gost28147_imit_compress, ctx->count++); +} + +void +gost28147_imit_digest(struct gost28147_imit_ctx *ctx, + size_t length, + uint8_t *digest) +{ + assert(length <= GOST28147_IMIT_DIGEST_SIZE); + const uint8_t zero[GOST28147_IMIT_BLOCK_SIZE] = { 0 }; + + if (ctx->index) + { + assert(ctx->index < GOST28147_IMIT_BLOCK_SIZE); + gost28147_imit_update(ctx, GOST28147_IMIT_BLOCK_SIZE - ctx->index, zero); + } + + if (ctx->count == 1) + { + gost28147_imit_update(ctx, GOST28147_IMIT_BLOCK_SIZE, zero); + } + + _nettle_write_le32(length, digest, ctx->state); + gost28147_imit_init(ctx); +} diff --git a/gost28147.h b/gost28147.h index 08189067983c..6d380dff190e 100644 --- a/gost28147.h +++ b/gost28147.h @@ -60,6 +60,13 @@ extern "C" { #define gost28147_cnt_set_iv nettle_gost28147_cnt_set_iv #define gost28147_cnt_crypt nettle_gost28147_cnt_crypt
+#define gost28147_imit_init nettle_gost28147_imit_init +#define gost28147_imit_set_key nettle_gost28147_imit_set_key +#define gost28147_imit_set_nonce nettle_gost28147_imit_set_nonce +#define gost28147_imit_set_param nettle_gost28147_imit_set_param +#define gost28147_imit_update nettle_gost28147_imit_update +#define gost28147_imit_digest nettle_gost28147_imit_digest + #define GOST28147_KEY_SIZE 32 #define GOST28147_BLOCK_SIZE 8
@@ -126,6 +133,46 @@ void gost28147_cnt_crypt(struct gost28147_cnt_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src); + +#define GOST28147_IMIT_DIGEST_SIZE 4 +#define GOST28147_IMIT_BLOCK_SIZE GOST28147_BLOCK_SIZE +#define GOST28147_IMIT_KEY_SIZE GOST28147_KEY_SIZE + +struct gost28147_imit_ctx +{ + struct gost28147_ctx cctx; + uint64_t count; /* Block count */ + uint8_t block[GOST28147_IMIT_BLOCK_SIZE]; /* Block buffer */ + unsigned index; /* Into buffer */ + uint32_t state[GOST28147_IMIT_BLOCK_SIZE/4]; +}; + +void +gost28147_imit_init(struct gost28147_imit_ctx *ctx); + +void +gost28147_imit_set_key(struct gost28147_imit_ctx *ctx, + size_t length, + const uint8_t *key); + +void +gost28147_imit_set_nonce(struct gost28147_imit_ctx *ctx, + const uint8_t *nonce); + +void +gost28147_imit_set_param(struct gost28147_imit_ctx *ctx, + const struct gost28147_param *param); + +void +gost28147_imit_update(struct gost28147_imit_ctx *ctx, + size_t length, + const uint8_t *data); + +void +gost28147_imit_digest(struct gost28147_imit_ctx *ctx, + size_t length, + uint8_t *digest); + #ifdef __cplusplus } #endif diff --git a/testsuite/gost28147-test.c b/testsuite/gost28147-test.c index 42441969a467..5682cf937e25 100644 --- a/testsuite/gost28147-test.c +++ b/testsuite/gost28147-test.c @@ -181,6 +181,34 @@ test_gost28147_cnt(const struct gost28147_param *param, free(data); }
+static void +test_gost28147_imit(const struct gost28147_param *param, + const struct tstring *key, + const struct tstring *cleartext, + const struct tstring *imit) +{ + struct gost28147_imit_ctx ctx; + uint8_t data[GOST28147_IMIT_DIGEST_SIZE]; + + gost28147_imit_init(&ctx); + gost28147_imit_set_key(&ctx, key->length, key->data); + gost28147_imit_set_param(&ctx, param); + gost28147_imit_update(&ctx, cleartext->length, cleartext->data); + gost28147_imit_digest(&ctx, imit->length, data); + + if (!MEMEQ(imit->length, data, imit->data)) + { + fprintf(stderr, "IMIT failed:\nInput:"); + tstring_print_hex(cleartext); + fprintf(stderr, "\nOutput: "); + print_hex(imit->length, data); + fprintf(stderr, "\nExpected:"); + tstring_print_hex(imit); + fprintf(stderr, "\n"); + FAIL(); + } +} + void test_main(void) { /* Examples from GOST R 34.11-94 standard */ @@ -420,4 +448,78 @@ void test_main(void) SHEX("626804b2e7ba1be2"), SHEX("90a23966ae01b9a3 524ec8ed6cdd8830"), SHEX("e8b14fc730dc25bb 36ba643c17dbff99")); + + /* From Open/LibreSSL testsuite */ + test_gost28147_imit(&gost28147_param_CryptoPro_A, + SHEX("9d05b79e90cad00a 2cdad22ef4e86f5c f5dc37681985b3bf aa18c1c3050a91a2"), + SHEX("b5a1f0e3 ce2f021d 67619434 5c41e36e"), + SHEX("f81f08a3")); + + test_gost28147_imit(&gost28147_param_CryptoPro_A, + SHEX("80d9a0dc21f93040 75fe491b9e719091 7888216039e7c92b fb551df4dd2b0a01"), + SHEX("d6cf31969ca1fbd6 8da3dd01d988c02f bc46c73ae4218696 8de2cab637a2e1a8" + "7ea7792ea456757f 3e558b43ae65dfaa 42b600a661030dd3 4102272395799b34" + "81a986b5a790e2ae c42fc38e325613fa 4d4e9f15757e74dc 322dee4d67709f62" + "b9c4db2484cc167b da22f7c5f3933573 c6031c77a5f27656 b495d47e0d20c66e" + "ee8f2548ff7e013a b41faa35c033589c b5ba654bd35114ec 61cee4ba49ba3932" + "abce8172ceabedd4 d219878592fa6434 d886f48a083cdeee 97929269ba9b5f7a" + "03c15d43028cbed2 467281407d689845 0b54271caf8042e4 d5d4e4a298078f03" + "f52c8c88ca5adee4 9fb15f82ff206752 85844fc8fea79eae 1cfab875d3f79f0d" + "da2de6cc866ba414 65c3f915bc87f5ae 8c10d4ce5b9ce2dd 4203098747ed5dd0" + "7a694cfa437dbf07 856aee68e67a57b2 208d80f2916f5c07 8ce46a4990858b77" + "29561c5ea93fab8b 79a36f6b34cb61f6 e692d1489e11a282 c04e23d2150d8dff" + "fa179d81b8bcd75b 08812040c03c068b 1a880b4b7b31f5d4 4e09d14d0d7f45d1" + "0935bace65ddf2b8 fb7abcc44bc875da 6bce3de894cc236f b03b4f7d07b90f62" + "927eda7050ced328 121100eb8d637078 a87b76abc640c04e 80ddf0fe8372564c" + "094cf17272862631 c3c2dc8ec7f435ec 17066347498847af b3384f7e4495b5bb" + "1dbd5a915bd01adf 0d0b50d8e20ec500 2d5b2919aa2b64c5 40314811bc04d1cf" + "6df9a52f4ac982fa 59e1fcab1c33260a 5feff206d8d37e16 58167873aebaebe5" + "3db20ab3322d14a4 fa3f1f43f97ba943 9818940707e51934 a8165f7167aa29e5" + "faf083061d9dfcfe fe8cb5b2a9e7a040 60b6719eab5b83b9 0c2b582380099e5d" + "947d4076a916969e 83e00deca0ec762a b7a0ffb8504c5bc6 8b0a652efeb4409a" + "01d8c6a3ab99a2c5 0c08c4b7ee4d1dc4 0815d0dbaa634f31 eb149743bdc19408" + "e6de439f950b967e 7f3c68ba6fc4c935 2bc40eda1f916864 633473be5775b9ed" + "f72d3b0521932848 969597a0d27d78bb 6a498f76557463b9 c5361225bf03828f" + "f0f680bb33b4f417 271cf34c10a3e4d1 55d968214e5a8367 bff83c7d4e62d328" + "a7266fe9eec20b2d 0384b1ffd6681fb6 f2e40fda2dee5f6e 21c8e1fcad6b0e04" + "7dafc23ba5689b0c f356f3da8dc87d39 dcd599c60110ce42 1bac48dc97780aec" + "b38f4735a36a64b2 8e63692266ae2ee0 88f9403cc9a25761 f6adf0dc90563f06" + "9b7dbdc28102abb8 1509884aff2f31bf 5efa6a7ef6c5a7f7 d5ab55acae0d8c8d" + "7f4b25bb32ff1133 2e373769961517b1 1749e09a9cd95b8d 58a31d9287f880b9" + "bd5aec40e1003360 e486166d6181f228 6aa7ce3f95ae43ca e13f81747e1c4717" + "95c660da7477d99f fa92b4bee1239818 956303134c1a2d41 cde484f7e638efff" + "95b2e87c8f58b5b5 ed277f3c18abbe7f 4fe2351571b76f85 389b88f69c8d43b5" + "589ef2d196beb7ad 1aa098"), + SHEX("90f2119a")); + + test_gost28147_imit(&gost28147_param_CryptoPro_A, + SHEX("a9b637cc6d9b2f25 b0df47045068b027 4127586abd0a6e50 2fc6fcc03e2942a5"), + SHEX("1debe6790a5900e6 8e5c"), + SHEX("317c16e4")); + + test_gost28147_imit(&gost28147_param_CryptoPro_A, + SHEX("b06c48230a6ef4ec 27980123a7d8bf60 89efade88f79148c 185c9adaef0bdda0"), + SHEX("ef068f14c904"), + SHEX("e972aebf")); + + test_gost28147_imit(&gost28147_param_CryptoPro_B, + SHEX("33d3ef0119950e15 a16975ae56271779 6347ab629d4af034 d31e6974ec3148fc"), + SHEX("02f8ec2b4d1fbc7c 6e47e387227541a7"), + SHEX("f5551f28")); + + test_gost28147_imit(&gost28147_param_CryptoPro_A, + SHEX("423581910ba999ff d943f8c619551f2f 2d4540201e1d327a b1076b4f4590d980"), + SHEX("f3b229d27a370312"), + SHEX("6e15fae8")); + + test_gost28147_imit(&gost28147_param_CryptoPro_A, + SHEX("26cbb9f00c629faa 4a1db63009015689 66d4e40efef6106b 6ce8043ae3614b19"), + SHEX(""), + SHEX("00000000")); + + test_gost28147_imit(&gost28147_param_TC26_Z, + SHEX("9d05b79e90cad00a 2cdad22ef4e86f5c f5dc37681985b3bf aa18c1c3050a91a2"), + SHEX("b5a1f0e3 ce2f021d 67619434 5c41e36e"), + SHEX("03e56766")); + }
nettle-bugs@lists.lysator.liu.se