mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
parent
9a901aaa01
commit
b18f533cf0
3
changes/bug16794_ed
Normal file
3
changes/bug16794_ed
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
o Testing:
|
||||||
|
- Always test both ed25519 backends, so that we can be sure that
|
||||||
|
our batch-open replacement code works. Part of ticket 16794.
|
@ -96,6 +96,28 @@ get_ed_impl(void)
|
|||||||
return ed25519_impl;
|
return ed25519_impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TOR_UNIT_TESTS
|
||||||
|
static const ed25519_impl_t *saved_ed25519_impl = NULL;
|
||||||
|
void
|
||||||
|
crypto_ed25519_testing_force_impl(const char *name)
|
||||||
|
{
|
||||||
|
tor_assert(saved_ed25519_impl == NULL);
|
||||||
|
saved_ed25519_impl = ed25519_impl;
|
||||||
|
if (! strcmp(name, "donna")) {
|
||||||
|
ed25519_impl = &impl_donna;
|
||||||
|
} else {
|
||||||
|
tor_assert(!strcmp(name, "ref10"));
|
||||||
|
ed25519_impl = &impl_ref10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void
|
||||||
|
crypto_ed25519_testing_restore_impl(void)
|
||||||
|
{
|
||||||
|
ed25519_impl = saved_ed25519_impl;
|
||||||
|
saved_ed25519_impl = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize a new ed25519 secret key in <b>seckey_out</b>. If
|
* Initialize a new ed25519 secret key in <b>seckey_out</b>. If
|
||||||
* <b>extra_strong</b>, take the RNG inputs directly from the operating
|
* <b>extra_strong</b>, take the RNG inputs directly from the operating
|
||||||
|
@ -111,5 +111,10 @@ int ed25519_pubkey_eq(const ed25519_public_key_t *key1,
|
|||||||
void ed25519_set_impl_params(int use_donna);
|
void ed25519_set_impl_params(int use_donna);
|
||||||
void ed25519_init(void);
|
void ed25519_init(void);
|
||||||
|
|
||||||
|
#ifdef TOR_UNIT_TESTS
|
||||||
|
void crypto_ed25519_testing_force_impl(const char *name);
|
||||||
|
void crypto_ed25519_testing_restore_impl(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1688,6 +1688,25 @@ test_crypto_curve25519_persist(void *arg)
|
|||||||
tor_free(tag);
|
tor_free(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
ed25519_testcase_setup(const struct testcase_t *testcase)
|
||||||
|
{
|
||||||
|
crypto_ed25519_testing_force_impl(testcase->setup_data);
|
||||||
|
return testcase->setup_data;
|
||||||
|
}
|
||||||
|
static int
|
||||||
|
ed25519_testcase_cleanup(const struct testcase_t *testcase, void *ptr)
|
||||||
|
{
|
||||||
|
(void)testcase;
|
||||||
|
(void)ptr;
|
||||||
|
crypto_ed25519_testing_restore_impl();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
static const struct testcase_setup_t ed25519_test_setup = {
|
||||||
|
ed25519_testcase_setup, ed25519_testcase_cleanup
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_crypto_ed25519_simple(void *arg)
|
test_crypto_ed25519_simple(void *arg)
|
||||||
{
|
{
|
||||||
@ -2327,6 +2346,14 @@ test_crypto_failure_modes(void *arg)
|
|||||||
#define CRYPTO_LEGACY(name) \
|
#define CRYPTO_LEGACY(name) \
|
||||||
{ #name, test_crypto_ ## name , 0, NULL, NULL }
|
{ #name, test_crypto_ ## name , 0, NULL, NULL }
|
||||||
|
|
||||||
|
#define ED25519_TEST_ONE(name, fl, which) \
|
||||||
|
{ #name "/ed25519_" which, test_crypto_ed25519_ ## name, (fl), \
|
||||||
|
&ed25519_test_setup, (void*)which }
|
||||||
|
|
||||||
|
#define ED25519_TEST(name, fl) \
|
||||||
|
ED25519_TEST_ONE(name, (fl), "donna"), \
|
||||||
|
ED25519_TEST_ONE(name, (fl), "ref10")
|
||||||
|
|
||||||
struct testcase_t crypto_tests[] = {
|
struct testcase_t crypto_tests[] = {
|
||||||
CRYPTO_LEGACY(formats),
|
CRYPTO_LEGACY(formats),
|
||||||
CRYPTO_LEGACY(rng),
|
CRYPTO_LEGACY(rng),
|
||||||
@ -2355,14 +2382,13 @@ struct testcase_t crypto_tests[] = {
|
|||||||
{ "curve25519_wrappers", test_crypto_curve25519_wrappers, 0, NULL, NULL },
|
{ "curve25519_wrappers", test_crypto_curve25519_wrappers, 0, NULL, NULL },
|
||||||
{ "curve25519_encode", test_crypto_curve25519_encode, 0, NULL, NULL },
|
{ "curve25519_encode", test_crypto_curve25519_encode, 0, NULL, NULL },
|
||||||
{ "curve25519_persist", test_crypto_curve25519_persist, 0, NULL, NULL },
|
{ "curve25519_persist", test_crypto_curve25519_persist, 0, NULL, NULL },
|
||||||
{ "ed25519_simple", test_crypto_ed25519_simple, 0, NULL, NULL },
|
ED25519_TEST(simple, 0),
|
||||||
{ "ed25519_test_vectors", test_crypto_ed25519_test_vectors, 0, NULL, NULL },
|
ED25519_TEST(test_vectors, 0),
|
||||||
{ "ed25519_encode", test_crypto_ed25519_encode, 0, NULL, NULL },
|
ED25519_TEST(encode, 0),
|
||||||
{ "ed25519_convert", test_crypto_ed25519_convert, 0, NULL, NULL },
|
ED25519_TEST(convert, 0),
|
||||||
{ "ed25519_blinding", test_crypto_ed25519_blinding, 0, NULL, NULL },
|
ED25519_TEST(blinding, 0),
|
||||||
{ "ed25519_testvectors", test_crypto_ed25519_testvectors, 0, NULL, NULL },
|
ED25519_TEST(testvectors, 0),
|
||||||
{ "ed25519_fuzz_donna", test_crypto_ed25519_fuzz_donna, TT_FORK, NULL,
|
ED25519_TEST(fuzz_donna, TT_FORK),
|
||||||
NULL },
|
|
||||||
{ "siphash", test_crypto_siphash, 0, NULL, NULL },
|
{ "siphash", test_crypto_siphash, 0, NULL, NULL },
|
||||||
{ "failure_modes", test_crypto_failure_modes, TT_FORK, NULL, NULL },
|
{ "failure_modes", test_crypto_failure_modes, TT_FORK, NULL, NULL },
|
||||||
END_OF_TESTCASES
|
END_OF_TESTCASES
|
||||||
|
Loading…
Reference in New Issue
Block a user