Skip to content

Commit

Permalink
Support LibreSSL
Browse files Browse the repository at this point in the history
This works with LibreSSL 3.5.x.

Missing in LibreSSL:

* RAND_OpenSSL (Deprecated in OpenSSL >= 3.0)
* NID_sm2

Signed-off-by: orbea <orbea@riseup.net>
  • Loading branch information
orbea committed Apr 20, 2023
1 parent 91ee009 commit 24e2d97
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,27 @@ jobs:
- name: failure
if: ${{ failure() }}
run: cat $(find ../ -name test-suite.log) || true
test-libressl:
runs-on: ubuntu-latest
if: "!contains(github.ref, 'coverity_scan')"
strategy:
matrix:
docker_image: [fedora-34-libressl]
steps:
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Launch Action
uses:
tpm2-software/ci/runCI@main
with:
CC: gcc
DOCKER_IMAGE: ${{ matrix.docker_image }}
PROJECT_NAME: ${{ github.event.repository.name }}
- name: failure
if: ${{ failure() }}
run: cat $(find ../ -name test-suite.log) || true
test-no-crypto-build:
runs-on: ubuntu-latest
if: "!contains(github.ref, 'coverity_scan')"
Expand Down
8 changes: 6 additions & 2 deletions src/tss2-esys/esys_crypto_ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ iesys_cryptossl_hmac_start(ESYS_CRYPTO_CONTEXT_BLOB ** context,
"Error EVP_MD_CTX_create", cleanup);
}

#if OPENSSL_VERSION_NUMBER < 0x10101000L
#if OPENSSL_VERSION_NUMBER < 0x10101000L || \
( defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3070000fL )
if (!(hkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, key, size))) {
#else
/* this is preferred, but available since OpenSSL 1.1.1 only */
Expand Down Expand Up @@ -558,7 +559,9 @@ iesys_cryptossl_random2b(
int rc;
#if OPENSSL_VERSION_NUMBER < 0x30000000L
const RAND_METHOD *rand_save = RAND_get_rand_method();
#ifndef LIBRESSL_VERSION_NUMBER
RAND_set_rand_method(RAND_OpenSSL());
#endif
#else
OSSL_LIB_CTX *libctx = OSSL_LIB_CTX_new();
if (!libctx)
Expand Down Expand Up @@ -615,8 +618,9 @@ iesys_cryptossl_pk_encrypt(TPM2B_PUBLIC * pub_tpm_key,
RSA *rsa_key = NULL;
const EVP_MD * hashAlg = NULL;
const RAND_METHOD *rand_save = RAND_get_rand_method();

#ifndef LIBRESSL_VERSION_NUMBER
RAND_set_rand_method(RAND_OpenSSL());
#endif
#else
OSSL_LIB_CTX *libctx = NULL;
EVP_MD * hashAlg = NULL;
Expand Down

0 comments on commit 24e2d97

Please sign in to comment.