}
#endif
-#ifdef BN_RECURSION
+#ifndef OPENSSL_SMALL_FOOTPRINT
/*
* Karatsuba recursive multiplication algorithm (cf. Knuth, The Art of
* Computer Programming, Vol. 2)
unsigned int neg, zero;
BN_ULONG ln, lo, *p;
-#ifndef OPENSSL_SMALL_FOOTPRINT
/*
* Only call bn_mul_comba 8 if n2 == 8 and the two arrays are complete
* [steve]
bn_mul_comba8(r, a, b);
return;
}
-#endif /* OPENSSL_SMALL_FOOTPRINT */
+
/* Else do normal multiply */
if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL) {
bn_mul_normal(r, a, n2 + dna, b, n2 + dnb);
break;
}
-#ifndef OPENSSL_SMALL_FOOTPRINT
if (n == 4 && dna == 0 && dnb == 0) { /* XXX: bn_mul_comba4 could take
* extra args to do this well */
if (!zero)
bn_mul_comba8(r, a, b);
bn_mul_comba8(&(r[n2]), &(a[n]), &(b[n]));
- } else
-#endif /* OPENSSL_SMALL_FOOTPRINT */
- {
+ } else {
p = &(t[n2 * 2]);
if (!zero)
bn_mul_recursive(&(t[n2]), t, &(t[n]), n, 0, 0, p);
bn_add_words(&(r[n]), &(r[n]), &(t[n]), n);
}
}
-#endif /* BN_RECURSION */
+#endif /* OPENSSL_SMALL_FOOTPRINT */
int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
{
int ret = 0;
int top, al, bl;
BIGNUM *rr;
-#if !defined(OPENSSL_SMALL_FOOTPRINT) || defined(BN_RECURSION)
+#if !defined(OPENSSL_SMALL_FOOTPRINT)
int i;
-#endif
-#ifdef BN_RECURSION
BIGNUM *t = NULL;
int j = 0, k;
#endif
} else
rr = r;
-#if !defined(OPENSSL_SMALL_FOOTPRINT) || defined(BN_RECURSION)
+#if !defined(OPENSSL_SMALL_FOOTPRINT)
i = al - bl;
-#endif
-#ifndef OPENSSL_SMALL_FOOTPRINT
+
if (i == 0) {
#if 0
if (al == 4) {
goto end;
}
}
-#endif /* OPENSSL_SMALL_FOOTPRINT */
-#ifdef BN_RECURSION
+
if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL)) {
if (i >= -1 && i <= 1) {
/*
goto end;
}
}
-#endif /* BN_RECURSION */
+#endif /* OPENSSL_SMALL_FOOTPRINT */
if (bn_wexpand(rr, top) == NULL)
goto err;
rr->top = top;
bn_mul_normal(rr->d, a->d, al, b->d, bl);
-#if !defined(OPENSSL_SMALL_FOOTPRINT) || defined(BN_RECURSION)
+#if !defined(OPENSSL_SMALL_FOOTPRINT)
end:
#endif
rr->neg = a->neg ^ b->neg;
bn_sqr_comba8(rr->d, a->d);
#endif
} else {
-#if defined(BN_RECURSION)
+#ifdef OPENSSL_SMALL_FOOTPRINT
+ if (bn_wexpand(tmp, max) == NULL)
+ goto err;
+ bn_sqr_normal(rr->d, a->d, al, tmp->d);
+#else
if (al < BN_SQR_RECURSIVE_SIZE_NORMAL) {
BN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL * 2];
bn_sqr_normal(rr->d, a->d, al, t);
bn_sqr_normal(rr->d, a->d, al, tmp->d);
}
}
-#else
- if (bn_wexpand(tmp, max) == NULL)
- goto err;
- bn_sqr_normal(rr->d, a->d, al, tmp->d);
#endif
}
bn_add_words(r, r, tmp, max);
}
-#ifdef BN_RECURSION
+#ifndef OPENSSL_SMALL_FOOTPRINT
/*-
* r is 2*n words in size,
* a and b are both n words in size. (There's not actually a 'b' here ...)
BN_ULONG ln, lo, *p;
if (n2 == 4) {
-#ifdef OPENSSL_SMALL_FOOTPRINT
- bn_sqr_normal(r, a, 4, t);
-#else
bn_sqr_comba4(r, a);
-#endif
return;
} else if (n2 == 8) {
-#ifdef OPENSSL_SMALL_FOOTPRINT
- bn_sqr_normal(r, a, 8, t);
-#else
bn_sqr_comba8(r, a);
-#endif
return;
}
if (n2 < BN_SQR_RECURSIVE_SIZE_NORMAL) {