Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Smith <brian@briansmith.org>2016-02-04 10:12:08 +0300
committerDavid Benjamin <davidben@google.com>2016-02-06 02:12:11 +0300
commitf98be21fad56eb76799aa290944832c3ed79ffcf (patch)
treea51de4a41360489c49729af60fc15a8fb47bb73c
parenta37fc70175cfbe9866c98194a1059245fb5e8874 (diff)
Remove dead platform-specific code in |BN_div|.
It is always the case that |BN_ULLONG| is defined or we're building for 64-bit MSVC. Lots of code is trying to handle impossible cases where neither of those is true. Change-Id: Ie337adda1dfb453843c6e0999807dfa1afb1ed89 Reviewed-on: https://boringssl-review.googlesource.com/7043 Reviewed-by: David Benjamin <davidben@google.com>
-rw-r--r--crypto/bn/div.c24
-rw-r--r--crypto/bn/internal.h62
2 files changed, 5 insertions, 81 deletions
diff --git a/crypto/bn/div.c b/crypto/bn/div.c
index f9e144a3..8fbbb169 100644
--- a/crypto/bn/div.c
+++ b/crypto/bn/div.c
@@ -291,31 +291,15 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
#else /* !BN_ULLONG */
BN_ULONG t2l, t2h;
-#if defined(div_asm)
- q = div_asm(n0, n1, d0);
-#else
- q = bn_div_words(n0, n1, d0);
+#if !defined(_MSC_VER) || !defined(OPENSSL_X86_64)
+#error "Unreachable code. BN_ULLONG is defined everywhere except 64-bit MSVC."
#endif
-#ifndef REMAINDER_IS_ALREADY_CALCULATED
+ q = bn_div_words(n0, n1, d0);
+
rem = (n1 - q * d0) & BN_MASK2;
-#endif
-#if defined(BN_UMULT_LOHI)
BN_UMULT_LOHI(t2l, t2h, d1, q);
-#elif defined(BN_UMULT_HIGH)
- t2l = d1 * q;
- t2h = BN_UMULT_HIGH(d1, q);
-#else
- {
- BN_ULONG ql, qh;
- t2l = LBITS(d1);
- t2h = HBITS(d1);
- ql = LBITS(q);
- qh = HBITS(q);
- mul64(t2l, t2h, ql, qh); /* t2=(BN_ULLONG)d1*q; */
- }
-#endif
for (;;) {
if ((t2h < rem) || ((t2h == rem) && (t2l <= wnump[-2]))) {
diff --git a/crypto/bn/internal.h b/crypto/bn/internal.h
index 0246aa99..e2ccb942 100644
--- a/crypto/bn/internal.h
+++ b/crypto/bn/internal.h
@@ -225,69 +225,9 @@ int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, int cl, int dl);
int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
const BN_ULONG *np, const BN_ULONG *n0, int num);
-#if !defined(BN_ULLONG)
-
-#define LBITS(a) ((a) & BN_MASK2l)
-#define HBITS(a) (((a) >> BN_BITS4) & BN_MASK2l)
-#define L2HBITS(a) (((a) << BN_BITS4) & BN_MASK2)
-
-#define LLBITS(a) ((a) & BN_MASKl)
-#define LHBITS(a) (((a) >> BN_BITS2) & BN_MASKl)
-#define LL2HBITS(a) ((BN_ULLONG)((a) & BN_MASKl) << BN_BITS2)
-
-#define mul64(l, h, bl, bh) \
- { \
- BN_ULONG m, m1, lt, ht; \
- \
- lt = l; \
- ht = h; \
- m = (bh) * (lt); \
- lt = (bl) * (lt); \
- m1 = (bl) * (ht); \
- ht = (bh) * (ht); \
- m = (m + m1) & BN_MASK2; \
- if (m < m1) \
- ht += L2HBITS((BN_ULONG)1); \
- ht += HBITS(m); \
- m1 = L2HBITS(m); \
- lt = (lt + m1) & BN_MASK2; \
- if (lt < m1) \
- ht++; \
- (l) = lt; \
- (h) = ht; \
- }
-
-#endif /* !defined(BN_ULLONG) */
-
-#if defined(OPENSSL_X86_64)
-# if defined(_MSC_VER)
+#if defined(OPENSSL_X86_64) && defined(_MSC_VER)
# define BN_UMULT_HIGH(a, b) __umulh((a), (b))
# define BN_UMULT_LOHI(low, high, a, b) ((low) = _umul128((a), (b), &(high)))
-# elif !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
-# define BN_UMULT_HIGH(a,b) ({ \
- register BN_ULONG ret,discard; \
- __asm__ ("mulq %3" \
- : "=a"(discard),"=d"(ret) \
- : "a"(a), "g"(b) \
- : "cc"); \
- ret; })
-# define BN_UMULT_LOHI(low,high,a,b) \
- __asm__ ("mulq %3" \
- : "=a"(low),"=d"(high) \
- : "a"(a),"g"(b) \
- : "cc");
-# endif
-#endif
-
-#if defined(OPENSSL_AARCH64)
-# if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
-# define BN_UMULT_HIGH(a,b) ({ \
- register BN_ULONG ret; \
- __asm__ ("umulh %0,%1,%2" \
- : "=r"(ret) \
- : "r"(a), "r"(b)); \
- ret; })
-# endif
#endif