diff options
Diffstat (limited to 'src/lib/libcrypto')
91 files changed, 1053 insertions, 637 deletions
diff --git a/src/lib/libcrypto/aes/aes_wrap.c b/src/lib/libcrypto/aes/aes_wrap.c index 9feacd65d8..e2d73d37ce 100644 --- a/src/lib/libcrypto/aes/aes_wrap.c +++ b/src/lib/libcrypto/aes/aes_wrap.c | |||
@@ -85,9 +85,9 @@ int AES_wrap_key(AES_KEY *key, const unsigned char *iv, | |||
85 | A[7] ^= (unsigned char)(t & 0xff); | 85 | A[7] ^= (unsigned char)(t & 0xff); |
86 | if (t > 0xff) | 86 | if (t > 0xff) |
87 | { | 87 | { |
88 | A[6] ^= (unsigned char)((t & 0xff) >> 8); | 88 | A[6] ^= (unsigned char)((t >> 8) & 0xff); |
89 | A[5] ^= (unsigned char)((t & 0xff) >> 16); | 89 | A[5] ^= (unsigned char)((t >> 16) & 0xff); |
90 | A[4] ^= (unsigned char)((t & 0xff) >> 24); | 90 | A[4] ^= (unsigned char)((t >> 24) & 0xff); |
91 | } | 91 | } |
92 | memcpy(R, B + 8, 8); | 92 | memcpy(R, B + 8, 8); |
93 | } | 93 | } |
@@ -119,9 +119,9 @@ int AES_unwrap_key(AES_KEY *key, const unsigned char *iv, | |||
119 | A[7] ^= (unsigned char)(t & 0xff); | 119 | A[7] ^= (unsigned char)(t & 0xff); |
120 | if (t > 0xff) | 120 | if (t > 0xff) |
121 | { | 121 | { |
122 | A[6] ^= (unsigned char)((t & 0xff) >> 8); | 122 | A[6] ^= (unsigned char)((t >> 8) & 0xff); |
123 | A[5] ^= (unsigned char)((t & 0xff) >> 16); | 123 | A[5] ^= (unsigned char)((t >> 16) & 0xff); |
124 | A[4] ^= (unsigned char)((t & 0xff) >> 24); | 124 | A[4] ^= (unsigned char)((t >> 24) & 0xff); |
125 | } | 125 | } |
126 | memcpy(B + 8, R, 8); | 126 | memcpy(B + 8, R, 8); |
127 | AES_decrypt(B, B, key); | 127 | AES_decrypt(B, B, key); |
diff --git a/src/lib/libcrypto/aes/asm/aes-armv4.pl b/src/lib/libcrypto/aes/asm/aes-armv4.pl index 690244111a..c51ee1fbf6 100644 --- a/src/lib/libcrypto/aes/asm/aes-armv4.pl +++ b/src/lib/libcrypto/aes/asm/aes-armv4.pl | |||
@@ -16,12 +16,20 @@ | |||
16 | # allows to merge logical or arithmetic operation with shift or rotate | 16 | # allows to merge logical or arithmetic operation with shift or rotate |
17 | # in one instruction and emit combined result every cycle. The module | 17 | # in one instruction and emit combined result every cycle. The module |
18 | # is endian-neutral. The performance is ~42 cycles/byte for 128-bit | 18 | # is endian-neutral. The performance is ~42 cycles/byte for 128-bit |
19 | # key. | 19 | # key [on single-issue Xscale PXA250 core]. |
20 | 20 | ||
21 | # May 2007. | 21 | # May 2007. |
22 | # | 22 | # |
23 | # AES_set_[en|de]crypt_key is added. | 23 | # AES_set_[en|de]crypt_key is added. |
24 | 24 | ||
25 | # July 2010. | ||
26 | # | ||
27 | # Rescheduling for dual-issue pipeline resulted in 12% improvement on | ||
28 | # Cortex A8 core and ~25 cycles per byte processed with 128-bit key. | ||
29 | |||
30 | while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {} | ||
31 | open STDOUT,">$output"; | ||
32 | |||
25 | $s0="r0"; | 33 | $s0="r0"; |
26 | $s1="r1"; | 34 | $s1="r1"; |
27 | $s2="r2"; | 35 | $s2="r2"; |
@@ -164,24 +172,24 @@ AES_encrypt: | |||
164 | ldrb $t2,[$rounds,#1] | 172 | ldrb $t2,[$rounds,#1] |
165 | ldrb $t3,[$rounds,#0] | 173 | ldrb $t3,[$rounds,#0] |
166 | orr $s0,$s0,$t1,lsl#8 | 174 | orr $s0,$s0,$t1,lsl#8 |
167 | orr $s0,$s0,$t2,lsl#16 | ||
168 | orr $s0,$s0,$t3,lsl#24 | ||
169 | ldrb $s1,[$rounds,#7] | 175 | ldrb $s1,[$rounds,#7] |
176 | orr $s0,$s0,$t2,lsl#16 | ||
170 | ldrb $t1,[$rounds,#6] | 177 | ldrb $t1,[$rounds,#6] |
178 | orr $s0,$s0,$t3,lsl#24 | ||
171 | ldrb $t2,[$rounds,#5] | 179 | ldrb $t2,[$rounds,#5] |
172 | ldrb $t3,[$rounds,#4] | 180 | ldrb $t3,[$rounds,#4] |
173 | orr $s1,$s1,$t1,lsl#8 | 181 | orr $s1,$s1,$t1,lsl#8 |
174 | orr $s1,$s1,$t2,lsl#16 | ||
175 | orr $s1,$s1,$t3,lsl#24 | ||
176 | ldrb $s2,[$rounds,#11] | 182 | ldrb $s2,[$rounds,#11] |
183 | orr $s1,$s1,$t2,lsl#16 | ||
177 | ldrb $t1,[$rounds,#10] | 184 | ldrb $t1,[$rounds,#10] |
185 | orr $s1,$s1,$t3,lsl#24 | ||
178 | ldrb $t2,[$rounds,#9] | 186 | ldrb $t2,[$rounds,#9] |
179 | ldrb $t3,[$rounds,#8] | 187 | ldrb $t3,[$rounds,#8] |
180 | orr $s2,$s2,$t1,lsl#8 | 188 | orr $s2,$s2,$t1,lsl#8 |
181 | orr $s2,$s2,$t2,lsl#16 | ||
182 | orr $s2,$s2,$t3,lsl#24 | ||
183 | ldrb $s3,[$rounds,#15] | 189 | ldrb $s3,[$rounds,#15] |
190 | orr $s2,$s2,$t2,lsl#16 | ||
184 | ldrb $t1,[$rounds,#14] | 191 | ldrb $t1,[$rounds,#14] |
192 | orr $s2,$s2,$t3,lsl#24 | ||
185 | ldrb $t2,[$rounds,#13] | 193 | ldrb $t2,[$rounds,#13] |
186 | ldrb $t3,[$rounds,#12] | 194 | ldrb $t3,[$rounds,#12] |
187 | orr $s3,$s3,$t1,lsl#8 | 195 | orr $s3,$s3,$t1,lsl#8 |
@@ -196,24 +204,24 @@ AES_encrypt: | |||
196 | mov $t3,$s0,lsr#8 | 204 | mov $t3,$s0,lsr#8 |
197 | strb $t1,[$rounds,#0] | 205 | strb $t1,[$rounds,#0] |
198 | strb $t2,[$rounds,#1] | 206 | strb $t2,[$rounds,#1] |
199 | strb $t3,[$rounds,#2] | ||
200 | strb $s0,[$rounds,#3] | ||
201 | mov $t1,$s1,lsr#24 | 207 | mov $t1,$s1,lsr#24 |
208 | strb $t3,[$rounds,#2] | ||
202 | mov $t2,$s1,lsr#16 | 209 | mov $t2,$s1,lsr#16 |
210 | strb $s0,[$rounds,#3] | ||
203 | mov $t3,$s1,lsr#8 | 211 | mov $t3,$s1,lsr#8 |
204 | strb $t1,[$rounds,#4] | 212 | strb $t1,[$rounds,#4] |
205 | strb $t2,[$rounds,#5] | 213 | strb $t2,[$rounds,#5] |
206 | strb $t3,[$rounds,#6] | ||
207 | strb $s1,[$rounds,#7] | ||
208 | mov $t1,$s2,lsr#24 | 214 | mov $t1,$s2,lsr#24 |
215 | strb $t3,[$rounds,#6] | ||
209 | mov $t2,$s2,lsr#16 | 216 | mov $t2,$s2,lsr#16 |
217 | strb $s1,[$rounds,#7] | ||
210 | mov $t3,$s2,lsr#8 | 218 | mov $t3,$s2,lsr#8 |
211 | strb $t1,[$rounds,#8] | 219 | strb $t1,[$rounds,#8] |
212 | strb $t2,[$rounds,#9] | 220 | strb $t2,[$rounds,#9] |
213 | strb $t3,[$rounds,#10] | ||
214 | strb $s2,[$rounds,#11] | ||
215 | mov $t1,$s3,lsr#24 | 221 | mov $t1,$s3,lsr#24 |
222 | strb $t3,[$rounds,#10] | ||
216 | mov $t2,$s3,lsr#16 | 223 | mov $t2,$s3,lsr#16 |
224 | strb $s2,[$rounds,#11] | ||
217 | mov $t3,$s3,lsr#8 | 225 | mov $t3,$s3,lsr#8 |
218 | strb $t1,[$rounds,#12] | 226 | strb $t1,[$rounds,#12] |
219 | strb $t2,[$rounds,#13] | 227 | strb $t2,[$rounds,#13] |
@@ -230,141 +238,137 @@ AES_encrypt: | |||
230 | .align 2 | 238 | .align 2 |
231 | _armv4_AES_encrypt: | 239 | _armv4_AES_encrypt: |
232 | str lr,[sp,#-4]! @ push lr | 240 | str lr,[sp,#-4]! @ push lr |
233 | ldr $t1,[$key],#16 | 241 | ldmia $key!,{$t1-$i1} |
234 | ldr $t2,[$key,#-12] | ||
235 | ldr $t3,[$key,#-8] | ||
236 | ldr $i1,[$key,#-4] | ||
237 | ldr $rounds,[$key,#240-16] | ||
238 | eor $s0,$s0,$t1 | 242 | eor $s0,$s0,$t1 |
243 | ldr $rounds,[$key,#240-16] | ||
239 | eor $s1,$s1,$t2 | 244 | eor $s1,$s1,$t2 |
240 | eor $s2,$s2,$t3 | 245 | eor $s2,$s2,$t3 |
241 | eor $s3,$s3,$i1 | 246 | eor $s3,$s3,$i1 |
242 | sub $rounds,$rounds,#1 | 247 | sub $rounds,$rounds,#1 |
243 | mov lr,#255 | 248 | mov lr,#255 |
244 | 249 | ||
245 | .Lenc_loop: | 250 | and $i1,lr,$s0 |
246 | and $i2,lr,$s0,lsr#8 | 251 | and $i2,lr,$s0,lsr#8 |
247 | and $i3,lr,$s0,lsr#16 | 252 | and $i3,lr,$s0,lsr#16 |
248 | and $i1,lr,$s0 | ||
249 | mov $s0,$s0,lsr#24 | 253 | mov $s0,$s0,lsr#24 |
254 | .Lenc_loop: | ||
250 | ldr $t1,[$tbl,$i1,lsl#2] @ Te3[s0>>0] | 255 | ldr $t1,[$tbl,$i1,lsl#2] @ Te3[s0>>0] |
251 | ldr $s0,[$tbl,$s0,lsl#2] @ Te0[s0>>24] | ||
252 | ldr $t2,[$tbl,$i2,lsl#2] @ Te2[s0>>8] | ||
253 | ldr $t3,[$tbl,$i3,lsl#2] @ Te1[s0>>16] | ||
254 | |||
255 | and $i1,lr,$s1,lsr#16 @ i0 | 256 | and $i1,lr,$s1,lsr#16 @ i0 |
257 | ldr $t2,[$tbl,$i2,lsl#2] @ Te2[s0>>8] | ||
256 | and $i2,lr,$s1 | 258 | and $i2,lr,$s1 |
259 | ldr $t3,[$tbl,$i3,lsl#2] @ Te1[s0>>16] | ||
257 | and $i3,lr,$s1,lsr#8 | 260 | and $i3,lr,$s1,lsr#8 |
261 | ldr $s0,[$tbl,$s0,lsl#2] @ Te0[s0>>24] | ||
258 | mov $s1,$s1,lsr#24 | 262 | mov $s1,$s1,lsr#24 |
263 | |||
259 | ldr $i1,[$tbl,$i1,lsl#2] @ Te1[s1>>16] | 264 | ldr $i1,[$tbl,$i1,lsl#2] @ Te1[s1>>16] |
260 | ldr $s1,[$tbl,$s1,lsl#2] @ Te0[s1>>24] | ||
261 | ldr $i2,[$tbl,$i2,lsl#2] @ Te3[s1>>0] | 265 | ldr $i2,[$tbl,$i2,lsl#2] @ Te3[s1>>0] |
262 | ldr $i3,[$tbl,$i3,lsl#2] @ Te2[s1>>8] | 266 | ldr $i3,[$tbl,$i3,lsl#2] @ Te2[s1>>8] |
263 | eor $s0,$s0,$i1,ror#8 | 267 | eor $s0,$s0,$i1,ror#8 |
264 | eor $s1,$s1,$t1,ror#24 | 268 | ldr $s1,[$tbl,$s1,lsl#2] @ Te0[s1>>24] |
265 | eor $t2,$t2,$i2,ror#8 | ||
266 | eor $t3,$t3,$i3,ror#8 | ||
267 | |||
268 | and $i1,lr,$s2,lsr#8 @ i0 | 269 | and $i1,lr,$s2,lsr#8 @ i0 |
270 | eor $t2,$t2,$i2,ror#8 | ||
269 | and $i2,lr,$s2,lsr#16 @ i1 | 271 | and $i2,lr,$s2,lsr#16 @ i1 |
272 | eor $t3,$t3,$i3,ror#8 | ||
270 | and $i3,lr,$s2 | 273 | and $i3,lr,$s2 |
271 | mov $s2,$s2,lsr#24 | 274 | eor $s1,$s1,$t1,ror#24 |
272 | ldr $i1,[$tbl,$i1,lsl#2] @ Te2[s2>>8] | 275 | ldr $i1,[$tbl,$i1,lsl#2] @ Te2[s2>>8] |
276 | mov $s2,$s2,lsr#24 | ||
277 | |||
273 | ldr $i2,[$tbl,$i2,lsl#2] @ Te1[s2>>16] | 278 | ldr $i2,[$tbl,$i2,lsl#2] @ Te1[s2>>16] |
274 | ldr $s2,[$tbl,$s2,lsl#2] @ Te0[s2>>24] | ||
275 | ldr $i3,[$tbl,$i3,lsl#2] @ Te3[s2>>0] | 279 | ldr $i3,[$tbl,$i3,lsl#2] @ Te3[s2>>0] |
276 | eor $s0,$s0,$i1,ror#16 | 280 | eor $s0,$s0,$i1,ror#16 |
277 | eor $s1,$s1,$i2,ror#8 | 281 | ldr $s2,[$tbl,$s2,lsl#2] @ Te0[s2>>24] |
278 | eor $s2,$s2,$t2,ror#16 | ||
279 | eor $t3,$t3,$i3,ror#16 | ||
280 | |||
281 | and $i1,lr,$s3 @ i0 | 282 | and $i1,lr,$s3 @ i0 |
283 | eor $s1,$s1,$i2,ror#8 | ||
282 | and $i2,lr,$s3,lsr#8 @ i1 | 284 | and $i2,lr,$s3,lsr#8 @ i1 |
285 | eor $t3,$t3,$i3,ror#16 | ||
283 | and $i3,lr,$s3,lsr#16 @ i2 | 286 | and $i3,lr,$s3,lsr#16 @ i2 |
284 | mov $s3,$s3,lsr#24 | 287 | eor $s2,$s2,$t2,ror#16 |
285 | ldr $i1,[$tbl,$i1,lsl#2] @ Te3[s3>>0] | 288 | ldr $i1,[$tbl,$i1,lsl#2] @ Te3[s3>>0] |
289 | mov $s3,$s3,lsr#24 | ||
290 | |||
286 | ldr $i2,[$tbl,$i2,lsl#2] @ Te2[s3>>8] | 291 | ldr $i2,[$tbl,$i2,lsl#2] @ Te2[s3>>8] |
287 | ldr $i3,[$tbl,$i3,lsl#2] @ Te1[s3>>16] | 292 | ldr $i3,[$tbl,$i3,lsl#2] @ Te1[s3>>16] |
288 | ldr $s3,[$tbl,$s3,lsl#2] @ Te0[s3>>24] | ||
289 | eor $s0,$s0,$i1,ror#24 | 293 | eor $s0,$s0,$i1,ror#24 |
294 | ldr $s3,[$tbl,$s3,lsl#2] @ Te0[s3>>24] | ||
290 | eor $s1,$s1,$i2,ror#16 | 295 | eor $s1,$s1,$i2,ror#16 |
296 | ldr $i1,[$key],#16 | ||
291 | eor $s2,$s2,$i3,ror#8 | 297 | eor $s2,$s2,$i3,ror#8 |
298 | ldr $t1,[$key,#-12] | ||
292 | eor $s3,$s3,$t3,ror#8 | 299 | eor $s3,$s3,$t3,ror#8 |
293 | 300 | ||
294 | ldr $t1,[$key],#16 | 301 | ldr $t2,[$key,#-8] |
295 | ldr $t2,[$key,#-12] | 302 | eor $s0,$s0,$i1 |
296 | ldr $t3,[$key,#-8] | 303 | ldr $t3,[$key,#-4] |
297 | ldr $i1,[$key,#-4] | 304 | and $i1,lr,$s0 |
298 | eor $s0,$s0,$t1 | 305 | eor $s1,$s1,$t1 |
299 | eor $s1,$s1,$t2 | 306 | and $i2,lr,$s0,lsr#8 |
300 | eor $s2,$s2,$t3 | 307 | eor $s2,$s2,$t2 |
301 | eor $s3,$s3,$i1 | 308 | and $i3,lr,$s0,lsr#16 |
309 | eor $s3,$s3,$t3 | ||
310 | mov $s0,$s0,lsr#24 | ||
302 | 311 | ||
303 | subs $rounds,$rounds,#1 | 312 | subs $rounds,$rounds,#1 |
304 | bne .Lenc_loop | 313 | bne .Lenc_loop |
305 | 314 | ||
306 | add $tbl,$tbl,#2 | 315 | add $tbl,$tbl,#2 |
307 | 316 | ||
308 | and $i1,lr,$s0 | ||
309 | and $i2,lr,$s0,lsr#8 | ||
310 | and $i3,lr,$s0,lsr#16 | ||
311 | mov $s0,$s0,lsr#24 | ||
312 | ldrb $t1,[$tbl,$i1,lsl#2] @ Te4[s0>>0] | 317 | ldrb $t1,[$tbl,$i1,lsl#2] @ Te4[s0>>0] |
313 | ldrb $s0,[$tbl,$s0,lsl#2] @ Te4[s0>>24] | ||
314 | ldrb $t2,[$tbl,$i2,lsl#2] @ Te4[s0>>8] | ||
315 | ldrb $t3,[$tbl,$i3,lsl#2] @ Te4[s0>>16] | ||
316 | |||
317 | and $i1,lr,$s1,lsr#16 @ i0 | 318 | and $i1,lr,$s1,lsr#16 @ i0 |
319 | ldrb $t2,[$tbl,$i2,lsl#2] @ Te4[s0>>8] | ||
318 | and $i2,lr,$s1 | 320 | and $i2,lr,$s1 |
321 | ldrb $t3,[$tbl,$i3,lsl#2] @ Te4[s0>>16] | ||
319 | and $i3,lr,$s1,lsr#8 | 322 | and $i3,lr,$s1,lsr#8 |
323 | ldrb $s0,[$tbl,$s0,lsl#2] @ Te4[s0>>24] | ||
320 | mov $s1,$s1,lsr#24 | 324 | mov $s1,$s1,lsr#24 |
325 | |||
321 | ldrb $i1,[$tbl,$i1,lsl#2] @ Te4[s1>>16] | 326 | ldrb $i1,[$tbl,$i1,lsl#2] @ Te4[s1>>16] |
322 | ldrb $s1,[$tbl,$s1,lsl#2] @ Te4[s1>>24] | ||
323 | ldrb $i2,[$tbl,$i2,lsl#2] @ Te4[s1>>0] | 327 | ldrb $i2,[$tbl,$i2,lsl#2] @ Te4[s1>>0] |
324 | ldrb $i3,[$tbl,$i3,lsl#2] @ Te4[s1>>8] | 328 | ldrb $i3,[$tbl,$i3,lsl#2] @ Te4[s1>>8] |
325 | eor $s0,$i1,$s0,lsl#8 | 329 | eor $s0,$i1,$s0,lsl#8 |
326 | eor $s1,$t1,$s1,lsl#24 | 330 | ldrb $s1,[$tbl,$s1,lsl#2] @ Te4[s1>>24] |
327 | eor $t2,$i2,$t2,lsl#8 | ||
328 | eor $t3,$i3,$t3,lsl#8 | ||
329 | |||
330 | and $i1,lr,$s2,lsr#8 @ i0 | 331 | and $i1,lr,$s2,lsr#8 @ i0 |
332 | eor $t2,$i2,$t2,lsl#8 | ||
331 | and $i2,lr,$s2,lsr#16 @ i1 | 333 | and $i2,lr,$s2,lsr#16 @ i1 |
334 | eor $t3,$i3,$t3,lsl#8 | ||
332 | and $i3,lr,$s2 | 335 | and $i3,lr,$s2 |
333 | mov $s2,$s2,lsr#24 | 336 | eor $s1,$t1,$s1,lsl#24 |
334 | ldrb $i1,[$tbl,$i1,lsl#2] @ Te4[s2>>8] | 337 | ldrb $i1,[$tbl,$i1,lsl#2] @ Te4[s2>>8] |
338 | mov $s2,$s2,lsr#24 | ||
339 | |||
335 | ldrb $i2,[$tbl,$i2,lsl#2] @ Te4[s2>>16] | 340 | ldrb $i2,[$tbl,$i2,lsl#2] @ Te4[s2>>16] |
336 | ldrb $s2,[$tbl,$s2,lsl#2] @ Te4[s2>>24] | ||
337 | ldrb $i3,[$tbl,$i3,lsl#2] @ Te4[s2>>0] | 341 | ldrb $i3,[$tbl,$i3,lsl#2] @ Te4[s2>>0] |
338 | eor $s0,$i1,$s0,lsl#8 | 342 | eor $s0,$i1,$s0,lsl#8 |
339 | eor $s1,$s1,$i2,lsl#16 | 343 | ldrb $s2,[$tbl,$s2,lsl#2] @ Te4[s2>>24] |
340 | eor $s2,$t2,$s2,lsl#24 | ||
341 | eor $t3,$i3,$t3,lsl#8 | ||
342 | |||
343 | and $i1,lr,$s3 @ i0 | 344 | and $i1,lr,$s3 @ i0 |
345 | eor $s1,$s1,$i2,lsl#16 | ||
344 | and $i2,lr,$s3,lsr#8 @ i1 | 346 | and $i2,lr,$s3,lsr#8 @ i1 |
347 | eor $t3,$i3,$t3,lsl#8 | ||
345 | and $i3,lr,$s3,lsr#16 @ i2 | 348 | and $i3,lr,$s3,lsr#16 @ i2 |
346 | mov $s3,$s3,lsr#24 | 349 | eor $s2,$t2,$s2,lsl#24 |
347 | ldrb $i1,[$tbl,$i1,lsl#2] @ Te4[s3>>0] | 350 | ldrb $i1,[$tbl,$i1,lsl#2] @ Te4[s3>>0] |
351 | mov $s3,$s3,lsr#24 | ||
352 | |||
348 | ldrb $i2,[$tbl,$i2,lsl#2] @ Te4[s3>>8] | 353 | ldrb $i2,[$tbl,$i2,lsl#2] @ Te4[s3>>8] |
349 | ldrb $i3,[$tbl,$i3,lsl#2] @ Te4[s3>>16] | 354 | ldrb $i3,[$tbl,$i3,lsl#2] @ Te4[s3>>16] |
350 | ldrb $s3,[$tbl,$s3,lsl#2] @ Te4[s3>>24] | ||
351 | eor $s0,$i1,$s0,lsl#8 | 355 | eor $s0,$i1,$s0,lsl#8 |
356 | ldrb $s3,[$tbl,$s3,lsl#2] @ Te4[s3>>24] | ||
357 | ldr $i1,[$key,#0] | ||
352 | eor $s1,$s1,$i2,lsl#8 | 358 | eor $s1,$s1,$i2,lsl#8 |
359 | ldr $t1,[$key,#4] | ||
353 | eor $s2,$s2,$i3,lsl#16 | 360 | eor $s2,$s2,$i3,lsl#16 |
361 | ldr $t2,[$key,#8] | ||
354 | eor $s3,$t3,$s3,lsl#24 | 362 | eor $s3,$t3,$s3,lsl#24 |
363 | ldr $t3,[$key,#12] | ||
355 | 364 | ||
356 | ldr lr,[sp],#4 @ pop lr | 365 | eor $s0,$s0,$i1 |
357 | ldr $t1,[$key,#0] | 366 | eor $s1,$s1,$t1 |
358 | ldr $t2,[$key,#4] | 367 | eor $s2,$s2,$t2 |
359 | ldr $t3,[$key,#8] | 368 | eor $s3,$s3,$t3 |
360 | ldr $i1,[$key,#12] | ||
361 | eor $s0,$s0,$t1 | ||
362 | eor $s1,$s1,$t2 | ||
363 | eor $s2,$s2,$t3 | ||
364 | eor $s3,$s3,$i1 | ||
365 | 369 | ||
366 | sub $tbl,$tbl,#2 | 370 | sub $tbl,$tbl,#2 |
367 | mov pc,lr @ return | 371 | ldr pc,[sp],#4 @ pop and return |
368 | .size _armv4_AES_encrypt,.-_armv4_AES_encrypt | 372 | .size _armv4_AES_encrypt,.-_armv4_AES_encrypt |
369 | 373 | ||
370 | .global AES_set_encrypt_key | 374 | .global AES_set_encrypt_key |
@@ -399,31 +403,31 @@ AES_set_encrypt_key: | |||
399 | ldrb $t2,[$rounds,#1] | 403 | ldrb $t2,[$rounds,#1] |
400 | ldrb $t3,[$rounds,#0] | 404 | ldrb $t3,[$rounds,#0] |
401 | orr $s0,$s0,$t1,lsl#8 | 405 | orr $s0,$s0,$t1,lsl#8 |
402 | orr $s0,$s0,$t2,lsl#16 | ||
403 | orr $s0,$s0,$t3,lsl#24 | ||
404 | ldrb $s1,[$rounds,#7] | 406 | ldrb $s1,[$rounds,#7] |
407 | orr $s0,$s0,$t2,lsl#16 | ||
405 | ldrb $t1,[$rounds,#6] | 408 | ldrb $t1,[$rounds,#6] |
409 | orr $s0,$s0,$t3,lsl#24 | ||
406 | ldrb $t2,[$rounds,#5] | 410 | ldrb $t2,[$rounds,#5] |
407 | ldrb $t3,[$rounds,#4] | 411 | ldrb $t3,[$rounds,#4] |
408 | orr $s1,$s1,$t1,lsl#8 | 412 | orr $s1,$s1,$t1,lsl#8 |
409 | orr $s1,$s1,$t2,lsl#16 | ||
410 | orr $s1,$s1,$t3,lsl#24 | ||
411 | ldrb $s2,[$rounds,#11] | 413 | ldrb $s2,[$rounds,#11] |
414 | orr $s1,$s1,$t2,lsl#16 | ||
412 | ldrb $t1,[$rounds,#10] | 415 | ldrb $t1,[$rounds,#10] |
416 | orr $s1,$s1,$t3,lsl#24 | ||
413 | ldrb $t2,[$rounds,#9] | 417 | ldrb $t2,[$rounds,#9] |
414 | ldrb $t3,[$rounds,#8] | 418 | ldrb $t3,[$rounds,#8] |
415 | orr $s2,$s2,$t1,lsl#8 | 419 | orr $s2,$s2,$t1,lsl#8 |
416 | orr $s2,$s2,$t2,lsl#16 | ||
417 | orr $s2,$s2,$t3,lsl#24 | ||
418 | ldrb $s3,[$rounds,#15] | 420 | ldrb $s3,[$rounds,#15] |
421 | orr $s2,$s2,$t2,lsl#16 | ||
419 | ldrb $t1,[$rounds,#14] | 422 | ldrb $t1,[$rounds,#14] |
423 | orr $s2,$s2,$t3,lsl#24 | ||
420 | ldrb $t2,[$rounds,#13] | 424 | ldrb $t2,[$rounds,#13] |
421 | ldrb $t3,[$rounds,#12] | 425 | ldrb $t3,[$rounds,#12] |
422 | orr $s3,$s3,$t1,lsl#8 | 426 | orr $s3,$s3,$t1,lsl#8 |
423 | orr $s3,$s3,$t2,lsl#16 | ||
424 | orr $s3,$s3,$t3,lsl#24 | ||
425 | str $s0,[$key],#16 | 427 | str $s0,[$key],#16 |
428 | orr $s3,$s3,$t2,lsl#16 | ||
426 | str $s1,[$key,#-12] | 429 | str $s1,[$key,#-12] |
430 | orr $s3,$s3,$t3,lsl#24 | ||
427 | str $s2,[$key,#-8] | 431 | str $s2,[$key,#-8] |
428 | str $s3,[$key,#-4] | 432 | str $s3,[$key,#-4] |
429 | 433 | ||
@@ -437,27 +441,26 @@ AES_set_encrypt_key: | |||
437 | .L128_loop: | 441 | .L128_loop: |
438 | and $t2,lr,$s3,lsr#24 | 442 | and $t2,lr,$s3,lsr#24 |
439 | and $i1,lr,$s3,lsr#16 | 443 | and $i1,lr,$s3,lsr#16 |
440 | and $i2,lr,$s3,lsr#8 | ||
441 | and $i3,lr,$s3 | ||
442 | ldrb $t2,[$tbl,$t2] | 444 | ldrb $t2,[$tbl,$t2] |
445 | and $i2,lr,$s3,lsr#8 | ||
443 | ldrb $i1,[$tbl,$i1] | 446 | ldrb $i1,[$tbl,$i1] |
447 | and $i3,lr,$s3 | ||
444 | ldrb $i2,[$tbl,$i2] | 448 | ldrb $i2,[$tbl,$i2] |
445 | ldrb $i3,[$tbl,$i3] | ||
446 | ldr $t1,[$t3],#4 @ rcon[i++] | ||
447 | orr $t2,$t2,$i1,lsl#24 | 449 | orr $t2,$t2,$i1,lsl#24 |
450 | ldrb $i3,[$tbl,$i3] | ||
448 | orr $t2,$t2,$i2,lsl#16 | 451 | orr $t2,$t2,$i2,lsl#16 |
452 | ldr $t1,[$t3],#4 @ rcon[i++] | ||
449 | orr $t2,$t2,$i3,lsl#8 | 453 | orr $t2,$t2,$i3,lsl#8 |
450 | eor $t2,$t2,$t1 | 454 | eor $t2,$t2,$t1 |
451 | eor $s0,$s0,$t2 @ rk[4]=rk[0]^... | 455 | eor $s0,$s0,$t2 @ rk[4]=rk[0]^... |
452 | eor $s1,$s1,$s0 @ rk[5]=rk[1]^rk[4] | 456 | eor $s1,$s1,$s0 @ rk[5]=rk[1]^rk[4] |
453 | eor $s2,$s2,$s1 @ rk[6]=rk[2]^rk[5] | ||
454 | eor $s3,$s3,$s2 @ rk[7]=rk[3]^rk[6] | ||
455 | str $s0,[$key],#16 | 457 | str $s0,[$key],#16 |
458 | eor $s2,$s2,$s1 @ rk[6]=rk[2]^rk[5] | ||
456 | str $s1,[$key,#-12] | 459 | str $s1,[$key,#-12] |
460 | eor $s3,$s3,$s2 @ rk[7]=rk[3]^rk[6] | ||
457 | str $s2,[$key,#-8] | 461 | str $s2,[$key,#-8] |
458 | str $s3,[$key,#-4] | ||
459 | |||
460 | subs $rounds,$rounds,#1 | 462 | subs $rounds,$rounds,#1 |
463 | str $s3,[$key,#-4] | ||
461 | bne .L128_loop | 464 | bne .L128_loop |
462 | sub r2,$key,#176 | 465 | sub r2,$key,#176 |
463 | b .Ldone | 466 | b .Ldone |
@@ -468,16 +471,16 @@ AES_set_encrypt_key: | |||
468 | ldrb $t2,[$rounds,#17] | 471 | ldrb $t2,[$rounds,#17] |
469 | ldrb $t3,[$rounds,#16] | 472 | ldrb $t3,[$rounds,#16] |
470 | orr $i2,$i2,$t1,lsl#8 | 473 | orr $i2,$i2,$t1,lsl#8 |
471 | orr $i2,$i2,$t2,lsl#16 | ||
472 | orr $i2,$i2,$t3,lsl#24 | ||
473 | ldrb $i3,[$rounds,#23] | 474 | ldrb $i3,[$rounds,#23] |
475 | orr $i2,$i2,$t2,lsl#16 | ||
474 | ldrb $t1,[$rounds,#22] | 476 | ldrb $t1,[$rounds,#22] |
477 | orr $i2,$i2,$t3,lsl#24 | ||
475 | ldrb $t2,[$rounds,#21] | 478 | ldrb $t2,[$rounds,#21] |
476 | ldrb $t3,[$rounds,#20] | 479 | ldrb $t3,[$rounds,#20] |
477 | orr $i3,$i3,$t1,lsl#8 | 480 | orr $i3,$i3,$t1,lsl#8 |
478 | orr $i3,$i3,$t2,lsl#16 | 481 | orr $i3,$i3,$t2,lsl#16 |
479 | orr $i3,$i3,$t3,lsl#24 | ||
480 | str $i2,[$key],#8 | 482 | str $i2,[$key],#8 |
483 | orr $i3,$i3,$t3,lsl#24 | ||
481 | str $i3,[$key,#-4] | 484 | str $i3,[$key,#-4] |
482 | 485 | ||
483 | teq lr,#192 | 486 | teq lr,#192 |
@@ -491,27 +494,26 @@ AES_set_encrypt_key: | |||
491 | .L192_loop: | 494 | .L192_loop: |
492 | and $t2,lr,$i3,lsr#24 | 495 | and $t2,lr,$i3,lsr#24 |
493 | and $i1,lr,$i3,lsr#16 | 496 | and $i1,lr,$i3,lsr#16 |
494 | and $i2,lr,$i3,lsr#8 | ||
495 | and $i3,lr,$i3 | ||
496 | ldrb $t2,[$tbl,$t2] | 497 | ldrb $t2,[$tbl,$t2] |
498 | and $i2,lr,$i3,lsr#8 | ||
497 | ldrb $i1,[$tbl,$i1] | 499 | ldrb $i1,[$tbl,$i1] |
500 | and $i3,lr,$i3 | ||
498 | ldrb $i2,[$tbl,$i2] | 501 | ldrb $i2,[$tbl,$i2] |
499 | ldrb $i3,[$tbl,$i3] | ||
500 | ldr $t1,[$t3],#4 @ rcon[i++] | ||
501 | orr $t2,$t2,$i1,lsl#24 | 502 | orr $t2,$t2,$i1,lsl#24 |
503 | ldrb $i3,[$tbl,$i3] | ||
502 | orr $t2,$t2,$i2,lsl#16 | 504 | orr $t2,$t2,$i2,lsl#16 |
505 | ldr $t1,[$t3],#4 @ rcon[i++] | ||
503 | orr $t2,$t2,$i3,lsl#8 | 506 | orr $t2,$t2,$i3,lsl#8 |
504 | eor $i3,$t2,$t1 | 507 | eor $i3,$t2,$t1 |
505 | eor $s0,$s0,$i3 @ rk[6]=rk[0]^... | 508 | eor $s0,$s0,$i3 @ rk[6]=rk[0]^... |
506 | eor $s1,$s1,$s0 @ rk[7]=rk[1]^rk[6] | 509 | eor $s1,$s1,$s0 @ rk[7]=rk[1]^rk[6] |
507 | eor $s2,$s2,$s1 @ rk[8]=rk[2]^rk[7] | ||
508 | eor $s3,$s3,$s2 @ rk[9]=rk[3]^rk[8] | ||
509 | str $s0,[$key],#24 | 510 | str $s0,[$key],#24 |
511 | eor $s2,$s2,$s1 @ rk[8]=rk[2]^rk[7] | ||
510 | str $s1,[$key,#-20] | 512 | str $s1,[$key,#-20] |
513 | eor $s3,$s3,$s2 @ rk[9]=rk[3]^rk[8] | ||
511 | str $s2,[$key,#-16] | 514 | str $s2,[$key,#-16] |
512 | str $s3,[$key,#-12] | ||
513 | |||
514 | subs $rounds,$rounds,#1 | 515 | subs $rounds,$rounds,#1 |
516 | str $s3,[$key,#-12] | ||
515 | subeq r2,$key,#216 | 517 | subeq r2,$key,#216 |
516 | beq .Ldone | 518 | beq .Ldone |
517 | 519 | ||
@@ -529,16 +531,16 @@ AES_set_encrypt_key: | |||
529 | ldrb $t2,[$rounds,#25] | 531 | ldrb $t2,[$rounds,#25] |
530 | ldrb $t3,[$rounds,#24] | 532 | ldrb $t3,[$rounds,#24] |
531 | orr $i2,$i2,$t1,lsl#8 | 533 | orr $i2,$i2,$t1,lsl#8 |
532 | orr $i2,$i2,$t2,lsl#16 | ||
533 | orr $i2,$i2,$t3,lsl#24 | ||
534 | ldrb $i3,[$rounds,#31] | 534 | ldrb $i3,[$rounds,#31] |
535 | orr $i2,$i2,$t2,lsl#16 | ||
535 | ldrb $t1,[$rounds,#30] | 536 | ldrb $t1,[$rounds,#30] |
537 | orr $i2,$i2,$t3,lsl#24 | ||
536 | ldrb $t2,[$rounds,#29] | 538 | ldrb $t2,[$rounds,#29] |
537 | ldrb $t3,[$rounds,#28] | 539 | ldrb $t3,[$rounds,#28] |
538 | orr $i3,$i3,$t1,lsl#8 | 540 | orr $i3,$i3,$t1,lsl#8 |
539 | orr $i3,$i3,$t2,lsl#16 | 541 | orr $i3,$i3,$t2,lsl#16 |
540 | orr $i3,$i3,$t3,lsl#24 | ||
541 | str $i2,[$key],#8 | 542 | str $i2,[$key],#8 |
543 | orr $i3,$i3,$t3,lsl#24 | ||
542 | str $i3,[$key,#-4] | 544 | str $i3,[$key,#-4] |
543 | 545 | ||
544 | mov $rounds,#14 | 546 | mov $rounds,#14 |
@@ -550,52 +552,51 @@ AES_set_encrypt_key: | |||
550 | .L256_loop: | 552 | .L256_loop: |
551 | and $t2,lr,$i3,lsr#24 | 553 | and $t2,lr,$i3,lsr#24 |
552 | and $i1,lr,$i3,lsr#16 | 554 | and $i1,lr,$i3,lsr#16 |
553 | and $i2,lr,$i3,lsr#8 | ||
554 | and $i3,lr,$i3 | ||
555 | ldrb $t2,[$tbl,$t2] | 555 | ldrb $t2,[$tbl,$t2] |
556 | and $i2,lr,$i3,lsr#8 | ||
556 | ldrb $i1,[$tbl,$i1] | 557 | ldrb $i1,[$tbl,$i1] |
558 | and $i3,lr,$i3 | ||
557 | ldrb $i2,[$tbl,$i2] | 559 | ldrb $i2,[$tbl,$i2] |
558 | ldrb $i3,[$tbl,$i3] | ||
559 | ldr $t1,[$t3],#4 @ rcon[i++] | ||
560 | orr $t2,$t2,$i1,lsl#24 | 560 | orr $t2,$t2,$i1,lsl#24 |
561 | ldrb $i3,[$tbl,$i3] | ||
561 | orr $t2,$t2,$i2,lsl#16 | 562 | orr $t2,$t2,$i2,lsl#16 |
563 | ldr $t1,[$t3],#4 @ rcon[i++] | ||
562 | orr $t2,$t2,$i3,lsl#8 | 564 | orr $t2,$t2,$i3,lsl#8 |
563 | eor $i3,$t2,$t1 | 565 | eor $i3,$t2,$t1 |
564 | eor $s0,$s0,$i3 @ rk[8]=rk[0]^... | 566 | eor $s0,$s0,$i3 @ rk[8]=rk[0]^... |
565 | eor $s1,$s1,$s0 @ rk[9]=rk[1]^rk[8] | 567 | eor $s1,$s1,$s0 @ rk[9]=rk[1]^rk[8] |
566 | eor $s2,$s2,$s1 @ rk[10]=rk[2]^rk[9] | ||
567 | eor $s3,$s3,$s2 @ rk[11]=rk[3]^rk[10] | ||
568 | str $s0,[$key],#32 | 568 | str $s0,[$key],#32 |
569 | eor $s2,$s2,$s1 @ rk[10]=rk[2]^rk[9] | ||
569 | str $s1,[$key,#-28] | 570 | str $s1,[$key,#-28] |
571 | eor $s3,$s3,$s2 @ rk[11]=rk[3]^rk[10] | ||
570 | str $s2,[$key,#-24] | 572 | str $s2,[$key,#-24] |
571 | str $s3,[$key,#-20] | ||
572 | |||
573 | subs $rounds,$rounds,#1 | 573 | subs $rounds,$rounds,#1 |
574 | str $s3,[$key,#-20] | ||
574 | subeq r2,$key,#256 | 575 | subeq r2,$key,#256 |
575 | beq .Ldone | 576 | beq .Ldone |
576 | 577 | ||
577 | and $t2,lr,$s3 | 578 | and $t2,lr,$s3 |
578 | and $i1,lr,$s3,lsr#8 | 579 | and $i1,lr,$s3,lsr#8 |
579 | and $i2,lr,$s3,lsr#16 | ||
580 | and $i3,lr,$s3,lsr#24 | ||
581 | ldrb $t2,[$tbl,$t2] | 580 | ldrb $t2,[$tbl,$t2] |
581 | and $i2,lr,$s3,lsr#16 | ||
582 | ldrb $i1,[$tbl,$i1] | 582 | ldrb $i1,[$tbl,$i1] |
583 | and $i3,lr,$s3,lsr#24 | ||
583 | ldrb $i2,[$tbl,$i2] | 584 | ldrb $i2,[$tbl,$i2] |
584 | ldrb $i3,[$tbl,$i3] | ||
585 | orr $t2,$t2,$i1,lsl#8 | 585 | orr $t2,$t2,$i1,lsl#8 |
586 | ldrb $i3,[$tbl,$i3] | ||
586 | orr $t2,$t2,$i2,lsl#16 | 587 | orr $t2,$t2,$i2,lsl#16 |
588 | ldr $t1,[$key,#-48] | ||
587 | orr $t2,$t2,$i3,lsl#24 | 589 | orr $t2,$t2,$i3,lsl#24 |
588 | 590 | ||
589 | ldr $t1,[$key,#-48] | ||
590 | ldr $i1,[$key,#-44] | 591 | ldr $i1,[$key,#-44] |
591 | ldr $i2,[$key,#-40] | 592 | ldr $i2,[$key,#-40] |
592 | ldr $i3,[$key,#-36] | ||
593 | eor $t1,$t1,$t2 @ rk[12]=rk[4]^... | 593 | eor $t1,$t1,$t2 @ rk[12]=rk[4]^... |
594 | ldr $i3,[$key,#-36] | ||
594 | eor $i1,$i1,$t1 @ rk[13]=rk[5]^rk[12] | 595 | eor $i1,$i1,$t1 @ rk[13]=rk[5]^rk[12] |
595 | eor $i2,$i2,$i1 @ rk[14]=rk[6]^rk[13] | ||
596 | eor $i3,$i3,$i2 @ rk[15]=rk[7]^rk[14] | ||
597 | str $t1,[$key,#-16] | 596 | str $t1,[$key,#-16] |
597 | eor $i2,$i2,$i1 @ rk[14]=rk[6]^rk[13] | ||
598 | str $i1,[$key,#-12] | 598 | str $i1,[$key,#-12] |
599 | eor $i3,$i3,$i2 @ rk[15]=rk[7]^rk[14] | ||
599 | str $i2,[$key,#-8] | 600 | str $i2,[$key,#-8] |
600 | str $i3,[$key,#-4] | 601 | str $i3,[$key,#-4] |
601 | b .L256_loop | 602 | b .L256_loop |
@@ -816,24 +817,24 @@ AES_decrypt: | |||
816 | ldrb $t2,[$rounds,#1] | 817 | ldrb $t2,[$rounds,#1] |
817 | ldrb $t3,[$rounds,#0] | 818 | ldrb $t3,[$rounds,#0] |
818 | orr $s0,$s0,$t1,lsl#8 | 819 | orr $s0,$s0,$t1,lsl#8 |
819 | orr $s0,$s0,$t2,lsl#16 | ||
820 | orr $s0,$s0,$t3,lsl#24 | ||
821 | ldrb $s1,[$rounds,#7] | 820 | ldrb $s1,[$rounds,#7] |
821 | orr $s0,$s0,$t2,lsl#16 | ||
822 | ldrb $t1,[$rounds,#6] | 822 | ldrb $t1,[$rounds,#6] |
823 | orr $s0,$s0,$t3,lsl#24 | ||
823 | ldrb $t2,[$rounds,#5] | 824 | ldrb $t2,[$rounds,#5] |
824 | ldrb $t3,[$rounds,#4] | 825 | ldrb $t3,[$rounds,#4] |
825 | orr $s1,$s1,$t1,lsl#8 | 826 | orr $s1,$s1,$t1,lsl#8 |
826 | orr $s1,$s1,$t2,lsl#16 | ||
827 | orr $s1,$s1,$t3,lsl#24 | ||
828 | ldrb $s2,[$rounds,#11] | 827 | ldrb $s2,[$rounds,#11] |
828 | orr $s1,$s1,$t2,lsl#16 | ||
829 | ldrb $t1,[$rounds,#10] | 829 | ldrb $t1,[$rounds,#10] |
830 | orr $s1,$s1,$t3,lsl#24 | ||
830 | ldrb $t2,[$rounds,#9] | 831 | ldrb $t2,[$rounds,#9] |
831 | ldrb $t3,[$rounds,#8] | 832 | ldrb $t3,[$rounds,#8] |
832 | orr $s2,$s2,$t1,lsl#8 | 833 | orr $s2,$s2,$t1,lsl#8 |
833 | orr $s2,$s2,$t2,lsl#16 | ||
834 | orr $s2,$s2,$t3,lsl#24 | ||
835 | ldrb $s3,[$rounds,#15] | 834 | ldrb $s3,[$rounds,#15] |
835 | orr $s2,$s2,$t2,lsl#16 | ||
836 | ldrb $t1,[$rounds,#14] | 836 | ldrb $t1,[$rounds,#14] |
837 | orr $s2,$s2,$t3,lsl#24 | ||
837 | ldrb $t2,[$rounds,#13] | 838 | ldrb $t2,[$rounds,#13] |
838 | ldrb $t3,[$rounds,#12] | 839 | ldrb $t3,[$rounds,#12] |
839 | orr $s3,$s3,$t1,lsl#8 | 840 | orr $s3,$s3,$t1,lsl#8 |
@@ -848,24 +849,24 @@ AES_decrypt: | |||
848 | mov $t3,$s0,lsr#8 | 849 | mov $t3,$s0,lsr#8 |
849 | strb $t1,[$rounds,#0] | 850 | strb $t1,[$rounds,#0] |
850 | strb $t2,[$rounds,#1] | 851 | strb $t2,[$rounds,#1] |
851 | strb $t3,[$rounds,#2] | ||
852 | strb $s0,[$rounds,#3] | ||
853 | mov $t1,$s1,lsr#24 | 852 | mov $t1,$s1,lsr#24 |
853 | strb $t3,[$rounds,#2] | ||
854 | mov $t2,$s1,lsr#16 | 854 | mov $t2,$s1,lsr#16 |
855 | strb $s0,[$rounds,#3] | ||
855 | mov $t3,$s1,lsr#8 | 856 | mov $t3,$s1,lsr#8 |
856 | strb $t1,[$rounds,#4] | 857 | strb $t1,[$rounds,#4] |
857 | strb $t2,[$rounds,#5] | 858 | strb $t2,[$rounds,#5] |
858 | strb $t3,[$rounds,#6] | ||
859 | strb $s1,[$rounds,#7] | ||
860 | mov $t1,$s2,lsr#24 | 859 | mov $t1,$s2,lsr#24 |
860 | strb $t3,[$rounds,#6] | ||
861 | mov $t2,$s2,lsr#16 | 861 | mov $t2,$s2,lsr#16 |
862 | strb $s1,[$rounds,#7] | ||
862 | mov $t3,$s2,lsr#8 | 863 | mov $t3,$s2,lsr#8 |
863 | strb $t1,[$rounds,#8] | 864 | strb $t1,[$rounds,#8] |
864 | strb $t2,[$rounds,#9] | 865 | strb $t2,[$rounds,#9] |
865 | strb $t3,[$rounds,#10] | ||
866 | strb $s2,[$rounds,#11] | ||
867 | mov $t1,$s3,lsr#24 | 866 | mov $t1,$s3,lsr#24 |
867 | strb $t3,[$rounds,#10] | ||
868 | mov $t2,$s3,lsr#16 | 868 | mov $t2,$s3,lsr#16 |
869 | strb $s2,[$rounds,#11] | ||
869 | mov $t3,$s3,lsr#8 | 870 | mov $t3,$s3,lsr#8 |
870 | strb $t1,[$rounds,#12] | 871 | strb $t1,[$rounds,#12] |
871 | strb $t2,[$rounds,#13] | 872 | strb $t2,[$rounds,#13] |
@@ -882,146 +883,143 @@ AES_decrypt: | |||
882 | .align 2 | 883 | .align 2 |
883 | _armv4_AES_decrypt: | 884 | _armv4_AES_decrypt: |
884 | str lr,[sp,#-4]! @ push lr | 885 | str lr,[sp,#-4]! @ push lr |
885 | ldr $t1,[$key],#16 | 886 | ldmia $key!,{$t1-$i1} |
886 | ldr $t2,[$key,#-12] | ||
887 | ldr $t3,[$key,#-8] | ||
888 | ldr $i1,[$key,#-4] | ||
889 | ldr $rounds,[$key,#240-16] | ||
890 | eor $s0,$s0,$t1 | 887 | eor $s0,$s0,$t1 |
888 | ldr $rounds,[$key,#240-16] | ||
891 | eor $s1,$s1,$t2 | 889 | eor $s1,$s1,$t2 |
892 | eor $s2,$s2,$t3 | 890 | eor $s2,$s2,$t3 |
893 | eor $s3,$s3,$i1 | 891 | eor $s3,$s3,$i1 |
894 | sub $rounds,$rounds,#1 | 892 | sub $rounds,$rounds,#1 |
895 | mov lr,#255 | 893 | mov lr,#255 |
896 | 894 | ||
897 | .Ldec_loop: | ||
898 | and $i1,lr,$s0,lsr#16 | 895 | and $i1,lr,$s0,lsr#16 |
899 | and $i2,lr,$s0,lsr#8 | 896 | and $i2,lr,$s0,lsr#8 |
900 | and $i3,lr,$s0 | 897 | and $i3,lr,$s0 |
901 | mov $s0,$s0,lsr#24 | 898 | mov $s0,$s0,lsr#24 |
899 | .Ldec_loop: | ||
902 | ldr $t1,[$tbl,$i1,lsl#2] @ Td1[s0>>16] | 900 | ldr $t1,[$tbl,$i1,lsl#2] @ Td1[s0>>16] |
903 | ldr $s0,[$tbl,$s0,lsl#2] @ Td0[s0>>24] | ||
904 | ldr $t2,[$tbl,$i2,lsl#2] @ Td2[s0>>8] | ||
905 | ldr $t3,[$tbl,$i3,lsl#2] @ Td3[s0>>0] | ||
906 | |||
907 | and $i1,lr,$s1 @ i0 | 901 | and $i1,lr,$s1 @ i0 |
902 | ldr $t2,[$tbl,$i2,lsl#2] @ Td2[s0>>8] | ||
908 | and $i2,lr,$s1,lsr#16 | 903 | and $i2,lr,$s1,lsr#16 |
904 | ldr $t3,[$tbl,$i3,lsl#2] @ Td3[s0>>0] | ||
909 | and $i3,lr,$s1,lsr#8 | 905 | and $i3,lr,$s1,lsr#8 |
906 | ldr $s0,[$tbl,$s0,lsl#2] @ Td0[s0>>24] | ||
910 | mov $s1,$s1,lsr#24 | 907 | mov $s1,$s1,lsr#24 |
908 | |||
911 | ldr $i1,[$tbl,$i1,lsl#2] @ Td3[s1>>0] | 909 | ldr $i1,[$tbl,$i1,lsl#2] @ Td3[s1>>0] |
912 | ldr $s1,[$tbl,$s1,lsl#2] @ Td0[s1>>24] | ||
913 | ldr $i2,[$tbl,$i2,lsl#2] @ Td1[s1>>16] | 910 | ldr $i2,[$tbl,$i2,lsl#2] @ Td1[s1>>16] |
914 | ldr $i3,[$tbl,$i3,lsl#2] @ Td2[s1>>8] | 911 | ldr $i3,[$tbl,$i3,lsl#2] @ Td2[s1>>8] |
915 | eor $s0,$s0,$i1,ror#24 | 912 | eor $s0,$s0,$i1,ror#24 |
916 | eor $s1,$s1,$t1,ror#8 | 913 | ldr $s1,[$tbl,$s1,lsl#2] @ Td0[s1>>24] |
917 | eor $t2,$i2,$t2,ror#8 | ||
918 | eor $t3,$i3,$t3,ror#8 | ||
919 | |||
920 | and $i1,lr,$s2,lsr#8 @ i0 | 914 | and $i1,lr,$s2,lsr#8 @ i0 |
915 | eor $t2,$i2,$t2,ror#8 | ||
921 | and $i2,lr,$s2 @ i1 | 916 | and $i2,lr,$s2 @ i1 |
917 | eor $t3,$i3,$t3,ror#8 | ||
922 | and $i3,lr,$s2,lsr#16 | 918 | and $i3,lr,$s2,lsr#16 |
923 | mov $s2,$s2,lsr#24 | 919 | eor $s1,$s1,$t1,ror#8 |
924 | ldr $i1,[$tbl,$i1,lsl#2] @ Td2[s2>>8] | 920 | ldr $i1,[$tbl,$i1,lsl#2] @ Td2[s2>>8] |
921 | mov $s2,$s2,lsr#24 | ||
922 | |||
925 | ldr $i2,[$tbl,$i2,lsl#2] @ Td3[s2>>0] | 923 | ldr $i2,[$tbl,$i2,lsl#2] @ Td3[s2>>0] |
926 | ldr $s2,[$tbl,$s2,lsl#2] @ Td0[s2>>24] | ||
927 | ldr $i3,[$tbl,$i3,lsl#2] @ Td1[s2>>16] | 924 | ldr $i3,[$tbl,$i3,lsl#2] @ Td1[s2>>16] |
928 | eor $s0,$s0,$i1,ror#16 | 925 | eor $s0,$s0,$i1,ror#16 |
929 | eor $s1,$s1,$i2,ror#24 | 926 | ldr $s2,[$tbl,$s2,lsl#2] @ Td0[s2>>24] |
930 | eor $s2,$s2,$t2,ror#8 | ||
931 | eor $t3,$i3,$t3,ror#8 | ||
932 | |||
933 | and $i1,lr,$s3,lsr#16 @ i0 | 927 | and $i1,lr,$s3,lsr#16 @ i0 |
928 | eor $s1,$s1,$i2,ror#24 | ||
934 | and $i2,lr,$s3,lsr#8 @ i1 | 929 | and $i2,lr,$s3,lsr#8 @ i1 |
930 | eor $t3,$i3,$t3,ror#8 | ||
935 | and $i3,lr,$s3 @ i2 | 931 | and $i3,lr,$s3 @ i2 |
936 | mov $s3,$s3,lsr#24 | 932 | eor $s2,$s2,$t2,ror#8 |
937 | ldr $i1,[$tbl,$i1,lsl#2] @ Td1[s3>>16] | 933 | ldr $i1,[$tbl,$i1,lsl#2] @ Td1[s3>>16] |
934 | mov $s3,$s3,lsr#24 | ||
935 | |||
938 | ldr $i2,[$tbl,$i2,lsl#2] @ Td2[s3>>8] | 936 | ldr $i2,[$tbl,$i2,lsl#2] @ Td2[s3>>8] |
939 | ldr $i3,[$tbl,$i3,lsl#2] @ Td3[s3>>0] | 937 | ldr $i3,[$tbl,$i3,lsl#2] @ Td3[s3>>0] |
940 | ldr $s3,[$tbl,$s3,lsl#2] @ Td0[s3>>24] | ||
941 | eor $s0,$s0,$i1,ror#8 | 938 | eor $s0,$s0,$i1,ror#8 |
939 | ldr $s3,[$tbl,$s3,lsl#2] @ Td0[s3>>24] | ||
942 | eor $s1,$s1,$i2,ror#16 | 940 | eor $s1,$s1,$i2,ror#16 |
943 | eor $s2,$s2,$i3,ror#24 | 941 | eor $s2,$s2,$i3,ror#24 |
942 | ldr $i1,[$key],#16 | ||
944 | eor $s3,$s3,$t3,ror#8 | 943 | eor $s3,$s3,$t3,ror#8 |
945 | 944 | ||
946 | ldr $t1,[$key],#16 | 945 | ldr $t1,[$key,#-12] |
947 | ldr $t2,[$key,#-12] | 946 | ldr $t2,[$key,#-8] |
948 | ldr $t3,[$key,#-8] | 947 | eor $s0,$s0,$i1 |
949 | ldr $i1,[$key,#-4] | 948 | ldr $t3,[$key,#-4] |
950 | eor $s0,$s0,$t1 | 949 | and $i1,lr,$s0,lsr#16 |
951 | eor $s1,$s1,$t2 | 950 | eor $s1,$s1,$t1 |
952 | eor $s2,$s2,$t3 | 951 | and $i2,lr,$s0,lsr#8 |
953 | eor $s3,$s3,$i1 | 952 | eor $s2,$s2,$t2 |
953 | and $i3,lr,$s0 | ||
954 | eor $s3,$s3,$t3 | ||
955 | mov $s0,$s0,lsr#24 | ||
954 | 956 | ||
955 | subs $rounds,$rounds,#1 | 957 | subs $rounds,$rounds,#1 |
956 | bne .Ldec_loop | 958 | bne .Ldec_loop |
957 | 959 | ||
958 | add $tbl,$tbl,#1024 | 960 | add $tbl,$tbl,#1024 |
959 | 961 | ||
960 | ldr $t1,[$tbl,#0] @ prefetch Td4 | 962 | ldr $t2,[$tbl,#0] @ prefetch Td4 |
961 | ldr $t2,[$tbl,#32] | 963 | ldr $t3,[$tbl,#32] |
962 | ldr $t3,[$tbl,#64] | 964 | ldr $t1,[$tbl,#64] |
963 | ldr $i1,[$tbl,#96] | 965 | ldr $t2,[$tbl,#96] |
964 | ldr $i2,[$tbl,#128] | 966 | ldr $t3,[$tbl,#128] |
965 | ldr $i3,[$tbl,#160] | 967 | ldr $t1,[$tbl,#160] |
966 | ldr $t1,[$tbl,#192] | 968 | ldr $t2,[$tbl,#192] |
967 | ldr $t2,[$tbl,#224] | 969 | ldr $t3,[$tbl,#224] |
968 | 970 | ||
969 | and $i1,lr,$s0,lsr#16 | 971 | ldrb $s0,[$tbl,$s0] @ Td4[s0>>24] |
970 | and $i2,lr,$s0,lsr#8 | ||
971 | and $i3,lr,$s0 | ||
972 | ldrb $s0,[$tbl,$s0,lsr#24] @ Td4[s0>>24] | ||
973 | ldrb $t1,[$tbl,$i1] @ Td4[s0>>16] | 972 | ldrb $t1,[$tbl,$i1] @ Td4[s0>>16] |
974 | ldrb $t2,[$tbl,$i2] @ Td4[s0>>8] | ||
975 | ldrb $t3,[$tbl,$i3] @ Td4[s0>>0] | ||
976 | |||
977 | and $i1,lr,$s1 @ i0 | 973 | and $i1,lr,$s1 @ i0 |
974 | ldrb $t2,[$tbl,$i2] @ Td4[s0>>8] | ||
978 | and $i2,lr,$s1,lsr#16 | 975 | and $i2,lr,$s1,lsr#16 |
976 | ldrb $t3,[$tbl,$i3] @ Td4[s0>>0] | ||
979 | and $i3,lr,$s1,lsr#8 | 977 | and $i3,lr,$s1,lsr#8 |
978 | |||
980 | ldrb $i1,[$tbl,$i1] @ Td4[s1>>0] | 979 | ldrb $i1,[$tbl,$i1] @ Td4[s1>>0] |
981 | ldrb $s1,[$tbl,$s1,lsr#24] @ Td4[s1>>24] | 980 | ldrb $s1,[$tbl,$s1,lsr#24] @ Td4[s1>>24] |
982 | ldrb $i2,[$tbl,$i2] @ Td4[s1>>16] | 981 | ldrb $i2,[$tbl,$i2] @ Td4[s1>>16] |
983 | ldrb $i3,[$tbl,$i3] @ Td4[s1>>8] | ||
984 | eor $s0,$i1,$s0,lsl#24 | 982 | eor $s0,$i1,$s0,lsl#24 |
983 | ldrb $i3,[$tbl,$i3] @ Td4[s1>>8] | ||
985 | eor $s1,$t1,$s1,lsl#8 | 984 | eor $s1,$t1,$s1,lsl#8 |
986 | eor $t2,$t2,$i2,lsl#8 | ||
987 | eor $t3,$t3,$i3,lsl#8 | ||
988 | |||
989 | and $i1,lr,$s2,lsr#8 @ i0 | 985 | and $i1,lr,$s2,lsr#8 @ i0 |
986 | eor $t2,$t2,$i2,lsl#8 | ||
990 | and $i2,lr,$s2 @ i1 | 987 | and $i2,lr,$s2 @ i1 |
991 | and $i3,lr,$s2,lsr#16 | 988 | eor $t3,$t3,$i3,lsl#8 |
992 | ldrb $i1,[$tbl,$i1] @ Td4[s2>>8] | 989 | ldrb $i1,[$tbl,$i1] @ Td4[s2>>8] |
990 | and $i3,lr,$s2,lsr#16 | ||
991 | |||
993 | ldrb $i2,[$tbl,$i2] @ Td4[s2>>0] | 992 | ldrb $i2,[$tbl,$i2] @ Td4[s2>>0] |
994 | ldrb $s2,[$tbl,$s2,lsr#24] @ Td4[s2>>24] | 993 | ldrb $s2,[$tbl,$s2,lsr#24] @ Td4[s2>>24] |
995 | ldrb $i3,[$tbl,$i3] @ Td4[s2>>16] | ||
996 | eor $s0,$s0,$i1,lsl#8 | 994 | eor $s0,$s0,$i1,lsl#8 |
995 | ldrb $i3,[$tbl,$i3] @ Td4[s2>>16] | ||
997 | eor $s1,$i2,$s1,lsl#16 | 996 | eor $s1,$i2,$s1,lsl#16 |
998 | eor $s2,$t2,$s2,lsl#16 | ||
999 | eor $t3,$t3,$i3,lsl#16 | ||
1000 | |||
1001 | and $i1,lr,$s3,lsr#16 @ i0 | 997 | and $i1,lr,$s3,lsr#16 @ i0 |
998 | eor $s2,$t2,$s2,lsl#16 | ||
1002 | and $i2,lr,$s3,lsr#8 @ i1 | 999 | and $i2,lr,$s3,lsr#8 @ i1 |
1003 | and $i3,lr,$s3 @ i2 | 1000 | eor $t3,$t3,$i3,lsl#16 |
1004 | ldrb $i1,[$tbl,$i1] @ Td4[s3>>16] | 1001 | ldrb $i1,[$tbl,$i1] @ Td4[s3>>16] |
1002 | and $i3,lr,$s3 @ i2 | ||
1003 | |||
1005 | ldrb $i2,[$tbl,$i2] @ Td4[s3>>8] | 1004 | ldrb $i2,[$tbl,$i2] @ Td4[s3>>8] |
1006 | ldrb $i3,[$tbl,$i3] @ Td4[s3>>0] | 1005 | ldrb $i3,[$tbl,$i3] @ Td4[s3>>0] |
1007 | ldrb $s3,[$tbl,$s3,lsr#24] @ Td4[s3>>24] | 1006 | ldrb $s3,[$tbl,$s3,lsr#24] @ Td4[s3>>24] |
1008 | eor $s0,$s0,$i1,lsl#16 | 1007 | eor $s0,$s0,$i1,lsl#16 |
1008 | ldr $i1,[$key,#0] | ||
1009 | eor $s1,$s1,$i2,lsl#8 | 1009 | eor $s1,$s1,$i2,lsl#8 |
1010 | ldr $t1,[$key,#4] | ||
1010 | eor $s2,$i3,$s2,lsl#8 | 1011 | eor $s2,$i3,$s2,lsl#8 |
1012 | ldr $t2,[$key,#8] | ||
1011 | eor $s3,$t3,$s3,lsl#24 | 1013 | eor $s3,$t3,$s3,lsl#24 |
1014 | ldr $t3,[$key,#12] | ||
1012 | 1015 | ||
1013 | ldr lr,[sp],#4 @ pop lr | 1016 | eor $s0,$s0,$i1 |
1014 | ldr $t1,[$key,#0] | 1017 | eor $s1,$s1,$t1 |
1015 | ldr $t2,[$key,#4] | 1018 | eor $s2,$s2,$t2 |
1016 | ldr $t3,[$key,#8] | 1019 | eor $s3,$s3,$t3 |
1017 | ldr $i1,[$key,#12] | ||
1018 | eor $s0,$s0,$t1 | ||
1019 | eor $s1,$s1,$t2 | ||
1020 | eor $s2,$s2,$t3 | ||
1021 | eor $s3,$s3,$i1 | ||
1022 | 1020 | ||
1023 | sub $tbl,$tbl,#1024 | 1021 | sub $tbl,$tbl,#1024 |
1024 | mov pc,lr @ return | 1022 | ldr pc,[sp],#4 @ pop and return |
1025 | .size _armv4_AES_decrypt,.-_armv4_AES_decrypt | 1023 | .size _armv4_AES_decrypt,.-_armv4_AES_decrypt |
1026 | .asciz "AES for ARMv4, CRYPTOGAMS by <appro\@openssl.org>" | 1024 | .asciz "AES for ARMv4, CRYPTOGAMS by <appro\@openssl.org>" |
1027 | .align 2 | 1025 | .align 2 |
@@ -1029,3 +1027,4 @@ ___ | |||
1029 | 1027 | ||
1030 | $code =~ s/\bbx\s+lr\b/.word\t0xe12fff1e/gm; # make it possible to compile with -march=armv4 | 1028 | $code =~ s/\bbx\s+lr\b/.word\t0xe12fff1e/gm; # make it possible to compile with -march=armv4 |
1031 | print $code; | 1029 | print $code; |
1030 | close STDOUT; # enforce flush | ||
diff --git a/src/lib/libcrypto/alphacpuid.pl b/src/lib/libcrypto/alphacpuid.pl new file mode 100644 index 0000000000..4b3cbb9827 --- /dev/null +++ b/src/lib/libcrypto/alphacpuid.pl | |||
@@ -0,0 +1,126 @@ | |||
1 | #!/usr/bin/env perl | ||
2 | print <<'___'; | ||
3 | .text | ||
4 | |||
5 | .set noat | ||
6 | |||
7 | .globl OPENSSL_cpuid_setup | ||
8 | .ent OPENSSL_cpuid_setup | ||
9 | OPENSSL_cpuid_setup: | ||
10 | .frame $30,0,$26 | ||
11 | .prologue 0 | ||
12 | ret ($26) | ||
13 | .end OPENSSL_cpuid_setup | ||
14 | |||
15 | .globl OPENSSL_wipe_cpu | ||
16 | .ent OPENSSL_wipe_cpu | ||
17 | OPENSSL_wipe_cpu: | ||
18 | .frame $30,0,$26 | ||
19 | .prologue 0 | ||
20 | clr $1 | ||
21 | clr $2 | ||
22 | clr $3 | ||
23 | clr $4 | ||
24 | clr $5 | ||
25 | clr $6 | ||
26 | clr $7 | ||
27 | clr $8 | ||
28 | clr $16 | ||
29 | clr $17 | ||
30 | clr $18 | ||
31 | clr $19 | ||
32 | clr $20 | ||
33 | clr $21 | ||
34 | clr $22 | ||
35 | clr $23 | ||
36 | clr $24 | ||
37 | clr $25 | ||
38 | clr $27 | ||
39 | clr $at | ||
40 | clr $29 | ||
41 | fclr $f0 | ||
42 | fclr $f1 | ||
43 | fclr $f10 | ||
44 | fclr $f11 | ||
45 | fclr $f12 | ||
46 | fclr $f13 | ||
47 | fclr $f14 | ||
48 | fclr $f15 | ||
49 | fclr $f16 | ||
50 | fclr $f17 | ||
51 | fclr $f18 | ||
52 | fclr $f19 | ||
53 | fclr $f20 | ||
54 | fclr $f21 | ||
55 | fclr $f22 | ||
56 | fclr $f23 | ||
57 | fclr $f24 | ||
58 | fclr $f25 | ||
59 | fclr $f26 | ||
60 | fclr $f27 | ||
61 | fclr $f28 | ||
62 | fclr $f29 | ||
63 | fclr $f30 | ||
64 | mov $sp,$0 | ||
65 | ret ($26) | ||
66 | .end OPENSSL_wipe_cpu | ||
67 | |||
68 | .globl OPENSSL_atomic_add | ||
69 | .ent OPENSSL_atomic_add | ||
70 | OPENSSL_atomic_add: | ||
71 | .frame $30,0,$26 | ||
72 | .prologue 0 | ||
73 | 1: ldl_l $0,0($16) | ||
74 | addl $0,$17,$1 | ||
75 | stl_c $1,0($16) | ||
76 | beq $1,1b | ||
77 | addl $0,$17,$0 | ||
78 | ret ($26) | ||
79 | .end OPENSSL_atomic_add | ||
80 | |||
81 | .globl OPENSSL_rdtsc | ||
82 | .ent OPENSSL_rdtsc | ||
83 | OPENSSL_rdtsc: | ||
84 | .frame $30,0,$26 | ||
85 | .prologue 0 | ||
86 | rpcc $0 | ||
87 | ret ($26) | ||
88 | .end OPENSSL_rdtsc | ||
89 | |||
90 | .globl OPENSSL_cleanse | ||
91 | .ent OPENSSL_cleanse | ||
92 | OPENSSL_cleanse: | ||
93 | .frame $30,0,$26 | ||
94 | .prologue 0 | ||
95 | beq $17,.Ldone | ||
96 | and $16,7,$0 | ||
97 | bic $17,7,$at | ||
98 | beq $at,.Little | ||
99 | beq $0,.Laligned | ||
100 | |||
101 | .Little: | ||
102 | subq $0,8,$0 | ||
103 | ldq_u $1,0($16) | ||
104 | mov $16,$2 | ||
105 | .Lalign: | ||
106 | mskbl $1,$16,$1 | ||
107 | lda $16,1($16) | ||
108 | subq $17,1,$17 | ||
109 | addq $0,1,$0 | ||
110 | beq $17,.Lout | ||
111 | bne $0,.Lalign | ||
112 | .Lout: stq_u $1,0($2) | ||
113 | beq $17,.Ldone | ||
114 | bic $17,7,$at | ||
115 | beq $at,.Little | ||
116 | |||
117 | .Laligned: | ||
118 | stq $31,0($16) | ||
119 | subq $17,8,$17 | ||
120 | lda $16,8($16) | ||
121 | bic $17,7,$at | ||
122 | bne $at,.Laligned | ||
123 | bne $17,.Little | ||
124 | .Ldone: ret ($26) | ||
125 | .end OPENSSL_cleanse | ||
126 | ___ | ||
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c index c6fd204ae3..3348b8762c 100644 --- a/src/lib/libcrypto/asn1/a_int.c +++ b/src/lib/libcrypto/asn1/a_int.c | |||
@@ -273,7 +273,7 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, | |||
273 | { | 273 | { |
274 | ASN1_INTEGER *ret=NULL; | 274 | ASN1_INTEGER *ret=NULL; |
275 | const unsigned char *p; | 275 | const unsigned char *p; |
276 | unsigned char *to,*s; | 276 | unsigned char *s; |
277 | long len; | 277 | long len; |
278 | int inf,tag,xclass; | 278 | int inf,tag,xclass; |
279 | int i; | 279 | int i; |
@@ -308,7 +308,6 @@ ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, | |||
308 | i=ERR_R_MALLOC_FAILURE; | 308 | i=ERR_R_MALLOC_FAILURE; |
309 | goto err; | 309 | goto err; |
310 | } | 310 | } |
311 | to=s; | ||
312 | ret->type=V_ASN1_INTEGER; | 311 | ret->type=V_ASN1_INTEGER; |
313 | if(len) { | 312 | if(len) { |
314 | if ((*p == 0) && (len != 1)) | 313 | if ((*p == 0) && (len != 1)) |
diff --git a/src/lib/libcrypto/asn1/a_object.c b/src/lib/libcrypto/asn1/a_object.c index e5fbe7cbb1..3978c9150d 100644 --- a/src/lib/libcrypto/asn1/a_object.c +++ b/src/lib/libcrypto/asn1/a_object.c | |||
@@ -139,7 +139,7 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num) | |||
139 | ASN1err(ASN1_F_A2D_ASN1_OBJECT,ASN1_R_INVALID_DIGIT); | 139 | ASN1err(ASN1_F_A2D_ASN1_OBJECT,ASN1_R_INVALID_DIGIT); |
140 | goto err; | 140 | goto err; |
141 | } | 141 | } |
142 | if (!use_bn && l > (ULONG_MAX / 10L)) | 142 | if (!use_bn && l >= ((ULONG_MAX - 80) / 10L)) |
143 | { | 143 | { |
144 | use_bn = 1; | 144 | use_bn = 1; |
145 | if (!bl) | 145 | if (!bl) |
@@ -293,7 +293,7 @@ ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, | |||
293 | /* Sanity check OID encoding: can't have leading 0x80 in | 293 | /* Sanity check OID encoding: can't have leading 0x80 in |
294 | * subidentifiers, see: X.690 8.19.2 | 294 | * subidentifiers, see: X.690 8.19.2 |
295 | */ | 295 | */ |
296 | for (i = 0, p = *pp + 1; i < len - 1; i++, p++) | 296 | for (i = 0, p = *pp; i < len; i++, p++) |
297 | { | 297 | { |
298 | if (*p == 0x80 && (!i || !(p[-1] & 0x80))) | 298 | if (*p == 0x80 && (!i || !(p[-1] & 0x80))) |
299 | { | 299 | { |
diff --git a/src/lib/libcrypto/asn1/a_strex.c b/src/lib/libcrypto/asn1/a_strex.c index 7fc14d3296..264ebf2393 100644 --- a/src/lib/libcrypto/asn1/a_strex.c +++ b/src/lib/libcrypto/asn1/a_strex.c | |||
@@ -74,6 +74,11 @@ | |||
74 | 74 | ||
75 | #define CHARTYPE_BS_ESC (ASN1_STRFLGS_ESC_2253 | CHARTYPE_FIRST_ESC_2253 | CHARTYPE_LAST_ESC_2253) | 75 | #define CHARTYPE_BS_ESC (ASN1_STRFLGS_ESC_2253 | CHARTYPE_FIRST_ESC_2253 | CHARTYPE_LAST_ESC_2253) |
76 | 76 | ||
77 | #define ESC_FLAGS (ASN1_STRFLGS_ESC_2253 | \ | ||
78 | ASN1_STRFLGS_ESC_QUOTE | \ | ||
79 | ASN1_STRFLGS_ESC_CTRL | \ | ||
80 | ASN1_STRFLGS_ESC_MSB) | ||
81 | |||
77 | 82 | ||
78 | /* Three IO functions for sending data to memory, a BIO and | 83 | /* Three IO functions for sending data to memory, a BIO and |
79 | * and a FILE pointer. | 84 | * and a FILE pointer. |
@@ -148,6 +153,13 @@ static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, ch | |||
148 | if(!io_ch(arg, tmphex, 3)) return -1; | 153 | if(!io_ch(arg, tmphex, 3)) return -1; |
149 | return 3; | 154 | return 3; |
150 | } | 155 | } |
156 | /* If we get this far and do any escaping at all must escape | ||
157 | * the escape character itself: backslash. | ||
158 | */ | ||
159 | if (chtmp == '\\' && flags & ESC_FLAGS) { | ||
160 | if(!io_ch(arg, "\\\\", 2)) return -1; | ||
161 | return 2; | ||
162 | } | ||
151 | if(!io_ch(arg, &chtmp, 1)) return -1; | 163 | if(!io_ch(arg, &chtmp, 1)) return -1; |
152 | return 1; | 164 | return 1; |
153 | } | 165 | } |
@@ -292,11 +304,6 @@ static const signed char tag2nbyte[] = { | |||
292 | 4, -1, 2 /* 28-30 */ | 304 | 4, -1, 2 /* 28-30 */ |
293 | }; | 305 | }; |
294 | 306 | ||
295 | #define ESC_FLAGS (ASN1_STRFLGS_ESC_2253 | \ | ||
296 | ASN1_STRFLGS_ESC_QUOTE | \ | ||
297 | ASN1_STRFLGS_ESC_CTRL | \ | ||
298 | ASN1_STRFLGS_ESC_MSB) | ||
299 | |||
300 | /* This is the main function, print out an | 307 | /* This is the main function, print out an |
301 | * ASN1_STRING taking note of various escape | 308 | * ASN1_STRING taking note of various escape |
302 | * and display options. Returns number of | 309 | * and display options. Returns number of |
diff --git a/src/lib/libcrypto/asn1/a_strnid.c b/src/lib/libcrypto/asn1/a_strnid.c index 753021a7a2..2fc48c1551 100644 --- a/src/lib/libcrypto/asn1/a_strnid.c +++ b/src/lib/libcrypto/asn1/a_strnid.c | |||
@@ -95,7 +95,7 @@ unsigned long ASN1_STRING_get_default_mask(void) | |||
95 | * default: the default value, Printable, T61, BMP. | 95 | * default: the default value, Printable, T61, BMP. |
96 | */ | 96 | */ |
97 | 97 | ||
98 | int ASN1_STRING_set_default_mask_asc(char *p) | 98 | int ASN1_STRING_set_default_mask_asc(const char *p) |
99 | { | 99 | { |
100 | unsigned long mask; | 100 | unsigned long mask; |
101 | char *end; | 101 | char *end; |
diff --git a/src/lib/libcrypto/asn1/ameth_lib.c b/src/lib/libcrypto/asn1/ameth_lib.c index 9a8b6cc222..5a581b90ea 100644 --- a/src/lib/libcrypto/asn1/ameth_lib.c +++ b/src/lib/libcrypto/asn1/ameth_lib.c | |||
@@ -172,7 +172,6 @@ static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type) | |||
172 | const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type) | 172 | const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type) |
173 | { | 173 | { |
174 | const EVP_PKEY_ASN1_METHOD *t; | 174 | const EVP_PKEY_ASN1_METHOD *t; |
175 | ENGINE *e; | ||
176 | 175 | ||
177 | for (;;) | 176 | for (;;) |
178 | { | 177 | { |
@@ -184,6 +183,7 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type) | |||
184 | if (pe) | 183 | if (pe) |
185 | { | 184 | { |
186 | #ifndef OPENSSL_NO_ENGINE | 185 | #ifndef OPENSSL_NO_ENGINE |
186 | ENGINE *e; | ||
187 | /* type will contain the final unaliased type */ | 187 | /* type will contain the final unaliased type */ |
188 | e = ENGINE_get_pkey_asn1_meth_engine(type); | 188 | e = ENGINE_get_pkey_asn1_meth_engine(type); |
189 | if (e) | 189 | if (e) |
diff --git a/src/lib/libcrypto/asn1/asn1.h b/src/lib/libcrypto/asn1/asn1.h index f7718b5a94..59540e4e79 100644 --- a/src/lib/libcrypto/asn1/asn1.h +++ b/src/lib/libcrypto/asn1/asn1.h | |||
@@ -1067,7 +1067,7 @@ ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, | |||
1067 | ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct); | 1067 | ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct); |
1068 | 1068 | ||
1069 | void ASN1_STRING_set_default_mask(unsigned long mask); | 1069 | void ASN1_STRING_set_default_mask(unsigned long mask); |
1070 | int ASN1_STRING_set_default_mask_asc(char *p); | 1070 | int ASN1_STRING_set_default_mask_asc(const char *p); |
1071 | unsigned long ASN1_STRING_get_default_mask(void); | 1071 | unsigned long ASN1_STRING_get_default_mask(void); |
1072 | int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, | 1072 | int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, |
1073 | int inform, unsigned long mask); | 1073 | int inform, unsigned long mask); |
diff --git a/src/lib/libcrypto/asn1/bio_ndef.c b/src/lib/libcrypto/asn1/bio_ndef.c index 370389b1e6..b91f97a1b1 100644 --- a/src/lib/libcrypto/asn1/bio_ndef.c +++ b/src/lib/libcrypto/asn1/bio_ndef.c | |||
@@ -57,9 +57,6 @@ | |||
57 | #include <openssl/bio.h> | 57 | #include <openssl/bio.h> |
58 | #include <openssl/err.h> | 58 | #include <openssl/err.h> |
59 | 59 | ||
60 | #ifndef OPENSSL_SYSNAME_NETWARE | ||
61 | #include <memory.h> | ||
62 | #endif | ||
63 | #include <stdio.h> | 60 | #include <stdio.h> |
64 | 61 | ||
65 | /* Experimental NDEF ASN1 BIO support routines */ | 62 | /* Experimental NDEF ASN1 BIO support routines */ |
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c index 60bc437938..e7d0439062 100644 --- a/src/lib/libcrypto/asn1/n_pkey.c +++ b/src/lib/libcrypto/asn1/n_pkey.c | |||
@@ -242,7 +242,7 @@ RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, | |||
242 | int sgckey) | 242 | int sgckey) |
243 | { | 243 | { |
244 | RSA *ret=NULL; | 244 | RSA *ret=NULL; |
245 | const unsigned char *p, *kp; | 245 | const unsigned char *p; |
246 | NETSCAPE_ENCRYPTED_PKEY *enckey = NULL; | 246 | NETSCAPE_ENCRYPTED_PKEY *enckey = NULL; |
247 | 247 | ||
248 | p = *pp; | 248 | p = *pp; |
@@ -265,7 +265,6 @@ RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, | |||
265 | ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM); | 265 | ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM); |
266 | goto err; | 266 | goto err; |
267 | } | 267 | } |
268 | kp = enckey->enckey->digest->data; | ||
269 | if (cb == NULL) | 268 | if (cb == NULL) |
270 | cb=EVP_read_pw_string; | 269 | cb=EVP_read_pw_string; |
271 | if ((ret=d2i_RSA_NET_2(a, enckey->enckey->digest,cb, sgckey)) == NULL) goto err; | 270 | if ((ret=d2i_RSA_NET_2(a, enckey->enckey->digest,cb, sgckey)) == NULL) goto err; |
diff --git a/src/lib/libcrypto/asn1/t_crl.c b/src/lib/libcrypto/asn1/t_crl.c index bdb244c015..ee5a687ce8 100644 --- a/src/lib/libcrypto/asn1/t_crl.c +++ b/src/lib/libcrypto/asn1/t_crl.c | |||
@@ -87,7 +87,7 @@ int X509_CRL_print(BIO *out, X509_CRL *x) | |||
87 | STACK_OF(X509_REVOKED) *rev; | 87 | STACK_OF(X509_REVOKED) *rev; |
88 | X509_REVOKED *r; | 88 | X509_REVOKED *r; |
89 | long l; | 89 | long l; |
90 | int i, n; | 90 | int i; |
91 | char *p; | 91 | char *p; |
92 | 92 | ||
93 | BIO_printf(out, "Certificate Revocation List (CRL):\n"); | 93 | BIO_printf(out, "Certificate Revocation List (CRL):\n"); |
@@ -107,7 +107,6 @@ int X509_CRL_print(BIO *out, X509_CRL *x) | |||
107 | else BIO_printf(out,"NONE"); | 107 | else BIO_printf(out,"NONE"); |
108 | BIO_printf(out,"\n"); | 108 | BIO_printf(out,"\n"); |
109 | 109 | ||
110 | n=X509_CRL_get_ext_count(x); | ||
111 | X509V3_extensions_print(out, "CRL extensions", | 110 | X509V3_extensions_print(out, "CRL extensions", |
112 | x->crl->extensions, 0, 8); | 111 | x->crl->extensions, 0, 8); |
113 | 112 | ||
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c index 3bee439968..87d7dfdf5c 100644 --- a/src/lib/libcrypto/asn1/tasn_dec.c +++ b/src/lib/libcrypto/asn1/tasn_dec.c | |||
@@ -168,7 +168,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
168 | int i; | 168 | int i; |
169 | int otag; | 169 | int otag; |
170 | int ret = 0; | 170 | int ret = 0; |
171 | ASN1_VALUE *pchval, **pchptr, *ptmpval; | 171 | ASN1_VALUE **pchptr, *ptmpval; |
172 | if (!pval) | 172 | if (!pval) |
173 | return 0; | 173 | return 0; |
174 | if (aux && aux->asn1_cb) | 174 | if (aux && aux->asn1_cb) |
@@ -319,7 +319,6 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | |||
319 | goto err; | 319 | goto err; |
320 | } | 320 | } |
321 | /* CHOICE type, try each possibility in turn */ | 321 | /* CHOICE type, try each possibility in turn */ |
322 | pchval = NULL; | ||
323 | p = *in; | 322 | p = *in; |
324 | for (i = 0, tt=it->templates; i < it->tcount; i++, tt++) | 323 | for (i = 0, tt=it->templates; i < it->tcount; i++, tt++) |
325 | { | 324 | { |
diff --git a/src/lib/libcrypto/asn1/x_name.c b/src/lib/libcrypto/asn1/x_name.c index caa4409feb..49be08b4da 100644 --- a/src/lib/libcrypto/asn1/x_name.c +++ b/src/lib/libcrypto/asn1/x_name.c | |||
@@ -214,7 +214,9 @@ static int x509_name_ex_d2i(ASN1_VALUE **val, | |||
214 | *val = nm.a; | 214 | *val = nm.a; |
215 | *in = p; | 215 | *in = p; |
216 | return ret; | 216 | return ret; |
217 | err: | 217 | err: |
218 | if (nm.x != NULL) | ||
219 | X509_NAME_free(nm.x); | ||
218 | ASN1err(ASN1_F_X509_NAME_EX_D2I, ERR_R_NESTED_ASN1_ERROR); | 220 | ASN1err(ASN1_F_X509_NAME_EX_D2I, ERR_R_NESTED_ASN1_ERROR); |
219 | return 0; | 221 | return 0; |
220 | } | 222 | } |
@@ -464,7 +466,8 @@ static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in) | |||
464 | } | 466 | } |
465 | else | 467 | else |
466 | { | 468 | { |
467 | *to++ = tolower(*from++); | 469 | *to++ = tolower(*from); |
470 | from++; | ||
468 | i++; | 471 | i++; |
469 | } | 472 | } |
470 | } | 473 | } |
diff --git a/src/lib/libcrypto/asn1/x_x509.c b/src/lib/libcrypto/asn1/x_x509.c index dafd3cc921..de3df9eb51 100644 --- a/src/lib/libcrypto/asn1/x_x509.c +++ b/src/lib/libcrypto/asn1/x_x509.c | |||
@@ -63,7 +63,7 @@ | |||
63 | #include <openssl/x509.h> | 63 | #include <openssl/x509.h> |
64 | #include <openssl/x509v3.h> | 64 | #include <openssl/x509v3.h> |
65 | 65 | ||
66 | ASN1_SEQUENCE(X509_CINF) = { | 66 | ASN1_SEQUENCE_enc(X509_CINF, enc, 0) = { |
67 | ASN1_EXP_OPT(X509_CINF, version, ASN1_INTEGER, 0), | 67 | ASN1_EXP_OPT(X509_CINF, version, ASN1_INTEGER, 0), |
68 | ASN1_SIMPLE(X509_CINF, serialNumber, ASN1_INTEGER), | 68 | ASN1_SIMPLE(X509_CINF, serialNumber, ASN1_INTEGER), |
69 | ASN1_SIMPLE(X509_CINF, signature, X509_ALGOR), | 69 | ASN1_SIMPLE(X509_CINF, signature, X509_ALGOR), |
@@ -74,7 +74,7 @@ ASN1_SEQUENCE(X509_CINF) = { | |||
74 | ASN1_IMP_OPT(X509_CINF, issuerUID, ASN1_BIT_STRING, 1), | 74 | ASN1_IMP_OPT(X509_CINF, issuerUID, ASN1_BIT_STRING, 1), |
75 | ASN1_IMP_OPT(X509_CINF, subjectUID, ASN1_BIT_STRING, 2), | 75 | ASN1_IMP_OPT(X509_CINF, subjectUID, ASN1_BIT_STRING, 2), |
76 | ASN1_EXP_SEQUENCE_OF_OPT(X509_CINF, extensions, X509_EXTENSION, 3) | 76 | ASN1_EXP_SEQUENCE_OF_OPT(X509_CINF, extensions, X509_EXTENSION, 3) |
77 | } ASN1_SEQUENCE_END(X509_CINF) | 77 | } ASN1_SEQUENCE_END_enc(X509_CINF, X509_CINF) |
78 | 78 | ||
79 | IMPLEMENT_ASN1_FUNCTIONS(X509_CINF) | 79 | IMPLEMENT_ASN1_FUNCTIONS(X509_CINF) |
80 | /* X509 top level structure needs a bit of customisation */ | 80 | /* X509 top level structure needs a bit of customisation */ |
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index 12b0a53a81..d47310d650 100644 --- a/src/lib/libcrypto/bio/b_sock.c +++ b/src/lib/libcrypto/bio/b_sock.c | |||
@@ -551,7 +551,30 @@ int BIO_socket_ioctl(int fd, long type, void *arg) | |||
551 | #ifdef __DJGPP__ | 551 | #ifdef __DJGPP__ |
552 | i=ioctlsocket(fd,type,(char *)arg); | 552 | i=ioctlsocket(fd,type,(char *)arg); |
553 | #else | 553 | #else |
554 | i=ioctlsocket(fd,type,arg); | 554 | # if defined(OPENSSL_SYS_VMS) |
555 | /* 2011-02-18 SMS. | ||
556 | * VMS ioctl() can't tolerate a 64-bit "void *arg", but we | ||
557 | * observe that all the consumers pass in an "unsigned long *", | ||
558 | * so we arrange a local copy with a short pointer, and use | ||
559 | * that, instead. | ||
560 | */ | ||
561 | # if __INITIAL_POINTER_SIZE == 64 | ||
562 | # define ARG arg_32p | ||
563 | # pragma pointer_size save | ||
564 | # pragma pointer_size 32 | ||
565 | unsigned long arg_32; | ||
566 | unsigned long *arg_32p; | ||
567 | # pragma pointer_size restore | ||
568 | arg_32p = &arg_32; | ||
569 | arg_32 = *((unsigned long *) arg); | ||
570 | # else /* __INITIAL_POINTER_SIZE == 64 */ | ||
571 | # define ARG arg | ||
572 | # endif /* __INITIAL_POINTER_SIZE == 64 [else] */ | ||
573 | # else /* defined(OPENSSL_SYS_VMS) */ | ||
574 | # define ARG arg | ||
575 | # endif /* defined(OPENSSL_SYS_VMS) [else] */ | ||
576 | |||
577 | i=ioctlsocket(fd,type,ARG); | ||
555 | #endif /* __DJGPP__ */ | 578 | #endif /* __DJGPP__ */ |
556 | if (i < 0) | 579 | if (i < 0) |
557 | SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error()); | 580 | SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error()); |
@@ -660,6 +683,7 @@ int BIO_get_accept_socket(char *host, int bind_mode) | |||
660 | * note that commonly IPv6 wildchard socket can service | 683 | * note that commonly IPv6 wildchard socket can service |
661 | * IPv4 connections just as well... */ | 684 | * IPv4 connections just as well... */ |
662 | memset(&hint,0,sizeof(hint)); | 685 | memset(&hint,0,sizeof(hint)); |
686 | hint.ai_flags = AI_PASSIVE; | ||
663 | if (h) | 687 | if (h) |
664 | { | 688 | { |
665 | if (strchr(h,':')) | 689 | if (strchr(h,':')) |
@@ -672,7 +696,10 @@ int BIO_get_accept_socket(char *host, int bind_mode) | |||
672 | #endif | 696 | #endif |
673 | } | 697 | } |
674 | else if (h[0]=='*' && h[1]=='\0') | 698 | else if (h[0]=='*' && h[1]=='\0') |
699 | { | ||
700 | hint.ai_family = AF_INET; | ||
675 | h=NULL; | 701 | h=NULL; |
702 | } | ||
676 | } | 703 | } |
677 | 704 | ||
678 | if ((*p_getaddrinfo.f)(h,p,&hint,&res)) break; | 705 | if ((*p_getaddrinfo.f)(h,p,&hint,&res)) break; |
diff --git a/src/lib/libcrypto/bio/bf_nbio.c b/src/lib/libcrypto/bio/bf_nbio.c index c72a23c2e1..028616c064 100644 --- a/src/lib/libcrypto/bio/bf_nbio.c +++ b/src/lib/libcrypto/bio/bf_nbio.c | |||
@@ -125,7 +125,6 @@ static int nbiof_free(BIO *a) | |||
125 | 125 | ||
126 | static int nbiof_read(BIO *b, char *out, int outl) | 126 | static int nbiof_read(BIO *b, char *out, int outl) |
127 | { | 127 | { |
128 | NBIO_TEST *nt; | ||
129 | int ret=0; | 128 | int ret=0; |
130 | #if 1 | 129 | #if 1 |
131 | int num; | 130 | int num; |
@@ -134,7 +133,6 @@ static int nbiof_read(BIO *b, char *out, int outl) | |||
134 | 133 | ||
135 | if (out == NULL) return(0); | 134 | if (out == NULL) return(0); |
136 | if (b->next_bio == NULL) return(0); | 135 | if (b->next_bio == NULL) return(0); |
137 | nt=(NBIO_TEST *)b->ptr; | ||
138 | 136 | ||
139 | BIO_clear_retry_flags(b); | 137 | BIO_clear_retry_flags(b); |
140 | #if 1 | 138 | #if 1 |
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c index 77f4de9c32..e12bc3a2ca 100644 --- a/src/lib/libcrypto/bio/bio_lib.c +++ b/src/lib/libcrypto/bio/bio_lib.c | |||
@@ -110,7 +110,7 @@ int BIO_set(BIO *bio, BIO_METHOD *method) | |||
110 | 110 | ||
111 | int BIO_free(BIO *a) | 111 | int BIO_free(BIO *a) |
112 | { | 112 | { |
113 | int ret=0,i; | 113 | int i; |
114 | 114 | ||
115 | if (a == NULL) return(0); | 115 | if (a == NULL) return(0); |
116 | 116 | ||
@@ -133,7 +133,7 @@ int BIO_free(BIO *a) | |||
133 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data); | 133 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data); |
134 | 134 | ||
135 | if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); | 135 | if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); |
136 | ret=a->method->destroy(a); | 136 | a->method->destroy(a); |
137 | OPENSSL_free(a); | 137 | OPENSSL_free(a); |
138 | return(1); | 138 | return(1); |
139 | } | 139 | } |
diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c index 826f761143..5d49e1a72b 100644 --- a/src/lib/libcrypto/bio/bss_acpt.c +++ b/src/lib/libcrypto/bio/bss_acpt.c | |||
@@ -340,7 +340,6 @@ static int acpt_write(BIO *b, const char *in, int inl) | |||
340 | 340 | ||
341 | static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) | 341 | static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) |
342 | { | 342 | { |
343 | BIO *dbio; | ||
344 | int *ip; | 343 | int *ip; |
345 | long ret=1; | 344 | long ret=1; |
346 | BIO_ACCEPT *data; | 345 | BIO_ACCEPT *data; |
@@ -437,8 +436,8 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
437 | ret=(long)data->bind_mode; | 436 | ret=(long)data->bind_mode; |
438 | break; | 437 | break; |
439 | case BIO_CTRL_DUP: | 438 | case BIO_CTRL_DUP: |
440 | dbio=(BIO *)ptr; | 439 | /* dbio=(BIO *)ptr; |
441 | /* if (data->param_port) EAY EAY | 440 | if (data->param_port) EAY EAY |
442 | BIO_set_port(dbio,data->param_port); | 441 | BIO_set_port(dbio,data->param_port); |
443 | if (data->param_hostname) | 442 | if (data->param_hostname) |
444 | BIO_set_hostname(dbio,data->param_hostname); | 443 | BIO_set_hostname(dbio,data->param_hostname); |
diff --git a/src/lib/libcrypto/bio/bss_dgram.c b/src/lib/libcrypto/bio/bss_dgram.c index eb7e365467..71ebe987b6 100644 --- a/src/lib/libcrypto/bio/bss_dgram.c +++ b/src/lib/libcrypto/bio/bss_dgram.c | |||
@@ -57,7 +57,6 @@ | |||
57 | * | 57 | * |
58 | */ | 58 | */ |
59 | 59 | ||
60 | #ifndef OPENSSL_NO_DGRAM | ||
61 | 60 | ||
62 | #include <stdio.h> | 61 | #include <stdio.h> |
63 | #include <errno.h> | 62 | #include <errno.h> |
@@ -65,6 +64,7 @@ | |||
65 | #include "cryptlib.h" | 64 | #include "cryptlib.h" |
66 | 65 | ||
67 | #include <openssl/bio.h> | 66 | #include <openssl/bio.h> |
67 | #ifndef OPENSSL_NO_DGRAM | ||
68 | 68 | ||
69 | #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) | 69 | #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) |
70 | #include <sys/timeb.h> | 70 | #include <sys/timeb.h> |
@@ -308,7 +308,6 @@ static int dgram_read(BIO *b, char *out, int outl) | |||
308 | OPENSSL_assert(sa.len.s<=sizeof(sa.peer)); | 308 | OPENSSL_assert(sa.len.s<=sizeof(sa.peer)); |
309 | sa.len.i = (int)sa.len.s; | 309 | sa.len.i = (int)sa.len.s; |
310 | } | 310 | } |
311 | dgram_reset_rcv_timeout(b); | ||
312 | 311 | ||
313 | if ( ! data->connected && ret >= 0) | 312 | if ( ! data->connected && ret >= 0) |
314 | BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer); | 313 | BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer); |
@@ -322,6 +321,8 @@ static int dgram_read(BIO *b, char *out, int outl) | |||
322 | data->_errno = get_last_socket_error(); | 321 | data->_errno = get_last_socket_error(); |
323 | } | 322 | } |
324 | } | 323 | } |
324 | |||
325 | dgram_reset_rcv_timeout(b); | ||
325 | } | 326 | } |
326 | return(ret); | 327 | return(ret); |
327 | } | 328 | } |
@@ -340,7 +341,7 @@ static int dgram_write(BIO *b, const char *in, int inl) | |||
340 | 341 | ||
341 | if (data->peer.sa.sa_family == AF_INET) | 342 | if (data->peer.sa.sa_family == AF_INET) |
342 | peerlen = sizeof(data->peer.sa_in); | 343 | peerlen = sizeof(data->peer.sa_in); |
343 | #if OPENSSL_USE_IVP6 | 344 | #if OPENSSL_USE_IPV6 |
344 | else if (data->peer.sa.sa_family == AF_INET6) | 345 | else if (data->peer.sa.sa_family == AF_INET6) |
345 | peerlen = sizeof(data->peer.sa_in6); | 346 | peerlen = sizeof(data->peer.sa_in6); |
346 | #endif | 347 | #endif |
@@ -745,9 +746,13 @@ static int BIO_dgram_should_retry(int i) | |||
745 | { | 746 | { |
746 | err=get_last_socket_error(); | 747 | err=get_last_socket_error(); |
747 | 748 | ||
748 | #if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ | 749 | #if defined(OPENSSL_SYS_WINDOWS) |
749 | if ((i == -1) && (err == 0)) | 750 | /* If the socket return value (i) is -1 |
750 | return(1); | 751 | * and err is unexpectedly 0 at this point, |
752 | * the error code was overwritten by | ||
753 | * another system call before this error | ||
754 | * handling is called. | ||
755 | */ | ||
751 | #endif | 756 | #endif |
752 | 757 | ||
753 | return(BIO_dgram_non_fatal_error(err)); | 758 | return(BIO_dgram_non_fatal_error(err)); |
@@ -810,7 +815,6 @@ int BIO_dgram_non_fatal_error(int err) | |||
810 | } | 815 | } |
811 | return(0); | 816 | return(0); |
812 | } | 817 | } |
813 | #endif | ||
814 | 818 | ||
815 | static void get_current_time(struct timeval *t) | 819 | static void get_current_time(struct timeval *t) |
816 | { | 820 | { |
@@ -828,3 +832,5 @@ static void get_current_time(struct timeval *t) | |||
828 | gettimeofday(t, NULL); | 832 | gettimeofday(t, NULL); |
829 | #endif | 833 | #endif |
830 | } | 834 | } |
835 | |||
836 | #endif | ||
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c index 8bfa0bcd97..b954fe7ebc 100644 --- a/src/lib/libcrypto/bio/bss_file.c +++ b/src/lib/libcrypto/bio/bss_file.c | |||
@@ -123,6 +123,7 @@ BIO *BIO_new_file(const char *filename, const char *mode) | |||
123 | 123 | ||
124 | #if defined(_WIN32) && defined(CP_UTF8) | 124 | #if defined(_WIN32) && defined(CP_UTF8) |
125 | int sz, len_0 = (int)strlen(filename)+1; | 125 | int sz, len_0 = (int)strlen(filename)+1; |
126 | DWORD flags; | ||
126 | 127 | ||
127 | /* | 128 | /* |
128 | * Basically there are three cases to cover: a) filename is | 129 | * Basically there are three cases to cover: a) filename is |
@@ -136,17 +137,22 @@ BIO *BIO_new_file(const char *filename, const char *mode) | |||
136 | * ERROR_NO_UNICODE_TRANSLATION, in which case we fall | 137 | * ERROR_NO_UNICODE_TRANSLATION, in which case we fall |
137 | * back to fopen... | 138 | * back to fopen... |
138 | */ | 139 | */ |
139 | if ((sz=MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS, | 140 | if ((sz=MultiByteToWideChar(CP_UTF8,(flags=MB_ERR_INVALID_CHARS), |
141 | filename,len_0,NULL,0))>0 || | ||
142 | (GetLastError()==ERROR_INVALID_FLAGS && | ||
143 | (sz=MultiByteToWideChar(CP_UTF8,(flags=0), | ||
140 | filename,len_0,NULL,0))>0) | 144 | filename,len_0,NULL,0))>0) |
145 | ) | ||
141 | { | 146 | { |
142 | WCHAR wmode[8]; | 147 | WCHAR wmode[8]; |
143 | WCHAR *wfilename = _alloca(sz*sizeof(WCHAR)); | 148 | WCHAR *wfilename = _alloca(sz*sizeof(WCHAR)); |
144 | 149 | ||
145 | if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS, | 150 | if (MultiByteToWideChar(CP_UTF8,flags, |
146 | filename,len_0,wfilename,sz) && | 151 | filename,len_0,wfilename,sz) && |
147 | MultiByteToWideChar(CP_UTF8,0,mode,strlen(mode)+1, | 152 | MultiByteToWideChar(CP_UTF8,0,mode,strlen(mode)+1, |
148 | wmode,sizeof(wmode)/sizeof(wmode[0])) && | 153 | wmode,sizeof(wmode)/sizeof(wmode[0])) && |
149 | (file=_wfopen(wfilename,wmode))==NULL && errno==ENOENT | 154 | (file=_wfopen(wfilename,wmode))==NULL && |
155 | (errno==ENOENT || errno==EBADF) | ||
150 | ) /* UTF-8 decode succeeded, but no file, filename | 156 | ) /* UTF-8 decode succeeded, but no file, filename |
151 | * could still have been locale-ized... */ | 157 | * could still have been locale-ized... */ |
152 | file = fopen(filename,mode); | 158 | file = fopen(filename,mode); |
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c index 7ead044b37..b7dce5c1a2 100644 --- a/src/lib/libcrypto/bio/bss_log.c +++ b/src/lib/libcrypto/bio/bss_log.c | |||
@@ -75,6 +75,15 @@ | |||
75 | # include <descrip.h> | 75 | # include <descrip.h> |
76 | # include <lib$routines.h> | 76 | # include <lib$routines.h> |
77 | # include <starlet.h> | 77 | # include <starlet.h> |
78 | /* Some compiler options may mask the declaration of "_malloc32". */ | ||
79 | # if __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE | ||
80 | # if __INITIAL_POINTER_SIZE == 64 | ||
81 | # pragma pointer_size save | ||
82 | # pragma pointer_size 32 | ||
83 | void * _malloc32 (__size_t); | ||
84 | # pragma pointer_size restore | ||
85 | # endif /* __INITIAL_POINTER_SIZE == 64 */ | ||
86 | # endif /* __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE */ | ||
78 | #elif defined(__ultrix) | 87 | #elif defined(__ultrix) |
79 | # include <sys/syslog.h> | 88 | # include <sys/syslog.h> |
80 | #elif defined(OPENSSL_SYS_NETWARE) | 89 | #elif defined(OPENSSL_SYS_NETWARE) |
@@ -300,7 +309,24 @@ static void xopenlog(BIO* bp, char* name, int level) | |||
300 | static void xsyslog(BIO *bp, int priority, const char *string) | 309 | static void xsyslog(BIO *bp, int priority, const char *string) |
301 | { | 310 | { |
302 | struct dsc$descriptor_s opc_dsc; | 311 | struct dsc$descriptor_s opc_dsc; |
312 | |||
313 | /* Arrange 32-bit pointer to opcdef buffer and malloc(), if needed. */ | ||
314 | #if __INITIAL_POINTER_SIZE == 64 | ||
315 | # pragma pointer_size save | ||
316 | # pragma pointer_size 32 | ||
317 | # define OPCDEF_TYPE __char_ptr32 | ||
318 | # define OPCDEF_MALLOC _malloc32 | ||
319 | #else /* __INITIAL_POINTER_SIZE == 64 */ | ||
320 | # define OPCDEF_TYPE char * | ||
321 | # define OPCDEF_MALLOC OPENSSL_malloc | ||
322 | #endif /* __INITIAL_POINTER_SIZE == 64 [else] */ | ||
323 | |||
303 | struct opcdef *opcdef_p; | 324 | struct opcdef *opcdef_p; |
325 | |||
326 | #if __INITIAL_POINTER_SIZE == 64 | ||
327 | # pragma pointer_size restore | ||
328 | #endif /* __INITIAL_POINTER_SIZE == 64 */ | ||
329 | |||
304 | char buf[10240]; | 330 | char buf[10240]; |
305 | unsigned int len; | 331 | unsigned int len; |
306 | struct dsc$descriptor_s buf_dsc; | 332 | struct dsc$descriptor_s buf_dsc; |
@@ -326,8 +352,8 @@ static void xsyslog(BIO *bp, int priority, const char *string) | |||
326 | 352 | ||
327 | lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string); | 353 | lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string); |
328 | 354 | ||
329 | /* we know there's an 8 byte header. That's documented */ | 355 | /* We know there's an 8-byte header. That's documented. */ |
330 | opcdef_p = (struct opcdef *) OPENSSL_malloc(8 + len); | 356 | opcdef_p = OPCDEF_MALLOC( 8+ len); |
331 | opcdef_p->opc$b_ms_type = OPC$_RQ_RQST; | 357 | opcdef_p->opc$b_ms_type = OPC$_RQ_RQST; |
332 | memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3); | 358 | memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3); |
333 | opcdef_p->opc$l_ms_rqstid = 0; | 359 | opcdef_p->opc$l_ms_rqstid = 0; |
@@ -335,7 +361,7 @@ static void xsyslog(BIO *bp, int priority, const char *string) | |||
335 | 361 | ||
336 | opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T; | 362 | opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T; |
337 | opc_dsc.dsc$b_class = DSC$K_CLASS_S; | 363 | opc_dsc.dsc$b_class = DSC$K_CLASS_S; |
338 | opc_dsc.dsc$a_pointer = (char *)opcdef_p; | 364 | opc_dsc.dsc$a_pointer = (OPCDEF_TYPE) opcdef_p; |
339 | opc_dsc.dsc$w_length = len + 8; | 365 | opc_dsc.dsc$w_length = len + 8; |
340 | 366 | ||
341 | sys$sndopr(opc_dsc, 0); | 367 | sys$sndopr(opc_dsc, 0); |
diff --git a/src/lib/libcrypto/bn/asm/alpha-mont.pl b/src/lib/libcrypto/bn/asm/alpha-mont.pl index f7e0ca1646..03596e2014 100644 --- a/src/lib/libcrypto/bn/asm/alpha-mont.pl +++ b/src/lib/libcrypto/bn/asm/alpha-mont.pl | |||
@@ -41,8 +41,12 @@ $j="s4"; | |||
41 | $m1="s5"; | 41 | $m1="s5"; |
42 | 42 | ||
43 | $code=<<___; | 43 | $code=<<___; |
44 | #ifdef __linux__ | ||
45 | #include <asm/regdef.h> | ||
46 | #else | ||
44 | #include <asm.h> | 47 | #include <asm.h> |
45 | #include <regdef.h> | 48 | #include <regdef.h> |
49 | #endif | ||
46 | 50 | ||
47 | .text | 51 | .text |
48 | 52 | ||
@@ -76,7 +80,7 @@ bn_mul_mont: | |||
76 | ldq $aj,8($ap) | 80 | ldq $aj,8($ap) |
77 | subq sp,AT,sp | 81 | subq sp,AT,sp |
78 | ldq $bi,0($bp) # bp[0] | 82 | ldq $bi,0($bp) # bp[0] |
79 | mov -4096,AT | 83 | lda AT,-4096(zero) # mov -4096,AT |
80 | ldq $n0,0($n0) | 84 | ldq $n0,0($n0) |
81 | and sp,AT,sp | 85 | and sp,AT,sp |
82 | 86 | ||
@@ -106,9 +110,9 @@ bn_mul_mont: | |||
106 | .align 4 | 110 | .align 4 |
107 | .L1st: | 111 | .L1st: |
108 | .set noreorder | 112 | .set noreorder |
109 | ldq $aj,($aj) | 113 | ldq $aj,0($aj) |
110 | addl $j,1,$j | 114 | addl $j,1,$j |
111 | ldq $nj,($nj) | 115 | ldq $nj,0($nj) |
112 | lda $tp,8($tp) | 116 | lda $tp,8($tp) |
113 | 117 | ||
114 | addq $alo,$hi0,$lo0 | 118 | addq $alo,$hi0,$lo0 |
@@ -159,12 +163,12 @@ bn_mul_mont: | |||
159 | .align 4 | 163 | .align 4 |
160 | .Louter: | 164 | .Louter: |
161 | s8addq $i,$bp,$bi | 165 | s8addq $i,$bp,$bi |
162 | ldq $hi0,($ap) | 166 | ldq $hi0,0($ap) |
163 | ldq $aj,8($ap) | 167 | ldq $aj,8($ap) |
164 | ldq $bi,($bi) | 168 | ldq $bi,0($bi) |
165 | ldq $hi1,($np) | 169 | ldq $hi1,0($np) |
166 | ldq $nj,8($np) | 170 | ldq $nj,8($np) |
167 | ldq $tj,(sp) | 171 | ldq $tj,0(sp) |
168 | 172 | ||
169 | mulq $hi0,$bi,$lo0 | 173 | mulq $hi0,$bi,$lo0 |
170 | umulh $hi0,$bi,$hi0 | 174 | umulh $hi0,$bi,$hi0 |
@@ -195,10 +199,10 @@ bn_mul_mont: | |||
195 | .set noreorder | 199 | .set noreorder |
196 | ldq $tj,8($tp) #L0 | 200 | ldq $tj,8($tp) #L0 |
197 | nop #U1 | 201 | nop #U1 |
198 | ldq $aj,($aj) #L1 | 202 | ldq $aj,0($aj) #L1 |
199 | s8addq $j,$np,$nj #U0 | 203 | s8addq $j,$np,$nj #U0 |
200 | 204 | ||
201 | ldq $nj,($nj) #L0 | 205 | ldq $nj,0($nj) #L0 |
202 | nop #U1 | 206 | nop #U1 |
203 | addq $alo,$hi0,$lo0 #L1 | 207 | addq $alo,$hi0,$lo0 #L1 |
204 | lda $tp,8($tp) | 208 | lda $tp,8($tp) |
@@ -247,7 +251,7 @@ bn_mul_mont: | |||
247 | addq $hi1,v0,$hi1 | 251 | addq $hi1,v0,$hi1 |
248 | 252 | ||
249 | addq $hi1,$hi0,$lo1 | 253 | addq $hi1,$hi0,$lo1 |
250 | stq $j,($tp) | 254 | stq $j,0($tp) |
251 | cmpult $lo1,$hi0,$hi1 | 255 | cmpult $lo1,$hi0,$hi1 |
252 | addq $lo1,$tj,$lo1 | 256 | addq $lo1,$tj,$lo1 |
253 | cmpult $lo1,$tj,AT | 257 | cmpult $lo1,$tj,AT |
@@ -265,8 +269,8 @@ bn_mul_mont: | |||
265 | mov 0,$hi0 # clear borrow bit | 269 | mov 0,$hi0 # clear borrow bit |
266 | 270 | ||
267 | .align 4 | 271 | .align 4 |
268 | .Lsub: ldq $lo0,($tp) | 272 | .Lsub: ldq $lo0,0($tp) |
269 | ldq $lo1,($np) | 273 | ldq $lo1,0($np) |
270 | lda $tp,8($tp) | 274 | lda $tp,8($tp) |
271 | lda $np,8($np) | 275 | lda $np,8($np) |
272 | subq $lo0,$lo1,$lo1 # tp[i]-np[i] | 276 | subq $lo0,$lo1,$lo1 # tp[i]-np[i] |
@@ -274,7 +278,7 @@ bn_mul_mont: | |||
274 | subq $lo1,$hi0,$lo0 | 278 | subq $lo1,$hi0,$lo0 |
275 | cmpult $lo1,$lo0,$hi0 | 279 | cmpult $lo1,$lo0,$hi0 |
276 | or $hi0,AT,$hi0 | 280 | or $hi0,AT,$hi0 |
277 | stq $lo0,($rp) | 281 | stq $lo0,0($rp) |
278 | cmpult $tp,$tj,v0 | 282 | cmpult $tp,$tj,v0 |
279 | lda $rp,8($rp) | 283 | lda $rp,8($rp) |
280 | bne v0,.Lsub | 284 | bne v0,.Lsub |
@@ -288,7 +292,7 @@ bn_mul_mont: | |||
288 | bis $bp,$ap,$ap # ap=borrow?tp:rp | 292 | bis $bp,$ap,$ap # ap=borrow?tp:rp |
289 | 293 | ||
290 | .align 4 | 294 | .align 4 |
291 | .Lcopy: ldq $aj,($ap) # copy or in-place refresh | 295 | .Lcopy: ldq $aj,0($ap) # copy or in-place refresh |
292 | lda $tp,8($tp) | 296 | lda $tp,8($tp) |
293 | lda $rp,8($rp) | 297 | lda $rp,8($rp) |
294 | lda $ap,8($ap) | 298 | lda $ap,8($ap) |
@@ -309,8 +313,8 @@ bn_mul_mont: | |||
309 | lda sp,48(sp) | 313 | lda sp,48(sp) |
310 | ret (ra) | 314 | ret (ra) |
311 | .end bn_mul_mont | 315 | .end bn_mul_mont |
312 | .rdata | 316 | .ascii "Montgomery Multiplication for Alpha, CRYPTOGAMS by <appro\@openssl.org>" |
313 | .asciiz "Montgomery Multiplication for Alpha, CRYPTOGAMS by <appro\@openssl.org>" | 317 | .align 2 |
314 | ___ | 318 | ___ |
315 | 319 | ||
316 | print $code; | 320 | print $code; |
diff --git a/src/lib/libcrypto/bn/asm/s390x-mont.pl b/src/lib/libcrypto/bn/asm/s390x-mont.pl index d23251033b..f61246f5b6 100644 --- a/src/lib/libcrypto/bn/asm/s390x-mont.pl +++ b/src/lib/libcrypto/bn/asm/s390x-mont.pl | |||
@@ -69,8 +69,8 @@ bn_mul_mont: | |||
69 | cghi $num,16 # | 69 | cghi $num,16 # |
70 | lghi %r2,0 # | 70 | lghi %r2,0 # |
71 | blr %r14 # if($num<16) return 0; | 71 | blr %r14 # if($num<16) return 0; |
72 | cghi $num,128 # | 72 | cghi $num,96 # |
73 | bhr %r14 # if($num>128) return 0; | 73 | bhr %r14 # if($num>96) return 0; |
74 | 74 | ||
75 | stmg %r3,%r15,24($sp) | 75 | stmg %r3,%r15,24($sp) |
76 | 76 | ||
diff --git a/src/lib/libcrypto/bn/asm/s390x.S b/src/lib/libcrypto/bn/asm/s390x.S index 8f45f5d513..43fcb79bc0 100755 --- a/src/lib/libcrypto/bn/asm/s390x.S +++ b/src/lib/libcrypto/bn/asm/s390x.S | |||
@@ -1,4 +1,4 @@ | |||
1 | .ident "s390x.S, version 1.0" | 1 | .ident "s390x.S, version 1.1" |
2 | // ==================================================================== | 2 | // ==================================================================== |
3 | // Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL | 3 | // Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL |
4 | // project. | 4 | // project. |
@@ -24,67 +24,67 @@ bn_mul_add_words: | |||
24 | bler %r14 // if (len<=0) return 0; | 24 | bler %r14 // if (len<=0) return 0; |
25 | 25 | ||
26 | stmg %r6,%r10,48(%r15) | 26 | stmg %r6,%r10,48(%r15) |
27 | lghi %r10,3 | ||
27 | lghi %r8,0 // carry = 0 | 28 | lghi %r8,0 // carry = 0 |
28 | srag %r10,%r4,2 // cnt=len/4 | 29 | nr %r10,%r4 // len%4 |
29 | jz .Loop1_madd | 30 | sra %r4,2 // cnt=len/4 |
31 | jz .Loop1_madd // carry is incidentally cleared if branch taken | ||
32 | algr zero,zero // clear carry | ||
30 | 33 | ||
31 | .Loop4_madd: | 34 | .Loop4_madd: |
32 | lg %r7,0(%r2,%r3) // ap[i] | 35 | lg %r7,0(%r2,%r3) // ap[i] |
33 | mlgr %r6,%r5 // *=w | 36 | mlgr %r6,%r5 // *=w |
34 | algr %r7,%r8 // +=carry | 37 | alcgr %r7,%r8 // +=carry |
35 | alcgr %r6,zero | 38 | alcgr %r6,zero |
36 | alg %r7,0(%r2,%r1) // +=rp[i] | 39 | alg %r7,0(%r2,%r1) // +=rp[i] |
37 | alcgr %r6,zero | ||
38 | stg %r7,0(%r2,%r1) // rp[i]= | 40 | stg %r7,0(%r2,%r1) // rp[i]= |
39 | 41 | ||
40 | lg %r9,8(%r2,%r3) | 42 | lg %r9,8(%r2,%r3) |
41 | mlgr %r8,%r5 | 43 | mlgr %r8,%r5 |
42 | algr %r9,%r6 | 44 | alcgr %r9,%r6 |
43 | alcgr %r8,zero | 45 | alcgr %r8,zero |
44 | alg %r9,8(%r2,%r1) | 46 | alg %r9,8(%r2,%r1) |
45 | alcgr %r8,zero | ||
46 | stg %r9,8(%r2,%r1) | 47 | stg %r9,8(%r2,%r1) |
47 | 48 | ||
48 | lg %r7,16(%r2,%r3) | 49 | lg %r7,16(%r2,%r3) |
49 | mlgr %r6,%r5 | 50 | mlgr %r6,%r5 |
50 | algr %r7,%r8 | 51 | alcgr %r7,%r8 |
51 | alcgr %r6,zero | 52 | alcgr %r6,zero |
52 | alg %r7,16(%r2,%r1) | 53 | alg %r7,16(%r2,%r1) |
53 | alcgr %r6,zero | ||
54 | stg %r7,16(%r2,%r1) | 54 | stg %r7,16(%r2,%r1) |
55 | 55 | ||
56 | lg %r9,24(%r2,%r3) | 56 | lg %r9,24(%r2,%r3) |
57 | mlgr %r8,%r5 | 57 | mlgr %r8,%r5 |
58 | algr %r9,%r6 | 58 | alcgr %r9,%r6 |
59 | alcgr %r8,zero | 59 | alcgr %r8,zero |
60 | alg %r9,24(%r2,%r1) | 60 | alg %r9,24(%r2,%r1) |
61 | alcgr %r8,zero | ||
62 | stg %r9,24(%r2,%r1) | 61 | stg %r9,24(%r2,%r1) |
63 | 62 | ||
64 | la %r2,32(%r2) // i+=4 | 63 | la %r2,32(%r2) // i+=4 |
65 | brct %r10,.Loop4_madd | 64 | brct %r4,.Loop4_madd |
66 | 65 | ||
67 | lghi %r10,3 | 66 | la %r10,1(%r10) // see if len%4 is zero ... |
68 | nr %r4,%r10 // cnt=len%4 | 67 | brct %r10,.Loop1_madd // without touching condition code:-) |
69 | jz .Lend_madd | 68 | |
69 | .Lend_madd: | ||
70 | alcgr %r8,zero // collect carry bit | ||
71 | lgr %r2,%r8 | ||
72 | lmg %r6,%r10,48(%r15) | ||
73 | br %r14 | ||
70 | 74 | ||
71 | .Loop1_madd: | 75 | .Loop1_madd: |
72 | lg %r7,0(%r2,%r3) // ap[i] | 76 | lg %r7,0(%r2,%r3) // ap[i] |
73 | mlgr %r6,%r5 // *=w | 77 | mlgr %r6,%r5 // *=w |
74 | algr %r7,%r8 // +=carry | 78 | alcgr %r7,%r8 // +=carry |
75 | alcgr %r6,zero | 79 | alcgr %r6,zero |
76 | alg %r7,0(%r2,%r1) // +=rp[i] | 80 | alg %r7,0(%r2,%r1) // +=rp[i] |
77 | alcgr %r6,zero | ||
78 | stg %r7,0(%r2,%r1) // rp[i]= | 81 | stg %r7,0(%r2,%r1) // rp[i]= |
79 | 82 | ||
80 | lgr %r8,%r6 | 83 | lgr %r8,%r6 |
81 | la %r2,8(%r2) // i++ | 84 | la %r2,8(%r2) // i++ |
82 | brct %r4,.Loop1_madd | 85 | brct %r10,.Loop1_madd |
83 | 86 | ||
84 | .Lend_madd: | 87 | j .Lend_madd |
85 | lgr %r2,%r8 | ||
86 | lmg %r6,%r10,48(%r15) | ||
87 | br %r14 | ||
88 | .size bn_mul_add_words,.-bn_mul_add_words | 88 | .size bn_mul_add_words,.-bn_mul_add_words |
89 | 89 | ||
90 | // BN_ULONG bn_mul_words(BN_ULONG *r2,BN_ULONG *r3,int r4,BN_ULONG r5); | 90 | // BN_ULONG bn_mul_words(BN_ULONG *r2,BN_ULONG *r3,int r4,BN_ULONG r5); |
@@ -99,57 +99,57 @@ bn_mul_words: | |||
99 | bler %r14 // if (len<=0) return 0; | 99 | bler %r14 // if (len<=0) return 0; |
100 | 100 | ||
101 | stmg %r6,%r10,48(%r15) | 101 | stmg %r6,%r10,48(%r15) |
102 | lghi %r10,3 | ||
102 | lghi %r8,0 // carry = 0 | 103 | lghi %r8,0 // carry = 0 |
103 | srag %r10,%r4,2 // cnt=len/4 | 104 | nr %r10,%r4 // len%4 |
104 | jz .Loop1_mul | 105 | sra %r4,2 // cnt=len/4 |
106 | jz .Loop1_mul // carry is incidentally cleared if branch taken | ||
107 | algr zero,zero // clear carry | ||
105 | 108 | ||
106 | .Loop4_mul: | 109 | .Loop4_mul: |
107 | lg %r7,0(%r2,%r3) // ap[i] | 110 | lg %r7,0(%r2,%r3) // ap[i] |
108 | mlgr %r6,%r5 // *=w | 111 | mlgr %r6,%r5 // *=w |
109 | algr %r7,%r8 // +=carry | 112 | alcgr %r7,%r8 // +=carry |
110 | alcgr %r6,zero | ||
111 | stg %r7,0(%r2,%r1) // rp[i]= | 113 | stg %r7,0(%r2,%r1) // rp[i]= |
112 | 114 | ||
113 | lg %r9,8(%r2,%r3) | 115 | lg %r9,8(%r2,%r3) |
114 | mlgr %r8,%r5 | 116 | mlgr %r8,%r5 |
115 | algr %r9,%r6 | 117 | alcgr %r9,%r6 |
116 | alcgr %r8,zero | ||
117 | stg %r9,8(%r2,%r1) | 118 | stg %r9,8(%r2,%r1) |
118 | 119 | ||
119 | lg %r7,16(%r2,%r3) | 120 | lg %r7,16(%r2,%r3) |
120 | mlgr %r6,%r5 | 121 | mlgr %r6,%r5 |
121 | algr %r7,%r8 | 122 | alcgr %r7,%r8 |
122 | alcgr %r6,zero | ||
123 | stg %r7,16(%r2,%r1) | 123 | stg %r7,16(%r2,%r1) |
124 | 124 | ||
125 | lg %r9,24(%r2,%r3) | 125 | lg %r9,24(%r2,%r3) |
126 | mlgr %r8,%r5 | 126 | mlgr %r8,%r5 |
127 | algr %r9,%r6 | 127 | alcgr %r9,%r6 |
128 | alcgr %r8,zero | ||
129 | stg %r9,24(%r2,%r1) | 128 | stg %r9,24(%r2,%r1) |
130 | 129 | ||
131 | la %r2,32(%r2) // i+=4 | 130 | la %r2,32(%r2) // i+=4 |
132 | brct %r10,.Loop4_mul | 131 | brct %r4,.Loop4_mul |
133 | 132 | ||
134 | lghi %r10,3 | 133 | la %r10,1(%r10) // see if len%4 is zero ... |
135 | nr %r4,%r10 // cnt=len%4 | 134 | brct %r10,.Loop1_mul // without touching condition code:-) |
136 | jz .Lend_mul | 135 | |
136 | .Lend_mul: | ||
137 | alcgr %r8,zero // collect carry bit | ||
138 | lgr %r2,%r8 | ||
139 | lmg %r6,%r10,48(%r15) | ||
140 | br %r14 | ||
137 | 141 | ||
138 | .Loop1_mul: | 142 | .Loop1_mul: |
139 | lg %r7,0(%r2,%r3) // ap[i] | 143 | lg %r7,0(%r2,%r3) // ap[i] |
140 | mlgr %r6,%r5 // *=w | 144 | mlgr %r6,%r5 // *=w |
141 | algr %r7,%r8 // +=carry | 145 | alcgr %r7,%r8 // +=carry |
142 | alcgr %r6,zero | ||
143 | stg %r7,0(%r2,%r1) // rp[i]= | 146 | stg %r7,0(%r2,%r1) // rp[i]= |
144 | 147 | ||
145 | lgr %r8,%r6 | 148 | lgr %r8,%r6 |
146 | la %r2,8(%r2) // i++ | 149 | la %r2,8(%r2) // i++ |
147 | brct %r4,.Loop1_mul | 150 | brct %r10,.Loop1_mul |
148 | 151 | ||
149 | .Lend_mul: | 152 | j .Lend_mul |
150 | lgr %r2,%r8 | ||
151 | lmg %r6,%r10,48(%r15) | ||
152 | br %r14 | ||
153 | .size bn_mul_words,.-bn_mul_words | 153 | .size bn_mul_words,.-bn_mul_words |
154 | 154 | ||
155 | // void bn_sqr_words(BN_ULONG *r2,BN_ULONG *r2,int r4) | 155 | // void bn_sqr_words(BN_ULONG *r2,BN_ULONG *r2,int r4) |
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h index e484b7fc11..a0bc47837d 100644 --- a/src/lib/libcrypto/bn/bn.h +++ b/src/lib/libcrypto/bn/bn.h | |||
@@ -253,6 +253,24 @@ extern "C" { | |||
253 | #define BN_HEX_FMT2 "%08X" | 253 | #define BN_HEX_FMT2 "%08X" |
254 | #endif | 254 | #endif |
255 | 255 | ||
256 | /* 2011-02-22 SMS. | ||
257 | * In various places, a size_t variable or a type cast to size_t was | ||
258 | * used to perform integer-only operations on pointers. This failed on | ||
259 | * VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t is | ||
260 | * still only 32 bits. What's needed in these cases is an integer type | ||
261 | * with the same size as a pointer, which size_t is not certain to be. | ||
262 | * The only fix here is VMS-specific. | ||
263 | */ | ||
264 | #if defined(OPENSSL_SYS_VMS) | ||
265 | # if __INITIAL_POINTER_SIZE == 64 | ||
266 | # define PTR_SIZE_INT long long | ||
267 | # else /* __INITIAL_POINTER_SIZE == 64 */ | ||
268 | # define PTR_SIZE_INT int | ||
269 | # endif /* __INITIAL_POINTER_SIZE == 64 [else] */ | ||
270 | #else /* defined(OPENSSL_SYS_VMS) */ | ||
271 | # define PTR_SIZE_INT size_t | ||
272 | #endif /* defined(OPENSSL_SYS_VMS) [else] */ | ||
273 | |||
256 | #define BN_DEFAULT_BITS 1280 | 274 | #define BN_DEFAULT_BITS 1280 |
257 | 275 | ||
258 | #define BN_FLG_MALLOCED 0x01 | 276 | #define BN_FLG_MALLOCED 0x01 |
diff --git a/src/lib/libcrypto/bn/bn_exp2.c b/src/lib/libcrypto/bn/bn_exp2.c index b3f43cec8c..bd0c34b91b 100644 --- a/src/lib/libcrypto/bn/bn_exp2.c +++ b/src/lib/libcrypto/bn/bn_exp2.c | |||
@@ -301,7 +301,8 @@ int BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1, | |||
301 | r_is_one = 0; | 301 | r_is_one = 0; |
302 | } | 302 | } |
303 | } | 303 | } |
304 | BN_from_montgomery(rr,r,mont,ctx); | 304 | if (!BN_from_montgomery(rr,r,mont,ctx)) |
305 | goto err; | ||
305 | ret=1; | 306 | ret=1; |
306 | err: | 307 | err: |
307 | if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); | 308 | if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); |
diff --git a/src/lib/libcrypto/bn/bn_gf2m.c b/src/lib/libcrypto/bn/bn_gf2m.c index 527b0fa15b..432a3aa338 100644 --- a/src/lib/libcrypto/bn/bn_gf2m.c +++ b/src/lib/libcrypto/bn/bn_gf2m.c | |||
@@ -545,6 +545,7 @@ int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) | |||
545 | { | 545 | { |
546 | while (!BN_is_odd(u)) | 546 | while (!BN_is_odd(u)) |
547 | { | 547 | { |
548 | if (BN_is_zero(u)) goto err; | ||
548 | if (!BN_rshift1(u, u)) goto err; | 549 | if (!BN_rshift1(u, u)) goto err; |
549 | if (BN_is_odd(b)) | 550 | if (BN_is_odd(b)) |
550 | { | 551 | { |
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c index 7224637ab3..1a866880f5 100644 --- a/src/lib/libcrypto/bn/bn_mont.c +++ b/src/lib/libcrypto/bn/bn_mont.c | |||
@@ -277,7 +277,7 @@ static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont) | |||
277 | m1|=m2; /* (al!=ri) */ | 277 | m1|=m2; /* (al!=ri) */ |
278 | m1|=(0-(size_t)v); /* (al!=ri || v) */ | 278 | m1|=(0-(size_t)v); /* (al!=ri || v) */ |
279 | m1&=~m2; /* (al!=ri || v) && !al>ri */ | 279 | m1&=~m2; /* (al!=ri || v) && !al>ri */ |
280 | nrp=(BN_ULONG *)(((size_t)rp&~m1)|((size_t)ap&m1)); | 280 | nrp=(BN_ULONG *)(((PTR_SIZE_INT)rp&~m1)|((PTR_SIZE_INT)ap&m1)); |
281 | } | 281 | } |
282 | 282 | ||
283 | /* 'i<ri' is chosen to eliminate dependency on input data, even | 283 | /* 'i<ri' is chosen to eliminate dependency on input data, even |
diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c index a0e9ec3b46..12e5be80eb 100644 --- a/src/lib/libcrypto/bn/bn_mul.c +++ b/src/lib/libcrypto/bn/bn_mul.c | |||
@@ -551,7 +551,7 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, | |||
551 | int tna, int tnb, BN_ULONG *t) | 551 | int tna, int tnb, BN_ULONG *t) |
552 | { | 552 | { |
553 | int i,j,n2=n*2; | 553 | int i,j,n2=n*2; |
554 | int c1,c2,neg,zero; | 554 | int c1,c2,neg; |
555 | BN_ULONG ln,lo,*p; | 555 | BN_ULONG ln,lo,*p; |
556 | 556 | ||
557 | # ifdef BN_COUNT | 557 | # ifdef BN_COUNT |
@@ -567,7 +567,7 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, | |||
567 | /* r=(a[0]-a[1])*(b[1]-b[0]) */ | 567 | /* r=(a[0]-a[1])*(b[1]-b[0]) */ |
568 | c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna); | 568 | c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna); |
569 | c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n); | 569 | c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n); |
570 | zero=neg=0; | 570 | neg=0; |
571 | switch (c1*3+c2) | 571 | switch (c1*3+c2) |
572 | { | 572 | { |
573 | case -4: | 573 | case -4: |
@@ -575,7 +575,6 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, | |||
575 | bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */ | 575 | bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */ |
576 | break; | 576 | break; |
577 | case -3: | 577 | case -3: |
578 | zero=1; | ||
579 | /* break; */ | 578 | /* break; */ |
580 | case -2: | 579 | case -2: |
581 | bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */ | 580 | bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */ |
@@ -585,7 +584,6 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, | |||
585 | case -1: | 584 | case -1: |
586 | case 0: | 585 | case 0: |
587 | case 1: | 586 | case 1: |
588 | zero=1; | ||
589 | /* break; */ | 587 | /* break; */ |
590 | case 2: | 588 | case 2: |
591 | bn_sub_part_words(t, a, &(a[n]),tna,n-tna); /* + */ | 589 | bn_sub_part_words(t, a, &(a[n]),tna,n-tna); /* + */ |
@@ -593,7 +591,6 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, | |||
593 | neg=1; | 591 | neg=1; |
594 | break; | 592 | break; |
595 | case 3: | 593 | case 3: |
596 | zero=1; | ||
597 | /* break; */ | 594 | /* break; */ |
598 | case 4: | 595 | case 4: |
599 | bn_sub_part_words(t, a, &(a[n]),tna,n-tna); | 596 | bn_sub_part_words(t, a, &(a[n]),tna,n-tna); |
@@ -1012,7 +1009,6 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | |||
1012 | { | 1009 | { |
1013 | if (i >= -1 && i <= 1) | 1010 | if (i >= -1 && i <= 1) |
1014 | { | 1011 | { |
1015 | int sav_j =0; | ||
1016 | /* Find out the power of two lower or equal | 1012 | /* Find out the power of two lower or equal |
1017 | to the longest of the two numbers */ | 1013 | to the longest of the two numbers */ |
1018 | if (i >= 0) | 1014 | if (i >= 0) |
@@ -1023,7 +1019,6 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | |||
1023 | { | 1019 | { |
1024 | j = BN_num_bits_word((BN_ULONG)bl); | 1020 | j = BN_num_bits_word((BN_ULONG)bl); |
1025 | } | 1021 | } |
1026 | sav_j = j; | ||
1027 | j = 1<<(j-1); | 1022 | j = 1<<(j-1); |
1028 | assert(j <= al || j <= bl); | 1023 | assert(j <= al || j <= bl); |
1029 | k = j+j; | 1024 | k = j+j; |
diff --git a/src/lib/libcrypto/bn/bn_nist.c b/src/lib/libcrypto/bn/bn_nist.c index 2ca5b01391..c6de032696 100644 --- a/src/lib/libcrypto/bn/bn_nist.c +++ b/src/lib/libcrypto/bn/bn_nist.c | |||
@@ -354,7 +354,7 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
354 | buf[BN_NIST_192_TOP], | 354 | buf[BN_NIST_192_TOP], |
355 | c_d[BN_NIST_192_TOP], | 355 | c_d[BN_NIST_192_TOP], |
356 | *res; | 356 | *res; |
357 | size_t mask; | 357 | PTR_SIZE_INT mask; |
358 | static const BIGNUM _bignum_nist_p_192_sqr = { | 358 | static const BIGNUM _bignum_nist_p_192_sqr = { |
359 | (BN_ULONG *)_nist_p_192_sqr, | 359 | (BN_ULONG *)_nist_p_192_sqr, |
360 | sizeof(_nist_p_192_sqr)/sizeof(_nist_p_192_sqr[0]), | 360 | sizeof(_nist_p_192_sqr)/sizeof(_nist_p_192_sqr[0]), |
@@ -405,9 +405,10 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
405 | * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;' | 405 | * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;' |
406 | * this is what happens below, but without explicit if:-) a. | 406 | * this is what happens below, but without explicit if:-) a. |
407 | */ | 407 | */ |
408 | mask = 0-(size_t)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP); | 408 | mask = 0-(PTR_SIZE_INT)bn_sub_words(c_d,r_d,_nist_p_192[0],BN_NIST_192_TOP); |
409 | mask &= 0-(size_t)carry; | 409 | mask &= 0-(PTR_SIZE_INT)carry; |
410 | res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask)); | 410 | res = (BN_ULONG *) |
411 | (((PTR_SIZE_INT)c_d&~mask) | ((PTR_SIZE_INT)r_d&mask)); | ||
411 | nist_cp_bn(r_d, res, BN_NIST_192_TOP); | 412 | nist_cp_bn(r_d, res, BN_NIST_192_TOP); |
412 | r->top = BN_NIST_192_TOP; | 413 | r->top = BN_NIST_192_TOP; |
413 | bn_correct_top(r); | 414 | bn_correct_top(r); |
@@ -438,8 +439,8 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
438 | buf[BN_NIST_224_TOP], | 439 | buf[BN_NIST_224_TOP], |
439 | c_d[BN_NIST_224_TOP], | 440 | c_d[BN_NIST_224_TOP], |
440 | *res; | 441 | *res; |
441 | size_t mask; | 442 | PTR_SIZE_INT mask; |
442 | union { bn_addsub_f f; size_t p; } u; | 443 | union { bn_addsub_f f; PTR_SIZE_INT p; } u; |
443 | static const BIGNUM _bignum_nist_p_224_sqr = { | 444 | static const BIGNUM _bignum_nist_p_224_sqr = { |
444 | (BN_ULONG *)_nist_p_224_sqr, | 445 | (BN_ULONG *)_nist_p_224_sqr, |
445 | sizeof(_nist_p_224_sqr)/sizeof(_nist_p_224_sqr[0]), | 446 | sizeof(_nist_p_224_sqr)/sizeof(_nist_p_224_sqr[0]), |
@@ -510,16 +511,18 @@ int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
510 | * to be compared to the modulus and conditionally | 511 | * to be compared to the modulus and conditionally |
511 | * adjusted by *subtracting* the latter. */ | 512 | * adjusted by *subtracting* the latter. */ |
512 | carry = (int)bn_add_words(r_d,r_d,_nist_p_224[-carry-1],BN_NIST_224_TOP); | 513 | carry = (int)bn_add_words(r_d,r_d,_nist_p_224[-carry-1],BN_NIST_224_TOP); |
513 | mask = 0-(size_t)carry; | 514 | mask = 0-(PTR_SIZE_INT)carry; |
514 | u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask); | 515 | u.p = ((PTR_SIZE_INT)bn_sub_words&mask) | |
516 | ((PTR_SIZE_INT)bn_add_words&~mask); | ||
515 | } | 517 | } |
516 | else | 518 | else |
517 | carry = 1; | 519 | carry = 1; |
518 | 520 | ||
519 | /* otherwise it's effectively same as in BN_nist_mod_192... */ | 521 | /* otherwise it's effectively same as in BN_nist_mod_192... */ |
520 | mask = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP); | 522 | mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_224[0],BN_NIST_224_TOP); |
521 | mask &= 0-(size_t)carry; | 523 | mask &= 0-(PTR_SIZE_INT)carry; |
522 | res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask)); | 524 | res = (BN_ULONG *)(((PTR_SIZE_INT)c_d&~mask) | |
525 | ((PTR_SIZE_INT)r_d&mask)); | ||
523 | nist_cp_bn(r_d, res, BN_NIST_224_TOP); | 526 | nist_cp_bn(r_d, res, BN_NIST_224_TOP); |
524 | r->top = BN_NIST_224_TOP; | 527 | r->top = BN_NIST_224_TOP; |
525 | bn_correct_top(r); | 528 | bn_correct_top(r); |
@@ -549,8 +552,8 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
549 | buf[BN_NIST_256_TOP], | 552 | buf[BN_NIST_256_TOP], |
550 | c_d[BN_NIST_256_TOP], | 553 | c_d[BN_NIST_256_TOP], |
551 | *res; | 554 | *res; |
552 | size_t mask; | 555 | PTR_SIZE_INT mask; |
553 | union { bn_addsub_f f; size_t p; } u; | 556 | union { bn_addsub_f f; PTR_SIZE_INT p; } u; |
554 | static const BIGNUM _bignum_nist_p_256_sqr = { | 557 | static const BIGNUM _bignum_nist_p_256_sqr = { |
555 | (BN_ULONG *)_nist_p_256_sqr, | 558 | (BN_ULONG *)_nist_p_256_sqr, |
556 | sizeof(_nist_p_256_sqr)/sizeof(_nist_p_256_sqr[0]), | 559 | sizeof(_nist_p_256_sqr)/sizeof(_nist_p_256_sqr[0]), |
@@ -629,15 +632,17 @@ int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
629 | else if (carry < 0) | 632 | else if (carry < 0) |
630 | { | 633 | { |
631 | carry = (int)bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP); | 634 | carry = (int)bn_add_words(r_d,r_d,_nist_p_256[-carry-1],BN_NIST_256_TOP); |
632 | mask = 0-(size_t)carry; | 635 | mask = 0-(PTR_SIZE_INT)carry; |
633 | u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask); | 636 | u.p = ((PTR_SIZE_INT)bn_sub_words&mask) | |
637 | ((PTR_SIZE_INT)bn_add_words&~mask); | ||
634 | } | 638 | } |
635 | else | 639 | else |
636 | carry = 1; | 640 | carry = 1; |
637 | 641 | ||
638 | mask = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP); | 642 | mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_256[0],BN_NIST_256_TOP); |
639 | mask &= 0-(size_t)carry; | 643 | mask &= 0-(PTR_SIZE_INT)carry; |
640 | res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask)); | 644 | res = (BN_ULONG *)(((PTR_SIZE_INT)c_d&~mask) | |
645 | ((PTR_SIZE_INT)r_d&mask)); | ||
641 | nist_cp_bn(r_d, res, BN_NIST_256_TOP); | 646 | nist_cp_bn(r_d, res, BN_NIST_256_TOP); |
642 | r->top = BN_NIST_256_TOP; | 647 | r->top = BN_NIST_256_TOP; |
643 | bn_correct_top(r); | 648 | bn_correct_top(r); |
@@ -671,8 +676,8 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
671 | buf[BN_NIST_384_TOP], | 676 | buf[BN_NIST_384_TOP], |
672 | c_d[BN_NIST_384_TOP], | 677 | c_d[BN_NIST_384_TOP], |
673 | *res; | 678 | *res; |
674 | size_t mask; | 679 | PTR_SIZE_INT mask; |
675 | union { bn_addsub_f f; size_t p; } u; | 680 | union { bn_addsub_f f; PTR_SIZE_INT p; } u; |
676 | static const BIGNUM _bignum_nist_p_384_sqr = { | 681 | static const BIGNUM _bignum_nist_p_384_sqr = { |
677 | (BN_ULONG *)_nist_p_384_sqr, | 682 | (BN_ULONG *)_nist_p_384_sqr, |
678 | sizeof(_nist_p_384_sqr)/sizeof(_nist_p_384_sqr[0]), | 683 | sizeof(_nist_p_384_sqr)/sizeof(_nist_p_384_sqr[0]), |
@@ -754,15 +759,17 @@ int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
754 | else if (carry < 0) | 759 | else if (carry < 0) |
755 | { | 760 | { |
756 | carry = (int)bn_add_words(r_d,r_d,_nist_p_384[-carry-1],BN_NIST_384_TOP); | 761 | carry = (int)bn_add_words(r_d,r_d,_nist_p_384[-carry-1],BN_NIST_384_TOP); |
757 | mask = 0-(size_t)carry; | 762 | mask = 0-(PTR_SIZE_INT)carry; |
758 | u.p = ((size_t)bn_sub_words&mask) | ((size_t)bn_add_words&~mask); | 763 | u.p = ((PTR_SIZE_INT)bn_sub_words&mask) | |
764 | ((PTR_SIZE_INT)bn_add_words&~mask); | ||
759 | } | 765 | } |
760 | else | 766 | else |
761 | carry = 1; | 767 | carry = 1; |
762 | 768 | ||
763 | mask = 0-(size_t)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP); | 769 | mask = 0-(PTR_SIZE_INT)(*u.f)(c_d,r_d,_nist_p_384[0],BN_NIST_384_TOP); |
764 | mask &= 0-(size_t)carry; | 770 | mask &= 0-(PTR_SIZE_INT)carry; |
765 | res = (BN_ULONG *)(((size_t)c_d&~mask) | ((size_t)r_d&mask)); | 771 | res = (BN_ULONG *)(((PTR_SIZE_INT)c_d&~mask) | |
772 | ((PTR_SIZE_INT)r_d&mask)); | ||
766 | nist_cp_bn(r_d, res, BN_NIST_384_TOP); | 773 | nist_cp_bn(r_d, res, BN_NIST_384_TOP); |
767 | r->top = BN_NIST_384_TOP; | 774 | r->top = BN_NIST_384_TOP; |
768 | bn_correct_top(r); | 775 | bn_correct_top(r); |
@@ -781,7 +788,7 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
781 | BN_ULONG *r_d, *a_d = a->d, | 788 | BN_ULONG *r_d, *a_d = a->d, |
782 | t_d[BN_NIST_521_TOP], | 789 | t_d[BN_NIST_521_TOP], |
783 | val,tmp,*res; | 790 | val,tmp,*res; |
784 | size_t mask; | 791 | PTR_SIZE_INT mask; |
785 | static const BIGNUM _bignum_nist_p_521_sqr = { | 792 | static const BIGNUM _bignum_nist_p_521_sqr = { |
786 | (BN_ULONG *)_nist_p_521_sqr, | 793 | (BN_ULONG *)_nist_p_521_sqr, |
787 | sizeof(_nist_p_521_sqr)/sizeof(_nist_p_521_sqr[0]), | 794 | sizeof(_nist_p_521_sqr)/sizeof(_nist_p_521_sqr[0]), |
@@ -826,8 +833,9 @@ int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field, | |||
826 | r_d[i] &= BN_NIST_521_TOP_MASK; | 833 | r_d[i] &= BN_NIST_521_TOP_MASK; |
827 | 834 | ||
828 | bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP); | 835 | bn_add_words(r_d,r_d,t_d,BN_NIST_521_TOP); |
829 | mask = 0-(size_t)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP); | 836 | mask = 0-(PTR_SIZE_INT)bn_sub_words(t_d,r_d,_nist_p_521,BN_NIST_521_TOP); |
830 | res = (BN_ULONG *)(((size_t)t_d&~mask) | ((size_t)r_d&mask)); | 837 | res = (BN_ULONG *)(((PTR_SIZE_INT)t_d&~mask) | |
838 | ((PTR_SIZE_INT)r_d&mask)); | ||
831 | nist_cp_bn(r_d,res,BN_NIST_521_TOP); | 839 | nist_cp_bn(r_d,res,BN_NIST_521_TOP); |
832 | r->top = BN_NIST_521_TOP; | 840 | r->top = BN_NIST_521_TOP; |
833 | bn_correct_top(r); | 841 | bn_correct_top(r); |
diff --git a/src/lib/libcrypto/comp/c_rle.c b/src/lib/libcrypto/comp/c_rle.c index efd366fa22..18bceae51e 100644 --- a/src/lib/libcrypto/comp/c_rle.c +++ b/src/lib/libcrypto/comp/c_rle.c | |||
@@ -46,7 +46,7 @@ static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, | |||
46 | { | 46 | { |
47 | int i; | 47 | int i; |
48 | 48 | ||
49 | if (olen < (ilen-1)) | 49 | if (ilen == 0 || olen < (ilen-1)) |
50 | { | 50 | { |
51 | /* ZZZZZZZZZZZZZZZZZZZZZZ */ | 51 | /* ZZZZZZZZZZZZZZZZZZZZZZ */ |
52 | return(-1); | 52 | return(-1); |
@@ -59,4 +59,3 @@ static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, | |||
59 | } | 59 | } |
60 | return(ilen-1); | 60 | return(ilen-1); |
61 | } | 61 | } |
62 | |||
diff --git a/src/lib/libcrypto/conf/conf_api.c b/src/lib/libcrypto/conf/conf_api.c index 22617e5fa1..f5fcbb9f6b 100644 --- a/src/lib/libcrypto/conf/conf_api.c +++ b/src/lib/libcrypto/conf/conf_api.c | |||
@@ -64,6 +64,7 @@ | |||
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | #include <assert.h> | 66 | #include <assert.h> |
67 | #include <stdlib.h> | ||
67 | #include <string.h> | 68 | #include <string.h> |
68 | #include <openssl/conf.h> | 69 | #include <openssl/conf.h> |
69 | #include <openssl/conf_api.h> | 70 | #include <openssl/conf_api.h> |
@@ -285,7 +286,7 @@ CONF_VALUE *_CONF_new_section(CONF *conf, const char *section) | |||
285 | v->value=(char *)sk; | 286 | v->value=(char *)sk; |
286 | 287 | ||
287 | vv=lh_CONF_VALUE_insert(conf->data,v); | 288 | vv=lh_CONF_VALUE_insert(conf->data,v); |
288 | assert(vv == NULL); | 289 | OPENSSL_assert(vv == NULL); |
289 | ok=1; | 290 | ok=1; |
290 | err: | 291 | err: |
291 | if (!ok) | 292 | if (!ok) |
diff --git a/src/lib/libcrypto/conf/conf_def.c b/src/lib/libcrypto/conf/conf_def.c index 0b571b0394..cf951320af 100644 --- a/src/lib/libcrypto/conf/conf_def.c +++ b/src/lib/libcrypto/conf/conf_def.c | |||
@@ -213,13 +213,12 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) | |||
213 | int bufnum=0,i,ii; | 213 | int bufnum=0,i,ii; |
214 | BUF_MEM *buff=NULL; | 214 | BUF_MEM *buff=NULL; |
215 | char *s,*p,*end; | 215 | char *s,*p,*end; |
216 | int again,n; | 216 | int again; |
217 | long eline=0; | 217 | long eline=0; |
218 | char btmp[DECIMAL_SIZE(eline)+1]; | 218 | char btmp[DECIMAL_SIZE(eline)+1]; |
219 | CONF_VALUE *v=NULL,*tv; | 219 | CONF_VALUE *v=NULL,*tv; |
220 | CONF_VALUE *sv=NULL; | 220 | CONF_VALUE *sv=NULL; |
221 | char *section=NULL,*buf; | 221 | char *section=NULL,*buf; |
222 | STACK_OF(CONF_VALUE) *section_sk=NULL,*ts; | ||
223 | char *start,*psection,*pname; | 222 | char *start,*psection,*pname; |
224 | void *h = (void *)(conf->data); | 223 | void *h = (void *)(conf->data); |
225 | 224 | ||
@@ -250,7 +249,6 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) | |||
250 | CONF_R_UNABLE_TO_CREATE_NEW_SECTION); | 249 | CONF_R_UNABLE_TO_CREATE_NEW_SECTION); |
251 | goto err; | 250 | goto err; |
252 | } | 251 | } |
253 | section_sk=(STACK_OF(CONF_VALUE) *)sv->value; | ||
254 | 252 | ||
255 | bufnum=0; | 253 | bufnum=0; |
256 | again=0; | 254 | again=0; |
@@ -309,7 +307,6 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) | |||
309 | buf=buff->data; | 307 | buf=buff->data; |
310 | 308 | ||
311 | clear_comments(conf, buf); | 309 | clear_comments(conf, buf); |
312 | n=strlen(buf); | ||
313 | s=eat_ws(conf, buf); | 310 | s=eat_ws(conf, buf); |
314 | if (IS_EOF(conf,*s)) continue; /* blank line */ | 311 | if (IS_EOF(conf,*s)) continue; /* blank line */ |
315 | if (*s == '[') | 312 | if (*s == '[') |
@@ -343,7 +340,6 @@ again: | |||
343 | CONF_R_UNABLE_TO_CREATE_NEW_SECTION); | 340 | CONF_R_UNABLE_TO_CREATE_NEW_SECTION); |
344 | goto err; | 341 | goto err; |
345 | } | 342 | } |
346 | section_sk=(STACK_OF(CONF_VALUE) *)sv->value; | ||
347 | continue; | 343 | continue; |
348 | } | 344 | } |
349 | else | 345 | else |
@@ -406,13 +402,9 @@ again: | |||
406 | CONF_R_UNABLE_TO_CREATE_NEW_SECTION); | 402 | CONF_R_UNABLE_TO_CREATE_NEW_SECTION); |
407 | goto err; | 403 | goto err; |
408 | } | 404 | } |
409 | ts=(STACK_OF(CONF_VALUE) *)tv->value; | ||
410 | } | 405 | } |
411 | else | 406 | else |
412 | { | ||
413 | tv=sv; | 407 | tv=sv; |
414 | ts=section_sk; | ||
415 | } | ||
416 | #if 1 | 408 | #if 1 |
417 | if (_CONF_add_string(conf, tv, v) == 0) | 409 | if (_CONF_add_string(conf, tv, v) == 0) |
418 | { | 410 | { |
@@ -465,9 +457,6 @@ err: | |||
465 | 457 | ||
466 | static void clear_comments(CONF *conf, char *p) | 458 | static void clear_comments(CONF *conf, char *p) |
467 | { | 459 | { |
468 | char *to; | ||
469 | |||
470 | to=p; | ||
471 | for (;;) | 460 | for (;;) |
472 | { | 461 | { |
473 | if (IS_FCOMMENT(conf,*p)) | 462 | if (IS_FCOMMENT(conf,*p)) |
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c index b4449b86d6..24fe123e14 100644 --- a/src/lib/libcrypto/cryptlib.c +++ b/src/lib/libcrypto/cryptlib.c | |||
@@ -731,7 +731,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, | |||
731 | case DLL_THREAD_ATTACH: | 731 | case DLL_THREAD_ATTACH: |
732 | break; | 732 | break; |
733 | case DLL_THREAD_DETACH: | 733 | case DLL_THREAD_DETACH: |
734 | ERR_remove_state(0); | ||
735 | break; | 734 | break; |
736 | case DLL_PROCESS_DETACH: | 735 | case DLL_PROCESS_DETACH: |
737 | break; | 736 | break; |
@@ -743,6 +742,16 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, | |||
743 | #if defined(_WIN32) && !defined(__CYGWIN__) | 742 | #if defined(_WIN32) && !defined(__CYGWIN__) |
744 | #include <tchar.h> | 743 | #include <tchar.h> |
745 | #include <signal.h> | 744 | #include <signal.h> |
745 | #ifdef __WATCOMC__ | ||
746 | #if defined(_UNICODE) || defined(__UNICODE__) | ||
747 | #define _vsntprintf _vsnwprintf | ||
748 | #else | ||
749 | #define _vsntprintf _vsnprintf | ||
750 | #endif | ||
751 | #endif | ||
752 | #ifdef _MSC_VER | ||
753 | #define alloca _alloca | ||
754 | #endif | ||
746 | 755 | ||
747 | #if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333 | 756 | #if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333 |
748 | int OPENSSL_isservice(void) | 757 | int OPENSSL_isservice(void) |
@@ -773,11 +782,7 @@ int OPENSSL_isservice(void) | |||
773 | 782 | ||
774 | if (len>512) return -1; /* paranoia */ | 783 | if (len>512) return -1; /* paranoia */ |
775 | len++,len&=~1; /* paranoia */ | 784 | len++,len&=~1; /* paranoia */ |
776 | #ifdef _MSC_VER | ||
777 | name=(WCHAR *)_alloca(len+sizeof(WCHAR)); | ||
778 | #else | ||
779 | name=(WCHAR *)alloca(len+sizeof(WCHAR)); | 785 | name=(WCHAR *)alloca(len+sizeof(WCHAR)); |
780 | #endif | ||
781 | if (!GetUserObjectInformationW (h,UOI_NAME,name,len,&len)) | 786 | if (!GetUserObjectInformationW (h,UOI_NAME,name,len,&len)) |
782 | return -1; | 787 | return -1; |
783 | 788 | ||
@@ -822,11 +827,7 @@ void OPENSSL_showfatal (const char *fmta,...) | |||
822 | size_t len_0=strlen(fmta)+1,i; | 827 | size_t len_0=strlen(fmta)+1,i; |
823 | WCHAR *fmtw; | 828 | WCHAR *fmtw; |
824 | 829 | ||
825 | #ifdef _MSC_VER | 830 | fmtw = (WCHAR *)alloca(len_0*sizeof(WCHAR)); |
826 | fmtw = (WCHAR *)_alloca (len_0*sizeof(WCHAR)); | ||
827 | #else | ||
828 | fmtw = (WCHAR *)alloca (len_0*sizeof(WCHAR)); | ||
829 | #endif | ||
830 | if (fmtw == NULL) { fmt=(const TCHAR *)L"no stack?"; break; } | 831 | if (fmtw == NULL) { fmt=(const TCHAR *)L"no stack?"; break; } |
831 | 832 | ||
832 | #ifndef OPENSSL_NO_MULTIBYTE | 833 | #ifndef OPENSSL_NO_MULTIBYTE |
diff --git a/src/lib/libcrypto/doc/EVP_PKEY_verify.pod b/src/lib/libcrypto/doc/EVP_PKEY_verify.pod index 10633da3f2..f93e5fc6c3 100644 --- a/src/lib/libcrypto/doc/EVP_PKEY_verify.pod +++ b/src/lib/libcrypto/doc/EVP_PKEY_verify.pod | |||
@@ -69,7 +69,7 @@ Verify signature using PKCS#1 and SHA256 digest: | |||
69 | /* Error */ | 69 | /* Error */ |
70 | 70 | ||
71 | /* Perform operation */ | 71 | /* Perform operation */ |
72 | ret = EVP_PKEY_verify(ctx, md, mdlen, sig, siglen); | 72 | ret = EVP_PKEY_verify(ctx, sig, siglen, md, mdlen); |
73 | 73 | ||
74 | /* ret == 1 indicates success, 0 verify failure and < 0 for some | 74 | /* ret == 1 indicates success, 0 verify failure and < 0 for some |
75 | * other error. | 75 | * other error. |
diff --git a/src/lib/libcrypto/dsa/dsa_gen.c b/src/lib/libcrypto/dsa/dsa_gen.c index 0fcd25f8b0..cb0b4538a4 100644 --- a/src/lib/libcrypto/dsa/dsa_gen.c +++ b/src/lib/libcrypto/dsa/dsa_gen.c | |||
@@ -120,7 +120,7 @@ int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, | |||
120 | BIGNUM *r0,*W,*X,*c,*test; | 120 | BIGNUM *r0,*W,*X,*c,*test; |
121 | BIGNUM *g=NULL,*q=NULL,*p=NULL; | 121 | BIGNUM *g=NULL,*q=NULL,*p=NULL; |
122 | BN_MONT_CTX *mont=NULL; | 122 | BN_MONT_CTX *mont=NULL; |
123 | int i, k,n=0,b,m=0, qsize = qbits >> 3; | 123 | int i, k, n=0, m=0, qsize = qbits >> 3; |
124 | int counter=0; | 124 | int counter=0; |
125 | int r=0; | 125 | int r=0; |
126 | BN_CTX *ctx=NULL; | 126 | BN_CTX *ctx=NULL; |
@@ -232,7 +232,6 @@ int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, | |||
232 | /* "offset = 2" */ | 232 | /* "offset = 2" */ |
233 | 233 | ||
234 | n=(bits-1)/160; | 234 | n=(bits-1)/160; |
235 | b=(bits-1)-n*160; | ||
236 | 235 | ||
237 | for (;;) | 236 | for (;;) |
238 | { | 237 | { |
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c index 4fead07e80..a3ddd7d281 100644 --- a/src/lib/libcrypto/dsa/dsa_ossl.c +++ b/src/lib/libcrypto/dsa/dsa_ossl.c | |||
@@ -148,15 +148,6 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) | |||
148 | 148 | ||
149 | s=BN_new(); | 149 | s=BN_new(); |
150 | if (s == NULL) goto err; | 150 | if (s == NULL) goto err; |
151 | |||
152 | /* reject a excessive digest length (currently at most | ||
153 | * dsa-with-SHA256 is supported) */ | ||
154 | if (dlen > SHA256_DIGEST_LENGTH) | ||
155 | { | ||
156 | reason=DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE; | ||
157 | goto err; | ||
158 | } | ||
159 | |||
160 | ctx=BN_CTX_new(); | 151 | ctx=BN_CTX_new(); |
161 | if (ctx == NULL) goto err; | 152 | if (ctx == NULL) goto err; |
162 | 153 | ||
@@ -185,7 +176,7 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) | |||
185 | if (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;/* s = xr */ | 176 | if (!BN_mod_mul(&xr,dsa->priv_key,r,dsa->q,ctx)) goto err;/* s = xr */ |
186 | if (!BN_add(s, &xr, &m)) goto err; /* s = m + xr */ | 177 | if (!BN_add(s, &xr, &m)) goto err; /* s = m + xr */ |
187 | if (BN_cmp(s,dsa->q) > 0) | 178 | if (BN_cmp(s,dsa->q) > 0) |
188 | BN_sub(s,s,dsa->q); | 179 | if (!BN_sub(s,s,dsa->q)) goto err; |
189 | if (!BN_mod_mul(s,s,kinv,dsa->q,ctx)) goto err; | 180 | if (!BN_mod_mul(s,s,kinv,dsa->q,ctx)) goto err; |
190 | 181 | ||
191 | ret=DSA_SIG_new(); | 182 | ret=DSA_SIG_new(); |
@@ -325,15 +316,6 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, | |||
325 | DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_MODULUS_TOO_LARGE); | 316 | DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_MODULUS_TOO_LARGE); |
326 | return -1; | 317 | return -1; |
327 | } | 318 | } |
328 | |||
329 | /* reject a excessive digest length (currently at most | ||
330 | * dsa-with-SHA256 is supported) */ | ||
331 | if (dgst_len > SHA256_DIGEST_LENGTH) | ||
332 | { | ||
333 | DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); | ||
334 | return -1; | ||
335 | } | ||
336 | |||
337 | BN_init(&u1); | 319 | BN_init(&u1); |
338 | BN_init(&u2); | 320 | BN_init(&u2); |
339 | BN_init(&t1); | 321 | BN_init(&t1); |
diff --git a/src/lib/libcrypto/dsa/dsa_pmeth.c b/src/lib/libcrypto/dsa/dsa_pmeth.c index 4ce91e20c6..e2df54fec6 100644 --- a/src/lib/libcrypto/dsa/dsa_pmeth.c +++ b/src/lib/libcrypto/dsa/dsa_pmeth.c | |||
@@ -187,6 +187,7 @@ static int pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) | |||
187 | case EVP_PKEY_CTRL_MD: | 187 | case EVP_PKEY_CTRL_MD: |
188 | if (EVP_MD_type((const EVP_MD *)p2) != NID_sha1 && | 188 | if (EVP_MD_type((const EVP_MD *)p2) != NID_sha1 && |
189 | EVP_MD_type((const EVP_MD *)p2) != NID_dsa && | 189 | EVP_MD_type((const EVP_MD *)p2) != NID_dsa && |
190 | EVP_MD_type((const EVP_MD *)p2) != NID_dsaWithSHA && | ||
190 | EVP_MD_type((const EVP_MD *)p2) != NID_sha224 && | 191 | EVP_MD_type((const EVP_MD *)p2) != NID_sha224 && |
191 | EVP_MD_type((const EVP_MD *)p2) != NID_sha256) | 192 | EVP_MD_type((const EVP_MD *)p2) != NID_sha256) |
192 | { | 193 | { |
diff --git a/src/lib/libcrypto/dso/dso_dlfcn.c b/src/lib/libcrypto/dso/dso_dlfcn.c index 14bd322fb8..c2bc61760b 100644 --- a/src/lib/libcrypto/dso/dso_dlfcn.c +++ b/src/lib/libcrypto/dso/dso_dlfcn.c | |||
@@ -85,6 +85,7 @@ DSO_METHOD *DSO_METHOD_dlfcn(void) | |||
85 | # define HAVE_DLINFO 1 | 85 | # define HAVE_DLINFO 1 |
86 | # if defined(_AIX) || defined(__CYGWIN__) || \ | 86 | # if defined(_AIX) || defined(__CYGWIN__) || \ |
87 | defined(__SCO_VERSION__) || defined(_SCO_ELF) || \ | 87 | defined(__SCO_VERSION__) || defined(_SCO_ELF) || \ |
88 | (defined(__osf__) && !defined(RTLD_NEXT)) || \ | ||
88 | (defined(__OpenBSD__) && !defined(RTLD_SELF)) | 89 | (defined(__OpenBSD__) && !defined(RTLD_SELF)) |
89 | # undef HAVE_DLINFO | 90 | # undef HAVE_DLINFO |
90 | # endif | 91 | # endif |
diff --git a/src/lib/libcrypto/ec/ec2_mult.c b/src/lib/libcrypto/ec/ec2_mult.c index ab631a50a2..e12b9b284a 100644 --- a/src/lib/libcrypto/ec/ec2_mult.c +++ b/src/lib/libcrypto/ec/ec2_mult.c | |||
@@ -319,6 +319,7 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
319 | int ret = 0; | 319 | int ret = 0; |
320 | size_t i; | 320 | size_t i; |
321 | EC_POINT *p=NULL; | 321 | EC_POINT *p=NULL; |
322 | EC_POINT *acc = NULL; | ||
322 | 323 | ||
323 | if (ctx == NULL) | 324 | if (ctx == NULL) |
324 | { | 325 | { |
@@ -338,15 +339,16 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
338 | } | 339 | } |
339 | 340 | ||
340 | if ((p = EC_POINT_new(group)) == NULL) goto err; | 341 | if ((p = EC_POINT_new(group)) == NULL) goto err; |
342 | if ((acc = EC_POINT_new(group)) == NULL) goto err; | ||
341 | 343 | ||
342 | if (!EC_POINT_set_to_infinity(group, r)) goto err; | 344 | if (!EC_POINT_set_to_infinity(group, acc)) goto err; |
343 | 345 | ||
344 | if (scalar) | 346 | if (scalar) |
345 | { | 347 | { |
346 | if (!ec_GF2m_montgomery_point_multiply(group, p, scalar, group->generator, ctx)) goto err; | 348 | if (!ec_GF2m_montgomery_point_multiply(group, p, scalar, group->generator, ctx)) goto err; |
347 | if (BN_is_negative(scalar)) | 349 | if (BN_is_negative(scalar)) |
348 | if (!group->meth->invert(group, p, ctx)) goto err; | 350 | if (!group->meth->invert(group, p, ctx)) goto err; |
349 | if (!group->meth->add(group, r, r, p, ctx)) goto err; | 351 | if (!group->meth->add(group, acc, acc, p, ctx)) goto err; |
350 | } | 352 | } |
351 | 353 | ||
352 | for (i = 0; i < num; i++) | 354 | for (i = 0; i < num; i++) |
@@ -354,13 +356,16 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
354 | if (!ec_GF2m_montgomery_point_multiply(group, p, scalars[i], points[i], ctx)) goto err; | 356 | if (!ec_GF2m_montgomery_point_multiply(group, p, scalars[i], points[i], ctx)) goto err; |
355 | if (BN_is_negative(scalars[i])) | 357 | if (BN_is_negative(scalars[i])) |
356 | if (!group->meth->invert(group, p, ctx)) goto err; | 358 | if (!group->meth->invert(group, p, ctx)) goto err; |
357 | if (!group->meth->add(group, r, r, p, ctx)) goto err; | 359 | if (!group->meth->add(group, acc, acc, p, ctx)) goto err; |
358 | } | 360 | } |
359 | 361 | ||
362 | if (!EC_POINT_copy(r, acc)) goto err; | ||
363 | |||
360 | ret = 1; | 364 | ret = 1; |
361 | 365 | ||
362 | err: | 366 | err: |
363 | if (p) EC_POINT_free(p); | 367 | if (p) EC_POINT_free(p); |
368 | if (acc) EC_POINT_free(acc); | ||
364 | if (new_ctx != NULL) | 369 | if (new_ctx != NULL) |
365 | BN_CTX_free(new_ctx); | 370 | BN_CTX_free(new_ctx); |
366 | return ret; | 371 | return ret; |
diff --git a/src/lib/libcrypto/ec/ec2_smpl.c b/src/lib/libcrypto/ec/ec2_smpl.c index cf357b462a..af94458ca7 100644 --- a/src/lib/libcrypto/ec/ec2_smpl.c +++ b/src/lib/libcrypto/ec/ec2_smpl.c | |||
@@ -937,6 +937,9 @@ int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT | |||
937 | { | 937 | { |
938 | return EC_POINT_is_at_infinity(group, b) ? 0 : 1; | 938 | return EC_POINT_is_at_infinity(group, b) ? 0 : 1; |
939 | } | 939 | } |
940 | |||
941 | if (EC_POINT_is_at_infinity(group, b)) | ||
942 | return 1; | ||
940 | 943 | ||
941 | if (a->Z_is_one && b->Z_is_one) | 944 | if (a->Z_is_one && b->Z_is_one) |
942 | { | 945 | { |
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c index 12fb0e6d6d..522802c07a 100644 --- a/src/lib/libcrypto/ec/ec_key.c +++ b/src/lib/libcrypto/ec/ec_key.c | |||
@@ -304,7 +304,13 @@ int EC_KEY_check_key(const EC_KEY *eckey) | |||
304 | ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER); | 304 | ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER); |
305 | return 0; | 305 | return 0; |
306 | } | 306 | } |
307 | 307 | ||
308 | if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key)) | ||
309 | { | ||
310 | ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_POINT_AT_INFINITY); | ||
311 | goto err; | ||
312 | } | ||
313 | |||
308 | if ((ctx = BN_CTX_new()) == NULL) | 314 | if ((ctx = BN_CTX_new()) == NULL) |
309 | goto err; | 315 | goto err; |
310 | if ((point = EC_POINT_new(eckey->group)) == NULL) | 316 | if ((point = EC_POINT_new(eckey->group)) == NULL) |
diff --git a/src/lib/libcrypto/ec/ec_mult.c b/src/lib/libcrypto/ec/ec_mult.c index f05df5332e..19f21675fb 100644 --- a/src/lib/libcrypto/ec/ec_mult.c +++ b/src/lib/libcrypto/ec/ec_mult.c | |||
@@ -169,11 +169,13 @@ static void ec_pre_comp_clear_free(void *pre_) | |||
169 | EC_POINT **p; | 169 | EC_POINT **p; |
170 | 170 | ||
171 | for (p = pre->points; *p != NULL; p++) | 171 | for (p = pre->points; *p != NULL; p++) |
172 | { | ||
172 | EC_POINT_clear_free(*p); | 173 | EC_POINT_clear_free(*p); |
173 | OPENSSL_cleanse(pre->points, sizeof pre->points); | 174 | OPENSSL_cleanse(p, sizeof *p); |
175 | } | ||
174 | OPENSSL_free(pre->points); | 176 | OPENSSL_free(pre->points); |
175 | } | 177 | } |
176 | OPENSSL_cleanse(pre, sizeof pre); | 178 | OPENSSL_cleanse(pre, sizeof *pre); |
177 | OPENSSL_free(pre); | 179 | OPENSSL_free(pre); |
178 | } | 180 | } |
179 | 181 | ||
diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c index 4d26f8bdf6..66a92e2a90 100644 --- a/src/lib/libcrypto/ec/ecp_smpl.c +++ b/src/lib/libcrypto/ec/ecp_smpl.c | |||
@@ -1406,6 +1406,9 @@ int ec_GFp_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT * | |||
1406 | { | 1406 | { |
1407 | return EC_POINT_is_at_infinity(group, b) ? 0 : 1; | 1407 | return EC_POINT_is_at_infinity(group, b) ? 0 : 1; |
1408 | } | 1408 | } |
1409 | |||
1410 | if (EC_POINT_is_at_infinity(group, b)) | ||
1411 | return 1; | ||
1409 | 1412 | ||
1410 | if (a->Z_is_one && b->Z_is_one) | 1413 | if (a->Z_is_one && b->Z_is_one) |
1411 | { | 1414 | { |
diff --git a/src/lib/libcrypto/ecdh/ech_lib.c b/src/lib/libcrypto/ecdh/ech_lib.c index e89b1d4772..4d8ea03d3d 100644 --- a/src/lib/libcrypto/ecdh/ech_lib.c +++ b/src/lib/libcrypto/ecdh/ech_lib.c | |||
@@ -96,7 +96,6 @@ const ECDH_METHOD *ECDH_get_default_method(void) | |||
96 | 96 | ||
97 | int ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth) | 97 | int ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth) |
98 | { | 98 | { |
99 | const ECDH_METHOD *mtmp; | ||
100 | ECDH_DATA *ecdh; | 99 | ECDH_DATA *ecdh; |
101 | 100 | ||
102 | ecdh = ecdh_check(eckey); | 101 | ecdh = ecdh_check(eckey); |
@@ -104,8 +103,8 @@ int ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth) | |||
104 | if (ecdh == NULL) | 103 | if (ecdh == NULL) |
105 | return 0; | 104 | return 0; |
106 | 105 | ||
107 | mtmp = ecdh->meth; | ||
108 | #if 0 | 106 | #if 0 |
107 | mtmp = ecdh->meth; | ||
109 | if (mtmp->finish) | 108 | if (mtmp->finish) |
110 | mtmp->finish(eckey); | 109 | mtmp->finish(eckey); |
111 | #endif | 110 | #endif |
diff --git a/src/lib/libcrypto/ecdsa/ecs_lib.c b/src/lib/libcrypto/ecdsa/ecs_lib.c index 85e8a3a7ed..2ebae3aa27 100644 --- a/src/lib/libcrypto/ecdsa/ecs_lib.c +++ b/src/lib/libcrypto/ecdsa/ecs_lib.c | |||
@@ -83,7 +83,6 @@ const ECDSA_METHOD *ECDSA_get_default_method(void) | |||
83 | 83 | ||
84 | int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth) | 84 | int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth) |
85 | { | 85 | { |
86 | const ECDSA_METHOD *mtmp; | ||
87 | ECDSA_DATA *ecdsa; | 86 | ECDSA_DATA *ecdsa; |
88 | 87 | ||
89 | ecdsa = ecdsa_check(eckey); | 88 | ecdsa = ecdsa_check(eckey); |
@@ -91,7 +90,6 @@ int ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth) | |||
91 | if (ecdsa == NULL) | 90 | if (ecdsa == NULL) |
92 | return 0; | 91 | return 0; |
93 | 92 | ||
94 | mtmp = ecdsa->meth; | ||
95 | #ifndef OPENSSL_NO_ENGINE | 93 | #ifndef OPENSSL_NO_ENGINE |
96 | if (ecdsa->engine) | 94 | if (ecdsa->engine) |
97 | { | 95 | { |
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c index 551cf5068f..1bbf328de5 100644 --- a/src/lib/libcrypto/ecdsa/ecs_ossl.c +++ b/src/lib/libcrypto/ecdsa/ecs_ossl.c | |||
@@ -144,6 +144,14 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, | |||
144 | } | 144 | } |
145 | while (BN_is_zero(k)); | 145 | while (BN_is_zero(k)); |
146 | 146 | ||
147 | /* We do not want timing information to leak the length of k, | ||
148 | * so we compute G*k using an equivalent scalar of fixed | ||
149 | * bit-length. */ | ||
150 | |||
151 | if (!BN_add(k, k, order)) goto err; | ||
152 | if (BN_num_bits(k) <= BN_num_bits(order)) | ||
153 | if (!BN_add(k, k, order)) goto err; | ||
154 | |||
147 | /* compute r the x-coordinate of generator * k */ | 155 | /* compute r the x-coordinate of generator * k */ |
148 | if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx)) | 156 | if (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx)) |
149 | { | 157 | { |
diff --git a/src/lib/libcrypto/engine/engine.h b/src/lib/libcrypto/engine/engine.h index 7fbd95f634..943aeae215 100644 --- a/src/lib/libcrypto/engine/engine.h +++ b/src/lib/libcrypto/engine/engine.h | |||
@@ -677,6 +677,7 @@ typedef struct st_dynamic_fns { | |||
677 | * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN(). */ | 677 | * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN(). */ |
678 | typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version); | 678 | typedef unsigned long (*dynamic_v_check_fn)(unsigned long ossl_version); |
679 | #define IMPLEMENT_DYNAMIC_CHECK_FN() \ | 679 | #define IMPLEMENT_DYNAMIC_CHECK_FN() \ |
680 | OPENSSL_EXPORT unsigned long v_check(unsigned long v); \ | ||
680 | OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \ | 681 | OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \ |
681 | if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \ | 682 | if(v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \ |
682 | return 0; } | 683 | return 0; } |
@@ -700,6 +701,8 @@ typedef int (*dynamic_bind_engine)(ENGINE *e, const char *id, | |||
700 | const dynamic_fns *fns); | 701 | const dynamic_fns *fns); |
701 | #define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ | 702 | #define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ |
702 | OPENSSL_EXPORT \ | 703 | OPENSSL_EXPORT \ |
704 | int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \ | ||
705 | OPENSSL_EXPORT \ | ||
703 | int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \ | 706 | int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \ |
704 | if(ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \ | 707 | if(ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \ |
705 | if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \ | 708 | if(!CRYPTO_set_mem_functions(fns->mem_fns.malloc_cb, \ |
diff --git a/src/lib/libcrypto/evp/encode.c b/src/lib/libcrypto/evp/encode.c index b42c747249..28546a84bc 100644 --- a/src/lib/libcrypto/evp/encode.c +++ b/src/lib/libcrypto/evp/encode.c | |||
@@ -235,7 +235,7 @@ void EVP_DecodeInit(EVP_ENCODE_CTX *ctx) | |||
235 | int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, | 235 | int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, |
236 | const unsigned char *in, int inl) | 236 | const unsigned char *in, int inl) |
237 | { | 237 | { |
238 | int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,tmp2,exp_nl; | 238 | int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,exp_nl; |
239 | unsigned char *d; | 239 | unsigned char *d; |
240 | 240 | ||
241 | n=ctx->num; | 241 | n=ctx->num; |
@@ -319,7 +319,6 @@ int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, | |||
319 | * lines. We process the line and then need to | 319 | * lines. We process the line and then need to |
320 | * accept the '\n' */ | 320 | * accept the '\n' */ |
321 | if ((v != B64_EOF) && (n >= 64)) exp_nl=1; | 321 | if ((v != B64_EOF) && (n >= 64)) exp_nl=1; |
322 | tmp2=v; | ||
323 | if (n > 0) | 322 | if (n > 0) |
324 | { | 323 | { |
325 | v=EVP_DecodeBlock(out,d,n); | 324 | v=EVP_DecodeBlock(out,d,n); |
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c index bead6a2170..c268d25cb4 100644 --- a/src/lib/libcrypto/evp/evp_enc.c +++ b/src/lib/libcrypto/evp/evp_enc.c | |||
@@ -204,6 +204,7 @@ skip_to_init: | |||
204 | case EVP_CIPH_OFB_MODE: | 204 | case EVP_CIPH_OFB_MODE: |
205 | 205 | ||
206 | ctx->num = 0; | 206 | ctx->num = 0; |
207 | /* fall-through */ | ||
207 | 208 | ||
208 | case EVP_CIPH_CBC_MODE: | 209 | case EVP_CIPH_CBC_MODE: |
209 | 210 | ||
diff --git a/src/lib/libcrypto/evp/m_sigver.c b/src/lib/libcrypto/evp/m_sigver.c index f0b7f95059..7e2731f4a4 100644 --- a/src/lib/libcrypto/evp/m_sigver.c +++ b/src/lib/libcrypto/evp/m_sigver.c | |||
@@ -137,7 +137,7 @@ int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen) | |||
137 | sctx = 0; | 137 | sctx = 0; |
138 | if (sigret) | 138 | if (sigret) |
139 | { | 139 | { |
140 | MS_STATIC EVP_MD_CTX tmp_ctx; | 140 | EVP_MD_CTX tmp_ctx; |
141 | unsigned char md[EVP_MAX_MD_SIZE]; | 141 | unsigned char md[EVP_MAX_MD_SIZE]; |
142 | unsigned int mdlen; | 142 | unsigned int mdlen; |
143 | EVP_MD_CTX_init(&tmp_ctx); | 143 | EVP_MD_CTX_init(&tmp_ctx); |
@@ -173,7 +173,7 @@ int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen) | |||
173 | 173 | ||
174 | int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, unsigned char *sig, size_t siglen) | 174 | int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, unsigned char *sig, size_t siglen) |
175 | { | 175 | { |
176 | MS_STATIC EVP_MD_CTX tmp_ctx; | 176 | EVP_MD_CTX tmp_ctx; |
177 | unsigned char md[EVP_MAX_MD_SIZE]; | 177 | unsigned char md[EVP_MAX_MD_SIZE]; |
178 | int r; | 178 | int r; |
179 | unsigned int mdlen; | 179 | unsigned int mdlen; |
diff --git a/src/lib/libcrypto/evp/p_lib.c b/src/lib/libcrypto/evp/p_lib.c index 1916c61699..e26ccd0d08 100644 --- a/src/lib/libcrypto/evp/p_lib.c +++ b/src/lib/libcrypto/evp/p_lib.c | |||
@@ -411,7 +411,10 @@ void EVP_PKEY_free(EVP_PKEY *x) | |||
411 | static void EVP_PKEY_free_it(EVP_PKEY *x) | 411 | static void EVP_PKEY_free_it(EVP_PKEY *x) |
412 | { | 412 | { |
413 | if (x->ameth && x->ameth->pkey_free) | 413 | if (x->ameth && x->ameth->pkey_free) |
414 | { | ||
414 | x->ameth->pkey_free(x); | 415 | x->ameth->pkey_free(x); |
416 | x->pkey.ptr = NULL; | ||
417 | } | ||
415 | #ifndef OPENSSL_NO_ENGINE | 418 | #ifndef OPENSSL_NO_ENGINE |
416 | if (x->engine) | 419 | if (x->engine) |
417 | { | 420 | { |
diff --git a/src/lib/libcrypto/evp/p_sign.c b/src/lib/libcrypto/evp/p_sign.c index 8df6d48a7e..bb893f5bde 100644 --- a/src/lib/libcrypto/evp/p_sign.c +++ b/src/lib/libcrypto/evp/p_sign.c | |||
@@ -81,7 +81,7 @@ int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, | |||
81 | unsigned char m[EVP_MAX_MD_SIZE]; | 81 | unsigned char m[EVP_MAX_MD_SIZE]; |
82 | unsigned int m_len; | 82 | unsigned int m_len; |
83 | int i,ok=0,v; | 83 | int i,ok=0,v; |
84 | MS_STATIC EVP_MD_CTX tmp_ctx; | 84 | EVP_MD_CTX tmp_ctx; |
85 | 85 | ||
86 | *siglen=0; | 86 | *siglen=0; |
87 | EVP_MD_CTX_init(&tmp_ctx); | 87 | EVP_MD_CTX_init(&tmp_ctx); |
diff --git a/src/lib/libcrypto/evp/p_verify.c b/src/lib/libcrypto/evp/p_verify.c index 8db46412f3..41d4b67130 100644 --- a/src/lib/libcrypto/evp/p_verify.c +++ b/src/lib/libcrypto/evp/p_verify.c | |||
@@ -68,7 +68,7 @@ int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, | |||
68 | unsigned char m[EVP_MAX_MD_SIZE]; | 68 | unsigned char m[EVP_MAX_MD_SIZE]; |
69 | unsigned int m_len; | 69 | unsigned int m_len; |
70 | int i,ok=0,v; | 70 | int i,ok=0,v; |
71 | MS_STATIC EVP_MD_CTX tmp_ctx; | 71 | EVP_MD_CTX tmp_ctx; |
72 | 72 | ||
73 | EVP_MD_CTX_init(&tmp_ctx); | 73 | EVP_MD_CTX_init(&tmp_ctx); |
74 | EVP_MD_CTX_copy_ex(&tmp_ctx,ctx); | 74 | EVP_MD_CTX_copy_ex(&tmp_ctx,ctx); |
diff --git a/src/lib/libcrypto/evp/pmeth_lib.c b/src/lib/libcrypto/evp/pmeth_lib.c index b2d8de3a8d..5481d4b8a5 100644 --- a/src/lib/libcrypto/evp/pmeth_lib.c +++ b/src/lib/libcrypto/evp/pmeth_lib.c | |||
@@ -134,6 +134,8 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) | |||
134 | id = pkey->ameth->pkey_id; | 134 | id = pkey->ameth->pkey_id; |
135 | } | 135 | } |
136 | #ifndef OPENSSL_NO_ENGINE | 136 | #ifndef OPENSSL_NO_ENGINE |
137 | if (pkey && pkey->engine) | ||
138 | e = pkey->engine; | ||
137 | /* Try to find an ENGINE which implements this method */ | 139 | /* Try to find an ENGINE which implements this method */ |
138 | if (e) | 140 | if (e) |
139 | { | 141 | { |
diff --git a/src/lib/libcrypto/hmac/hm_pmeth.c b/src/lib/libcrypto/hmac/hm_pmeth.c index 985921ca1a..71e8567a14 100644 --- a/src/lib/libcrypto/hmac/hm_pmeth.c +++ b/src/lib/libcrypto/hmac/hm_pmeth.c | |||
@@ -147,6 +147,8 @@ static int int_update(EVP_MD_CTX *ctx,const void *data,size_t count) | |||
147 | 147 | ||
148 | static int hmac_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx) | 148 | static int hmac_signctx_init(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx) |
149 | { | 149 | { |
150 | HMAC_PKEY_CTX *hctx = ctx->data; | ||
151 | HMAC_CTX_set_flags(&hctx->ctx, mctx->flags & ~EVP_MD_CTX_FLAG_NO_INIT); | ||
150 | EVP_MD_CTX_set_flags(mctx, EVP_MD_CTX_FLAG_NO_INIT); | 152 | EVP_MD_CTX_set_flags(mctx, EVP_MD_CTX_FLAG_NO_INIT); |
151 | mctx->update = int_update; | 153 | mctx->update = int_update; |
152 | return 1; | 154 | return 1; |
diff --git a/src/lib/libcrypto/hmac/hmac.c b/src/lib/libcrypto/hmac/hmac.c index 45015fe754..6c98fc43a3 100644 --- a/src/lib/libcrypto/hmac/hmac.c +++ b/src/lib/libcrypto/hmac/hmac.c | |||
@@ -138,12 +138,9 @@ int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len) | |||
138 | 138 | ||
139 | int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) | 139 | int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) |
140 | { | 140 | { |
141 | int j; | ||
142 | unsigned int i; | 141 | unsigned int i; |
143 | unsigned char buf[EVP_MAX_MD_SIZE]; | 142 | unsigned char buf[EVP_MAX_MD_SIZE]; |
144 | 143 | ||
145 | j=EVP_MD_block_size(ctx->md); | ||
146 | |||
147 | if (!EVP_DigestFinal_ex(&ctx->md_ctx,buf,&i)) | 144 | if (!EVP_DigestFinal_ex(&ctx->md_ctx,buf,&i)) |
148 | goto err; | 145 | goto err; |
149 | if (!EVP_MD_CTX_copy_ex(&ctx->md_ctx,&ctx->o_ctx)) | 146 | if (!EVP_MD_CTX_copy_ex(&ctx->md_ctx,&ctx->o_ctx)) |
diff --git a/src/lib/libcrypto/md32_common.h b/src/lib/libcrypto/md32_common.h index 1cb783944e..bb7381952a 100644 --- a/src/lib/libcrypto/md32_common.h +++ b/src/lib/libcrypto/md32_common.h | |||
@@ -165,7 +165,7 @@ | |||
165 | asm ( \ | 165 | asm ( \ |
166 | "roll %1,%0" \ | 166 | "roll %1,%0" \ |
167 | : "=r"(ret) \ | 167 | : "=r"(ret) \ |
168 | : "I"(n), "0"(a) \ | 168 | : "I"(n), "0"((unsigned int)(a)) \ |
169 | : "cc"); \ | 169 | : "cc"); \ |
170 | ret; \ | 170 | ret; \ |
171 | }) | 171 | }) |
@@ -383,6 +383,7 @@ int HASH_FINAL (unsigned char *md, HASH_CTX *c) | |||
383 | } | 383 | } |
384 | 384 | ||
385 | #ifndef MD32_REG_T | 385 | #ifndef MD32_REG_T |
386 | #if defined(__alpha) || defined(__sparcv9) || defined(__mips) | ||
386 | #define MD32_REG_T long | 387 | #define MD32_REG_T long |
387 | /* | 388 | /* |
388 | * This comment was originaly written for MD5, which is why it | 389 | * This comment was originaly written for MD5, which is why it |
@@ -400,9 +401,15 @@ int HASH_FINAL (unsigned char *md, HASH_CTX *c) | |||
400 | * Well, to be honest it should say that this *prevents* | 401 | * Well, to be honest it should say that this *prevents* |
401 | * performance degradation. | 402 | * performance degradation. |
402 | * <appro@fy.chalmers.se> | 403 | * <appro@fy.chalmers.se> |
403 | * Apparently there're LP64 compilers that generate better | 404 | */ |
404 | * code if A-D are declared int. Most notably GCC-x86_64 | 405 | #else |
405 | * generates better code. | 406 | /* |
407 | * Above is not absolute and there are LP64 compilers that | ||
408 | * generate better code if MD32_REG_T is defined int. The above | ||
409 | * pre-processor condition reflects the circumstances under which | ||
410 | * the conclusion was made and is subject to further extension. | ||
406 | * <appro@fy.chalmers.se> | 411 | * <appro@fy.chalmers.se> |
407 | */ | 412 | */ |
413 | #define MD32_REG_T int | ||
414 | #endif | ||
408 | #endif | 415 | #endif |
diff --git a/src/lib/libcrypto/o_time.c b/src/lib/libcrypto/o_time.c index eecbdd19f0..9030fdef7a 100644 --- a/src/lib/libcrypto/o_time.c +++ b/src/lib/libcrypto/o_time.c | |||
@@ -64,12 +64,18 @@ | |||
64 | #include "o_time.h" | 64 | #include "o_time.h" |
65 | 65 | ||
66 | #ifdef OPENSSL_SYS_VMS | 66 | #ifdef OPENSSL_SYS_VMS |
67 | # include <libdtdef.h> | 67 | # if __CRTL_VER >= 70000000 && \ |
68 | # include <lib$routines.h> | 68 | (defined _POSIX_C_SOURCE || !defined _ANSI_C_SOURCE) |
69 | # include <lnmdef.h> | 69 | # define VMS_GMTIME_OK |
70 | # include <starlet.h> | 70 | # endif |
71 | # include <descrip.h> | 71 | # ifndef VMS_GMTIME_OK |
72 | # include <stdlib.h> | 72 | # include <libdtdef.h> |
73 | # include <lib$routines.h> | ||
74 | # include <lnmdef.h> | ||
75 | # include <starlet.h> | ||
76 | # include <descrip.h> | ||
77 | # include <stdlib.h> | ||
78 | # endif /* ndef VMS_GMTIME_OK */ | ||
73 | #endif | 79 | #endif |
74 | 80 | ||
75 | struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result) | 81 | struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result) |
@@ -81,7 +87,7 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result) | |||
81 | so we don't even look at the return value */ | 87 | so we don't even look at the return value */ |
82 | gmtime_r(timer,result); | 88 | gmtime_r(timer,result); |
83 | ts = result; | 89 | ts = result; |
84 | #elif !defined(OPENSSL_SYS_VMS) | 90 | #elif !defined(OPENSSL_SYS_VMS) || defined(VMS_GMTIME_OK) |
85 | ts = gmtime(timer); | 91 | ts = gmtime(timer); |
86 | if (ts == NULL) | 92 | if (ts == NULL) |
87 | return NULL; | 93 | return NULL; |
@@ -89,7 +95,7 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result) | |||
89 | memcpy(result, ts, sizeof(struct tm)); | 95 | memcpy(result, ts, sizeof(struct tm)); |
90 | ts = result; | 96 | ts = result; |
91 | #endif | 97 | #endif |
92 | #ifdef OPENSSL_SYS_VMS | 98 | #if defined( OPENSSL_SYS_VMS) && !defined( VMS_GMTIME_OK) |
93 | if (ts == NULL) | 99 | if (ts == NULL) |
94 | { | 100 | { |
95 | static $DESCRIPTOR(tabnam,"LNM$DCL_LOGICAL"); | 101 | static $DESCRIPTOR(tabnam,"LNM$DCL_LOGICAL"); |
diff --git a/src/lib/libcrypto/ocsp/ocsp_ht.c b/src/lib/libcrypto/ocsp/ocsp_ht.c index 12bbfcffd1..af5fc16691 100644 --- a/src/lib/libcrypto/ocsp/ocsp_ht.c +++ b/src/lib/libcrypto/ocsp/ocsp_ht.c | |||
@@ -397,11 +397,12 @@ int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx) | |||
397 | 397 | ||
398 | 398 | ||
399 | case OHS_ASN1_HEADER: | 399 | case OHS_ASN1_HEADER: |
400 | /* Now reading ASN1 header: can read at least 6 bytes which | 400 | /* Now reading ASN1 header: can read at least 2 bytes which |
401 | * is more than enough for any valid ASN1 SEQUENCE header | 401 | * is enough for ASN1 SEQUENCE header and either length field |
402 | * or at least the length of the length field. | ||
402 | */ | 403 | */ |
403 | n = BIO_get_mem_data(rctx->mem, &p); | 404 | n = BIO_get_mem_data(rctx->mem, &p); |
404 | if (n < 6) | 405 | if (n < 2) |
405 | goto next_io; | 406 | goto next_io; |
406 | 407 | ||
407 | /* Check it is an ASN1 SEQUENCE */ | 408 | /* Check it is an ASN1 SEQUENCE */ |
@@ -414,6 +415,11 @@ int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx) | |||
414 | /* Check out length field */ | 415 | /* Check out length field */ |
415 | if (*p & 0x80) | 416 | if (*p & 0x80) |
416 | { | 417 | { |
418 | /* If MSB set on initial length octet we can now | ||
419 | * always read 6 octets: make sure we have them. | ||
420 | */ | ||
421 | if (n < 6) | ||
422 | goto next_io; | ||
417 | n = *p & 0x7F; | 423 | n = *p & 0x7F; |
418 | /* Not NDEF or excessive length */ | 424 | /* Not NDEF or excessive length */ |
419 | if (!n || (n > 4)) | 425 | if (!n || (n > 4)) |
diff --git a/src/lib/libcrypto/ocsp/ocsp_lib.c b/src/lib/libcrypto/ocsp/ocsp_lib.c index 36905d76cd..e92b86c060 100644 --- a/src/lib/libcrypto/ocsp/ocsp_lib.c +++ b/src/lib/libcrypto/ocsp/ocsp_lib.c | |||
@@ -170,14 +170,14 @@ int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath, int *pss | |||
170 | 170 | ||
171 | char *host, *port; | 171 | char *host, *port; |
172 | 172 | ||
173 | /* dup the buffer since we are going to mess with it */ | ||
174 | buf = BUF_strdup(url); | ||
175 | if (!buf) goto mem_err; | ||
176 | |||
177 | *phost = NULL; | 173 | *phost = NULL; |
178 | *pport = NULL; | 174 | *pport = NULL; |
179 | *ppath = NULL; | 175 | *ppath = NULL; |
180 | 176 | ||
177 | /* dup the buffer since we are going to mess with it */ | ||
178 | buf = BUF_strdup(url); | ||
179 | if (!buf) goto mem_err; | ||
180 | |||
181 | /* Check for initial colon */ | 181 | /* Check for initial colon */ |
182 | p = strchr(buf, ':'); | 182 | p = strchr(buf, ':'); |
183 | 183 | ||
diff --git a/src/lib/libcrypto/ocsp/ocsp_prn.c b/src/lib/libcrypto/ocsp/ocsp_prn.c index 1695c9c4ad..87608ff399 100644 --- a/src/lib/libcrypto/ocsp/ocsp_prn.c +++ b/src/lib/libcrypto/ocsp/ocsp_prn.c | |||
@@ -182,7 +182,6 @@ int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags) | |||
182 | { | 182 | { |
183 | int i, ret = 0; | 183 | int i, ret = 0; |
184 | long l; | 184 | long l; |
185 | unsigned char *p; | ||
186 | OCSP_CERTID *cid = NULL; | 185 | OCSP_CERTID *cid = NULL; |
187 | OCSP_BASICRESP *br = NULL; | 186 | OCSP_BASICRESP *br = NULL; |
188 | OCSP_RESPID *rid = NULL; | 187 | OCSP_RESPID *rid = NULL; |
@@ -207,7 +206,6 @@ int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o, unsigned long flags) | |||
207 | return 1; | 206 | return 1; |
208 | } | 207 | } |
209 | 208 | ||
210 | p = ASN1_STRING_data(rb->response); | ||
211 | i = ASN1_STRING_length(rb->response); | 209 | i = ASN1_STRING_length(rb->response); |
212 | if (!(br = OCSP_response_get1_basic(o))) goto err; | 210 | if (!(br = OCSP_response_get1_basic(o))) goto err; |
213 | rd = br->tbsResponseData; | 211 | rd = br->tbsResponseData; |
diff --git a/src/lib/libcrypto/opensslv.h b/src/lib/libcrypto/opensslv.h index 2fb110fa0e..310a3387be 100644 --- a/src/lib/libcrypto/opensslv.h +++ b/src/lib/libcrypto/opensslv.h | |||
@@ -25,11 +25,11 @@ | |||
25 | * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for | 25 | * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for |
26 | * major minor fix final patch/beta) | 26 | * major minor fix final patch/beta) |
27 | */ | 27 | */ |
28 | #define OPENSSL_VERSION_NUMBER 0x1000001fL | 28 | #define OPENSSL_VERSION_NUMBER 0x1000005fL |
29 | #ifdef OPENSSL_FIPS | 29 | #ifdef OPENSSL_FIPS |
30 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0a-fips 1 Jun 2010" | 30 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0e-fips 6 Sep 2011" |
31 | #else | 31 | #else |
32 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0a 1 Jun 2010" | 32 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0e 6 Sep 2011" |
33 | #endif | 33 | #endif |
34 | #define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT | 34 | #define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT |
35 | 35 | ||
diff --git a/src/lib/libcrypto/pem/pem_lib.c b/src/lib/libcrypto/pem/pem_lib.c index 42e4861bc1..cfc89a9921 100644 --- a/src/lib/libcrypto/pem/pem_lib.c +++ b/src/lib/libcrypto/pem/pem_lib.c | |||
@@ -482,7 +482,6 @@ int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *plen, | |||
482 | 482 | ||
483 | int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher) | 483 | int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher) |
484 | { | 484 | { |
485 | int o; | ||
486 | const EVP_CIPHER *enc=NULL; | 485 | const EVP_CIPHER *enc=NULL; |
487 | char *p,c; | 486 | char *p,c; |
488 | char **header_pp = &header; | 487 | char **header_pp = &header; |
@@ -522,7 +521,6 @@ int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher) | |||
522 | header++; | 521 | header++; |
523 | } | 522 | } |
524 | *header='\0'; | 523 | *header='\0'; |
525 | o=OBJ_sn2nid(p); | ||
526 | cipher->cipher=enc=EVP_get_cipherbyname(p); | 524 | cipher->cipher=enc=EVP_get_cipherbyname(p); |
527 | *header=c; | 525 | *header=c; |
528 | header++; | 526 | header++; |
diff --git a/src/lib/libcrypto/pem/pvkfmt.c b/src/lib/libcrypto/pem/pvkfmt.c index d998a67fa5..5f130c4528 100644 --- a/src/lib/libcrypto/pem/pvkfmt.c +++ b/src/lib/libcrypto/pem/pvkfmt.c | |||
@@ -662,7 +662,7 @@ static int do_PVK_header(const unsigned char **in, unsigned int length, | |||
662 | 662 | ||
663 | { | 663 | { |
664 | const unsigned char *p = *in; | 664 | const unsigned char *p = *in; |
665 | unsigned int pvk_magic, keytype, is_encrypted; | 665 | unsigned int pvk_magic, is_encrypted; |
666 | if (skip_magic) | 666 | if (skip_magic) |
667 | { | 667 | { |
668 | if (length < 20) | 668 | if (length < 20) |
@@ -689,7 +689,7 @@ static int do_PVK_header(const unsigned char **in, unsigned int length, | |||
689 | } | 689 | } |
690 | /* Skip reserved */ | 690 | /* Skip reserved */ |
691 | p += 4; | 691 | p += 4; |
692 | keytype = read_ledword(&p); | 692 | /*keytype = */read_ledword(&p); |
693 | is_encrypted = read_ledword(&p); | 693 | is_encrypted = read_ledword(&p); |
694 | *psaltlen = read_ledword(&p); | 694 | *psaltlen = read_ledword(&p); |
695 | *pkeylen = read_ledword(&p); | 695 | *pkeylen = read_ledword(&p); |
@@ -839,7 +839,7 @@ EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u) | |||
839 | static int i2b_PVK(unsigned char **out, EVP_PKEY*pk, int enclevel, | 839 | static int i2b_PVK(unsigned char **out, EVP_PKEY*pk, int enclevel, |
840 | pem_password_cb *cb, void *u) | 840 | pem_password_cb *cb, void *u) |
841 | { | 841 | { |
842 | int outlen = 24, noinc, pklen; | 842 | int outlen = 24, pklen; |
843 | unsigned char *p, *salt = NULL; | 843 | unsigned char *p, *salt = NULL; |
844 | if (enclevel) | 844 | if (enclevel) |
845 | outlen += PVK_SALTLEN; | 845 | outlen += PVK_SALTLEN; |
@@ -850,10 +850,7 @@ static int i2b_PVK(unsigned char **out, EVP_PKEY*pk, int enclevel, | |||
850 | if (!out) | 850 | if (!out) |
851 | return outlen; | 851 | return outlen; |
852 | if (*out) | 852 | if (*out) |
853 | { | ||
854 | p = *out; | 853 | p = *out; |
855 | noinc = 0; | ||
856 | } | ||
857 | else | 854 | else |
858 | { | 855 | { |
859 | p = OPENSSL_malloc(outlen); | 856 | p = OPENSSL_malloc(outlen); |
@@ -863,7 +860,6 @@ static int i2b_PVK(unsigned char **out, EVP_PKEY*pk, int enclevel, | |||
863 | return -1; | 860 | return -1; |
864 | } | 861 | } |
865 | *out = p; | 862 | *out = p; |
866 | noinc = 1; | ||
867 | } | 863 | } |
868 | 864 | ||
869 | write_ledword(&p, MS_PVKMAGIC); | 865 | write_ledword(&p, MS_PVKMAGIC); |
diff --git a/src/lib/libcrypto/perlasm/cbc.pl b/src/lib/libcrypto/perlasm/cbc.pl index e43dc9ae15..6fc2510905 100644 --- a/src/lib/libcrypto/perlasm/cbc.pl +++ b/src/lib/libcrypto/perlasm/cbc.pl | |||
@@ -158,7 +158,6 @@ sub cbc | |||
158 | &jmp_ptr($count); | 158 | &jmp_ptr($count); |
159 | 159 | ||
160 | &set_label("ej7"); | 160 | &set_label("ej7"); |
161 | &xor("edx", "edx") if $ppro; # ppro friendly | ||
162 | &movb(&HB("edx"), &BP(6,$in,"",0)); | 161 | &movb(&HB("edx"), &BP(6,$in,"",0)); |
163 | &shl("edx",8); | 162 | &shl("edx",8); |
164 | &set_label("ej6"); | 163 | &set_label("ej6"); |
@@ -170,7 +169,6 @@ sub cbc | |||
170 | &jmp(&label("ejend")); | 169 | &jmp(&label("ejend")); |
171 | &set_label("ej3"); | 170 | &set_label("ej3"); |
172 | &movb(&HB("ecx"), &BP(2,$in,"",0)); | 171 | &movb(&HB("ecx"), &BP(2,$in,"",0)); |
173 | &xor("ecx", "ecx") if $ppro; # ppro friendly | ||
174 | &shl("ecx",8); | 172 | &shl("ecx",8); |
175 | &set_label("ej2"); | 173 | &set_label("ej2"); |
176 | &movb(&HB("ecx"), &BP(1,$in,"",0)); | 174 | &movb(&HB("ecx"), &BP(1,$in,"",0)); |
diff --git a/src/lib/libcrypto/perlasm/x86_64-xlate.pl b/src/lib/libcrypto/perlasm/x86_64-xlate.pl index 354673acc1..e47116b74b 100755 --- a/src/lib/libcrypto/perlasm/x86_64-xlate.pl +++ b/src/lib/libcrypto/perlasm/x86_64-xlate.pl | |||
@@ -167,7 +167,7 @@ my %globals; | |||
167 | } elsif ($self->{op} =~ /^(pop|push)f/) { | 167 | } elsif ($self->{op} =~ /^(pop|push)f/) { |
168 | $self->{op} .= $self->{sz}; | 168 | $self->{op} .= $self->{sz}; |
169 | } elsif ($self->{op} eq "call" && $current_segment eq ".CRT\$XCU") { | 169 | } elsif ($self->{op} eq "call" && $current_segment eq ".CRT\$XCU") { |
170 | $self->{op} = "ALIGN\t8\n\tDQ"; | 170 | $self->{op} = "\tDQ"; |
171 | } | 171 | } |
172 | $self->{op}; | 172 | $self->{op}; |
173 | } | 173 | } |
@@ -545,6 +545,8 @@ my %globals; | |||
545 | if ($line=~/\.([px])data/) { | 545 | if ($line=~/\.([px])data/) { |
546 | $v.=" rdata align="; | 546 | $v.=" rdata align="; |
547 | $v.=$1 eq "p"? 4 : 8; | 547 | $v.=$1 eq "p"? 4 : 8; |
548 | } elsif ($line=~/\.CRT\$/i) { | ||
549 | $v.=" rdata align=8"; | ||
548 | } | 550 | } |
549 | } else { | 551 | } else { |
550 | $v="$current_segment\tENDS\n" if ($current_segment); | 552 | $v="$current_segment\tENDS\n" if ($current_segment); |
@@ -552,6 +554,8 @@ my %globals; | |||
552 | if ($line=~/\.([px])data/) { | 554 | if ($line=~/\.([px])data/) { |
553 | $v.=" READONLY"; | 555 | $v.=" READONLY"; |
554 | $v.=" ALIGN(".($1 eq "p" ? 4 : 8).")" if ($masm>=$masmref); | 556 | $v.=" ALIGN(".($1 eq "p" ? 4 : 8).")" if ($masm>=$masmref); |
557 | } elsif ($line=~/\.CRT\$/i) { | ||
558 | $v.=" READONLY DWORD"; | ||
555 | } | 559 | } |
556 | } | 560 | } |
557 | $current_segment = $line; | 561 | $current_segment = $line; |
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c index a29794bbbc..424203f648 100644 --- a/src/lib/libcrypto/pkcs12/p12_key.c +++ b/src/lib/libcrypto/pkcs12/p12_key.c | |||
@@ -107,6 +107,7 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, | |||
107 | unsigned char *B, *D, *I, *p, *Ai; | 107 | unsigned char *B, *D, *I, *p, *Ai; |
108 | int Slen, Plen, Ilen, Ijlen; | 108 | int Slen, Plen, Ilen, Ijlen; |
109 | int i, j, u, v; | 109 | int i, j, u, v; |
110 | int ret = 0; | ||
110 | BIGNUM *Ij, *Bpl1; /* These hold Ij and B + 1 */ | 111 | BIGNUM *Ij, *Bpl1; /* These hold Ij and B + 1 */ |
111 | EVP_MD_CTX ctx; | 112 | EVP_MD_CTX ctx; |
112 | #ifdef DEBUG_KEYGEN | 113 | #ifdef DEBUG_KEYGEN |
@@ -144,10 +145,8 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, | |||
144 | I = OPENSSL_malloc (Ilen); | 145 | I = OPENSSL_malloc (Ilen); |
145 | Ij = BN_new(); | 146 | Ij = BN_new(); |
146 | Bpl1 = BN_new(); | 147 | Bpl1 = BN_new(); |
147 | if (!D || !Ai || !B || !I || !Ij || !Bpl1) { | 148 | if (!D || !Ai || !B || !I || !Ij || !Bpl1) |
148 | PKCS12err(PKCS12_F_PKCS12_KEY_GEN_UNI,ERR_R_MALLOC_FAILURE); | 149 | goto err; |
149 | return 0; | ||
150 | } | ||
151 | for (i = 0; i < v; i++) D[i] = id; | 150 | for (i = 0; i < v; i++) D[i] = id; |
152 | p = I; | 151 | p = I; |
153 | for (i = 0; i < Slen; i++) *p++ = salt[i % saltlen]; | 152 | for (i = 0; i < Slen; i++) *p++ = salt[i % saltlen]; |
@@ -164,28 +163,22 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, | |||
164 | } | 163 | } |
165 | memcpy (out, Ai, min (n, u)); | 164 | memcpy (out, Ai, min (n, u)); |
166 | if (u >= n) { | 165 | if (u >= n) { |
167 | OPENSSL_free (Ai); | ||
168 | OPENSSL_free (B); | ||
169 | OPENSSL_free (D); | ||
170 | OPENSSL_free (I); | ||
171 | BN_free (Ij); | ||
172 | BN_free (Bpl1); | ||
173 | EVP_MD_CTX_cleanup(&ctx); | ||
174 | #ifdef DEBUG_KEYGEN | 166 | #ifdef DEBUG_KEYGEN |
175 | fprintf(stderr, "Output KEY (length %d)\n", tmpn); | 167 | fprintf(stderr, "Output KEY (length %d)\n", tmpn); |
176 | h__dump(tmpout, tmpn); | 168 | h__dump(tmpout, tmpn); |
177 | #endif | 169 | #endif |
178 | return 1; | 170 | ret = 1; |
171 | goto end; | ||
179 | } | 172 | } |
180 | n -= u; | 173 | n -= u; |
181 | out += u; | 174 | out += u; |
182 | for (j = 0; j < v; j++) B[j] = Ai[j % u]; | 175 | for (j = 0; j < v; j++) B[j] = Ai[j % u]; |
183 | /* Work out B + 1 first then can use B as tmp space */ | 176 | /* Work out B + 1 first then can use B as tmp space */ |
184 | BN_bin2bn (B, v, Bpl1); | 177 | if (!BN_bin2bn (B, v, Bpl1)) goto err; |
185 | BN_add_word (Bpl1, 1); | 178 | if (!BN_add_word (Bpl1, 1)) goto err; |
186 | for (j = 0; j < Ilen ; j+=v) { | 179 | for (j = 0; j < Ilen ; j+=v) { |
187 | BN_bin2bn (I + j, v, Ij); | 180 | if (!BN_bin2bn (I + j, v, Ij)) goto err; |
188 | BN_add (Ij, Ij, Bpl1); | 181 | if (!BN_add (Ij, Ij, Bpl1)) goto err; |
189 | BN_bn2bin (Ij, B); | 182 | BN_bn2bin (Ij, B); |
190 | Ijlen = BN_num_bytes (Ij); | 183 | Ijlen = BN_num_bytes (Ij); |
191 | /* If more than 2^(v*8) - 1 cut off MSB */ | 184 | /* If more than 2^(v*8) - 1 cut off MSB */ |
@@ -201,6 +194,19 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, | |||
201 | } else BN_bn2bin (Ij, I + j); | 194 | } else BN_bn2bin (Ij, I + j); |
202 | } | 195 | } |
203 | } | 196 | } |
197 | |||
198 | err: | ||
199 | PKCS12err(PKCS12_F_PKCS12_KEY_GEN_UNI,ERR_R_MALLOC_FAILURE); | ||
200 | |||
201 | end: | ||
202 | OPENSSL_free (Ai); | ||
203 | OPENSSL_free (B); | ||
204 | OPENSSL_free (D); | ||
205 | OPENSSL_free (I); | ||
206 | BN_free (Ij); | ||
207 | BN_free (Bpl1); | ||
208 | EVP_MD_CTX_cleanup(&ctx); | ||
209 | return ret; | ||
204 | } | 210 | } |
205 | #ifdef DEBUG_KEYGEN | 211 | #ifdef DEBUG_KEYGEN |
206 | void h__dump (unsigned char *p, int len) | 212 | void h__dump (unsigned char *p, int len) |
diff --git a/src/lib/libcrypto/pkcs7/pk7_doit.c b/src/lib/libcrypto/pkcs7/pk7_doit.c index 451de84489..3bf1a367bb 100644 --- a/src/lib/libcrypto/pkcs7/pk7_doit.c +++ b/src/lib/libcrypto/pkcs7/pk7_doit.c | |||
@@ -422,7 +422,6 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert) | |||
422 | X509_ALGOR *enc_alg=NULL; | 422 | X509_ALGOR *enc_alg=NULL; |
423 | STACK_OF(X509_ALGOR) *md_sk=NULL; | 423 | STACK_OF(X509_ALGOR) *md_sk=NULL; |
424 | STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL; | 424 | STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL; |
425 | X509_ALGOR *xalg=NULL; | ||
426 | PKCS7_RECIP_INFO *ri=NULL; | 425 | PKCS7_RECIP_INFO *ri=NULL; |
427 | 426 | ||
428 | i=OBJ_obj2nid(p7->type); | 427 | i=OBJ_obj2nid(p7->type); |
@@ -445,7 +444,6 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert) | |||
445 | PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE); | 444 | PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE); |
446 | goto err; | 445 | goto err; |
447 | } | 446 | } |
448 | xalg=p7->d.signed_and_enveloped->enc_data->algorithm; | ||
449 | break; | 447 | break; |
450 | case NID_pkcs7_enveloped: | 448 | case NID_pkcs7_enveloped: |
451 | rsk=p7->d.enveloped->recipientinfo; | 449 | rsk=p7->d.enveloped->recipientinfo; |
@@ -457,7 +455,6 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert) | |||
457 | PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE); | 455 | PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE); |
458 | goto err; | 456 | goto err; |
459 | } | 457 | } |
460 | xalg=p7->d.enveloped->enc_data->algorithm; | ||
461 | break; | 458 | break; |
462 | default: | 459 | default: |
463 | PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CONTENT_TYPE); | 460 | PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CONTENT_TYPE); |
diff --git a/src/lib/libcrypto/pkcs7/pk7_lib.c b/src/lib/libcrypto/pkcs7/pk7_lib.c index 3ca0952792..d411269b50 100644 --- a/src/lib/libcrypto/pkcs7/pk7_lib.c +++ b/src/lib/libcrypto/pkcs7/pk7_lib.c | |||
@@ -591,7 +591,6 @@ X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si) | |||
591 | int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher) | 591 | int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher) |
592 | { | 592 | { |
593 | int i; | 593 | int i; |
594 | ASN1_OBJECT *objtmp; | ||
595 | PKCS7_ENC_CONTENT *ec; | 594 | PKCS7_ENC_CONTENT *ec; |
596 | 595 | ||
597 | i=OBJ_obj2nid(p7->type); | 596 | i=OBJ_obj2nid(p7->type); |
@@ -614,7 +613,6 @@ int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher) | |||
614 | PKCS7err(PKCS7_F_PKCS7_SET_CIPHER,PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER); | 613 | PKCS7err(PKCS7_F_PKCS7_SET_CIPHER,PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER); |
615 | return(0); | 614 | return(0); |
616 | } | 615 | } |
617 | objtmp = OBJ_nid2obj(i); | ||
618 | 616 | ||
619 | ec->cipher = cipher; | 617 | ec->cipher = cipher; |
620 | return 1; | 618 | return 1; |
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c index 4ed40b7b70..bc7d9c5804 100644 --- a/src/lib/libcrypto/rand/randfile.c +++ b/src/lib/libcrypto/rand/randfile.c | |||
@@ -144,7 +144,9 @@ int RAND_load_file(const char *file, long bytes) | |||
144 | * I/O because we will waste system entropy. | 144 | * I/O because we will waste system entropy. |
145 | */ | 145 | */ |
146 | bytes = (bytes == -1) ? 2048 : bytes; /* ok, is 2048 enough? */ | 146 | bytes = (bytes == -1) ? 2048 : bytes; /* ok, is 2048 enough? */ |
147 | #ifndef OPENSSL_NO_SETVBUF_IONBF | ||
147 | setvbuf(in, NULL, _IONBF, 0); /* don't do buffered reads */ | 148 | setvbuf(in, NULL, _IONBF, 0); /* don't do buffered reads */ |
149 | #endif /* ndef OPENSSL_NO_SETVBUF_IONBF */ | ||
148 | } | 150 | } |
149 | #endif | 151 | #endif |
150 | for (;;) | 152 | for (;;) |
@@ -269,7 +271,6 @@ err: | |||
269 | const char *RAND_file_name(char *buf, size_t size) | 271 | const char *RAND_file_name(char *buf, size_t size) |
270 | { | 272 | { |
271 | char *s=NULL; | 273 | char *s=NULL; |
272 | int ok = 0; | ||
273 | #ifdef __OpenBSD__ | 274 | #ifdef __OpenBSD__ |
274 | struct stat sb; | 275 | struct stat sb; |
275 | #endif | 276 | #endif |
@@ -298,7 +299,6 @@ const char *RAND_file_name(char *buf, size_t size) | |||
298 | BUF_strlcat(buf,"/",size); | 299 | BUF_strlcat(buf,"/",size); |
299 | #endif | 300 | #endif |
300 | BUF_strlcat(buf,RFILE,size); | 301 | BUF_strlcat(buf,RFILE,size); |
301 | ok = 1; | ||
302 | } | 302 | } |
303 | else | 303 | else |
304 | buf[0] = '\0'; /* no file name */ | 304 | buf[0] = '\0'; /* no file name */ |
@@ -312,7 +312,7 @@ const char *RAND_file_name(char *buf, size_t size) | |||
312 | * to something hopefully decent if that isn't available. | 312 | * to something hopefully decent if that isn't available. |
313 | */ | 313 | */ |
314 | 314 | ||
315 | if (!ok) | 315 | if (!buf[0]) |
316 | if (BUF_strlcpy(buf,"/dev/arandom",size) >= size) { | 316 | if (BUF_strlcpy(buf,"/dev/arandom",size) >= size) { |
317 | return(NULL); | 317 | return(NULL); |
318 | } | 318 | } |
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c index c5eaeeae6b..7c941885f0 100644 --- a/src/lib/libcrypto/rsa/rsa_eay.c +++ b/src/lib/libcrypto/rsa/rsa_eay.c | |||
@@ -675,7 +675,7 @@ static int RSA_eay_public_decrypt(int flen, const unsigned char *from, | |||
675 | rsa->_method_mod_n)) goto err; | 675 | rsa->_method_mod_n)) goto err; |
676 | 676 | ||
677 | if ((padding == RSA_X931_PADDING) && ((ret->d[0] & 0xf) != 12)) | 677 | if ((padding == RSA_X931_PADDING) && ((ret->d[0] & 0xf) != 12)) |
678 | BN_sub(ret, rsa->n, ret); | 678 | if (!BN_sub(ret, rsa->n, ret)) goto err; |
679 | 679 | ||
680 | p=buf; | 680 | p=buf; |
681 | i=BN_bn2bin(ret,p); | 681 | i=BN_bn2bin(ret,p); |
diff --git a/src/lib/libcrypto/rsa/rsa_oaep.c b/src/lib/libcrypto/rsa/rsa_oaep.c index e238d10e5c..18d307ea9e 100644 --- a/src/lib/libcrypto/rsa/rsa_oaep.c +++ b/src/lib/libcrypto/rsa/rsa_oaep.c | |||
@@ -189,34 +189,40 @@ int PKCS1_MGF1(unsigned char *mask, long len, | |||
189 | EVP_MD_CTX c; | 189 | EVP_MD_CTX c; |
190 | unsigned char md[EVP_MAX_MD_SIZE]; | 190 | unsigned char md[EVP_MAX_MD_SIZE]; |
191 | int mdlen; | 191 | int mdlen; |
192 | int rv = -1; | ||
192 | 193 | ||
193 | EVP_MD_CTX_init(&c); | 194 | EVP_MD_CTX_init(&c); |
194 | mdlen = EVP_MD_size(dgst); | 195 | mdlen = EVP_MD_size(dgst); |
195 | if (mdlen < 0) | 196 | if (mdlen < 0) |
196 | return -1; | 197 | goto err; |
197 | for (i = 0; outlen < len; i++) | 198 | for (i = 0; outlen < len; i++) |
198 | { | 199 | { |
199 | cnt[0] = (unsigned char)((i >> 24) & 255); | 200 | cnt[0] = (unsigned char)((i >> 24) & 255); |
200 | cnt[1] = (unsigned char)((i >> 16) & 255); | 201 | cnt[1] = (unsigned char)((i >> 16) & 255); |
201 | cnt[2] = (unsigned char)((i >> 8)) & 255; | 202 | cnt[2] = (unsigned char)((i >> 8)) & 255; |
202 | cnt[3] = (unsigned char)(i & 255); | 203 | cnt[3] = (unsigned char)(i & 255); |
203 | EVP_DigestInit_ex(&c,dgst, NULL); | 204 | if (!EVP_DigestInit_ex(&c,dgst, NULL) |
204 | EVP_DigestUpdate(&c, seed, seedlen); | 205 | || !EVP_DigestUpdate(&c, seed, seedlen) |
205 | EVP_DigestUpdate(&c, cnt, 4); | 206 | || !EVP_DigestUpdate(&c, cnt, 4)) |
207 | goto err; | ||
206 | if (outlen + mdlen <= len) | 208 | if (outlen + mdlen <= len) |
207 | { | 209 | { |
208 | EVP_DigestFinal_ex(&c, mask + outlen, NULL); | 210 | if (!EVP_DigestFinal_ex(&c, mask + outlen, NULL)) |
211 | goto err; | ||
209 | outlen += mdlen; | 212 | outlen += mdlen; |
210 | } | 213 | } |
211 | else | 214 | else |
212 | { | 215 | { |
213 | EVP_DigestFinal_ex(&c, md, NULL); | 216 | if (!EVP_DigestFinal_ex(&c, md, NULL)) |
217 | goto err; | ||
214 | memcpy(mask + outlen, md, len - outlen); | 218 | memcpy(mask + outlen, md, len - outlen); |
215 | outlen = len; | 219 | outlen = len; |
216 | } | 220 | } |
217 | } | 221 | } |
222 | rv = 0; | ||
223 | err: | ||
218 | EVP_MD_CTX_cleanup(&c); | 224 | EVP_MD_CTX_cleanup(&c); |
219 | return 0; | 225 | return rv; |
220 | } | 226 | } |
221 | 227 | ||
222 | static int MGF1(unsigned char *mask, long len, const unsigned char *seed, | 228 | static int MGF1(unsigned char *mask, long len, const unsigned char *seed, |
diff --git a/src/lib/libcrypto/sha/asm/sha1-armv4-large.pl b/src/lib/libcrypto/sha/asm/sha1-armv4-large.pl index 88861af641..6e65fe3e01 100644 --- a/src/lib/libcrypto/sha/asm/sha1-armv4-large.pl +++ b/src/lib/libcrypto/sha/asm/sha1-armv4-large.pl | |||
@@ -37,9 +37,18 @@ | |||
37 | # modes are limited. As result it takes more instructions to do | 37 | # modes are limited. As result it takes more instructions to do |
38 | # the same job in Thumb, therefore the code is never twice as | 38 | # the same job in Thumb, therefore the code is never twice as |
39 | # small and always slower. | 39 | # small and always slower. |
40 | # [***] which is also ~35% better than compiler generated code. | 40 | # [***] which is also ~35% better than compiler generated code. Dual- |
41 | # issue Cortex A8 core was measured to process input block in | ||
42 | # ~990 cycles. | ||
41 | 43 | ||
42 | $output=shift; | 44 | # August 2010. |
45 | # | ||
46 | # Rescheduling for dual-issue pipeline resulted in 13% improvement on | ||
47 | # Cortex A8 core and in absolute terms ~870 cycles per input block | ||
48 | # [or 13.6 cycles per byte]. | ||
49 | |||
50 | |||
51 | while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {} | ||
43 | open STDOUT,">$output"; | 52 | open STDOUT,">$output"; |
44 | 53 | ||
45 | $ctx="r0"; | 54 | $ctx="r0"; |
@@ -58,43 +67,22 @@ $t3="r12"; | |||
58 | $Xi="r14"; | 67 | $Xi="r14"; |
59 | @V=($a,$b,$c,$d,$e); | 68 | @V=($a,$b,$c,$d,$e); |
60 | 69 | ||
61 | # One can optimize this for aligned access on big-endian architecture, | ||
62 | # but code's endian neutrality makes it too pretty:-) | ||
63 | sub Xload { | ||
64 | my ($a,$b,$c,$d,$e)=@_; | ||
65 | $code.=<<___; | ||
66 | ldrb $t0,[$inp],#4 | ||
67 | ldrb $t1,[$inp,#-3] | ||
68 | ldrb $t2,[$inp,#-2] | ||
69 | ldrb $t3,[$inp,#-1] | ||
70 | add $e,$K,$e,ror#2 @ E+=K_00_19 | ||
71 | orr $t0,$t1,$t0,lsl#8 | ||
72 | add $e,$e,$a,ror#27 @ E+=ROR(A,27) | ||
73 | orr $t0,$t2,$t0,lsl#8 | ||
74 | eor $t1,$c,$d @ F_xx_xx | ||
75 | orr $t0,$t3,$t0,lsl#8 | ||
76 | add $e,$e,$t0 @ E+=X[i] | ||
77 | str $t0,[$Xi,#-4]! | ||
78 | ___ | ||
79 | } | ||
80 | sub Xupdate { | 70 | sub Xupdate { |
81 | my ($a,$b,$c,$d,$e,$flag)=@_; | 71 | my ($a,$b,$c,$d,$e,$opt1,$opt2)=@_; |
82 | $code.=<<___; | 72 | $code.=<<___; |
83 | ldr $t0,[$Xi,#15*4] | 73 | ldr $t0,[$Xi,#15*4] |
84 | ldr $t1,[$Xi,#13*4] | 74 | ldr $t1,[$Xi,#13*4] |
85 | ldr $t2,[$Xi,#7*4] | 75 | ldr $t2,[$Xi,#7*4] |
86 | ldr $t3,[$Xi,#2*4] | ||
87 | add $e,$K,$e,ror#2 @ E+=K_xx_xx | 76 | add $e,$K,$e,ror#2 @ E+=K_xx_xx |
77 | ldr $t3,[$Xi,#2*4] | ||
88 | eor $t0,$t0,$t1 | 78 | eor $t0,$t0,$t1 |
89 | eor $t0,$t0,$t2 | 79 | eor $t2,$t2,$t3 |
90 | eor $t0,$t0,$t3 | 80 | eor $t1,$c,$d @ F_xx_xx |
91 | add $e,$e,$a,ror#27 @ E+=ROR(A,27) | ||
92 | ___ | ||
93 | $code.=<<___ if (!defined($flag)); | ||
94 | eor $t1,$c,$d @ F_xx_xx, but not in 40_59 | ||
95 | ___ | ||
96 | $code.=<<___; | ||
97 | mov $t0,$t0,ror#31 | 81 | mov $t0,$t0,ror#31 |
82 | add $e,$e,$a,ror#27 @ E+=ROR(A,27) | ||
83 | eor $t0,$t0,$t2,ror#31 | ||
84 | $opt1 @ F_xx_xx | ||
85 | $opt2 @ F_xx_xx | ||
98 | add $e,$e,$t0 @ E+=X[i] | 86 | add $e,$e,$t0 @ E+=X[i] |
99 | str $t0,[$Xi,#-4]! | 87 | str $t0,[$Xi,#-4]! |
100 | ___ | 88 | ___ |
@@ -102,19 +90,29 @@ ___ | |||
102 | 90 | ||
103 | sub BODY_00_15 { | 91 | sub BODY_00_15 { |
104 | my ($a,$b,$c,$d,$e)=@_; | 92 | my ($a,$b,$c,$d,$e)=@_; |
105 | &Xload(@_); | ||
106 | $code.=<<___; | 93 | $code.=<<___; |
94 | ldrb $t0,[$inp],#4 | ||
95 | ldrb $t1,[$inp,#-1] | ||
96 | ldrb $t2,[$inp,#-2] | ||
97 | add $e,$K,$e,ror#2 @ E+=K_00_19 | ||
98 | ldrb $t3,[$inp,#-3] | ||
99 | add $e,$e,$a,ror#27 @ E+=ROR(A,27) | ||
100 | orr $t0,$t1,$t0,lsl#24 | ||
101 | eor $t1,$c,$d @ F_xx_xx | ||
102 | orr $t0,$t0,$t2,lsl#8 | ||
103 | orr $t0,$t0,$t3,lsl#16 | ||
107 | and $t1,$b,$t1,ror#2 | 104 | and $t1,$b,$t1,ror#2 |
105 | add $e,$e,$t0 @ E+=X[i] | ||
108 | eor $t1,$t1,$d,ror#2 @ F_00_19(B,C,D) | 106 | eor $t1,$t1,$d,ror#2 @ F_00_19(B,C,D) |
107 | str $t0,[$Xi,#-4]! | ||
109 | add $e,$e,$t1 @ E+=F_00_19(B,C,D) | 108 | add $e,$e,$t1 @ E+=F_00_19(B,C,D) |
110 | ___ | 109 | ___ |
111 | } | 110 | } |
112 | 111 | ||
113 | sub BODY_16_19 { | 112 | sub BODY_16_19 { |
114 | my ($a,$b,$c,$d,$e)=@_; | 113 | my ($a,$b,$c,$d,$e)=@_; |
115 | &Xupdate(@_); | 114 | &Xupdate(@_,"and $t1,$b,$t1,ror#2"); |
116 | $code.=<<___; | 115 | $code.=<<___; |
117 | and $t1,$b,$t1,ror#2 | ||
118 | eor $t1,$t1,$d,ror#2 @ F_00_19(B,C,D) | 116 | eor $t1,$t1,$d,ror#2 @ F_00_19(B,C,D) |
119 | add $e,$e,$t1 @ E+=F_00_19(B,C,D) | 117 | add $e,$e,$t1 @ E+=F_00_19(B,C,D) |
120 | ___ | 118 | ___ |
@@ -122,22 +120,18 @@ ___ | |||
122 | 120 | ||
123 | sub BODY_20_39 { | 121 | sub BODY_20_39 { |
124 | my ($a,$b,$c,$d,$e)=@_; | 122 | my ($a,$b,$c,$d,$e)=@_; |
125 | &Xupdate(@_); | 123 | &Xupdate(@_,"eor $t1,$b,$t1,ror#2"); |
126 | $code.=<<___; | 124 | $code.=<<___; |
127 | eor $t1,$b,$t1,ror#2 @ F_20_39(B,C,D) | ||
128 | add $e,$e,$t1 @ E+=F_20_39(B,C,D) | 125 | add $e,$e,$t1 @ E+=F_20_39(B,C,D) |
129 | ___ | 126 | ___ |
130 | } | 127 | } |
131 | 128 | ||
132 | sub BODY_40_59 { | 129 | sub BODY_40_59 { |
133 | my ($a,$b,$c,$d,$e)=@_; | 130 | my ($a,$b,$c,$d,$e)=@_; |
134 | &Xupdate(@_,1); | 131 | &Xupdate(@_,"and $t1,$b,$t1,ror#2","and $t2,$c,$d"); |
135 | $code.=<<___; | 132 | $code.=<<___; |
136 | and $t1,$b,$c,ror#2 | ||
137 | orr $t2,$b,$c,ror#2 | ||
138 | and $t2,$t2,$d,ror#2 | ||
139 | orr $t1,$t1,$t2 @ F_40_59(B,C,D) | ||
140 | add $e,$e,$t1 @ E+=F_40_59(B,C,D) | 133 | add $e,$e,$t1 @ E+=F_40_59(B,C,D) |
134 | add $e,$e,$t2,ror#2 | ||
141 | ___ | 135 | ___ |
142 | } | 136 | } |
143 | 137 | ||
diff --git a/src/lib/libcrypto/sha/asm/sha1-sparcv9.pl b/src/lib/libcrypto/sha/asm/sha1-sparcv9.pl index 8306fc88cc..5c161cecd6 100644 --- a/src/lib/libcrypto/sha/asm/sha1-sparcv9.pl +++ b/src/lib/libcrypto/sha/asm/sha1-sparcv9.pl | |||
@@ -276,6 +276,7 @@ $code.=<<___; | |||
276 | .type sha1_block_data_order,#function | 276 | .type sha1_block_data_order,#function |
277 | .size sha1_block_data_order,(.-sha1_block_data_order) | 277 | .size sha1_block_data_order,(.-sha1_block_data_order) |
278 | .asciz "SHA1 block transform for SPARCv9, CRYPTOGAMS by <appro\@openssl.org>" | 278 | .asciz "SHA1 block transform for SPARCv9, CRYPTOGAMS by <appro\@openssl.org>" |
279 | .align 4 | ||
279 | ___ | 280 | ___ |
280 | 281 | ||
281 | $code =~ s/\`([^\`]*)\`/eval $1/gem; | 282 | $code =~ s/\`([^\`]*)\`/eval $1/gem; |
diff --git a/src/lib/libcrypto/sha/asm/sha1-sparcv9a.pl b/src/lib/libcrypto/sha/asm/sha1-sparcv9a.pl index 15eb854bad..85e8d68086 100644 --- a/src/lib/libcrypto/sha/asm/sha1-sparcv9a.pl +++ b/src/lib/libcrypto/sha/asm/sha1-sparcv9a.pl | |||
@@ -539,6 +539,7 @@ $code.=<<___; | |||
539 | .type sha1_block_data_order,#function | 539 | .type sha1_block_data_order,#function |
540 | .size sha1_block_data_order,(.-sha1_block_data_order) | 540 | .size sha1_block_data_order,(.-sha1_block_data_order) |
541 | .asciz "SHA1 block transform for SPARCv9a, CRYPTOGAMS by <appro\@openssl.org>" | 541 | .asciz "SHA1 block transform for SPARCv9a, CRYPTOGAMS by <appro\@openssl.org>" |
542 | .align 4 | ||
542 | ___ | 543 | ___ |
543 | 544 | ||
544 | # Purpose of these subroutines is to explicitly encode VIS instructions, | 545 | # Purpose of these subroutines is to explicitly encode VIS instructions, |
diff --git a/src/lib/libcrypto/sha/asm/sha256-armv4.pl b/src/lib/libcrypto/sha/asm/sha256-armv4.pl index 48d846deec..492cb62bc0 100644 --- a/src/lib/libcrypto/sha/asm/sha256-armv4.pl +++ b/src/lib/libcrypto/sha/asm/sha256-armv4.pl | |||
@@ -11,9 +11,14 @@ | |||
11 | 11 | ||
12 | # Performance is ~2x better than gcc 3.4 generated code and in "abso- | 12 | # Performance is ~2x better than gcc 3.4 generated code and in "abso- |
13 | # lute" terms is ~2250 cycles per 64-byte block or ~35 cycles per | 13 | # lute" terms is ~2250 cycles per 64-byte block or ~35 cycles per |
14 | # byte. | 14 | # byte [on single-issue Xscale PXA250 core]. |
15 | 15 | ||
16 | $output=shift; | 16 | # July 2010. |
17 | # | ||
18 | # Rescheduling for dual-issue pipeline resulted in 22% improvement on | ||
19 | # Cortex A8 core and ~20 cycles per processed byte. | ||
20 | |||
21 | while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {} | ||
17 | open STDOUT,">$output"; | 22 | open STDOUT,">$output"; |
18 | 23 | ||
19 | $ctx="r0"; $t0="r0"; | 24 | $ctx="r0"; $t0="r0"; |
@@ -52,27 +57,27 @@ $code.=<<___ if ($i<16); | |||
52 | ___ | 57 | ___ |
53 | $code.=<<___; | 58 | $code.=<<___; |
54 | ldr $t2,[$Ktbl],#4 @ *K256++ | 59 | ldr $t2,[$Ktbl],#4 @ *K256++ |
55 | str $T1,[sp,#`$i%16`*4] | ||
56 | mov $t0,$e,ror#$Sigma1[0] | 60 | mov $t0,$e,ror#$Sigma1[0] |
61 | str $T1,[sp,#`$i%16`*4] | ||
57 | eor $t0,$t0,$e,ror#$Sigma1[1] | 62 | eor $t0,$t0,$e,ror#$Sigma1[1] |
58 | eor $t0,$t0,$e,ror#$Sigma1[2] @ Sigma1(e) | ||
59 | add $T1,$T1,$t0 | ||
60 | eor $t1,$f,$g | 63 | eor $t1,$f,$g |
64 | eor $t0,$t0,$e,ror#$Sigma1[2] @ Sigma1(e) | ||
61 | and $t1,$t1,$e | 65 | and $t1,$t1,$e |
66 | add $T1,$T1,$t0 | ||
62 | eor $t1,$t1,$g @ Ch(e,f,g) | 67 | eor $t1,$t1,$g @ Ch(e,f,g) |
63 | add $T1,$T1,$t1 | ||
64 | add $T1,$T1,$h | 68 | add $T1,$T1,$h |
65 | add $T1,$T1,$t2 | ||
66 | mov $h,$a,ror#$Sigma0[0] | 69 | mov $h,$a,ror#$Sigma0[0] |
70 | add $T1,$T1,$t1 | ||
67 | eor $h,$h,$a,ror#$Sigma0[1] | 71 | eor $h,$h,$a,ror#$Sigma0[1] |
72 | add $T1,$T1,$t2 | ||
68 | eor $h,$h,$a,ror#$Sigma0[2] @ Sigma0(a) | 73 | eor $h,$h,$a,ror#$Sigma0[2] @ Sigma0(a) |
69 | orr $t0,$a,$b | 74 | orr $t0,$a,$b |
70 | and $t0,$t0,$c | ||
71 | and $t1,$a,$b | 75 | and $t1,$a,$b |
76 | and $t0,$t0,$c | ||
77 | add $h,$h,$T1 | ||
72 | orr $t0,$t0,$t1 @ Maj(a,b,c) | 78 | orr $t0,$t0,$t1 @ Maj(a,b,c) |
73 | add $h,$h,$t0 | ||
74 | add $d,$d,$T1 | 79 | add $d,$d,$T1 |
75 | add $h,$h,$T1 | 80 | add $h,$h,$t0 |
76 | ___ | 81 | ___ |
77 | } | 82 | } |
78 | 83 | ||
@@ -80,19 +85,19 @@ sub BODY_16_XX { | |||
80 | my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_; | 85 | my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_; |
81 | 86 | ||
82 | $code.=<<___; | 87 | $code.=<<___; |
83 | ldr $t1,[sp,#`($i+1)%16`*4] @ $i | 88 | ldr $t1,[sp,#`($i+1)%16`*4] @ $i |
84 | ldr $t2,[sp,#`($i+14)%16`*4] | 89 | ldr $t2,[sp,#`($i+14)%16`*4] |
85 | ldr $T1,[sp,#`($i+0)%16`*4] | 90 | ldr $T1,[sp,#`($i+0)%16`*4] |
86 | ldr $inp,[sp,#`($i+9)%16`*4] | ||
87 | mov $t0,$t1,ror#$sigma0[0] | 91 | mov $t0,$t1,ror#$sigma0[0] |
92 | ldr $inp,[sp,#`($i+9)%16`*4] | ||
88 | eor $t0,$t0,$t1,ror#$sigma0[1] | 93 | eor $t0,$t0,$t1,ror#$sigma0[1] |
89 | eor $t0,$t0,$t1,lsr#$sigma0[2] @ sigma0(X[i+1]) | 94 | eor $t0,$t0,$t1,lsr#$sigma0[2] @ sigma0(X[i+1]) |
90 | mov $t1,$t2,ror#$sigma1[0] | 95 | mov $t1,$t2,ror#$sigma1[0] |
96 | add $T1,$T1,$t0 | ||
91 | eor $t1,$t1,$t2,ror#$sigma1[1] | 97 | eor $t1,$t1,$t2,ror#$sigma1[1] |
98 | add $T1,$T1,$inp | ||
92 | eor $t1,$t1,$t2,lsr#$sigma1[2] @ sigma1(X[i+14]) | 99 | eor $t1,$t1,$t2,lsr#$sigma1[2] @ sigma1(X[i+14]) |
93 | add $T1,$T1,$t0 | ||
94 | add $T1,$T1,$t1 | 100 | add $T1,$T1,$t1 |
95 | add $T1,$T1,$inp | ||
96 | ___ | 101 | ___ |
97 | &BODY_00_15(@_); | 102 | &BODY_00_15(@_); |
98 | } | 103 | } |
diff --git a/src/lib/libcrypto/sha/asm/sha512-armv4.pl b/src/lib/libcrypto/sha/asm/sha512-armv4.pl index 4fbb94a914..3a35861ac6 100644 --- a/src/lib/libcrypto/sha/asm/sha512-armv4.pl +++ b/src/lib/libcrypto/sha/asm/sha512-armv4.pl | |||
@@ -10,7 +10,13 @@ | |||
10 | # SHA512 block procedure for ARMv4. September 2007. | 10 | # SHA512 block procedure for ARMv4. September 2007. |
11 | 11 | ||
12 | # This code is ~4.5 (four and a half) times faster than code generated | 12 | # This code is ~4.5 (four and a half) times faster than code generated |
13 | # by gcc 3.4 and it spends ~72 clock cycles per byte. | 13 | # by gcc 3.4 and it spends ~72 clock cycles per byte [on single-issue |
14 | # Xscale PXA250 core]. | ||
15 | # | ||
16 | # July 2010. | ||
17 | # | ||
18 | # Rescheduling for dual-issue pipeline resulted in 6% improvement on | ||
19 | # Cortex A8 core and ~40 cycles per processed byte. | ||
14 | 20 | ||
15 | # Byte order [in]dependence. ========================================= | 21 | # Byte order [in]dependence. ========================================= |
16 | # | 22 | # |
@@ -22,7 +28,7 @@ $hi=0; | |||
22 | $lo=4; | 28 | $lo=4; |
23 | # ==================================================================== | 29 | # ==================================================================== |
24 | 30 | ||
25 | $output=shift; | 31 | while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {} |
26 | open STDOUT,">$output"; | 32 | open STDOUT,">$output"; |
27 | 33 | ||
28 | $ctx="r0"; | 34 | $ctx="r0"; |
@@ -73,33 +79,31 @@ $code.=<<___; | |||
73 | eor $t0,$t0,$Elo,lsl#23 | 79 | eor $t0,$t0,$Elo,lsl#23 |
74 | eor $t1,$t1,$Ehi,lsl#23 @ Sigma1(e) | 80 | eor $t1,$t1,$Ehi,lsl#23 @ Sigma1(e) |
75 | adds $Tlo,$Tlo,$t0 | 81 | adds $Tlo,$Tlo,$t0 |
76 | adc $Thi,$Thi,$t1 @ T += Sigma1(e) | ||
77 | adds $Tlo,$Tlo,$t2 | ||
78 | adc $Thi,$Thi,$t3 @ T += h | ||
79 | |||
80 | ldr $t0,[sp,#$Foff+0] @ f.lo | 82 | ldr $t0,[sp,#$Foff+0] @ f.lo |
83 | adc $Thi,$Thi,$t1 @ T += Sigma1(e) | ||
81 | ldr $t1,[sp,#$Foff+4] @ f.hi | 84 | ldr $t1,[sp,#$Foff+4] @ f.hi |
85 | adds $Tlo,$Tlo,$t2 | ||
82 | ldr $t2,[sp,#$Goff+0] @ g.lo | 86 | ldr $t2,[sp,#$Goff+0] @ g.lo |
87 | adc $Thi,$Thi,$t3 @ T += h | ||
83 | ldr $t3,[sp,#$Goff+4] @ g.hi | 88 | ldr $t3,[sp,#$Goff+4] @ g.hi |
84 | str $Elo,[sp,#$Eoff+0] | ||
85 | str $Ehi,[sp,#$Eoff+4] | ||
86 | str $Alo,[sp,#$Aoff+0] | ||
87 | str $Ahi,[sp,#$Aoff+4] | ||
88 | 89 | ||
89 | eor $t0,$t0,$t2 | 90 | eor $t0,$t0,$t2 |
91 | str $Elo,[sp,#$Eoff+0] | ||
90 | eor $t1,$t1,$t3 | 92 | eor $t1,$t1,$t3 |
93 | str $Ehi,[sp,#$Eoff+4] | ||
91 | and $t0,$t0,$Elo | 94 | and $t0,$t0,$Elo |
95 | str $Alo,[sp,#$Aoff+0] | ||
92 | and $t1,$t1,$Ehi | 96 | and $t1,$t1,$Ehi |
97 | str $Ahi,[sp,#$Aoff+4] | ||
93 | eor $t0,$t0,$t2 | 98 | eor $t0,$t0,$t2 |
94 | eor $t1,$t1,$t3 @ Ch(e,f,g) | ||
95 | |||
96 | ldr $t2,[$Ktbl,#4] @ K[i].lo | 99 | ldr $t2,[$Ktbl,#4] @ K[i].lo |
100 | eor $t1,$t1,$t3 @ Ch(e,f,g) | ||
97 | ldr $t3,[$Ktbl,#0] @ K[i].hi | 101 | ldr $t3,[$Ktbl,#0] @ K[i].hi |
98 | ldr $Elo,[sp,#$Doff+0] @ d.lo | ||
99 | ldr $Ehi,[sp,#$Doff+4] @ d.hi | ||
100 | 102 | ||
101 | adds $Tlo,$Tlo,$t0 | 103 | adds $Tlo,$Tlo,$t0 |
104 | ldr $Elo,[sp,#$Doff+0] @ d.lo | ||
102 | adc $Thi,$Thi,$t1 @ T += Ch(e,f,g) | 105 | adc $Thi,$Thi,$t1 @ T += Ch(e,f,g) |
106 | ldr $Ehi,[sp,#$Doff+4] @ d.hi | ||
103 | adds $Tlo,$Tlo,$t2 | 107 | adds $Tlo,$Tlo,$t2 |
104 | adc $Thi,$Thi,$t3 @ T += K[i] | 108 | adc $Thi,$Thi,$t3 @ T += K[i] |
105 | adds $Elo,$Elo,$Tlo | 109 | adds $Elo,$Elo,$Tlo |
diff --git a/src/lib/libcrypto/sha/asm/sha512-sparcv9.pl b/src/lib/libcrypto/sha/asm/sha512-sparcv9.pl index 54241aab50..ec5d78135e 100644 --- a/src/lib/libcrypto/sha/asm/sha512-sparcv9.pl +++ b/src/lib/libcrypto/sha/asm/sha512-sparcv9.pl | |||
@@ -586,6 +586,7 @@ $code.=<<___; | |||
586 | .type sha${label}_block_data_order,#function | 586 | .type sha${label}_block_data_order,#function |
587 | .size sha${label}_block_data_order,(.-sha${label}_block_data_order) | 587 | .size sha${label}_block_data_order,(.-sha${label}_block_data_order) |
588 | .asciz "SHA${label} block transform for SPARCv9, CRYPTOGAMS by <appro\@openssl.org>" | 588 | .asciz "SHA${label} block transform for SPARCv9, CRYPTOGAMS by <appro\@openssl.org>" |
589 | .align 4 | ||
589 | ___ | 590 | ___ |
590 | 591 | ||
591 | $code =~ s/\`([^\`]*)\`/eval $1/gem; | 592 | $code =~ s/\`([^\`]*)\`/eval $1/gem; |
diff --git a/src/lib/libcrypto/sparccpuid.S b/src/lib/libcrypto/sparccpuid.S index aa8b11efc9..ae61f7f5ce 100644 --- a/src/lib/libcrypto/sparccpuid.S +++ b/src/lib/libcrypto/sparccpuid.S | |||
@@ -225,13 +225,95 @@ _sparcv9_rdtick: | |||
225 | xor %o0,%o0,%o0 | 225 | xor %o0,%o0,%o0 |
226 | .word 0x91410000 !rd %tick,%o0 | 226 | .word 0x91410000 !rd %tick,%o0 |
227 | retl | 227 | retl |
228 | .word 0x93323020 !srlx %o2,32,%o1 | 228 | .word 0x93323020 !srlx %o0,32,%o1 |
229 | .notick: | 229 | .notick: |
230 | retl | 230 | retl |
231 | xor %o1,%o1,%o1 | 231 | xor %o1,%o1,%o1 |
232 | .type _sparcv9_rdtick,#function | 232 | .type _sparcv9_rdtick,#function |
233 | .size _sparcv9_rdtick,.-_sparcv9_rdtick | 233 | .size _sparcv9_rdtick,.-_sparcv9_rdtick |
234 | 234 | ||
235 | .global _sparcv9_vis1_probe | ||
236 | .align 8 | ||
237 | _sparcv9_vis1_probe: | ||
238 | .word 0x81b00d80 !fxor %f0,%f0,%f0 | ||
239 | add %sp,BIAS+2,%o1 | ||
240 | retl | ||
241 | .word 0xc19a5a40 !ldda [%o1]ASI_FP16_P,%f0 | ||
242 | .type _sparcv9_vis1_probe,#function | ||
243 | .size _sparcv9_vis1_probe,.-_sparcv9_vis1_probe | ||
244 | |||
245 | ! Probe and instrument VIS1 instruction. Output is number of cycles it | ||
246 | ! takes to execute rdtick and pair of VIS1 instructions. US-Tx VIS unit | ||
247 | ! is slow (documented to be 6 cycles on T2) and the core is in-order | ||
248 | ! single-issue, it should be possible to distinguish Tx reliably... | ||
249 | ! Observed return values are: | ||
250 | ! | ||
251 | ! UltraSPARC IIe 7 | ||
252 | ! UltraSPARC III 7 | ||
253 | ! UltraSPARC T1 24 | ||
254 | ! | ||
255 | ! Numbers for T2 and SPARC64 V-VII are more than welcomed. | ||
256 | ! | ||
257 | ! It would be possible to detect specifically US-T1 by instrumenting | ||
258 | ! fmul8ulx16, which is emulated on T1 and as such accounts for quite | ||
259 | ! a lot of %tick-s, couple of thousand on Linux... | ||
260 | .global _sparcv9_vis1_instrument | ||
261 | .align 8 | ||
262 | _sparcv9_vis1_instrument: | ||
263 | .word 0x91410000 !rd %tick,%o0 | ||
264 | .word 0x81b00d80 !fxor %f0,%f0,%f0 | ||
265 | .word 0x85b08d82 !fxor %f2,%f2,%f2 | ||
266 | .word 0x93410000 !rd %tick,%o1 | ||
267 | .word 0x81b00d80 !fxor %f0,%f0,%f0 | ||
268 | .word 0x85b08d82 !fxor %f2,%f2,%f2 | ||
269 | .word 0x95410000 !rd %tick,%o2 | ||
270 | .word 0x81b00d80 !fxor %f0,%f0,%f0 | ||
271 | .word 0x85b08d82 !fxor %f2,%f2,%f2 | ||
272 | .word 0x97410000 !rd %tick,%o3 | ||
273 | .word 0x81b00d80 !fxor %f0,%f0,%f0 | ||
274 | .word 0x85b08d82 !fxor %f2,%f2,%f2 | ||
275 | .word 0x99410000 !rd %tick,%o4 | ||
276 | |||
277 | ! calculate intervals | ||
278 | sub %o1,%o0,%o0 | ||
279 | sub %o2,%o1,%o1 | ||
280 | sub %o3,%o2,%o2 | ||
281 | sub %o4,%o3,%o3 | ||
282 | |||
283 | ! find minumum value | ||
284 | cmp %o0,%o1 | ||
285 | .word 0x38680002 !bgu,a %xcc,.+8 | ||
286 | mov %o1,%o0 | ||
287 | cmp %o0,%o2 | ||
288 | .word 0x38680002 !bgu,a %xcc,.+8 | ||
289 | mov %o2,%o0 | ||
290 | cmp %o0,%o3 | ||
291 | .word 0x38680002 !bgu,a %xcc,.+8 | ||
292 | mov %o3,%o0 | ||
293 | |||
294 | retl | ||
295 | nop | ||
296 | .type _sparcv9_vis1_instrument,#function | ||
297 | .size _sparcv9_vis1_instrument,.-_sparcv9_vis1_instrument | ||
298 | |||
299 | .global _sparcv9_vis2_probe | ||
300 | .align 8 | ||
301 | _sparcv9_vis2_probe: | ||
302 | retl | ||
303 | .word 0x81b00980 !bshuffle %f0,%f0,%f0 | ||
304 | .type _sparcv9_vis2_probe,#function | ||
305 | .size _sparcv9_vis2_probe,.-_sparcv9_vis2_probe | ||
306 | |||
307 | .global _sparcv9_fmadd_probe | ||
308 | .align 8 | ||
309 | _sparcv9_fmadd_probe: | ||
310 | .word 0x81b00d80 !fxor %f0,%f0,%f0 | ||
311 | .word 0x85b08d82 !fxor %f2,%f2,%f2 | ||
312 | retl | ||
313 | .word 0x81b80440 !fmaddd %f0,%f0,%f2,%f0 | ||
314 | .type _sparcv9_fmadd_probe,#function | ||
315 | .size _sparcv9_fmadd_probe,.-_sparcv9_fmadd_probe | ||
316 | |||
235 | .global OPENSSL_cleanse | 317 | .global OPENSSL_cleanse |
236 | .align 32 | 318 | .align 32 |
237 | OPENSSL_cleanse: | 319 | OPENSSL_cleanse: |
diff --git a/src/lib/libcrypto/sparcv9cap.c b/src/lib/libcrypto/sparcv9cap.c index 5f31d20bd0..ed195ab402 100644 --- a/src/lib/libcrypto/sparcv9cap.c +++ b/src/lib/libcrypto/sparcv9cap.c | |||
@@ -1,6 +1,8 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include <setjmp.h> | ||
5 | #include <signal.h> | ||
4 | #include <sys/time.h> | 6 | #include <sys/time.h> |
5 | #include <openssl/bn.h> | 7 | #include <openssl/bn.h> |
6 | 8 | ||
@@ -9,6 +11,7 @@ | |||
9 | #define SPARCV9_VIS1 (1<<2) | 11 | #define SPARCV9_VIS1 (1<<2) |
10 | #define SPARCV9_VIS2 (1<<3) /* reserved */ | 12 | #define SPARCV9_VIS2 (1<<3) /* reserved */ |
11 | #define SPARCV9_FMADD (1<<4) /* reserved for SPARC64 V */ | 13 | #define SPARCV9_FMADD (1<<4) /* reserved for SPARC64 V */ |
14 | |||
12 | static int OPENSSL_sparcv9cap_P=SPARCV9_TICK_PRIVILEGED; | 15 | static int OPENSSL_sparcv9cap_P=SPARCV9_TICK_PRIVILEGED; |
13 | 16 | ||
14 | 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) | 17 | 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) |
@@ -23,10 +26,14 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_U | |||
23 | return bn_mul_mont_int(rp,ap,bp,np,n0,num); | 26 | return bn_mul_mont_int(rp,ap,bp,np,n0,num); |
24 | } | 27 | } |
25 | 28 | ||
29 | unsigned long _sparcv9_rdtick(void); | ||
30 | void _sparcv9_vis1_probe(void); | ||
31 | unsigned long _sparcv9_vis1_instrument(void); | ||
32 | void _sparcv9_vis2_probe(void); | ||
33 | void _sparcv9_fmadd_probe(void); | ||
34 | |||
26 | unsigned long OPENSSL_rdtsc(void) | 35 | unsigned long OPENSSL_rdtsc(void) |
27 | { | 36 | { |
28 | unsigned long _sparcv9_rdtick(void); | ||
29 | |||
30 | if (OPENSSL_sparcv9cap_P&SPARCV9_TICK_PRIVILEGED) | 37 | if (OPENSSL_sparcv9cap_P&SPARCV9_TICK_PRIVILEGED) |
31 | #if defined(__sun) && defined(__SVR4) | 38 | #if defined(__sun) && defined(__SVR4) |
32 | return gethrtime(); | 39 | return gethrtime(); |
@@ -37,8 +44,11 @@ unsigned long OPENSSL_rdtsc(void) | |||
37 | return _sparcv9_rdtick(); | 44 | return _sparcv9_rdtick(); |
38 | } | 45 | } |
39 | 46 | ||
40 | #if defined(__sun) && defined(__SVR4) | 47 | #if 0 && defined(__sun) && defined(__SVR4) |
41 | 48 | /* This code path is disabled, because of incompatibility of | |
49 | * libdevinfo.so.1 and libmalloc.so.1 (see below for details) | ||
50 | */ | ||
51 | #include <malloc.h> | ||
42 | #include <dlfcn.h> | 52 | #include <dlfcn.h> |
43 | #include <libdevinfo.h> | 53 | #include <libdevinfo.h> |
44 | #include <sys/systeminfo.h> | 54 | #include <sys/systeminfo.h> |
@@ -110,7 +120,21 @@ void OPENSSL_cpuid_setup(void) | |||
110 | return; | 120 | return; |
111 | } | 121 | } |
112 | } | 122 | } |
113 | 123 | #ifdef M_KEEP | |
124 | /* | ||
125 | * Solaris libdevinfo.so.1 is effectively incomatible with | ||
126 | * libmalloc.so.1. Specifically, if application is linked with | ||
127 | * -lmalloc, it crashes upon startup with SIGSEGV in | ||
128 | * free(3LIBMALLOC) called by di_fini. Prior call to | ||
129 | * mallopt(M_KEEP,0) somehow helps... But not always... | ||
130 | */ | ||
131 | if ((h = dlopen(NULL,RTLD_LAZY))) | ||
132 | { | ||
133 | union { void *p; int (*f)(int,int); } sym; | ||
134 | if ((sym.p = dlsym(h,"mallopt"))) (*sym.f)(M_KEEP,0); | ||
135 | dlclose(h); | ||
136 | } | ||
137 | #endif | ||
114 | if ((h = dlopen("libdevinfo.so.1",RTLD_LAZY))) do | 138 | if ((h = dlopen("libdevinfo.so.1",RTLD_LAZY))) do |
115 | { | 139 | { |
116 | di_init_t di_init; | 140 | di_init_t di_init; |
@@ -137,9 +161,19 @@ void OPENSSL_cpuid_setup(void) | |||
137 | 161 | ||
138 | #else | 162 | #else |
139 | 163 | ||
164 | static sigjmp_buf common_jmp; | ||
165 | static void common_handler(int sig) { siglongjmp(common_jmp,sig); } | ||
166 | |||
140 | void OPENSSL_cpuid_setup(void) | 167 | void OPENSSL_cpuid_setup(void) |
141 | { | 168 | { |
142 | char *e; | 169 | char *e; |
170 | struct sigaction common_act,ill_oact,bus_oact; | ||
171 | sigset_t all_masked,oset; | ||
172 | int sig; | ||
173 | static int trigger=0; | ||
174 | |||
175 | if (trigger) return; | ||
176 | trigger=1; | ||
143 | 177 | ||
144 | if ((e=getenv("OPENSSL_sparcv9cap"))) | 178 | if ((e=getenv("OPENSSL_sparcv9cap"))) |
145 | { | 179 | { |
@@ -147,8 +181,57 @@ void OPENSSL_cpuid_setup(void) | |||
147 | return; | 181 | return; |
148 | } | 182 | } |
149 | 183 | ||
150 | /* For now we assume that the rest supports UltraSPARC-I* only */ | 184 | /* Initial value, fits UltraSPARC-I&II... */ |
151 | OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU|SPARCV9_VIS1; | 185 | OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU|SPARCV9_TICK_PRIVILEGED; |
186 | |||
187 | sigfillset(&all_masked); | ||
188 | sigdelset(&all_masked,SIGILL); | ||
189 | sigdelset(&all_masked,SIGTRAP); | ||
190 | #ifdef SIGEMT | ||
191 | sigdelset(&all_masked,SIGEMT); | ||
192 | #endif | ||
193 | sigdelset(&all_masked,SIGFPE); | ||
194 | sigdelset(&all_masked,SIGBUS); | ||
195 | sigdelset(&all_masked,SIGSEGV); | ||
196 | sigprocmask(SIG_SETMASK,&all_masked,&oset); | ||
197 | |||
198 | memset(&common_act,0,sizeof(common_act)); | ||
199 | common_act.sa_handler = common_handler; | ||
200 | common_act.sa_mask = all_masked; | ||
201 | |||
202 | sigaction(SIGILL,&common_act,&ill_oact); | ||
203 | sigaction(SIGBUS,&common_act,&bus_oact);/* T1 fails 16-bit ldda [on Linux] */ | ||
204 | |||
205 | if (sigsetjmp(common_jmp,1) == 0) | ||
206 | { | ||
207 | _sparcv9_rdtick(); | ||
208 | OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; | ||
209 | } | ||
210 | |||
211 | if (sigsetjmp(common_jmp,1) == 0) | ||
212 | { | ||
213 | _sparcv9_vis1_probe(); | ||
214 | OPENSSL_sparcv9cap_P |= SPARCV9_VIS1; | ||
215 | /* detect UltraSPARC-Tx, see sparccpud.S for details... */ | ||
216 | if (_sparcv9_vis1_instrument() >= 12) | ||
217 | OPENSSL_sparcv9cap_P &= ~(SPARCV9_VIS1|SPARCV9_PREFER_FPU); | ||
218 | else | ||
219 | { | ||
220 | _sparcv9_vis2_probe(); | ||
221 | OPENSSL_sparcv9cap_P |= SPARCV9_VIS2; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | if (sigsetjmp(common_jmp,1) == 0) | ||
226 | { | ||
227 | _sparcv9_fmadd_probe(); | ||
228 | OPENSSL_sparcv9cap_P |= SPARCV9_FMADD; | ||
229 | } | ||
230 | |||
231 | sigaction(SIGBUS,&bus_oact,NULL); | ||
232 | sigaction(SIGILL,&ill_oact,NULL); | ||
233 | |||
234 | sigprocmask(SIG_SETMASK,&oset,NULL); | ||
152 | } | 235 | } |
153 | 236 | ||
154 | #endif | 237 | #endif |
diff --git a/src/lib/libcrypto/stack/safestack.h b/src/lib/libcrypto/stack/safestack.h index 891cb84a51..3e76aa58f5 100644 --- a/src/lib/libcrypto/stack/safestack.h +++ b/src/lib/libcrypto/stack/safestack.h | |||
@@ -179,7 +179,8 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void) | |||
179 | sk_is_sorted(CHECKED_STACK_OF(type, st)) | 179 | sk_is_sorted(CHECKED_STACK_OF(type, st)) |
180 | 180 | ||
181 | #define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ | 181 | #define SKM_ASN1_SET_OF_d2i(type, st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ |
182 | (STACK_OF(type) *)d2i_ASN1_SET((STACK_OF(OPENSSL_BLOCK) **)CHECKED_STACK_OF(type, st), \ | 182 | (STACK_OF(type) *)d2i_ASN1_SET( \ |
183 | (STACK_OF(OPENSSL_BLOCK) **)CHECKED_PTR_OF(STACK_OF(type)*, st), \ | ||
183 | pp, length, \ | 184 | pp, length, \ |
184 | CHECKED_D2I_OF(type, d2i_func), \ | 185 | CHECKED_D2I_OF(type, d2i_func), \ |
185 | CHECKED_SK_FREE_FUNC(type, free_func), \ | 186 | CHECKED_SK_FREE_FUNC(type, free_func), \ |
@@ -2030,79 +2031,79 @@ DECLARE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void) | |||
2030 | #define sk_void_sort(st) SKM_sk_sort(void, (st)) | 2031 | #define sk_void_sort(st) SKM_sk_sort(void, (st)) |
2031 | #define sk_void_is_sorted(st) SKM_sk_is_sorted(void, (st)) | 2032 | #define sk_void_is_sorted(st) SKM_sk_is_sorted(void, (st)) |
2032 | 2033 | ||
2033 | #define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp))) | 2034 | #define sk_OPENSSL_STRING_new(cmp) ((STACK_OF(OPENSSL_STRING) *)sk_new(CHECKED_SK_CMP_FUNC(char, cmp))) |
2034 | #define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null()) | 2035 | #define sk_OPENSSL_STRING_new_null() ((STACK_OF(OPENSSL_STRING) *)sk_new_null()) |
2035 | #define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_PTR_OF(void, val)) | 2036 | #define sk_OPENSSL_STRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val)) |
2036 | #define sk_OPENSSL_BLOCK_find(st, val) sk_find(CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_PTR_OF(void, val)) | 2037 | #define sk_OPENSSL_STRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val)) |
2037 | #define sk_OPENSSL_BLOCK_value(st, i) ((OPENSSL_BLOCK)sk_value(CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), i)) | 2038 | #define sk_OPENSSL_STRING_value(st, i) ((OPENSSL_STRING)sk_value(CHECKED_STACK_OF(OPENSSL_STRING, st), i)) |
2038 | #define sk_OPENSSL_BLOCK_num(st) SKM_sk_num(OPENSSL_BLOCK, st) | 2039 | #define sk_OPENSSL_STRING_num(st) SKM_sk_num(OPENSSL_STRING, st) |
2039 | #define sk_OPENSSL_BLOCK_pop_free(st, free_func) sk_pop_free(CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_SK_FREE_FUNC2(OPENSSL_BLOCK, free_func)) | 2040 | #define sk_OPENSSL_STRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_FREE_FUNC2(OPENSSL_STRING, free_func)) |
2040 | #define sk_OPENSSL_BLOCK_insert(st, val, i) sk_insert(CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_PTR_OF(void, val), i) | 2041 | #define sk_OPENSSL_STRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val), i) |
2041 | #define sk_OPENSSL_BLOCK_free(st) SKM_sk_free(OPENSSL_BLOCK, st) | 2042 | #define sk_OPENSSL_STRING_free(st) SKM_sk_free(OPENSSL_STRING, st) |
2042 | #define sk_OPENSSL_BLOCK_set(st, i, val) sk_set((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), i, CHECKED_PTR_OF(void, val)) | 2043 | #define sk_OPENSSL_STRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_STRING, st), i, CHECKED_PTR_OF(char, val)) |
2043 | #define sk_OPENSSL_BLOCK_zero(st) SKM_sk_zero(OPENSSL_BLOCK, (st)) | 2044 | #define sk_OPENSSL_STRING_zero(st) SKM_sk_zero(OPENSSL_STRING, (st)) |
2044 | #define sk_OPENSSL_BLOCK_unshift(st, val) sk_unshift((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_PTR_OF(void, val)) | 2045 | #define sk_OPENSSL_STRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, val)) |
2045 | #define sk_OPENSSL_BLOCK_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_CONST_PTR_OF(void, val)) | 2046 | #define sk_OPENSSL_STRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_CONST_PTR_OF(char, val)) |
2046 | #define sk_OPENSSL_BLOCK_delete(st, i) SKM_sk_delete(OPENSSL_BLOCK, (st), (i)) | 2047 | #define sk_OPENSSL_STRING_delete(st, i) SKM_sk_delete(OPENSSL_STRING, (st), (i)) |
2047 | #define sk_OPENSSL_BLOCK_delete_ptr(st, ptr) (OPENSSL_BLOCK *)sk_delete_ptr((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_PTR_OF(void, ptr)) | 2048 | #define sk_OPENSSL_STRING_delete_ptr(st, ptr) (OPENSSL_STRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_PTR_OF(char, ptr)) |
2048 | #define sk_OPENSSL_BLOCK_set_cmp_func(st, cmp) \ | 2049 | #define sk_OPENSSL_STRING_set_cmp_func(st, cmp) \ |
2049 | ((int (*)(const void * const *,const void * const *)) \ | 2050 | ((int (*)(const char * const *,const char * const *)) \ |
2050 | sk_set_cmp_func((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_SK_CMP_FUNC(void, cmp))) | 2051 | sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_STRING, st), CHECKED_SK_CMP_FUNC(char, cmp))) |
2051 | #define sk_OPENSSL_BLOCK_dup(st) SKM_sk_dup(OPENSSL_BLOCK, st) | 2052 | #define sk_OPENSSL_STRING_dup(st) SKM_sk_dup(OPENSSL_STRING, st) |
2052 | #define sk_OPENSSL_BLOCK_shift(st) SKM_sk_shift(OPENSSL_BLOCK, (st)) | 2053 | #define sk_OPENSSL_STRING_shift(st) SKM_sk_shift(OPENSSL_STRING, (st)) |
2053 | #define sk_OPENSSL_BLOCK_pop(st) (void *)sk_pop((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_BLOCK), st)) | 2054 | #define sk_OPENSSL_STRING_pop(st) (char *)sk_pop(CHECKED_STACK_OF(OPENSSL_STRING, st)) |
2054 | #define sk_OPENSSL_BLOCK_sort(st) SKM_sk_sort(OPENSSL_BLOCK, (st)) | 2055 | #define sk_OPENSSL_STRING_sort(st) SKM_sk_sort(OPENSSL_STRING, (st)) |
2055 | #define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st)) | 2056 | #define sk_OPENSSL_STRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_STRING, (st)) |
2056 | 2057 | ||
2057 | 2058 | ||
2058 | #define sk_OPENSSL_PSTRING_new(cmp) ((STACK_OF(OPENSSL_PSTRING) *)sk_new(CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp))) | 2059 | #define sk_OPENSSL_PSTRING_new(cmp) ((STACK_OF(OPENSSL_PSTRING) *)sk_new(CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp))) |
2059 | #define sk_OPENSSL_PSTRING_new_null() ((STACK_OF(OPENSSL_PSTRING) *)sk_new_null()) | 2060 | #define sk_OPENSSL_PSTRING_new_null() ((STACK_OF(OPENSSL_PSTRING) *)sk_new_null()) |
2060 | #define sk_OPENSSL_PSTRING_push(st, val) sk_push(CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_PTR_OF(OPENSSL_STRING, val)) | 2061 | #define sk_OPENSSL_PSTRING_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val)) |
2061 | #define sk_OPENSSL_PSTRING_find(st, val) sk_find(CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_PTR_OF(OPENSSL_STRING, val)) | 2062 | #define sk_OPENSSL_PSTRING_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val)) |
2062 | #define sk_OPENSSL_PSTRING_value(st, i) ((OPENSSL_PSTRING)sk_value(CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), i)) | 2063 | #define sk_OPENSSL_PSTRING_value(st, i) ((OPENSSL_PSTRING)sk_value(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i)) |
2063 | #define sk_OPENSSL_PSTRING_num(st) SKM_sk_num(OPENSSL_PSTRING, st) | 2064 | #define sk_OPENSSL_PSTRING_num(st) SKM_sk_num(OPENSSL_PSTRING, st) |
2064 | #define sk_OPENSSL_PSTRING_pop_free(st, free_func) sk_pop_free(CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_SK_FREE_FUNC2(OPENSSL_PSTRING, free_func)) | 2065 | #define sk_OPENSSL_PSTRING_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_FREE_FUNC2(OPENSSL_PSTRING, free_func)) |
2065 | #define sk_OPENSSL_PSTRING_insert(st, val, i) sk_insert(CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_PTR_OF(OPENSSL_STRING, val), i) | 2066 | #define sk_OPENSSL_PSTRING_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val), i) |
2066 | #define sk_OPENSSL_PSTRING_free(st) SKM_sk_free(OPENSSL_PSTRING, st) | 2067 | #define sk_OPENSSL_PSTRING_free(st) SKM_sk_free(OPENSSL_PSTRING, st) |
2067 | #define sk_OPENSSL_PSTRING_set(st, i, val) sk_set((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), i, CHECKED_PTR_OF(OPENSSL_STRING, val)) | 2068 | #define sk_OPENSSL_PSTRING_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_PSTRING, st), i, CHECKED_PTR_OF(OPENSSL_STRING, val)) |
2068 | #define sk_OPENSSL_PSTRING_zero(st) SKM_sk_zero(OPENSSL_PSTRING, (st)) | 2069 | #define sk_OPENSSL_PSTRING_zero(st) SKM_sk_zero(OPENSSL_PSTRING, (st)) |
2069 | #define sk_OPENSSL_PSTRING_unshift(st, val) sk_unshift((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_PTR_OF(OPENSSL_STRING, val)) | 2070 | #define sk_OPENSSL_PSTRING_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, val)) |
2070 | #define sk_OPENSSL_PSTRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_CONST_PTR_OF(OPENSSL_STRING, val)) | 2071 | #define sk_OPENSSL_PSTRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_CONST_PTR_OF(OPENSSL_STRING, val)) |
2071 | #define sk_OPENSSL_PSTRING_delete(st, i) SKM_sk_delete(OPENSSL_PSTRING, (st), (i)) | 2072 | #define sk_OPENSSL_PSTRING_delete(st, i) SKM_sk_delete(OPENSSL_PSTRING, (st), (i)) |
2072 | #define sk_OPENSSL_PSTRING_delete_ptr(st, ptr) (OPENSSL_PSTRING *)sk_delete_ptr((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_PTR_OF(OPENSSL_STRING, ptr)) | 2073 | #define sk_OPENSSL_PSTRING_delete_ptr(st, ptr) (OPENSSL_PSTRING *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_PTR_OF(OPENSSL_STRING, ptr)) |
2073 | #define sk_OPENSSL_PSTRING_set_cmp_func(st, cmp) \ | 2074 | #define sk_OPENSSL_PSTRING_set_cmp_func(st, cmp) \ |
2074 | ((int (*)(const OPENSSL_STRING * const *,const OPENSSL_STRING * const *)) \ | 2075 | ((int (*)(const OPENSSL_STRING * const *,const OPENSSL_STRING * const *)) \ |
2075 | sk_set_cmp_func((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st), CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp))) | 2076 | sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_PSTRING, st), CHECKED_SK_CMP_FUNC(OPENSSL_STRING, cmp))) |
2076 | #define sk_OPENSSL_PSTRING_dup(st) SKM_sk_dup(OPENSSL_PSTRING, st) | 2077 | #define sk_OPENSSL_PSTRING_dup(st) SKM_sk_dup(OPENSSL_PSTRING, st) |
2077 | #define sk_OPENSSL_PSTRING_shift(st) SKM_sk_shift(OPENSSL_PSTRING, (st)) | 2078 | #define sk_OPENSSL_PSTRING_shift(st) SKM_sk_shift(OPENSSL_PSTRING, (st)) |
2078 | #define sk_OPENSSL_PSTRING_pop(st) (OPENSSL_STRING *)sk_pop((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_PSTRING), st)) | 2079 | #define sk_OPENSSL_PSTRING_pop(st) (OPENSSL_STRING *)sk_pop(CHECKED_STACK_OF(OPENSSL_PSTRING, st)) |
2079 | #define sk_OPENSSL_PSTRING_sort(st) SKM_sk_sort(OPENSSL_PSTRING, (st)) | 2080 | #define sk_OPENSSL_PSTRING_sort(st) SKM_sk_sort(OPENSSL_PSTRING, (st)) |
2080 | #define sk_OPENSSL_PSTRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_PSTRING, (st)) | 2081 | #define sk_OPENSSL_PSTRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_PSTRING, (st)) |
2081 | 2082 | ||
2082 | 2083 | ||
2083 | #define sk_OPENSSL_STRING_new(cmp) ((STACK_OF(OPENSSL_STRING) *)sk_new(CHECKED_SK_CMP_FUNC(char, cmp))) | 2084 | #define sk_OPENSSL_BLOCK_new(cmp) ((STACK_OF(OPENSSL_BLOCK) *)sk_new(CHECKED_SK_CMP_FUNC(void, cmp))) |
2084 | #define sk_OPENSSL_STRING_new_null() ((STACK_OF(OPENSSL_STRING) *)sk_new_null()) | 2085 | #define sk_OPENSSL_BLOCK_new_null() ((STACK_OF(OPENSSL_BLOCK) *)sk_new_null()) |
2085 | #define sk_OPENSSL_STRING_push(st, val) sk_push(CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_PTR_OF(char, val)) | 2086 | #define sk_OPENSSL_BLOCK_push(st, val) sk_push(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val)) |
2086 | #define sk_OPENSSL_STRING_find(st, val) sk_find(CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_PTR_OF(char, val)) | 2087 | #define sk_OPENSSL_BLOCK_find(st, val) sk_find(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val)) |
2087 | #define sk_OPENSSL_STRING_value(st, i) ((OPENSSL_STRING)sk_value(CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), i)) | 2088 | #define sk_OPENSSL_BLOCK_value(st, i) ((OPENSSL_BLOCK)sk_value(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i)) |
2088 | #define sk_OPENSSL_STRING_num(st) SKM_sk_num(OPENSSL_STRING, st) | 2089 | #define sk_OPENSSL_BLOCK_num(st) SKM_sk_num(OPENSSL_BLOCK, st) |
2089 | #define sk_OPENSSL_STRING_pop_free(st, free_func) sk_pop_free(CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_SK_FREE_FUNC2(OPENSSL_STRING, free_func)) | 2090 | #define sk_OPENSSL_BLOCK_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_FREE_FUNC2(OPENSSL_BLOCK, free_func)) |
2090 | #define sk_OPENSSL_STRING_insert(st, val, i) sk_insert(CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_PTR_OF(char, val), i) | 2091 | #define sk_OPENSSL_BLOCK_insert(st, val, i) sk_insert(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val), i) |
2091 | #define sk_OPENSSL_STRING_free(st) SKM_sk_free(OPENSSL_STRING, st) | 2092 | #define sk_OPENSSL_BLOCK_free(st) SKM_sk_free(OPENSSL_BLOCK, st) |
2092 | #define sk_OPENSSL_STRING_set(st, i, val) sk_set((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), i, CHECKED_PTR_OF(char, val)) | 2093 | #define sk_OPENSSL_BLOCK_set(st, i, val) sk_set(CHECKED_STACK_OF(OPENSSL_BLOCK, st), i, CHECKED_PTR_OF(void, val)) |
2093 | #define sk_OPENSSL_STRING_zero(st) SKM_sk_zero(OPENSSL_STRING, (st)) | 2094 | #define sk_OPENSSL_BLOCK_zero(st) SKM_sk_zero(OPENSSL_BLOCK, (st)) |
2094 | #define sk_OPENSSL_STRING_unshift(st, val) sk_unshift((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_PTR_OF(char, val)) | 2095 | #define sk_OPENSSL_BLOCK_unshift(st, val) sk_unshift(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, val)) |
2095 | #define sk_OPENSSL_STRING_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_CONST_PTR_OF(char, val)) | 2096 | #define sk_OPENSSL_BLOCK_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF(OPENSSL_BLOCK), st), CHECKED_CONST_PTR_OF(void, val)) |
2096 | #define sk_OPENSSL_STRING_delete(st, i) SKM_sk_delete(OPENSSL_STRING, (st), (i)) | 2097 | #define sk_OPENSSL_BLOCK_delete(st, i) SKM_sk_delete(OPENSSL_BLOCK, (st), (i)) |
2097 | #define sk_OPENSSL_STRING_delete_ptr(st, ptr) (OPENSSL_STRING *)sk_delete_ptr((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_PTR_OF(char, ptr)) | 2098 | #define sk_OPENSSL_BLOCK_delete_ptr(st, ptr) (OPENSSL_BLOCK *)sk_delete_ptr(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_PTR_OF(void, ptr)) |
2098 | #define sk_OPENSSL_STRING_set_cmp_func(st, cmp) \ | 2099 | #define sk_OPENSSL_BLOCK_set_cmp_func(st, cmp) \ |
2099 | ((int (*)(const char * const *,const char * const *)) \ | 2100 | ((int (*)(const void * const *,const void * const *)) \ |
2100 | sk_set_cmp_func((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st), CHECKED_SK_CMP_FUNC(char, cmp))) | 2101 | sk_set_cmp_func(CHECKED_STACK_OF(OPENSSL_BLOCK, st), CHECKED_SK_CMP_FUNC(void, cmp))) |
2101 | #define sk_OPENSSL_STRING_dup(st) SKM_sk_dup(OPENSSL_STRING, st) | 2102 | #define sk_OPENSSL_BLOCK_dup(st) SKM_sk_dup(OPENSSL_BLOCK, st) |
2102 | #define sk_OPENSSL_STRING_shift(st) SKM_sk_shift(OPENSSL_STRING, (st)) | 2103 | #define sk_OPENSSL_BLOCK_shift(st) SKM_sk_shift(OPENSSL_BLOCK, (st)) |
2103 | #define sk_OPENSSL_STRING_pop(st) (char *)sk_pop((_STACK *)CHECKED_PTR_OF(STACK_OF(OPENSSL_STRING), st)) | 2104 | #define sk_OPENSSL_BLOCK_pop(st) (void *)sk_pop(CHECKED_STACK_OF(OPENSSL_BLOCK, st)) |
2104 | #define sk_OPENSSL_STRING_sort(st) SKM_sk_sort(OPENSSL_STRING, (st)) | 2105 | #define sk_OPENSSL_BLOCK_sort(st) SKM_sk_sort(OPENSSL_BLOCK, (st)) |
2105 | #define sk_OPENSSL_STRING_is_sorted(st) SKM_sk_is_sorted(OPENSSL_STRING, (st)) | 2106 | #define sk_OPENSSL_BLOCK_is_sorted(st) SKM_sk_is_sorted(OPENSSL_BLOCK, (st)) |
2106 | 2107 | ||
2107 | 2108 | ||
2108 | #define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ | 2109 | #define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \ |
diff --git a/src/lib/libcrypto/ts/ts_verify_ctx.c b/src/lib/libcrypto/ts/ts_verify_ctx.c index b079b50fc3..609b7735d4 100644 --- a/src/lib/libcrypto/ts/ts_verify_ctx.c +++ b/src/lib/libcrypto/ts/ts_verify_ctx.c | |||
@@ -56,7 +56,6 @@ | |||
56 | * | 56 | * |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include <assert.h> | ||
60 | #include "cryptlib.h" | 59 | #include "cryptlib.h" |
61 | #include <openssl/objects.h> | 60 | #include <openssl/objects.h> |
62 | #include <openssl/ts.h> | 61 | #include <openssl/ts.h> |
@@ -74,7 +73,7 @@ TS_VERIFY_CTX *TS_VERIFY_CTX_new(void) | |||
74 | 73 | ||
75 | void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx) | 74 | void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx) |
76 | { | 75 | { |
77 | assert(ctx != NULL); | 76 | OPENSSL_assert(ctx != NULL); |
78 | memset(ctx, 0, sizeof(TS_VERIFY_CTX)); | 77 | memset(ctx, 0, sizeof(TS_VERIFY_CTX)); |
79 | } | 78 | } |
80 | 79 | ||
@@ -116,7 +115,7 @@ TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx) | |||
116 | ASN1_OCTET_STRING *msg; | 115 | ASN1_OCTET_STRING *msg; |
117 | const ASN1_INTEGER *nonce; | 116 | const ASN1_INTEGER *nonce; |
118 | 117 | ||
119 | assert(req != NULL); | 118 | OPENSSL_assert(req != NULL); |
120 | if (ret) | 119 | if (ret) |
121 | TS_VERIFY_CTX_cleanup(ret); | 120 | TS_VERIFY_CTX_cleanup(ret); |
122 | else | 121 | else |
diff --git a/src/lib/libcrypto/util/mkerr.pl b/src/lib/libcrypto/util/mkerr.pl index 15b774f277..2c99467d34 100644 --- a/src/lib/libcrypto/util/mkerr.pl +++ b/src/lib/libcrypto/util/mkerr.pl | |||
@@ -391,7 +391,7 @@ foreach $lib (keys %csrc) | |||
391 | } else { | 391 | } else { |
392 | push @out, | 392 | push @out, |
393 | "/* ====================================================================\n", | 393 | "/* ====================================================================\n", |
394 | " * Copyright (c) 2001-2010 The OpenSSL Project. All rights reserved.\n", | 394 | " * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.\n", |
395 | " *\n", | 395 | " *\n", |
396 | " * Redistribution and use in source and binary forms, with or without\n", | 396 | " * Redistribution and use in source and binary forms, with or without\n", |
397 | " * modification, are permitted provided that the following conditions\n", | 397 | " * modification, are permitted provided that the following conditions\n", |
@@ -576,7 +576,7 @@ EOF | |||
576 | print OUT <<"EOF"; | 576 | print OUT <<"EOF"; |
577 | /* $cfile */ | 577 | /* $cfile */ |
578 | /* ==================================================================== | 578 | /* ==================================================================== |
579 | * Copyright (c) 1999-2010 The OpenSSL Project. All rights reserved. | 579 | * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. |
580 | * | 580 | * |
581 | * Redistribution and use in source and binary forms, with or without | 581 | * Redistribution and use in source and binary forms, with or without |
582 | * modification, are permitted provided that the following conditions | 582 | * modification, are permitted provided that the following conditions |
diff --git a/src/lib/libcrypto/util/mkstack.pl b/src/lib/libcrypto/util/mkstack.pl index 6a43757c95..f708610a78 100644 --- a/src/lib/libcrypto/util/mkstack.pl +++ b/src/lib/libcrypto/util/mkstack.pl | |||
@@ -104,25 +104,25 @@ EOF | |||
104 | 104 | ||
105 | #define sk_${t1}_new(cmp) ((STACK_OF($t1) *)sk_new(CHECKED_SK_CMP_FUNC($t2, cmp))) | 105 | #define sk_${t1}_new(cmp) ((STACK_OF($t1) *)sk_new(CHECKED_SK_CMP_FUNC($t2, cmp))) |
106 | #define sk_${t1}_new_null() ((STACK_OF($t1) *)sk_new_null()) | 106 | #define sk_${t1}_new_null() ((STACK_OF($t1) *)sk_new_null()) |
107 | #define sk_${t1}_push(st, val) sk_push(CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_PTR_OF($t2, val)) | 107 | #define sk_${t1}_push(st, val) sk_push(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, val)) |
108 | #define sk_${t1}_find(st, val) sk_find(CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_PTR_OF($t2, val)) | 108 | #define sk_${t1}_find(st, val) sk_find(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, val)) |
109 | #define sk_${t1}_value(st, i) (($t1)sk_value(CHECKED_PTR_OF(STACK_OF($t1), st), i)) | 109 | #define sk_${t1}_value(st, i) (($t1)sk_value(CHECKED_STACK_OF($t1, st), i)) |
110 | #define sk_${t1}_num(st) SKM_sk_num($t1, st) | 110 | #define sk_${t1}_num(st) SKM_sk_num($t1, st) |
111 | #define sk_${t1}_pop_free(st, free_func) sk_pop_free(CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_SK_FREE_FUNC2($t1, free_func)) | 111 | #define sk_${t1}_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF($t1, st), CHECKED_SK_FREE_FUNC2($t1, free_func)) |
112 | #define sk_${t1}_insert(st, val, i) sk_insert(CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_PTR_OF($t2, val), i) | 112 | #define sk_${t1}_insert(st, val, i) sk_insert(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, val), i) |
113 | #define sk_${t1}_free(st) SKM_sk_free(${t1}, st) | 113 | #define sk_${t1}_free(st) SKM_sk_free(${t1}, st) |
114 | #define sk_${t1}_set(st, i, val) sk_set((_STACK *)CHECKED_PTR_OF(STACK_OF($t1), st), i, CHECKED_PTR_OF($t2, val)) | 114 | #define sk_${t1}_set(st, i, val) sk_set(CHECKED_STACK_OF($t1, st), i, CHECKED_PTR_OF($t2, val)) |
115 | #define sk_${t1}_zero(st) SKM_sk_zero($t1, (st)) | 115 | #define sk_${t1}_zero(st) SKM_sk_zero($t1, (st)) |
116 | #define sk_${t1}_unshift(st, val) sk_unshift((_STACK *)CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_PTR_OF($t2, val)) | 116 | #define sk_${t1}_unshift(st, val) sk_unshift(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, val)) |
117 | #define sk_${t1}_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF($t1), st), CHECKED_CONST_PTR_OF($t2, val)) | 117 | #define sk_${t1}_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF($t1), st), CHECKED_CONST_PTR_OF($t2, val)) |
118 | #define sk_${t1}_delete(st, i) SKM_sk_delete($t1, (st), (i)) | 118 | #define sk_${t1}_delete(st, i) SKM_sk_delete($t1, (st), (i)) |
119 | #define sk_${t1}_delete_ptr(st, ptr) ($t1 *)sk_delete_ptr((_STACK *)CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_PTR_OF($t2, ptr)) | 119 | #define sk_${t1}_delete_ptr(st, ptr) ($t1 *)sk_delete_ptr(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, ptr)) |
120 | #define sk_${t1}_set_cmp_func(st, cmp) \\ | 120 | #define sk_${t1}_set_cmp_func(st, cmp) \\ |
121 | ((int (*)(const $t2 * const *,const $t2 * const *)) \\ | 121 | ((int (*)(const $t2 * const *,const $t2 * const *)) \\ |
122 | sk_set_cmp_func((_STACK *)CHECKED_PTR_OF(STACK_OF($t1), st), CHECKED_SK_CMP_FUNC($t2, cmp))) | 122 | sk_set_cmp_func(CHECKED_STACK_OF($t1, st), CHECKED_SK_CMP_FUNC($t2, cmp))) |
123 | #define sk_${t1}_dup(st) SKM_sk_dup($t1, st) | 123 | #define sk_${t1}_dup(st) SKM_sk_dup($t1, st) |
124 | #define sk_${t1}_shift(st) SKM_sk_shift($t1, (st)) | 124 | #define sk_${t1}_shift(st) SKM_sk_shift($t1, (st)) |
125 | #define sk_${t1}_pop(st) ($t2 *)sk_pop((_STACK *)CHECKED_PTR_OF(STACK_OF($t1), st)) | 125 | #define sk_${t1}_pop(st) ($t2 *)sk_pop(CHECKED_STACK_OF($t1, st)) |
126 | #define sk_${t1}_sort(st) SKM_sk_sort($t1, (st)) | 126 | #define sk_${t1}_sort(st) SKM_sk_sort($t1, (st)) |
127 | #define sk_${t1}_is_sorted(st) SKM_sk_is_sorted($t1, (st)) | 127 | #define sk_${t1}_is_sorted(st) SKM_sk_is_sorted($t1, (st)) |
128 | 128 | ||
diff --git a/src/lib/libcrypto/x509/x509.h b/src/lib/libcrypto/x509/x509.h index 604f4fb27f..e6f8a40395 100644 --- a/src/lib/libcrypto/x509/x509.h +++ b/src/lib/libcrypto/x509/x509.h | |||
@@ -258,6 +258,7 @@ typedef struct x509_cinf_st | |||
258 | ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ | 258 | ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ |
259 | ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ | 259 | ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ |
260 | STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ | 260 | STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ |
261 | ASN1_ENCODING enc; | ||
261 | } X509_CINF; | 262 | } X509_CINF; |
262 | 263 | ||
263 | /* This stuff is certificate "auxiliary info" | 264 | /* This stuff is certificate "auxiliary info" |
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index 87ebf62525..5a0b0249b4 100644 --- a/src/lib/libcrypto/x509/x509_vfy.c +++ b/src/lib/libcrypto/x509/x509_vfy.c | |||
@@ -703,6 +703,7 @@ static int check_cert(X509_STORE_CTX *ctx) | |||
703 | x = sk_X509_value(ctx->chain, cnum); | 703 | x = sk_X509_value(ctx->chain, cnum); |
704 | ctx->current_cert = x; | 704 | ctx->current_cert = x; |
705 | ctx->current_issuer = NULL; | 705 | ctx->current_issuer = NULL; |
706 | ctx->current_crl_score = 0; | ||
706 | ctx->current_reasons = 0; | 707 | ctx->current_reasons = 0; |
707 | while (ctx->current_reasons != CRLDP_ALL_REASONS) | 708 | while (ctx->current_reasons != CRLDP_ALL_REASONS) |
708 | { | 709 | { |
@@ -2015,6 +2016,9 @@ int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, | |||
2015 | ctx->error_depth=0; | 2016 | ctx->error_depth=0; |
2016 | ctx->current_cert=NULL; | 2017 | ctx->current_cert=NULL; |
2017 | ctx->current_issuer=NULL; | 2018 | ctx->current_issuer=NULL; |
2019 | ctx->current_crl=NULL; | ||
2020 | ctx->current_crl_score=0; | ||
2021 | ctx->current_reasons=0; | ||
2018 | ctx->tree = NULL; | 2022 | ctx->tree = NULL; |
2019 | ctx->parent = NULL; | 2023 | ctx->parent = NULL; |
2020 | 2024 | ||
@@ -2034,7 +2038,7 @@ int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, | |||
2034 | if (store) | 2038 | if (store) |
2035 | ret = X509_VERIFY_PARAM_inherit(ctx->param, store->param); | 2039 | ret = X509_VERIFY_PARAM_inherit(ctx->param, store->param); |
2036 | else | 2040 | else |
2037 | ctx->param->flags |= X509_VP_FLAG_DEFAULT|X509_VP_FLAG_ONCE; | 2041 | ctx->param->inh_flags |= X509_VP_FLAG_DEFAULT|X509_VP_FLAG_ONCE; |
2038 | 2042 | ||
2039 | if (store) | 2043 | if (store) |
2040 | { | 2044 | { |
diff --git a/src/lib/libcrypto/x509/x_all.c b/src/lib/libcrypto/x509/x_all.c index ebae30b701..8ec88c215a 100644 --- a/src/lib/libcrypto/x509/x_all.c +++ b/src/lib/libcrypto/x509/x_all.c | |||
@@ -90,6 +90,7 @@ int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r) | |||
90 | 90 | ||
91 | int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) | 91 | int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) |
92 | { | 92 | { |
93 | x->cert_info->enc.modified = 1; | ||
93 | return(ASN1_item_sign(ASN1_ITEM_rptr(X509_CINF), x->cert_info->signature, | 94 | return(ASN1_item_sign(ASN1_ITEM_rptr(X509_CINF), x->cert_info->signature, |
94 | x->sig_alg, x->signature, x->cert_info,pkey,md)); | 95 | x->sig_alg, x->signature, x->cert_info,pkey,md)); |
95 | } | 96 | } |
diff --git a/src/lib/libcrypto/x509v3/pcy_tree.c b/src/lib/libcrypto/x509v3/pcy_tree.c index 92f6b24556..bb9777348f 100644 --- a/src/lib/libcrypto/x509v3/pcy_tree.c +++ b/src/lib/libcrypto/x509v3/pcy_tree.c | |||
@@ -341,9 +341,8 @@ static int tree_link_nodes(X509_POLICY_LEVEL *curr, | |||
341 | const X509_POLICY_CACHE *cache) | 341 | const X509_POLICY_CACHE *cache) |
342 | { | 342 | { |
343 | int i; | 343 | int i; |
344 | X509_POLICY_LEVEL *last; | ||
345 | X509_POLICY_DATA *data; | 344 | X509_POLICY_DATA *data; |
346 | last = curr - 1; | 345 | |
347 | for (i = 0; i < sk_X509_POLICY_DATA_num(cache->data); i++) | 346 | for (i = 0; i < sk_X509_POLICY_DATA_num(cache->data); i++) |
348 | { | 347 | { |
349 | data = sk_X509_POLICY_DATA_value(cache->data, i); | 348 | data = sk_X509_POLICY_DATA_value(cache->data, i); |
diff --git a/src/lib/libcrypto/x509v3/v3_ncons.c b/src/lib/libcrypto/x509v3/v3_ncons.c index 689df46acd..a01dc64dd2 100644 --- a/src/lib/libcrypto/x509v3/v3_ncons.c +++ b/src/lib/libcrypto/x509v3/v3_ncons.c | |||
@@ -189,7 +189,6 @@ static int do_i2r_name_constraints(const X509V3_EXT_METHOD *method, | |||
189 | print_nc_ipadd(bp, tree->base->d.ip); | 189 | print_nc_ipadd(bp, tree->base->d.ip); |
190 | else | 190 | else |
191 | GENERAL_NAME_print(bp, tree->base); | 191 | GENERAL_NAME_print(bp, tree->base); |
192 | tree = sk_GENERAL_SUBTREE_value(trees, i); | ||
193 | BIO_puts(bp, "\n"); | 192 | BIO_puts(bp, "\n"); |
194 | } | 193 | } |
195 | return 1; | 194 | return 1; |