summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_shift.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/bn_shift.c')
-rw-r--r--src/lib/libcrypto/bn/bn_shift.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/lib/libcrypto/bn/bn_shift.c b/src/lib/libcrypto/bn/bn_shift.c
index de9312dce2..70f785ea18 100644
--- a/src/lib/libcrypto/bn/bn_shift.c
+++ b/src/lib/libcrypto/bn/bn_shift.c
@@ -65,9 +65,6 @@ int BN_lshift1(BIGNUM *r, const BIGNUM *a)
65 register BN_ULONG *ap,*rp,t,c; 65 register BN_ULONG *ap,*rp,t,c;
66 int i; 66 int i;
67 67
68 bn_check_top(r);
69 bn_check_top(a);
70
71 if (r != a) 68 if (r != a)
72 { 69 {
73 r->neg=a->neg; 70 r->neg=a->neg;
@@ -92,7 +89,6 @@ int BN_lshift1(BIGNUM *r, const BIGNUM *a)
92 *rp=1; 89 *rp=1;
93 r->top++; 90 r->top++;
94 } 91 }
95 bn_check_top(r);
96 return(1); 92 return(1);
97 } 93 }
98 94
@@ -101,9 +97,6 @@ int BN_rshift1(BIGNUM *r, const BIGNUM *a)
101 BN_ULONG *ap,*rp,t,c; 97 BN_ULONG *ap,*rp,t,c;
102 int i; 98 int i;
103 99
104 bn_check_top(r);
105 bn_check_top(a);
106
107 if (BN_is_zero(a)) 100 if (BN_is_zero(a))
108 { 101 {
109 BN_zero(r); 102 BN_zero(r);
@@ -124,8 +117,7 @@ int BN_rshift1(BIGNUM *r, const BIGNUM *a)
124 rp[i]=((t>>1)&BN_MASK2)|c; 117 rp[i]=((t>>1)&BN_MASK2)|c;
125 c=(t&1)?BN_TBIT:0; 118 c=(t&1)?BN_TBIT:0;
126 } 119 }
127 bn_correct_top(r); 120 bn_fix_top(r);
128 bn_check_top(r);
129 return(1); 121 return(1);
130 } 122 }
131 123
@@ -135,9 +127,6 @@ int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
135 BN_ULONG *t,*f; 127 BN_ULONG *t,*f;
136 BN_ULONG l; 128 BN_ULONG l;
137 129
138 bn_check_top(r);
139 bn_check_top(a);
140
141 r->neg=a->neg; 130 r->neg=a->neg;
142 nw=n/BN_BITS2; 131 nw=n/BN_BITS2;
143 if (bn_wexpand(r,a->top+nw+1) == NULL) return(0); 132 if (bn_wexpand(r,a->top+nw+1) == NULL) return(0);
@@ -160,8 +149,7 @@ int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
160/* for (i=0; i<nw; i++) 149/* for (i=0; i<nw; i++)
161 t[i]=0;*/ 150 t[i]=0;*/
162 r->top=a->top+nw+1; 151 r->top=a->top+nw+1;
163 bn_correct_top(r); 152 bn_fix_top(r);
164 bn_check_top(r);
165 return(1); 153 return(1);
166 } 154 }
167 155
@@ -171,9 +159,6 @@ int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
171 BN_ULONG *t,*f; 159 BN_ULONG *t,*f;
172 BN_ULONG l,tmp; 160 BN_ULONG l,tmp;
173 161
174 bn_check_top(r);
175 bn_check_top(a);
176
177 nw=n/BN_BITS2; 162 nw=n/BN_BITS2;
178 rb=n%BN_BITS2; 163 rb=n%BN_BITS2;
179 lb=BN_BITS2-rb; 164 lb=BN_BITS2-rb;
@@ -200,13 +185,13 @@ int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
200 185
201 if (rb == 0) 186 if (rb == 0)
202 { 187 {
203 for (i=j; i != 0; i--) 188 for (i=j+1; i > 0; i--)
204 *(t++)= *(f++); 189 *(t++)= *(f++);
205 } 190 }
206 else 191 else
207 { 192 {
208 l= *(f++); 193 l= *(f++);
209 for (i=j-1; i != 0; i--) 194 for (i=1; i<j; i++)
210 { 195 {
211 tmp =(l>>rb)&BN_MASK2; 196 tmp =(l>>rb)&BN_MASK2;
212 l= *(f++); 197 l= *(f++);
@@ -214,7 +199,7 @@ int BN_rshift(BIGNUM *r, const BIGNUM *a, int n)
214 } 199 }
215 *(t++) =(l>>rb)&BN_MASK2; 200 *(t++) =(l>>rb)&BN_MASK2;
216 } 201 }
217 bn_correct_top(r); 202 *t=0;
218 bn_check_top(r); 203 bn_fix_top(r);
219 return(1); 204 return(1);
220 } 205 }