#include <openssl/err.h>
#include <openssl/rand.h>
#include "testutil.h"
-#include "test_main_custom.h"
/*
* In bn_lcl.h, bn_expand() is defined as a static ossl_inline function.
return st;
}
+static int test_3_is_prime()
+{
+ int ret = 0;
+ BIGNUM *r = BN_new();
+
+ /* For a long time, small primes were not considered prime when
+ * do_trial_division was set. */
+ if (r == NULL ||
+ !BN_set_word(r, 3) ||
+ BN_is_prime_fasttest_ex(r, 3 /* nchecks */, ctx,
+ 0 /* do_trial_division */, NULL) != 1 ||
+ BN_is_prime_fasttest_ex(r, 3 /* nchecks */, ctx,
+ 1 /* do_trial_division */, NULL) != 1) {
+ goto err;
+ }
+
+ ret = 1;
+
+err:
+ BN_free(r);
+ return ret;
+}
+
/* Delete leading and trailing spaces from a string */
static char *strip_spaces(char *p)
static int file_tests()
{
STANZA s;
- int linesread = 0, result = 0;
+ int linesread = 0, errcnt = 0;
/* Read test file. */
memset(&s, 0, sizeof(s));
if (s.numpairs == 0)
continue;
if (!file_test_run(&s)) {
- if (result == 0)
- fprintf(stderr, "Test at %d failed\n", s.start);
- goto err;
+ fprintf(stderr, "Test at %d failed\n", s.start);
+ errcnt++;
}
clearstanza(&s);
s.start = linesread;
}
- result = 1;
-err:
- return result;
+ return errcnt == 0;
}
int test_main(int argc, char *argv[])
ADD_TEST(test_gf2m_modsqrt);
ADD_TEST(test_gf2m_modsolvequad);
#endif
+ ADD_TEST(test_3_is_prime);
ADD_TEST(file_tests);
RAND_seed(rnd_seed, sizeof rnd_seed);