int i;
const BIGNUM *at, *bt;
+ bn_check_top(a);
+ bn_check_top(b);
+
if (a->top < b->top) { at = b; bt = a; }
else { at = a; bt = b; }
int j, k;
int n, dN, d0, d1;
BN_ULONG zz, *z;
-
+
+ bn_check_top(a);
+
if (!p[0])
/* reduction mod 1 => return 0 */
return BN_zero(r);
}
bn_correct_top(r);
-
return 1;
}
int ret = 0;
const int max = BN_num_bits(p);
unsigned int *arr=NULL;
+ bn_check_top(a);
+ bn_check_top(p);
if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;
ret = BN_GF2m_poly2arr(p, arr, max);
if (!ret || ret > max)
}
ret = BN_GF2m_mod_arr(r, a, arr);
bn_check_top(r);
- err:
+err:
if (arr) OPENSSL_free(arr);
return ret;
}
int zlen, i, j, k, ret = 0;
BIGNUM *s;
BN_ULONG x1, x0, y1, y0, zz[4];
-
+
+ bn_check_top(a);
+ bn_check_top(b);
+
if (a == b)
{
return BN_GF2m_mod_sqr_arr(r, a, p, ctx);
}
-
BN_CTX_start(ctx);
if ((s = BN_CTX_get(ctx)) == NULL) goto err;
ret = 1;
bn_check_top(r);
- err:
+err:
BN_CTX_end(ctx);
return ret;
-
}
/* Compute the product of two polynomials a and b, reduce modulo p, and store
int ret = 0;
const int max = BN_num_bits(p);
unsigned int *arr=NULL;
+ bn_check_top(a);
+ bn_check_top(b);
+ bn_check_top(p);
if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;
ret = BN_GF2m_poly2arr(p, arr, max);
if (!ret || ret > max)
}
ret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx);
bn_check_top(r);
- err:
+err:
if (arr) OPENSSL_free(arr);
return ret;
}
{
int i, ret = 0;
BIGNUM *s;
-
+
+ bn_check_top(a);
BN_CTX_start(ctx);
if ((s = BN_CTX_get(ctx)) == NULL) return 0;
if (!bn_wexpand(s, 2 * a->top)) goto err;
if (!BN_GF2m_mod_arr(r, s, p)) goto err;
bn_check_top(r);
ret = 1;
- err:
+err:
BN_CTX_end(ctx);
return ret;
}
int ret = 0;
const int max = BN_num_bits(p);
unsigned int *arr=NULL;
+
+ bn_check_top(a);
+ bn_check_top(p);
if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;
ret = BN_GF2m_poly2arr(p, arr, max);
if (!ret || ret > max)
}
ret = BN_GF2m_mod_sqr_arr(r, a, arr, ctx);
bn_check_top(r);
- err:
+err:
if (arr) OPENSSL_free(arr);
return ret;
}
BIGNUM *b, *c, *u, *v, *tmp;
int ret = 0;
+ bn_check_top(a);
+ bn_check_top(p);
+
BN_CTX_start(ctx);
b = BN_CTX_get(ctx);
bn_check_top(r);
ret = 1;
- err:
+err:
BN_CTX_end(ctx);
return ret;
}
BIGNUM *field;
int ret = 0;
+ bn_check_top(xx);
BN_CTX_start(ctx);
if ((field = BN_CTX_get(ctx)) == NULL) goto err;
if (!BN_GF2m_arr2poly(p, field)) goto err;
ret = BN_GF2m_mod_inv(r, xx, field, ctx);
bn_check_top(r);
- err:
+err:
BN_CTX_end(ctx);
return ret;
}
{
BIGNUM *xinv = NULL;
int ret = 0;
-
+
+ bn_check_top(y);
+ bn_check_top(x);
+ bn_check_top(p);
+
BN_CTX_start(ctx);
xinv = BN_CTX_get(ctx);
if (xinv == NULL) goto err;
bn_check_top(r);
ret = 1;
- err:
+err:
BN_CTX_end(ctx);
return ret;
}
BIGNUM *a, *b, *u, *v;
int ret = 0;
+ bn_check_top(y);
+ bn_check_top(x);
+ bn_check_top(p);
+
BN_CTX_start(ctx);
a = BN_CTX_get(ctx);
bn_check_top(r);
ret = 1;
- err:
+err:
BN_CTX_end(ctx);
return ret;
}
BIGNUM *field;
int ret = 0;
+ bn_check_top(yy);
+ bn_check_top(xx);
+
BN_CTX_start(ctx);
if ((field = BN_CTX_get(ctx)) == NULL) goto err;
if (!BN_GF2m_arr2poly(p, field)) goto err;
ret = BN_GF2m_mod_div(r, yy, xx, field, ctx);
bn_check_top(r);
- err:
+err:
BN_CTX_end(ctx);
return ret;
}
{
int ret = 0, i, n;
BIGNUM *u;
-
+
+ bn_check_top(a);
+ bn_check_top(b);
+
if (BN_is_zero(b))
return(BN_one(r));
if (BN_abs_is_word(b, 1))
return (BN_copy(r, a) != NULL);
-
BN_CTX_start(ctx);
if ((u = BN_CTX_get(ctx)) == NULL) goto err;
}
if (!BN_copy(r, u)) goto err;
bn_check_top(r);
-
ret = 1;
-
- err:
+err:
BN_CTX_end(ctx);
return ret;
}
int ret = 0;
const int max = BN_num_bits(p);
unsigned int *arr=NULL;
+ bn_check_top(a);
+ bn_check_top(b);
+ bn_check_top(p);
if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;
ret = BN_GF2m_poly2arr(p, arr, max);
if (!ret || ret > max)
}
ret = BN_GF2m_mod_exp_arr(r, a, b, arr, ctx);
bn_check_top(r);
- err:
+err:
if (arr) OPENSSL_free(arr);
return ret;
}
int ret = 0;
BIGNUM *u;
+ bn_check_top(a);
+
if (!p[0])
/* reduction mod 1 => return 0 */
return BN_zero(r);
-
+
BN_CTX_start(ctx);
if ((u = BN_CTX_get(ctx)) == NULL) goto err;
ret = BN_GF2m_mod_exp_arr(r, a, u, p, ctx);
bn_check_top(r);
- err:
+err:
BN_CTX_end(ctx);
return ret;
}
int ret = 0;
const int max = BN_num_bits(p);
unsigned int *arr=NULL;
+ bn_check_top(a);
+ bn_check_top(p);
if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) * max)) == NULL) goto err;
ret = BN_GF2m_poly2arr(p, arr, max);
if (!ret || ret > max)
}
ret = BN_GF2m_mod_sqrt_arr(r, a, arr, ctx);
bn_check_top(r);
- err:
+err:
if (arr) OPENSSL_free(arr);
return ret;
}
unsigned int j;
BIGNUM *a, *z, *rho, *w, *w2, *tmp;
+ bn_check_top(a_);
+
if (!p[0])
/* reduction mod 1 => return 0 */
return BN_zero(r);
ret = 1;
- err:
+err:
BN_CTX_end(ctx);
return ret;
}
int ret = 0;
const int max = BN_num_bits(p);
unsigned int *arr=NULL;
+ bn_check_top(a);
+ bn_check_top(p);
if ((arr = (unsigned int *)OPENSSL_malloc(sizeof(unsigned int) *
max)) == NULL) goto err;
ret = BN_GF2m_poly2arr(p, arr, max);
}
ret = BN_GF2m_mod_solve_quad_arr(r, a, arr, ctx);
bn_check_top(r);
- err:
+err:
if (arr) OPENSSL_free(arr);
return ret;
}
{
int i;
+ bn_check_top(a);
BN_zero(a);
for (i = 0; p[i] != 0; i++)
{
}
BN_set_bit(a, 0);
bn_check_top(a);
-
+
return 1;
}