summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_gf2m.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/bn_gf2m.c')
-rw-r--r--src/lib/libcrypto/bn/bn_gf2m.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/lib/libcrypto/bn/bn_gf2m.c b/src/lib/libcrypto/bn/bn_gf2m.c
index 68a5faa52d..a75c98ac0e 100644
--- a/src/lib/libcrypto/bn/bn_gf2m.c
+++ b/src/lib/libcrypto/bn/bn_gf2m.c
@@ -103,7 +103,7 @@ static const BN_ULONG SQR_tb[16] =
103 { 0, 1, 4, 5, 16, 17, 20, 21, 103 { 0, 1, 4, 5, 16, 17, 20, 21,
104 64, 65, 68, 69, 80, 81, 84, 85 }; 104 64, 65, 68, 69, 80, 81, 84, 85 };
105/* Platform-specific macros to accelerate squaring. */ 105/* Platform-specific macros to accelerate squaring. */
106#if defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG) 106#ifdef _LP64
107#define SQR1(w) \ 107#define SQR1(w) \
108 SQR_tb[(w) >> 60 & 0xF] << 56 | SQR_tb[(w) >> 56 & 0xF] << 48 | \ 108 SQR_tb[(w) >> 60 & 0xF] << 56 | SQR_tb[(w) >> 56 & 0xF] << 48 | \
109 SQR_tb[(w) >> 52 & 0xF] << 40 | SQR_tb[(w) >> 48 & 0xF] << 32 | \ 109 SQR_tb[(w) >> 52 & 0xF] << 40 | SQR_tb[(w) >> 48 & 0xF] << 32 | \
@@ -114,8 +114,7 @@ static const BN_ULONG SQR_tb[16] =
114 SQR_tb[(w) >> 20 & 0xF] << 40 | SQR_tb[(w) >> 16 & 0xF] << 32 | \ 114 SQR_tb[(w) >> 20 & 0xF] << 40 | SQR_tb[(w) >> 16 & 0xF] << 32 | \
115 SQR_tb[(w) >> 12 & 0xF] << 24 | SQR_tb[(w) >> 8 & 0xF] << 16 | \ 115 SQR_tb[(w) >> 12 & 0xF] << 24 | SQR_tb[(w) >> 8 & 0xF] << 16 | \
116 SQR_tb[(w) >> 4 & 0xF] << 8 | SQR_tb[(w) & 0xF] 116 SQR_tb[(w) >> 4 & 0xF] << 8 | SQR_tb[(w) & 0xF]
117#endif 117#else
118#ifdef THIRTY_TWO_BIT
119#define SQR1(w) \ 118#define SQR1(w) \
120 SQR_tb[(w) >> 28 & 0xF] << 24 | SQR_tb[(w) >> 24 & 0xF] << 16 | \ 119 SQR_tb[(w) >> 28 & 0xF] << 24 | SQR_tb[(w) >> 24 & 0xF] << 16 | \
121 SQR_tb[(w) >> 20 & 0xF] << 8 | SQR_tb[(w) >> 16 & 0xF] 120 SQR_tb[(w) >> 20 & 0xF] << 8 | SQR_tb[(w) >> 16 & 0xF]
@@ -130,9 +129,9 @@ static const BN_ULONG SQR_tb[16] =
130 * The caller MUST ensure that the variables have the right amount 129 * The caller MUST ensure that the variables have the right amount
131 * of space allocated. 130 * of space allocated.
132 */ 131 */
133#ifdef THIRTY_TWO_BIT
134static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const BN_ULONG b) 132static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const BN_ULONG b)
135 { 133 {
134#ifndef _LP64
136 register BN_ULONG h, l, s; 135 register BN_ULONG h, l, s;
137 BN_ULONG tab[8], top2b = a >> 30; 136 BN_ULONG tab[8], top2b = a >> 30;
138 register BN_ULONG a1, a2, a4; 137 register BN_ULONG a1, a2, a4;
@@ -160,11 +159,7 @@ static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const
160 if (top2b & 02) { l ^= b << 31; h ^= b >> 1; } 159 if (top2b & 02) { l ^= b << 31; h ^= b >> 1; }
161 160
162 *r1 = h; *r0 = l; 161 *r1 = h; *r0 = l;
163 } 162#else
164#endif
165#if defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)
166static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const BN_ULONG b)
167 {
168 register BN_ULONG h, l, s; 163 register BN_ULONG h, l, s;
169 BN_ULONG tab[16], top3b = a >> 61; 164 BN_ULONG tab[16], top3b = a >> 61;
170 register BN_ULONG a1, a2, a4, a8; 165 register BN_ULONG a1, a2, a4, a8;
@@ -200,8 +195,8 @@ static void bn_GF2m_mul_1x1(BN_ULONG *r1, BN_ULONG *r0, const BN_ULONG a, const
200 if (top3b & 04) { l ^= b << 63; h ^= b >> 1; } 195 if (top3b & 04) { l ^= b << 63; h ^= b >> 1; }
201 196
202 *r1 = h; *r0 = l; 197 *r1 = h; *r0 = l;
203 }
204#endif 198#endif
199 }
205 200
206/* Product of two polynomials a, b each with degree < 2 * BN_BITS2 - 1, 201/* Product of two polynomials a, b each with degree < 2 * BN_BITS2 - 1,
207 * result is a polynomial r with degree < 4 * BN_BITS2 - 1 202 * result is a polynomial r with degree < 4 * BN_BITS2 - 1