*/
#include <openssl/opensslconf.h>
-#ifdef OPENSSL_NO_SRP
+# include "testutil.h"
+#ifdef OPENSSL_NO_SRP
# include <stdio.h>
-
-int main(int argc, char *argv[])
-{
- printf("No SRP support\n");
- return (0);
-}
-
#else
# include <openssl/srp.h>
# include <openssl/rand.h>
# include <openssl/err.h>
-# include "testutil.h"
static void showbn(const char *name, const BIGNUM *bn)
{
/* Server random */
RAND_bytes(rand_tmp, sizeof(rand_tmp));
b = BN_bin2bn(rand_tmp, sizeof(rand_tmp), NULL);
- if (!TEST_false(BN_is_zero(b)))
+ if (!TEST_BN_ne_zero(b))
goto end;
showbn("b", b);
/* Client random */
RAND_bytes(rand_tmp, sizeof(rand_tmp));
a = BN_bin2bn(rand_tmp, sizeof(rand_tmp), NULL);
- if (!TEST_false(BN_is_zero(a)))
+ if (!TEST_BN_ne_zero(a))
goto end;
showbn("a", a);
Kserver = SRP_Calc_server_key(Apub, v, u, b, GN->N);
showbn("Server's key", Kserver);
- if (!TEST_int_eq(BN_cmp(Kclient, Kserver), 0))
+ if (!TEST_BN_eq(Kclient, Kserver))
goto end;
ret = 1;
static int check_bn(const char *name, const BIGNUM *bn, const char *hexbn)
{
BIGNUM *tmp = NULL;
+ int r;
if (!TEST_true(BN_hex2bn(&tmp, hexbn)))
return 0;
- if (!TEST_int_eq(BN_cmp(bn, tmp), 0)) {
- TEST_info("Unexpected %s value", name);
- showbn("expecting", tmp);
- showbn("received", bn);
- BN_free(tmp);
- return 0;
- }
+ if (BN_cmp(bn, tmp) != 0)
+ TEST_error("unexpected %s value", name);
+ r = TEST_BN_eq(bn, tmp);
BN_free(tmp);
- return 1;
+ return r;
}
/* SRP test vectors from RFC5054 */
return 1;
}
+#endif
void register_tests(void)
{
+#ifdef OPENSSL_NO_SRP
+ printf("No SRP support\n");
+#else
ADD_TEST(run_srp_tests);
ADD_TEST(run_srp_kat);
-}
#endif
+}