diff --git a/libdvbci/dh_rsa_misc.cpp b/libdvbci/dh_rsa_misc.cpp index 921821e..fe2e16b 100644 --- a/libdvbci/dh_rsa_misc.cpp +++ b/libdvbci/dh_rsa_misc.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "misc.h" @@ -148,21 +149,37 @@ int dh_gen_exp(uint8_t *dest, int dest_len, uint8_t *dh_g, int dh_g_len, uint8_t dh = DH_new(); +#if OPENSSL_VERSION_NUMBER < 0x10100000L dh->p = BN_bin2bn(dh_p, dh_p_len, 0); dh->g = BN_bin2bn(dh_g, dh_g_len, 0); dh->flags |= DH_FLAG_NO_EXP_CONSTTIME; +#else + BIGNUM *p = BN_bin2bn(dh_p, dh_p_len, 0); + BIGNUM *g = BN_bin2bn(dh_g, dh_g_len, 0); + DH_set0_pqg(dh, p, NULL, g); +#endif DH_generate_key(dh); - len = BN_num_bytes(dh->priv_key); + const BIGNUM *pub_key, *priv_key; + DH_get0_key(dh, &pub_key, &priv_key); + +#if OPENSSL_VERSION_NUMBER < 0x10100000L + len = BN_num_bytes(priv_key); +#else if (len > dest_len) { printf("len > dest_len\n"); return -1; } - +#endif gap = dest_len - len; memset(dest, 0, gap); + +#if OPENSSL_VERSION_NUMBER < 0x10100000L BN_bn2bin(dh->priv_key, &dest[gap]); +#else + BN_bn2bin(priv_key, &dest[gap]); +#endif DH_free(dh); diff --git a/libdvbci/dvbci_ccmgr.cpp b/libdvbci/dvbci_ccmgr.cpp index 53f3658..932e6b1 100644 --- a/libdvbci/dvbci_ccmgr.cpp +++ b/libdvbci/dvbci_ccmgr.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "misc.h" #include "_dh_params.h" @@ -240,7 +241,11 @@ static bool certificate_validate(struct cert_ctx *ctx, X509 *cert) ret = X509_verify_cert(store_ctx); if (ret != 1) +#if OPENSSL_VERSION_NUMBER < 0x10100000L fprintf(stderr, "%s\n", X509_verify_cert_error_string(store_ctx->error)); +#else + fprintf(stderr, "%s\n", X509_verify_cert_error_string(ret)); +#endif X509_STORE_CTX_free(store_ctx);