Create data structure for test cases.

This commit is contained in:
Douglas Stebila 2016-10-04 21:18:21 -04:00
parent be98d4b9de
commit e6688f0df0
2 changed files with 33 additions and 6 deletions

View File

@ -5,6 +5,18 @@
#include <oqs/rand.h>
#include <oqs/kex.h>
struct kex_testcase {
enum OQS_KEX_alg_name alg_name;
unsigned char *seed;
size_t seed_len;
char *named_parameters;
};
/* Add new testcases here */
struct kex_testcase kex_testcases[] = {
{ OQS_KEX_alg_rlwe_bcns15, NULL, 0, NULL },
};
#define KEX_TEST_ITERATIONS 500
#define PRINT_HEX_STRING(label, str, len) { \
@ -172,9 +184,12 @@ int main() {
goto err;
}
success = kex_test_correctness_wrapper(rand, OQS_KEX_alg_rlwe_bcns15, NULL, 0, NULL, KEX_TEST_ITERATIONS);
if (success != 1) {
goto err;
size_t kex_testcases_len = sizeof(kex_testcases) / sizeof(struct kex_testcase);
for (size_t i = 0; i < kex_testcases_len; i++) {
success = kex_test_correctness_wrapper(rand, kex_testcases[i].alg_name, kex_testcases[i].seed, kex_testcases[i].seed_len, kex_testcases[i].named_parameters, KEX_TEST_ITERATIONS);
if (success != 1) {
goto err;
}
}
success = 1;

View File

@ -5,6 +5,15 @@
#include <oqs/rand.h>
struct rand_testcase {
enum OQS_RAND_alg_name alg_name;
};
/* Add new testcases here */
struct rand_testcase rand_testcases[] = {
{ OQS_RAND_alg_urandom_chacha20 },
};
#define RAND_TEST_ITERATIONS 10000000L
static void rand_test_distribution_8(OQS_RAND *rand, unsigned long occurrences[256], int iterations) {
@ -141,9 +150,12 @@ int main() {
int success;
success = rand_test_distribution_wrapper(OQS_RAND_alg_urandom_chacha20, RAND_TEST_ITERATIONS);
if (success != 1) {
goto err;
size_t rand_testcases_len = sizeof(rand_testcases) / sizeof(struct rand_testcase);
for (size_t i = 0; i < rand_testcases_len; i++) {
success = rand_test_distribution_wrapper(rand_testcases[i].alg_name, RAND_TEST_ITERATIONS);
if (success != 1) {
goto err;
}
}
success = 1;