Skip to content

Commit

Permalink
Fixed OQS include for non-OQS enabled compilation. Fixed name of vari…
Browse files Browse the repository at this point in the history
…able for OpenSSL 3.x HSM's PEM write function.
  • Loading branch information
Massimiliano Pala committed Aug 16, 2023
1 parent af946c1 commit f43b3ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 10 additions & 4 deletions src/drivers/openssl/openssl_hsm_pkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,9 @@ PKI_X509_KEYPAIR *HSM_OPENSSL_X509_KEYPAIR_new(PKI_KEYPARAMS * kp,
// Memory Cleanup
if (value) EVP_PKEY_free(value);
if (ret) PKI_X509_KEYPAIR_free(ret);
#ifdef ENABLE_OQS
if (ctx) EVP_PKEY_CTX_free(ctx);
#endif

// Error
return NULL;
Expand All @@ -897,9 +899,13 @@ void HSM_OPENSSL_X509_KEYPAIR_free ( PKI_X509_KEYPAIR *pkey ) {
// we have to provide our own function until OpenSSL solve
// this issue

int OPENSSL_HSM_write_bio_PrivateKey (BIO *bp, EVP_PKEY *x,
const EVP_CIPHER *enc, unsigned char *out_buffer, int klen,
pem_password_cb *cb, void *u) {
int OPENSSL_HSM_write_bio_PrivateKey (BIO * bp,
EVP_PKEY * x,
const EVP_CIPHER * enc,
unsigned char * out_buffer,
int klen,
pem_password_cb * cb,
void * u) {

int ret = PKI_ERR;

Expand All @@ -914,7 +920,7 @@ int OPENSSL_HSM_write_bio_PrivateKey (BIO *bp, EVP_PKEY *x,
case EVP_PKEY_EC: {
# if OPENSSL_VERSION_NUMBER >= 0x30000000L
ret = PEM_write_bio_ECPrivateKey(bp,
EVP_PKEY_get1_EC_KEY(x), enc, (unsigned char *) kstr, klen, cb, u);
EVP_PKEY_get1_EC_KEY(x), enc, (unsigned char *) out_buffer, klen, cb, u);
# elif OPENSSL_VERSION_NUMBER < 0x1010000fL
ret = PEM_write_bio_ECPrivateKey(bp,
x->pkey.ec, enc, (unsigned char *) out_buffer, klen, cb, u);
Expand Down
6 changes: 4 additions & 2 deletions src/libpki/openssl/pki_oid_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
* Released under OpenCA LICENSE
*/

#ifndef OQS_H
#include <oqs/oqs.h>
#ifdef ENABLE_OQS
# ifndef OQS_H
# include <oqs/oqs.h>
# endif
#endif

#ifndef _LIBPKI_OID_DEFS_H
Expand Down

0 comments on commit f43b3ce

Please sign in to comment.