diff options
author | 2023-07-05 10:30:52 +0200 | |
---|---|---|
committer | 2023-07-05 10:30:52 +0200 | |
commit | e57b6e7163277c6a63f22a7e2942cf666cf71a80 (patch) | |
tree | 56c083f63bffb238a1aabd8f43a42489c19570d6 /tools | |
parent | 474fd9284b76d8ddd3a3aec41cbca3cc48271cc1 (diff) | |
download | libimobiledevice-e57b6e7163277c6a63f22a7e2942cf666cf71a80.tar.gz libimobiledevice-e57b6e7163277c6a63f22a7e2942cf666cf71a80.tar.bz2 |
Updated OpenSSL-specific code to use OpenSSL 3.0+ API
Diffstat (limited to 'tools')
-rw-r--r-- | tools/idevicebackup.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/idevicebackup.c b/tools/idevicebackup.c index 1684666..5694c12 100644 --- a/tools/idevicebackup.c +++ b/tools/idevicebackup.c | |||
@@ -34,6 +34,9 @@ | |||
34 | #include <getopt.h> | 34 | #include <getopt.h> |
35 | #if defined(HAVE_OPENSSL) | 35 | #if defined(HAVE_OPENSSL) |
36 | #include <openssl/sha.h> | 36 | #include <openssl/sha.h> |
37 | #if OPENSSL_VERSION_NUMBER >= 0x30000000L | ||
38 | #include <openssl/evp.h> | ||
39 | #endif | ||
37 | #elif defined(HAVE_GNUTLS) | 40 | #elif defined(HAVE_GNUTLS) |
38 | #include <gcrypt.h> | 41 | #include <gcrypt.h> |
39 | #elif defined(HAVE_MBEDTLS) | 42 | #elif defined(HAVE_MBEDTLS) |
@@ -113,7 +116,11 @@ static int compare_hash(const unsigned char *hash1, const unsigned char *hash2, | |||
113 | static void _sha1_update(void* context, const char* data, size_t len) | 116 | static void _sha1_update(void* context, const char* data, size_t len) |
114 | { | 117 | { |
115 | #if defined(HAVE_OPENSSL) | 118 | #if defined(HAVE_OPENSSL) |
119 | #if OPENSSL_VERSION_NUMBER >= 0x30000000L | ||
120 | EVP_DigestUpdate(context, data, len); | ||
121 | #else | ||
116 | SHA1_Update(context, data, len); | 122 | SHA1_Update(context, data, len); |
123 | #endif | ||
117 | #elif defined(HAVE_GNUTLS) | 124 | #elif defined(HAVE_GNUTLS) |
118 | gcry_md_write(context, data, len); | 125 | gcry_md_write(context, data, len); |
119 | #elif defined(HAVE_MBEDTLS) | 126 | #elif defined(HAVE_MBEDTLS) |
@@ -124,9 +131,15 @@ static void _sha1_update(void* context, const char* data, size_t len) | |||
124 | static void compute_datahash(const char *path, const char *destpath, uint8_t greylist, const char *domain, const char *appid, const char *version, unsigned char *hash_out) | 131 | static void compute_datahash(const char *path, const char *destpath, uint8_t greylist, const char *domain, const char *appid, const char *version, unsigned char *hash_out) |
125 | { | 132 | { |
126 | #if defined(HAVE_OPENSSL) | 133 | #if defined(HAVE_OPENSSL) |
134 | #if OPENSSL_VERSION_NUMBER >= 0x30000000L | ||
135 | EVP_MD_CTX* sha1 = EVP_MD_CTX_new(); | ||
136 | EVP_DigestInit(sha1, EVP_sha1()); | ||
137 | void* psha1 = sha1; | ||
138 | #else | ||
127 | SHA_CTX sha1; | 139 | SHA_CTX sha1; |
128 | SHA1_Init(&sha1); | 140 | SHA1_Init(&sha1); |
129 | void* psha1 = &sha1; | 141 | void* psha1 = &sha1; |
142 | #endif | ||
130 | #elif defined(HAVE_GNUTLS) | 143 | #elif defined(HAVE_GNUTLS) |
131 | gcry_md_hd_t hd = NULL; | 144 | gcry_md_hd_t hd = NULL; |
132 | gcry_md_open(&hd, GCRY_MD_SHA1, 0); | 145 | gcry_md_open(&hd, GCRY_MD_SHA1, 0); |
@@ -180,7 +193,12 @@ static void compute_datahash(const char *path, const char *destpath, uint8_t gre | |||
180 | _sha1_update(psha1, "(null)", 6); | 193 | _sha1_update(psha1, "(null)", 6); |
181 | } | 194 | } |
182 | #if defined(HAVE_OPENSSL) | 195 | #if defined(HAVE_OPENSSL) |
196 | #if OPENSSL_VERSION_NUMBER >= 0x30000000L | ||
197 | EVP_DigestFinal(sha1, hash_out, NULL); | ||
198 | EVP_MD_CTX_destroy(sha1); | ||
199 | #else | ||
183 | SHA1_Final(hash_out, &sha1); | 200 | SHA1_Final(hash_out, &sha1); |
201 | #endif | ||
184 | #elif defined(HAVE_GNUTLS) | 202 | #elif defined(HAVE_GNUTLS) |
185 | unsigned char *newhash = gcry_md_read(hd, GCRY_MD_SHA1); | 203 | unsigned char *newhash = gcry_md_read(hd, GCRY_MD_SHA1); |
186 | memcpy(hash_out, newhash, 20); | 204 | memcpy(hash_out, newhash, 20); |