diff options
| author | djm <> | 2009-01-09 12:14:11 +0000 |
|---|---|---|
| committer | djm <> | 2009-01-09 12:14:11 +0000 |
| commit | a0fdc9ec41594852f67ec77dfad9cb06bacc4186 (patch) | |
| tree | c43f6b3a4d93ad2cb3dcf93275295679d895a033 /src/lib/libcrypto/sha | |
| parent | 5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80 (diff) | |
| download | openbsd-a0fdc9ec41594852f67ec77dfad9cb06bacc4186.tar.gz openbsd-a0fdc9ec41594852f67ec77dfad9cb06bacc4186.tar.bz2 openbsd-a0fdc9ec41594852f67ec77dfad9cb06bacc4186.zip | |
import openssl-0.9.8j
Diffstat (limited to 'src/lib/libcrypto/sha')
| -rw-r--r-- | src/lib/libcrypto/sha/asm/sha1-586.pl | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/sha/sha.h | 3 | ||||
| -rw-r--r-- | src/lib/libcrypto/sha/sha1_one.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/sha/sha1dgst.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/sha/sha256.c | 10 | ||||
| -rw-r--r-- | src/lib/libcrypto/sha/sha512.c | 12 | ||||
| -rw-r--r-- | src/lib/libcrypto/sha/sha_locl.h | 7 |
7 files changed, 37 insertions, 3 deletions
diff --git a/src/lib/libcrypto/sha/asm/sha1-586.pl b/src/lib/libcrypto/sha/asm/sha1-586.pl index 0b4dab2bd5..a787dd37da 100644 --- a/src/lib/libcrypto/sha/asm/sha1-586.pl +++ b/src/lib/libcrypto/sha/asm/sha1-586.pl | |||
| @@ -149,7 +149,7 @@ sub BODY_40_59 | |||
| 149 | &add($f,$e); # f+=ROTATE(a,5) | 149 | &add($f,$e); # f+=ROTATE(a,5) |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | &function_begin("sha1_block_data_order",16); | 152 | &function_begin("sha1_block_data_order"); |
| 153 | &mov($tmp1,&wparam(0)); # SHA_CTX *c | 153 | &mov($tmp1,&wparam(0)); # SHA_CTX *c |
| 154 | &mov($T,&wparam(1)); # const void *input | 154 | &mov($T,&wparam(1)); # const void *input |
| 155 | &mov($A,&wparam(2)); # size_t num | 155 | &mov($A,&wparam(2)); # size_t num |
diff --git a/src/lib/libcrypto/sha/sha.h b/src/lib/libcrypto/sha/sha.h index eed44d7f94..47a2c29f66 100644 --- a/src/lib/libcrypto/sha/sha.h +++ b/src/lib/libcrypto/sha/sha.h | |||
| @@ -106,6 +106,9 @@ typedef struct SHAstate_st | |||
| 106 | } SHA_CTX; | 106 | } SHA_CTX; |
| 107 | 107 | ||
| 108 | #ifndef OPENSSL_NO_SHA0 | 108 | #ifndef OPENSSL_NO_SHA0 |
| 109 | #ifdef OPENSSL_FIPS | ||
| 110 | int private_SHA_Init(SHA_CTX *c); | ||
| 111 | #endif | ||
| 109 | int SHA_Init(SHA_CTX *c); | 112 | int SHA_Init(SHA_CTX *c); |
| 110 | int SHA_Update(SHA_CTX *c, const void *data, size_t len); | 113 | int SHA_Update(SHA_CTX *c, const void *data, size_t len); |
| 111 | int SHA_Final(unsigned char *md, SHA_CTX *c); | 114 | int SHA_Final(unsigned char *md, SHA_CTX *c); |
diff --git a/src/lib/libcrypto/sha/sha1_one.c b/src/lib/libcrypto/sha/sha1_one.c index 7c65b60276..4831174198 100644 --- a/src/lib/libcrypto/sha/sha1_one.c +++ b/src/lib/libcrypto/sha/sha1_one.c | |||
| @@ -61,7 +61,7 @@ | |||
| 61 | #include <openssl/sha.h> | 61 | #include <openssl/sha.h> |
| 62 | #include <openssl/crypto.h> | 62 | #include <openssl/crypto.h> |
| 63 | 63 | ||
| 64 | #ifndef OPENSSL_NO_SHA1 | 64 | #if !defined(OPENSSL_NO_SHA1) |
| 65 | unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md) | 65 | unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md) |
| 66 | { | 66 | { |
| 67 | SHA_CTX c; | 67 | SHA_CTX c; |
diff --git a/src/lib/libcrypto/sha/sha1dgst.c b/src/lib/libcrypto/sha/sha1dgst.c index 50d1925cde..d31f0781a0 100644 --- a/src/lib/libcrypto/sha/sha1dgst.c +++ b/src/lib/libcrypto/sha/sha1dgst.c | |||
| @@ -63,6 +63,10 @@ | |||
| 63 | #define SHA_1 | 63 | #define SHA_1 |
| 64 | 64 | ||
| 65 | #include <openssl/opensslv.h> | 65 | #include <openssl/opensslv.h> |
| 66 | #ifdef OPENSSL_FIPS | ||
| 67 | #include <openssl/fips.h> | ||
| 68 | #endif | ||
| 69 | |||
| 66 | 70 | ||
| 67 | const char SHA1_version[]="SHA1" OPENSSL_VERSION_PTEXT; | 71 | const char SHA1_version[]="SHA1" OPENSSL_VERSION_PTEXT; |
| 68 | 72 | ||
diff --git a/src/lib/libcrypto/sha/sha256.c b/src/lib/libcrypto/sha/sha256.c index 867f90cc97..3256a83e98 100644 --- a/src/lib/libcrypto/sha/sha256.c +++ b/src/lib/libcrypto/sha/sha256.c | |||
| @@ -12,12 +12,19 @@ | |||
| 12 | 12 | ||
| 13 | #include <openssl/crypto.h> | 13 | #include <openssl/crypto.h> |
| 14 | #include <openssl/sha.h> | 14 | #include <openssl/sha.h> |
| 15 | #ifdef OPENSSL_FIPS | ||
| 16 | #include <openssl/fips.h> | ||
| 17 | #endif | ||
| 18 | |||
| 15 | #include <openssl/opensslv.h> | 19 | #include <openssl/opensslv.h> |
| 16 | 20 | ||
| 17 | const char SHA256_version[]="SHA-256" OPENSSL_VERSION_PTEXT; | 21 | const char SHA256_version[]="SHA-256" OPENSSL_VERSION_PTEXT; |
| 18 | 22 | ||
| 19 | int SHA224_Init (SHA256_CTX *c) | 23 | int SHA224_Init (SHA256_CTX *c) |
| 20 | { | 24 | { |
| 25 | #ifdef OPENSSL_FIPS | ||
| 26 | FIPS_selftest_check(); | ||
| 27 | #endif | ||
| 21 | c->h[0]=0xc1059ed8UL; c->h[1]=0x367cd507UL; | 28 | c->h[0]=0xc1059ed8UL; c->h[1]=0x367cd507UL; |
| 22 | c->h[2]=0x3070dd17UL; c->h[3]=0xf70e5939UL; | 29 | c->h[2]=0x3070dd17UL; c->h[3]=0xf70e5939UL; |
| 23 | c->h[4]=0xffc00b31UL; c->h[5]=0x68581511UL; | 30 | c->h[4]=0xffc00b31UL; c->h[5]=0x68581511UL; |
| @@ -29,6 +36,9 @@ int SHA224_Init (SHA256_CTX *c) | |||
| 29 | 36 | ||
| 30 | int SHA256_Init (SHA256_CTX *c) | 37 | int SHA256_Init (SHA256_CTX *c) |
| 31 | { | 38 | { |
| 39 | #ifdef OPENSSL_FIPS | ||
| 40 | FIPS_selftest_check(); | ||
| 41 | #endif | ||
| 32 | c->h[0]=0x6a09e667UL; c->h[1]=0xbb67ae85UL; | 42 | c->h[0]=0x6a09e667UL; c->h[1]=0xbb67ae85UL; |
| 33 | c->h[2]=0x3c6ef372UL; c->h[3]=0xa54ff53aUL; | 43 | c->h[2]=0x3c6ef372UL; c->h[3]=0xa54ff53aUL; |
| 34 | c->h[4]=0x510e527fUL; c->h[5]=0x9b05688cUL; | 44 | c->h[4]=0x510e527fUL; c->h[5]=0x9b05688cUL; |
diff --git a/src/lib/libcrypto/sha/sha512.c b/src/lib/libcrypto/sha/sha512.c index 987fc07c99..f5ed468b85 100644 --- a/src/lib/libcrypto/sha/sha512.c +++ b/src/lib/libcrypto/sha/sha512.c | |||
| @@ -5,6 +5,10 @@ | |||
| 5 | * ==================================================================== | 5 | * ==================================================================== |
| 6 | */ | 6 | */ |
| 7 | #include <openssl/opensslconf.h> | 7 | #include <openssl/opensslconf.h> |
| 8 | #ifdef OPENSSL_FIPS | ||
| 9 | #include <openssl/fips.h> | ||
| 10 | #endif | ||
| 11 | |||
| 8 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA512) | 12 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA512) |
| 9 | /* | 13 | /* |
| 10 | * IMPLEMENTATION NOTES. | 14 | * IMPLEMENTATION NOTES. |
| @@ -61,6 +65,9 @@ const char SHA512_version[]="SHA-512" OPENSSL_VERSION_PTEXT; | |||
| 61 | 65 | ||
| 62 | int SHA384_Init (SHA512_CTX *c) | 66 | int SHA384_Init (SHA512_CTX *c) |
| 63 | { | 67 | { |
| 68 | #ifdef OPENSSL_FIPS | ||
| 69 | FIPS_selftest_check(); | ||
| 70 | #endif | ||
| 64 | c->h[0]=U64(0xcbbb9d5dc1059ed8); | 71 | c->h[0]=U64(0xcbbb9d5dc1059ed8); |
| 65 | c->h[1]=U64(0x629a292a367cd507); | 72 | c->h[1]=U64(0x629a292a367cd507); |
| 66 | c->h[2]=U64(0x9159015a3070dd17); | 73 | c->h[2]=U64(0x9159015a3070dd17); |
| @@ -76,6 +83,9 @@ int SHA384_Init (SHA512_CTX *c) | |||
| 76 | 83 | ||
| 77 | int SHA512_Init (SHA512_CTX *c) | 84 | int SHA512_Init (SHA512_CTX *c) |
| 78 | { | 85 | { |
| 86 | #ifdef OPENSSL_FIPS | ||
| 87 | FIPS_selftest_check(); | ||
| 88 | #endif | ||
| 79 | c->h[0]=U64(0x6a09e667f3bcc908); | 89 | c->h[0]=U64(0x6a09e667f3bcc908); |
| 80 | c->h[1]=U64(0xbb67ae8584caa73b); | 90 | c->h[1]=U64(0xbb67ae8584caa73b); |
| 81 | c->h[2]=U64(0x3c6ef372fe94f82b); | 91 | c->h[2]=U64(0x3c6ef372fe94f82b); |
| @@ -327,7 +337,7 @@ static const SHA_LONG64 K512[80] = { | |||
| 327 | ((SHA_LONG64)hi)<<32|lo; }) | 337 | ((SHA_LONG64)hi)<<32|lo; }) |
| 328 | # else | 338 | # else |
| 329 | # define PULL64(x) ({ const unsigned int *p=(const unsigned int *)(&(x));\ | 339 | # define PULL64(x) ({ const unsigned int *p=(const unsigned int *)(&(x));\ |
| 330 | unsigned int hi=p[0],lo=p[1]; \ | 340 | unsigned int hi=p[0],lo=p[1]; \ |
| 331 | asm ("bswapl %0; bswapl %1;" \ | 341 | asm ("bswapl %0; bswapl %1;" \ |
| 332 | : "=r"(lo),"=r"(hi) \ | 342 | : "=r"(lo),"=r"(hi) \ |
| 333 | : "0"(lo),"1"(hi)); \ | 343 | : "0"(lo),"1"(hi)); \ |
diff --git a/src/lib/libcrypto/sha/sha_locl.h b/src/lib/libcrypto/sha/sha_locl.h index e37e5726e3..da46ddfe79 100644 --- a/src/lib/libcrypto/sha/sha_locl.h +++ b/src/lib/libcrypto/sha/sha_locl.h | |||
| @@ -122,8 +122,15 @@ void sha1_block_data_order (SHA_CTX *c, const void *p,size_t num); | |||
| 122 | #define INIT_DATA_h3 0x10325476UL | 122 | #define INIT_DATA_h3 0x10325476UL |
| 123 | #define INIT_DATA_h4 0xc3d2e1f0UL | 123 | #define INIT_DATA_h4 0xc3d2e1f0UL |
| 124 | 124 | ||
| 125 | #if defined(SHA_0) && defined(OPENSSL_FIPS) | ||
| 126 | FIPS_NON_FIPS_MD_Init(SHA) | ||
| 127 | #else | ||
| 125 | int HASH_INIT (SHA_CTX *c) | 128 | int HASH_INIT (SHA_CTX *c) |
| 129 | #endif | ||
| 126 | { | 130 | { |
| 131 | #if defined(SHA_1) && defined(OPENSSL_FIPS) | ||
| 132 | FIPS_selftest_check(); | ||
| 133 | #endif | ||
| 127 | c->h0=INIT_DATA_h0; | 134 | c->h0=INIT_DATA_h0; |
| 128 | c->h1=INIT_DATA_h1; | 135 | c->h1=INIT_DATA_h1; |
| 129 | c->h2=INIT_DATA_h2; | 136 | c->h2=INIT_DATA_h2; |
