diff options
author | Marek Majkowski <marek@popcount.org> | 2013-06-10 16:21:39 +0100 |
---|---|---|
committer | Marek Majkowski <marek@popcount.org> | 2013-06-10 16:21:39 +0100 |
commit | d769cd82b5b9517971bdefabfcc1c68b0a901751 (patch) | |
tree | f47cff5dff640df813f4d937a9bcf21282f2ee51 /src/test | |
parent | e4f51682bc6d15e5ba78dfe6dfe69e95c298954e (diff) | |
download | tor-d769cd82b5b9517971bdefabfcc1c68b0a901751.tar.gz tor-d769cd82b5b9517971bdefabfcc1c68b0a901751.zip |
Bug #5170 - make pkey_eq testable, introduce test_tortls.c
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/include.am | 1 | ||||
-rw-r--r-- | src/test/test.c | 2 | ||||
-rw-r--r-- | src/test/test_tortls.c | 45 |
3 files changed, 48 insertions, 0 deletions
diff --git a/src/test/include.am b/src/test/include.am index 112d1a79d8..af95d44470 100644 --- a/src/test/include.am +++ b/src/test/include.am @@ -23,6 +23,7 @@ src_test_test_SOURCES = \ src/test/test_microdesc.c \ src/test/test_pt.c \ src/test/test_replay.c \ + src/test/test_tortls.c \ src/test/test_util.c \ src/test/test_config.c \ src/ext/tinytest.c diff --git a/src/test/test.c b/src/test/test.c index a9cf899a0e..da5b4e5256 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -2133,6 +2133,7 @@ extern struct testcase_t config_tests[]; extern struct testcase_t introduce_tests[]; extern struct testcase_t replaycache_tests[]; extern struct testcase_t cell_format_tests[]; +extern struct testcase_t tortls_tests[]; static struct testgroup_t testgroups[] = { { "", test_array }, @@ -2147,6 +2148,7 @@ static struct testgroup_t testgroups[] = { { "pt/", pt_tests }, { "config/", config_tests }, { "replaycache/", replaycache_tests }, + { "tortls/", tortls_tests }, { "introduce/", introduce_tests }, END_OF_GROUPS }; diff --git a/src/test/test_tortls.c b/src/test/test_tortls.c new file mode 100644 index 0000000000..28ffbb1759 --- /dev/null +++ b/src/test/test_tortls.c @@ -0,0 +1,45 @@ +/* Copyright (c) 2013-2013, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +#include <openssl/evp.h> + +#include "orconfig.h" +#define CRYPTO_PRIVATE +#define TORTLS_PRIVATE +#include "or.h" +#include "test.h" + + +static void +test_tortls_evp_pkey_eq(void) +{ + crypto_pk_t *pk1 = NULL, *pk2 = NULL; + EVP_PKEY *evp1 = NULL, *evp2 = NULL; + + pk1 = pk_generate(0); + pk2 = pk_generate(1); + test_assert(pk1 && pk2); + + evp1 = crypto_pk_get_evp_pkey_(pk1, 0); + evp2 = crypto_pk_get_evp_pkey_(pk2, 0); + test_assert(evp1 && evp2); + + test_assert(tor_tls_evp_pkey_eq(evp1, evp2) == 0); + test_assert(tor_tls_evp_pkey_eq(evp1, evp1) == 1); + +done: + crypto_pk_free(pk1); + crypto_pk_free(pk2); + if (evp1) + EVP_PKEY_free(evp1); + if (evp2) + EVP_PKEY_free(evp2); +} + +#define TORTLS_LEGACY(name) \ + { #name, legacy_test_helper, 0, &legacy_setup, test_tortls_ ## name } + +struct testcase_t tortls_tests[] = { + TORTLS_LEGACY(evp_pkey_eq), + END_OF_TESTCASES +}; |