From e57b6e7163277c6a63f22a7e2942cf666cf71a80 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 5 Jul 2023 10:30:52 +0200 Subject: Updated OpenSSL-specific code to use OpenSSL 3.0+ API --- tools/idevicebackup.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tools') 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 @@ #include #if defined(HAVE_OPENSSL) #include +#if OPENSSL_VERSION_NUMBER >= 0x30000000L +#include +#endif #elif defined(HAVE_GNUTLS) #include #elif defined(HAVE_MBEDTLS) @@ -113,7 +116,11 @@ static int compare_hash(const unsigned char *hash1, const unsigned char *hash2, static void _sha1_update(void* context, const char* data, size_t len) { #if defined(HAVE_OPENSSL) +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + EVP_DigestUpdate(context, data, len); +#else SHA1_Update(context, data, len); +#endif #elif defined(HAVE_GNUTLS) gcry_md_write(context, data, len); #elif defined(HAVE_MBEDTLS) @@ -124,9 +131,15 @@ static void _sha1_update(void* context, const char* data, size_t len) 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) { #if defined(HAVE_OPENSSL) +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + EVP_MD_CTX* sha1 = EVP_MD_CTX_new(); + EVP_DigestInit(sha1, EVP_sha1()); + void* psha1 = sha1; +#else SHA_CTX sha1; SHA1_Init(&sha1); void* psha1 = &sha1; +#endif #elif defined(HAVE_GNUTLS) gcry_md_hd_t hd = NULL; 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 _sha1_update(psha1, "(null)", 6); } #if defined(HAVE_OPENSSL) +#if OPENSSL_VERSION_NUMBER >= 0x30000000L + EVP_DigestFinal(sha1, hash_out, NULL); + EVP_MD_CTX_destroy(sha1); +#else SHA1_Final(hash_out, &sha1); +#endif #elif defined(HAVE_GNUTLS) unsigned char *newhash = gcry_md_read(hd, GCRY_MD_SHA1); memcpy(hash_out, newhash, 20); -- cgit v1.1-32-gdbae