diff --git a/CMakeLists.txt b/CMakeLists.txt index 36613f1c7..ed58440fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.10 FATAL_ERROR) project(gost-engine LANGUAGES C) include(GNUInstallDirs) @@ -10,36 +10,50 @@ enable_testing() find_package(OpenSSL 1.1.1 REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) -if (CMAKE_C_COMPILER_ID MATCHES "Clang") - add_compile_options(-O2 -Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -ggdb -Qunused-arguments) -elseif(CMAKE_C_COMPILER_ID MATCHES "GNU") - add_compile_options(-O2 -Werror -Wall -Wno-unused-parameter -Wno-unused-function -Wno-missing-braces -ggdb) -elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC") - add_definitions(-D_CRT_SECURE_NO_WARNINGS) - add_definitions(-D_CRT_DEPRECATED_NO_WARNINGS) - add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) - add_compile_options(/MP /WX /W4 /wd4100 /wd4267 /wd4206 /wd4706 /wd4244 /wd4115) +if(NOT CMAKE_BUILD_TYPE) + if (ASAN) + set(CMAKE_BUILD_TYPE Debug) + else() + set(CMAKE_BUILD_TYPE Release) + endif() endif() -if (ASAN) - message(STATUS "address sanitizer enabled") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -g3 -fno-omit-frame-pointer") +set(CMAKE_C_FLAGS_RELEASE "-O2") + +if(CMAKE_C_COMPILER_ID MATCHES "Clang") + set(GCC_COMPATIBLE_COMPILER 1) + set(CMAKE_C_FLAGS_DEBUG "-ggdb") + add_compile_options(-Werror -Wall -Qunused-arguments) +ELSEif(CMAKE_C_COMPILER_ID MATCHES "GNU|ICC") + set(GCC_COMPATIBLE_COMPILER 1) + set(CMAKE_C_FLAGS_DEBUG "-ggdb") + add_compile_options(-Werror -Wall) +ELSEif(CMAKE_C_COMPILER_ID MATCHES "MSVC") + set(MSVC_COMPATIBLE_COMPILER 1) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + add_compile_options(/MP /WX /W4 /wd4100 /wd4267 /wd4706) +ENDif() + +if(ASAN) + message(STATUS "address sanitizer enabled") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -g3 -fno-omit-frame-pointer") endif() -set(CMAKE_C_STANDARD 90) +set(CMAKE_C_STANDARD 11) CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME_C) CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_CLOCK_GETTIME_RT) + if(HAVE_CLOCK_GETTIME_RT AND NOT HAVE_CLOCK_GETTIME_C) - set(CLOCK_GETTIME_LIB rt) + set(CLOCK_GETTIME_LIB rt) endif() include (TestBigEndian) TEST_BIG_ENDIAN(IS_BIG_ENDIAN) if(IS_BIG_ENDIAN) - message(STATUS "BIG_ENDIAN") + message(STATUS "BIG_ENDIAN") else() - message(STATUS "LITTLE_ENDIAN") - add_definitions(-DL_ENDIAN) + message(STATUS "LITTLE_ENDIAN") + add_definitions(-DL_ENDIAN) endif() set(BIN_DIRECTORY bin) @@ -48,209 +62,256 @@ set(BIN_DIRECTORY bin) set(GOST_SOVERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}") set(OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BIN_DIRECTORY}) - -#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY}) # Remove when https://gitlab.kitware.com/cmake/cmake/issues/18525 is addressed set(OPENSSL_ENGINES_DIR "" CACHE PATH "OpenSSL Engines Directory") if ("${OPENSSL_ENGINES_DIR}" STREQUAL "") - include(FindPkgConfig) - pkg_get_variable(OPENSSL_ENGINES_DIR libcrypto enginesdir) - if ("${OPENSSL_ENGINES_DIR}" STREQUAL "") - message( FATAL_ERROR "Unable to discover the OpenSSL engines directory. Provide the path using -DOPENSSL_ENGINES_DIR" ) - endif() + include(FindPkgConfig) + pkg_get_variable(OPENSSL_ENGINES_DIR libcrypto enginesdir) + if ("${OPENSSL_ENGINES_DIR}" STREQUAL "") + message( FATAL_ERROR "Unable to discover the OpenSSL engines directory. Provide the path using -DOPENSSL_ENGINES_DIR" ) + endif() endif() set(GOST_89_SOURCE_FILES - gost89.c - gost89.h - ) + gost89.c + gost89.h +) set(GOST_HASH_SOURCE_FILES - gosthash.c - gosthash.h - ) + gosthash.c + gosthash.h +) set(GOST_HASH_2012_SOURCE_FILES - gosthash2012.c - gosthash2012.h - gosthash2012_const.h - gosthash2012_precalc.h - gosthash2012_ref.h - gosthash2012_sse2.h - ) + gosthash2012.c + gosthash2012.h + gosthash2012_const.h + gosthash2012_precalc.h + gosthash2012_ref.h + gosthash2012_sse2.h +) set(GOST_GRASSHOPPER_SOURCE_FILES - gost_grasshopper.h - gost_grasshopper_core.h - gost_grasshopper_core.c - gost_grasshopper_defines.h - gost_grasshopper_defines.c - gost_grasshopper_math.h - gost_grasshopper_galois_precompiled.c - gost_grasshopper_precompiled.c - gost_grasshopper_cipher.h - gost_grasshopper_cipher.c - ) + gost_grasshopper.h + gost_grasshopper_core.h + gost_grasshopper_core.c + gost_grasshopper_defines.h + gost_grasshopper_defines.c + gost_grasshopper_math.h + gost_grasshopper_galois_precompiled.c + gost_grasshopper_precompiled.c + gost_grasshopper_cipher.h + gost_grasshopper_cipher.c +) set(GOST_CORE_SOURCE_FILES - e_gost_err.c - e_gost_err.h - gost_asn1.c - gost_crypt.c - gost_ctl.c - gost_eng.c - gost_keywrap.c - gost_keywrap.h - gost_lcl.h - gost_params.c - gost_keyexpimp.c - ) + e_gost_err.c + e_gost_err.h + gost_asn1.c + gost_crypt.c + gost_ctl.c + gost_eng.c + gost_keywrap.c + gost_keywrap.h + gost_lcl.h + gost_params.c + gost_keyexpimp.c +) set(GOST_EC_SOURCE_FILES - gost_ec_keyx.c - gost_ec_sign.c - ) + gost_ec_keyx.c + gost_ec_sign.c +) set (GOST_OMAC_SOURCE_FILES - gost_omac.c - gost_omac_acpkm.c - ) + gost_omac.c + gost_omac_acpkm.c +) set(GOST_LIB_SOURCE_FILES - ${GOST_89_SOURCE_FILES} - ${GOST_HASH_SOURCE_FILES} - ${GOST_HASH_2012_SOURCE_FILES} - ${GOST_GRASSHOPPER_SOURCE_FILES} - ${GOST_EC_SOURCE_FILES} - ${GOST_OMAC_SOURCE_FILES} - ) + ${GOST_CORE_SOURCE_FILES} + ${GOST_89_SOURCE_FILES} + ${GOST_HASH_SOURCE_FILES} + ${GOST_HASH_2012_SOURCE_FILES} + ${GOST_GRASSHOPPER_SOURCE_FILES} + ${GOST_EC_SOURCE_FILES} + ${GOST_OMAC_SOURCE_FILES} +) set(GOST_ENGINE_SOURCE_FILES - ${GOST_CORE_SOURCE_FILES} - gost_ameth.c - gost_md.c - gost_md2012.c - gost_pmeth.c - gost_omac.c - gost_omac_acpkm.c - ) - -add_executable(test_digest test_digest.c) + ${GOST_CORE_SOURCE_FILES} + gost_ameth.c + gost_md.c + gost_md2012.c + gost_pmeth.c + gost_omac.c + gost_omac_acpkm.c +) + +#core library +add_library(gost_core STATIC ${GOST_LIB_SOURCE_FILES}) +set_target_properties(gost_core PROPERTIES + POSITION_INDEPENDENT_CODE ON +) +#engine +add_library(gost_engine SHARED ${GOST_ENGINE_SOURCE_FILES}) +set_target_properties(gost_engine PROPERTIES + PREFIX "" OUTPUT_NAME "gost" +) +set_target_properties(gost_engine PROPERTIES + VERSION ${GOST_SOVERSION} SOVERSION ${GOST_SOVERSION} +) +target_link_libraries(gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY}) + +if(WIN32) + target_link_libraries(gost_engine wsock32 ws2_32) +endif() + +#tests +add_executable(test_digest test_digest.c ansi_terminal.c) target_link_libraries(test_digest gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY}) add_test(NAME digest - COMMAND test_digest) + COMMAND test_digest +) -add_executable(test_curves test_curves.c) +add_executable(test_curves test_curves.c ansi_terminal.c) target_link_libraries(test_curves gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY}) add_test(NAME curves - COMMAND test_curves) + COMMAND test_curves +) -add_executable(test_params test_params.c) +add_executable(test_params test_params.c ansi_terminal.c) target_link_libraries(test_params gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY}) add_test(NAME parameters - COMMAND test_params) + COMMAND test_params +) -add_executable(test_sign test_sign.c) +add_executable(test_sign test_sign.c ansi_terminal.c) target_link_libraries(test_sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY}) add_test(NAME sign/verify - COMMAND test_sign) - -add_executable(test_tls test_tls.c) -target_link_libraries(test_tls gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY}) -add_test(NAME TLS - COMMAND test_tls) - -add_executable(test_context test_context.c) + COMMAND test_sign +) + +if(NOT MSVC) + add_executable(test_tls test_tls.c ansi_terminal.c) + target_link_libraries(test_tls gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY}) + add_test(NAME TLS + COMMAND test_tls + ) +ELSE() + message(WARNING "test_tls build is skipped. Windows platform doesn't support some POSIX API ") +ENDif() + +add_executable(test_context test_context.c ansi_terminal.c) target_link_libraries(test_context gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY}) add_test(NAME context - COMMAND test_context) + COMMAND test_context +) -add_executable(test_grasshopper test_grasshopper.c) +add_executable(test_grasshopper test_grasshopper.c ansi_terminal.c) target_link_libraries(test_grasshopper gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY}) add_test(NAME grasshopper - COMMAND test_grasshopper) + COMMAND test_grasshopper +) + +add_executable(test_keyexpimp test_keyexpimp.c ansi_terminal.c) -add_executable(test_keyexpimp test_keyexpimp.c) -#target_compile_definitions(test_keyexpimp PUBLIC -DOPENSSL_LOAD_CONF) target_link_libraries(test_keyexpimp gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY}) add_test(NAME keyexpimp - COMMAND test_keyexpimp) + COMMAND test_keyexpimp +) add_executable(test_gost89 test_gost89.c) target_link_libraries(test_gost89 gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY}) add_test(NAME gost89 - COMMAND test_gost89) + COMMAND test_gost89 +) if(NOT ASAN) -add_test(NAME engine - COMMAND perl run_tests - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test) -set_tests_properties(engine PROPERTIES ENVIRONMENT - "OPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR};OPENSSL_ENGINES=${OUTPUT_DIRECTORY};OPENSSL_CONF=${CMAKE_SOURCE_DIR}/test/empty.cnf") + add_test(NAME engine + COMMAND perl run_tests + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test + ) + + set_tests_properties(engine PROPERTIES + ENVIRONMENT "OPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR};OPENSSL_ENGINES=${OUTPUT_DIRECTORY};OPENSSL_CONF=${CMAKE_SOURCE_DIR}/test/empty.cnf" + ) + + add_test(NAME tcl + COMMAND sh ./runtest.sh + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tcl_tests + ) + set_tests_properties(tcl PROPERTIES + ENVIRONMENT "ENGINE_DIR=${OUTPUT_DIRECTORY}" + ) + endif() -add_executable(sign benchmark/sign.c) -target_link_libraries(sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} ${CLOCK_GETTIME_LIB}) +add_executable(test_tlstree test_tlstree.c) +target_link_libraries(test_tlstree PUBLIC ${OPENSSL_CRYPTO_LIBRARY}) +add_test(NAME test_tlstree + COMMAND test_tlstree +) -# All that may need to load just built engine will have path to it defined. set(BINARY_TESTS_TARGETS - test_digest - test_curves - test_params - test_sign - test_context - test_grasshopper - test_keyexpimp - test_gost89 - test_tls - ) -set_property(TARGET ${BINARY_TESTS_TARGETS} APPEND PROPERTY COMPILE_DEFINITIONS ENGINE_DIR="${OUTPUT_DIRECTORY}") - -add_library(gost_core STATIC ${GOST_LIB_SOURCE_FILES}) -set_target_properties(gost_core PROPERTIES POSITION_INDEPENDENT_CODE ON) - -add_library(gost_engine SHARED ${GOST_ENGINE_SOURCE_FILES}) -set_target_properties(gost_engine PROPERTIES PREFIX "" OUTPUT_NAME "gost") -set_target_properties(gost_engine PROPERTIES VERSION ${GOST_SOVERSION} SOVERSION ${GOST_SOVERSION}) -target_link_libraries(gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY}) - + test_digest + test_curves + test_params + test_sign + test_context + test_grasshopper + test_keyexpimp + test_gost89 +) + +if(NOT MSVC) + list(APPEND BINARY_TESTS_TARGETS test_tls) +ENDif() + +set_property(TARGET ${BINARY_TESTS_TARGETS} + APPEND PROPERTY COMPILE_DEFINITIONS ENGINE_DIR="${OUTPUT_DIRECTORY}" +) + +#utilities set(GOST_SUM_SOURCE_FILES - gostsum.c - ) + gostsum.c +) add_executable(gostsum ${GOST_SUM_SOURCE_FILES}) target_link_libraries(gostsum gost_core) set(GOST_12_SUM_SOURCE_FILES - gost12sum.c - ) - + gost12sum.c + ansi_terminal.c + gosthash2012.c +) add_executable(gost12sum ${GOST_12_SUM_SOURCE_FILES}) -target_link_libraries(gost12sum gost_core) - -set_source_files_properties(tags PROPERTIES GENERATED true) -add_custom_target(tags - COMMAND ctags -R . ${OPENSSL_ROOT_DIR} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) - -add_custom_target(tcl_tests - COMMAND ENGINE_DIR=${OUTPUT_DIRECTORY} sh ./runtest.sh - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tcl_tests) -add_executable(test_tlstree test_tlstree.c) -target_link_libraries(test_tlstree PUBLIC ${OPENSSL_CRYPTO_LIBRARY}) - -# install -set(OPENSSL_MAN_INSTALL_DIR ${CMAKE_INSTALL_MANDIR}/man1) - -install(TARGETS gost_engine gostsum gost12sum EXPORT GostEngineConfig +#benchmarks +add_executable(bench_sign benchmark/sign.c ansi_terminal.c) +target_link_libraries(bench_sign gost_engine gost_core ${OPENSSL_CRYPTO_LIBRARY} ${CLOCK_GETTIME_LIB}) + +#install +if(NOT MSVC) + set_source_files_properties(tags PROPERTIES GENERATED true) + add_custom_target(tags + COMMAND ctags -R . ${OPENSSL_ROOT_DIR} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + + set(OPENSSL_MAN_INSTALL_DIR ${CMAKE_INSTALL_MANDIR}/man1) + + install(TARGETS gost_engine gostsum gost12sum EXPORT GostEngineConfig LIBRARY DESTINATION ${OPENSSL_ENGINES_DIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES gostsum.1 gost12sum.1 DESTINATION ${OPENSSL_MAN_INSTALL_DIR}) -if (MSVC) - install(FILES $ DESTINATION ${OPENSSL_ENGINES_DIR} OPTIONAL) - install(FILES $ $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + install(FILES gostsum.1 gost12sum.1 DESTINATION ${OPENSSL_MAN_INSTALL_DIR}) + +else() + install(FILES $ DESTINATION ${OPENSSL_ENGINES_DIR} OPTIONAL) + install(FILES $ $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) endif() + diff --git a/ansi_terminal.c b/ansi_terminal.c new file mode 100644 index 000000000..bdc4685e3 --- /dev/null +++ b/ansi_terminal.c @@ -0,0 +1,95 @@ +#ifdef _WIN32 + #define _CRT_SECURE_NO_WARNINGS 1 + #include +#else + #include + #include +#endif + +#include +#include + +#ifdef _WIN32 + // Some old MinGW/CYGWIN distributions don't define this: + #ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING + #define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 + #endif + +static HANDLE stdoutHandle, stdinHandle; +static DWORD outModeInit, inModeInit; + +void setupConsole(void) { + DWORD outMode = 0, inMode = 0; + stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE); + stdinHandle = GetStdHandle(STD_INPUT_HANDLE); + + if(stdoutHandle == INVALID_HANDLE_VALUE || stdinHandle == INVALID_HANDLE_VALUE) { + exit(GetLastError()); + } + + if(!GetConsoleMode(stdoutHandle, &outMode) || !GetConsoleMode(stdinHandle, &inMode)) { + exit(GetLastError()); + } + + outModeInit = outMode; + inModeInit = inMode; + + // Enable ANSI escape codes + outMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + + // Set stdin as no echo and unbuffered + inMode &= ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT); + + if(!SetConsoleMode(stdoutHandle, outMode) || !SetConsoleMode(stdinHandle, inMode)) { + exit(GetLastError()); + } +} + +void restoreConsole(void) { + // Reset colors + printf("\x1b[0m"); + + // Reset console mode + if(!SetConsoleMode(stdoutHandle, outModeInit) || !SetConsoleMode(stdinHandle, inModeInit)) { + exit(GetLastError()); + } +} +#else + +static struct termios orig_term; +static struct termios new_term; + +void setupConsole(void) { + tcgetattr(STDIN_FILENO, &orig_term); + new_term = orig_term; + + new_term.c_lflag &= ~(ICANON | ECHO); + + tcsetattr(STDIN_FILENO, TCSANOW, &new_term); +} + +void restoreConsole(void) { + // Reset colors + printf("\x1b[0m"); + + // Reset console mode + tcsetattr(STDIN_FILENO, TCSANOW, &orig_term); +} +#endif + +void getCursorPosition(int *row, int *col) { + printf("\x1b[6n"); + char buff[128]; + int indx = 0; + for(;;) { + int cc = getchar(); + buff[indx] = (char)cc; + indx++; + if(cc == 'R') { + buff[indx + 1] = '\0'; + break; + } + } + sscanf(buff, "\x1b[%d;%dR", row, col); + fseek(stdin, 0, SEEK_END); +} diff --git a/ansi_terminal.h b/ansi_terminal.h new file mode 100644 index 000000000..41d72e8d4 --- /dev/null +++ b/ansi_terminal.h @@ -0,0 +1,13 @@ +/* adopted from https://github.com/sol-prog/ansi-escape-codes-windows-posix-terminals-c-programming-examples */ + +#define cRED "\033[1;31m" +#define cDRED "\033[0;31m" +#define cGREEN "\033[1;32m" +#define cDGREEN "\033[0;32m" +#define cBLUE "\033[1;34m" +#define cDBLUE "\033[0;34m" +#define cNORM "\033[m" + +void setupConsole(void); +void restoreConsole(void); +void getCursorPosition(int *row, int *col); diff --git a/benchmark/platform.h b/benchmark/platform.h new file mode 100644 index 000000000..3b9a0b449 --- /dev/null +++ b/benchmark/platform.h @@ -0,0 +1,36 @@ + +#ifdef _MSC_VER + /** init the clock */ + #define TIMER_INIT \ + LARGE_INTEGER frequency; \ + LARGE_INTEGER t1,t2; \ + double elapsedTime; \ + QueryPerformanceFrequency(&frequency); + + #define TIMER_INIT_EX(CT) TIMER_INIT + /** start the performance timer */ + #define TIMER_START QueryPerformanceCounter(&t1); + /** stop the performance timer and store the result in elapsedTime. */ + #define TIMER_STOP \ + QueryPerformanceCounter(&t2); \ + elapsedTime=(double)(t2.QuadPart-t1.QuadPart)* 1000000 /frequency.QuadPart; + +#else + #include + #include + + #define TIMER_INIT \ + struct timespec ts1, ts2; \ + struct timeval tv1, tv2, delta; \ + double elapsedTime; \ + clockid_t clock_type = CLOCK_MONOTONIC; + + #define TIMER_INIT_EX(CT) TIMER_INIT clock_type = CT; + #define TIMER_START clock_gettime(clock_type, &ts1); + #define TIMER_STOP clock_gettime(clock_type, &ts2);\ + TIMESPEC_TO_TIMEVAL(&tv1, &ts1);\ + TIMESPEC_TO_TIMEVAL(&tv2, &ts2);\ + timersub(&tv2, &tv1, &delta); \ + elapsedTime = (double)delta.tv_sec * 1000000 + (double)delta.tv_usec ; + +#endif diff --git a/benchmark/sign.c b/benchmark/sign.c index 765b9f050..3680af7f0 100644 --- a/benchmark/sign.c +++ b/benchmark/sign.c @@ -9,9 +9,8 @@ #define _GNU_SOURCE #include #include -#include -#include -#include +#include "../ansi_terminal.h" +#include "platform.h" #include #include #include @@ -19,6 +18,12 @@ #include #include +#ifdef _MSC_VER +#include "../getopt.h" +#else +#include +#endif + const char *tests[] = { "md_gost12_256", "gost2012_256", "A", "md_gost12_256", "gost2012_256", "B", @@ -27,166 +32,190 @@ const char *tests[] = { "md_gost12_256", "gost2012_256", "TCB", "md_gost12_256", "gost2012_256", "TCC", "md_gost12_256", "gost2012_256", "TCD", - "md_gost12_512", "gost2012_512", "A", "md_gost12_512", "gost2012_512", "B", "md_gost12_512", "gost2012_512", "C", - NULL, }; +const int tests_line_size = 3; static EVP_PKEY *create_key(const char *algname, const char *param) { - EVP_PKEY *key1 = EVP_PKEY_new(), *newkey = NULL; - EVP_PKEY_CTX *ctx = NULL; - - if(EVP_PKEY_set_type_str(key1, algname, strlen(algname)) <= 0) - { - goto err; - } - if(!(ctx = EVP_PKEY_CTX_new(key1, NULL))) - { - goto err; - } - EVP_PKEY_keygen_init(ctx); - if(ERR_peek_last_error()) - { - goto err; - } - if(EVP_PKEY_CTX_ctrl_str(ctx, "paramset", param) <= 0) - { - goto err; - } - if(EVP_PKEY_keygen(ctx, &newkey) <= 0) - { - goto err; - } + EVP_PKEY *key1 = EVP_PKEY_new(), *newkey = NULL; + EVP_PKEY_CTX *ctx = NULL; + + if(EVP_PKEY_set_type_str(key1, algname, strlen(algname)) <= 0) + { + goto err; + } + if(!(ctx = EVP_PKEY_CTX_new(key1, NULL))) + { + goto err; + } + if(1!=EVP_PKEY_keygen_init(ctx)) + { + goto err; + } + if(EVP_PKEY_CTX_ctrl_str(ctx, "paramset", param) <= 0) + { + goto err; + } + if(EVP_PKEY_keygen(ctx, &newkey) <= 0) + { + goto err; + } err: - if(ctx) - EVP_PKEY_CTX_free(ctx); - EVP_PKEY_free(key1); - return newkey; + if(ctx) + EVP_PKEY_CTX_free(ctx); + EVP_PKEY_free(key1); + return newkey; } void usage(char *name) { - fprintf(stderr, "usage: %s [-l data_len] [-c cycles]\n", name); - exit(1); + fprintf(stderr, "usage: %s [-l data_len] [-c cycles]\n", name); + exit(1); } int main(int argc, char **argv) { - unsigned int data_len = 1; - unsigned int cycles = 100; - int option; - clockid_t clock_type = CLOCK_MONOTONIC; - int test, test_count = 0; - - opterr = 0; - while((option = getopt(argc, argv, "l:c:C")) >= 0) - { - if(option == ':') option = optopt; - if(optarg && (optarg[0] == '-')) { optind--; optarg = NULL; } - switch (option) - { - case 'l': - data_len = atoi(optarg); - break; - case 'c': - cycles = atoi(optarg); - break; - case 'C': - clock_type = CLOCK_PROCESS_CPUTIME_ID; - break; - default: - usage(argv[0]); - break; - } - } - if (optind < argc) usage(argv[0]); - if (cycles < 100) { printf("cycles too low\n"); exit(1); } - - OPENSSL_add_all_algorithms_conf(); - ERR_load_crypto_strings(); - - for (test = 0; tests[test]; test += 3) { - double diff[2]; /* sign, verify */ - const char *digest = tests[test]; - const char *algo = tests[test + 1]; - const char *param = tests[test + 2]; - const EVP_MD *mdtype; - EVP_MD_CTX *md_ctx; - unsigned int siglen; - unsigned char *sigbuf; - EVP_PKEY *pkey; - unsigned char *data; - int pass; - - md_ctx = EVP_MD_CTX_new(); - mdtype = EVP_get_digestbyname(digest); - if (!mdtype) - continue; - pkey = create_key(algo, param); - data = (unsigned char *) malloc(data_len); - if (!pkey) - continue; - - test_count++; - printf("wait..."); - fflush(stdout); - siglen = EVP_PKEY_size(pkey); - sigbuf = malloc(siglen * cycles); - if (!sigbuf) { - fprintf(stderr, "No tests were run, malloc failure.\n"); - exit(1); - } - - for (pass = 0; pass < 2; pass++) { - struct timespec ts; - struct timeval debut, fin, delta; - int err; - unsigned int i; - - clock_gettime(clock_type, &ts); - TIMESPEC_TO_TIMEVAL(&debut, &ts); - - if (pass == 0) { /* sign */ - for (i = 0; i < cycles; i++) { - EVP_SignInit(md_ctx, mdtype); - EVP_SignUpdate(md_ctx, data, data_len); - err = EVP_SignFinal(md_ctx, &sigbuf[siglen * i], - (unsigned int *)&siglen, pkey); - if (err != 1) - printf("!"); - EVP_MD_CTX_reset(md_ctx); - } - } else { /* verify */ - for (i = 0; i < cycles; i++) { - EVP_VerifyInit(md_ctx, mdtype); - EVP_VerifyUpdate(md_ctx, data, data_len); - err = EVP_VerifyFinal(md_ctx, &sigbuf[siglen * i], - siglen, pkey); - EVP_MD_CTX_reset(md_ctx); - if (err != 1) - printf("!"); - } - } - - clock_gettime(clock_type, &ts); - TIMESPEC_TO_TIMEVAL(&fin, &ts); - timersub(&fin, &debut, &delta); - diff[pass] = (double)delta.tv_sec + (double)delta.tv_usec / 1000000; - } - printf("\r%s %s: sign: %.1f/s, verify: %.1f/s\n", algo, param, - (double)cycles / diff[0], (double)cycles / diff[1]); - EVP_PKEY_free(pkey); - free(sigbuf); - free(data); - } - - if (!test_count) { - fprintf(stderr, "No tests were run, something is wrong.\n"); - exit(1); - } - exit(0); + unsigned int data_len = 1; + unsigned int cycles = 100; + int name_length=0; + int line_length; + int option; +#ifndef _MSC_VER + clockid_t option_clock_type = CLOCK_MONOTONIC; +#else + #define option_clock_type void(0) +#endif + int test, test_count = 0; + + opterr = 0; + while((option = getopt(argc, argv, "l:c:C")) >= 0) + { + if(option == ':') option = optopt; + if(optarg && (optarg[0] == '-')) { optind--; optarg = NULL; } + switch (option) + { + case 'l': + data_len = atoi(optarg); + break; + case 'c': + cycles = atoi(optarg); + break; +#ifndef _MSC_VER + case 'C': + option_clock_type = CLOCK_PROCESS_CPUTIME_ID; + break; +#endif + default: + usage(argv[0]); + break; + } + } + if (optind < argc) usage(argv[0]); + if (cycles < 100) { printf("cycles too low\n"); exit(1); } + + OPENSSL_add_all_algorithms_conf(); + ERR_load_crypto_strings(); + + + for (test = 0; tests[test]; test += tests_line_size) { + line_length = strlen(tests[test+1]) + strlen(tests[test+2]); + if(line_length>name_length){ + name_length = line_length; + } + } + setupConsole(); + printf("%*soperations per sec\n",name_length,""); + printf("%*s sign verify\n",name_length,""); + + for (test = 0; tests[test]; test += tests_line_size) { + TIMER_INIT_EX(option_clock_type); + int error_flag = 0; + double diff[2]; /* sign, verify */ + const char *digest = tests[test]; + const char *algo = tests[test + 1]; + const char *param = tests[test + 2]; + const EVP_MD *mdtype; + EVP_MD_CTX *md_ctx; + unsigned int siglen; + unsigned char *sigbuf; + EVP_PKEY *pkey; + unsigned char *data; + int pass; + + md_ctx = EVP_MD_CTX_new(); + mdtype = EVP_get_digestbyname(digest); + if (!mdtype) + continue; + + pkey = create_key(algo, param); + data = (unsigned char *) malloc(data_len); + if (!pkey) + continue; + + + printf("wait..."); + fflush(stdout); + siglen = EVP_PKEY_size(pkey); + sigbuf = malloc(siglen * cycles); + if (!sigbuf) { + fprintf(stderr, cRED "No tests were run, malloc failure.\n"); + restoreConsole(); + exit(1); + } + + for (pass = 0; pass < 2; pass++) { + int err; + + unsigned int i; + TIMER_START; + + if (pass == 0) { /* sign */ + for (i = 0; i < cycles; i++) { + EVP_SignInit(md_ctx, mdtype); + EVP_SignUpdate(md_ctx, data, data_len); + err = EVP_SignFinal(md_ctx, &sigbuf[siglen * i], + (unsigned int *)&siglen, pkey); + if (err != 1){ + error_flag=1; + test_count++; + } + EVP_MD_CTX_reset(md_ctx); + } + } else { /* verify */ + for (i = 0; i < cycles; i++) { + EVP_VerifyInit(md_ctx, mdtype); + EVP_VerifyUpdate(md_ctx, data, data_len); + err = EVP_VerifyFinal(md_ctx, &sigbuf[siglen * i], + siglen, pkey); + EVP_MD_CTX_reset(md_ctx); + if (err != 1){ + error_flag=1; + test_count++; + } + } + } + + TIMER_STOP; + diff[pass] = elapsedTime; + } + /* pad length */ + line_length = name_length - strlen(algo) - strlen(param); + + printf(cNORM"\r%s %s%*s %s " cNORM "%10.1f %10.1f\n", algo, param, line_length, "", (error_flag==1)?cRED"ERR":" ", + (double)cycles * 1000000 / diff[0], (double)cycles * 1000000 / diff[1]); + EVP_PKEY_free(pkey); + free(sigbuf); + free(data); + } + restoreConsole(); + if (test_count) { + fprintf(stderr, cRED "No tests were run,%i tests are failed .\n", test_count); + exit(1); + } + exit(0); + } diff --git a/getopt.h b/getopt.h index bcbff179e..267e6e7a5 100644 --- a/getopt.h +++ b/getopt.h @@ -115,10 +115,26 @@ static char EMSG[] = ""; #define EMSG "" #endif +typedef struct option /* specification for a long form option... */ +{ + const char *name; /* option name, without leading hyphens */ + int has_arg; /* does it take an argument? */ + int *flag; /* where to save its status, or NULL */ + int val; /* its associated status value */ +}option_t; + +enum /* permitted values for its `has_arg' field... */ +{ + no_argument = 0, /* option never takes an argument */ + required_argument, /* option always requires an argument */ + optional_argument /* option may take an argument */ +}; + + static int getopt_internal(int, char * const *, const char *, - const struct option *, int *, int); + const option_t *, int *, int); static int parse_long_options(char * const *, const char *, - const struct option *, int *, int); + const option_t *, int *, int); static int gcd(int, int); static void permute_args(int, int, int, char * const *); @@ -265,20 +281,6 @@ extern int optreset; extern "C" { #endif -struct option /* specification for a long form option... */ -{ - const char *name; /* option name, without leading hyphens */ - int has_arg; /* does it take an argument? */ - int *flag; /* where to save its status, or NULL */ - int val; /* its associated status value */ -}; - -enum /* permitted values for its `has_arg' field... */ -{ - no_argument = 0, /* option never takes an argument */ - required_argument, /* option always requires an argument */ - optional_argument /* option may take an argument */ -}; /* * parse_long_options -- @@ -287,7 +289,7 @@ enum /* permitted values for its `has_arg' field... */ */ static int parse_long_options(char * const *nargv, const char *options, - const struct option *long_options, int *idx, int short_too) + const option_t *long_options, int *idx, int short_too) { char *current_argv, *has_equal; size_t current_argv_len; @@ -415,7 +417,7 @@ parse_long_options(char * const *nargv, const char *options, */ static int getopt_internal(int nargc, char * const *nargv, const char *options, - const struct option *long_options, int *idx, int flags) + const option_t *long_options, int *idx, int flags) { char *oli; /* option letter list index */ int optchar, short_too; @@ -612,7 +614,7 @@ getopt_internal(int nargc, char * const *nargv, const char *options, */ int getopt_long(int nargc, char * const *nargv, const char *options, - const struct option *long_options, int *idx) + const option_t *long_options, int *idx) { return (getopt_internal(nargc, nargv, options, long_options, idx, @@ -625,7 +627,7 @@ getopt_long(int nargc, char * const *nargv, const char *options, */ int getopt_long_only(int nargc, char * const *nargv, const char *options, - const struct option *long_options, int *idx) + const option_t *long_options, int *idx) { return (getopt_internal(nargc, nargv, options, long_options, idx, diff --git a/gost12sum.c b/gost12sum.c index b44fe3bdb..2a5359eaf 100644 --- a/gost12sum.c +++ b/gost12sum.c @@ -10,7 +10,6 @@ **********************************************************************/ #include #include -#include #include #include #include @@ -19,13 +18,30 @@ #define MAX_HASH_TXT_BYTES 128 #define gost_hash_ctx gost2012_hash_ctx +#ifdef _MSC_VER +#include "getopt.h" +# ifndef PATH_MAX +# define PATH_MAX _MAX_PATH +# endif +#include +#else +#include +#endif +#include +#include +#ifdef _WIN32 +# include +#endif + +const char *RB_MODE="rb"; + typedef unsigned char byte; -int hash_file(gost_hash_ctx * ctx, char *filename, char *sum, int mode, +static int hash_file(gost_hash_ctx * ctx, char *filename, char *sum, const char *mode, int hashsize); -int hash_stream(gost_hash_ctx * ctx, int fd, char *sum, int hashsize); -int get_line(FILE *f, char *hash, char *filename, int verbose, int *size); +static int hash_stream(gost_hash_ctx * ctx, FILE *f, char *sum, int hashsize); +static int get_line(FILE *f, char *hash, char *filename, int verbose, int *size); -void help() +static void help() { fprintf(stderr, "Calculates GOST R 34.11-2012 hash function\n\n"); fprintf(stderr, "gost12sum [-vl] [-c [file]]| [files]|-x\n" @@ -39,23 +55,19 @@ void help() exit(3); } -#ifndef O_BINARY -# define O_BINARY 0 -#endif - -int start_hash(gost_hash_ctx * ctx, int hashsize) +static int start_hash(gost_hash_ctx * ctx, int hashsize) { init_gost2012_hash_ctx(ctx, hashsize); return 1; } -int hash_block(gost_hash_ctx * ctx, const byte * block, size_t length) +static int hash_block(gost_hash_ctx * ctx, const byte * block, size_t length) { gost2012_hash_block(ctx, block, length); return 1; } -int finish_hash(gost_hash_ctx * ctx, byte * hashval) +static int finish_hash(gost_hash_ctx * ctx, byte * hashval) { gost2012_finish_hash(ctx, hashval); return 1; @@ -66,7 +78,7 @@ int main(int argc, char **argv) int c, i; int verbose = 0; int errors = 0; - int open_mode = O_RDONLY | O_BINARY; + const char *open_mode = RB_MODE; FILE *check_file = NULL; int filenames_from_stdin = 0; int hashsize = 32; @@ -76,7 +88,6 @@ int main(int argc, char **argv) switch (c) { case 'h': help(); - exit(0); break; case 'v': verbose = 1; @@ -180,7 +191,7 @@ int main(int argc, char **argv) } else if (optind == argc) { char sum[MAX_HASH_TXT_BYTES + 1]; - if (!hash_stream(&ctx, fileno(stdin), sum, hashsize)) { + if (!hash_stream(&ctx, stdin, sum, hashsize)) { perror("stdin"); exit(1); } @@ -199,33 +210,33 @@ int main(int argc, char **argv) exit(errors ? 1 : 0); } -int hash_file(gost_hash_ctx * ctx, char *filename, char *sum, int mode, +static int hash_file(gost_hash_ctx * ctx, char *filename, char *sum, const char *mode, int hashsize) { - int fd; - if ((fd = open(filename, mode)) < 0) { + FILE *f; + if ((f = fopen(filename, mode)) == NULL) { perror(filename); return 0; } - if (!hash_stream(ctx, fd, sum, hashsize)) { + if (!hash_stream(ctx, f, sum, hashsize)) { perror(filename); - close(fd); + fclose(f); return 0; } - close(fd); + fclose(f); return 1; } -int hash_stream(gost_hash_ctx * ctx, int fd, char *sum, int hashsize) +static int hash_stream(gost_hash_ctx * ctx, FILE *f, char *sum, int hashsize) { unsigned char buffer[BUF_SIZE]; - ssize_t bytes; + size_t bytes; int i; start_hash(ctx, hashsize * 8); - while ((bytes = read(fd, buffer, BUF_SIZE)) > 0) { - hash_block(ctx, buffer, bytes); + while ((bytes = fread(buffer, sizeof(unsigned char), BUF_SIZE, f)) > 0) { + hash_block(ctx, buffer, bytes * sizeof(unsigned char)); } - if (bytes < 0) { + if (ferror(f)) { return 0; } finish_hash(ctx, buffer); @@ -235,7 +246,7 @@ int hash_stream(gost_hash_ctx * ctx, int fd, char *sum, int hashsize) return 1; } -int get_line(FILE *f, char *hash, char *filename, int verbose, int *size) +static int get_line(FILE *f, char *hash, char *filename, int verbose, int *size) { int i, len; char *ptr = filename; @@ -259,7 +270,7 @@ int get_line(FILE *f, char *hash, char *filename, int verbose, int *size) if (spacepos == NULL || strlen(spacepos + 1) == 0) goto nextline; - *size = spacepos - ptr; + *size = (int)(spacepos - ptr); for (i = 0; i < *size; i++) { if (ptr[i] < '0' || (ptr[i] > '9' && ptr[i] < 'A') || diff --git a/gost_grasshopper_cipher.c b/gost_grasshopper_cipher.c index 9df7bbc7b..ae0598647 100644 --- a/gost_grasshopper_cipher.c +++ b/gost_grasshopper_cipher.c @@ -152,7 +152,7 @@ gost_grasshopper_cipher_key(gost_grasshopper_cipher_ctx * c, const uint8_t *k) } /* Set master 256-bit key to be used in TLSTREE calculation into context */ -GRASSHOPPER_INLINE void +static GRASSHOPPER_INLINE void gost_grasshopper_master_key(gost_grasshopper_cipher_ctx * c, const uint8_t *k) { int i; diff --git a/gost_grasshopper_core.h b/gost_grasshopper_core.h index a5d3df622..1cd5b0143 100644 --- a/gost_grasshopper_core.h +++ b/gost_grasshopper_core.h @@ -12,9 +12,6 @@ extern "C" { #include "gost_grasshopper_defines.h" -static void grasshopper_l(grasshopper_w128_t* w); -static void grasshopper_l_inv(grasshopper_w128_t* w); - // key setup extern void grasshopper_set_encrypt_key(grasshopper_round_keys_t* subkeys, const grasshopper_key_t* key); extern void grasshopper_set_decrypt_key(grasshopper_round_keys_t* subkeys, const grasshopper_key_t* key); diff --git a/gost_grasshopper_precompiled.c b/gost_grasshopper_precompiled.c index a9fcd9c6a..2f0172e6f 100644 --- a/gost_grasshopper_precompiled.c +++ b/gost_grasshopper_precompiled.c @@ -7,6 +7,11 @@ #include "gost_grasshopper_defines.h" #include "gost_grasshopper_math.h" +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-braces" +#endif + const grasshopper_w128_t grasshopper_pil_enc128[GRASSHOPPER_MAX_BIT_PARTS][256] = { { { @@ -36973,3 +36978,6 @@ const grasshopper_w128_t grasshopper_l_dec128[GRASSHOPPER_MAX_BIT_PARTS][256] = }, }, }; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/gost_pmeth.c b/gost_pmeth.c index b6f454369..1fee88459 100644 --- a/gost_pmeth.c +++ b/gost_pmeth.c @@ -659,7 +659,7 @@ static int pkey_gost_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL, GOST_R_INVALID_MAC_SIZE); return 0; } - data->mac_size = p1; + data->mac_size = (short int)p1; return 1; } } @@ -787,12 +787,12 @@ static int pkey_gost_omac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2, si } case EVP_PKEY_CTRL_MAC_LEN: { - if (p1 < 1 || p1 > max_size) { + if ((size_t)p1==0 || (size_t)p1 > max_size) { GOSTerr(GOST_F_PKEY_GOST_OMAC_CTRL, GOST_R_INVALID_MAC_SIZE); return 0; } - data->mac_size = p1; + data->mac_size = (short int)p1; return 1; } } diff --git a/gostsum.c b/gostsum.c index b61215c9f..8e7de013e 100644 --- a/gostsum.c +++ b/gostsum.c @@ -27,10 +27,14 @@ typedef SSIZE_T ssize_t; #include #include "gosthash.h" #define BUF_SIZE 262144 -int hash_file(gost_hash_ctx * ctx, char *filename, char *sum, int mode); -int hash_stream(gost_hash_ctx * ctx, int fd, char *sum); -int get_line(FILE *f, char *hash, char *filename); -void help() + +const char *R_MODE = "r"; +const char *RB_MODE = "rb"; + +static int hash_file(gost_hash_ctx * ctx, char *filename, char *sum, const char *mode); +static int hash_stream(gost_hash_ctx * ctx, FILE *f, char *sum); +static int get_line(FILE *f, char *hash, char *filename); +static void help() { fprintf(stderr, "gostsum [-bvt] [-c [file]]| [files]\n" "\t-c check message digests (default is generate)\n" @@ -51,7 +55,7 @@ int main(int argc, char **argv) int c, i; int verbose = 0; int errors = 0; - int open_mode = O_RDONLY; + const char *open_mode = R_MODE; gost_subst_block *b = &GostR3411_94_CryptoProParamSet; FILE *check_file = NULL; gost_hash_ctx ctx; @@ -65,7 +69,7 @@ int main(int argc, char **argv) b = &GostR3411_94_TestParamSet; break; case 'b': - open_mode |= O_BINARY; + open_mode = RB_MODE; break; case 'c': if (optarg) { @@ -132,11 +136,11 @@ int main(int argc, char **argv) if (optind == argc) { char sum[65]; #ifdef _WIN32 - if (open_mode & O_BINARY) { + if (open_mode == RB_MODE) { _setmode(fileno(stdin), O_BINARY); } #endif - if (!hash_stream(&ctx, fileno(stdin), sum)) { + if (!hash_stream(&ctx, stdin, sum)) { perror("stdin"); exit(1); } @@ -154,32 +158,32 @@ int main(int argc, char **argv) exit(errors ? 1 : 0); } -int hash_file(gost_hash_ctx * ctx, char *filename, char *sum, int mode) +static int hash_file(gost_hash_ctx * ctx, char *filename, char *sum, const char *mode) { - int fd; - if ((fd = open(filename, mode)) < 0) { + FILE *f; + if ((f = fopen(filename, mode)) == NULL) { perror(filename); return 0; } - if (!hash_stream(ctx, fd, sum)) { + if (!hash_stream(ctx, f, sum)) { perror(filename); - close(fd); + fclose(f); return 0; } - close(fd); + fclose(f); return 1; } -int hash_stream(gost_hash_ctx * ctx, int fd, char *sum) +static int hash_stream(gost_hash_ctx * ctx, FILE *f, char *sum) { unsigned char buffer[BUF_SIZE]; - ssize_t bytes; + size_t bytes; int i; start_hash(ctx); - while ((bytes = read(fd, buffer, BUF_SIZE)) > 0) { - hash_block(ctx, buffer, bytes); + while ((bytes = fread(buffer, sizeof(unsigned char), BUF_SIZE, f)) > 0) { + hash_block(ctx, buffer, bytes * sizeof(unsigned char)); } - if (bytes < 0) { + if (ferror(f)) { return 0; } finish_hash(ctx, buffer); @@ -189,7 +193,7 @@ int hash_stream(gost_hash_ctx * ctx, int fd, char *sum) return 1; } -int get_line(FILE *f, char *hash, char *filename) +static int get_line(FILE *f, char *hash, char *filename) { int i; if (fread(hash, 1, 64, f) < 64) diff --git a/test.h b/test.h new file mode 100644 index 000000000..ed5f1b56e --- /dev/null +++ b/test.h @@ -0,0 +1,64 @@ +#ifndef TEST_H +#define TEST_H + + + +#define T(e) do{ if (!(e)) { ERR_print_errors_fp(stderr); OpenSSLDie(__FILE__, __LINE__, #e); } }while (0) + +#define TE(e) do{ if (!(e)) { \ + ERR_print_errors_fp(stderr); \ + fprintf(stderr, "Error at %s:%d %s\n", __FILE__, __LINE__, #e); \ + return -1; } }while (0) + +#define TEST_ASSERT(e) do{ test = (e);}while (0); if (test) \ + printf(cRED " Test FAILED\n" cNORM); \ + else \ + printf(cGREEN " Test passed\n" cNORM)\ + + +#ifdef __GNUC__ +# define _UNUSED_ __attribute__ ((unused)) +#else +# define _UNUSED_ +#endif + +_UNUSED_ static void hexdump(FILE *f, const char *title, const unsigned char *s, int l) +{ + int n = 0; + + if(title!=NULL) fprintf(f, "%s", title); + for (; n < l; ++n) { + if ((n % 16) == 0) + fprintf(f, "\n%04x", n); + fprintf(f, " %02x", s[n]); + } + fprintf(f, "\n"); +} + +_UNUSED_ static void hexdump_inline(const void *ptr, size_t len) +{ + const unsigned char *p = ptr; + size_t i, j; + + for (i = 0; i < len; i += j) { + for (j = 0; j < 16 && i + j < len; j++) + printf("%s%02x", j? "" : " ", p[i + j]); + } + printf("\n"); +} + + + +#ifdef _WIN32 + #include + static inline int setenv(const char* name, const char* value,int overwrite){ + return _putenv_s(name, value); + } +#else + #include + #include +#endif + +#endif + + diff --git a/test_context.c b/test_context.c index 72e105799..244b53c2b 100644 --- a/test_context.c +++ b/test_context.c @@ -11,40 +11,14 @@ #include "gost_grasshopper_core.h" #include "e_gost_err.h" #include "gost_lcl.h" +#include "test.h" +#include "ansi_terminal.h" #include #include #include #include #include -#define T(e) if (!(e)) {\ - ERR_print_errors_fp(stderr);\ - OpenSSLDie(__FILE__, __LINE__, #e);\ - } - -#define cRED "\033[1;31m" -#define cDRED "\033[0;31m" -#define cGREEN "\033[1;32m" -#define cDGREEN "\033[0;32m" -#define cBLUE "\033[1;34m" -#define cDBLUE "\033[0;34m" -#define cNORM "\033[m" -#define TEST_ASSERT(e) {if ((test = (e))) \ - printf(cRED " Test FAILED\n" cNORM); \ - else \ - printf(cGREEN " Test passed\n" cNORM);} - -static void hexdump(const void *ptr, size_t len) -{ - const unsigned char *p = ptr; - size_t i, j; - - for (i = 0; i < len; i += j) { - for (j = 0; j < 16 && i + j < len; j++) - printf("%s%02x", j? "" : " ", p[i + j]); - } - printf("\n"); -} #define TEST_SIZE 256 #define STEP_SIZE 16 @@ -68,7 +42,7 @@ static int test_contexts(const EVP_CIPHER *type, const int enc, const char *msg, T(ctx); T(EVP_CipherInit_ex(ctx, type, NULL, K, iv, enc)); if (acpkm) - T(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, NULL)); + T(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, NULL)); T(EVP_CIPHER_CTX_set_padding(ctx, 0)); T(EVP_CipherUpdate(ctx, b, &outlen, pt, sizeof(b))); T(EVP_CipherFinal_ex(ctx, b + outlen, &tmplen)); @@ -80,32 +54,32 @@ static int test_contexts(const EVP_CIPHER *type, const int enc, const char *msg, T(EVP_CipherInit_ex(ctx, type, NULL, K, iv, enc)); T(EVP_CIPHER_CTX_set_padding(ctx, 0)); if (acpkm) - T(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, NULL)); + T(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, NULL)); save = ctx; int i; memset(c, 0, sizeof(c)); for (i = 0; i < TEST_SIZE / STEP_SIZE; i++) { - EVP_CIPHER_CTX *copy = EVP_CIPHER_CTX_new(); - T(copy); - T(EVP_CIPHER_CTX_copy(copy, ctx)); - if (save != ctx) /* else original context */ - EVP_CIPHER_CTX_free(ctx); - ctx = copy; - - T(EVP_CipherUpdate(ctx, c + STEP_SIZE * i, &outlen, - pt + STEP_SIZE * i, STEP_SIZE)); + EVP_CIPHER_CTX *copy = EVP_CIPHER_CTX_new(); + T(copy); + T(EVP_CIPHER_CTX_copy(copy, ctx)); + if (save != ctx) /* else original context */ + EVP_CIPHER_CTX_free(ctx); + ctx = copy; + + T(EVP_CipherUpdate(ctx, c + STEP_SIZE * i, &outlen, + pt + STEP_SIZE * i, STEP_SIZE)); } outlen = i * GRASSHOPPER_BLOCK_SIZE; T(EVP_CipherFinal_ex(ctx, c + outlen, &tmplen)); - TEST_ASSERT(outlen != TEST_SIZE || memcmp(c, b, TEST_SIZE)); + TEST_ASSERT(outlen != TEST_SIZE || memcmp(c, b, TEST_SIZE) ); EVP_CIPHER_CTX_free(ctx); if (test) { - printf(" b[%d] = ", outlen); - hexdump(b, outlen); - printf(" c[%d] = ", outlen); - hexdump(c, outlen); + printf(" b[%d] = ", outlen); + hexdump_inline(b, outlen); + printf(" c[%d] = ", outlen); + hexdump_inline(c, outlen); } ret |= test; @@ -119,13 +93,13 @@ static int test_contexts(const EVP_CIPHER *type, const int enc, const char *msg, EVP_CIPHER_CTX_cleanup(save); EVP_CIPHER_CTX_free(save); if (test) { - printf(" b[%d] = ", outlen); - hexdump(b, outlen); - printf(" c[%d] = ", outlen); - hexdump(c, outlen); + printf(" b[%d] = ", outlen); + hexdump_inline(b, outlen); + printf(" c[%d] = ", outlen); + hexdump_inline(c, outlen); } ret |= test; - + return ret; } @@ -133,7 +107,7 @@ static int test_contexts(const EVP_CIPHER *type, const int enc, const char *msg, int main(int argc, char **argv) { int ret = 0; - + setupConsole(); ret |= test_contexts(cipher_gost_grasshopper_ecb(), 1, "grasshopper ecb", 0); ret |= test_contexts(cipher_gost_grasshopper_ecb(), 0, "grasshopper ecb", 0); ret |= test_contexts(cipher_gost_grasshopper_cbc(), 1, "grasshopper cbc", 0); @@ -146,8 +120,9 @@ int main(int argc, char **argv) ret |= test_contexts(cipher_gost_grasshopper_ctracpkm(), 0, "grasshopper ctracpkm", 256 / 8); if (ret) - printf(cDRED "= Some tests FAILED!\n" cNORM); + printf(cDRED "= Some tests FAILED!\n" cNORM); else - printf(cDGREEN "= All tests passed!\n" cNORM); + printf(cDGREEN "= All tests passed!\n" cNORM); + restoreConsole(); return ret; } diff --git a/test_curves.c b/test_curves.c index 973307b0f..e27732e1e 100644 --- a/test_curves.c +++ b/test_curves.c @@ -7,6 +7,8 @@ #include "e_gost_err.h" #include "gost_lcl.h" +#include "test.h" +#include "ansi_terminal.h" #include #include #include @@ -16,24 +18,6 @@ #include #include -#define T(e) ({ if (!(e)) { \ - ERR_print_errors_fp(stderr); \ - OpenSSLDie(__FILE__, __LINE__, #e); \ - } \ - }) - -#define cRED "\033[1;31m" -#define cDRED "\033[0;31m" -#define cGREEN "\033[1;32m" -#define cDGREEN "\033[0;32m" -#define cBLUE "\033[1;34m" -#define cDBLUE "\033[0;34m" -#define cNORM "\033[m" -#define TEST_ASSERT(e) {if ((test = (e))) \ - printf(cRED " Test FAILED\n" cNORM); \ - else \ - printf(cGREEN " Test passed\n" cNORM);} - struct test_curve { int nid; const char *name; @@ -56,18 +40,9 @@ static struct test_curve test_curves[] = { { NID_id_tc26_gost_3410_2012_256_paramSetB, "id-tc26-gost-3410-2012-256-paramSetB", }, { NID_id_tc26_gost_3410_2012_256_paramSetC, "id-tc26-gost-3410-2012-256-paramSetC", }, { NID_id_tc26_gost_3410_2012_256_paramSetD, "id-tc26-gost-3410-2012-256-paramSetD", }, - 0, + {0}, }; -static struct test_curve *get_test_curve(int nid) -{ - int i; - - for (i = 0; test_curves[i].nid; i++) - if (test_curves[i].nid == nid) - return &test_curves[i]; - return NULL; -} static void print_bn(const char *name, const BIGNUM *n) { @@ -80,18 +55,18 @@ static void print_bn(const char *name, const BIGNUM *n) static int parameter_test(struct test_curve *tc) { const int nid = tc->nid; - int test; + int test=0; printf(cBLUE "Test curve NID %d" cNORM, nid); if (tc->name) - printf(cBLUE ": %s" cNORM, tc->name); + printf(cBLUE ": %s" cNORM, tc->name); else if (OBJ_nid2sn(nid)) - printf(cBLUE ": %s" cNORM, OBJ_nid2sn(nid)); + printf(cBLUE ": %s" cNORM, OBJ_nid2sn(nid)); printf("\n"); if (!OBJ_nid2obj(nid)) { - printf(cRED "NID %d not found\n" cNORM, nid); - return 1; + printf(cRED "NID %d not found\n" cNORM, nid); + return 1; } /* nid resolves in both directions */ @@ -99,16 +74,16 @@ static int parameter_test(struct test_curve *tc) T(sn = OBJ_nid2sn(nid)); T(ln = OBJ_nid2ln(nid)); if (tc->name) - T(!strcmp(tc->name, OBJ_nid2sn(nid))); + T(!strcmp(tc->name, OBJ_nid2sn(nid))); T(nid == OBJ_sn2nid(sn)); T(nid == OBJ_ln2nid(ln)); EC_KEY *ec; T(ec = EC_KEY_new()); if (!fill_GOST_EC_params(ec, nid)) { - printf(cRED "fill_GOST_EC_params FAIL\n" cNORM); - ERR_print_errors_fp(stderr); - return 1; + printf(cRED "fill_GOST_EC_params FAIL\n" cNORM); + ERR_print_errors_fp(stderr); + return 1; } const EC_GROUP *group; @@ -214,14 +189,14 @@ static int parameter_test(struct test_curve *tc) BN_CTX_free(ctx); EC_KEY_free(ec); - TEST_ASSERT(0); return test; } int main(int argc, char **argv) { int ret = 0; - + + setupConsole(); setenv("OPENSSL_ENGINES", ENGINE_DIR, 0); OPENSSL_add_all_algorithms_conf(); ERR_load_crypto_strings(); @@ -232,15 +207,17 @@ int main(int argc, char **argv) struct test_curve *tc; for (tc = test_curves; tc->nid; tc++) { - ret |= parameter_test(tc); + ret |= parameter_test(tc); } ENGINE_finish(eng); ENGINE_free(eng); if (ret) - printf(cDRED "= Some tests FAILED!\n" cNORM); + printf(cDRED "= Some tests FAILED!\n" cNORM); else - printf(cDGREEN "= All tests passed!\n" cNORM); + printf(cDGREEN "= All tests passed!\n" cNORM); + + restoreConsole(); return ret; } diff --git a/test_digest.c b/test_digest.c index 1628ab2bc..e77587857 100644 --- a/test_digest.c +++ b/test_digest.c @@ -9,6 +9,8 @@ #include "e_gost_err.h" #include "gost_lcl.h" +#include "test.h" +#include "ansi_terminal.h" #include #include #include @@ -20,178 +22,207 @@ # include #endif -#define T(e) ({ if (!(e)) { \ - ERR_print_errors_fp(stderr); \ - OpenSSLDie(__FILE__, __LINE__, #e); \ - } \ - }) -#define TE(e) ({ if (!(e)) { \ - ERR_print_errors_fp(stderr); \ - fprintf(stderr, "Error at %s:%d %s\n", __FILE__, __LINE__, #e); \ - return -1; \ - } \ - }) - -#define cRED "\033[1;31m" -#define cDRED "\033[0;31m" -#define cGREEN "\033[1;32m" -#define cDGREEN "\033[0;32m" -#define cBLUE "\033[1;34m" -#define cDBLUE "\033[0;34m" -#define cNORM "\033[m" -#define TEST_ASSERT(e) {if ((test = (e))) \ - printf(cRED " Test FAILED\n" cNORM); \ - else \ - printf(cGREEN " Test passed\n" cNORM);} struct hash_testvec { - int nid; - const char *name; - const char *plaintext; - const char *digest; - unsigned short psize; + int nid; + const char *name; + const char *plaintext; + const char *digest; + unsigned short psize; }; static const struct hash_testvec testvecs[] = { - { /* M1 */ - .nid = NID_id_GostR3411_2012_256, - .name = "M1", - .plaintext = "012345678901234567890123456789012345678901234567890123456789012", - .psize = 63, - .digest = - "\x9d\x15\x1e\xef\xd8\x59\x0b\x89" - "\xda\xa6\xba\x6c\xb7\x4a\xf9\x27" - "\x5d\xd0\x51\x02\x6b\xb1\x49\xa4" - "\x52\xfd\x84\xe5\xe5\x7b\x55\x00", - }, - { /* M2 */ - .nid = NID_id_GostR3411_2012_256, - .name = "M2", - .plaintext = - "\xd1\xe5\x20\xe2\xe5\xf2\xf0\xe8" - "\x2c\x20\xd1\xf2\xf0\xe8\xe1\xee" - "\xe6\xe8\x20\xe2\xed\xf3\xf6\xe8" - "\x2c\x20\xe2\xe5\xfe\xf2\xfa\x20" - "\xf1\x20\xec\xee\xf0\xff\x20\xf1" - "\xf2\xf0\xe5\xeb\xe0\xec\xe8\x20" - "\xed\xe0\x20\xf5\xf0\xe0\xe1\xf0" - "\xfb\xff\x20\xef\xeb\xfa\xea\xfb" - "\x20\xc8\xe3\xee\xf0\xe5\xe2\xfb", - .psize = 72, - .digest = - "\x9d\xd2\xfe\x4e\x90\x40\x9e\x5d" - "\xa8\x7f\x53\x97\x6d\x74\x05\xb0" - "\xc0\xca\xc6\x28\xfc\x66\x9a\x74" - "\x1d\x50\x06\x3c\x55\x7e\x8f\x50", - }, - { /* M1 */ - .nid = NID_id_GostR3411_2012_512, - .name = "M1", - .plaintext = "012345678901234567890123456789012345678901234567890123456789012", - .psize = 63, - .digest = - "\x1b\x54\xd0\x1a\x4a\xf5\xb9\xd5" - "\xcc\x3d\x86\xd6\x8d\x28\x54\x62" - "\xb1\x9a\xbc\x24\x75\x22\x2f\x35" - "\xc0\x85\x12\x2b\xe4\xba\x1f\xfa" - "\x00\xad\x30\xf8\x76\x7b\x3a\x82" - "\x38\x4c\x65\x74\xf0\x24\xc3\x11" - "\xe2\xa4\x81\x33\x2b\x08\xef\x7f" - "\x41\x79\x78\x91\xc1\x64\x6f\x48", - }, - { /* M2 */ - .nid = NID_id_GostR3411_2012_512, - .name = "M2", - .plaintext = - "\xd1\xe5\x20\xe2\xe5\xf2\xf0\xe8" - "\x2c\x20\xd1\xf2\xf0\xe8\xe1\xee" - "\xe6\xe8\x20\xe2\xed\xf3\xf6\xe8" - "\x2c\x20\xe2\xe5\xfe\xf2\xfa\x20" - "\xf1\x20\xec\xee\xf0\xff\x20\xf1" - "\xf2\xf0\xe5\xeb\xe0\xec\xe8\x20" - "\xed\xe0\x20\xf5\xf0\xe0\xe1\xf0" - "\xfb\xff\x20\xef\xeb\xfa\xea\xfb" - "\x20\xc8\xe3\xee\xf0\xe5\xe2\xfb", - .psize = 72, - .digest = - "\x1e\x88\xe6\x22\x26\xbf\xca\x6f" - "\x99\x94\xf1\xf2\xd5\x15\x69\xe0" - "\xda\xf8\x47\x5a\x3b\x0f\xe6\x1a" - "\x53\x00\xee\xe4\x6d\x96\x13\x76" - "\x03\x5f\xe8\x35\x49\xad\xa2\xb8" - "\x62\x0f\xcd\x7c\x49\x6c\xe5\xb3" - "\x3f\x0c\xb9\xdd\xdc\x2b\x64\x60" - "\x14\x3b\x03\xda\xba\xc9\xfb\x28", - }, - { 0 } + { /* M1 */ + .nid = NID_id_GostR3411_2012_256, + .name = "M1", + .plaintext = "012345678901234567890123456789012345678901234567890123456789012", + .psize = 63, + .digest = + "\x9d\x15\x1e\xef\xd8\x59\x0b\x89" + "\xda\xa6\xba\x6c\xb7\x4a\xf9\x27" + "\x5d\xd0\x51\x02\x6b\xb1\x49\xa4" + "\x52\xfd\x84\xe5\xe5\x7b\x55\x00", + }, + { /* M2 */ + .nid = NID_id_GostR3411_2012_256, + .name = "M2", + .plaintext = + "\xd1\xe5\x20\xe2\xe5\xf2\xf0\xe8" + "\x2c\x20\xd1\xf2\xf0\xe8\xe1\xee" + "\xe6\xe8\x20\xe2\xed\xf3\xf6\xe8" + "\x2c\x20\xe2\xe5\xfe\xf2\xfa\x20" + "\xf1\x20\xec\xee\xf0\xff\x20\xf1" + "\xf2\xf0\xe5\xeb\xe0\xec\xe8\x20" + "\xed\xe0\x20\xf5\xf0\xe0\xe1\xf0" + "\xfb\xff\x20\xef\xeb\xfa\xea\xfb" + "\x20\xc8\xe3\xee\xf0\xe5\xe2\xfb", + .psize = 72, + .digest = + "\x9d\xd2\xfe\x4e\x90\x40\x9e\x5d" + "\xa8\x7f\x53\x97\x6d\x74\x05\xb0" + "\xc0\xca\xc6\x28\xfc\x66\x9a\x74" + "\x1d\x50\x06\x3c\x55\x7e\x8f\x50", + }, + { /* M1 */ + .nid = NID_id_GostR3411_2012_512, + .name = "M1", + .plaintext = "012345678901234567890123456789012345678901234567890123456789012", + .psize = 63, + .digest = + "\x1b\x54\xd0\x1a\x4a\xf5\xb9\xd5" + "\xcc\x3d\x86\xd6\x8d\x28\x54\x62" + "\xb1\x9a\xbc\x24\x75\x22\x2f\x35" + "\xc0\x85\x12\x2b\xe4\xba\x1f\xfa" + "\x00\xad\x30\xf8\x76\x7b\x3a\x82" + "\x38\x4c\x65\x74\xf0\x24\xc3\x11" + "\xe2\xa4\x81\x33\x2b\x08\xef\x7f" + "\x41\x79\x78\x91\xc1\x64\x6f\x48", + }, + { /* M2 */ + .nid = NID_id_GostR3411_2012_512, + .name = "M2", + .plaintext = + "\xd1\xe5\x20\xe2\xe5\xf2\xf0\xe8" + "\x2c\x20\xd1\xf2\xf0\xe8\xe1\xee" + "\xe6\xe8\x20\xe2\xed\xf3\xf6\xe8" + "\x2c\x20\xe2\xe5\xfe\xf2\xfa\x20" + "\xf1\x20\xec\xee\xf0\xff\x20\xf1" + "\xf2\xf0\xe5\xeb\xe0\xec\xe8\x20" + "\xed\xe0\x20\xf5\xf0\xe0\xe1\xf0" + "\xfb\xff\x20\xef\xeb\xfa\xea\xfb" + "\x20\xc8\xe3\xee\xf0\xe5\xe2\xfb", + .psize = 72, + .digest = + "\x1e\x88\xe6\x22\x26\xbf\xca\x6f" + "\x99\x94\xf1\xf2\xd5\x15\x69\xe0" + "\xda\xf8\x47\x5a\x3b\x0f\xe6\x1a" + "\x53\x00\xee\xe4\x6d\x96\x13\x76" + "\x03\x5f\xe8\x35\x49\xad\xa2\xb8" + "\x62\x0f\xcd\x7c\x49\x6c\xe5\xb3" + "\x3f\x0c\xb9\xdd\xdc\x2b\x64\x60" + "\x14\x3b\x03\xda\xba\xc9\xfb\x28", + }, + { /* M5 */ + .nid = NID_id_GostR3411_2012_256, + .name = "M5", + .plaintext = + "\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1" + "\x00\x00\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00" + "\x3e\x00\x03\x00\xfe\xff\x09\x00" + "\x06\x00\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x01\x00\x00\x00" + "\x01\x00\x00\x00\x00\x00\x00\x00" + "\x00\x10\x00\x00\x24\x00\x00\x00" + "\x01\x00\x00\x00\xfe\xff\xff\xff" + "\x00\x00\x00\x00\x00\x00\x00\x00" + "\xff\xff\xff\xff\xff\xff\xff\xff" + "\xff\xff\xff\xff\xff\xff\xff\xff" + "\xff\xff\xff\xff\xff\xff\xff\xff" + "\xff\xff\xff\xff\xff\xff\xff\xff" + "\xff\xff\xff\xff\xff\xff\xff\xff" + "\xff\xff\xff\xff\xff\xff\xff\xff" + "\xff\xff\xff\xff\xff\xff\xff\xff" + "\xff\xff\xff\xff\xff\xff\xff\xff", + .psize = 144, + .digest = + "\xc7\x66\x08\x55\x40\xca\xaa\x89" + "\x53\xbf\xcf\x7a\x1b\xa2\x20\x61" + "\x9c\xee\x50\xd6\x5d\xc2\x42\xf8" + "\x2f\x23\xba\x4b\x18\x0b\x18\xe0", + }, + + { 0 } }; static int do_digest(int hash_nid, const char *plaintext, unsigned int psize, const char *etalon) { - unsigned int mdlen = 0; - if (hash_nid == NID_id_GostR3411_2012_256) - mdlen = 256 / 8; - else if (hash_nid == NID_id_GostR3411_2012_512) - mdlen = 512 / 8; - const EVP_MD *mdtype; - T(mdtype = EVP_get_digestbynid(hash_nid)); - EVP_MD_CTX *ctx; - T(ctx = EVP_MD_CTX_new()); - T(EVP_DigestInit(ctx, mdtype)); - T(EVP_DigestUpdate(ctx, plaintext, psize)); - unsigned int len; - unsigned char md[512 / 8]; - T(EVP_DigestFinal(ctx, md, &len)); - EVP_MD_CTX_free(ctx); - if (len != mdlen) { - printf(cRED "digest output len mismatch %u != %u (expected)\n" cNORM, - len, mdlen); - return 1; - } - if (memcmp(md, etalon, mdlen) != 0) { - printf(cRED "digest mismatch\n" cNORM); - return 1; - } - - return 0; + unsigned int mdlen = 0; + unsigned int len; + unsigned char md[512 / 8]; + const EVP_MD *mdtype; + + if (hash_nid == NID_id_GostR3411_2012_256) + mdlen = 256 / 8; + else if (hash_nid == NID_id_GostR3411_2012_512) + mdlen = 512 / 8; + + T(mdtype = EVP_get_digestbynid(hash_nid)); + EVP_Digest(plaintext, psize, md, &len, mdtype, NULL); + if (len != mdlen) { + printf(cRED "digest output len mismatch %u != %u (expected)\n" cNORM, + len, mdlen); + return 1; + } + if (memcmp(md, etalon, mdlen) != 0) { + printf(cRED "digest mismatch\n" cNORM); + hexdump(stdout, "actial", md, mdlen ); + hexdump(stdout, "expected", (const unsigned char*)etalon, mdlen ); + return 1; + } + + /* small chunk test. split data on 63+64+rest*/ + if( psize>128 ){ + EVP_MD_CTX *ctx; + T(ctx = EVP_MD_CTX_new()); + T(EVP_DigestInit(ctx, mdtype)); + T(EVP_DigestUpdate(ctx, plaintext, 63)); + T(EVP_DigestUpdate(ctx, plaintext + 63, 64)); + T(EVP_DigestUpdate(ctx, plaintext + 63 + 64, psize - 63 - 64)); + + T(EVP_DigestFinal(ctx, md, &len)); + EVP_MD_CTX_free(ctx); + + if (len != mdlen) { + printf(cRED "digest output len mismatch %u != %u (expected)\n" cNORM, + len, mdlen); + return 1; + } + + if (memcmp(md, etalon, mdlen) != 0) { + printf(cRED "digest mismatch\n" cNORM); + return 1; + } + } + return 0; } static int do_test(const struct hash_testvec *tv) { - int ret = 0; - - const char *mdname = NULL; - if (tv->nid == NID_id_GostR3411_2012_256) - mdname = "streebog256"; - else if (tv->nid == NID_id_GostR3411_2012_512) - mdname = "streebog512"; - printf(cBLUE "Test %s %s: " cNORM, mdname, tv->name); - fflush(stdout); - ret |= do_digest(tv->nid, tv->plaintext, tv->psize, tv->digest); - - /* Text alignment problems. */ - int shifts = 32; - int i; - char *buf; - T(buf = OPENSSL_malloc(tv->psize + shifts)); - for (i = 0; i < shifts; i++) { - memcpy(buf + i, tv->plaintext, tv->psize); - ret |= do_digest(tv->nid, buf + i, tv->psize, tv->digest); - } - OPENSSL_free(buf); + int ret = 0; - if (!ret) - printf(cGREEN "success\n" cNORM); - else - printf(cRED "fail\n" cNORM); - return ret; + const char *mdname = NULL; + if (tv->nid == NID_id_GostR3411_2012_256) + mdname = "streebog256"; + else if (tv->nid == NID_id_GostR3411_2012_512) + mdname = "streebog512"; + printf(cBLUE "Test %s %s: " cNORM, mdname, tv->name); + fflush(stdout); + ret |= do_digest(tv->nid, tv->plaintext, tv->psize, tv->digest); + + /* Test alignment problems. */ + int shifts = 32; + int i; + char *buf; + T(buf = OPENSSL_malloc(tv->psize + shifts)); + for (i = 0; i < shifts; i++) { + memcpy(buf + i, tv->plaintext, tv->psize); + ret |= do_digest(tv->nid, buf + i, tv->psize, tv->digest); + } + OPENSSL_free(buf); + + if (!ret) + printf(cGREEN "success\n" cNORM); + else + printf(cRED "fail\n" cNORM); + return ret; } int main(int argc, char **argv) { int ret = 0; - + setupConsole(); #if MIPSEL /* Trigger SIGBUS for unaligned access. */ sysmips(MIPS_FIXADE, 0); @@ -206,14 +237,15 @@ int main(int argc, char **argv) const struct hash_testvec *tv; for (tv = testvecs; tv->nid; tv++) - ret |= do_test(tv); + ret |= do_test(tv); ENGINE_finish(eng); ENGINE_free(eng); if (ret) - printf(cDRED "= Some tests FAILED!\n" cNORM); + printf(cDRED "= Some tests FAILED!\n" cNORM); else - printf(cDGREEN "= All tests passed!\n" cNORM); + printf(cDGREEN "= All tests passed!\n" cNORM); + restoreConsole(); return ret; } diff --git a/test_gost2814789.c b/test_gost2814789.c index 20e3fe030..1b2d3460f 100644 --- a/test_gost2814789.c +++ b/test_gost2814789.c @@ -8,7 +8,6 @@ * ==================================================================== */ #include - #include #include #include @@ -22,8 +21,9 @@ #define CCGOST_DIR "." #include "gost89.h" +#include "test.h" -#define G89_MAX_TC_LEN (2048) +#define G89_MAX_TC_LEN (2048) #define G89_BLOCK_LEN (8) typedef enum g89_mode_ { @@ -34,1196 +34,1196 @@ typedef enum g89_mode_ { } g89_mode; typedef struct g89_tc_ { - unsigned long long ullLen; // ullLen > G89_MAX_TC_LEN - // Clear text ullLen - // of zero bytes - const byte bIn[G89_MAX_TC_LEN]; // Clear text, when - // ullLen <= G89_MAX_TC_LEN - const char *szParamSet; // S-Box ID - const char *szDerive; // String for derive bRawKey + unsigned long long ullLen; // ullLen > G89_MAX_TC_LEN + // Clear text ullLen + // of zero bytes + const byte bIn[G89_MAX_TC_LEN]; // Clear text, when + // ullLen <= G89_MAX_TC_LEN + const char *szParamSet; // S-Box ID + const char *szDerive; // String for derive bRawKey const byte bRawKey[EVP_MAX_KEY_LENGTH]; - g89_mode gMode; // Mode of encryption or MAC - const byte bIV[EVP_MAX_IV_LENGTH]; // IV for CFB or CNT mode - const byte bOut[G89_MAX_TC_LEN]; // Cipher text for ECB/CFB/CNT - // mode, when ullLen <= G89_MAX_TC_LEN; - // Last 16 byte of cipher text for - // ECB/CFB/CNT, when ullLen > - // G89_MAX_TC_LEN; - // 4 byte MAC for imitovstavka + g89_mode gMode; // Mode of encryption or MAC + const byte bIV[EVP_MAX_IV_LENGTH]; // IV for CFB or CNT mode + const byte bOut[G89_MAX_TC_LEN]; // Cipher text for ECB/CFB/CNT + // mode, when ullLen <= G89_MAX_TC_LEN; + // Last 16 byte of cipher text for + // ECB/CFB/CNT, when ullLen > + // G89_MAX_TC_LEN; + // 4 byte MAC for imitovstavka } g89_tc; const g89_tc tcs[] = { /* * GOST R 34.11-94 Test cases */ - { /* see p. A.3.1 [GOSTR341194], p. 7.3.1 [ENG-GOSTR341194] */ - /* */ - /* Iteration 1, K[1], see Errata for RFC 5831 */ - 8, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - "id-GostR3410-94-TestParamSet", - NULL, - { - 0x54, 0x6d, 0x20, 0x33, 0x68, 0x65, 0x6c, 0x32, - 0x69, 0x73, 0x65, 0x20, 0x73, 0x73, 0x6e, 0x62, - 0x20, 0x61, 0x67, 0x79, 0x69, 0x67, 0x74, 0x74, - 0x73, 0x65, 0x68, 0x65, 0x20, 0x2c, 0x3d, 0x73 - }, - G89_ECB, - { 0 }, - { - 0x1b, 0x0b, 0xbc, 0x32, 0xce, 0xbc, 0xab, 0x42 - } + { /* see p. A.3.1 [GOSTR341194], p. 7.3.1 [ENG-GOSTR341194] */ + /* */ + /* Iteration 1, K[1], see Errata for RFC 5831 */ + 8, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + "id-GostR3410-94-TestParamSet", + NULL, + { + 0x54, 0x6d, 0x20, 0x33, 0x68, 0x65, 0x6c, 0x32, + 0x69, 0x73, 0x65, 0x20, 0x73, 0x73, 0x6e, 0x62, + 0x20, 0x61, 0x67, 0x79, 0x69, 0x67, 0x74, 0x74, + 0x73, 0x65, 0x68, 0x65, 0x20, 0x2c, 0x3d, 0x73 + }, + G89_ECB, + { 0 }, + { + 0x1b, 0x0b, 0xbc, 0x32, 0xce, 0xbc, 0xab, 0x42 + } }, - { /* see p. A.3.1 [GOSTR341194], p. 7.3.1 [ENG-GOSTR341194] */ - /* */ - /* Iteration 1, K[4] */ - 8, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - "id-GostR3410-94-TestParamSet", - NULL, - { - 0xec, 0x0a, 0x8b, 0xa1, 0x5e, 0xc0, 0x04, 0xa8, - 0xba, 0xc5, 0x0c, 0xac, 0x0c, 0x62, 0x1d, 0xee, - 0xe1, 0xc7, 0xb8, 0xe7, 0x00, 0x7a, 0xe2, 0xec, - 0xf2, 0x73, 0x1b, 0xff, 0x4e, 0x80, 0xe2, 0xa0 - }, - G89_ECB, - { 0 }, - { - 0x2d, 0x56, 0x2a, 0x0d, 0x19, 0x04, 0x86, 0xe7 - } + { /* see p. A.3.1 [GOSTR341194], p. 7.3.1 [ENG-GOSTR341194] */ + /* */ + /* Iteration 1, K[4] */ + 8, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + "id-GostR3410-94-TestParamSet", + NULL, + { + 0xec, 0x0a, 0x8b, 0xa1, 0x5e, 0xc0, 0x04, 0xa8, + 0xba, 0xc5, 0x0c, 0xac, 0x0c, 0x62, 0x1d, 0xee, + 0xe1, 0xc7, 0xb8, 0xe7, 0x00, 0x7a, 0xe2, 0xec, + 0xf2, 0x73, 0x1b, 0xff, 0x4e, 0x80, 0xe2, 0xa0 + }, + G89_ECB, + { 0 }, + { + 0x2d, 0x56, 0x2a, 0x0d, 0x19, 0x04, 0x86, 0xe7 + } }, - { /* see p. A.3.1 [GOSTR341194], p. 7.3.1 [ENG-GOSTR341194] */ - /* */ - /* Iteration 2, K[1] */ - 8, - { - 0x34, 0xc0, 0x15, 0x33, 0xe3, 0x7d, 0x1c, 0x56 - }, - "id-GostR3410-94-TestParamSet", - NULL, - { - 0x34, 0x87, 0x24, 0xa4, 0xc1, 0xa6, 0x76, 0x67, - 0x15, 0x3d, 0xde, 0x59, 0x33, 0x88, 0x42, 0x50, - 0xe3, 0x24, 0x8c, 0x65, 0x7d, 0x41, 0x3b, 0x8c, - 0x1c, 0x9c, 0xa0, 0x9a, 0x56, 0xd9, 0x68, 0xcf - }, - G89_ECB, - { 0 }, - { - 0x86, 0x3e, 0x78, 0xdd, 0x2d, 0x60, 0xd1, 0x3c - } + { /* see p. A.3.1 [GOSTR341194], p. 7.3.1 [ENG-GOSTR341194] */ + /* */ + /* Iteration 2, K[1] */ + 8, + { + 0x34, 0xc0, 0x15, 0x33, 0xe3, 0x7d, 0x1c, 0x56 + }, + "id-GostR3410-94-TestParamSet", + NULL, + { + 0x34, 0x87, 0x24, 0xa4, 0xc1, 0xa6, 0x76, 0x67, + 0x15, 0x3d, 0xde, 0x59, 0x33, 0x88, 0x42, 0x50, + 0xe3, 0x24, 0x8c, 0x65, 0x7d, 0x41, 0x3b, 0x8c, + 0x1c, 0x9c, 0xa0, 0x9a, 0x56, 0xd9, 0x68, 0xcf + }, + G89_ECB, + { 0 }, + { + 0x86, 0x3e, 0x78, 0xdd, 0x2d, 0x60, 0xd1, 0x3c + } }, - /* - * id-Gost28147-89-CryptoPro-A-ParamSet (1.2.643.2.2.31.1) - * Test cases - */ - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 16, - { - 0x74, 0x3d, 0x76, 0xf9, 0x1b, 0xee, 0x35, 0x3c, - 0xa2, 0x5c, 0x3b, 0x10, 0xeb, 0x64, 0xcf, 0xf5 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testecb1", - { - 0xbb, 0xf1, 0xed, 0xd3, 0x20, 0xaf, 0x8a, 0x62, - 0x8e, 0x11, 0xc8, 0xa9, 0x51, 0xcc, 0xbe, 0x81, - 0x47, 0x7b, 0x41, 0xa1, 0x6a, 0xf6, 0x7f, 0x05, - 0xe8, 0x51, 0x2f, 0x9e, 0x01, 0xf8, 0xcf, 0x49 - }, - G89_ECB, - { 0 }, - { - 0xc3, 0x73, 0x90, 0x95, 0x35, 0x58, 0x08, 0x63, - 0xcb, 0x68, 0x85, 0x96, 0x77, 0xe8, 0xfb, 0xa9 - } + /* + * id-Gost28147-89-CryptoPro-A-ParamSet (1.2.643.2.2.31.1) + * Test cases + */ + { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ + 16, + { + 0x74, 0x3d, 0x76, 0xf9, 0x1b, 0xee, 0x35, 0x3c, + 0xa2, 0x5c, 0x3b, 0x10, 0xeb, 0x64, 0xcf, 0xf5 + }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "testecb1", + { + 0xbb, 0xf1, 0xed, 0xd3, 0x20, 0xaf, 0x8a, 0x62, + 0x8e, 0x11, 0xc8, 0xa9, 0x51, 0xcc, 0xbe, 0x81, + 0x47, 0x7b, 0x41, 0xa1, 0x6a, 0xf6, 0x7f, 0x05, + 0xe8, 0x51, 0x2f, 0x9e, 0x01, 0xf8, 0xcf, 0x49 + }, + G89_ECB, + { 0 }, + { + 0xc3, 0x73, 0x90, 0x95, 0x35, 0x58, 0x08, 0x63, + 0xcb, 0x68, 0x85, 0x96, 0x77, 0xe8, 0xfb, 0xa9 + } }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 16, - { - 0xd2, 0xfd, 0xf8, 0x3a, 0xc1, 0xb4, 0x39, 0x23, - 0x2e, 0xaa, 0xcc, 0x98, 0x0a, 0x02, 0xda, 0x33 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testcfb1", - { - 0x8d, 0x5a, 0x2c, 0x83, 0xa7, 0xc7, 0x0a, 0x61, - 0xd6, 0x1b, 0x34, 0xb5, 0x1f, 0xdf, 0x42, 0x68, - 0x66, 0x71, 0xa3, 0x5d, 0x87, 0x4c, 0xfd, 0x84, - 0x99, 0x36, 0x63, 0xb6, 0x1e, 0xd6, 0x0d, 0xad - }, - G89_CFB, - { - 0x46, 0x60, 0x6f, 0x0d, 0x88, 0x34, 0x23, 0x5a - }, - { - 0x88, 0xb7, 0x75, 0x16, 0x74, 0xa5, 0xee, 0x2d, - 0x14, 0xfe, 0x91, 0x67, 0xd0, 0x5c, 0xcc, 0x40 - } + { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ + 16, + { + 0xd2, 0xfd, 0xf8, 0x3a, 0xc1, 0xb4, 0x39, 0x23, + 0x2e, 0xaa, 0xcc, 0x98, 0x0a, 0x02, 0xda, 0x33 + }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "testcfb1", + { + 0x8d, 0x5a, 0x2c, 0x83, 0xa7, 0xc7, 0x0a, 0x61, + 0xd6, 0x1b, 0x34, 0xb5, 0x1f, 0xdf, 0x42, 0x68, + 0x66, 0x71, 0xa3, 0x5d, 0x87, 0x4c, 0xfd, 0x84, + 0x99, 0x36, 0x63, 0xb6, 0x1e, 0xd6, 0x0d, 0xad + }, + G89_CFB, + { + 0x46, 0x60, 0x6f, 0x0d, 0x88, 0x34, 0x23, 0x5a + }, + { + 0x88, 0xb7, 0x75, 0x16, 0x74, 0xa5, 0xee, 0x2d, + 0x14, 0xfe, 0x91, 0x67, 0xd0, 0x5c, 0xcc, 0x40 + } }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 16, - { - 0x90, 0xa2, 0x39, 0x66, 0xae, 0x01, 0xb9, 0xa3, - 0x52, 0x4e, 0xc8, 0xed, 0x6c, 0xdd, 0x88, 0x30 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testcnt1", - { - 0x59, 0x9f, 0x84, 0xba, 0xc3, 0xf3, 0xd2, 0xf1, - 0x60, 0xe1, 0xe3, 0xf2, 0x6a, 0x96, 0x1a, 0xf9, - 0x9c, 0x48, 0xb2, 0x4e, 0xbc, 0xbb, 0xbf, 0x7c, - 0xd8, 0xf3, 0xac, 0xcd, 0x96, 0x8d, 0x28, 0x6a - }, - G89_CNT, - { - 0x8d, 0xaf, 0xa8, 0xd1, 0x58, 0xed, 0x05, 0x8d - }, - { - 0x6e, 0x72, 0x62, 0xcc, 0xe3, 0x59, 0x36, 0x90, - 0x83, 0x3a, 0xfe, 0xa9, 0x1b, 0xc9, 0xbe, 0xce - } + { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ + 16, + { + 0x90, 0xa2, 0x39, 0x66, 0xae, 0x01, 0xb9, 0xa3, + 0x52, 0x4e, 0xc8, 0xed, 0x6c, 0xdd, 0x88, 0x30 + }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "testcnt1", + { + 0x59, 0x9f, 0x84, 0xba, 0xc3, 0xf3, 0xd2, 0xf1, + 0x60, 0xe1, 0xe3, 0xf2, 0x6a, 0x96, 0x1a, 0xf9, + 0x9c, 0x48, 0xb2, 0x4e, 0xbc, 0xbb, 0xbf, 0x7c, + 0xd8, 0xf3, 0xac, 0xcd, 0x96, 0x8d, 0x28, 0x6a + }, + G89_CNT, + { + 0x8d, 0xaf, 0xa8, 0xd1, 0x58, 0xed, 0x05, 0x8d + }, + { + 0x6e, 0x72, 0x62, 0xcc, 0xe3, 0x59, 0x36, 0x90, + 0x83, 0x3a, 0xfe, 0xa9, 0x1b, 0xc9, 0xbe, 0xce + } }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 16, - { - 0xb5, 0xa1, 0xf0, 0xe3, 0xce, 0x2f, 0x02, 0x1d, - 0x67, 0x61, 0x94, 0x34, 0x5c, 0x41, 0xe3, 0x6e - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testimit1", - { - 0x9d, 0x05, 0xb7, 0x9e, 0x90, 0xca, 0xd0, 0x0a, - 0x2c, 0xda, 0xd2, 0x2e, 0xf4, 0xe8, 0x6f, 0x5c, - 0xf5, 0xdc, 0x37, 0x68, 0x19, 0x85, 0xb3, 0xbf, - 0xaa, 0x18, 0xc1, 0xc3, 0x05, 0x0a, 0x91, 0xa2 - }, - G89_IMIT, - { 0 }, - { - 0xf8, 0x1f, 0x08, 0xa3 - } + { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ + 16, + { + 0xb5, 0xa1, 0xf0, 0xe3, 0xce, 0x2f, 0x02, 0x1d, + 0x67, 0x61, 0x94, 0x34, 0x5c, 0x41, 0xe3, 0x6e + }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "testimit1", + { + 0x9d, 0x05, 0xb7, 0x9e, 0x90, 0xca, 0xd0, 0x0a, + 0x2c, 0xda, 0xd2, 0x2e, 0xf4, 0xe8, 0x6f, 0x5c, + 0xf5, 0xdc, 0x37, 0x68, 0x19, 0x85, 0xb3, 0xbf, + 0xaa, 0x18, 0xc1, 0xc3, 0x05, 0x0a, 0x91, 0xa2 + }, + G89_IMIT, + { 0 }, + { + 0xf8, 0x1f, 0x08, 0xa3 + } }, - /* - * Other paramsets and key meshing test cases. - */ + /* + * Other paramsets and key meshing test cases. + */ { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 1039, - { - 0x8c, 0x9c, 0x44, 0x35, 0xfb, 0xe9, 0xa5, 0xa3, - 0xa0, 0xae, 0x28, 0x56, 0x91, 0x10, 0x8e, 0x1e , - 0xd2, 0xbb, 0x18, 0x53, 0x81, 0x27, 0x0d, 0xa6, - 0x68, 0x59, 0x36, 0xc5, 0x81, 0x62, 0x9a, 0x8e, - 0x7d, 0x50, 0xf1, 0x6f, 0x97, 0x62, 0x29, 0xec, - 0x80, 0x51, 0xe3, 0x7d, 0x6c, 0xc4, 0x07, 0x95, - 0x28, 0x63, 0xdc, 0xb4, 0xb9, 0x2d, 0xb8, 0x13, - 0xb1, 0x05, 0xb5, 0xf9, 0xeb, 0x75, 0x37, 0x4e, - 0xf7, 0xbf, 0x51, 0xf1, 0x98, 0x86, 0x43, 0xc4, - 0xe4, 0x3d, 0x3e, 0xa7, 0x62, 0xec, 0x41, 0x59, - 0xe0, 0xbd, 0xfb, 0xb6, 0xfd, 0xec, 0xe0, 0x77, - 0x13, 0xd2, 0x59, 0x90, 0xa1, 0xb8, 0x97, 0x6b, - 0x3d, 0x8b, 0x7d, 0xfc, 0x9d, 0xca, 0x82, 0x73, - 0x32, 0x70, 0x0a, 0x74, 0x03, 0xc6, 0x0c, 0x26, - 0x7f, 0x56, 0xf0, 0x9d, 0xb2, 0xeb, 0x71, 0x40, - 0xd7, 0xc3, 0xb1, 0xa7, 0xc5, 0x1e, 0x20, 0x17, - 0xb3, 0x50, 0x1d, 0x8a, 0x6e, 0x19, 0xcb, 0xbe, - 0x20, 0x86, 0x2b, 0xd6, 0x1c, 0xfd, 0xb4, 0xb7, - 0x5d, 0x9a, 0xb3, 0xe3, 0x7d, 0x15, 0x7a, 0x35, - 0x01, 0x9f, 0x5d, 0x65, 0x89, 0x4b, 0x34, 0xc6, - 0xf4, 0x81, 0x3f, 0x78, 0x30, 0xcf, 0xe9, 0x15, - 0x90, 0x9a, 0xf9, 0xde, 0xba, 0x63, 0xd0, 0x19, - 0x14, 0x66, 0x3c, 0xb9, 0xa4, 0xb2, 0x84, 0x94, - 0x02, 0xcf, 0xce, 0x20, 0xcf, 0x76, 0xe7, 0xc5, - 0x48, 0xf7, 0x69, 0x3a, 0x5d, 0xec, 0xaf, 0x41, - 0xa7, 0x12, 0x64, 0x83, 0xf5, 0x99, 0x1e, 0x9e, - 0xb2, 0xab, 0x86, 0x16, 0x00, 0x23, 0x8e, 0xe6, - 0xd9, 0x80, 0x0b, 0x6d, 0xc5, 0x93, 0xe2, 0x5c, - 0x8c, 0xd8, 0x5e, 0x5a, 0xae, 0x4a, 0x85, 0xfd, - 0x76, 0x01, 0xea, 0x30, 0xf3, 0x78, 0x34, 0x10, - 0x72, 0x51, 0xbc, 0x9f, 0x76, 0xce, 0x1f, 0xd4, - 0x8f, 0x33, 0x50, 0x34, 0xc7, 0x4d, 0x7b, 0xcf, - 0x91, 0x63, 0x7d, 0x82, 0x9e, 0xa1, 0x23, 0x45, - 0xf5, 0x45, 0xac, 0x98, 0x7a, 0x48, 0xff, 0x64, - 0xd5, 0x59, 0x47, 0xde, 0x2b, 0x3f, 0xfa, 0xec, - 0x50, 0xe0, 0x81, 0x60, 0x8b, 0xc3, 0xfc, 0x80, - 0x98, 0x17, 0xc7, 0xa3, 0xc2, 0x57, 0x3d, 0xab, - 0x91, 0x67, 0xf5, 0xc4, 0xab, 0x92, 0xc8, 0xd6, - 0x3b, 0x6b, 0x3f, 0xff, 0x15, 0x6b, 0xcf, 0x53, - 0x65, 0x02, 0xf1, 0x74, 0xca, 0xa9, 0xbe, 0x24, - 0xd2, 0xf0, 0xb7, 0x26, 0xa8, 0xd7, 0x6d, 0xed, - 0x90, 0x36, 0x7b, 0x3e, 0x41, 0xa9, 0x7f, 0xa3, - 0x1b, 0xf4, 0x43, 0xc5, 0x51, 0xbe, 0x28, 0x59, - 0xe9, 0x45, 0x26, 0x49, 0x38, 0x32, 0xf8, 0xf3, - 0x92, 0x6e, 0x30, 0xcc, 0xb0, 0xa0, 0xf9, 0x01, - 0x14, 0xc8, 0xba, 0xd9, 0xf0, 0x2a, 0x29, 0xe2, - 0x52, 0x9a, 0x76, 0x95, 0x3a, 0x16, 0x32, 0xec, - 0xf4, 0x10, 0xec, 0xee, 0x47, 0x00, 0x70, 0x19, - 0xe4, 0x72, 0x35, 0x66, 0x44, 0x53, 0x2d, 0xa2, - 0xf3, 0xaa, 0x7e, 0x8a, 0x33, 0x13, 0xcd, 0xc8, - 0xbf, 0x0e, 0x40, 0x90, 0x00, 0xe4, 0x42, 0xc3, - 0x09, 0x84, 0xe1, 0x66, 0x17, 0xa2, 0xaf, 0x03, - 0xab, 0x6b, 0xa1, 0xec, 0xfb, 0x17, 0x72, 0x81, - 0xfe, 0x9a, 0x9f, 0xf4, 0xb2, 0x33, 0x1f, 0xae, - 0x0c, 0xd1, 0x6a, 0xae, 0x19, 0xb8, 0xaf, 0xec, - 0xe3, 0xea, 0x00, 0xf8, 0xac, 0x87, 0x07, 0x5f, - 0x6d, 0xb0, 0xac, 0x6b, 0x22, 0x48, 0x36, 0xbf, - 0x22, 0x18, 0xb0, 0x03, 0x9f, 0x6c, 0x70, 0x45, - 0x36, 0xf0, 0x6b, 0xc6, 0xc2, 0xa5, 0x72, 0x2c, - 0xd8, 0xe0, 0x27, 0x3d, 0xec, 0x56, 0x07, 0x05, - 0x7d, 0x83, 0xa1, 0x65, 0x7d, 0x41, 0x5b, 0xcd, - 0x77, 0x24, 0xe5, 0xaa, 0x76, 0x47, 0xd0, 0x50, - 0xf6, 0xe7, 0xb5, 0x59, 0x75, 0x31, 0x27, 0xef, - 0xd8, 0xa6, 0x4e, 0x7f, 0xb8, 0x40, 0xb1, 0xdf, - 0x53, 0x14, 0xed, 0xf1, 0x68, 0x5f, 0xfc, 0x3f, - 0x02, 0xdb, 0x05, 0xeb, 0x31, 0xe4, 0x2c, 0x7f, - 0x32, 0xb5, 0x70, 0x8e, 0x75, 0x85, 0xa4, 0x5c, - 0x16, 0x23, 0x37, 0xf2, 0x10, 0x79, 0xcb, 0xdc, - 0xf8, 0x1c, 0x25, 0xc2, 0xa1, 0x3d, 0x9c, 0x33, - 0x6c, 0xed, 0xc3, 0xe7, 0xf3, 0x02, 0x87, 0x82, - 0x4e, 0xfb, 0xac, 0xb3, 0x2d, 0xfc, 0xf8, 0x0d, - 0x1d, 0x4a, 0x39, 0xd4, 0xb3, 0x09, 0xbb, 0xe9, - 0x25, 0xc7, 0xec, 0x6a, 0x87, 0x72, 0x84, 0xed, - 0x12, 0x60, 0x19, 0x64, 0xeb, 0x16, 0x2a, 0x5b, - 0x10, 0x76, 0x27, 0xff, 0x7b, 0xe4, 0xae, 0xe5, - 0xa4, 0x04, 0x02, 0x7f, 0xbb, 0x0a, 0xb5, 0xf4, - 0x05, 0xa5, 0x56, 0x1c, 0x53, 0x31, 0x7a, 0x93, - 0xba, 0x16, 0x15, 0xab, 0x62, 0x60, 0xfc, 0xde, - 0x72, 0x36, 0x6e, 0x28, 0xaf, 0x98, 0x0d, 0xe6, - 0xf4, 0xde, 0x60, 0xa7, 0x7e, 0x06, 0x07, 0x86, - 0xf3, 0x94, 0xb6, 0x6d, 0x0d, 0x93, 0xa6, 0xbc, - 0x60, 0x70, 0x33, 0xac, 0x3f, 0xa1, 0xa8, 0x4a, - 0x20, 0x61, 0xb6, 0xb5, 0x43, 0xa3, 0x15, 0x5a, - 0x00, 0xbe, 0x76, 0x98, 0x57, 0x72, 0xab, 0x7a, - 0x0e, 0x18, 0x93, 0x82, 0x3a, 0x18, 0x78, 0x6e, - 0x71, 0x7b, 0x78, 0x4f, 0x7e, 0x8c, 0xde, 0x7a, - 0x62, 0xb5, 0x0a, 0x7c, 0x45, 0x1d, 0x16, 0xd5, - 0xc3, 0x8c, 0x9b, 0x25, 0xb4, 0x50, 0x90, 0xcd, - 0x96, 0x93, 0xad, 0x0f, 0xd4, 0x43, 0xcb, 0x49, - 0x0f, 0xfc, 0x5a, 0x31, 0xf4, 0x19, 0xb7, 0xd4, - 0xeb, 0x4d, 0x40, 0x58, 0xd0, 0x3b, 0xc8, 0xe0, - 0x4a, 0x54, 0x2f, 0xdb, 0x22, 0xc3, 0x29, 0x7b, - 0x40, 0x90, 0x61, 0x43, 0xd3, 0x7e, 0xe2, 0x30, - 0x2b, 0x48, 0x3c, 0xce, 0x90, 0x93, 0xb1, 0x8b, - 0x31, 0x96, 0x65, 0x6d, 0x57, 0x8b, 0x9d, 0x4d, - 0x53, 0xf0, 0x83, 0x1c, 0xe5, 0xa1, 0x9d, 0x55, - 0xe3, 0xbf, 0x7e, 0xca, 0x1a, 0x74, 0x66, 0x14, - 0xcc, 0x47, 0x43, 0xd9, 0xbb, 0xef, 0x97, 0x7d, - 0xb7, 0x6e, 0xff, 0xf1, 0x22, 0xf8, 0x10, 0x2d, - 0x3f, 0xcd, 0x49, 0x96, 0xd9, 0x09, 0x11, 0xb8, - 0x33, 0xd0, 0x23, 0x9a, 0xfa, 0x16, 0xcb, 0x50, - 0x26, 0x57, 0x24, 0x5c, 0x0e, 0xba, 0xf0, 0x3f, - 0x37, 0x2f, 0xa3, 0xf7, 0x18, 0x57, 0x48, 0x48, - 0x95, 0xcf, 0xef, 0x87, 0x67, 0x2a, 0xe9, 0xb6, - 0x8a, 0x21, 0x36, 0x7f, 0xff, 0x48, 0x6c, 0x46, - 0x35, 0x57, 0xf2, 0xbc, 0x48, 0x67, 0x8f, 0x63, - 0x23, 0x78, 0x11, 0x2b, 0xc2, 0x08, 0xde, 0x51, - 0xe8, 0x8b, 0x92, 0x29, 0xf9, 0x9a, 0x9e, 0xad, - 0xed, 0x0f, 0xeb, 0xa2, 0xd2, 0x40, 0x92, 0xd4, - 0xde, 0x62, 0x95, 0x76, 0xfd, 0x6e, 0x3c, 0xbf, - 0xc0, 0xd7, 0x0d, 0xe5, 0x1b, 0xa4, 0xc7, 0x18, - 0xe1, 0x58, 0xa4, 0x56, 0xef, 0x2e, 0x17, 0x1b, - 0x75, 0xcb, 0xbc, 0xf9, 0x2a, 0x95, 0x71, 0xa7, - 0x1d, 0x7f, 0xe7, 0x73, 0x63, 0x05, 0x6b, 0x19, - 0x4c, 0xf4, 0x22, 0x14, 0xc4, 0x59, 0x88, 0x66, - 0x92, 0x86, 0x61, 0x5c, 0x6a, 0xae, 0xec, 0x58, - 0xff, 0xc9, 0xf2, 0x44, 0xd4, 0xa2, 0xf5, 0x98, - 0xeb, 0x5f, 0x09, 0xbc, 0x8a, 0xbf, 0x3c, 0xb4, - 0x3e, 0xb1, 0x20, 0x05, 0x44, 0x96, 0x79, 0x0a, - 0x40, 0x92, 0x7f, 0x9d, 0xd1, 0xaf, 0xbc, 0x90, - 0x95, 0x0a, 0x81, 0xd4, 0xa7, 0xc6, 0xb8, 0xe0, - 0xe4, 0x39, 0x30, 0x1d, 0x79, 0xc0, 0xe5, 0xfa, - 0xb4, 0xe9, 0x63, 0xb4, 0x09, 0x72, 0x3b, 0x3e, - 0xd9, 0xf6, 0xd9, 0x10, 0x21, 0x18, 0x7e, 0xe5, - 0xad, 0x81, 0xd7, 0xd5, 0x82, 0xd0, 0x8c, 0x3b, - 0x38, 0x95, 0xf8, 0x92, 0x01, 0xa9, 0x92, 0x00, - 0x70, 0xd1, 0xa7, 0x88, 0x77, 0x1f, 0x3a, 0xeb, - 0xb5, 0xe4, 0xf5, 0x9d, 0xc7, 0x37, 0x86, 0xb2, - 0x12, 0x46, 0x34, 0x19, 0x72, 0x8c, 0xf5, 0x8c, - 0xf6, 0x78, 0x98, 0xe0, 0x7c, 0xd3, 0xf4 - }, - "id-Gost28147-89-CryptoPro-B-ParamSet", - "testcfb2", - { - 0x48, 0x0c, 0x74, 0x1b, 0x02, 0x6b, 0x55, 0xd5, - 0xb6, 0x6d, 0xd7, 0x1d, 0x40, 0x48, 0x05, 0x6b, - 0x6d, 0xeb, 0x3c, 0x29, 0x0f, 0x84, 0x80, 0x23, - 0xee, 0x0d, 0x47, 0x77, 0xe3, 0xfe, 0x61, 0xc9 - }, - G89_CFB, - { - 0x1f, 0x3f, 0x82, 0x1e, 0x0d, 0xd8, 0x1e, 0x22 - }, - { - 0x23, 0xc6, 0x7f, 0x20, 0xa1, 0x23, 0x58, 0xbc, - 0x7b, 0x05, 0xdb, 0x21, 0x15, 0xcf, 0x96, 0x41, - 0xc7, 0x88, 0xef, 0x76, 0x5c, 0x49, 0xdb, 0x42, - 0xbf, 0xf3, 0xc0, 0xf5, 0xbd, 0x5d, 0xd9, 0x8e, - 0xaf, 0x3d, 0xf4, 0xe4, 0xda, 0x88, 0xbd, 0xbc, - 0x47, 0x5d, 0x76, 0x07, 0xc9, 0x5f, 0x54, 0x1d, - 0x1d, 0x6a, 0xa1, 0x2e, 0x18, 0xd6, 0x60, 0x84, - 0x02, 0x18, 0x37, 0x92, 0x92, 0x15, 0xab, 0x21, - 0xee, 0x21, 0xcc, 0x71, 0x6e, 0x51, 0xd9, 0x2b, - 0xcc, 0x81, 0x97, 0x3f,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 0x96, 0x26, 0xf6, 0xe2, - 0x19, 0x61, 0x3f, 0xf4, 0x58, 0x27, 0x0a, 0xeb, - 0xce, 0x7c, 0xb6, 0x68, 0x92, 0xe7, 0x12, 0x3b, - 0x31, 0xd4, 0x48, 0xdf, 0x35, 0x8d, 0xf4, 0x86, - 0x42, 0x2a, 0x15, 0x4b, 0xe8, 0x19, 0x1f, 0x26, - 0x65, 0x9b, 0xa8, 0xda, 0x4b, 0x79, 0x1f, 0x8e, - 0xe6, 0x13, 0x7e, 0x49, 0x8f, 0xc1, 0xce, 0xdc, - 0x5e, 0x64, 0x74, 0xce, 0x02, 0x78, 0xe0, 0xcf, - 0xa0, 0xed, 0x5e, 0x31, 0x74, 0xd1, 0xd0, 0xb4, - 0xee, 0x70, 0x19, 0x14, 0x3c, 0x8f, 0x16, 0xa6, - 0xcf, 0x12, 0x93, 0x15, 0x88, 0xeb, 0x91, 0x65, - 0x76, 0x98, 0xfd, 0xa1, 0x94, 0x30, 0xba, 0x43, - 0x62, 0x65, 0x40, 0x04, 0x77, 0x9e, 0xd6, 0xab, - 0x8b, 0x0d, 0x93, 0x80, 0x50, 0x5f, 0xa2, 0x76, - 0x20, 0xa7, 0xd6, 0x9c, 0x27, 0x15, 0x27, 0xbc, - 0xa5, 0x5a, 0xbf, 0xe9, 0x92, 0x82, 0x05, 0xa8, - 0x41, 0xe9, 0xb5, 0x60, 0xd5, 0xc0, 0xd7, 0x4b, - 0xad, 0x38, 0xb2, 0xe9, 0xd1, 0xe5, 0x51, 0x5f, - 0x24, 0x78, 0x24, 0x9a, 0x23, 0xd2, 0xc2, 0x48, - 0xbd, 0x0e, 0xf1, 0x37, 0x72, 0x91, 0x87, 0xb0, - 0x4e, 0xbd, 0x99, 0x6b, 0x2c, 0x01, 0xb6, 0x79, - 0x69, 0xec, 0x0c, 0xed, 0xe5, 0x3f, 0x50, 0x64, - 0x7c, 0xb9, 0xdd, 0xe1, 0x92, 0x81, 0xb5, 0xd0, - 0xcb, 0x17,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0x08, 0xfa, - 0xe7, 0x0f, 0x03, 0xa9, 0x68, 0xde, 0x6b, 0x41, - 0xa0, 0xf9, 0x41, 0x6c, 0x57, 0x4d, 0x3a, 0x0e, - 0xea, 0x51, 0xca, 0x9f, 0x97, 0x11, 0x7d, 0xf6, - 0x8e, 0x88, 0x63, 0x67, 0xc9, 0x65, 0x13, 0xca, - 0x38, 0xed, 0x35, 0xbe, 0xf4, 0x27, 0xa9, 0xfc, - 0xa9, 0xe6, 0xc3, 0x40, 0x86, 0x08, 0x39, 0x72, - 0x37, 0xee, 0xb2, 0x87, 0x09, 0x96, 0xb7, 0x40, - 0x87, 0x36, 0x92, 0xc1, 0x5d, 0x6a, 0x2c, 0x43, - 0xca, 0x25, 0xc8, 0x35, 0x37, 0x2d, 0xb5, 0xa9, - 0x27, 0x44, 0x50, 0xf2, 0x6d, 0x22, 0x75, 0x41, - 0x77, 0x2a, 0xdb, 0xb1, 0x8c, 0x6d, 0x05, 0xe8, - 0xc9, 0x99, 0xc7, 0x08, 0xf9, 0x14, 0x8f, 0x78, - 0xa9, 0x8f, 0xc2, 0x5a, 0x7a, 0x65, 0xc5, 0xd8, - 0x86, 0xbb, 0x72, 0x69, 0x6b, 0x6b, 0x45, 0x83, - 0x5b, 0xb1, 0xf7, 0xcd, 0x16, 0x73, 0xee, 0xe9, - 0x80, 0x85, 0xfe, 0x8e, 0xe1, 0xae, 0x53, 0x8f, - 0xde, 0xbe, 0x48, 0x8b, 0x59, 0xef, 0xf6, 0x7e, - 0xd8, 0xb5, 0xa8, 0x47, 0xc0, 0x4e, 0x15, 0x58, - 0xca, 0xd3, 0x2f, 0xf8, 0x6c, 0xa6, 0x3d, 0x78, - 0x4d, 0x7a, 0x54, 0xd6, 0x10, 0xe5, 0xcc, 0x05, - 0xe2, 0x29, 0xb5, 0x86, 0x07, 0x39, 0x7d, 0x78, - 0x8e, 0x5a, 0x8f, 0x83, 0x4c, 0xe7, 0x3d, 0x68, - 0x3e, 0xe5, 0x02, 0xe6, 0x64, 0x4f, 0x5e, 0xb4, - 0x49, 0x77, 0xf0, 0xc0, 0xfa, 0x6f, 0xc8, 0xfb, - 0x9f, 0x84, 0x6f, 0x55, 0xfb, 0x30, 0x5e, 0x89, - 0x93, 0xa9, 0xf3, 0xa6, 0xa3, 0xd7, 0x26, 0xbb, - 0xd8, 0xa8, 0xd9, 0x95, 0x1d, 0xfe, 0xfc, 0xd7, - 0xa8, 0x93, 0x66, 0x2f, 0x04, 0x53, 0x06, 0x64, - 0x7f, 0x31, 0x29, 0xae, 0xb7, 0x9f, 0xba, 0xc4, - 0x6d, 0x68, 0xd1, 0x24, 0x32, 0xf4, 0x11 - } + 1039, + { + 0x8c, 0x9c, 0x44, 0x35, 0xfb, 0xe9, 0xa5, 0xa3, + 0xa0, 0xae, 0x28, 0x56, 0x91, 0x10, 0x8e, 0x1e , + 0xd2, 0xbb, 0x18, 0x53, 0x81, 0x27, 0x0d, 0xa6, + 0x68, 0x59, 0x36, 0xc5, 0x81, 0x62, 0x9a, 0x8e, + 0x7d, 0x50, 0xf1, 0x6f, 0x97, 0x62, 0x29, 0xec, + 0x80, 0x51, 0xe3, 0x7d, 0x6c, 0xc4, 0x07, 0x95, + 0x28, 0x63, 0xdc, 0xb4, 0xb9, 0x2d, 0xb8, 0x13, + 0xb1, 0x05, 0xb5, 0xf9, 0xeb, 0x75, 0x37, 0x4e, + 0xf7, 0xbf, 0x51, 0xf1, 0x98, 0x86, 0x43, 0xc4, + 0xe4, 0x3d, 0x3e, 0xa7, 0x62, 0xec, 0x41, 0x59, + 0xe0, 0xbd, 0xfb, 0xb6, 0xfd, 0xec, 0xe0, 0x77, + 0x13, 0xd2, 0x59, 0x90, 0xa1, 0xb8, 0x97, 0x6b, + 0x3d, 0x8b, 0x7d, 0xfc, 0x9d, 0xca, 0x82, 0x73, + 0x32, 0x70, 0x0a, 0x74, 0x03, 0xc6, 0x0c, 0x26, + 0x7f, 0x56, 0xf0, 0x9d, 0xb2, 0xeb, 0x71, 0x40, + 0xd7, 0xc3, 0xb1, 0xa7, 0xc5, 0x1e, 0x20, 0x17, + 0xb3, 0x50, 0x1d, 0x8a, 0x6e, 0x19, 0xcb, 0xbe, + 0x20, 0x86, 0x2b, 0xd6, 0x1c, 0xfd, 0xb4, 0xb7, + 0x5d, 0x9a, 0xb3, 0xe3, 0x7d, 0x15, 0x7a, 0x35, + 0x01, 0x9f, 0x5d, 0x65, 0x89, 0x4b, 0x34, 0xc6, + 0xf4, 0x81, 0x3f, 0x78, 0x30, 0xcf, 0xe9, 0x15, + 0x90, 0x9a, 0xf9, 0xde, 0xba, 0x63, 0xd0, 0x19, + 0x14, 0x66, 0x3c, 0xb9, 0xa4, 0xb2, 0x84, 0x94, + 0x02, 0xcf, 0xce, 0x20, 0xcf, 0x76, 0xe7, 0xc5, + 0x48, 0xf7, 0x69, 0x3a, 0x5d, 0xec, 0xaf, 0x41, + 0xa7, 0x12, 0x64, 0x83, 0xf5, 0x99, 0x1e, 0x9e, + 0xb2, 0xab, 0x86, 0x16, 0x00, 0x23, 0x8e, 0xe6, + 0xd9, 0x80, 0x0b, 0x6d, 0xc5, 0x93, 0xe2, 0x5c, + 0x8c, 0xd8, 0x5e, 0x5a, 0xae, 0x4a, 0x85, 0xfd, + 0x76, 0x01, 0xea, 0x30, 0xf3, 0x78, 0x34, 0x10, + 0x72, 0x51, 0xbc, 0x9f, 0x76, 0xce, 0x1f, 0xd4, + 0x8f, 0x33, 0x50, 0x34, 0xc7, 0x4d, 0x7b, 0xcf, + 0x91, 0x63, 0x7d, 0x82, 0x9e, 0xa1, 0x23, 0x45, + 0xf5, 0x45, 0xac, 0x98, 0x7a, 0x48, 0xff, 0x64, + 0xd5, 0x59, 0x47, 0xde, 0x2b, 0x3f, 0xfa, 0xec, + 0x50, 0xe0, 0x81, 0x60, 0x8b, 0xc3, 0xfc, 0x80, + 0x98, 0x17, 0xc7, 0xa3, 0xc2, 0x57, 0x3d, 0xab, + 0x91, 0x67, 0xf5, 0xc4, 0xab, 0x92, 0xc8, 0xd6, + 0x3b, 0x6b, 0x3f, 0xff, 0x15, 0x6b, 0xcf, 0x53, + 0x65, 0x02, 0xf1, 0x74, 0xca, 0xa9, 0xbe, 0x24, + 0xd2, 0xf0, 0xb7, 0x26, 0xa8, 0xd7, 0x6d, 0xed, + 0x90, 0x36, 0x7b, 0x3e, 0x41, 0xa9, 0x7f, 0xa3, + 0x1b, 0xf4, 0x43, 0xc5, 0x51, 0xbe, 0x28, 0x59, + 0xe9, 0x45, 0x26, 0x49, 0x38, 0x32, 0xf8, 0xf3, + 0x92, 0x6e, 0x30, 0xcc, 0xb0, 0xa0, 0xf9, 0x01, + 0x14, 0xc8, 0xba, 0xd9, 0xf0, 0x2a, 0x29, 0xe2, + 0x52, 0x9a, 0x76, 0x95, 0x3a, 0x16, 0x32, 0xec, + 0xf4, 0x10, 0xec, 0xee, 0x47, 0x00, 0x70, 0x19, + 0xe4, 0x72, 0x35, 0x66, 0x44, 0x53, 0x2d, 0xa2, + 0xf3, 0xaa, 0x7e, 0x8a, 0x33, 0x13, 0xcd, 0xc8, + 0xbf, 0x0e, 0x40, 0x90, 0x00, 0xe4, 0x42, 0xc3, + 0x09, 0x84, 0xe1, 0x66, 0x17, 0xa2, 0xaf, 0x03, + 0xab, 0x6b, 0xa1, 0xec, 0xfb, 0x17, 0x72, 0x81, + 0xfe, 0x9a, 0x9f, 0xf4, 0xb2, 0x33, 0x1f, 0xae, + 0x0c, 0xd1, 0x6a, 0xae, 0x19, 0xb8, 0xaf, 0xec, + 0xe3, 0xea, 0x00, 0xf8, 0xac, 0x87, 0x07, 0x5f, + 0x6d, 0xb0, 0xac, 0x6b, 0x22, 0x48, 0x36, 0xbf, + 0x22, 0x18, 0xb0, 0x03, 0x9f, 0x6c, 0x70, 0x45, + 0x36, 0xf0, 0x6b, 0xc6, 0xc2, 0xa5, 0x72, 0x2c, + 0xd8, 0xe0, 0x27, 0x3d, 0xec, 0x56, 0x07, 0x05, + 0x7d, 0x83, 0xa1, 0x65, 0x7d, 0x41, 0x5b, 0xcd, + 0x77, 0x24, 0xe5, 0xaa, 0x76, 0x47, 0xd0, 0x50, + 0xf6, 0xe7, 0xb5, 0x59, 0x75, 0x31, 0x27, 0xef, + 0xd8, 0xa6, 0x4e, 0x7f, 0xb8, 0x40, 0xb1, 0xdf, + 0x53, 0x14, 0xed, 0xf1, 0x68, 0x5f, 0xfc, 0x3f, + 0x02, 0xdb, 0x05, 0xeb, 0x31, 0xe4, 0x2c, 0x7f, + 0x32, 0xb5, 0x70, 0x8e, 0x75, 0x85, 0xa4, 0x5c, + 0x16, 0x23, 0x37, 0xf2, 0x10, 0x79, 0xcb, 0xdc, + 0xf8, 0x1c, 0x25, 0xc2, 0xa1, 0x3d, 0x9c, 0x33, + 0x6c, 0xed, 0xc3, 0xe7, 0xf3, 0x02, 0x87, 0x82, + 0x4e, 0xfb, 0xac, 0xb3, 0x2d, 0xfc, 0xf8, 0x0d, + 0x1d, 0x4a, 0x39, 0xd4, 0xb3, 0x09, 0xbb, 0xe9, + 0x25, 0xc7, 0xec, 0x6a, 0x87, 0x72, 0x84, 0xed, + 0x12, 0x60, 0x19, 0x64, 0xeb, 0x16, 0x2a, 0x5b, + 0x10, 0x76, 0x27, 0xff, 0x7b, 0xe4, 0xae, 0xe5, + 0xa4, 0x04, 0x02, 0x7f, 0xbb, 0x0a, 0xb5, 0xf4, + 0x05, 0xa5, 0x56, 0x1c, 0x53, 0x31, 0x7a, 0x93, + 0xba, 0x16, 0x15, 0xab, 0x62, 0x60, 0xfc, 0xde, + 0x72, 0x36, 0x6e, 0x28, 0xaf, 0x98, 0x0d, 0xe6, + 0xf4, 0xde, 0x60, 0xa7, 0x7e, 0x06, 0x07, 0x86, + 0xf3, 0x94, 0xb6, 0x6d, 0x0d, 0x93, 0xa6, 0xbc, + 0x60, 0x70, 0x33, 0xac, 0x3f, 0xa1, 0xa8, 0x4a, + 0x20, 0x61, 0xb6, 0xb5, 0x43, 0xa3, 0x15, 0x5a, + 0x00, 0xbe, 0x76, 0x98, 0x57, 0x72, 0xab, 0x7a, + 0x0e, 0x18, 0x93, 0x82, 0x3a, 0x18, 0x78, 0x6e, + 0x71, 0x7b, 0x78, 0x4f, 0x7e, 0x8c, 0xde, 0x7a, + 0x62, 0xb5, 0x0a, 0x7c, 0x45, 0x1d, 0x16, 0xd5, + 0xc3, 0x8c, 0x9b, 0x25, 0xb4, 0x50, 0x90, 0xcd, + 0x96, 0x93, 0xad, 0x0f, 0xd4, 0x43, 0xcb, 0x49, + 0x0f, 0xfc, 0x5a, 0x31, 0xf4, 0x19, 0xb7, 0xd4, + 0xeb, 0x4d, 0x40, 0x58, 0xd0, 0x3b, 0xc8, 0xe0, + 0x4a, 0x54, 0x2f, 0xdb, 0x22, 0xc3, 0x29, 0x7b, + 0x40, 0x90, 0x61, 0x43, 0xd3, 0x7e, 0xe2, 0x30, + 0x2b, 0x48, 0x3c, 0xce, 0x90, 0x93, 0xb1, 0x8b, + 0x31, 0x96, 0x65, 0x6d, 0x57, 0x8b, 0x9d, 0x4d, + 0x53, 0xf0, 0x83, 0x1c, 0xe5, 0xa1, 0x9d, 0x55, + 0xe3, 0xbf, 0x7e, 0xca, 0x1a, 0x74, 0x66, 0x14, + 0xcc, 0x47, 0x43, 0xd9, 0xbb, 0xef, 0x97, 0x7d, + 0xb7, 0x6e, 0xff, 0xf1, 0x22, 0xf8, 0x10, 0x2d, + 0x3f, 0xcd, 0x49, 0x96, 0xd9, 0x09, 0x11, 0xb8, + 0x33, 0xd0, 0x23, 0x9a, 0xfa, 0x16, 0xcb, 0x50, + 0x26, 0x57, 0x24, 0x5c, 0x0e, 0xba, 0xf0, 0x3f, + 0x37, 0x2f, 0xa3, 0xf7, 0x18, 0x57, 0x48, 0x48, + 0x95, 0xcf, 0xef, 0x87, 0x67, 0x2a, 0xe9, 0xb6, + 0x8a, 0x21, 0x36, 0x7f, 0xff, 0x48, 0x6c, 0x46, + 0x35, 0x57, 0xf2, 0xbc, 0x48, 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0x46, 0x34, 0x19, 0x72, 0x8c, 0xf5, 0x8c, + 0xf6, 0x78, 0x98, 0xe0, 0x7c, 0xd3, 0xf4 + }, + "id-Gost28147-89-CryptoPro-B-ParamSet", + "testcfb2", + { + 0x48, 0x0c, 0x74, 0x1b, 0x02, 0x6b, 0x55, 0xd5, + 0xb6, 0x6d, 0xd7, 0x1d, 0x40, 0x48, 0x05, 0x6b, + 0x6d, 0xeb, 0x3c, 0x29, 0x0f, 0x84, 0x80, 0x23, + 0xee, 0x0d, 0x47, 0x77, 0xe3, 0xfe, 0x61, 0xc9 + }, + G89_CFB, + { + 0x1f, 0x3f, 0x82, 0x1e, 0x0d, 0xd8, 0x1e, 0x22 + }, + { + 0x23, 0xc6, 0x7f, 0x20, 0xa1, 0x23, 0x58, 0xbc, + 0x7b, 0x05, 0xdb, 0x21, 0x15, 0xcf, 0x96, 0x41, + 0xc7, 0x88, 0xef, 0x76, 0x5c, 0x49, 0xdb, 0x42, + 0xbf, 0xf3, 0xc0, 0xf5, 0xbd, 0x5d, 0xd9, 0x8e, + 0xaf, 0x3d, 0xf4, 0xe4, 0xda, 0x88, 0xbd, 0xbc, + 0x47, 0x5d, 0x76, 0x07, 0xc9, 0x5f, 0x54, 0x1d, + 0x1d, 0x6a, 0xa1, 0x2e, 0x18, 0xd6, 0x60, 0x84, + 0x02, 0x18, 0x37, 0x92, 0x92, 0x15, 0xab, 0x21, + 0xee, 0x21, 0xcc, 0x71, 0x6e, 0x51, 0xd9, 0x2b, + 0xcc, 0x81, 0x97, 0x3f, 0xeb, 0x45, 0x99, 0xb8, + 0x1b, 0xda, 0xff, 0x90, 0xd3, 0x41, 0x06, 0x9c, + 0x3f, 0xfb, 0xe4, 0xb2, 0xdc, 0xc9, 0x03, 0x0d, + 0xa7, 0xae, 0xd7, 0x7d, 0x02, 0xb8, 0x32, 0xab, + 0xf3, 0x65, 0xa3, 0x65, 0x6c, 0x4e, 0xe4, 0xa2, + 0x5e, 0x9e, 0xee, 0xcd, 0xde, 0x79, 0x36, 0x6b, + 0x1b, 0xe1, 0x3c, 0xdf, 0x10, 0xad, 0x4f, 0x02, + 0xe1, 0x14, 0xaa, 0x09, 0xb4, 0x0b, 0x76, 0xeb, + 0x69, 0x38, 0x20, 0x02, 0xcb, 0x8e, 0xc0, 0xdf, + 0xca, 0x48, 0x74, 0xc3, 0x31, 0xad, 0x42, 0x2c, + 0x51, 0x9b, 0xd0, 0x6a, 0xc1, 0x36, 0xd7, 0x21, + 0xdf, 0xb0, 0x45, 0xba, 0xca, 0x7f, 0x35, 0x20, + 0x28, 0xbb, 0xc1, 0x76, 0xfd, 0x43, 0x5d, 0x23, + 0x7d, 0x31, 0x84, 0x1a, 0x97, 0x4d, 0x83, 0xaa, + 0x7e, 0xf1, 0xc4, 0xe6, 0x83, 0xac, 0x0d, 0xef, + 0xef, 0x3c, 0xa4, 0x7c, 0x48, 0xe4, 0xc8, 0xca, + 0x0d, 0x7d, 0xea, 0x7c, 0x45, 0xd7, 0x73, 0x50, + 0x25, 0x1d, 0x01, 0xc4, 0x02, 0x1a, 0xcd, 0xe0, + 0x38, 0x5b, 0xa8, 0x5a, 0x16, 0x9a, 0x10, 0x59, + 0x74, 0xd7, 0x19, 0xc6, 0xf3, 0xb5, 0x17, 0xf6, + 0x59, 0x8d, 0x62, 0xaf, 0x44, 0xe8, 0xdc, 0xe9, + 0xc1, 0x76, 0xf1, 0xd0, 0xbd, 0x29, 0xd7, 0xec, + 0x1d, 0xac, 0x57, 0xdb, 0x1a, 0x3f, 0xd8, 0xf6, + 0x6e, 0xb6, 0xe6, 0xdf, 0x36, 0xe7, 0x89, 0xce, + 0x56, 0x35, 0x43, 0x1c, 0x7d, 0x57, 0x79, 0x0e, + 0xd8, 0xf4, 0xd7, 0xa7, 0x0d, 0xc6, 0x8f, 0x91, + 0x66, 0x67, 0x82, 0x0f, 0x49, 0xc9, 0xc5, 0x65, + 0x81, 0xa1, 0x39, 0x5a, 0x53, 0x9f, 0x02, 0xa5, + 0xd5, 0x36, 0x22, 0xa8, 0xa8, 0x1c, 0x37, 0x0e, + 0x76, 0x46, 0xdf, 0xbd, 0x6a, 0xdb, 0xfc, 0x1b, + 0xbd, 0x10, 0xb8, 0xb1, 0xbc, 0x72, 0x4c, 0x58, + 0x4a, 0xda, 0x6d, 0x66, 0x00, 0xda, 0x7a, 0x66, + 0xa0, 0xe7, 0x3b, 0x39, 0xa3, 0xf7, 0x05, 0x07, + 0xfa, 0x21, 0x4b, 0xc7, 0x94, 0xc0, 0xd3, 0x7b, + 0x19, 0x02, 0x5d, 0x4a, 0x10, 0xf1, 0xc2, 0x0f, + 0x19, 0x68, 0x27, 0xc7, 0x7d, 0xbf, 0x55, 0x03, + 0x57, 0x7d, 0xaf, 0x77, 0xae, 0x80, 0x2f, 0x7a, + 0xe6, 0x1f, 0x4b, 0xdc, 0x15, 0x18, 0xc0, 0x62, + 0xa1, 0xe8, 0xd9, 0x1c, 0x9e, 0x8c, 0x96, 0x39, + 0xc1, 0xc4, 0x88, 0xf7, 0x0c, 0xe1, 0x04, 0x84, + 0x68, 0x51, 0xce, 0xf1, 0x90, 0xda, 0x7f, 0x76, + 0xc8, 0xc0, 0x88, 0xef, 0x8e, 0x15, 0x25, 0x3e, + 0x7b, 0xe4, 0x79, 0xb5, 0x66, 0x2d, 0x9c, 0xd1, + 0x13, 0xda, 0xd0, 0xd5, 0x46, 0xd5, 0x8d, 0x46, + 0x18, 0x07, 0xee, 0xd8, 0xc9, 0x64, 0xe3, 0xbe, + 0x0e, 0x68, 0x27, 0x09, 0x96, 0x26, 0xf6, 0xe2, + 0x19, 0x61, 0x3f, 0xf4, 0x58, 0x27, 0x0a, 0xeb, + 0xce, 0x7c, 0xb6, 0x68, 0x92, 0xe7, 0x12, 0x3b, + 0x31, 0xd4, 0x48, 0xdf, 0x35, 0x8d, 0xf4, 0x86, + 0x42, 0x2a, 0x15, 0x4b, 0xe8, 0x19, 0x1f, 0x26, + 0x65, 0x9b, 0xa8, 0xda, 0x4b, 0x79, 0x1f, 0x8e, + 0xe6, 0x13, 0x7e, 0x49, 0x8f, 0xc1, 0xce, 0xdc, + 0x5e, 0x64, 0x74, 0xce, 0x02, 0x78, 0xe0, 0xcf, + 0xa0, 0xed, 0x5e, 0x31, 0x74, 0xd1, 0xd0, 0xb4, + 0xee, 0x70, 0x19, 0x14, 0x3c, 0x8f, 0x16, 0xa6, + 0xcf, 0x12, 0x93, 0x15, 0x88, 0xeb, 0x91, 0x65, + 0x76, 0x98, 0xfd, 0xa1, 0x94, 0x30, 0xba, 0x43, + 0x62, 0x65, 0x40, 0x04, 0x77, 0x9e, 0xd6, 0xab, + 0x8b, 0x0d, 0x93, 0x80, 0x50, 0x5f, 0xa2, 0x76, + 0x20, 0xa7, 0xd6, 0x9c, 0x27, 0x15, 0x27, 0xbc, + 0xa5, 0x5a, 0xbf, 0xe9, 0x92, 0x82, 0x05, 0xa8, + 0x41, 0xe9, 0xb5, 0x60, 0xd5, 0xc0, 0xd7, 0x4b, + 0xad, 0x38, 0xb2, 0xe9, 0xd1, 0xe5, 0x51, 0x5f, + 0x24, 0x78, 0x24, 0x9a, 0x23, 0xd2, 0xc2, 0x48, + 0xbd, 0x0e, 0xf1, 0x37, 0x72, 0x91, 0x87, 0xb0, + 0x4e, 0xbd, 0x99, 0x6b, 0x2c, 0x01, 0xb6, 0x79, + 0x69, 0xec, 0x0c, 0xed, 0xe5, 0x3f, 0x50, 0x64, + 0x7c, 0xb9, 0xdd, 0xe1, 0x92, 0x81, 0xb5, 0xd0, + 0xcb, 0x17, 0x83, 0x86, 0x8b, 0xea, 0x4f, 0x93, + 0x08, 0xbc, 0x22, 0x0c, 0xef, 0xe8, 0x0d, 0xf5, + 0x9e, 0x23, 0xe1, 0xf9, 0xb7, 0x6b, 0x45, 0x0b, + 0xcb, 0xa9, 0xb6, 0x4d, 0x28, 0x25, 0xba, 0x3e, + 0x86, 0xf2, 0x75, 0x47, 0x5d, 0x9d, 0x6b, 0xf6, + 0x8a, 0x05, 0x58, 0x73, 0x3d, 0x00, 0xde, 0xfd, + 0x69, 0xb1, 0x61, 0x16, 0xf5, 0x2e, 0xb0, 0x9f, + 0x31, 0x6a, 0x00, 0xb9, 0xef, 0x71, 0x63, 0x47, + 0xa3, 0xca, 0xe0, 0x40, 0xa8, 0x7e, 0x02, 0x04, + 0xfe, 0xe5, 0xce, 0x48, 0x73, 0xe3, 0x94, 0xcf, + 0xe2, 0xff, 0x29, 0x7e, 0xf6, 0x32, 0xbb, 0xb7, + 0x55, 0x12, 0x21, 0x7a, 0x9c, 0x75, 0x04, 0x0c, + 0xb4, 0x7c, 0xb0, 0x3d, 0x40, 0xb3, 0x11, 0x9a, + 0x7a, 0x9a, 0x13, 0xfb, 0x77, 0xa7, 0x51, 0x68, + 0xf7, 0x05, 0x47, 0x3b, 0x0f, 0x52, 0x5c, 0xe6, + 0xc2, 0x99, 0x3a, 0x37, 0x54, 0x5c, 0x4f, 0x2b, + 0xa7, 0x01, 0x08, 0x74, 0xbc, 0x91, 0xe3, 0xe2, + 0xfe, 0x65, 0x94, 0xfd, 0x3d, 0x18, 0xe0, 0xf0, + 0x62, 0xed, 0xc2, 0x10, 0x82, 0x9c, 0x58, 0x7f, + 0xb2, 0xa3, 0x87, 0x8a, 0x74, 0xd9, 0xc1, 0xfb, + 0x84, 0x28, 0x17, 0xc7, 0x2b, 0xcb, 0x53, 0x1f, + 0x4e, 0x8a, 0x82, 0xfc, 0xb4, 0x3f, 0xc1, 0x47, + 0x25, 0xf3, 0x21, 0xdc, 0x4c, 0x2d, 0x08, 0xfa, + 0xe7, 0x0f, 0x03, 0xa9, 0x68, 0xde, 0x6b, 0x41, + 0xa0, 0xf9, 0x41, 0x6c, 0x57, 0x4d, 0x3a, 0x0e, + 0xea, 0x51, 0xca, 0x9f, 0x97, 0x11, 0x7d, 0xf6, + 0x8e, 0x88, 0x63, 0x67, 0xc9, 0x65, 0x13, 0xca, + 0x38, 0xed, 0x35, 0xbe, 0xf4, 0x27, 0xa9, 0x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 0x2f, 0x04, 0x53, 0x06, 0x64, + 0x7f, 0x31, 0x29, 0xae, 0xb7, 0x9f, 0xba, 0xc4, + 0x6d, 0x68, 0xd1, 0x24, 0x32, 0xf4, 0x11 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 4, - { - 0x07, 0x9c, 0x91, 0xbe - }, - "id-Gost28147-89-CryptoPro-C-ParamSet", - "testcfb3", - { - 0x77, 0xc3, 0x45, 0x8e, 0xf6, 0x42, 0xe7, 0x04, - 0x8e, 0xfc, 0x08, 0xe4, 0x70, 0x96, 0xd6, 0x05, - 0x93, 0x59, 0x02, 0x6d, 0x6f, 0x97, 0xca, 0xe9, - 0xcf, 0x89, 0x44, 0x4b, 0xde, 0x6c, 0x22, 0x1d - }, - G89_CFB, - { - 0x43, 0x7c, 0x3e, 0x8e, 0x2f, 0x2a, 0x00, 0x98 - }, - { - 0x19, 0x35, 0x81, 0x34 - } + 4, + { + 0x07, 0x9c, 0x91, 0xbe + }, + "id-Gost28147-89-CryptoPro-C-ParamSet", + "testcfb3", + { + 0x77, 0xc3, 0x45, 0x8e, 0xf6, 0x42, 0xe7, 0x04, + 0x8e, 0xfc, 0x08, 0xe4, 0x70, 0x96, 0xd6, 0x05, + 0x93, 0x59, 0x02, 0x6d, 0x6f, 0x97, 0xca, 0xe9, + 0xcf, 0x89, 0x44, 0x4b, 0xde, 0x6c, 0x22, 0x1d + }, + G89_CFB, + { + 0x43, 0x7c, 0x3e, 0x8e, 0x2f, 0x2a, 0x00, 0x98 + }, + { + 0x19, 0x35, 0x81, 0x34 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 9, - { - 0x2f, 0x31, 0xd8, 0x83, 0xb4, 0x20, 0xe8, 0x6e, - 0xda - }, - "id-Gost28147-89-CryptoPro-D-ParamSet", - "testcfb4", - { - 0x38, 0x9f, 0xe8, 0x37, 0xff, 0x9c, 0x5d, 0x29, - 0xfc, 0x48, 0x55, 0xa0, 0x87, 0xea, 0xe8, 0x40, - 0x20, 0x87, 0x5b, 0xb2, 0x01, 0x15, 0x55, 0xa7, - 0xe3, 0x2d, 0xcb, 0x3d, 0xd6, 0x59, 0x04, 0x73 - }, - G89_CFB, - { - 0xc5, 0xa2, 0xd2, 0x1f, 0x2f, 0xdf, 0xb8, 0xeb - }, - { - 0x6d, 0xa4, 0xed, 0x40, 0x08, 0x88, 0x71, 0xad, - 0x16 - } + 9, + { + 0x2f, 0x31, 0xd8, 0x83, 0xb4, 0x20, 0xe8, 0x6e, + 0xda + }, + "id-Gost28147-89-CryptoPro-D-ParamSet", + "testcfb4", + { + 0x38, 0x9f, 0xe8, 0x37, 0xff, 0x9c, 0x5d, 0x29, + 0xfc, 0x48, 0x55, 0xa0, 0x87, 0xea, 0xe8, 0x40, + 0x20, 0x87, 0x5b, 0xb2, 0x01, 0x15, 0x55, 0xa7, + 0xe3, 0x2d, 0xcb, 0x3d, 0xd6, 0x59, 0x04, 0x73 + }, + G89_CFB, + { + 0xc5, 0xa2, 0xd2, 0x1f, 0x2f, 0xdf, 0xb8, 0xeb + }, + { + 0x6d, 0xa4, 0xed, 0x40, 0x08, 0x88, 0x71, 0xad, + 0x16 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 5242880+8, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test5Mcfb", - { - 0x61, 0x58, 0x44, 0x5a, 0x41, 0xf6, 0xc7, 0x0f, - 0x6b, 0xdb, 0x51, 0x91, 0x6a, 0xf6, 0x81, 0x30, - 0x8c, 0xa7, 0x98, 0xdd, 0x38, 0x35, 0x8a, 0x60, - 0x85, 0xb4, 0xf0, 0xf9, 0x43, 0xa2, 0x7d, 0x9a - }, - G89_CFB, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - { - 0x1c, 0x16, 0xa0, 0xe9, 0x63, 0x94, 0xfe, 0x38, - 0x37, 0xa7, 0x9b, 0x70, 0x25, 0x2e, 0xd6, 0x00 - } + 5242880+8, + { 0 }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "test5Mcfb", + { + 0x61, 0x58, 0x44, 0x5a, 0x41, 0xf6, 0xc7, 0x0f, + 0x6b, 0xdb, 0x51, 0x91, 0x6a, 0xf6, 0x81, 0x30, + 0x8c, 0xa7, 0x98, 0xdd, 0x38, 0x35, 0x8a, 0x60, + 0x85, 0xb4, 0xf0, 0xf9, 0x43, 0xa2, 0x7d, 0x9a + }, + G89_CFB, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { + 0x1c, 0x16, 0xa0, 0xe9, 0x63, 0x94, 0xfe, 0x38, + 0x37, 0xa7, 0x9b, 0x70, 0x25, 0x2e, 0xd6, 0x00 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 4294967296ULL+16, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test4Gcfb", - { - 0xae, 0x57, 0xa2, 0xdd, 0xa4, 0xef, 0x4f, 0x96, - 0xb8, 0x94, 0xa5, 0xd1, 0x1b, 0xc8, 0x9b, 0x42, - 0xa5, 0x24, 0xcc, 0x89, 0x5c, 0xb8, 0x92, 0x52, - 0xc1, 0x12, 0x6a, 0xb0, 0x9a, 0x26, 0xe8, 0x06 - }, - G89_CFB, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - { - 0x2e, 0x62, 0xb0, 0x2e, 0xc7, 0x87, 0x4b, 0x29, - 0x33, 0x16, 0x6b, 0xb4, 0xd6, 0x61, 0x66, 0xd9 - } + 4294967296ULL+16, + { 0 }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "test4Gcfb", + { + 0xae, 0x57, 0xa2, 0xdd, 0xa4, 0xef, 0x4f, 0x96, + 0xb8, 0x94, 0xa5, 0xd1, 0x1b, 0xc8, 0x9b, 0x42, + 0xa5, 0x24, 0xcc, 0x89, 0x5c, 0xb8, 0x92, 0x52, + 0xc1, 0x12, 0x6a, 0xb0, 0x9a, 0x26, 0xe8, 0x06 + }, + G89_CFB, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { + 0x2e, 0x62, 0xb0, 0x2e, 0xc7, 0x87, 0x4b, 0x29, + 0x33, 0x16, 0x6b, 0xb4, 0xd6, 0x61, 0x66, 0xd9 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 1037, - { - 0x3d, 0x0b, 0x69, 0xf7, 0xa8, 0xe4, 0xfc, 0x99, - 0x22, 0x2e, 0xee, 0xd1, 0x63, 0x12, 0xfe, 0xa8, - 0x9d, 0xcb, 0x6c, 0x4d, 0x48, 0x8c, 0xe8, 0xbd, - 0x8b, 0x60, 0xf1, 0xbf, 0x7b, 0xe3, 0x79, 0xd5, - 0x2b, 0x25, 0x97, 0x13, 0xef, 0x35, 0xda, 0xf4, - 0xbc, 0x77, 0xce, 0xea, 0xe9, 0x3f, 0xa4, 0xb6, - 0x01, 0xd5, 0x73, 0x29, 0x58, 0xda, 0xd7, 0x67, - 0x17, 0xac, 0xe4, 0x75, 0x2f, 0x57, 0x23, 0xac, - 0x96, 0x21, 0xc7, 0x62, 0x2d, 0xf7, 0x32, 0xb5, - 0x44, 0x5f, 0x72, 0xb1, 0x5f, 0xba, 0x1b, 0x1e, - 0xdb, 0x4a, 0x09, 0x8c, 0x92, 0x61, 0xa2, 0xb0, - 0x49, 0x68, 0xe5, 0xb3, 0xa2, 0x8f, 0x13, 0x4b, - 0xf5, 0x4d, 0x84, 0xda, 0xab, 0xa0, 0xb6, 0xd1, - 0x5a, 0x63, 0x19, 0xe8, 0xa2, 0x09, 0xf6, 0x76, - 0x6f, 0x9b, 0x48, 0x0a, 0x15, 0x5d, 0xb7, 0x20, - 0x21, 0x9a, 0x2e, 0xb9, 0x6d, 0xfa, 0x1e, 0xc2, - 0x0e, 0xef, 0x15, 0xab, 0x59, 0x01, 0xfe, 0x43, - 0x90, 0xf2, 0x62, 0xca, 0x4a, 0x9a, 0x48, 0x38, - 0xab, 0x6f, 0x9d, 0x21, 0xb3, 0xad, 0xa7, 0x60, - 0x46, 0xe3, 0xef, 0xd0, 0xe3, 0x1d, 0xc5, 0xe1, - 0xb8, 0xa1, 0xe2, 0x99, 0x20, 0xc5, 0x76, 0xcc, - 0xaa, 0x8a, 0xa9, 0x45, 0x55, 0xa0, 0x78, 0x00, - 0x64, 0xde, 0xcf, 0x5b, 0xdf, 0x26, 0x48, 0xcd, - 0xba, 0x8a, 0xb5, 0xfb, 0xfd, 0x4a, 0xd5, 0xc4, - 0xe0, 0x43, 0xa6, 0x71, 0x90, 0xa4, 0x8b, 0xca, - 0x2e, 0x88, 0x7b, 0xac, 0xb2, 0xdc, 0xf2, 0x01, - 0xcb, 0xda, 0x6e, 0x91, 0x27, 0x28, 0x44, 0x88, - 0x9a, 0xd2, 0x12, 0xf1, 0xa6, 0xf5, 0xb7, 0x61, - 0xce, 0x79, 0x62, 0x52, 0x3c, 0xe6, 0x14, 0x73, - 0xd1, 0x41, 0x92, 0x50, 0xbd, 0xdc, 0x3b, 0xd0, - 0xa7, 0x11, 0x8c, 0x3a, 0xe4, 0x2d, 0xf2, 0x52, - 0xd3, 0x2f, 0x7c, 0x8e, 0x54, 0x90, 0x4e, 0x23, - 0xae, 0xb3, 0xa0, 0xf3, 0x25, 0x7e, 0x66, 0xaa, - 0x0f, 0x6f, 0x81, 0x72, 0x77, 0xbb, 0xd3, 0x47, - 0xe8, 0x05, 0xff, 0xe1, 0x5b, 0xc9, 0x37, 0x50, - 0x33, 0x49, 0x17, 0xaf, 0xab, 0x1d, 0xe1, 0x15, - 0xf2, 0xe5, 0x98, 0x5e, 0x2d, 0x05, 0x1f, 0x0d, - 0x55, 0x97, 0xed, 0xff, 0x5e, 0xe0, 0x0f, 0xc3, - 0x9c, 0xbd, 0x82, 0xc2, 0x06, 0xbe, 0x45, 0x66, - 0xae, 0x33, 0xbe, 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, 0x0a, 0x97, 0x27, - 0x03, 0x14, 0x96, 0xa6, 0x3d, 0x04, 0xea, 0x9f, - 0x14, 0x14, 0x27, 0x4c, 0xd9, 0xa2, 0x89, 0x5f, - 0x65, 0x4a, 0xe1, 0x9d, 0x2c, 0xb8, 0xf8, 0xd4, - 0x8f, 0x2a, 0x57, 0x36, 0xcc, 0x06, 0x9c, 0x2c, - 0xc5, 0x13, 0x16, 0xdf, 0xfc, 0xae, 0x22, 0x16, - 0xa8, 0x2b, 0x71, 0x6f, 0x1d, 0xb3, 0x47, 0x54, - 0x3f, 0x2d, 0x0a, 0x68, 0x9f, 0x2e, 0xf6, 0x90, - 0xd8, 0xa1, 0x21, 0x09, 0xd4, 0x97, 0xb9, 0x7b, - 0x7f, 0x9b, 0x6a, 0xed, 0xd1, 0xf0, 0xe3, 0xb6, - 0x28, 0xc7, 0x62, 0x82, 0x00, 0xc9, 0x38, 0xa1, - 0x82, 0x78, 0xce, 0x87, 0xc8, 0x53, 0xac, 0x4f, - 0x2e, 0x31, 0xb9, 0x50, 0x7f, 0x36, 0x00, 0x4a, - 0x32, 0xe6, 0xd8, 0xbb, 0x59, 0x45, 0x0e, 0x91, - 0x1b, 0x38, 0xa9, 0xbc, 0xb9, 0x5e, 0x6c, 0x6a, - 0x9c, 0x03, 0x01, 0x1c, 0xde, 0xe8, 0x1f, 0x1e, - 0xe3, 0xde, 0x25, 0xa2, 0x56, 0x79, 0xe1, 0xbd, - 0x58, 0xc4, 0x93, 0xe6, 0xd0, 0x8a, 0x4d, 0x08, - 0xab, 0xf7, 0xaa, 0xc3, 0x7d, 0xc1, 0xee, 0x68, - 0x37, 0xbc, 0x78, 0x0b, 0x19, 0x68, 0x2b, 0x2b, - 0x2e, 0x6d, 0xc4, 0x6f, 0xaa, 0x3b, 0xc6, 0x19, - 0xcb, 0xf1, 0x58, 0xb9, 0x60, 0x85, 0x45, 0xae, - 0x52, 0x97, 0xba, 0x24, 0x32, 0x13, 0x72, 0x16, - 0x6e,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 0xe1, 0xb0, 0x22, - 0xe5, 0x94, 0xbd, 0xdd, 0x8e, 0xbb, 0xf6, 0x75, - 0xbf, 0xbf, 0xee, 0x7a, 0xb1, 0x58, 0xb4, 0x81, - 0xb8, 0x39, 0x3e, 0xb6, 0x1e, 0xde, 0xda, 0x1b, - 0xd5, 0xf7, 0xdd, 0x7d, 0x65, 0x9c, 0xaa, 0x56, - 0x93, 0xb8, 0xaf, 0x48, 0x53, 0xc7, 0x22, 0xe4, - 0x1c, 0xdf, 0xe9, 0x79, 0xb4, 0x20, 0x89, 0xcc, - 0x2a, 0x79, 0x2c, 0x09, 0xbe, 0x78, 0xcf, 0xcc, - 0xf2, 0x90, 0xd6, 0x65, 0xc5, 0x29, 0xfc, 0xda, - 0x69, 0xfc, 0xc0, 0xd6, 0x70, 0x99, 0x61, 0x3f, - 0x60, 0x02, 0xd8, 0x12, 0x22, 0xc8, 0x34, 0xc6, - 0x3b, 0xb3, 0xc2, 0x33, 0xa1, 0x5c, 0x8f, 0x4c, - 0xd1, 0x52, 0x72, 0xf2, 0x42, 0x05, 0x8e, 0x18, - 0x1f, 0x16, 0xda, 0xb8, 0x53, 0xa1, 0x5f, 0x01, - 0x32, 0x1b, 0x90, 0xb3, 0x53, 0x9b, 0xd0, 0x85, - 0x61, 0x2d, 0x17, 0xed, 0x0a, 0xa4, 0xa5, 0x27, - 0x09, 0x75, 0x7c, 0xbc, 0x30, 0xf7, 0x5e, 0x59, - 0x9a, 0x07, 0x96, 0x84, 0x28, 0x86, 0x4b, 0xa7, - 0x22, 0x35, 0x28, 0xc7, 0xed, 0x0d, 0xc3, 0xce, - 0x98, 0xcc, 0x2d, 0xec, 0xd4, 0x98, 0x09, 0x8e, - 0x52, 0x5f, 0x2b, 0x9a, 0x13, 0xbe, 0x99, 0x16, - 0x73, 0xd1, 0x1f, 0x81, 0xe5, 0xa2, 0x08, 0x78, - 0xcb, 0x0c, 0x20, 0xd4, 0xa5, 0xea, 0x4b, 0x5b, - 0x95, 0x5a, 0x92, 0x9a, 0x52 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testcnt2", - { - 0x1b, 0x5d, 0xdb, 0x77, 0xcf, 0xf9, 0xec, 0x95, - 0x5e, 0xcc, 0x67, 0x9f, 0x5d, 0x28, 0xad, 0x4a, - 0x27, 0xf4, 0x32, 0xc6, 0xb2, 0xcb, 0xb1, 0x45, - 0x6a, 0x88, 0x14, 0x0c, 0x9b, 0x9b, 0x5f, 0x48 - }, - G89_CNT, - { - 0x71, 0x58, 0x8c, 0xe1, 0x55, 0xf4, 0xf6, 0xb3 - }, - { - 0x8e, 0xcd, 0x8f, 0xc8, 0xac, 0xe1, 0x15, 0x48, - 0x2d, 0xae, 0x24, 0x8a, 0xc7, 0xfb, 0xba, 0x0f, - 0x1d, 0x8a, 0x95, 0xa2, 0x43, 0xef, 0xcb, 0xdc, - 0x59, 0x57, 0xa7, 0xc7, 0x0e, 0xe3, 0xe2, 0xb9, - 0x0d, 0x86, 0x29, 0x62, 0xcb, 0x83, 0x4d, 0x07, - 0x0c, 0x40, 0xd4, 0x7b, 0x2e, 0xca, 0xba, 0xbf, - 0x4a, 0x60, 0x3b, 0x31, 0x98, 0xc8, 0x88, 0x47, - 0xd9, 0x82, 0xab, 0xfc, 0x8f, 0x48, 0xe2, 0x46, - 0xab, 0xd3, 0xa1, 0xab, 0x8a, 0x05, 0x22, 0x8c, - 0xf4, 0xec, 0x9a, 0x1e, 0x76, 0xab, 0x1a, 0x60, - 0xd9, 0x25, 0x6b, 0xb8, 0x56, 0xe5, 0xb2, 0xea, - 0x10, 0xf3, 0x62, 0x04, 0x32, 0x5e, 0xaa, 0x3b, - 0x7b, 0x57, 0xbc, 0x3b, 0x8b, 0x43, 0x47, 0xf2, - 0xd5, 0x03, 0x7e, 0x51, 0x01, 0xff, 0x77, 0x28, - 0xca, 0x90, 0xa3, 0xfe, 0x7e, 0x2e, 0x70, 0x16, - 0x75, 0x18, 0x44, 0xf0, 0x1b, 0x85, 0x05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, 0x94, 0x6c, 0x9c, 0x3d, 0x0c, 0x81, - 0xce, 0x82, 0x72, 0x42, 0x28, 0xf9, 0x37, 0x6a, - 0x6d, 0xe4, 0x12, 0xf4, 0x21, 0xaa, 0xf7, 0xfe, - 0x27, 0x55, 0x40, 0x1a, 0x14, 0xc3, 0x39, 0x5b, - 0xbf, 0x63, 0xc2, 0x5f, 0x10, 0x1f, 0x14, 0x25, - 0xd0, 0xce, 0xf3, 0x14, 0x48, 0x13, 0xa5, 0x0b, - 0x4d, 0x38, 0xcf, 0x0d, 0x34, 0xc0, 0x0a, 0x11, - 0xb4, 0xb5, 0x72, 0xc8, 0x4b, 0xc2, 0x6f, 0xe7, - 0x9d, 0x93, 0xf7, 0xdf, 0xb8, 0x43, 0x72, 0x7e, - 0xda, 0x3e, 0x20, 0x1f, 0xbc, 0x21, 0x2a, 0xce, - 0x00, 0xfa, 0x96, 0x9f, 0x3d, 0xe5, 0x88, 0x96, - 0xef, 0x29, 0x84, 0xdf, 0x6c, 0x1c, 0x96, 0xd8, - 0x58, 0x47, 0xaa, 0x92, 0xf3, 0x07, 0xe5, 0xfb, - 0xaf, 0xea, 0x95, 0x7e, 0x0b, 0x71, 0xcd, 0x81, - 0x0f, 0xb7, 0x0a, 0x59, 0x8f, 0x31, 0x4d, 0xd1, - 0xc3, 0xf3, 0x2f, 0x70, 0x5c, 0x59, 0x18, 0x97, - 0xaf, 0x77, 0x95, 0x5e, 0xaf, 0x40, 0x06, 0x12, - 0x81, 0x61, 0x86, 0x08, 0x4e, 0xbc, 0x89, 0x46, - 0x07, 0x2e, 0x5b, 0x10, 0xaa, 0x12, 0xf0, 0xa7, - 0x84, 0xe2, 0x9a, 0x08, 0xf1, 0xde, 0x59, 0xe3, - 0x0e, 0x47, 0x4b, 0xff, 0xc3, 0xc9, 0x18, 0xaf, - 0x95, 0x9c, 0x67, 0x2a, 0xde, 0x8a, 0x7a, 0x99, - 0x04, 0xc4, 0xb8, 0x97, 0x4c, 0x04, 0x29,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 0x05, 0x9b, 0x29, 0x6d, 0xba, - 0xf1, 0xf4, 0x1e, 0x23, 0x2e - } + 1037, + { + 0x3d, 0x0b, 0x69, 0xf7, 0xa8, 0xe4, 0xfc, 0x99, + 0x22, 0x2e, 0xee, 0xd1, 0x63, 0x12, 0xfe, 0xa8, + 0x9d, 0xcb, 0x6c, 0x4d, 0x48, 0x8c, 0xe8, 0xbd, + 0x8b, 0x60, 0xf1, 0xbf, 0x7b, 0xe3, 0x79, 0xd5, + 0x2b, 0x25, 0x97, 0x13, 0xef, 0x35, 0xda, 0xf4, + 0xbc, 0x77, 0xce, 0xea, 0xe9, 0x3f, 0xa4, 0xb6, + 0x01, 0xd5, 0x73, 0x29, 0x58, 0xda, 0xd7, 0x67, + 0x17, 0xac, 0xe4, 0x75, 0x2f, 0x57, 0x23, 0xac, + 0x96, 0x21, 0xc7, 0x62, 0x2d, 0xf7, 0x32, 0xb5, + 0x44, 0x5f, 0x72, 0xb1, 0x5f, 0xba, 0x1b, 0x1e, + 0xdb, 0x4a, 0x09, 0x8c, 0x92, 0x61, 0xa2, 0xb0, + 0x49, 0x68, 0xe5, 0xb3, 0xa2, 0x8f, 0x13, 0x4b, + 0xf5, 0x4d, 0x84, 0xda, 0xab, 0xa0, 0xb6, 0xd1, + 0x5a, 0x63, 0x19, 0xe8, 0xa2, 0x09, 0xf6, 0x76, + 0x6f, 0x9b, 0x48, 0x0a, 0x15, 0x5d, 0xb7, 0x20, + 0x21, 0x9a, 0x2e, 0xb9, 0x6d, 0xfa, 0x1e, 0xc2, + 0x0e, 0xef, 0x15, 0xab, 0x59, 0x01, 0xfe, 0x43, + 0x90, 0xf2, 0x62, 0xca, 0x4a, 0x9a, 0x48, 0x38, + 0xab, 0x6f, 0x9d, 0x21, 0xb3, 0xad, 0xa7, 0x60, + 0x46, 0xe3, 0xef, 0xd0, 0xe3, 0x1d, 0xc5, 0xe1, + 0xb8, 0xa1, 0xe2, 0x99, 0x20, 0xc5, 0x76, 0xcc, + 0xaa, 0x8a, 0xa9, 0x45, 0x55, 0xa0, 0x78, 0x00, + 0x64, 0xde, 0xcf, 0x5b, 0xdf, 0x26, 0x48, 0xcd, + 0xba, 0x8a, 0xb5, 0xfb, 0xfd, 0x4a, 0xd5, 0xc4, + 0xe0, 0x43, 0xa6, 0x71, 0x90, 0xa4, 0x8b, 0xca, + 0x2e, 0x88, 0x7b, 0xac, 0xb2, 0xdc, 0xf2, 0x01, + 0xcb, 0xda, 0x6e, 0x91, 0x27, 0x28, 0x44, 0x88, + 0x9a, 0xd2, 0x12, 0xf1, 0xa6, 0xf5, 0xb7, 0x61, + 0xce, 0x79, 0x62, 0x52, 0x3c, 0xe6, 0x14, 0x73, + 0xd1, 0x41, 0x92, 0x50, 0xbd, 0xdc, 0x3b, 0xd0, + 0xa7, 0x11, 0x8c, 0x3a, 0xe4, 0x2d, 0xf2, 0x52, + 0xd3, 0x2f, 0x7c, 0x8e, 0x54, 0x90, 0x4e, 0x23, + 0xae, 0xb3, 0xa0, 0xf3, 0x25, 0x7e, 0x66, 0xaa, + 0x0f, 0x6f, 0x81, 0x72, 0x77, 0xbb, 0xd3, 0x47, + 0xe8, 0x05, 0xff, 0xe1, 0x5b, 0xc9, 0x37, 0x50, + 0x33, 0x49, 0x17, 0xaf, 0xab, 0x1d, 0xe1, 0x15, + 0xf2, 0xe5, 0x98, 0x5e, 0x2d, 0x05, 0x1f, 0x0d, + 0x55, 0x97, 0xed, 0xff, 0x5e, 0xe0, 0x0f, 0xc3, + 0x9c, 0xbd, 0x82, 0xc2, 0x06, 0xbe, 0x45, 0x66, + 0xae, 0x33, 0xbe, 0x28, 0x48, 0xe9, 0x2d, 0x1a, + 0xe6, 0x65, 0x8e, 0xdf, 0x76, 0x03, 0x73, 0x4b, + 0xc0, 0x80, 0x71, 0xf9, 0xac, 0xba, 0xa0, 0xb0, + 0x19, 0x1a, 0x0a, 0xd4, 0x35, 0x12, 0x88, 0x76, + 0x05, 0x75, 0x8f, 0x7c, 0xb5, 0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 0xaa, 0x56, + 0x93, 0xb8, 0xaf, 0x48, 0x53, 0xc7, 0x22, 0xe4, + 0x1c, 0xdf, 0xe9, 0x79, 0xb4, 0x20, 0x89, 0xcc, + 0x2a, 0x79, 0x2c, 0x09, 0xbe, 0x78, 0xcf, 0xcc, + 0xf2, 0x90, 0xd6, 0x65, 0xc5, 0x29, 0xfc, 0xda, + 0x69, 0xfc, 0xc0, 0xd6, 0x70, 0x99, 0x61, 0x3f, + 0x60, 0x02, 0xd8, 0x12, 0x22, 0xc8, 0x34, 0xc6, + 0x3b, 0xb3, 0xc2, 0x33, 0xa1, 0x5c, 0x8f, 0x4c, + 0xd1, 0x52, 0x72, 0xf2, 0x42, 0x05, 0x8e, 0x18, + 0x1f, 0x16, 0xda, 0xb8, 0x53, 0xa1, 0x5f, 0x01, + 0x32, 0x1b, 0x90, 0xb3, 0x53, 0x9b, 0xd0, 0x85, + 0x61, 0x2d, 0x17, 0xed, 0x0a, 0xa4, 0xa5, 0x27, + 0x09, 0x75, 0x7c, 0xbc, 0x30, 0xf7, 0x5e, 0x59, + 0x9a, 0x07, 0x96, 0x84, 0x28, 0x86, 0x4b, 0xa7, + 0x22, 0x35, 0x28, 0xc7, 0xed, 0x0d, 0xc3, 0xce, + 0x98, 0xcc, 0x2d, 0xec, 0xd4, 0x98, 0x09, 0x8e, + 0x52, 0x5f, 0x2b, 0x9a, 0x13, 0xbe, 0x99, 0x16, + 0x73, 0xd1, 0x1f, 0x81, 0xe5, 0xa2, 0x08, 0x78, + 0xcb, 0x0c, 0x20, 0xd4, 0xa5, 0xea, 0x4b, 0x5b, + 0x95, 0x5a, 0x92, 0x9a, 0x52 + }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "testcnt2", + { + 0x1b, 0x5d, 0xdb, 0x77, 0xcf, 0xf9, 0xec, 0x95, + 0x5e, 0xcc, 0x67, 0x9f, 0x5d, 0x28, 0xad, 0x4a, + 0x27, 0xf4, 0x32, 0xc6, 0xb2, 0xcb, 0xb1, 0x45, + 0x6a, 0x88, 0x14, 0x0c, 0x9b, 0x9b, 0x5f, 0x48 + }, + G89_CNT, + { + 0x71, 0x58, 0x8c, 0xe1, 0x55, 0xf4, 0xf6, 0xb3 + }, + { + 0x8e, 0xcd, 0x8f, 0xc8, 0xac, 0xe1, 0x15, 0x48, + 0x2d, 0xae, 0x24, 0x8a, 0xc7, 0xfb, 0xba, 0x0f, + 0x1d, 0x8a, 0x95, 0xa2, 0x43, 0xef, 0xcb, 0xdc, + 0x59, 0x57, 0xa7, 0xc7, 0x0e, 0xe3, 0xe2, 0xb9, + 0x0d, 0x86, 0x29, 0x62, 0xcb, 0x83, 0x4d, 0x07, + 0x0c, 0x40, 0xd4, 0x7b, 0x2e, 0xca, 0xba, 0xbf, + 0x4a, 0x60, 0x3b, 0x31, 0x98, 0xc8, 0x88, 0x47, + 0xd9, 0x82, 0xab, 0xfc, 0x8f, 0x48, 0xe2, 0x46, + 0xab, 0xd3, 0xa1, 0xab, 0x8a, 0x05, 0x22, 0x8c, + 0xf4, 0xec, 0x9a, 0x1e, 0x76, 0xab, 0x1a, 0x60, + 0xd9, 0x25, 0x6b, 0xb8, 0x56, 0xe5, 0xb2, 0xea, + 0x10, 0xf3, 0x62, 0x04, 0x32, 0x5e, 0xaa, 0x3b, + 0x7b, 0x57, 0xbc, 0x3b, 0x8b, 0x43, 0x47, 0xf2, + 0xd5, 0x03, 0x7e, 0x51, 0x01, 0xff, 0x77, 0x28, + 0xca, 0x90, 0xa3, 0xfe, 0x7e, 0x2e, 0x70, 0x16, + 0x75, 0x18, 0x44, 0xf0, 0x1b, 0x85, 0x05, 0xea, + 0xe3, 0x21, 0xf7, 0x26, 0x86, 0x76, 0x3c, 0x67, + 0x9d, 0xfc, 0xbc, 0x10, 0x7f, 0x77, 0xe4, 0xed, + 0xd3, 0x12, 0xf8, 0x83, 0x00, 0x1f, 0x4b, 0x92, + 0x95, 0x92, 0x5c, 0xf3, 0x5a, 0xf3, 0xb7, 0xd0, + 0x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, 0x10, 0x1f, 0x14, 0x25, + 0xd0, 0xce, 0xf3, 0x14, 0x48, 0x13, 0xa5, 0x0b, + 0x4d, 0x38, 0xcf, 0x0d, 0x34, 0xc0, 0x0a, 0x11, + 0xb4, 0xb5, 0x72, 0xc8, 0x4b, 0xc2, 0x6f, 0xe7, + 0x9d, 0x93, 0xf7, 0xdf, 0xb8, 0x43, 0x72, 0x7e, + 0xda, 0x3e, 0x20, 0x1f, 0xbc, 0x21, 0x2a, 0xce, + 0x00, 0xfa, 0x96, 0x9f, 0x3d, 0xe5, 0x88, 0x96, + 0xef, 0x29, 0x84, 0xdf, 0x6c, 0x1c, 0x96, 0xd8, + 0x58, 0x47, 0xaa, 0x92, 0xf3, 0x07, 0xe5, 0xfb, + 0xaf, 0xea, 0x95, 0x7e, 0x0b, 0x71, 0xcd, 0x81, + 0x0f, 0xb7, 0x0a, 0x59, 0x8f, 0x31, 0x4d, 0xd1, + 0xc3, 0xf3, 0x2f, 0x70, 0x5c, 0x59, 0x18, 0x97, + 0xaf, 0x77, 0x95, 0x5e, 0xaf, 0x40, 0x06, 0x12, + 0x81, 0x61, 0x86, 0x08, 0x4e, 0xbc, 0x89, 0x46, + 0x07, 0x2e, 0x5b, 0x10, 0xaa, 0x12, 0xf0, 0xa7, + 0x84, 0xe2, 0x9a, 0x08, 0xf1, 0xde, 0x59, 0xe3, + 0x0e, 0x47, 0x4b, 0xff, 0xc3, 0xc9, 0x18, 0xaf, + 0x95, 0x9c, 0x67, 0x2a, 0xde, 0x8a, 0x7a, 0x99, + 0x04, 0xc4, 0xb8, 0x97, 0x4c, 0x04, 0x29, 0x71, + 0x05, 0xda, 0xb3, 0xd6, 0xdb, 0x6c, 0x71, 0xe6, + 0xe8, 0x03, 0xbf, 0x94, 0x7d, 0xde, 0x3d, 0xc8, + 0x44, 0xfa, 0x7d, 0x62, 0xb4, 0x36, 0x03, 0xee, + 0x36, 0x52, 0x64, 0xb4, 0x85, 0x6d, 0xd5, 0x78, + 0xf0, 0x6f, 0x67, 0x2d, 0x0e, 0xe0, 0x2c, 0x88, + 0x9b, 0x55, 0x19, 0x29, 0x40, 0xf6, 0x8c, 0x12, + 0xbb, 0x2c, 0x83, 0x96, 0x40, 0xc0, 0x36, 0xf5, + 0x77, 0xff, 0x70, 0x8c, 0x75, 0x92, 0x0b, 0xad, + 0x05, 0x9b, 0x7e, 0xa2, 0xfc, 0xa9, 0xd1, 0x64, + 0x76, 0x82, 0x13, 0xba, 0x22, 0x5e, 0x33, 0x0e, + 0x26, 0x70, 0xa9, 0xbe, 0x74, 0x28, 0xf5, 0xe2, + 0xc4, 0x96, 0xee, 0x3a, 0xbc, 0x97, 0xa6, 0x2c, + 0x2a, 0xe0, 0x64, 0x8d, 0x35, 0xc6, 0x1a, 0xca, + 0xf4, 0x92, 0xfa, 0xc3, 0xf1, 0x1f, 0x98, 0xe4, + 0x43, 0x88, 0x69, 0x3a, 0x09, 0xbf, 0x63, 0xe5, + 0x96, 0x29, 0x0b, 0x9b, 0x62, 0x23, 0x14, 0x8a, + 0x95, 0xe4, 0x1c, 0x5c, 0x0a, 0xa9, 0xc5, 0xb9, + 0x6f, 0x4f, 0x2b, 0x25, 0x6f, 0x74, 0x1e, 0x18, + 0xd5, 0xfe, 0x27, 0x7d, 0x3f, 0x6e, 0x55, 0x2c, + 0x67, 0xe6, 0xde, 0xb5, 0xcc, 0xc0, 0x2d, 0xff, + 0xc4, 0xe4, 0x06, 0x21, 0xa5, 0xc8, 0xd3, 0xd6, + 0x6c, 0xa1, 0xc3, 0xfb, 0x88, 0x92, 0xb1, 0x1d, + 0x90, 0xe1, 0x35, 0x05, 0x9b, 0x29, 0x6d, 0xba, + 0xf1, 0xf4, 0x1e, 0x23, 0x2e + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 5242880+8, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test5Mcnt", - { - 0x07, 0x52, 0x65, 0xe7, 0xca, 0xa3, 0xca, 0x45, - 0xcf, 0x3a, 0x05, 0x1d, 0x38, 0x03, 0x53, 0x0c, - 0x22, 0x31, 0xba, 0x99, 0x4f, 0x9b, 0x6a, 0x1b, - 0x7e, 0x09, 0x9d, 0x4e, 0xb5, 0xc9, 0x84, 0x2e - }, - G89_CNT, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - { - 0x3d, 0x05, 0x07, 0x57, 0xc0, 0x75, 0x89, 0x97, - 0xd6, 0x94, 0x49, 0x11, 0x1d, 0xd0, 0x91, 0xee - } + 5242880+8, + { 0 }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "test5Mcnt", + { + 0x07, 0x52, 0x65, 0xe7, 0xca, 0xa3, 0xca, 0x45, + 0xcf, 0x3a, 0x05, 0x1d, 0x38, 0x03, 0x53, 0x0c, + 0x22, 0x31, 0xba, 0x99, 0x4f, 0x9b, 0x6a, 0x1b, + 0x7e, 0x09, 0x9d, 0x4e, 0xb5, 0xc9, 0x84, 0x2e + }, + G89_CNT, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { + 0x3d, 0x05, 0x07, 0x57, 0xc0, 0x75, 0x89, 0x97, + 0xd6, 0x94, 0x49, 0x11, 0x1d, 0xd0, 0x91, 0xee + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 4294967296ULL+16, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test4Gcnt", - { - 0x75, 0xa3, 0x3c, 0xae, 0x03, 0x6b, 0x10, 0xdb, - 0xc1, 0x56, 0x50, 0x89, 0x03, 0xd2, 0x9f, 0x91, - 0xee, 0xe8, 0x64, 0x1d, 0x43, 0xf2, 0x4e, 0xf8, - 0xf2, 0x6c, 0xed, 0xda, 0x8f, 0xe4, 0x88, 0xe9 - }, - G89_CNT, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - { - 0xfa, 0x6c, 0x96, 0x78, 0xe2, 0xf8, 0xdd, 0xaa, - 0x67, 0x5a, 0xc9, 0x5d, 0x57, 0xf1, 0xbd, 0x99 - } + 4294967296ULL+16, + { 0 }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "test4Gcnt", + { + 0x75, 0xa3, 0x3c, 0xae, 0x03, 0x6b, 0x10, 0xdb, + 0xc1, 0x56, 0x50, 0x89, 0x03, 0xd2, 0x9f, 0x91, + 0xee, 0xe8, 0x64, 0x1d, 0x43, 0xf2, 0x4e, 0xf8, + 0xf2, 0x6c, 0xed, 0xda, 0x8f, 0xe4, 0x88, 0xe9 + }, + G89_CNT, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { + 0xfa, 0x6c, 0x96, 0x78, 0xe2, 0xf8, 0xdd, 0xaa, + 0x67, 0x5a, 0xc9, 0x5d, 0x57, 0xf1, 0xbd, 0x99 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 1035, - { - 0xd6, 0xcf, 0x31, 0x96, 0x9c, 0xa1, 0xfb, 0xd6, - 0x8d, 0xa3, 0xdd, 0x01, 0xd9, 0x88, 0xc0, 0x2f, - 0xbc, 0x46, 0xc7, 0x3a, 0xe4, 0x21, 0x86, 0x96, - 0x8d, 0xe2, 0xca, 0xb6, 0x37, 0xa2, 0xe1, 0xa8, - 0x7e, 0xa7, 0x79, 0x2e, 0xa4, 0x56, 0x75, 0x7f, - 0x3e, 0x55, 0x8b, 0x43, 0xae, 0x65, 0xdf, 0xaa, - 0x42, 0xb6, 0x00, 0xa6, 0x61, 0x03, 0x0d, 0xd3, - 0x41, 0x02, 0x27, 0x23, 0x95, 0x79, 0x9b, 0x34, - 0x81, 0xa9, 0x86, 0xb5, 0xa7, 0x90, 0xe2, 0xae, - 0xc4, 0x2f, 0xc3, 0x8e, 0x32, 0x56, 0x13, 0xfa, - 0x4d, 0x4e, 0x9f, 0x15, 0x75, 0x7e, 0x74, 0xdc, - 0x32, 0x2d, 0xee, 0x4d, 0x67, 0x70, 0x9f, 0x62, - 0xb9, 0xc4, 0xdb, 0x24, 0x84, 0xcc, 0x16, 0x7b, - 0xda, 0x22, 0xf7, 0xc5, 0xf3, 0x93, 0x35, 0x73, - 0xc6, 0x03, 0x1c, 0x77, 0xa5, 0xf2, 0x76, 0x56, - 0xb4, 0x95, 0xd4, 0x7e, 0x0d, 0x20, 0xc6, 0x6e, - 0xee, 0x8f, 0x25, 0x48, 0xff, 0x7e, 0x01, 0x3a, - 0xb4, 0x1f, 0xaa, 0x35, 0xc0, 0x33, 0x58, 0x9c, - 0xb5, 0xba, 0x65, 0x4b, 0xd3, 0x51, 0x14, 0xec, - 0x61, 0xce, 0xe4, 0xba, 0x49, 0xba, 0x39, 0x32, - 0xab, 0xce, 0x81, 0x72, 0xce, 0xab, 0xed, 0xd4, - 0xd2, 0x19, 0x87, 0x85, 0x92, 0xfa, 0x64, 0x34, - 0xd8, 0x86, 0xf4, 0x8a, 0x08, 0x3c, 0xde, 0xee, - 0x97, 0x92, 0x92, 0x69, 0xba, 0x9b, 0x5f, 0x7a, - 0x03, 0xc1, 0x5d, 0x43, 0x02, 0x8c, 0xbe, 0xd2, - 0x46, 0x72, 0x81, 0x40, 0x7d, 0x68, 0x98, 0x45, - 0x0b, 0x54, 0x27, 0x1c, 0xaf, 0x80, 0x42, 0xe4, - 0xd5, 0xd4, 0xe4, 0xa2, 0x98, 0x07, 0x8f, 0x03, - 0xf5, 0x2c, 0x8c, 0x88, 0xca, 0x5a, 0xde, 0xe4, - 0x9f, 0xb1, 0x5f, 0x82, 0xff, 0x20, 0x67, 0x52, - 0x85, 0x84, 0x4f, 0xc8, 0xfe, 0xa7, 0x9e, 0xae, - 0x1c, 0xfa, 0xb8, 0x75, 0xd3, 0xf7, 0x9f, 0x0d, - 0xda, 0x2d, 0xe6, 0xcc, 0x86, 0x6b, 0xa4, 0x14, - 0x65, 0xc3, 0xf9, 0x15, 0xbc, 0x87, 0xf5, 0xae, - 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x8d, 0xc8, 0x7d, 0x39, - 0xdc, 0xd5, 0x99, 0xc6, 0x01, 0x10, 0xce, 0x42, - 0x1b, 0xac, 0x48, 0xdc, 0x97, 0x78, 0x0a, 0xec, - 0xb3, 0x8f, 0x47, 0x35, 0xa3, 0x6a, 0x64, 0xb2, - 0x8e, 0x63, 0x69, 0x22, 0x66, 0xae, 0x2e, 0xe0, - 0x88, 0xf9, 0x40, 0x3c, 0xc9, 0xa2, 0x57, 0x61, - 0xf6, 0xad, 0xf0, 0xdc, 0x90, 0x56, 0x3f, 0x06, - 0x9b, 0x7d, 0xbd, 0xc2, 0x81, 0x02, 0xab, 0xb8, - 0x15, 0x09, 0x88, 0x4a, 0xff, 0x2f, 0x31, 0xbf, - 0x5e, 0xfa, 0x6a, 0x7e, 0xf6, 0xc5, 0xa7, 0xf7, - 0xd5, 0xab, 0x55, 0xac, 0xae, 0x0d, 0x8c, 0x8d, - 0x7f, 0x4b, 0x25, 0xbb, 0x32, 0xff, 0x11, 0x33, - 0x2e, 0x37, 0x37, 0x69, 0x96, 0x15, 0x17, 0xb1, - 0x17, 0x49, 0xe0, 0x9a, 0x9c, 0xd9, 0x5b, 0x8d, - 0x58, 0xa3, 0x1d, 0x92, 0x87, 0xf8, 0x80, 0xb9, - 0xbd, 0x5a, 0xec, 0x40, 0xe1, 0x00, 0x33, 0x60, - 0xe4, 0x86, 0x16, 0x6d, 0x61, 0x81, 0xf2, 0x28, - 0x6a, 0xa7, 0xce, 0x3f, 0x95, 0xae, 0x43, 0xca, - 0xe1, 0x3f, 0x81, 0x74, 0x7e, 0x1c, 0x47, 0x17, - 0x95, 0xc6, 0x60, 0xda, 0x74, 0x77, 0xd9, 0x9f, - 0xfa, 0x92, 0xb4, 0xbe, 0xe1, 0x23, 0x98, 0x18, - 0x95, 0x63, 0x03, 0x13, 0x4c, 0x1a, 0x2d, 0x41, - 0xcd, 0xe4, 0x84, 0xf7, 0xe6, 0x38, 0xef, 0xff, - 0x95, 0xb2, 0xe8, 0x7c, 0x8f, 0x58, 0xb5, 0xb5, - 0xed, 0x27, 0x7f, 0x3c, 0x18, 0xab, 0xbe, 0x7f, - 0x4f, 0xe2, 0x35, 0x15, 0x71, 0xb7, 0x6f, 0x85, - 0x38, 0x9b, 0x88, 0xf6, 0x9c, 0x8d, 0x43, 0xb5, - 0x58, 0x9e, 0xf2, 0xd1, 0x96, 0xbe, 0xb7, 0xad, - 0x1a, 0xa0, 0x98 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testimit2", - { - 0x80, 0xd9, 0xa0, 0xdc, 0x21, 0xf9, 0x30, 0x40, - 0x75, 0xfe, 0x49, 0x1b, 0x9e, 0x71, 0x90, 0x91, - 0x78, 0x88, 0x21, 0x60, 0x39, 0xe7, 0xc9, 0x2b, - 0xfb, 0x55, 0x1d, 0xf4, 0xdd, 0x2b, 0x0a, 0x01 - }, - G89_IMIT, - { 0 }, - { - 0x90, 0xf2, 0x11, 0x9a - } + 1035, + { + 0xd6, 0xcf, 0x31, 0x96, 0x9c, 0xa1, 0xfb, 0xd6, + 0x8d, 0xa3, 0xdd, 0x01, 0xd9, 0x88, 0xc0, 0x2f, + 0xbc, 0x46, 0xc7, 0x3a, 0xe4, 0x21, 0x86, 0x96, + 0x8d, 0xe2, 0xca, 0xb6, 0x37, 0xa2, 0xe1, 0xa8, + 0x7e, 0xa7, 0x79, 0x2e, 0xa4, 0x56, 0x75, 0x7f, + 0x3e, 0x55, 0x8b, 0x43, 0xae, 0x65, 0xdf, 0xaa, + 0x42, 0xb6, 0x00, 0xa6, 0x61, 0x03, 0x0d, 0xd3, + 0x41, 0x02, 0x27, 0x23, 0x95, 0x79, 0x9b, 0x34, + 0x81, 0xa9, 0x86, 0xb5, 0xa7, 0x90, 0xe2, 0xae, + 0xc4, 0x2f, 0xc3, 0x8e, 0x32, 0x56, 0x13, 0xfa, + 0x4d, 0x4e, 0x9f, 0x15, 0x75, 0x7e, 0x74, 0xdc, + 0x32, 0x2d, 0xee, 0x4d, 0x67, 0x70, 0x9f, 0x62, + 0xb9, 0xc4, 0xdb, 0x24, 0x84, 0xcc, 0x16, 0x7b, + 0xda, 0x22, 0xf7, 0xc5, 0xf3, 0x93, 0x35, 0x73, + 0xc6, 0x03, 0x1c, 0x77, 0xa5, 0xf2, 0x76, 0x56, + 0xb4, 0x95, 0xd4, 0x7e, 0x0d, 0x20, 0xc6, 0x6e, + 0xee, 0x8f, 0x25, 0x48, 0xff, 0x7e, 0x01, 0x3a, + 0xb4, 0x1f, 0xaa, 0x35, 0xc0, 0x33, 0x58, 0x9c, + 0xb5, 0xba, 0x65, 0x4b, 0xd3, 0x51, 0x14, 0xec, + 0x61, 0xce, 0xe4, 0xba, 0x49, 0xba, 0x39, 0x32, + 0xab, 0xce, 0x81, 0x72, 0xce, 0xab, 0xed, 0xd4, + 0xd2, 0x19, 0x87, 0x85, 0x92, 0xfa, 0x64, 0x34, + 0xd8, 0x86, 0xf4, 0x8a, 0x08, 0x3c, 0xde, 0xee, + 0x97, 0x92, 0x92, 0x69, 0xba, 0x9b, 0x5f, 0x7a, + 0x03, 0xc1, 0x5d, 0x43, 0x02, 0x8c, 0xbe, 0xd2, + 0x46, 0x72, 0x81, 0x40, 0x7d, 0x68, 0x98, 0x45, + 0x0b, 0x54, 0x27, 0x1c, 0xaf, 0x80, 0x42, 0xe4, + 0xd5, 0xd4, 0xe4, 0xa2, 0x98, 0x07, 0x8f, 0x03, + 0xf5, 0x2c, 0x8c, 0x88, 0xca, 0x5a, 0xde, 0xe4, + 0x9f, 0xb1, 0x5f, 0x82, 0xff, 0x20, 0x67, 0x52, + 0x85, 0x84, 0x4f, 0xc8, 0xfe, 0xa7, 0x9e, 0xae, + 0x1c, 0xfa, 0xb8, 0x75, 0xd3, 0xf7, 0x9f, 0x0d, + 0xda, 0x2d, 0xe6, 0xcc, 0x86, 0x6b, 0xa4, 0x14, + 0x65, 0xc3, 0xf9, 0x15, 0xbc, 0x87, 0xf5, 0xae, + 0x8c, 0x10, 0xd4, 0xce, 0x5b, 0x9c, 0xe2, 0xdd, + 0x42, 0x03, 0x09, 0x87, 0x47, 0xed, 0x5d, 0xd0, + 0x7a, 0x69, 0x4c, 0xfa, 0x43, 0x7d, 0xbf, 0x07, + 0x85, 0x6a, 0xee, 0x68, 0xe6, 0x7a, 0x57, 0xb2, + 0x20, 0x8d, 0x80, 0xf2, 0x91, 0x6f, 0x5c, 0x07, + 0x8c, 0xe4, 0x6a, 0x49, 0x90, 0x85, 0x8b, 0x77, + 0x29, 0x56, 0x1c, 0x5e, 0xa9, 0x3f, 0xab, 0x8b, + 0x79, 0xa3, 0x6f, 0x6b, 0x34, 0xcb, 0x61, 0xf6, + 0xe6, 0x92, 0xd1, 0x48, 0x9e, 0x11, 0xa2, 0x82, + 0xc0, 0x4e, 0x23, 0xd2, 0x15, 0x0d, 0x8d, 0xff, + 0xfa, 0x17, 0x9d, 0x81, 0xb8, 0xbc, 0xd7, 0x5b, + 0x08, 0x81, 0x20, 0x40, 0xc0, 0x3c, 0x06, 0x8b, + 0x1a, 0x88, 0x0b, 0x4b, 0x7b, 0x31, 0xf5, 0xd4, + 0x4e, 0x09, 0xd1, 0x4d, 0x0d, 0x7f, 0x45, 0xd1, + 0x09, 0x35, 0xba, 0xce, 0x65, 0xdd, 0xf2, 0xb8, + 0xfb, 0x7a, 0xbc, 0xc4, 0x4b, 0xc8, 0x75, 0xda, + 0x6b, 0xce, 0x3d, 0xe8, 0x94, 0xcc, 0x23, 0x6f, + 0xb0, 0x3b, 0x4f, 0x7d, 0x07, 0xb9, 0x0f, 0x62, + 0x92, 0x7e, 0xda, 0x70, 0x50, 0xce, 0xd3, 0x28, + 0x12, 0x11, 0x00, 0xeb, 0x8d, 0x63, 0x70, 0x78, + 0xa8, 0x7b, 0x76, 0xab, 0xc6, 0x40, 0xc0, 0x4e, + 0x80, 0xdd, 0xf0, 0xfe, 0x83, 0x72, 0x56, 0x4c, + 0x09, 0x4c, 0xf1, 0x72, 0x72, 0x86, 0x26, 0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d, 0x39, + 0xdc, 0xd5, 0x99, 0xc6, 0x01, 0x10, 0xce, 0x42, + 0x1b, 0xac, 0x48, 0xdc, 0x97, 0x78, 0x0a, 0xec, + 0xb3, 0x8f, 0x47, 0x35, 0xa3, 0x6a, 0x64, 0xb2, + 0x8e, 0x63, 0x69, 0x22, 0x66, 0xae, 0x2e, 0xe0, + 0x88, 0xf9, 0x40, 0x3c, 0xc9, 0xa2, 0x57, 0x61, + 0xf6, 0xad, 0xf0, 0xdc, 0x90, 0x56, 0x3f, 0x06, + 0x9b, 0x7d, 0xbd, 0xc2, 0x81, 0x02, 0xab, 0xb8, + 0x15, 0x09, 0x88, 0x4a, 0xff, 0x2f, 0x31, 0xbf, + 0x5e, 0xfa, 0x6a, 0x7e, 0xf6, 0xc5, 0xa7, 0xf7, + 0xd5, 0xab, 0x55, 0xac, 0xae, 0x0d, 0x8c, 0x8d, + 0x7f, 0x4b, 0x25, 0xbb, 0x32, 0xff, 0x11, 0x33, + 0x2e, 0x37, 0x37, 0x69, 0x96, 0x15, 0x17, 0xb1, + 0x17, 0x49, 0xe0, 0x9a, 0x9c, 0xd9, 0x5b, 0x8d, + 0x58, 0xa3, 0x1d, 0x92, 0x87, 0xf8, 0x80, 0xb9, + 0xbd, 0x5a, 0xec, 0x40, 0xe1, 0x00, 0x33, 0x60, + 0xe4, 0x86, 0x16, 0x6d, 0x61, 0x81, 0xf2, 0x28, + 0x6a, 0xa7, 0xce, 0x3f, 0x95, 0xae, 0x43, 0xca, + 0xe1, 0x3f, 0x81, 0x74, 0x7e, 0x1c, 0x47, 0x17, + 0x95, 0xc6, 0x60, 0xda, 0x74, 0x77, 0xd9, 0x9f, + 0xfa, 0x92, 0xb4, 0xbe, 0xe1, 0x23, 0x98, 0x18, + 0x95, 0x63, 0x03, 0x13, 0x4c, 0x1a, 0x2d, 0x41, + 0xcd, 0xe4, 0x84, 0xf7, 0xe6, 0x38, 0xef, 0xff, + 0x95, 0xb2, 0xe8, 0x7c, 0x8f, 0x58, 0xb5, 0xb5, + 0xed, 0x27, 0x7f, 0x3c, 0x18, 0xab, 0xbe, 0x7f, + 0x4f, 0xe2, 0x35, 0x15, 0x71, 0xb7, 0x6f, 0x85, + 0x38, 0x9b, 0x88, 0xf6, 0x9c, 0x8d, 0x43, 0xb5, + 0x58, 0x9e, 0xf2, 0xd1, 0x96, 0xbe, 0xb7, 0xad, + 0x1a, 0xa0, 0x98 + }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "testimit2", + { + 0x80, 0xd9, 0xa0, 0xdc, 0x21, 0xf9, 0x30, 0x40, + 0x75, 0xfe, 0x49, 0x1b, 0x9e, 0x71, 0x90, 0x91, + 0x78, 0x88, 0x21, 0x60, 0x39, 0xe7, 0xc9, 0x2b, + 0xfb, 0x55, 0x1d, 0xf4, 0xdd, 0x2b, 0x0a, 0x01 + }, + G89_IMIT, + { 0 }, + { + 0x90, 0xf2, 0x11, 0x9a + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 10, - { - 0x1d, 0xeb, 0xe6, 0x79, 0x0a, 0x59, 0x00, 0xe6, - 0x8e, 0x5c - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testimit3", - { - 0xa9, 0xb6, 0x37, 0xcc, 0x6d, 0x9b, 0x2f, 0x25, - 0xb0, 0xdf, 0x47, 0x04, 0x50, 0x68, 0xb0, 0x27, - 0x41, 0x27, 0x58, 0x6a, 0xbd, 0x0a, 0x6e, 0x50, - 0x2f, 0xc6, 0xfc, 0xc0, 0x3e, 0x29, 0x42, 0xa5 - }, - G89_IMIT, - { 0 }, - { - 0x31, 0x7c, 0x16, 0xe4 - } + 10, + { + 0x1d, 0xeb, 0xe6, 0x79, 0x0a, 0x59, 0x00, 0xe6, + 0x8e, 0x5c + }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "testimit3", + { + 0xa9, 0xb6, 0x37, 0xcc, 0x6d, 0x9b, 0x2f, 0x25, + 0xb0, 0xdf, 0x47, 0x04, 0x50, 0x68, 0xb0, 0x27, + 0x41, 0x27, 0x58, 0x6a, 0xbd, 0x0a, 0x6e, 0x50, + 0x2f, 0xc6, 0xfc, 0xc0, 0x3e, 0x29, 0x42, 0xa5 + }, + G89_IMIT, + { 0 }, + { + 0x31, 0x7c, 0x16, 0xe4 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 6, - { - 0xef, 0x06, 0x8f, 0x14, 0xc9, 0x04 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testimit4", - { - 0xb0, 0x6c, 0x48, 0x23, 0x0a, 0x6e, 0xf4, 0xec, - 0x27, 0x98, 0x01, 0x23, 0xa7, 0xd8, 0xbf, 0x60, - 0x89, 0xef, 0xad, 0xe8, 0x8f, 0x79, 0x14, 0x8c, - 0x18, 0x5c, 0x9a, 0xda, 0xef, 0x0b, 0xdd, 0xa0 - }, - G89_IMIT, - { 0 }, - { - 0xe9, 0x72, 0xae, 0xbf - } + 6, + { + 0xef, 0x06, 0x8f, 0x14, 0xc9, 0x04 + }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "testimit4", + { + 0xb0, 0x6c, 0x48, 0x23, 0x0a, 0x6e, 0xf4, 0xec, + 0x27, 0x98, 0x01, 0x23, 0xa7, 0xd8, 0xbf, 0x60, + 0x89, 0xef, 0xad, 0xe8, 0x8f, 0x79, 0x14, 0x8c, + 0x18, 0x5c, 0x9a, 0xda, 0xef, 0x0b, 0xdd, 0xa0 + }, + G89_IMIT, + { 0 }, + { + 0xe9, 0x72, 0xae, 0xbf + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 16, - { - 0x02, 0xf8, 0xec, 0x2b, 0x4d, 0x1f, 0xbc, 0x7c, - 0x6e, 0x47, 0xe3, 0x87, 0x22, 0x75, 0x41, 0xa7 - }, - "id-Gost28147-89-CryptoPro-B-ParamSet", - "testimit5", - { - 0x33, 0xd3, 0xef, 0x01, 0x19, 0x95, 0x0e, 0x15, - 0xa1, 0x69, 0x75, 0xae, 0x56, 0x27, 0x17, 0x79, - 0x63, 0x47, 0xab, 0x62, 0x9d, 0x4a, 0xf0, 0x34, - 0xd3, 0x1e, 0x69, 0x74, 0xec, 0x31, 0x48, 0xfc - }, - G89_IMIT, - { 0 }, - { - 0xf5, 0x55, 0x1f, 0x28 - } + 16, + { + 0x02, 0xf8, 0xec, 0x2b, 0x4d, 0x1f, 0xbc, 0x7c, + 0x6e, 0x47, 0xe3, 0x87, 0x22, 0x75, 0x41, 0xa7 + }, + "id-Gost28147-89-CryptoPro-B-ParamSet", + "testimit5", + { + 0x33, 0xd3, 0xef, 0x01, 0x19, 0x95, 0x0e, 0x15, + 0xa1, 0x69, 0x75, 0xae, 0x56, 0x27, 0x17, 0x79, + 0x63, 0x47, 0xab, 0x62, 0x9d, 0x4a, 0xf0, 0x34, + 0xd3, 0x1e, 0x69, 0x74, 0xec, 0x31, 0x48, 0xfc + }, + G89_IMIT, + { 0 }, + { + 0xf5, 0x55, 0x1f, 0x28 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 8, - { - 0xf3, 0xb2, 0x29, 0xd2, 0x7a, 0x37, 0x03, 0x12 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testimit6", - { - 0x42, 0x35, 0x81, 0x91, 0x0b, 0xa9, 0x99, 0xff, - 0xd9, 0x43, 0xf8, 0xc6, 0x19, 0x55, 0x1f, 0x2f, - 0x2d, 0x45, 0x40, 0x20, 0x1e, 0x1d, 0x32, 0x7a, - 0xb1, 0x07, 0x6b, 0x4f, 0x45, 0x90, 0xd9, 0x80 - }, - G89_IMIT, - { 0 }, - { - 0x6e, 0x15, 0xfa, 0xe8 - } + 8, + { + 0xf3, 0xb2, 0x29, 0xd2, 0x7a, 0x37, 0x03, 0x12 + }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "testimit6", + { + 0x42, 0x35, 0x81, 0x91, 0x0b, 0xa9, 0x99, 0xff, + 0xd9, 0x43, 0xf8, 0xc6, 0x19, 0x55, 0x1f, 0x2f, + 0x2d, 0x45, 0x40, 0x20, 0x1e, 0x1d, 0x32, 0x7a, + 0xb1, 0x07, 0x6b, 0x4f, 0x45, 0x90, 0xd9, 0x80 + }, + G89_IMIT, + { 0 }, + { + 0x6e, 0x15, 0xfa, 0xe8 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 0, - { - 0 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testimit7", - { - 0x26, 0xcb, 0xb9, 0xf0, 0x0c, 0x62, 0x9f, 0xaa, - 0x4a, 0x1d, 0xb6, 0x30, 0x09, 0x01, 0x56, 0x89, - 0x66, 0xd4, 0xe4, 0x0e, 0xfe, 0xf6, 0x10, 0x6b, - 0x6c, 0xe8, 0x04, 0x3a, 0xe3, 0x61, 0x4b, 0x19 - }, - G89_IMIT, - { 0 }, - { - 0x00, 0x00, 0x00, 0x00 - } + 0, + { + 0 + }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "testimit7", + { + 0x26, 0xcb, 0xb9, 0xf0, 0x0c, 0x62, 0x9f, 0xaa, + 0x4a, 0x1d, 0xb6, 0x30, 0x09, 0x01, 0x56, 0x89, + 0x66, 0xd4, 0xe4, 0x0e, 0xfe, 0xf6, 0x10, 0x6b, + 0x6c, 0xe8, 0x04, 0x3a, 0xe3, 0x61, 0x4b, 0x19 + }, + G89_IMIT, + { 0 }, + { + 0x00, 0x00, 0x00, 0x00 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 5242880, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test5Mimit", - { - 0xaa, 0x85, 0x84, 0xcd, 0x65, 0x28, 0xe1, 0xdb, - 0xb8, 0x20, 0x19, 0x43, 0xe0, 0x36, 0x35, 0x10, - 0x19, 0xc3, 0x70, 0x5b, 0x27, 0xc1, 0x9d, 0x84, - 0x75, 0xa3, 0xc6, 0x49, 0x46, 0x8f, 0x7c, 0x4e - }, - G89_IMIT, - { 0 }, - { - 0x2a, 0xe6, 0x23, 0xc6 - } + 5242880, + { 0 }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "test5Mimit", + { + 0xaa, 0x85, 0x84, 0xcd, 0x65, 0x28, 0xe1, 0xdb, + 0xb8, 0x20, 0x19, 0x43, 0xe0, 0x36, 0x35, 0x10, + 0x19, 0xc3, 0x70, 0x5b, 0x27, 0xc1, 0x9d, 0x84, + 0x75, 0xa3, 0xc6, 0x49, 0x46, 0x8f, 0x7c, 0x4e + }, + G89_IMIT, + { 0 }, + { + 0x2a, 0xe6, 0x23, 0xc6 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 3221225472ULL + 16, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test3Gimit1", - { - 0xd5, 0xda, 0xfe, 0x06, 0x60, 0xdc, 0xf0, 0xb3, - 0x49, 0x5a, 0x02, 0x59, 0xc8, 0x2e, 0x4a, 0x2b, - 0xcc, 0x9b, 0x98, 0x04, 0xb7, 0xf2, 0x78, 0xb7, - 0xce, 0xa3, 0xf2, 0xdb, 0x9e, 0xa8, 0x49, 0x1d - }, - G89_IMIT, - { 0 }, - { - 0xcc, 0x46, 0x67, 0xe4 - } + 3221225472ULL + 16, + { 0 }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "test3Gimit1", + { + 0xd5, 0xda, 0xfe, 0x06, 0x60, 0xdc, 0xf0, 0xb3, + 0x49, 0x5a, 0x02, 0x59, 0xc8, 0x2e, 0x4a, 0x2b, + 0xcc, 0x9b, 0x98, 0x04, 0xb7, 0xf2, 0x78, 0xb7, + 0xce, 0xa3, 0xf2, 0xdb, 0x9e, 0xa8, 0x49, 0x1d + }, + G89_IMIT, + { 0 }, + { + 0xcc, 0x46, 0x67, 0xe4 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 4ULL*1024*1024*1024ULL, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test4Gimit3", - { - 0x0d, 0xf1, 0xa8, 0x7f, 0x57, 0x03, 0x44, 0xcc, - 0xdb, 0x20, 0xde, 0xed, 0x85, 0x50, 0x38, 0xda, - 0xc9, 0x44, 0xec, 0x2c, 0x0d, 0x66, 0xb7, 0xdc, - 0x17, 0x14, 0x55, 0x95, 0x33, 0x6e, 0x43, 0x3e - }, - G89_IMIT, - { 0 }, - { - 0xb7, 0x21, 0x2e, 0x48 - } + 4ULL*1024*1024*1024ULL, + { 0 }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "test4Gimit3", + { + 0x0d, 0xf1, 0xa8, 0x7f, 0x57, 0x03, 0x44, 0xcc, + 0xdb, 0x20, 0xde, 0xed, 0x85, 0x50, 0x38, 0xda, + 0xc9, 0x44, 0xec, 0x2c, 0x0d, 0x66, 0xb7, 0xdc, + 0x17, 0x14, 0x55, 0x95, 0x33, 0x6e, 0x43, 0x3e + }, + G89_IMIT, + { 0 }, + { + 0xb7, 0x21, 0x2e, 0x48 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 4ULL*1024*1024*1024+4ULL, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test4Gimit1", - { - 0x0c, 0xf3, 0xe9, 0xb0, 0x28, 0x3b, 0x9f, 0x8b, - 0xe3, 0x82, 0xb9, 0xa2, 0xa6, 0xbd, 0x80, 0xd2, - 0xcd, 0xfa, 0x3f, 0xf7, 0x90, 0xa7, 0x55, 0x06, - 0x9b, 0x7a, 0x58, 0xee, 0xe7, 0xf1, 0x9d, 0xbe - }, - G89_IMIT, - { 0 }, - { - 0xda, 0x15, 0x10, 0x73 - } + 4ULL*1024*1024*1024+4ULL, + { 0 }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "test4Gimit1", + { + 0x0c, 0xf3, 0xe9, 0xb0, 0x28, 0x3b, 0x9f, 0x8b, + 0xe3, 0x82, 0xb9, 0xa2, 0xa6, 0xbd, 0x80, 0xd2, + 0xcd, 0xfa, 0x3f, 0xf7, 0x90, 0xa7, 0x55, 0x06, + 0x9b, 0x7a, 0x58, 0xee, 0xe7, 0xf1, 0x9d, 0xbe + }, + G89_IMIT, + { 0 }, + { + 0xda, 0x15, 0x10, 0x73 + } }, { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 4ULL*1024*1024*1024+10ULL, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test4Gimit2", - { - 0x97, 0x1a, 0x42, 0x22, 0xfa, 0x07, 0xb2, 0xca, - 0xf9, 0xd2, 0x34, 0x5a, 0x92, 0xb1, 0x1f, 0x6b, - 0x53, 0xf8, 0xaf, 0xed, 0x9a, 0x73, 0xc4, 0x38, - 0xd7, 0x7d, 0x25, 0x81, 0x00, 0x0d, 0xd4, 0x29 - }, - G89_IMIT, - { 0 }, - { - 0x52, 0xaa, 0x22, 0xb4 - } + 4ULL*1024*1024*1024+10ULL, + { 0 }, + "id-Gost28147-89-CryptoPro-A-ParamSet", + "test4Gimit2", + { + 0x97, 0x1a, 0x42, 0x22, 0xfa, 0x07, 0xb2, 0xca, + 0xf9, 0xd2, 0x34, 0x5a, 0x92, 0xb1, 0x1f, 0x6b, + 0x53, 0xf8, 0xaf, 0xed, 0x9a, 0x73, 0xc4, 0x38, + 0xd7, 0x7d, 0x25, 0x81, 0x00, 0x0d, 0xd4, 0x29 + }, + G89_IMIT, + { 0 }, + { + 0x52, 0xaa, 0x22, 0xb4 + } } }; @@ -1258,18 +1258,18 @@ int main(int argc, char *argv[]) CONF *pConfig = NCONF_new(NULL); BIO *bpConf; char sConf[] = - "openssl_conf = openssl_def\n" - "\n" - "[openssl_def]\n" - "engines = engine_section\n" - "\n" - "[engine_section]\n" - "gost = gost_section\n" - "\n" - "[gost_section]\n" - "default_algorithms = ALL\n" - "\n" - ; + "openssl_conf = openssl_def\n" + "\n" + "[openssl_def]\n" + "engines = engine_section\n" + "\n" + "[engine_section]\n" + "gost = gost_section\n" + "\n" + "[gost_section]\n" + "default_algorithms = ALL\n" + "\n" + ; printf("Testing GOST 28147-89 "); @@ -1289,87 +1289,87 @@ int main(int argc, char *argv[]) */ #ifdef OPENSSL_NO_DYNAMIC_ENGINE { - gost_ctx ctx; + gost_ctx ctx; - for(t = 0; t < sizeof(tcs)/sizeof(tcs[0]); t++) { - const gost_subst_block *pSubst = NULL; + for(t = 0; t < sizeof(tcs)/sizeof(tcs[0]); t++) { + const gost_subst_block *pSubst = NULL; - if(1024 < tcs[t].ullLen) { - /* Key meshing check by engine tests */ - continue; - } - memset(bTest, 0xc3, sizeof(bTest)); - if(0 == strcmp(tcs[t].szParamSet, - "id-GostR3410-94-TestParamSet")) { - pSubst = &GostR3411_94_TestParamSet; - } else if(0 == strcmp(tcs[t].szParamSet, - "id-Gost28147-89-CryptoPro-A-ParamSet")) { - pSubst = &Gost28147_CryptoProParamSetA; - } else if(0 == strcmp(tcs[t].szParamSet, - "id-Gost28147-89-CryptoPro-B-ParamSet")) { - pSubst = &Gost28147_CryptoProParamSetB; - } else if(0 == strcmp(tcs[t].szParamSet, - "id-Gost28147-89-CryptoPro-C-ParamSet")) { - pSubst = &Gost28147_CryptoProParamSetC; - } else if(0 == strcmp(tcs[t].szParamSet, - "id-Gost28147-89-CryptoPro-D-ParamSet")) { - pSubst = &Gost28147_CryptoProParamSetD; - } - gost_init(&ctx, pSubst); - gost_key(&ctx, tcs[t].bRawKey); - switch(tcs[t].gMode) { - case G89_ECB: - gost_enc(&ctx, tcs[t].bIn, bTest, - (int)((tcs[t].ullLen + G89_BLOCK_LEN - 1)/ - G89_BLOCK_LEN)); - l = (size_t)tcs[t].ullLen; - break; - case G89_CFB: - gost_enc_cfb(&ctx, tcs[t].bIV, tcs[t].bIn, - bTest, - (int)((tcs[t].ullLen + G89_BLOCK_LEN - 1)/ - G89_BLOCK_LEN)); - l = (size_t)tcs[t].ullLen; - break; - case G89_CNT: - /* GOST 28147-89 cipher CNT mode check by engine - * tests - */ - continue; - case G89_IMIT: - gost_mac(&ctx, 32, tcs[t].bIn, - (unsigned int)tcs[t].ullLen, - bTest); - gost_mac_iv(&ctx, 32, tcs[t].bIV, tcs[t].bIn, - (unsigned int)tcs[t].ullLen, - bTest1); - if(0 != memcmp(bTest, bTest1, 4)) { - fflush(NULL); - fprintf(stderr, "\nInternal test t=%d len=%llu " - "failed (gost_mac_iv).\n", t, - tcs[t].ullLen); - if(!ignore) { - return 2; - } - } - l = 4; - break; - } - gost_destroy(&ctx); + if(1024 < tcs[t].ullLen) { + /* Key meshing check by engine tests */ + continue; + } + memset(bTest, 0xc3, sizeof(bTest)); + if(0 == strcmp(tcs[t].szParamSet, + "id-GostR3410-94-TestParamSet")) { + pSubst = &GostR3411_94_TestParamSet; + } else if(0 == strcmp(tcs[t].szParamSet, + "id-Gost28147-89-CryptoPro-A-ParamSet")) { + pSubst = &Gost28147_CryptoProParamSetA; + } else if(0 == strcmp(tcs[t].szParamSet, + "id-Gost28147-89-CryptoPro-B-ParamSet")) { + pSubst = &Gost28147_CryptoProParamSetB; + } else if(0 == strcmp(tcs[t].szParamSet, + "id-Gost28147-89-CryptoPro-C-ParamSet")) { + pSubst = &Gost28147_CryptoProParamSetC; + } else if(0 == strcmp(tcs[t].szParamSet, + "id-Gost28147-89-CryptoPro-D-ParamSet")) { + pSubst = &Gost28147_CryptoProParamSetD; + } + gost_init(&ctx, pSubst); + gost_key(&ctx, tcs[t].bRawKey); + switch(tcs[t].gMode) { + case G89_ECB: + gost_enc(&ctx, tcs[t].bIn, bTest, + (int)((tcs[t].ullLen + G89_BLOCK_LEN - 1)/ + G89_BLOCK_LEN)); + l = (size_t)tcs[t].ullLen; + break; + case G89_CFB: + gost_enc_cfb(&ctx, tcs[t].bIV, tcs[t].bIn, + bTest, + (int)((tcs[t].ullLen + G89_BLOCK_LEN - 1)/ + G89_BLOCK_LEN)); + l = (size_t)tcs[t].ullLen; + break; + case G89_CNT: + /* GOST 28147-89 cipher CNT mode check by engine + * tests + */ + continue; + case G89_IMIT: + gost_mac(&ctx, 32, tcs[t].bIn, + (unsigned int)tcs[t].ullLen, + bTest); + gost_mac_iv(&ctx, 32, tcs[t].bIV, tcs[t].bIn, + (unsigned int)tcs[t].ullLen, + bTest1); + if(0 != memcmp(bTest, bTest1, 4)) { + fflush(NULL); + fprintf(stderr, "\nInternal test t=%d len=%llu " + "failed (gost_mac_iv).\n", t, + tcs[t].ullLen); + if(!ignore) { + return 2; + } + } + l = 4; + break; + } + gost_destroy(&ctx); - if(0 != memcmp(tcs[t].bOut, bTest, l)) { - fflush(NULL); - fprintf(stderr, "\nInternal test t=%d len=%llu " - "failed.\n", t, - tcs[t].ullLen); - if(!ignore) { - return 3; - } - } else { - printf(","); - fflush(NULL); - } - } + if(0 != memcmp(tcs[t].bOut, bTest, l)) { + fflush(NULL); + fprintf(stderr, "\nInternal test t=%d len=%llu " + "failed.\n", t, + tcs[t].ullLen); + if(!ignore) { + return 3; + } + } else { + printf(","); + fflush(NULL); + } + } } #endif @@ -1377,7 +1377,7 @@ int main(int argc, char *argv[]) * ccgost engine test on GostR3411_94_CryptoProParamSet */ #ifndef OPENSSL_NO_DYNAMIC_ENGINE - setenv("OPENSSL_ENGINES", CCGOST_DIR, 1); + setenv("OPENSSL_ENGINES", CCGOST_DIR, 1); #endif ERR_load_crypto_strings(); ENGINE_load_builtin_engines(); @@ -1385,186 +1385,186 @@ int main(int argc, char *argv[]) bpConf = BIO_new_mem_buf(sConf, -1); if(!NCONF_load_bio(pConfig, bpConf, &lErrLine)) { - fflush(NULL); - fprintf(stderr, "NCONF_load_bio: ErrLine=%ld: %s\n", - lErrLine, - ERR_error_string(ERR_get_error(), NULL)); - return 4; + fflush(NULL); + fprintf(stderr, "NCONF_load_bio: ErrLine=%ld: %s\n", + lErrLine, + ERR_error_string(ERR_get_error(), NULL)); + return 4; } BIO_free(bpConf); if(!CONF_modules_load(pConfig, NULL, 0)) { - fflush(NULL); - fprintf(stderr, "CONF_modules_load: %s\n", - ERR_error_string(ERR_get_error(), NULL)); - return 5; + fflush(NULL); + fprintf(stderr, "CONF_modules_load: %s\n", + ERR_error_string(ERR_get_error(), NULL)); + return 5; } - /* Test load engine */ + /* Test load engine */ if(NULL == (impl = ENGINE_by_id(CCGOST_ID))) { - fflush(NULL); - fprintf(stderr, "Can't load engine id \"" CCGOST_ID "\"\n"); - if(!ignore) { - return 6; - } + fflush(NULL); + fprintf(stderr, "Can't load engine id \"" CCGOST_ID "\"\n"); + if(!ignore) { + return 6; + } } if(NULL == (md_gost94 = EVP_get_digestbyname(SN_id_GostR3411_94))) { - fflush(NULL); - fprintf(stderr, "\"" SN_id_GostR3411_94 "\" - not found\n"); - if(!ignore) { - return 7; - } + fflush(NULL); + fprintf(stderr, "\"" SN_id_GostR3411_94 "\" - not found\n"); + if(!ignore) { + return 7; + } } if(NULL == (cp_g89cfb = EVP_get_cipherbyname(SN_id_Gost28147_89))) { - fflush(NULL); - fprintf(stderr, "\"" SN_id_Gost28147_89 "\" - not found\n"); - if(!ignore) { - return 8; - } + fflush(NULL); + fprintf(stderr, "\"" SN_id_Gost28147_89 "\" - not found\n"); + if(!ignore) { + return 8; + } } if(NULL == (cp_g89cnt = EVP_get_cipherbyname(SN_gost89_cnt))) { - fflush(NULL); - fprintf(stderr, "\"" SN_gost89_cnt "\" - not found\n"); - if(!ignore) { - return 9; - } + fflush(NULL); + fprintf(stderr, "\"" SN_gost89_cnt "\" - not found\n"); + if(!ignore) { + return 9; + } } if(NULL == (md_g89imit = EVP_get_digestbyname(SN_id_Gost28147_89_MAC))) { - fflush(NULL); - fprintf(stderr, "\"" SN_id_Gost28147_89_MAC "\" - not found\n"); - if(!ignore) { - return 10; - } + fflush(NULL); + fprintf(stderr, "\"" SN_id_Gost28147_89_MAC "\" - not found\n"); + if(!ignore) { + return 10; + } } - /* Test cases */ + /* Test cases */ for(t = 0; t < sizeof(tcs)/sizeof(tcs[0]); t++) { - if(NULL == tcs[t].szDerive) { - continue; - } - memset(bDerive, 0x3c, sizeof(bDerive)); - mdl = sizeof(bDerive); - EVP_Digest(tcs[t].szDerive, strlen(tcs[t].szDerive), - bDerive, &mdl, - md_gost94, impl); - if(0 != memcmp(tcs[t].bRawKey, bDerive, mdl)) { - fflush(NULL); - fprintf(stderr, "Engine test t=%d " - "derive key error.\n", t); - if(!ignore) { - return 12; - } - } - if(ullMaxLen < tcs[t].ullLen) { - continue; - } - memset(bTest, 0xa5, sizeof(bTest)); - memset(bTest1, 0x5a, sizeof(bTest1)); - if(!ENGINE_ctrl_cmd_string(impl, - "CRYPT_PARAMS", - tcs[t].szParamSet, 0)) { - fflush(NULL); - fprintf(stderr, "ENGINE_ctrl_cmd_string: %s\n", - ERR_error_string(ERR_get_error(), NULL)); - return 11; - } - switch(tcs[t].gMode) { - case G89_ECB: - /* OpenSSL/ccgost not implemented GOST 28147-89 ECB */ - continue; - case G89_CFB: - ctype = cp_g89cfb; - goto engine_cipher_check; - case G89_CNT: - if(0 != strcmp("id-Gost28147-89-CryptoPro-A-ParamSet", - tcs[t].szParamSet)) { - /* - * ccgost engine can't change S-Box for gost-cnt - */ - continue; - } - ctype = cp_g89cnt; -engine_cipher_check: - EVP_CIPHER_CTX_init(ectx); - EVP_EncryptInit_ex(ectx, ctype, impl, - bDerive, tcs[t].bIV); - if(G89_MAX_TC_LEN >= tcs[t].ullLen) { - enlu = sizeof(bTest); - EVP_EncryptUpdate(ectx, bTest, &enlu, - tcs[t].bIn, (int)tcs[t].ullLen); - l = (size_t)tcs[t].ullLen; - } else { - for(ullLeft = tcs[t].ullLen; - ullLeft >= sizeof(bZB); - ullLeft -= sizeof(bZB)) { - printf("B"); - fflush(NULL); - enlu = sizeof(bTS); - EVP_EncryptUpdate(ectx, bTS, &enlu, - bZB, sizeof(bZB)); - } - printf("b%llu/%llu", ullLeft, tcs[t].ullLen); - fflush(NULL); - EVP_EncryptUpdate(ectx, bTS, &enlu, - bZB, (int)ullLeft); - memcpy(bTest, &bTS[enlu-16], 16); - enlu = (int)tcs[t].ullLen; - l = 16; - } - enlf = sizeof(bTest1); - EVP_EncryptFinal_ex(ectx, bTest1, &enlf); - EVP_CIPHER_CTX_cleanup(ectx); - break; - case G89_IMIT: - if(0 != strcmp("id-Gost28147-89-CryptoPro-A-ParamSet", - tcs[t].szParamSet)) { - /* - * ccgost engine can't change S-Box for gost-mac - */ - continue; - } - EVP_MD_CTX_init(mctx); - mac_key = EVP_PKEY_new_mac_key( - NID_id_Gost28147_89_MAC, NULL, - bDerive, mdl); - EVP_DigestSignInit(mctx, NULL, - md_g89imit, impl, mac_key); - if(G89_MAX_TC_LEN >= tcs[t].ullLen) { - EVP_DigestSignUpdate(mctx, tcs[t].bIn, - (unsigned int)tcs[t].ullLen); - } else { - for(ullLeft = tcs[t].ullLen; - ullLeft >= sizeof(bZB); - ullLeft -= sizeof(bZB)) { - printf("B"); - fflush(NULL); - EVP_DigestSignUpdate(mctx, bZB, sizeof(bZB)); - } - printf("b%llu/%llu", ullLeft, tcs[t].ullLen); - fflush(NULL); - EVP_DigestSignUpdate(mctx, bZB, - (unsigned int)ullLeft); - } - siglen = 4; - EVP_DigestSignFinal(mctx, bTest, &siglen); - EVP_MD_CTX_free(mctx); - enlu = (int)tcs[t].ullLen; - enlf = 0; - l = siglen; - break; - } - if((int)tcs[t].ullLen != enlu || 0 != enlf || - 0 != memcmp(tcs[t].bOut, bTest, l)) { - fflush(NULL); - fprintf(stderr, "\nEngine test t=%d len=%llu " - "failed.\n", t, tcs[t].ullLen); - if(!ignore) { - return 13; - } - } else { - printf("."); - fflush(NULL); - } + if(NULL == tcs[t].szDerive) { + continue; + } + memset(bDerive, 0x3c, sizeof(bDerive)); + mdl = sizeof(bDerive); + EVP_Digest(tcs[t].szDerive, strlen(tcs[t].szDerive), + bDerive, &mdl, + md_gost94, impl); + if(0 != memcmp(tcs[t].bRawKey, bDerive, mdl)) { + fflush(NULL); + fprintf(stderr, "Engine test t=%d " + "derive key error.\n", t); + if(!ignore) { + return 12; + } + } + if(ullMaxLen < tcs[t].ullLen) { + continue; + } + memset(bTest, 0xa5, sizeof(bTest)); + memset(bTest1, 0x5a, sizeof(bTest1)); + if(!ENGINE_ctrl_cmd_string(impl, + "CRYPT_PARAMS", + tcs[t].szParamSet, 0)) { + fflush(NULL); + fprintf(stderr, "ENGINE_ctrl_cmd_string: %s\n", + ERR_error_string(ERR_get_error(), NULL)); + return 11; + } + switch(tcs[t].gMode) { + case G89_ECB: + /* OpenSSL/ccgost not implemented GOST 28147-89 ECB */ + continue; + case G89_CFB: + ctype = cp_g89cfb; + goto engine_cipher_check; + case G89_CNT: + if(0 != strcmp("id-Gost28147-89-CryptoPro-A-ParamSet", + tcs[t].szParamSet)) { + /* + * ccgost engine can't change S-Box for gost-cnt + */ + continue; + } + ctype = cp_g89cnt; + engine_cipher_check: + EVP_CIPHER_CTX_init(ectx); + EVP_EncryptInit_ex(ectx, ctype, impl, + bDerive, tcs[t].bIV); + if(G89_MAX_TC_LEN >= tcs[t].ullLen) { + enlu = sizeof(bTest); + EVP_EncryptUpdate(ectx, bTest, &enlu, + tcs[t].bIn, (int)tcs[t].ullLen); + l = (size_t)tcs[t].ullLen; + } else { + for(ullLeft = tcs[t].ullLen; + ullLeft >= sizeof(bZB); + ullLeft -= sizeof(bZB)) { + printf("B"); + fflush(NULL); + enlu = sizeof(bTS); + EVP_EncryptUpdate(ectx, bTS, &enlu, + bZB, sizeof(bZB)); + } + printf("b%llu/%llu", ullLeft, tcs[t].ullLen); + fflush(NULL); + EVP_EncryptUpdate(ectx, bTS, &enlu, + bZB, (int)ullLeft); + memcpy(bTest, &bTS[enlu-16], 16); + enlu = (int)tcs[t].ullLen; + l = 16; + } + enlf = sizeof(bTest1); + EVP_EncryptFinal_ex(ectx, bTest1, &enlf); + EVP_CIPHER_CTX_cleanup(ectx); + break; + case G89_IMIT: + if(0 != strcmp("id-Gost28147-89-CryptoPro-A-ParamSet", + tcs[t].szParamSet)) { + /* + * ccgost engine can't change S-Box for gost-mac + */ + continue; + } + EVP_MD_CTX_init(mctx); + mac_key = EVP_PKEY_new_mac_key( + NID_id_Gost28147_89_MAC, NULL, + bDerive, mdl); + EVP_DigestSignInit(mctx, NULL, + md_g89imit, impl, mac_key); + if(G89_MAX_TC_LEN >= tcs[t].ullLen) { + EVP_DigestSignUpdate(mctx, tcs[t].bIn, + (unsigned int)tcs[t].ullLen); + } else { + for(ullLeft = tcs[t].ullLen; + ullLeft >= sizeof(bZB); + ullLeft -= sizeof(bZB)) { + printf("B"); + fflush(NULL); + EVP_DigestSignUpdate(mctx, bZB, sizeof(bZB)); + } + printf("b%llu/%llu", ullLeft, tcs[t].ullLen); + fflush(NULL); + EVP_DigestSignUpdate(mctx, bZB, + (unsigned int)ullLeft); + } + siglen = 4; + EVP_DigestSignFinal(mctx, bTest, &siglen); + EVP_MD_CTX_free(mctx); + enlu = (int)tcs[t].ullLen; + enlf = 0; + l = siglen; + break; + } + if((int)tcs[t].ullLen != enlu || 0 != enlf || + 0 != memcmp(tcs[t].bOut, bTest, l)) { + fflush(NULL); + fprintf(stderr, "\nEngine test t=%d len=%llu " + "failed.\n", t, tcs[t].ullLen); + if(!ignore) { + return 13; + } + } else { + printf("."); + fflush(NULL); + } } printf(" passed\n"); diff --git a/test_gost89.c b/test_gost89.c index cdba84221..fb3d71b90 100644 --- a/test_gost89.c +++ b/test_gost89.c @@ -11,19 +11,7 @@ #include "gost89.h" #include #include - -static void hexdump(FILE *f, const char *title, const unsigned char *s, int l) -{ - int n = 0; - - fprintf(f, "%s", title); - for (; n < l; ++n) { - if ((n % 16) == 0) - fprintf(f, "\n%04x", n); - fprintf(f, " %02x", s[n]); - } - fprintf(f, "\n"); -} +#include "test.h" int main(void) { @@ -58,7 +46,7 @@ int main(void) if (memcmp(meshed_key, buf, 32)) { fprintf(stderr, "Magma meshing failed"); - ret = 1; + ret = 1; } acpkm_magma_key_meshing(&ctx); diff --git a/test_grasshopper.c b/test_grasshopper.c index f11f04943..54cb1d6ab 100644 --- a/test_grasshopper.c +++ b/test_grasshopper.c @@ -11,28 +11,26 @@ #include "gost_grasshopper_core.h" #include "e_gost_err.h" #include "gost_lcl.h" +#include "test.h" +#include "ansi_terminal.h" #include #include #include #include #include +#include +#if defined(_MSC_VER) + /* MSVC doesn't fully support C99 VLA. The simples workaround is using + big static array instead. + */ +# define MAX_BUF_SIZE 144 +# define DECLARE_BUF(SZ) unsigned char c[MAX_BUF_SIZE];\ + assert(SZ<=MAX_BUF_SIZE); +#else +# define DECLARE_BUF(SZ) unsigned char c[SZ]; +#endif -#define T(e) if (!(e)) {\ - ERR_print_errors_fp(stderr);\ - OpenSSLDie(__FILE__, __LINE__, #e);\ - } -#define cRED "\033[1;31m" -#define cDRED "\033[0;31m" -#define cGREEN "\033[1;32m" -#define cDGREEN "\033[0;32m" -#define cBLUE "\033[1;34m" -#define cDBLUE "\033[0;34m" -#define cNORM "\033[m" -#define TEST_ASSERT(e) {if ((test = (e))) \ - printf(cRED "Test FAILED\n" cNORM); \ - else \ - printf(cGREEN "Test passed\n" cNORM);} /* Test key from both GOST R 34.12-2015 and GOST R 34.13-2015. */ static const unsigned char K[32] = { @@ -141,14 +139,14 @@ static const unsigned char E_cfb[] = { 0xe1,0xc8,0x52,0xe9,0xa8,0x56,0x71,0x62,0xdb,0xb5,0xda,0x7f,0x66,0xde,0xa9,0x26, }; -static const unsigned char iv_ctr[] = { 0x12,0x34,0x56,0x78,0x90,0xab,0xce,0xf0, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; +static const unsigned char iv_ctr[] = { 0x12,0x34,0x56,0x78,0x90,0xab,0xce,0xf0, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; /* Truncated to 128-bits IV from GOST examples. */ -static const unsigned char iv_128bit[] = { 0x12,0x34,0x56,0x78,0x90,0xab,0xce,0xf0, - 0xa1,0xb2,0xc3,0xd4,0xe5,0xf0,0x01,0x12 }; +static const unsigned char iv_128bit[] = { 0x12,0x34,0x56,0x78,0x90,0xab,0xce,0xf0, + 0xa1,0xb2,0xc3,0xd4,0xe5,0xf0,0x01,0x12 }; /* Universal IV for ACPKM-Master. */ -static const unsigned char iv_acpkm_m[] = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; +static const unsigned char iv_acpkm_m[] = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; static const unsigned char MAC_omac[] = { 0x33,0x6f,0x4d,0x29,0x60,0x59,0xfb,0xe3 }; static const unsigned char MAC_omac_acpkm1[] = { 0xB5,0x36,0x7F,0x47,0xB6,0x2B,0x99,0x5E,0xEB,0x2A,0x64,0x8C,0x58,0x43,0x14,0x5E, @@ -159,7 +157,7 @@ static const unsigned char MAC_omac_acpkm2[] = { struct testcase { const char *name; - const EVP_CIPHER *(*type)(void); + const EVP_CIPHER *(*type)(); int stream; const unsigned char *plaintext; const unsigned char *expected; @@ -174,24 +172,13 @@ static struct testcase testcases[] = { { "ctr-no-acpkm", cipher_gost_grasshopper_ctracpkm, 1, P, E_ctr, sizeof(P), iv_ctr, sizeof(iv_ctr), 0 }, { "ctracpkm", cipher_gost_grasshopper_ctracpkm, 1, P_acpkm, E_acpkm, sizeof(P_acpkm), iv_ctr, sizeof(iv_ctr), 256 / 8 }, { "acpkm-Master", cipher_gost_grasshopper_ctracpkm, 0, P_acpkm_master, E_acpkm_master, sizeof(P_acpkm_master), - iv_acpkm_m, sizeof(iv_acpkm_m), 768 / 8 }, + iv_acpkm_m, sizeof(iv_acpkm_m), 768 / 8 }, { "ofb", cipher_gost_grasshopper_ofb, 1, P, E_ofb, sizeof(P), iv_128bit, sizeof(iv_128bit), 0 }, { "cbc", cipher_gost_grasshopper_cbc, 0, P, E_cbc, sizeof(P), iv_128bit, sizeof(iv_128bit), 0 }, { "cfb", cipher_gost_grasshopper_cfb, 0, P, E_cfb, sizeof(P), iv_128bit, sizeof(iv_128bit), 0 }, - NULL + {0} }; -static void hexdump(const void *ptr, size_t len) -{ - const unsigned char *p = ptr; - size_t i, j; - - for (i = 0; i < len; i += j) { - for (j = 0; j < 16 && i + j < len; j++) - printf("%s%02x", j? "" : " ", p[i + j]); - } - printf("\n"); -} static int test_block(const EVP_CIPHER *type, const char *name, const unsigned char *pt, const unsigned char *exp, size_t size, @@ -200,79 +187,80 @@ static int test_block(const EVP_CIPHER *type, const char *name, { EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); const char *standard = acpkm? "R 23565.1.017-2018" : "GOST R 34.13-2015"; - unsigned char c[size]; int outlen, tmplen; int ret = 0, test; + + DECLARE_BUF(size); OPENSSL_assert(ctx); printf("Encryption test from %s [%s] %s\n", standard, name, - inplace ? "in-place" : "out-of-place"); + inplace ? "in-place" : "out-of-place"); /* test with single big chunk */ EVP_CIPHER_CTX_init(ctx); T(EVP_CipherInit_ex(ctx, type, NULL, K, iv, 1)); T(EVP_CIPHER_CTX_set_padding(ctx, 0)); if (inplace) - memcpy(c, pt, size); + memcpy(c, pt, size); else - memset(c, 0, sizeof(c)); + memset(c, 0, size); if (acpkm) - T(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, NULL)); + T(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, NULL)); T(EVP_CipherUpdate(ctx, c, &outlen, inplace? c : pt, size)); T(EVP_CipherFinal_ex(ctx, c + outlen, &tmplen)); EVP_CIPHER_CTX_cleanup(ctx); printf(" c[%d] = ", outlen); - hexdump(c, outlen); + hexdump_inline(c, outlen); TEST_ASSERT(outlen != size || memcmp(c, exp, size)); ret |= test; /* test with small chunks of block size */ printf("Chunked encryption test from %s [%s] %s\n", standard, name, - inplace ? "in-place" : "out-of-place"); + inplace ? "in-place" : "out-of-place"); int blocks = size / GRASSHOPPER_BLOCK_SIZE; int z; EVP_CIPHER_CTX_init(ctx); T(EVP_CipherInit_ex(ctx, type, NULL, K, iv, 1)); T(EVP_CIPHER_CTX_set_padding(ctx, 0)); if (inplace) - memcpy(c, pt, size); + memcpy(c, pt, size); else - memset(c, 0, sizeof(c)); + memset(c, 0, size); if (acpkm) - T(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, NULL)); + T(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, NULL)); for (z = 0; z < blocks; z++) { - int offset = z * GRASSHOPPER_BLOCK_SIZE; - int sz = GRASSHOPPER_BLOCK_SIZE; + int offset = z * GRASSHOPPER_BLOCK_SIZE; + int sz = GRASSHOPPER_BLOCK_SIZE; - T(EVP_CipherUpdate(ctx, c + offset, &outlen, (inplace ? c : pt) + offset, sz)); + T(EVP_CipherUpdate(ctx, c + offset, &outlen, (inplace ? c : pt) + offset, sz)); } outlen = z * GRASSHOPPER_BLOCK_SIZE; T(EVP_CipherFinal_ex(ctx, c + outlen, &tmplen)); EVP_CIPHER_CTX_cleanup(ctx); printf(" c[%d] = ", outlen); - hexdump(c, outlen); + hexdump_inline(c, outlen); TEST_ASSERT(outlen != size || memcmp(c, exp, size)); ret |= test; /* test with single big chunk */ printf("Decryption test from %s [%s] %s\n", standard, name, - inplace ? "in-place" : "out-of-place"); + inplace ? "in-place" : "out-of-place"); EVP_CIPHER_CTX_init(ctx); T(EVP_CipherInit_ex(ctx, type, NULL, K, iv, 0)); T(EVP_CIPHER_CTX_set_padding(ctx, 0)); if (inplace) - memcpy(c, exp, size); + memcpy(c, exp, size); else - memset(c, 0, sizeof(c)); + memset(c, 0, size); if (acpkm) - T(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, NULL)); + T(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, NULL)); T(EVP_CipherUpdate(ctx, c, &outlen, inplace ? c : exp, size)); T(EVP_CipherFinal_ex(ctx, c + outlen, &tmplen)); EVP_CIPHER_CTX_cleanup(ctx); EVP_CIPHER_CTX_free(ctx); printf(" d[%d] = ", outlen); - hexdump(c, outlen); + hexdump_inline(c, outlen); TEST_ASSERT(outlen != size || memcmp(c, pt, size)); ret |= test; @@ -288,37 +276,37 @@ static int test_stream(const EVP_CIPHER *type, const char *name, const char *standard = acpkm? "R 23565.1.017-2018" : "GOST R 34.13-2015"; int ret = 0, test; int z; + DECLARE_BUF(size); OPENSSL_assert(ctx); /* Cycle through all lengths from 1 upto maximum size */ printf("Stream encryption test from %s [%s] \n", standard, name); for (z = 1; z <= size; z++) { - unsigned char c[size]; - int outlen, tmplen; - int sz = 0; - int i; - - EVP_CIPHER_CTX_init(ctx); - T(EVP_CipherInit_ex(ctx, type, NULL, K, iv, 1)); - T(EVP_CIPHER_CTX_set_padding(ctx, 0)); - memset(c, 0xff, sizeof(c)); - if (acpkm) - T(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, NULL)); - for (i = 0; i < size; i += z) { - if (i + z > size) - sz = size - i; - else - sz = z; - T(EVP_CipherUpdate(ctx, c + i, &outlen, pt + i, sz)); - OPENSSL_assert(outlen == sz); - } - outlen = i - z + sz; - T(EVP_CipherFinal_ex(ctx, c + outlen, &tmplen)); - EVP_CIPHER_CTX_cleanup(ctx); - - test = outlen != size || memcmp(c, exp, size); - printf("%c", test ? 'E' : '+'); - ret |= test; + int outlen, tmplen; + int sz = 0; + int i; + + EVP_CIPHER_CTX_init(ctx); + T(EVP_CipherInit_ex(ctx, type, NULL, K, iv, 1)); + T(EVP_CIPHER_CTX_set_padding(ctx, 0)); + memset(c, 0xff, size); + if (acpkm) + T(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, NULL)); + for (i = 0; i < size; i += z) { + if (i + z > size) + sz = size - i; + else + sz = z; + T(EVP_CipherUpdate(ctx, c + i, &outlen, pt + i, sz)); + OPENSSL_assert(outlen == sz); + } + outlen = i - z + sz; + T(EVP_CipherFinal_ex(ctx, c + outlen, &tmplen)); + EVP_CIPHER_CTX_cleanup(ctx); + + test = outlen != size || memcmp(c, exp, size); + printf("%c", test ? 'E' : '+'); + ret |= test; } printf("\n"); TEST_ASSERT(ret); @@ -343,21 +331,21 @@ static int test_mac(const char *name, const char *from, T(EVP_DigestInit_ex(ctx, type, NULL)); T(EVP_MD_CTX_ctrl(ctx, EVP_MD_CTRL_SET_KEY, sizeof(K), (void *)K)); if (acpkm) - T(EVP_MD_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, acpkm_t ? &acpkm_t : NULL)); + T(EVP_MD_CTX_ctrl(ctx, EVP_CTRL_KEY_MESH, acpkm, acpkm_t ? &acpkm_t : NULL)); T(EVP_DigestUpdate(ctx, pt, pt_size)); if (EVP_MD_flags(EVP_MD_CTX_md(ctx)) & EVP_MD_FLAG_XOF) { - T(EVP_DigestFinalXOF(ctx, md_value, mac_size)); - md_len = (unsigned int)mac_size; + T(EVP_DigestFinalXOF(ctx, md_value, mac_size)); + md_len = (unsigned int)mac_size; } else { - T(EVP_MD_CTX_size(ctx) == mac_size); - T(EVP_DigestFinal_ex(ctx, md_value, &md_len)); + T(EVP_MD_CTX_size(ctx) == mac_size); + T(EVP_DigestFinal_ex(ctx, md_value, &md_len)); } EVP_MD_CTX_free(ctx); printf(" MAC[%u] = ", md_len); - hexdump(md_value, mac_size); + hexdump_inline(md_value, mac_size); TEST_ASSERT(md_len != mac_size || - memcmp(mac, md_value, mac_size)); + memcmp(mac, md_value, mac_size)); return test; } @@ -367,6 +355,7 @@ int main(int argc, char **argv) int ret = 0; const struct testcase *t; + setupConsole(); setenv("OPENSSL_ENGINES", ENGINE_DIR, 0); OPENSSL_add_all_algorithms_conf(); ERR_load_crypto_strings(); @@ -376,18 +365,18 @@ int main(int argc, char **argv) T(ENGINE_set_default(eng, ENGINE_METHOD_ALL)); for (t = testcases; t->name; t++) { - int inplace; - const char *standard = t->acpkm? "R 23565.1.017-2018" : "GOST R 34.13-2015"; - - printf(cBLUE "# Tests for %s [%s]\n" cNORM, t->name, standard); - for (inplace = 0; inplace <= 1; inplace++) - ret |= test_block(t->type(), t->name, - t->plaintext, t->expected, t->size, - t->iv, t->iv_size, t->acpkm, inplace); - if (t->stream) - ret |= test_stream(t->type(), t->name, - t->plaintext, t->expected, t->size, - t->iv, t->iv_size, t->acpkm); + int inplace; + const char *standard = t->acpkm? "R 23565.1.017-2018" : "GOST R 34.13-2015"; + + printf(cBLUE "# Tests for %s [%s]\n" cNORM, t->name, standard); + for (inplace = 0; inplace <= 1; inplace++) + ret |= test_block(t->type(), t->name, + t->plaintext, t->expected, t->size, + t->iv, t->iv_size, t->acpkm, inplace); + if (t->stream) + ret |= test_stream(t->type(), t->name, + t->plaintext, t->expected, t->size, + t->iv, t->iv_size, t->acpkm); } printf(cBLUE "# Tests for omac\n" cNORM); @@ -406,8 +395,9 @@ int main(int argc, char **argv) ENGINE_free(eng); if (ret) - printf(cDRED "= Some tests FAILED!\n" cNORM); + printf(cDRED "= Some tests FAILED!\n" cNORM); else - printf(cDGREEN "= All tests passed!\n" cNORM); + printf(cDGREEN "= All tests passed!\n" cNORM); + restoreConsole(); return ret; } diff --git a/test_keyexpimp.c b/test_keyexpimp.c index de7b1fa40..feeb2eb56 100644 --- a/test_keyexpimp.c +++ b/test_keyexpimp.c @@ -1,4 +1,4 @@ -#include + #include #include #include @@ -8,24 +8,9 @@ #include "gost_lcl.h" #include "e_gost_err.h" #include "gost_grasshopper_cipher.h" +#include "test.h" +#include "ansi_terminal.h" -#define T(e) if (!(e)) {\ - ERR_print_errors_fp(stderr);\ - OpenSSLDie(__FILE__, __LINE__, #e);\ - } - -static void hexdump(FILE *f, const char *title, const unsigned char *s, int l) -{ - int n = 0; - - fprintf(f, "%s", title); - for (; n < l; ++n) { - if ((n % 16) == 0) - fprintf(f, "\n%04x", n); - fprintf(f, " %02x", s[n]); - } - fprintf(f, "\n"); -} int main(void) { @@ -118,12 +103,12 @@ int main(void) if (ret <= 0) { ERR_print_errors_fp(stderr); - err = 1; + err = 1; } else { hexdump(stdout, "Magma key export", buf, 40); if (memcmp(buf, magma_export, 40) != 0) { fprintf(stdout, "ERROR! test failed\n"); - err = 2; + err = 2; } } @@ -133,12 +118,12 @@ int main(void) if (ret <= 0) { ERR_print_errors_fp(stderr); - err = 3; + err = 3; } else { hexdump(stdout, "Magma key import", buf, 32); if (memcmp(buf, shared_key, 32) != 0) { fprintf(stdout, "ERROR! test failed\n"); - err = 4; + err = 4; } } @@ -146,24 +131,24 @@ int main(void) kdf_seed, 8, 1); if (ret <= 0) { ERR_print_errors_fp(stderr); - err = 5; + err = 5; } else { hexdump(stdout, "KDF TREE", kdf_result, 64); if (memcmp(kdf_result, kdf_etalon, 64) != 0) { fprintf(stdout, "ERROR! test failed\n"); - err = 6; + err = 6; } } ret = gost_tlstree(NID_grasshopper_cbc, kroot, out, tlsseq); if (ret <= 0) { ERR_print_errors_fp(stderr); - err = 7; + err = 7; } else { hexdump(stdout, "Gost TLSTREE - grasshopper", out, 32); if (memcmp(out, tlstree_gh_etalon, 32) != 0) { fprintf(stdout, "ERROR! test failed\n"); - err = 8; + err = 8; } } diff --git a/test_params.c b/test_params.c index f7d4b90f8..3080ec857 100644 --- a/test_params.c +++ b/test_params.c @@ -9,6 +9,8 @@ #include "e_gost_err.h" #include "gost_lcl.h" +#include "test.h" +#include "ansi_terminal.h" #include #include #include @@ -19,38 +21,14 @@ #include #include -#define T(e) ({ if (!(e)) { \ - ERR_print_errors_fp(stderr); \ - OpenSSLDie(__FILE__, __LINE__, #e); \ - } \ - }) -#define TE(e) ({ if (!(e)) { \ - ERR_print_errors_fp(stderr); \ - fprintf(stderr, "Error at %s:%d %s\n", __FILE__, __LINE__, #e); \ - return -1; \ - } \ - }) - -#define cRED "\033[1;31m" -#define cDRED "\033[0;31m" -#define cGREEN "\033[1;32m" -#define cDGREEN "\033[0;32m" -#define cBLUE "\033[1;34m" -#define cDBLUE "\033[0;34m" -#define cNORM "\033[m" -#define TEST_ASSERT(e) {if ((test = (e))) \ - printf(cRED " Test FAILED\n" cNORM); \ - else \ - printf(cGREEN " Test passed\n" cNORM);} - struct test_param { - unsigned int param; /* NID of EC parameters */ - unsigned int len; /* length of a digest or a half of the key */ - unsigned int data_len; /* length of @data */ - const uint8_t *data; /* data to hash (optional) */ - const uint8_t *hash; /* hash of data */ - const uint8_t *signature; /* raw signature */ - const uint8_t *pub_key; /* raw public key */ + unsigned int param; /* NID of EC parameters */ + unsigned int len; /* length of a digest or a half of the key */ + unsigned int data_len; /* length of @data */ + const uint8_t *data; /* data to hash (optional) */ + const uint8_t *hash; /* hash of data */ + const uint8_t *signature; /* raw signature */ + const uint8_t *pub_key; /* raw public key */ }; /* @@ -402,73 +380,73 @@ const uint8_t pubkey_tc26_gost_3410_12_512_setC[] = { /* end */ static struct test_param cp_2001_256_a = { - .param = NID_id_GostR3410_2001_CryptoPro_A_ParamSet, - .len = 256 / 8, - .data = data_2001_256_setA, - .data_len = sizeof(data_2001_256_setA), - .hash = hash_2001_256_setA, - .signature = signature_2001_256_setA, - .pub_key = pubkey_2001_256_setA, + .param = NID_id_GostR3410_2001_CryptoPro_A_ParamSet, + .len = 256 / 8, + .data = data_2001_256_setA, + .data_len = sizeof(data_2001_256_setA), + .hash = hash_2001_256_setA, + .signature = signature_2001_256_setA, + .pub_key = pubkey_2001_256_setA, }; static struct test_param cp_2001_256_b = { - .param = NID_id_GostR3410_2001_CryptoPro_B_ParamSet, - .len = 256 / 8, - .data = data_2001_256_setB, - .data_len = sizeof(data_2001_256_setB), - .hash = hash_2001_256_setB, - .signature = signature_2001_256_setB, - .pub_key = pubkey_2001_256_setB, + .param = NID_id_GostR3410_2001_CryptoPro_B_ParamSet, + .len = 256 / 8, + .data = data_2001_256_setB, + .data_len = sizeof(data_2001_256_setB), + .hash = hash_2001_256_setB, + .signature = signature_2001_256_setB, + .pub_key = pubkey_2001_256_setB, }; static struct test_param cp_2001_256_c = { - .param = NID_id_GostR3410_2001_CryptoPro_C_ParamSet, - .len = 256 / 8, - .data = data_2001_256_setC, - .data_len = sizeof(data_2001_256_setC), - .hash = hash_2001_256_setC, - .signature = signature_2001_256_setC, - .pub_key = pubkey_2001_256_setC, + .param = NID_id_GostR3410_2001_CryptoPro_C_ParamSet, + .len = 256 / 8, + .data = data_2001_256_setC, + .data_len = sizeof(data_2001_256_setC), + .hash = hash_2001_256_setC, + .signature = signature_2001_256_setC, + .pub_key = pubkey_2001_256_setC, }; static struct test_param tc_2012_256_a = { - .param = NID_id_tc26_gost_3410_2012_256_paramSetA, - .len = 256 / 8, - .data = data_tc26_gost_3410_12_256_setA, - .data_len = sizeof(data_tc26_gost_3410_12_256_setA), - .hash = hash_tc26_gost_3410_12_256_setA, - .signature = signature_tc26_gost_3410_12_256_setA, - .pub_key = pubkey_tc26_gost_3410_12_256_setA, + .param = NID_id_tc26_gost_3410_2012_256_paramSetA, + .len = 256 / 8, + .data = data_tc26_gost_3410_12_256_setA, + .data_len = sizeof(data_tc26_gost_3410_12_256_setA), + .hash = hash_tc26_gost_3410_12_256_setA, + .signature = signature_tc26_gost_3410_12_256_setA, + .pub_key = pubkey_tc26_gost_3410_12_256_setA, }; static struct test_param tc_2012_512_a = { - .param = NID_id_tc26_gost_3410_2012_512_paramSetA, - .len = 512 / 8, - .data = data_tc26_gost_3410_12_512_setA, - .data_len = sizeof(data_tc26_gost_3410_12_512_setA), - .hash = hash_tc26_gost_3410_12_512_setA, - .signature = signature_tc26_gost_3410_12_512_setA, - .pub_key = pubkey_tc26_gost_3410_12_512_setA, + .param = NID_id_tc26_gost_3410_2012_512_paramSetA, + .len = 512 / 8, + .data = data_tc26_gost_3410_12_512_setA, + .data_len = sizeof(data_tc26_gost_3410_12_512_setA), + .hash = hash_tc26_gost_3410_12_512_setA, + .signature = signature_tc26_gost_3410_12_512_setA, + .pub_key = pubkey_tc26_gost_3410_12_512_setA, }; static struct test_param tc_2012_512_b = { - .param = NID_id_tc26_gost_3410_2012_512_paramSetB, - .len = 512 / 8, - .data = data_tc26_gost_3410_12_512_setB, - .data_len = sizeof(data_tc26_gost_3410_12_512_setB), - .hash = hash_tc26_gost_3410_12_512_setB, - .signature = signature_tc26_gost_3410_12_512_setB, - .pub_key = pubkey_tc26_gost_3410_12_512_setB, + .param = NID_id_tc26_gost_3410_2012_512_paramSetB, + .len = 512 / 8, + .data = data_tc26_gost_3410_12_512_setB, + .data_len = sizeof(data_tc26_gost_3410_12_512_setB), + .hash = hash_tc26_gost_3410_12_512_setB, + .signature = signature_tc26_gost_3410_12_512_setB, + .pub_key = pubkey_tc26_gost_3410_12_512_setB, }; static struct test_param tc_2012_512_c = { - .param = NID_id_tc26_gost_3410_2012_512_paramSetC, - .len = 512 / 8, - .data = data_tc26_gost_3410_12_512_setC, - .data_len = sizeof(data_tc26_gost_3410_12_512_setC), - .hash = hash_tc26_gost_3410_12_512_setC, - .signature = signature_tc26_gost_3410_12_512_setC, - .pub_key = pubkey_tc26_gost_3410_12_512_setC, + .param = NID_id_tc26_gost_3410_2012_512_paramSetC, + .len = 512 / 8, + .data = data_tc26_gost_3410_12_512_setC, + .data_len = sizeof(data_tc26_gost_3410_12_512_setC), + .hash = hash_tc26_gost_3410_12_512_setC, + .signature = signature_tc26_gost_3410_12_512_setC, + .pub_key = pubkey_tc26_gost_3410_12_512_setC, }; static struct test_param *test_params[] = { @@ -858,26 +836,15 @@ static struct test_cert { }; #undef D -static void hexdump(const void *ptr, size_t len) -{ - const unsigned char *p = ptr; - size_t i, j; - - for (i = 0; i < len; i += j) { - for (j = 0; j < 16 && i + j < len; j++) - printf("%s %02x", j? "" : "\n", p[i + j]); - } - printf("\n"); -} static void print_test_result(int err) { if (err == 1) - printf(cGREEN "correct\n" cNORM); + printf(cGREEN "correct\n" cNORM); else if (err == 0) - printf(cRED "incorrect\n" cNORM); + printf(cRED "incorrect\n" cNORM); else - ERR_print_errors_fp(stderr); + ERR_print_errors_fp(stderr); } static int test_cert(struct test_cert *tc) @@ -986,24 +953,24 @@ static int test_param(struct test_param *t) printf(cBLUE "Test %s (cp):\n" cNORM, sn); switch (t->len) { - case 256 / 8: - type = NID_id_GostR3410_2012_256; - break; - case 512 / 8: - type = NID_id_GostR3410_2012_512; - break; - default: - OpenSSLDie(__FILE__, __LINE__, "invalid len"); + case 256 / 8: + type = NID_id_GostR3410_2012_256; + break; + case 512 / 8: + type = NID_id_GostR3410_2012_512; + break; + default: + OpenSSLDie(__FILE__, __LINE__, "invalid len"); } switch (type) { - case NID_id_GostR3410_2012_256: - hash_nid = NID_id_GostR3411_2012_256; - break; - case NID_id_GostR3410_2012_512: - hash_nid = NID_id_GostR3411_2012_512; - break; - default: - OpenSSLDie(__FILE__, __LINE__, "invalid type"); + case NID_id_GostR3410_2012_256: + hash_nid = NID_id_GostR3411_2012_256; + break; + case NID_id_GostR3410_2012_512: + hash_nid = NID_id_GostR3411_2012_512; + break; + default: + OpenSSLDie(__FILE__, __LINE__, "invalid type"); } /* Manually construct public key */ @@ -1053,35 +1020,35 @@ static int test_param(struct test_param *t) /* Verify using EVP_Verify API */ if (t->data) { - printf(" EVP_Verify API\t\t"); - EVP_MD_CTX *md_ctx; - T(md_ctx = EVP_MD_CTX_new()); - const EVP_MD *mdtype; - T(mdtype = EVP_get_digestbynid(hash_nid)); - T(EVP_VerifyInit(md_ctx, mdtype)); - /* Feed byte-by-byte. */ - int i; - for (i = 0; i < t->data_len; i++) - T(EVP_VerifyUpdate(md_ctx, &t->data[i], 1)); - err = EVP_VerifyFinal(md_ctx, sig, siglen, pkey); - print_test_result(err); - EVP_MD_CTX_free(md_ctx); - ret |= err != 1; + printf(" EVP_Verify API\t\t"); + EVP_MD_CTX *md_ctx; + T(md_ctx = EVP_MD_CTX_new()); + const EVP_MD *mdtype; + T(mdtype = EVP_get_digestbynid(hash_nid)); + T(EVP_VerifyInit(md_ctx, mdtype)); + /* Feed byte-by-byte. */ + unsigned int i; + for (i = 0; i < t->data_len; i++) + T(EVP_VerifyUpdate(md_ctx, &t->data[i], 1)); + err = EVP_VerifyFinal(md_ctx, sig, siglen, pkey); + print_test_result(err); + EVP_MD_CTX_free(md_ctx); + ret |= err != 1; } /* Verify using EVP_DigestVerifyInit API */ if (t->data) { - printf(" EVP_DigestVerifyInit API\t"); - EVP_MD_CTX *md_ctx; - T(md_ctx = EVP_MD_CTX_new()); - const EVP_MD *mdtype; - T(mdtype = EVP_get_digestbynid(hash_nid)); - T(EVP_DigestVerifyInit(md_ctx, NULL, mdtype, NULL, pkey)); - /* Verify in one step. */ - err = EVP_DigestVerify(md_ctx, sig, siglen, t->data, t->data_len); - print_test_result(err); - EVP_MD_CTX_free(md_ctx); - ret |= err != 1; + printf(" EVP_DigestVerifyInit API\t"); + EVP_MD_CTX *md_ctx; + T(md_ctx = EVP_MD_CTX_new()); + const EVP_MD *mdtype; + T(mdtype = EVP_get_digestbynid(hash_nid)); + T(EVP_DigestVerifyInit(md_ctx, NULL, mdtype, NULL, pkey)); + /* Verify in one step. */ + err = EVP_DigestVerify(md_ctx, sig, siglen, t->data, t->data_len); + print_test_result(err); + EVP_MD_CTX_free(md_ctx); + ret |= err != 1; } OPENSSL_free(sig); @@ -1092,7 +1059,7 @@ static int test_param(struct test_param *t) int main(int argc, char **argv) { int ret = 0; - + setupConsole(); setenv("OPENSSL_ENGINES", ENGINE_DIR, 0); OPENSSL_add_all_algorithms_conf(); ERR_load_crypto_strings(); @@ -1103,14 +1070,14 @@ int main(int argc, char **argv) struct test_param **tpp; for (tpp = test_params; *tpp; tpp++) - ret |= test_param(*tpp); + ret |= test_param(*tpp); struct test_cert *tc; for (tc = test_certs; tc->cert; tc++) - ret |= test_cert(tc); + ret |= test_cert(tc); ENGINE_finish(eng); ENGINE_free(eng); - + restoreConsole(); return ret; } diff --git a/test_sign.c b/test_sign.c index 1d0058164..35762903a 100644 --- a/test_sign.c +++ b/test_sign.c @@ -9,6 +9,8 @@ #include "e_gost_err.h" #include "gost_lcl.h" +#include "test.h" +#include "ansi_terminal.h" #include #include #include @@ -19,33 +21,10 @@ #include #include -#define T(e) ({ if (!(e)) { \ - ERR_print_errors_fp(stderr); \ - OpenSSLDie(__FILE__, __LINE__, #e); \ - } \ - }) -#define TE(e) ({ if (!(e)) { \ - ERR_print_errors_fp(stderr); \ - fprintf(stderr, "Error at %s:%d %s\n", __FILE__, __LINE__, #e); \ - return -1; \ - } \ - }) - -#define cRED "\033[1;31m" -#define cDRED "\033[0;31m" -#define cGREEN "\033[1;32m" -#define cDGREEN "\033[0;32m" -#define cBLUE "\033[1;34m" -#define cDBLUE "\033[0;34m" -#define cNORM "\033[m" -#define TEST_ASSERT(e) {if ((test = (e))) \ - printf(cRED " Test FAILED\n" cNORM); \ - else \ - printf(cGREEN " Test passed\n" cNORM);} struct test_sign { const char *name; - unsigned int nid; + int nid; size_t bits; const char *paramset; }; @@ -62,38 +41,26 @@ static struct test_sign test_signs[] = { D(NID_id_tc26_gost_3410_2012_512_paramSetA, 512, "A"), D(NID_id_tc26_gost_3410_2012_512_paramSetB, 512, "B"), D(NID_id_tc26_gost_3410_2012_512_paramSetC, 512, "C"), - 0 + {0} }; #undef D -static void hexdump(const void *ptr, size_t len) -{ - const unsigned char *p = ptr; - size_t i, j; - - for (i = 0; i < len; i += j) { - for (j = 0; j < 16 && i + j < len; j++) - printf("%s %02x", j? "" : "\n", p[i + j]); - } - printf("\n"); -} - static void print_test_tf(int err, int val, const char *t, const char *f) { if (err == 1) - printf(cGREEN "%s\n" cNORM, t); + printf(cGREEN "%s\n" cNORM, t); else - printf(cRED "%s [%d]\n" cNORM, f, val); + printf(cRED "%s [%d]\n" cNORM, f, val); } static void print_test_result(int err) { if (err == 1) - printf(cGREEN "success\n" cNORM); + printf(cGREEN "success\n" cNORM); else if (err == 0) - printf(cRED "failure\n" cNORM); + printf(cRED "failure\n" cNORM); else - ERR_print_errors_fp(stderr); + ERR_print_errors_fp(stderr); } static int test_sign(struct test_sign *t) @@ -107,13 +74,13 @@ static int test_sign(struct test_sign *t) int type = 0; const char *algname = NULL; switch (t->bits) { - case 256: - type = NID_id_GostR3410_2012_256; - algname = "gost2012_256"; - break; - case 512: - type = NID_id_GostR3410_2012_512; - algname = "gost2012_512"; + case 256: + type = NID_id_GostR3410_2012_256; + algname = "gost2012_256"; + break; + case 512: + type = NID_id_GostR3410_2012_512; + algname = "gost2012_512"; } /* Keygen. */ @@ -131,7 +98,7 @@ static int test_sign(struct test_sign *t) EVP_PKEY_CTX_free(ctx); EVP_PKEY_free(pkey); if (err != 1) - return -1; + return -1; /* Create another key using string interface. */ EVP_PKEY *key1; @@ -235,7 +202,7 @@ static int test_sign(struct test_sign *t) int main(int argc, char **argv) { int ret = 0; - + setupConsole(); setenv("OPENSSL_ENGINES", ENGINE_DIR, 0); OPENSSL_add_all_algorithms_conf(); ERR_load_crypto_strings(); @@ -246,14 +213,15 @@ int main(int argc, char **argv) struct test_sign *sp; for (sp = test_signs; sp->name; sp++) - ret |= test_sign(sp); + ret |= test_sign(sp); ENGINE_finish(eng); ENGINE_free(eng); if (ret) - printf(cDRED "= Some tests FAILED!\n" cNORM); + printf(cDRED "= Some tests FAILED!\n" cNORM); else - printf(cDGREEN "= All tests passed!\n" cNORM); + printf(cDGREEN "= All tests passed!\n" cNORM); + restoreConsole(); return ret; } diff --git a/test_tls.c b/test_tls.c index d13760216..7a137302c 100644 --- a/test_tls.c +++ b/test_tls.c @@ -10,6 +10,8 @@ #include "e_gost_err.h" #include "gost_lcl.h" +#include "test.h" +#include "ansi_terminal.h" #include #include #include @@ -22,41 +24,15 @@ #include #include #include -#include #include #include #include #include -#include #include /* For X509_NAME_add_entry_by_txt */ #pragma GCC diagnostic ignored "-Wpointer-sign" -#define T(e) ({ if (!(e)) { \ - ERR_print_errors_fp(stderr); \ - OpenSSLDie(__FILE__, __LINE__, #e); \ - } \ - }) -#define TE(e) ({ if (!(e)) { \ - ERR_print_errors_fp(stderr); \ - fprintf(stderr, "Error at %s:%d %s\n", __FILE__, __LINE__, #e); \ - return -1; \ - } \ - }) - -#define cRED "\033[1;31m" -#define cDRED "\033[0;31m" -#define cGREEN "\033[1;32m" -#define cDGREEN "\033[0;32m" -#define cBLUE "\033[1;34m" -#define cDBLUE "\033[0;34m" -#define cNORM "\033[m" -#define TEST_ASSERT(e) {if ((test = (e))) \ - printf(cRED " Test FAILED\n" cNORM); \ - else \ - printf(cGREEN " Test passed\n" cNORM);} - struct certkey { EVP_PKEY *pkey; X509 *cert; @@ -86,17 +62,16 @@ static int s_server(EVP_PKEY *pkey, X509 *cert, int client) char buf[1024]; int i; for (i = 0; i < KTRANSFER; i++) { - int k; + int k; - T(SSL_read(ssl, buf, sizeof(buf)) == sizeof(buf)); - for (k = 0; k < sizeof(buf); k++) - if (buf[k] != 'c') - err(1, "corruption from client"); + T(SSL_read(ssl, buf, sizeof(buf)) == sizeof(buf)); + for (k = 0; k < sizeof(buf); k++) + if (buf[k] != 'c') err(1, "corruption from client"); } /* Send data to client. */ memset(buf, 's', sizeof(buf)); for (i = 0; i < KTRANSFER; i++) { - T(SSL_write(ssl, buf, sizeof(buf)) == sizeof(buf)); + T(SSL_write(ssl, buf, sizeof(buf)) == sizeof(buf)); } SSL_shutdown(ssl); SSL_free(ssl); @@ -140,37 +115,36 @@ static int s_client(int server) int verify = SSL_get_verify_result(ssl); printf("Verify: %s\n", X509_verify_cert_error_string(verify)); if (verify != X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) - err(1, "invalid SSL_get_verify_result"); + err(1, "invalid SSL_get_verify_result"); /* Send data to server. */ char buf[1024]; int i; memset(buf, 'c', sizeof(buf)); for (i = 0; i < KTRANSFER; i++) { - T(BIO_write(sbio, buf, sizeof(buf)) == sizeof(buf)); + T(BIO_write(sbio, buf, sizeof(buf)) == sizeof(buf)); } (void)BIO_shutdown_wr(sbio); /* Receive data from server. */ for (i = 0; i < KTRANSFER; i++) { - int k; - int n = BIO_read(sbio, buf, sizeof(buf)); - - if (n != sizeof(buf)) { - printf("i:%d BIO_read:%d SSL_get_error:%d\n", i, n, - SSL_get_error(ssl, n)); - ERR_print_errors_fp(stderr); - err(1, "BIO_read"); - } - - for (k = 0; k < sizeof(buf); k++) - if (buf[k] != 's') - err(1, "corruption from server"); + int k; + int n = BIO_read(sbio, buf, sizeof(buf)); + + if (n != sizeof(buf)) { + printf("i:%d BIO_read:%d SSL_get_error:%d\n", i, n, + SSL_get_error(ssl, n)); + ERR_print_errors_fp(stderr); + err(1, "BIO_read"); + } + + for (k = 0; k < sizeof(buf); k++) + if (buf[k] != 's') err(1, "corruption from server"); } i = BIO_get_num_renegotiates(sbio); if (i) - printf("Renegs: %d\n", i); + printf("Renegs: %d\n", i); BIO_free_all(sbio); SSL_CTX_free(ctx); @@ -188,7 +162,7 @@ static struct certkey certgen(const char *algname, const char *paramset) T(ctx = EVP_PKEY_CTX_new(tkey, NULL)); T(EVP_PKEY_keygen_init(ctx)); if (paramset) - T(EVP_PKEY_CTX_ctrl_str(ctx, "paramset", paramset)); + T(EVP_PKEY_CTX_ctrl_str(ctx, "paramset", paramset)); EVP_PKEY *pkey = NULL; T((EVP_PKEY_keygen(ctx, &pkey)) == 1); EVP_PKEY_CTX_free(ctx); @@ -259,7 +233,7 @@ int test(const char *algname, const char *paramset) printf(cBLUE "Test %s", algname); if (paramset) - printf(cBLUE ":%s", paramset); + printf(cBLUE ":%s", paramset); printf(cNORM "\n"); struct certkey ck; @@ -267,25 +241,25 @@ int test(const char *algname, const char *paramset) int sockfd[2]; if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sockfd) == -1) - err(1, "socketpair"); + err(1, "socketpair"); pid_t pid = fork(); if (pid < 0) - err(1, "fork"); + err(1, "fork"); if (pid > 0) { - int status; + int status; - ret = s_client(sockfd[0]); - wait(&status); - ret |= WIFEXITED(status) && WEXITSTATUS(status); - X509_free(ck.cert); - EVP_PKEY_free(ck.pkey); + ret = s_client(sockfd[0]); + wait(&status); + ret |= WIFEXITED(status) && WEXITSTATUS(status); + X509_free(ck.cert); + EVP_PKEY_free(ck.pkey); } else if (pid == 0) { - ret = s_server(ck.pkey, ck.cert, sockfd[1]); - X509_free(ck.cert); - EVP_PKEY_free(ck.pkey); - exit(ret); + ret = s_server(ck.pkey, ck.cert, sockfd[1]); + X509_free(ck.cert); + EVP_PKEY_free(ck.pkey); + exit(ret); } return ret; @@ -316,8 +290,8 @@ int main(int argc, char **argv) ENGINE_free(eng); if (ret) - printf(cDRED "= Some tests FAILED!\n" cNORM); + printf(cDRED "= Some tests FAILED!\n" cNORM); else - printf(cDGREEN "= All tests passed!\n" cNORM); + printf(cDGREEN "= All tests passed!\n" cNORM); return ret; } diff --git a/test_tlstree.c b/test_tlstree.c index df2574298..ae955c2f3 100644 --- a/test_tlstree.c +++ b/test_tlstree.c @@ -3,179 +3,167 @@ # include # include -static void hexdump(FILE *f, const char *title, const unsigned char *s, int l) -{ - int n = 0; - - fprintf(f, "%s", title); - for (; n < l; ++n) { - if ((n % 16) == 0) - fprintf(f, "\n%04x", n); - fprintf(f, " %02x", s[n]); - } - fprintf(f, "\n"); -} int main(void) { #ifdef EVP_MD_CTRL_TLSTREE - const unsigned char mac_secret[] = { -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, -0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - }; - - const unsigned char enc_key[] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - - const unsigned char full_iv[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - - - unsigned char seq0[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - - const unsigned char rec0_header[] = { -0x17, 0x03, 0x03, 0x00, 0x0F - }; - - const unsigned char data0[15] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - const unsigned char mac0_etl[16] = { -0x75, 0x53, 0x09, 0xCB, 0xC7, 0x3B, 0xB9, 0x49, 0xC5, 0x0E, 0xBB, 0x86, 0x16, 0x0A, 0x0F, 0xEE - }; - - const unsigned char enc0_etl[31] = { -0xf3, 0x17, 0xa7, 0x1d, 0x3a, 0xce, 0x43, 0x3b, 0x01, 0xd4, 0xe7, 0xd4, 0xef, 0x61, 0xae, 0x00, -0xd5, 0x3b, 0x41, 0x52, 0x7a, 0x26, 0x1e, 0xdf, 0xc2, 0xba, 0x78, 0x57, 0xc1, 0x93, 0x2d - }; - - unsigned char data0_processed[31]; - unsigned char mac0[16]; - - unsigned char seq63[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, - }; - - const unsigned char rec63_header[] = { -0x17, 0x03, 0x03, 0x10, 0x00 - }; - - unsigned char data63[4096]; - - const unsigned char mac63_etl[16] = { -0x0A, 0x3B, 0xFD, 0x43, 0x0F, 0xCD, 0xD8, 0xD8, 0x5C, 0x96, 0x46, 0x86, 0x81, 0x78, 0x4F, 0x7D - }; - - const unsigned char enc63_etl_head[32] = { -0x6A, 0x18, 0x38, 0xB0, 0xA0, 0xD5, 0xA0, 0x4D, 0x1F, 0x29, 0x64, 0x89, 0x6D, 0x08, 0x5F, 0xB7, -0xDA, 0x84, 0xD7, 0x76, 0xC3, 0x9F, 0x5C, 0xDC, 0x37, 0x20, 0xB7, 0xB5, 0x59, 0xEF, 0x13, 0x9D - }; - const unsigned char enc63_etl_tail[48] = { -0x0A, 0x81, 0x29, 0x9B, 0x35, 0x98, 0x19, 0x5D, 0xD4, 0x51, 0x68, 0xA6, 0x38, 0x50, 0xA7, 0x6E, -0x1A, 0x4F, 0x1E, 0x6D, 0xD5, 0xEF, 0x72, 0x59, 0x3F, 0xAE, 0x76, 0x55, 0x71, 0xEC, 0x37, 0xE7, -0x17, 0xF5, 0xB8, 0x62, 0x85, 0xBB, 0x5B, 0xFD, 0x83, 0xB6, 0x6A, 0xB7, 0x63, 0x86, 0x52, 0x08 - }; - - unsigned char data63_processed[4096+16]; - unsigned char mac63[16]; - - EVP_MD_CTX *mdctx = EVP_MD_CTX_new(); - EVP_CIPHER_CTX *enc = NULL; - const EVP_MD *md; - const EVP_CIPHER *ciph; - EVP_PKEY *mac_key; - size_t mac_len; - int i; - - OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL); - - memset(data63, 0, 4096); - - md = EVP_get_digestbynid(NID_grasshopper_mac); - - EVP_DigestInit_ex(mdctx, md, NULL); - mac_key = EVP_PKEY_new_mac_key(NID_grasshopper_mac, NULL, mac_secret, 32); - EVP_DigestSignInit(mdctx, NULL, md, NULL, mac_key); - EVP_PKEY_free(mac_key); - - EVP_MD_CTX_ctrl(mdctx, EVP_MD_CTRL_TLSTREE, 0, seq0); - EVP_DigestSignUpdate(mdctx, seq0, 8); - EVP_DigestSignUpdate(mdctx, rec0_header, 5); - EVP_DigestSignUpdate(mdctx, data0, 15); - EVP_DigestSignFinal(mdctx, mac0, &mac_len); - - EVP_MD_CTX_free(mdctx); - hexdump(stderr, "MAC0 result", mac0, mac_len); - if (memcmp(mac0, mac0_etl, 16) != 0) { - fprintf(stderr, "MAC0 mismatch"); - exit(1); - } - - ciph = EVP_get_cipherbynid(NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm); - enc = EVP_CIPHER_CTX_new(); - EVP_EncryptInit_ex(enc, ciph, NULL, enc_key, full_iv); - - for (i = 7; i >= 0; i--) { - ++seq0[i]; - if (seq0[i] != 0) - break; - } - EVP_CIPHER_CTX_ctrl(enc, EVP_CTRL_TLS1_2_TLSTREE, 0, seq0); - EVP_Cipher(enc, data0_processed, data0, sizeof(data0)); - EVP_Cipher(enc, data0_processed+sizeof(data0), mac0, 16); - - hexdump(stderr, "ENC0 result", data0_processed, 31); - if (memcmp(enc0_etl, data0_processed, sizeof(data0_processed)) != 0) { - fprintf(stderr, "ENC0 mismatch"); - exit(1); - } - - mdctx = EVP_MD_CTX_new(); - EVP_DigestInit_ex(mdctx, md, NULL); - mac_key = EVP_PKEY_new_mac_key(NID_grasshopper_mac, NULL, mac_secret, 32); - EVP_DigestSignInit(mdctx, NULL, md, NULL, mac_key); - EVP_PKEY_free(mac_key); - - EVP_MD_CTX_ctrl(mdctx, EVP_MD_CTRL_TLSTREE, 0, seq63); - EVP_DigestSignUpdate(mdctx, seq63, 8); - EVP_DigestSignUpdate(mdctx, rec63_header, 5); - EVP_DigestSignUpdate(mdctx, data63, 4096); - EVP_DigestSignFinal(mdctx, mac63, &mac_len); - - EVP_MD_CTX_free(mdctx); - hexdump(stderr, "MAC63 result", mac63, mac_len); - if (memcmp(mac63, mac63_etl, 16) != 0) { - fprintf(stderr, "MAC63 mismatch"); - exit(1); - } - - for (i = 7; i >= 0; i--) { - ++seq63[i]; - if (seq63[i] != 0) - break; - } - EVP_CIPHER_CTX_ctrl(enc, EVP_CTRL_TLS1_2_TLSTREE, 0, seq63); - EVP_Cipher(enc, data63_processed, data63, sizeof(data63)); - EVP_Cipher(enc, data63_processed+sizeof(data63), mac63, 16); - - hexdump(stderr, "ENC63 result: head", data63_processed, 32); - if (memcmp(enc63_etl_head, data63_processed, sizeof(enc63_etl_head)) != 0) { - fprintf(stderr, "ENC63 mismatch: head"); - exit(1); - } - hexdump(stderr, "ENC63 result: tail", data63_processed+4096+16-48, 48); - if (memcmp(enc63_etl_tail, data63_processed+4096+16-48, sizeof(enc63_etl_tail)) != 0) { - fprintf(stderr, "ENC63 mismatch: tail"); - exit(1); - } + const unsigned char mac_secret[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + }; + + const unsigned char enc_key[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + + const unsigned char full_iv[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + + + unsigned char seq0[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + + const unsigned char rec0_header[] = { + 0x17, 0x03, 0x03, 0x00, 0x0F + }; + + const unsigned char data0[15] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + const unsigned char mac0_etl[16] = { + 0x75, 0x53, 0x09, 0xCB, 0xC7, 0x3B, 0xB9, 0x49, 0xC5, 0x0E, 0xBB, 0x86, 0x16, 0x0A, 0x0F, 0xEE + }; + + const unsigned char enc0_etl[31] = { + 0xf3, 0x17, 0xa7, 0x1d, 0x3a, 0xce, 0x43, 0x3b, 0x01, 0xd4, 0xe7, 0xd4, 0xef, 0x61, 0xae, 0x00, + 0xd5, 0x3b, 0x41, 0x52, 0x7a, 0x26, 0x1e, 0xdf, 0xc2, 0xba, 0x78, 0x57, 0xc1, 0x93, 0x2d + }; + + unsigned char data0_processed[31]; + unsigned char mac0[16]; + + unsigned char seq63[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, + }; + + const unsigned char rec63_header[] = { + 0x17, 0x03, 0x03, 0x10, 0x00 + }; + + unsigned char data63[4096]; + + const unsigned char mac63_etl[16] = { + 0x0A, 0x3B, 0xFD, 0x43, 0x0F, 0xCD, 0xD8, 0xD8, 0x5C, 0x96, 0x46, 0x86, 0x81, 0x78, 0x4F, 0x7D + }; + + const unsigned char enc63_etl_head[32] = { + 0x6A, 0x18, 0x38, 0xB0, 0xA0, 0xD5, 0xA0, 0x4D, 0x1F, 0x29, 0x64, 0x89, 0x6D, 0x08, 0x5F, 0xB7, + 0xDA, 0x84, 0xD7, 0x76, 0xC3, 0x9F, 0x5C, 0xDC, 0x37, 0x20, 0xB7, 0xB5, 0x59, 0xEF, 0x13, 0x9D + }; + const unsigned char enc63_etl_tail[48] = { + 0x0A, 0x81, 0x29, 0x9B, 0x35, 0x98, 0x19, 0x5D, 0xD4, 0x51, 0x68, 0xA6, 0x38, 0x50, 0xA7, 0x6E, + 0x1A, 0x4F, 0x1E, 0x6D, 0xD5, 0xEF, 0x72, 0x59, 0x3F, 0xAE, 0x76, 0x55, 0x71, 0xEC, 0x37, 0xE7, + 0x17, 0xF5, 0xB8, 0x62, 0x85, 0xBB, 0x5B, 0xFD, 0x83, 0xB6, 0x6A, 0xB7, 0x63, 0x86, 0x52, 0x08 + }; + + unsigned char data63_processed[4096+16]; + unsigned char mac63[16]; + + EVP_MD_CTX *mdctx = EVP_MD_CTX_new(); + EVP_CIPHER_CTX *enc = NULL; + const EVP_MD *md; + const EVP_CIPHER *ciph; + EVP_PKEY *mac_key; + size_t mac_len; + int i; + + OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL); + + memset(data63, 0, 4096); + + md = EVP_get_digestbynid(NID_grasshopper_mac); + + EVP_DigestInit_ex(mdctx, md, NULL); + mac_key = EVP_PKEY_new_mac_key(NID_grasshopper_mac, NULL, mac_secret, 32); + EVP_DigestSignInit(mdctx, NULL, md, NULL, mac_key); + EVP_PKEY_free(mac_key); + + EVP_MD_CTX_ctrl(mdctx, EVP_MD_CTRL_TLSTREE, 0, seq0); + EVP_DigestSignUpdate(mdctx, seq0, 8); + EVP_DigestSignUpdate(mdctx, rec0_header, 5); + EVP_DigestSignUpdate(mdctx, data0, 15); + EVP_DigestSignFinal(mdctx, mac0, &mac_len); + + EVP_MD_CTX_free(mdctx); + hexdump(stderr, "MAC0 result", mac0, mac_len); + if (memcmp(mac0, mac0_etl, 16) != 0) { + fprintf(stderr, "MAC0 mismatch"); + exit(1); + } + + ciph = EVP_get_cipherbynid(NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm); + enc = EVP_CIPHER_CTX_new(); + EVP_EncryptInit_ex(enc, ciph, NULL, enc_key, full_iv); + + for (i = 7; i >= 0; i--) { + ++seq0[i]; + if (seq0[i] != 0) + break; + } + EVP_CIPHER_CTX_ctrl(enc, EVP_CTRL_TLS1_2_TLSTREE, 0, seq0); + EVP_Cipher(enc, data0_processed, data0, sizeof(data0)); + EVP_Cipher(enc, data0_processed+sizeof(data0), mac0, 16); + + hexdump(stderr, "ENC0 result", data0_processed, 31); + if (memcmp(enc0_etl, data0_processed, sizeof(data0_processed)) != 0) { + fprintf(stderr, "ENC0 mismatch"); + exit(1); + } + + mdctx = EVP_MD_CTX_new(); + EVP_DigestInit_ex(mdctx, md, NULL); + mac_key = EVP_PKEY_new_mac_key(NID_grasshopper_mac, NULL, mac_secret, 32); + EVP_DigestSignInit(mdctx, NULL, md, NULL, mac_key); + EVP_PKEY_free(mac_key); + + EVP_MD_CTX_ctrl(mdctx, EVP_MD_CTRL_TLSTREE, 0, seq63); + EVP_DigestSignUpdate(mdctx, seq63, 8); + EVP_DigestSignUpdate(mdctx, rec63_header, 5); + EVP_DigestSignUpdate(mdctx, data63, 4096); + EVP_DigestSignFinal(mdctx, mac63, &mac_len); + + EVP_MD_CTX_free(mdctx); + hexdump(stderr, "MAC63 result", mac63, mac_len); + if (memcmp(mac63, mac63_etl, 16) != 0) { + fprintf(stderr, "MAC63 mismatch"); + exit(1); + } + + for (i = 7; i >= 0; i--) { + ++seq63[i]; + if (seq63[i] != 0) + break; + } + EVP_CIPHER_CTX_ctrl(enc, EVP_CTRL_TLS1_2_TLSTREE, 0, seq63); + EVP_Cipher(enc, data63_processed, data63, sizeof(data63)); + EVP_Cipher(enc, data63_processed+sizeof(data63), mac63, 16); + + hexdump(stderr, "ENC63 result: head", data63_processed, 32); + if (memcmp(enc63_etl_head, data63_processed, sizeof(enc63_etl_head)) != 0) { + fprintf(stderr, "ENC63 mismatch: head"); + exit(1); + } + hexdump(stderr, "ENC63 result: tail", data63_processed+4096+16-48, 48); + if (memcmp(enc63_etl_tail, data63_processed+4096+16-48, sizeof(enc63_etl_tail)) != 0) { + fprintf(stderr, "ENC63 mismatch: tail"); + exit(1); + } #endif - return 0; + return 0; }