Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build with OpenSSL 1.1 is broken #7735

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions src/util/cert/libcrypto/cert.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#include <openssl/x509.h>
#include <openssl/bio.h>
#include <openssl/pem.h>
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
#include <openssl/core_names.h>
#endif

#include "util/util.h"
#include "util/sss_endian.h"
Expand Down Expand Up @@ -177,14 +179,18 @@ errno_t sss_cert_pem_to_der(TALLOC_CTX *mem_ctx, const char *pem,
#define IDENTIFIER_NISTP384 "nistp384"
#define IDENTIFIER_NISTP521 "nistp521"

#if OPENSSL_VERSION_NUMBER < 0x30000000L
static int sss_ec_get_key(BN_CTX *bn_ctx, EVP_PKEY *cert_pub_key,
#else
static int sss_ec_get_key(BN_CTX *bn_ctx, const EVP_PKEY *cert_pub_key,
#endif
EC_GROUP **_ec_group, EC_POINT **_ec_public_key)
{
EC_GROUP *ec_group = NULL;
EC_POINT *ec_public_key = NULL;
int ret;

#if OPENSSL_VERSION_NUMBER >= 0x30000000L
int ret;
static char curve_name[4096];
static unsigned char pubkey[4096];
size_t len;
Expand Down Expand Up @@ -243,7 +249,7 @@ static int sss_ec_get_key(BN_CTX *bn_ctx, const EVP_PKEY *cert_pub_key,
pk = EC_KEY_get0_public_key(ec_key);

ec_group = EC_GROUP_dup(gr);
if (*_ec_group == NULL) {
if (ec_group == NULL) {
ret = ENOMEM;
goto done;
}
Expand Down Expand Up @@ -373,7 +379,11 @@ static errno_t ec_pub_key_to_ssh(TALLOC_CTX *mem_ctx, EVP_PKEY *cert_pub_key,
#define SSH_RSA_HEADER "ssh-rsa"
#define SSH_RSA_HEADER_LEN (sizeof(SSH_RSA_HEADER) - 1)

#if OPENSSL_VERSION_NUMBER < 0x30000000L
static int sss_rsa_get_key(EVP_PKEY *cert_pub_key,
#else
static int sss_rsa_get_key(const EVP_PKEY *cert_pub_key,
#endif
BIGNUM **_n, BIGNUM **_e)
{
int ret;
Expand All @@ -396,26 +406,26 @@ static int sss_rsa_get_key(const EVP_PKEY *cert_pub_key,
#else

const BIGNUM *tmp_n;
const BIGNUM *tmp_e:
const BIGNUM *tmp_e;
const RSA *rsa_pub_key = NULL;
rsa_pub_key = EVP_PKEY_get0_RSA(cert_pub_key);
if (rsa_pub_key == NULL) {
ret = ENOMEM;
goto done;
}

RSA_get0_key(rsa_pub_key, tmp_n, tmp_e, NULL);
RSA_get0_key(rsa_pub_key, &tmp_n, &tmp_e, NULL);

*n = BN_dup(tmp_n);
if (*n == NULL) {
n = BN_dup(tmp_n);
if (n == NULL) {
ret = ENOMEM;
goto done;
}

*e = BN_dup(tmp_e);
if (*e == NULL) {
e = BN_dup(tmp_e);
if (e == NULL) {
BN_clear_free(n);
ret = ENOME;
ret = ENOMEM;
goto done;
}

Expand Down
Loading