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