aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/dh_speed.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2015-04-07 18:11:41 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2016-11-14 16:20:51 +0100
commit2ac95123bb1f1602c59571326050d9d791c94658 (patch)
treec6140eba7906d70d59cb1385c52460939e7aea2e /scripts/dh_speed.c
parent0ab854789d26e7f3a1162ac78f7a3fa7cb9aa3a1 (diff)
downloadstrongswan-2ac95123bb1f1602c59571326050d9d791c94658.tar.bz2
strongswan-2ac95123bb1f1602c59571326050d9d791c94658.tar.xz
dh-speed: Compare the shared secrets for equality after test
Diffstat (limited to 'scripts/dh_speed.c')
-rw-r--r--scripts/dh_speed.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/scripts/dh_speed.c b/scripts/dh_speed.c
index 40b83168a..c2cac0260 100644
--- a/scripts/dh_speed.c
+++ b/scripts/dh_speed.c
@@ -66,7 +66,7 @@ static double end_timing(struct timespec *start)
static void run_test(diffie_hellman_group_t group, int rounds)
{
diffie_hellman_t *l[rounds], *r;
- chunk_t chunk, chunks[rounds];
+ chunk_t chunk, chunks[rounds], lsecrets[rounds], rsecrets[rounds];
struct timespec timing;
int round;
@@ -78,8 +78,7 @@ static void run_test(diffie_hellman_group_t group, int rounds)
return;
}
- printf("%N:\t",
- diffie_hellman_group_names, group);
+ printf("%N:\t", diffie_hellman_group_names, group);
start_timing(&timing);
for (round = 0; round < rounds; round++)
@@ -92,6 +91,7 @@ static void run_test(diffie_hellman_group_t group, int rounds)
for (round = 0; round < rounds; round++)
{
assert(r->set_other_public_value(r, chunks[round]));
+ assert(r->get_shared_secret(r, &rsecrets[round]));
chunk_free(&chunks[round]);
}
@@ -100,12 +100,16 @@ static void run_test(diffie_hellman_group_t group, int rounds)
for (round = 0; round < rounds; round++)
{
assert(l[round]->set_other_public_value(l[round], chunk));
+ assert(l[round]->get_shared_secret(l[round], &lsecrets[round]));
}
printf(" | S = B^a/s: %8.1f\n", rounds / end_timing(&timing));
chunk_free(&chunk);
for (round = 0; round < rounds; round++)
{
+ assert(chunk_equals(rsecrets[round], lsecrets[round]));
+ free(lsecrets[round].ptr);
+ free(rsecrets[round].ptr);
l[round]->destroy(l[round]);
}
r->destroy(r);