diff options
Diffstat (limited to 'src/lib/libcrypto/evp/m_sha1.c')
| -rw-r--r-- | src/lib/libcrypto/evp/m_sha1.c | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/src/lib/libcrypto/evp/m_sha1.c b/src/lib/libcrypto/evp/m_sha1.c index 8c7e4eb222..e4af84acd2 100644 --- a/src/lib/libcrypto/evp/m_sha1.c +++ b/src/lib/libcrypto/evp/m_sha1.c | |||
| @@ -69,17 +69,20 @@ | |||
| 69 | #endif | 69 | #endif |
| 70 | 70 | ||
| 71 | 71 | ||
| 72 | static int init(EVP_MD_CTX *ctx) | 72 | static int |
| 73 | init(EVP_MD_CTX *ctx) | ||
| 73 | { | 74 | { |
| 74 | return SHA1_Init(ctx->md_data); | 75 | return SHA1_Init(ctx->md_data); |
| 75 | } | 76 | } |
| 76 | 77 | ||
| 77 | static int update(EVP_MD_CTX *ctx, const void *data, size_t count) | 78 | static int |
| 79 | update(EVP_MD_CTX *ctx, const void *data, size_t count) | ||
| 78 | { | 80 | { |
| 79 | return SHA1_Update(ctx->md_data, data, count); | 81 | return SHA1_Update(ctx->md_data, data, count); |
| 80 | } | 82 | } |
| 81 | 83 | ||
| 82 | static int final(EVP_MD_CTX *ctx, unsigned char *md) | 84 | static int |
| 85 | final(EVP_MD_CTX *ctx, unsigned char *md) | ||
| 83 | { | 86 | { |
| 84 | return SHA1_Final(md, ctx->md_data); | 87 | return SHA1_Final(md, ctx->md_data); |
| 85 | } | 88 | } |
| @@ -107,11 +110,14 @@ EVP_sha1(void) | |||
| 107 | #endif | 110 | #endif |
| 108 | 111 | ||
| 109 | #ifndef OPENSSL_NO_SHA256 | 112 | #ifndef OPENSSL_NO_SHA256 |
| 110 | static int init224(EVP_MD_CTX *ctx) | 113 | static int |
| 114 | init224(EVP_MD_CTX *ctx) | ||
| 111 | { | 115 | { |
| 112 | return SHA224_Init(ctx->md_data); | 116 | return SHA224_Init(ctx->md_data); |
| 113 | } | 117 | } |
| 114 | static int init256(EVP_MD_CTX *ctx) | 118 | |
| 119 | static int | ||
| 120 | init256(EVP_MD_CTX *ctx) | ||
| 115 | { | 121 | { |
| 116 | return SHA256_Init(ctx->md_data); | 122 | return SHA256_Init(ctx->md_data); |
| 117 | } | 123 | } |
| @@ -120,11 +126,14 @@ static int init256(EVP_MD_CTX *ctx) | |||
| 120 | * SHA256 functions even in SHA224 context. This is what happens | 126 | * SHA256 functions even in SHA224 context. This is what happens |
| 121 | * there anyway, so we can spare few CPU cycles:-) | 127 | * there anyway, so we can spare few CPU cycles:-) |
| 122 | */ | 128 | */ |
| 123 | static int update256(EVP_MD_CTX *ctx, const void *data, size_t count) | 129 | static int |
| 130 | update256(EVP_MD_CTX *ctx, const void *data, size_t count) | ||
| 124 | { | 131 | { |
| 125 | return SHA256_Update(ctx->md_data, data, count); | 132 | return SHA256_Update(ctx->md_data, data, count); |
| 126 | } | 133 | } |
| 127 | static int final256(EVP_MD_CTX *ctx, unsigned char *md) | 134 | |
| 135 | static int | ||
| 136 | final256(EVP_MD_CTX *ctx, unsigned char *md) | ||
| 128 | { | 137 | { |
| 129 | return SHA256_Final(md, ctx->md_data); | 138 | return SHA256_Final(md, ctx->md_data); |
| 130 | } | 139 | } |
| @@ -144,7 +153,8 @@ static const EVP_MD sha224_md = { | |||
| 144 | sizeof(EVP_MD *) + sizeof(SHA256_CTX), | 153 | sizeof(EVP_MD *) + sizeof(SHA256_CTX), |
| 145 | }; | 154 | }; |
| 146 | 155 | ||
| 147 | const EVP_MD *EVP_sha224(void) | 156 | const EVP_MD * |
| 157 | EVP_sha224(void) | ||
| 148 | { | 158 | { |
| 149 | return (&sha224_md); | 159 | return (&sha224_md); |
| 150 | } | 160 | } |
| @@ -164,27 +174,34 @@ static const EVP_MD sha256_md = { | |||
| 164 | sizeof(EVP_MD *) + sizeof(SHA256_CTX), | 174 | sizeof(EVP_MD *) + sizeof(SHA256_CTX), |
| 165 | }; | 175 | }; |
| 166 | 176 | ||
| 167 | const EVP_MD *EVP_sha256(void) | 177 | const EVP_MD * |
| 178 | EVP_sha256(void) | ||
| 168 | { | 179 | { |
| 169 | return (&sha256_md); | 180 | return (&sha256_md); |
| 170 | } | 181 | } |
| 171 | #endif /* ifndef OPENSSL_NO_SHA256 */ | 182 | #endif /* ifndef OPENSSL_NO_SHA256 */ |
| 172 | 183 | ||
| 173 | #ifndef OPENSSL_NO_SHA512 | 184 | #ifndef OPENSSL_NO_SHA512 |
| 174 | static int init384(EVP_MD_CTX *ctx) | 185 | static int |
| 186 | init384(EVP_MD_CTX *ctx) | ||
| 175 | { | 187 | { |
| 176 | return SHA384_Init(ctx->md_data); | 188 | return SHA384_Init(ctx->md_data); |
| 177 | } | 189 | } |
| 178 | static int init512(EVP_MD_CTX *ctx) | 190 | |
| 191 | static int | ||
| 192 | init512(EVP_MD_CTX *ctx) | ||
| 179 | { | 193 | { |
| 180 | return SHA512_Init(ctx->md_data); | 194 | return SHA512_Init(ctx->md_data); |
| 181 | } | 195 | } |
| 182 | /* See comment in SHA224/256 section */ | 196 | /* See comment in SHA224/256 section */ |
| 183 | static int update512(EVP_MD_CTX *ctx, const void *data, size_t count) | 197 | static int |
| 198 | update512(EVP_MD_CTX *ctx, const void *data, size_t count) | ||
| 184 | { | 199 | { |
| 185 | return SHA512_Update(ctx->md_data, data, count); | 200 | return SHA512_Update(ctx->md_data, data, count); |
| 186 | } | 201 | } |
| 187 | static int final512(EVP_MD_CTX *ctx, unsigned char *md) | 202 | |
| 203 | static int | ||
| 204 | final512(EVP_MD_CTX *ctx, unsigned char *md) | ||
| 188 | { | 205 | { |
| 189 | return SHA512_Final(md, ctx->md_data); | 206 | return SHA512_Final(md, ctx->md_data); |
| 190 | } | 207 | } |
| @@ -204,7 +221,8 @@ static const EVP_MD sha384_md = { | |||
| 204 | sizeof(EVP_MD *) + sizeof(SHA512_CTX), | 221 | sizeof(EVP_MD *) + sizeof(SHA512_CTX), |
| 205 | }; | 222 | }; |
| 206 | 223 | ||
| 207 | const EVP_MD *EVP_sha384(void) | 224 | const EVP_MD * |
| 225 | EVP_sha384(void) | ||
| 208 | { | 226 | { |
| 209 | return (&sha384_md); | 227 | return (&sha384_md); |
| 210 | } | 228 | } |
| @@ -224,7 +242,8 @@ static const EVP_MD sha512_md = { | |||
| 224 | sizeof(EVP_MD *) + sizeof(SHA512_CTX), | 242 | sizeof(EVP_MD *) + sizeof(SHA512_CTX), |
| 225 | }; | 243 | }; |
| 226 | 244 | ||
| 227 | const EVP_MD *EVP_sha512(void) | 245 | const EVP_MD * |
| 246 | EVP_sha512(void) | ||
| 228 | { | 247 | { |
| 229 | return (&sha512_md); | 248 | return (&sha512_md); |
| 230 | } | 249 | } |
