summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Makefile.am18
-rw-r--r--common/debug.c6
-rw-r--r--common/userpref.c28
3 files changed, 29 insertions, 23 deletions
diff --git a/common/Makefile.am b/common/Makefile.am
index 1a90571..bd09bad 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -4,22 +4,16 @@ AM_CPPFLAGS = \
AM_CFLAGS = \
$(GLOBAL_CFLAGS) \
+ $(ssl_lib_CFLAGS) \
+ $(LFS_CFLAGS) \
$(libusbmuxd_CFLAGS) \
- $(libplist_CFLAGS) \
- $(libgnutls_CFLAGS) \
- $(libtasn1_CFLAGS) \
- $(libgcrypt_CFLAGS) \
- $(openssl_CFLAGS) \
- $(LFS_CFLAGS)
+ $(libplist_CFLAGS)
AM_LDFLAGS = \
+ $(ssl_lib_LIBS) \
+ ${libpthread_LIBS} \
$(libusbmuxd_LIBS) \
- $(libplist_LIBS) \
- $(libgnutls_LIBS) \
- $(libtasn1_LIBS) \
- $(libgcrypt_LIBS) \
- $(openssl_LIBS) \
- ${libpthread_LIBS}
+ $(libplist_LIBS)
noinst_LTLIBRARIES = libinternalcommon.la
libinternalcommon_la_LIBADD =
diff --git a/common/debug.c b/common/debug.c
index 6212e71..cf1bc2f 100644
--- a/common/debug.c
+++ b/common/debug.c
@@ -31,9 +31,9 @@
#include <stdlib.h>
#include <time.h>
+#include "src/idevice.h"
#include "debug.h"
#include "libimobiledevice/libimobiledevice.h"
-#include "src/idevice.h"
#ifndef STRIP_DEBUG_CODE
#include "asprintf.h"
@@ -60,7 +60,7 @@ static void debug_print_line(const char *func, const char *file, int line, const
strftime(str_time, 254, "%H:%M:%S", localtime (&the_time));
/* generate header text */
- (void)asprintf(&header, "%s %s:%d %s()", str_time, file, line, func);
+ if(asprintf(&header, "%s %s:%d %s()", str_time, file, line, func)<0){}
free (str_time);
/* trim ending newlines */
@@ -86,7 +86,7 @@ void debug_info_real(const char *func, const char *file, int line, const char *f
/* run the real fprintf */
va_start(args, format);
- (void)vasprintf(&buffer, format, args);
+ if(vasprintf(&buffer, format, args)<0){}
va_end(args);
debug_print_line(func, file, line, buffer);
diff --git a/common/userpref.c b/common/userpref.c
index ddd380a..48bcfcb 100644
--- a/common/userpref.c
+++ b/common/userpref.c
@@ -338,7 +338,7 @@ userpref_error_t userpref_read_pair_record(const char *udid, plist_t *pair_recor
}
*pair_record = NULL;
- plist_from_memory(record_data, record_size, pair_record);
+ plist_from_memory(record_data, record_size, pair_record, NULL);
free(record_data);
if (!*pair_record) {
@@ -435,6 +435,10 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
debug_info("Generating keys and certificates...");
#if defined(HAVE_OPENSSL)
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ EVP_PKEY* root_pkey = EVP_RSA_gen(2048);
+ EVP_PKEY* host_pkey = EVP_RSA_gen(2048);
+#else
BIGNUM *e = BN_new();
RSA* root_keypair = RSA_new();
RSA* host_keypair = RSA_new();
@@ -451,6 +455,7 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
EVP_PKEY* host_pkey = EVP_PKEY_new();
EVP_PKEY_assign_RSA(host_pkey, host_keypair);
+#endif
/* generate root certificate */
X509* root_cert = X509_new();
@@ -561,12 +566,22 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
}
}
- RSA *pubkey = NULL;
+ EVP_PKEY *pubkey = NULL;
{
BIO *membp = BIO_new_mem_buf(public_key.data, public_key.size);
- if (!PEM_read_bio_RSAPublicKey(membp, &pubkey, NULL, NULL)) {
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L
+ if (!PEM_read_bio_PUBKEY(membp, &pubkey, NULL, NULL)) {
debug_info("WARNING: Could not read public key");
}
+#else
+ RSA *rsa_pubkey = NULL;
+ if (!PEM_read_bio_RSAPublicKey(membp, &rsa_pubkey, NULL, NULL)) {
+ debug_info("WARNING: Could not read public key");
+ } else {
+ pubkey = EVP_PKEY_new();
+ EVP_PKEY_assign_RSA(pubkey, rsa_pubkey);
+ }
+#endif
BIO_free(membp);
}
@@ -588,10 +603,7 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
X509_set1_notAfter(dev_cert, asn1time);
ASN1_TIME_free(asn1time);
- EVP_PKEY* pkey = EVP_PKEY_new();
- EVP_PKEY_assign_RSA(pkey, pubkey);
- X509_set_pubkey(dev_cert, pkey);
- EVP_PKEY_free(pkey);
+ X509_set_pubkey(dev_cert, pubkey);
X509_add_ext_helper(dev_cert, NID_subject_key_identifier, (char*)"hash");
X509_add_ext_helper(dev_cert, NID_key_usage, (char*)"critical,digitalSignature,keyEncipherment");
@@ -615,9 +627,9 @@ userpref_error_t pair_record_generate_keys_and_certs(plist_t pair_record, key_da
}
}
- X509V3_EXT_cleanup();
X509_free(dev_cert);
+ EVP_PKEY_free(pubkey);
EVP_PKEY_free(root_pkey);
EVP_PKEY_free(host_pkey);