diff options
author | 2023-07-04 17:14:27 +0200 | |
---|---|---|
committer | 2023-07-04 17:14:27 +0200 | |
commit | 474fd9284b76d8ddd3a3aec41cbca3cc48271cc1 (patch) | |
tree | 58fcb909dff8cee2d2121d17bf0643fad6a8e766 /3rd_party/libsrp6a-sha512/t_sha.c | |
parent | 52ab7b76f76ee0464fd150ec881ce50fbf2dc001 (diff) | |
download | libimobiledevice-474fd9284b76d8ddd3a3aec41cbca3cc48271cc1.tar.gz libimobiledevice-474fd9284b76d8ddd3a3aec41cbca3cc48271cc1.tar.bz2 |
3rd_party/libsrp6a-sha512: Updated to work with OpenSSL 3.0+ API
Diffstat (limited to '3rd_party/libsrp6a-sha512/t_sha.c')
-rw-r--r-- | 3rd_party/libsrp6a-sha512/t_sha.c | 40 |
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 | ||
112 | void | ||
113 | SHA1Init_openssl(SHA1_CTX *ctx) | ||
114 | { | ||
115 | *ctx = EVP_MD_CTX_new(); | ||
116 | EVP_DigestInit(*ctx, EVP_sha1()); | ||
117 | } | ||
118 | |||
119 | void SHA1Update_openssl(SHA1_CTX *ctx, const void *data, unsigned int len) | ||
120 | { | ||
121 | EVP_DigestUpdate(*ctx, data, (size_t)len); | ||
122 | } | ||
123 | |||
124 | void SHA1Final_openssl(unsigned char digest[20], SHA1_CTX *ctx) | ||
125 | { | ||
126 | EVP_DigestFinal(*ctx, digest, NULL); | ||
127 | EVP_MD_CTX_destroy(*ctx); | ||
128 | } | ||
129 | |||
130 | void | ||
131 | SHA512Init_openssl(SHA512_CTX *ctx) | ||
132 | { | ||
133 | *ctx = EVP_MD_CTX_new(); | ||
134 | EVP_DigestInit(*ctx, EVP_sha512()); | ||
135 | } | ||
136 | |||
137 | void SHA512Update_openssl(SHA512_CTX *ctx, const void *data, unsigned int len) | ||
138 | { | ||
139 | EVP_DigestUpdate(*ctx, data, (size_t)len); | ||
140 | } | ||
141 | |||
142 | void 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 |