#include <stdlib.h>
#include <string.h>
-#include "openssl/e_os.h"
+#include "e_os.h"
#include <openssl/bio.h>
#include <openssl/bn.h>
#include <openssl/x509.h>
#include <openssl/err.h>
-#ifdef WINDOWS
+#ifdef OPENSSL_SYS_WINDOWS
#include "../bio/bss_file.c"
#endif
int rand_neg(void);
static int results=0;
-#ifdef NO_STDIO
+#ifdef OPENSSL_NO_STDIO
#define APPS_WIN16
#include "bss_file.c"
#endif
if (!BN_sub_word(t, 1)) goto err;
if (!BN_rshift1(t, t)) goto err;
/* r := a^t mod b */
- /* FIXME: Using BN_mod_exp (Montgomery variant) leads to
- * incorrect results if b is negative ("Legendre symbol
- * computation failed").
- * We want computations to be carried out modulo |b|. */
- if (!BN_mod_exp_simple(r, a, t, b, ctx)) goto err;
+ b->neg=0;
+
+ if (!BN_mod_exp_recp(r, a, t, b, ctx)) goto err; /* XXX should be BN_mod_exp_recp, but ..._recp triggers a bug that must be fixed */
+ b->neg=1;
if (BN_is_word(r, 1))
legendre = 1;
else
{
if (!BN_add_word(r, 1)) goto err;
- if (0 != BN_cmp(r, b))
+ if (0 != BN_ucmp(r, b))
{
fprintf(stderr, "Legendre symbol computation failed\n");
goto err;
}
BN_sub(c,a,b);
BN_sub(c,c,b);
- if(!BN_is_zero(c) && !BN_is_one(c))
+ if(!BN_is_zero(c) && !BN_abs_is_word(c, 1))
{
fprintf(stderr,"Right shift one test failed!\n");
return 0;