Rename diffie_hellman_t to key_exchange_t and change the interface etc.

This makes it more generic so we can use it for QSKE methods.
This commit is contained in:
Tobias Brunner
2022-06-29 10:28:50 +02:00
parent ec95fd9b93
commit 3af7c6db87
130 changed files with 1379 additions and 1384 deletions
+12 -12
View File
@@ -650,8 +650,8 @@ static bool kdf_e(TPMI_ALG_HASH hash_alg, chunk_t z, chunk_t label,
static bool ecc_salt(TPM2B_PUBLIC *public, TPMI_ALG_HASH hash_alg,
chunk_t *secret, TPM2B_ENCRYPTED_SECRET *encryptedSalt)
{
diffie_hellman_group_t ec_group;
diffie_hellman_t *dh;
key_exchange_method_t ec_ke_method;
key_exchange_t *ke;
chunk_t ecdh_pubkey = chunk_empty, ecdh_pubkey_x, ecdh_pubkey_y;
chunk_t ecc_pubkey = chunk_empty, ecc_pubkey_x, ecc_pubkey_y;
chunk_t z = chunk_empty;
@@ -663,13 +663,13 @@ static bool ecc_salt(TPM2B_PUBLIC *public, TPMI_ALG_HASH hash_alg,
switch (public->publicArea.parameters.eccDetail.curveID)
{
case TPM2_ECC_NIST_P256:
ec_group = ECP_256_BIT;
ec_ke_method = ECP_256_BIT;
break;
case TPM2_ECC_NIST_P384:
ec_group = ECP_384_BIT;
ec_ke_method = ECP_384_BIT;
break;
case TPM2_ECC_NIST_P521:
ec_group = ECP_521_BIT;
ec_ke_method = ECP_521_BIT;
break;
default:
DBG1(DBG_PTS, "type of ECC EK key not supported");
@@ -677,16 +677,16 @@ static bool ecc_salt(TPM2B_PUBLIC *public, TPMI_ALG_HASH hash_alg,
}
/* Generate ECDH key pair */
dh = lib->crypto->create_dh(lib->crypto, ec_group);
if (!dh)
ke = lib->crypto->create_ke(lib->crypto, ec_ke_method);
if (!ke)
{
DBG1(DBG_PTS, "DH group could not be created");
return FALSE;
}
if (!dh->get_my_public_value(dh, &ecdh_pubkey))
if (!ke->get_public_key(ke, &ecdh_pubkey))
{
DBG1(DBG_PTS, "DH public key could not be generated");
dh->destroy(dh);
ke->destroy(ke);
return FALSE;
}
ecdh_pubkey_x = chunk_create(ecdh_pubkey.ptr, ecdh_pubkey.len / 2);
@@ -701,12 +701,12 @@ static bool ecc_salt(TPM2B_PUBLIC *public, TPMI_ALG_HASH hash_alg,
ecc_pubkey = chunk_cat("cc", ecc_pubkey_x, ecc_pubkey_y);
/* compute point multiplication of ecc_pubkey with ecdh_privkey */
if (!dh->set_other_public_value(dh, ecc_pubkey))
if (!ke->set_public_key(ke, ecc_pubkey))
{
DBG1(DBG_PTS, "ECC public could not be set");
goto error;
}
if (!dh->get_shared_secret(dh, &z))
if (!ke->get_shared_secret(ke, &z))
{
DBG1(DBG_PTS, "could not create shared secret");
goto error;
@@ -736,7 +736,7 @@ static bool ecc_salt(TPM2B_PUBLIC *public, TPMI_ALG_HASH hash_alg,
success = TRUE;
error:
dh->destroy(dh);
ke->destroy(ke);
chunk_free(&ecdh_pubkey);
chunk_free(&ecc_pubkey);
chunk_clear(&z);