summaryrefslogtreecommitdiffstats
path: root/3rd_party/libsrp6a-sha512/t_sha.c
diff options
context:
space:
mode:
Diffstat (limited to '3rd_party/libsrp6a-sha512/t_sha.c')
-rw-r--r--3rd_party/libsrp6a-sha512/t_sha.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/3rd_party/libsrp6a-sha512/t_sha.c b/3rd_party/libsrp6a-sha512/t_sha.c
index 4029de8..8e54cb6 100644
--- a/3rd_party/libsrp6a-sha512/t_sha.c
+++ b/3rd_party/libsrp6a-sha512/t_sha.c
@@ -107,6 +107,44 @@ SHA512Final_mbed(unsigned char digest[64], SHA512_CTX * ctx)
107 mbedtls_md_free(ctx); 107 mbedtls_md_free(ctx);
108} 108}
109 109
110#elif defined(OPENSSL_SHA)
111#if OPENSSL_VERSION_NUMBER >= 0x30000000L
112void
113SHA1Init_openssl(SHA1_CTX *ctx)
114{
115 *ctx = EVP_MD_CTX_new();
116 EVP_DigestInit(*ctx, EVP_sha1());
117}
118
119void SHA1Update_openssl(SHA1_CTX *ctx, const void *data, unsigned int len)
120{
121 EVP_DigestUpdate(*ctx, data, (size_t)len);
122}
123
124void SHA1Final_openssl(unsigned char digest[20], SHA1_CTX *ctx)
125{
126 EVP_DigestFinal(*ctx, digest, NULL);
127 EVP_MD_CTX_destroy(*ctx);
128}
129
130void
131SHA512Init_openssl(SHA512_CTX *ctx)
132{
133 *ctx = EVP_MD_CTX_new();
134 EVP_DigestInit(*ctx, EVP_sha512());
135}
136
137void SHA512Update_openssl(SHA512_CTX *ctx, const void *data, unsigned int len)
138{
139 EVP_DigestUpdate(*ctx, data, (size_t)len);
140}
141
142void SHA512Final_openssl(unsigned char digest[64], SHA512_CTX *ctx)
143{
144 EVP_DigestFinal(*ctx, digest, NULL);
145 EVP_MD_CTX_destroy(*ctx);
146}
147#endif
110#elif !defined(OPENSSL_SHA) && !defined(TOMCRYPT_SHA) 148#elif !defined(OPENSSL_SHA) && !defined(TOMCRYPT_SHA)
111/* Use the free SHA1 if the library doesn't have it */ 149/* Use the free SHA1 if the library doesn't have it */
112 150
@@ -273,4 +311,4 @@ unsigned char finalcount[8];
273 SHA1Transform(context->state, context->buffer); 311 SHA1Transform(context->state, context->buffer);
274#endif 312#endif
275} 313}
276#endif /* OPENSSL */ 314#endif