diff --git a/include/tss2/tss2_tpm2_types.h b/include/tss2/tss2_tpm2_types.h index f3863336b..550a64831 100644 --- a/include/tss2/tss2_tpm2_types.h +++ b/include/tss2/tss2_tpm2_types.h @@ -128,6 +128,10 @@ typedef UINT16 TPM2_ECC_CURVE; #define TPM2_ECC_BN_P256 ((TPM2_ECC_CURVE) 0x0010) #define TPM2_ECC_BN_P638 ((TPM2_ECC_CURVE) 0x0011) #define TPM2_ECC_SM2_P256 ((TPM2_ECC_CURVE) 0x0020) +#define TPM_ECC_BP_P256_R1 ((TPM2_ECC_CURVE) 0x0030) +#define TPM_ECC_BP_P384_R1 ((TPM2_ECC_CURVE) 0x0031) +#define TPM_ECC_BP_P512_R1 ((TPM2_ECC_CURVE) 0x0032) +#define TPM_ECC_CURVE_25519 ((TPM2_ECC_CURVE) 0x0040) /* From TPM 2.0 Part 2: Definition of TPM2_CC Constants */ typedef UINT32 TPM2_CC; diff --git a/src/tss2-esys/esys_crypto_ossl.c b/src/tss2-esys/esys_crypto_ossl.c index 15e534cec..16e29e0d9 100644 --- a/src/tss2-esys/esys_crypto_ossl.c +++ b/src/tss2-esys/esys_crypto_ossl.c @@ -930,6 +930,24 @@ iesys_cryptossl_get_ecdh_point(TPM2B_PUBLIC *key, curveId = NID_sm2; key_size = 32; break; +#endif +#ifdef NID_brainpoolP256r1 + case TPM_ECC_BP_P256_R1: + curveId = NID_brainpoolP256r1; + key_size = 32; + break; +#endif +#ifdef NID_brainpoolP384r1 + case TPM_ECC_BP_P384_R1: + curveId = NID_brainpoolP384r1; + key_size = 48; + break; +#endif +#ifdef NID_brainpoolP512r1 + case TPM_ECC_BP_P512_R1: + curveId = NID_brainpoolP512r1; + key_size = 64; + break; #endif default: return_error(TSS2_ESYS_RC_NOT_IMPLEMENTED, diff --git a/src/tss2-fapi/fapi_crypto.c b/src/tss2-fapi/fapi_crypto.c index eab576ac0..91111eebc 100644 --- a/src/tss2-fapi/fapi_crypto.c +++ b/src/tss2-fapi/fapi_crypto.c @@ -566,6 +566,21 @@ ossl_ecc_pub_from_tpm(const TPM2B_PUBLIC *tpmPublicKey, EVP_PKEY **evpPublicKey) case TPM2_ECC_SM2_P256: curveId = NID_sm2; break; +#endif +#ifdef NID_brainpoolP256r1 + case TPM_ECC_BP_P256_R1: + curveId = NID_brainpoolP256r1; + break; +#endif +#ifdef NID_brainpoolP384r1 + case TPM_ECC_BP_P384_R1: + curveId = NID_brainpoolP384r1; + break; +#endif +#ifdef NID_brainpoolP512r1 + case TPM_ECC_BP_P512_R1: + curveId = NID_brainpoolP512r1; + break; #endif default: return_error(TSS2_FAPI_RC_BAD_VALUE, diff --git a/src/tss2-fapi/tpm_json_deserialize.c b/src/tss2-fapi/tpm_json_deserialize.c index cc519be4e..93ce17ea4 100644 --- a/src/tss2-fapi/tpm_json_deserialize.c +++ b/src/tss2-fapi/tpm_json_deserialize.c @@ -837,6 +837,10 @@ ifapi_json_TPM2_ECC_CURVE_deserialize(json_object *jso, TPM2_ECC_CURVE *out) { TPM2_ECC_BN_P256, "BN_P256" }, { TPM2_ECC_BN_P638, "BN_P638" }, { TPM2_ECC_SM2_P256, "SM2_P256" }, + { TPM_ECC_BP_P256_R1, "BP_P256_R1" }, + { TPM_ECC_BP_P384_R1, "BP_P384_R1" }, + { TPM_ECC_BP_P512_R1, "BP_P512_R1" }, + { TPM_ECC_CURVE_25519, "CURVE_25519"}, }; const char *s = json_object_get_string(jso); @@ -3721,7 +3725,8 @@ ifapi_json_TPMI_ECC_CURVE_deserialize(json_object *jso, TPMI_ECC_CURVE *out) SUBTYPE_FILTER(TPMI_ECC_CURVE, TPM2_ECC_CURVE, TPM2_ECC_NONE, TPM2_ECC_NIST_P192, TPM2_ECC_NIST_P224, TPM2_ECC_NIST_P256, TPM2_ECC_NIST_P384, TPM2_ECC_NIST_P521, TPM2_ECC_BN_P256, TPM2_ECC_BN_P638, - TPM2_ECC_SM2_P256); + TPM2_ECC_SM2_P256, TPM_ECC_BP_P256_R1, TPM_ECC_BP_P384_R1, TPM_ECC_BP_P512_R1, + TPM_ECC_CURVE_25519); } static char *field_TPMT_ECC_SCHEME_tab[] = { diff --git a/src/tss2-fapi/tpm_json_serialize.c b/src/tss2-fapi/tpm_json_serialize.c index cbc3eb03b..73a6bdc0d 100644 --- a/src/tss2-fapi/tpm_json_serialize.c +++ b/src/tss2-fapi/tpm_json_serialize.c @@ -461,6 +461,10 @@ ifapi_json_TPM2_ECC_CURVE_serialize(const TPM2_ECC_CURVE in, json_object **jso) { TPM2_ECC_BN_P256, "BN_P256" }, { TPM2_ECC_BN_P638, "BN_P638" }, { TPM2_ECC_SM2_P256, "SM2_P256" }, + { TPM_ECC_BP_P256_R1, "BP_P256_R1" }, + { TPM_ECC_BP_P384_R1, "BP_P384_R1" }, + { TPM_ECC_BP_P512_R1, "BP_P512_R1" }, + { TPM_ECC_CURVE_25519, "CURVE_25519"}, }; for (size_t i = 0; i < sizeof(tab) / sizeof(tab[0]); i++) {