Adapt names: dh -> xxdh
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
diff --git a/library/ssl_tls12_server.c b/library/ssl_tls12_server.c
index c023d1f..9d302d6 100644
--- a/library/ssl_tls12_server.c
+++ b/library/ssl_tls12_server.c
@@ -2628,20 +2628,20 @@
return MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH;
}
- ssl->handshake->dh_psa_privkey = pk->priv_id;
+ ssl->handshake->xxdh_psa_privkey = pk->priv_id;
/* Key should not be destroyed in the TLS library */
- ssl->handshake->dh_psa_privkey_is_external = 1;
+ ssl->handshake->xxdh_psa_privkey_is_external = 1;
- status = psa_get_key_attributes(ssl->handshake->dh_psa_privkey,
+ status = psa_get_key_attributes(ssl->handshake->xxdh_psa_privkey,
&key_attributes);
if (status != PSA_SUCCESS) {
- ssl->handshake->dh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
+ ssl->handshake->xxdh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
return PSA_TO_MBEDTLS_ERR(status);
}
- ssl->handshake->dh_psa_type = psa_get_key_type(&key_attributes);
- ssl->handshake->dh_bits = psa_get_key_bits(&key_attributes);
+ ssl->handshake->xxdh_psa_type = psa_get_key_type(&key_attributes);
+ ssl->handshake->xxdh_bits = psa_get_key_bits(&key_attributes);
psa_reset_key_attributes(&key_attributes);
@@ -2665,16 +2665,16 @@
/* If the above conversion to TLS ID was fine, then also this one will
be, so there is no need to check the return value here */
mbedtls_ssl_get_psa_curve_info_from_tls_id(tls_id, &key_type,
- &ssl->handshake->dh_bits);
+ &ssl->handshake->xxdh_bits);
- ssl->handshake->dh_psa_type = key_type;
+ ssl->handshake->xxdh_psa_type = key_type;
key_attributes = psa_key_attributes_init();
psa_set_key_usage_flags(&key_attributes, PSA_KEY_USAGE_DERIVE);
psa_set_key_algorithm(&key_attributes, PSA_ALG_ECDH);
psa_set_key_type(&key_attributes,
- PSA_KEY_TYPE_ECC_KEY_PAIR(ssl->handshake->dh_psa_type));
- psa_set_key_bits(&key_attributes, ssl->handshake->dh_bits);
+ PSA_KEY_TYPE_ECC_KEY_PAIR(ssl->handshake->xxdh_psa_type));
+ psa_set_key_bits(&key_attributes, ssl->handshake->xxdh_bits);
key_len = PSA_BITS_TO_BYTES(key->grp.pbits);
ret = mbedtls_ecp_write_key(key, buf, key_len);
@@ -2684,7 +2684,7 @@
}
status = psa_import_key(&key_attributes, buf, key_len,
- &ssl->handshake->dh_psa_privkey);
+ &ssl->handshake->xxdh_psa_privkey);
if (status != PSA_SUCCESS) {
ret = PSA_TO_MBEDTLS_ERR(status);
mbedtls_platform_zeroize(buf, sizeof(buf));
@@ -2981,14 +2981,14 @@
MBEDTLS_SSL_DEBUG_MSG(1, ("Invalid ecc group parse."));
return MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER;
}
- handshake->dh_psa_type = key_type;
- handshake->dh_bits = ec_bits;
+ handshake->xxdh_psa_type = key_type;
+ handshake->xxdh_bits = ec_bits;
key_attributes = psa_key_attributes_init();
psa_set_key_usage_flags(&key_attributes, PSA_KEY_USAGE_DERIVE);
psa_set_key_algorithm(&key_attributes, PSA_ALG_ECDH);
- psa_set_key_type(&key_attributes, handshake->dh_psa_type);
- psa_set_key_bits(&key_attributes, handshake->dh_bits);
+ psa_set_key_type(&key_attributes, handshake->xxdh_psa_type);
+ psa_set_key_bits(&key_attributes, handshake->xxdh_bits);
/*
* ECParameters curve_params
@@ -3005,7 +3005,7 @@
/* Generate ECDH private key. */
status = psa_generate_key(&key_attributes,
- &handshake->dh_psa_privkey);
+ &handshake->xxdh_psa_privkey);
if (status != PSA_SUCCESS) {
ret = PSA_TO_MBEDTLS_ERR(status);
MBEDTLS_SSL_DEBUG_RET(1, "psa_generate_key", ret);
@@ -3027,14 +3027,14 @@
size_t own_pubkey_max_len = (size_t) (MBEDTLS_SSL_OUT_CONTENT_LEN
- (own_pubkey - ssl->out_msg));
- status = psa_export_public_key(handshake->dh_psa_privkey,
+ status = psa_export_public_key(handshake->xxdh_psa_privkey,
own_pubkey, own_pubkey_max_len,
&len);
if (status != PSA_SUCCESS) {
ret = PSA_TO_MBEDTLS_ERR(status);
MBEDTLS_SSL_DEBUG_RET(1, "psa_export_public_key", ret);
- (void) psa_destroy_key(handshake->dh_psa_privkey);
- handshake->dh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
+ (void) psa_destroy_key(handshake->xxdh_psa_privkey);
+ handshake->xxdh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
return ret;
}
@@ -3729,27 +3729,27 @@
}
/* Store peer's ECDH public key. */
- memcpy(handshake->dh_psa_peerkey, p, data_len);
- handshake->dh_psa_peerkey_len = data_len;
+ memcpy(handshake->xxdh_psa_peerkey, p, data_len);
+ handshake->xxdh_psa_peerkey_len = data_len;
/* Compute ECDH shared secret. */
status = psa_raw_key_agreement(
- PSA_ALG_ECDH, handshake->dh_psa_privkey,
- handshake->dh_psa_peerkey, handshake->dh_psa_peerkey_len,
+ PSA_ALG_ECDH, handshake->xxdh_psa_privkey,
+ handshake->xxdh_psa_peerkey, handshake->xxdh_psa_peerkey_len,
handshake->premaster, sizeof(handshake->premaster),
&handshake->pmslen);
if (status != PSA_SUCCESS) {
ret = PSA_TO_MBEDTLS_ERR(status);
MBEDTLS_SSL_DEBUG_RET(1, "psa_raw_key_agreement", ret);
- if (handshake->dh_psa_privkey_is_external == 0) {
- (void) psa_destroy_key(handshake->dh_psa_privkey);
+ if (handshake->xxdh_psa_privkey_is_external == 0) {
+ (void) psa_destroy_key(handshake->xxdh_psa_privkey);
}
- handshake->dh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
+ handshake->xxdh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
return ret;
}
- if (handshake->dh_psa_privkey_is_external == 0) {
- status = psa_destroy_key(handshake->dh_psa_privkey);
+ if (handshake->xxdh_psa_privkey_is_external == 0) {
+ status = psa_destroy_key(handshake->xxdh_psa_privkey);
if (status != PSA_SUCCESS) {
ret = PSA_TO_MBEDTLS_ERR(status);
@@ -3757,7 +3757,7 @@
return ret;
}
}
- handshake->dh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
+ handshake->xxdh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
#else
if ((ret = mbedtls_ecdh_read_public(&ssl->handshake->ecdh_ctx,
p, end - p)) != 0) {
@@ -3890,35 +3890,35 @@
if ((ret = ssl_parse_client_psk_identity(ssl, &p, end)) != 0) {
MBEDTLS_SSL_DEBUG_RET(1, ("ssl_parse_client_psk_identity"), ret);
- psa_destroy_key(handshake->dh_psa_privkey);
- handshake->dh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
+ psa_destroy_key(handshake->xxdh_psa_privkey);
+ handshake->xxdh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
return ret;
}
/* Keep a copy of the peer's public key */
if (p >= end) {
- psa_destroy_key(handshake->dh_psa_privkey);
- handshake->dh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
+ psa_destroy_key(handshake->xxdh_psa_privkey);
+ handshake->xxdh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
return MBEDTLS_ERR_SSL_DECODE_ERROR;
}
ecpoint_len = *(p++);
if ((size_t) (end - p) < ecpoint_len) {
- psa_destroy_key(handshake->dh_psa_privkey);
- handshake->dh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
+ psa_destroy_key(handshake->xxdh_psa_privkey);
+ handshake->xxdh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
return MBEDTLS_ERR_SSL_DECODE_ERROR;
}
#if !defined(PSA_WANT_ALG_FFDH)
- if (ecpoint_len > sizeof(handshake->dh_psa_peerkey)) {
- psa_destroy_key(handshake->dh_psa_privkey);
- handshake->dh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
+ if (ecpoint_len > sizeof(handshake->xxdh_psa_peerkey)) {
+ psa_destroy_key(handshake->xxdh_psa_privkey);
+ handshake->xxdh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
return MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE;
}
#endif
- memcpy(handshake->dh_psa_peerkey, p, ecpoint_len);
- handshake->dh_psa_peerkey_len = ecpoint_len;
+ memcpy(handshake->xxdh_psa_peerkey, p, ecpoint_len);
+ handshake->xxdh_psa_peerkey_len = ecpoint_len;
p += ecpoint_len;
/* As RFC 5489 section 2, the premaster secret is formed as follows:
@@ -3936,15 +3936,15 @@
/* Compute ECDH shared secret. */
status = psa_raw_key_agreement(PSA_ALG_ECDH,
- handshake->dh_psa_privkey,
- handshake->dh_psa_peerkey,
- handshake->dh_psa_peerkey_len,
+ handshake->xxdh_psa_privkey,
+ handshake->xxdh_psa_peerkey,
+ handshake->xxdh_psa_peerkey_len,
psm + zlen_size,
psm_end - (psm + zlen_size),
&zlen);
- destruction_status = psa_destroy_key(handshake->dh_psa_privkey);
- handshake->dh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
+ destruction_status = psa_destroy_key(handshake->xxdh_psa_privkey);
+ handshake->xxdh_psa_privkey = MBEDTLS_SVC_KEY_ID_INIT;
if (status != PSA_SUCCESS) {
return PSA_TO_MBEDTLS_ERR(status);