The following programs had a hard coded load of the gost engine.
This changes them to rely more on the testing environment, and to
load engines through configuration files.
This affects: test_ciphers.c, test_context.c, test_derive.c,
test_digest.c, test_params.c, test_sign.c, test_tls.c
gost_eng.c
)
+set(TEST_ENVIRONMENT
+ CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
+ PERL5LIB=${CMAKE_CURRENT_SOURCE_DIR}/test
+ OPENSSL_ENGINES=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ OPENSSL_PROGRAM=${OPENSSL_PROGRAM}
+ OPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}
+ OPENSSL_CONF=${CMAKE_CURRENT_SOURCE_DIR}/test/engine.cnf
+ )
add_executable(test_digest test_digest.c)
-target_link_libraries(test_digest gost_core ${OPENSSL_CRYPTO_LIBRARY})
-add_test(NAME digest
- COMMAND test_digest)
+target_link_libraries(test_digest ${OPENSSL_CRYPTO_LIBRARY})
+add_test(NAME digest COMMAND test_digest)
+set_tests_properties(digest PROPERTIES ENVIRONMENT "${TEST_ENVIRONMENT}")
add_executable(test_ciphers test_ciphers.c)
-target_link_libraries(test_ciphers gost_core ${OPENSSL_CRYPTO_LIBRARY})
-add_test(NAME ciphers
- COMMAND test_ciphers)
+target_link_libraries(test_ciphers ${OPENSSL_CRYPTO_LIBRARY})
+add_test(NAME ciphers COMMAND test_ciphers)
+set_tests_properties(ciphers PROPERTIES ENVIRONMENT "${TEST_ENVIRONMENT}")
add_executable(test_curves test_curves.c)
target_link_libraries(test_curves gost_core ${OPENSSL_CRYPTO_LIBRARY})
COMMAND test_curves)
add_executable(test_params test_params.c)
-target_link_libraries(test_params gost_core ${OPENSSL_CRYPTO_LIBRARY})
-add_test(NAME parameters
- COMMAND test_params)
+target_link_libraries(test_params ${OPENSSL_CRYPTO_LIBRARY})
+add_test(NAME parameters COMMAND test_params)
+set_tests_properties(parameters PROPERTIES ENVIRONMENT "${TEST_ENVIRONMENT}")
add_executable(test_derive test_derive.c)
-target_link_libraries(test_derive gost_core ${OPENSSL_CRYPTO_LIBRARY})
-add_test(NAME derive
- COMMAND test_derive)
+target_link_libraries(test_derive ${OPENSSL_CRYPTO_LIBRARY})
+add_test(NAME derive COMMAND test_derive)
+set_tests_properties(derive PROPERTIES ENVIRONMENT "${TEST_ENVIRONMENT}")
add_executable(test_sign test_sign.c)
-target_link_libraries(test_sign gost_core ${OPENSSL_CRYPTO_LIBRARY})
-add_test(NAME sign/verify
- COMMAND test_sign)
+target_link_libraries(test_sign ${OPENSSL_CRYPTO_LIBRARY})
+add_test(NAME sign/verify COMMAND test_sign)
+set_tests_properties(sign/verify PROPERTIES ENVIRONMENT "${TEST_ENVIRONMENT}")
add_executable(test_tls test_tls.c)
-target_link_libraries(test_tls gost_core ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY})
-add_test(NAME TLS
- COMMAND test_tls)
+target_link_libraries(test_tls ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY})
+add_test(NAME TLS COMMAND test_tls)
+set_tests_properties(TLS PROPERTIES ENVIRONMENT "${TEST_ENVIRONMENT}")
add_executable(test_context test_context.c)
-target_link_libraries(test_context gost_core ${OPENSSL_CRYPTO_LIBRARY})
-add_test(NAME context
- COMMAND test_context)
+target_link_libraries(test_context ${OPENSSL_CRYPTO_LIBRARY})
+add_test(NAME context COMMAND test_context)
+set_tests_properties(context PROPERTIES ENVIRONMENT "${TEST_ENVIRONMENT}")
add_executable(test_keyexpimp test_keyexpimp.c)
#target_compile_definitions(test_keyexpimp PUBLIC -DOPENSSL_LOAD_CONF)
execute_process(COMMAND perl -MTest2::V0 -e ""
ERROR_QUIET RESULT_VARIABLE HAVE_TEST2_V0)
if(NOT HAVE_TEST2_V0)
- set(TEST_ENVIRONMENT
- CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
- PERL5LIB=${CMAKE_CURRENT_SOURCE_DIR}/test
- OPENSSL_ENGINES=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
- OPENSSL_PROGRAM=${OPENSSL_PROGRAM}
- OPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}
- OPENSSL_CONF=${CMAKE_CURRENT_SOURCE_DIR}/test/empty.cnf
- )
add_test(NAME engine
COMMAND prove --merge -PWrapOpenSSL ${CMAKE_CURRENT_SOURCE_DIR}/test)
set_tests_properties(engine PROPERTIES ENVIRONMENT "${TEST_ENVIRONMENT}")
--- /dev/null
+openssl_conf = openssl_def
+[openssl_def]
+engines = engines
+[engines]
+gost = gost_conf
+[gost_conf]
+default_algorithms = ALL
/* Trigger SIGBUS for unaligned access. */
sysmips(MIPS_FIXADE, 0);
#endif
- setenv("OPENSSL_ENGINES", ENGINE_DIR, 0);
OPENSSL_add_all_algorithms_conf();
- ERR_load_crypto_strings();
- ENGINE *eng;
- T(eng = ENGINE_by_id("gost"));
- T(ENGINE_init(eng));
- T(ENGINE_set_default(eng, ENGINE_METHOD_ALL));
for (t = testcases; t->nid; t++) {
int inplace;
t->iv, t->iv_size, t->acpkm);
}
+ ENGINE *eng;
ENGINE_CIPHERS_PTR fn_c;
+ T(eng = ENGINE_by_id("gost"));
T(fn_c = ENGINE_get_ciphers(eng));
const int *nids;
int n, k;
if (!t->nid)
printf(cMAGENT "Cipher %s is untested!" cNORM "\n", OBJ_nid2sn(nids[k]));
}
-
- ENGINE_finish(eng);
ENGINE_free(eng);
if (ret)
{
int ret = 0;
- setenv("OPENSSL_ENGINES", ENGINE_DIR, 0);
OPENSSL_add_all_algorithms_conf();
- ERR_load_crypto_strings();
- ENGINE *eng;
- T(eng = ENGINE_by_id("gost"));
- T(ENGINE_init(eng));
- T(ENGINE_set_default(eng, ENGINE_METHOD_ALL));
const struct testcase_cipher *tc;
for (tc = testcases_ciphers; tc->nid; tc++) {
ret |= test_contexts_digest(td->nid, td->mac);
}
- ENGINE_finish(eng);
- ENGINE_free(eng);
-
if (ret)
printf(cDRED "= Some tests FAILED!" cNORM "\n");
else
{
int ret = 0;
- setenv("OPENSSL_ENGINES", ENGINE_DIR, 0);
OPENSSL_add_all_algorithms_conf();
- ERR_load_crypto_strings();
- ENGINE *eng;
- T(eng = ENGINE_by_id("gost"));
- T(ENGINE_init(eng));
- T(ENGINE_set_default(eng, ENGINE_METHOD_ALL));
int i;
for (i = 0; i < OSSL_NELEM(derive_tests); i++)
ret |= test_derive_alg("gost2012_512", "C", i);
}
- ENGINE_finish(eng);
- ENGINE_free(eng);
-
if (ret)
printf(cDRED "= Some tests FAILED!" cNORM "\n");
else
/* Trigger SIGBUS for unaligned access. */
sysmips(MIPS_FIXADE, 0);
#endif
- setenv("OPENSSL_ENGINES", ENGINE_DIR, 0);
OPENSSL_add_all_algorithms_conf();
- ERR_load_crypto_strings();
- ENGINE *eng;
- T(eng = ENGINE_by_id("gost"));
- T(ENGINE_init(eng));
- T(ENGINE_set_default(eng, ENGINE_METHOD_ALL));
const struct hash_testvec *tv;
for (tv = testvecs; tv->nid; tv++) {
ret |= do_synthetic_test(tv);
}
+ ENGINE *eng;
ENGINE_DIGESTS_PTR fn_c;
+ T(eng = ENGINE_by_id("gost"));
T(fn_c = ENGINE_get_digests(eng));
const int *nids;
int n, k;
if (!tv->nid)
printf(cMAGENT "Digest %s is untested!" cNORM "\n", OBJ_nid2sn(nids[k]));
}
-
- ENGINE_finish(eng);
ENGINE_free(eng);
if (ret)
{
int ret = 0;
- setenv("OPENSSL_ENGINES", ENGINE_DIR, 0);
OPENSSL_add_all_algorithms_conf();
- ERR_load_crypto_strings();
- ENGINE *eng;
- T(eng = ENGINE_by_id("gost"));
- T(ENGINE_init(eng));
- T(ENGINE_set_default(eng, ENGINE_METHOD_ALL));
struct test_param **tpp;
for (tpp = test_params; *tpp; tpp++)
for (tc = test_certs; tc->cert; tc++)
ret |= test_cert(tc);
- ENGINE_finish(eng);
- ENGINE_free(eng);
-
if (ret)
printf(cDRED "= Some tests FAILED!" cNORM "\n");
else
* See https://www.openssl.org/source/license.html for details
*/
-#include "e_gost_err.h"
#include "gost_lcl.h"
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/ec.h>
#include <openssl/bn.h>
#include <openssl/store.h>
+#include <openssl/engine.h>
#include <string.h>
#include <stdlib.h>
{
int ret = 0;
- setenv("OPENSSL_ENGINES", ENGINE_DIR, 0);
OPENSSL_add_all_algorithms_conf();
- ERR_load_crypto_strings();
- ENGINE *eng;
- T(eng = ENGINE_by_id("gost"));
- T(ENGINE_init(eng));
- T(ENGINE_set_default(eng, ENGINE_METHOD_ALL));
struct test_sign *sp;
for (sp = test_signs; sp->name; sp++)
ret |= test_sign(sp);
- ENGINE_finish(eng);
- ENGINE_free(eng);
-
if (ret)
printf(cDRED "= Some tests FAILED!" cNORM "\n");
else
{
int ret = 0;
- setenv("OPENSSL_ENGINES", ENGINE_DIR, 0);
OPENSSL_add_all_algorithms_conf();
- ERR_load_crypto_strings();
- ENGINE *eng;
- T(eng = ENGINE_by_id("gost"));
- T(ENGINE_init(eng));
- T(ENGINE_set_default(eng, ENGINE_METHOD_ALL));
char *p;
if ((p = getenv("VERBOSE")))
ret |= test("gost2012_512", "B");
ret |= test("gost2012_512", "C");
- ENGINE_finish(eng);
- ENGINE_free(eng);
-
if (ret)
printf(cDRED "= Some tests FAILED!\n" cNORM);
else