diff options
Diffstat (limited to 'src/lib/libcrypto/evp/m_sha1.c')
-rw-r--r-- | src/lib/libcrypto/evp/m_sha1.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/src/lib/libcrypto/evp/m_sha1.c b/src/lib/libcrypto/evp/m_sha1.c index 4679b1c463..60da93873c 100644 --- a/src/lib/libcrypto/evp/m_sha1.c +++ b/src/lib/libcrypto/evp/m_sha1.c | |||
@@ -56,23 +56,25 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef OPENSSL_NO_SHA | ||
59 | #include <stdio.h> | 60 | #include <stdio.h> |
60 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
61 | |||
62 | #ifndef OPENSSL_NO_SHA | ||
63 | |||
64 | #include <openssl/evp.h> | 62 | #include <openssl/evp.h> |
65 | #include <openssl/objects.h> | 63 | #include <openssl/objects.h> |
66 | #include <openssl/x509.h> | 64 | #include <openssl/x509.h> |
67 | #ifndef OPENSSL_NO_RSA | ||
68 | #include <openssl/rsa.h> | ||
69 | #endif | ||
70 | 65 | ||
71 | static int init(EVP_MD_CTX *ctx) | 66 | static int init(EVP_MD_CTX *ctx) |
72 | { return SHA1_Init(ctx->md_data); } | 67 | { return SHA1_Init(ctx->md_data); } |
73 | 68 | ||
74 | static int update(EVP_MD_CTX *ctx,const void *data,size_t count) | 69 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) |
70 | #ifndef OPENSSL_FIPS | ||
75 | { return SHA1_Update(ctx->md_data,data,count); } | 71 | { return SHA1_Update(ctx->md_data,data,count); } |
72 | #else | ||
73 | { | ||
74 | OPENSSL_assert(sizeof(count)<=sizeof(size_t)); | ||
75 | return SHA1_Update(ctx->md_data,data,count); | ||
76 | } | ||
77 | #endif | ||
76 | 78 | ||
77 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | 79 | static int final(EVP_MD_CTX *ctx,unsigned char *md) |
78 | { return SHA1_Final(md,ctx->md_data); } | 80 | { return SHA1_Final(md,ctx->md_data); } |
@@ -82,7 +84,7 @@ static const EVP_MD sha1_md= | |||
82 | NID_sha1, | 84 | NID_sha1, |
83 | NID_sha1WithRSAEncryption, | 85 | NID_sha1WithRSAEncryption, |
84 | SHA_DIGEST_LENGTH, | 86 | SHA_DIGEST_LENGTH, |
85 | 0, | 87 | EVP_MD_FLAG_FIPS, |
86 | init, | 88 | init, |
87 | update, | 89 | update, |
88 | final, | 90 | final, |
@@ -99,6 +101,7 @@ const EVP_MD *EVP_sha1(void) | |||
99 | } | 101 | } |
100 | #endif | 102 | #endif |
101 | 103 | ||
104 | #ifdef OPENSSL_FIPS | ||
102 | #ifndef OPENSSL_NO_SHA256 | 105 | #ifndef OPENSSL_NO_SHA256 |
103 | static int init224(EVP_MD_CTX *ctx) | 106 | static int init224(EVP_MD_CTX *ctx) |
104 | { return SHA224_Init(ctx->md_data); } | 107 | { return SHA224_Init(ctx->md_data); } |
@@ -109,8 +112,11 @@ static int init256(EVP_MD_CTX *ctx) | |||
109 | * SHA256 functions even in SHA224 context. This is what happens | 112 | * SHA256 functions even in SHA224 context. This is what happens |
110 | * there anyway, so we can spare few CPU cycles:-) | 113 | * there anyway, so we can spare few CPU cycles:-) |
111 | */ | 114 | */ |
112 | static int update256(EVP_MD_CTX *ctx,const void *data,size_t count) | 115 | static int update256(EVP_MD_CTX *ctx,const void *data,unsigned long count) |
113 | { return SHA256_Update(ctx->md_data,data,count); } | 116 | { |
117 | OPENSSL_assert(sizeof(count)<=sizeof(size_t)); | ||
118 | return SHA256_Update(ctx->md_data,data,count); | ||
119 | } | ||
114 | static int final256(EVP_MD_CTX *ctx,unsigned char *md) | 120 | static int final256(EVP_MD_CTX *ctx,unsigned char *md) |
115 | { return SHA256_Final(md,ctx->md_data); } | 121 | { return SHA256_Final(md,ctx->md_data); } |
116 | 122 | ||
@@ -119,7 +125,7 @@ static const EVP_MD sha224_md= | |||
119 | NID_sha224, | 125 | NID_sha224, |
120 | NID_sha224WithRSAEncryption, | 126 | NID_sha224WithRSAEncryption, |
121 | SHA224_DIGEST_LENGTH, | 127 | SHA224_DIGEST_LENGTH, |
122 | 0, | 128 | EVP_MD_FLAG_FIPS, |
123 | init224, | 129 | init224, |
124 | update256, | 130 | update256, |
125 | final256, | 131 | final256, |
@@ -138,7 +144,7 @@ static const EVP_MD sha256_md= | |||
138 | NID_sha256, | 144 | NID_sha256, |
139 | NID_sha256WithRSAEncryption, | 145 | NID_sha256WithRSAEncryption, |
140 | SHA256_DIGEST_LENGTH, | 146 | SHA256_DIGEST_LENGTH, |
141 | 0, | 147 | EVP_MD_FLAG_FIPS, |
142 | init256, | 148 | init256, |
143 | update256, | 149 | update256, |
144 | final256, | 150 | final256, |
@@ -151,7 +157,7 @@ static const EVP_MD sha256_md= | |||
151 | 157 | ||
152 | const EVP_MD *EVP_sha256(void) | 158 | const EVP_MD *EVP_sha256(void) |
153 | { return(&sha256_md); } | 159 | { return(&sha256_md); } |
154 | #endif /* ifndef OPENSSL_NO_SHA256 */ | 160 | #endif /* ifndef OPENSSL_NO_SHA256 */ |
155 | 161 | ||
156 | #ifndef OPENSSL_NO_SHA512 | 162 | #ifndef OPENSSL_NO_SHA512 |
157 | static int init384(EVP_MD_CTX *ctx) | 163 | static int init384(EVP_MD_CTX *ctx) |
@@ -159,8 +165,11 @@ static int init384(EVP_MD_CTX *ctx) | |||
159 | static int init512(EVP_MD_CTX *ctx) | 165 | static int init512(EVP_MD_CTX *ctx) |
160 | { return SHA512_Init(ctx->md_data); } | 166 | { return SHA512_Init(ctx->md_data); } |
161 | /* See comment in SHA224/256 section */ | 167 | /* See comment in SHA224/256 section */ |
162 | static int update512(EVP_MD_CTX *ctx,const void *data,size_t count) | 168 | static int update512(EVP_MD_CTX *ctx,const void *data,unsigned long count) |
163 | { return SHA512_Update(ctx->md_data,data,count); } | 169 | { |
170 | OPENSSL_assert(sizeof(count)<=sizeof(size_t)); | ||
171 | return SHA512_Update(ctx->md_data,data,count); | ||
172 | } | ||
164 | static int final512(EVP_MD_CTX *ctx,unsigned char *md) | 173 | static int final512(EVP_MD_CTX *ctx,unsigned char *md) |
165 | { return SHA512_Final(md,ctx->md_data); } | 174 | { return SHA512_Final(md,ctx->md_data); } |
166 | 175 | ||
@@ -169,7 +178,7 @@ static const EVP_MD sha384_md= | |||
169 | NID_sha384, | 178 | NID_sha384, |
170 | NID_sha384WithRSAEncryption, | 179 | NID_sha384WithRSAEncryption, |
171 | SHA384_DIGEST_LENGTH, | 180 | SHA384_DIGEST_LENGTH, |
172 | 0, | 181 | EVP_MD_FLAG_FIPS, |
173 | init384, | 182 | init384, |
174 | update512, | 183 | update512, |
175 | final512, | 184 | final512, |
@@ -188,7 +197,7 @@ static const EVP_MD sha512_md= | |||
188 | NID_sha512, | 197 | NID_sha512, |
189 | NID_sha512WithRSAEncryption, | 198 | NID_sha512WithRSAEncryption, |
190 | SHA512_DIGEST_LENGTH, | 199 | SHA512_DIGEST_LENGTH, |
191 | 0, | 200 | EVP_MD_FLAG_FIPS, |
192 | init512, | 201 | init512, |
193 | update512, | 202 | update512, |
194 | final512, | 203 | final512, |
@@ -201,4 +210,5 @@ static const EVP_MD sha512_md= | |||
201 | 210 | ||
202 | const EVP_MD *EVP_sha512(void) | 211 | const EVP_MD *EVP_sha512(void) |
203 | { return(&sha512_md); } | 212 | { return(&sha512_md); } |
204 | #endif /* ifndef OPENSSL_NO_SHA512 */ | 213 | #endif /* ifndef OPENSSL_NO_SHA512 */ |
214 | #endif /* ifdef OPENSSL_FIPS */ | ||