libdvbci: fix for build with openssl 1.1

error: invalid use of incomplete type 'DH' {aka 'struct dh_st'}
This commit is contained in:
2019-02-15 13:25:58 +01:00
parent 97db720210
commit 1ce6f8c629
2 changed files with 24 additions and 2 deletions

View File

@@ -4,6 +4,7 @@
#include <openssl/dh.h>
#include <openssl/rsa.h>
#include <openssl/sha.h>
#include <openssl/opensslv.h>
#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);

View File

@@ -14,6 +14,7 @@
#include <openssl/x509v3.h>
#include <openssl/sha.h>
#include <openssl/aes.h>
#include <openssl/opensslv.h>
#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);