summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_word.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/bn_word.c')
-rw-r--r--src/lib/libcrypto/bn/bn_word.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/bn_word.c b/src/lib/libcrypto/bn/bn_word.c
index c4c6754c37..71654586a1 100644
--- a/src/lib/libcrypto/bn/bn_word.c
+++ b/src/lib/libcrypto/bn/bn_word.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_word.c,v 1.12 2014/07/11 08:44:48 jsing Exp $ */ 1/* $OpenBSD: bn_word.c,v 1.13 2016/07/05 02:54:35 bcook Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -73,6 +73,20 @@ BN_mod_word(const BIGNUM *a, BN_ULONG w)
73 if (w == 0) 73 if (w == 0)
74 return (BN_ULONG) - 1; 74 return (BN_ULONG) - 1;
75 75
76#ifndef BN_ULLONG
77 /* If |w| is too long and we don't have |BN_ULLONG| then we need to fall back
78 * to using |BN_div_word|. */
79 if (w > ((BN_ULONG)1 << BN_BITS4)) {
80 BIGNUM *tmp = BN_dup(a);
81 if (tmp == NULL) {
82 return (BN_ULONG)-1;
83 }
84 ret = BN_div_word(tmp, w);
85 BN_free(tmp);
86 return ret;
87 }
88#endif
89
76 bn_check_top(a); 90 bn_check_top(a);
77 w &= BN_MASK2; 91 w &= BN_MASK2;
78 for (i = a->top - 1; i >= 0; i--) { 92 for (i = a->top - 1; i >= 0; i--) {