diff options
Diffstat (limited to 'src/lib/libcrypto/md32_common.h')
-rw-r--r-- | src/lib/libcrypto/md32_common.h | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/lib/libcrypto/md32_common.h b/src/lib/libcrypto/md32_common.h index 353d2b96ad..573850b122 100644 --- a/src/lib/libcrypto/md32_common.h +++ b/src/lib/libcrypto/md32_common.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* crypto/md32_common.h */ | 1 | /* crypto/md32_common.h */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions | 6 | * modification, are permitted provided that the following conditions |
@@ -198,7 +198,7 @@ | |||
198 | * | 198 | * |
199 | * <appro@fy.chalmers.se> | 199 | * <appro@fy.chalmers.se> |
200 | */ | 200 | */ |
201 | # if defined(__i386) || defined(__i386__) | 201 | # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) |
202 | # define ROTATE(a,n) ({ register unsigned int ret; \ | 202 | # define ROTATE(a,n) ({ register unsigned int ret; \ |
203 | asm ( \ | 203 | asm ( \ |
204 | "roll %1,%0" \ | 204 | "roll %1,%0" \ |
@@ -224,7 +224,7 @@ | |||
224 | */ | 224 | */ |
225 | # if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) | 225 | # if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) |
226 | /* some GNU C inline assembler templates by <appro@fy.chalmers.se> */ | 226 | /* some GNU C inline assembler templates by <appro@fy.chalmers.se> */ |
227 | # if (defined(__i386) || defined(__i386__)) && !defined(I386_ONLY) | 227 | # if (defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)) && !defined(I386_ONLY) |
228 | # define BE_FETCH32(a) ({ register unsigned int l=(a);\ | 228 | # define BE_FETCH32(a) ({ register unsigned int l=(a);\ |
229 | asm ( \ | 229 | asm ( \ |
230 | "bswapl %0" \ | 230 | "bswapl %0" \ |
@@ -456,7 +456,10 @@ int HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len) | |||
456 | { | 456 | { |
457 | ew=(c->num>>2); | 457 | ew=(c->num>>2); |
458 | ec=(c->num&0x03); | 458 | ec=(c->num&0x03); |
459 | l=p[sw]; HOST_p_c2l(data,l,sc); p[sw++]=l; | 459 | if (sc) |
460 | l=p[sw]; | ||
461 | HOST_p_c2l(data,l,sc); | ||
462 | p[sw++]=l; | ||
460 | for (; sw < ew; sw++) | 463 | for (; sw < ew; sw++) |
461 | { | 464 | { |
462 | HOST_c2l(data,l); p[sw]=l; | 465 | HOST_c2l(data,l); p[sw]=l; |
@@ -603,7 +606,32 @@ int HASH_FINAL (unsigned char *md, HASH_CTX *c) | |||
603 | c->num=0; | 606 | c->num=0; |
604 | /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack | 607 | /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack |
605 | * but I'm not worried :-) | 608 | * but I'm not worried :-) |
606 | memset((void *)c,0,sizeof(HASH_CTX)); | 609 | OPENSSL_cleanse((void *)c,sizeof(HASH_CTX)); |
607 | */ | 610 | */ |
608 | return 1; | 611 | return 1; |
609 | } | 612 | } |
613 | |||
614 | #ifndef MD32_REG_T | ||
615 | #define MD32_REG_T long | ||
616 | /* | ||
617 | * This comment was originaly written for MD5, which is why it | ||
618 | * discusses A-D. But it basically applies to all 32-bit digests, | ||
619 | * which is why it was moved to common header file. | ||
620 | * | ||
621 | * In case you wonder why A-D are declared as long and not | ||
622 | * as MD5_LONG. Doing so results in slight performance | ||
623 | * boost on LP64 architectures. The catch is we don't | ||
624 | * really care if 32 MSBs of a 64-bit register get polluted | ||
625 | * with eventual overflows as we *save* only 32 LSBs in | ||
626 | * *either* case. Now declaring 'em long excuses the compiler | ||
627 | * from keeping 32 MSBs zeroed resulting in 13% performance | ||
628 | * improvement under SPARC Solaris7/64 and 5% under AlphaLinux. | ||
629 | * Well, to be honest it should say that this *prevents* | ||
630 | * performance degradation. | ||
631 | * <appro@fy.chalmers.se> | ||
632 | * Apparently there're LP64 compilers that generate better | ||
633 | * code if A-D are declared int. Most notably GCC-x86_64 | ||
634 | * generates better code. | ||
635 | * <appro@fy.chalmers.se> | ||
636 | */ | ||
637 | #endif | ||