Skip to content

Commit

Permalink
src: Check if NID_sm2 is defined
Browse files Browse the repository at this point in the history
The NID_sm2 algorithm is not currently supported by LibreSSL which
causes build failures. However instead of checking the OpenSSL version
number it is possible to just check if NID_sm2 is defined instead. This
way it will be automatically enabled when LibreSSL does support it and
disabled in the event the OpenSSL stops supporting it.

LibreSSL issue: libressl/portable#841

Signed-off-by: orbea <orbea@riseup.net>
  • Loading branch information
orbea authored and JuergenReppSIT committed Apr 20, 2023
1 parent 3d3c9a8 commit 569bf25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/tss2-esys/esys_crypto_ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ iesys_cryptossl_get_ecdh_point(TPM2B_PUBLIC *key,
curveId = NID_secp521r1;
key_size = 66;
break;
#if OPENSSL_VERSION_NUMBER >= 0x10101000L
#ifdef NID_sm2
case TPM2_ECC_SM2_P256:
curveId = NID_sm2;
key_size = 32;
Expand Down
4 changes: 2 additions & 2 deletions src/tss2-fapi/fapi_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ ossl_ecc_pub_from_tpm(const TPM2B_PUBLIC *tpmPublicKey, EVP_PKEY **evpPublicKey)
case TPM2_ECC_NIST_P521:
curveId = NID_secp521r1;
break;
#if OPENSSL_VERSION_NUMBER >= 0x10101000L
#ifdef NID_sm2
case TPM2_ECC_SM2_P256:
curveId = NID_sm2;
break;
Expand Down Expand Up @@ -1195,7 +1195,7 @@ get_ecc_tpm2b_public_from_evp(
case NID_secp521r1:
tpmCurveId = TPM2_ECC_NIST_P521;
break;
#if OPENSSL_VERSION_NUMBER >= 0x10101000L
#ifdef NID_sm2
case NID_sm2:
tpmCurveId = TPM2_ECC_SM2_P256;
break;
Expand Down

0 comments on commit 569bf25

Please sign in to comment.