Skip to content

Commit 00d579e

Browse files
authored
Merge pull request #10439 from bjwtaylor/remove-all-non-ext-apis
Remove all non ext apis
2 parents 18f2661 + 42074c1 commit 00d579e

File tree

12 files changed

+102
-107
lines changed

12 files changed

+102
-107
lines changed

library/pkcs7.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,9 +704,9 @@ static int mbedtls_pkcs7_data_or_hash_verify(mbedtls_pkcs7 *pkcs7,
704704
* failed to validate'.
705705
*/
706706
for (signer = &pkcs7->signed_data.signers; signer; signer = signer->next) {
707-
ret = mbedtls_pk_verify(&pk_cxt, md_alg, hash,
708-
mbedtls_md_get_size(md_info),
709-
signer->sig.p, signer->sig.len);
707+
ret = mbedtls_pk_verify_ext(cert->sig_pk, &pk_cxt, md_alg, hash,
708+
mbedtls_md_get_size(md_info),
709+
signer->sig.p, signer->sig.len);
710710

711711
if (ret == 0) {
712712
break;

library/ssl_ciphersuites.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -902,17 +902,17 @@ size_t mbedtls_ssl_ciphersuite_get_cipher_key_bitlen(const mbedtls_ssl_ciphersui
902902
}
903903

904904
#if defined(MBEDTLS_PK_C)
905-
mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg(const mbedtls_ssl_ciphersuite_t *info)
905+
mbedtls_pk_sigalg_t mbedtls_ssl_get_ciphersuite_sig_pk_alg(const mbedtls_ssl_ciphersuite_t *info)
906906
{
907907
switch (info->key_exchange) {
908908
case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
909-
return MBEDTLS_PK_RSA;
909+
return MBEDTLS_PK_SIGALG_RSA_PKCS1V15;
910910

911911
case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
912-
return MBEDTLS_PK_ECDSA;
912+
return MBEDTLS_PK_SIGALG_ECDSA;
913913

914914
default:
915-
return MBEDTLS_PK_NONE;
915+
return MBEDTLS_PK_SIGALG_NONE;
916916
}
917917
}
918918

@@ -943,17 +943,17 @@ psa_key_usage_t mbedtls_ssl_get_ciphersuite_sig_pk_psa_usage(const mbedtls_ssl_c
943943
}
944944
}
945945

946-
mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_alg(const mbedtls_ssl_ciphersuite_t *info)
946+
mbedtls_pk_sigalg_t mbedtls_ssl_get_ciphersuite_sig_alg(const mbedtls_ssl_ciphersuite_t *info)
947947
{
948948
switch (info->key_exchange) {
949949
case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
950-
return MBEDTLS_PK_RSA;
950+
return MBEDTLS_PK_SIGALG_RSA_PKCS1V15;
951951

952952
case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
953-
return MBEDTLS_PK_ECDSA;
953+
return MBEDTLS_PK_SIGALG_ECDSA;
954954

955955
default:
956-
return MBEDTLS_PK_NONE;
956+
return MBEDTLS_PK_SIGALG_NONE;
957957
}
958958
}
959959

library/ssl_ciphersuites_internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
#endif /* MBEDTLS_PK_HAVE_PRIVATE_HEADER */
1717

1818
#if defined(MBEDTLS_PK_C)
19-
mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg(const mbedtls_ssl_ciphersuite_t *info);
19+
mbedtls_pk_sigalg_t mbedtls_ssl_get_ciphersuite_sig_pk_alg(const mbedtls_ssl_ciphersuite_t *info);
2020
psa_algorithm_t mbedtls_ssl_get_ciphersuite_sig_pk_psa_alg(const mbedtls_ssl_ciphersuite_t *info);
2121
psa_key_usage_t mbedtls_ssl_get_ciphersuite_sig_pk_psa_usage(const mbedtls_ssl_ciphersuite_t *info);
22-
mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_alg(const mbedtls_ssl_ciphersuite_t *info);
22+
mbedtls_pk_sigalg_t mbedtls_ssl_get_ciphersuite_sig_alg(const mbedtls_ssl_ciphersuite_t *info);
2323
#endif /* MBEDTLS_PK_C */
2424

2525
int mbedtls_ssl_ciphersuite_uses_ec(const mbedtls_ssl_ciphersuite_t *info);

library/ssl_client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,8 +943,8 @@ int mbedtls_ssl_write_client_hello(mbedtls_ssl_context *ssl)
943943
*/
944944
mbedtls_ssl_handshake_set_state(ssl, MBEDTLS_SSL_SERVER_HELLO);
945945

946-
if ((ret = mbedtls_ssl_write_handshake_msg(ssl)) != 0) {
947-
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg", ret);
946+
if ((ret = mbedtls_ssl_write_handshake_msg_ext(ssl, 1, 1)) != 0) {
947+
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg_ext", ret);
948948
return ret;
949949
}
950950

library/ssl_misc.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,11 +1436,6 @@ MBEDTLS_CHECK_RETURN_CRITICAL
14361436
int mbedtls_ssl_write_handshake_msg_ext(mbedtls_ssl_context *ssl,
14371437
int update_checksum,
14381438
int force_flush);
1439-
static inline int mbedtls_ssl_write_handshake_msg(mbedtls_ssl_context *ssl)
1440-
{
1441-
return mbedtls_ssl_write_handshake_msg_ext(ssl, 1 /* update checksum */, 1 /* force flush */);
1442-
}
1443-
14441439
/*
14451440
* Write handshake message tail
14461441
*/
@@ -1515,8 +1510,8 @@ static inline mbedtls_svc_key_id_t mbedtls_ssl_get_opaque_psk(
15151510

15161511
#if defined(MBEDTLS_PK_C)
15171512
unsigned char mbedtls_ssl_sig_from_pk(mbedtls_pk_context *pk);
1518-
unsigned char mbedtls_ssl_sig_from_pk_alg(mbedtls_pk_type_t type);
1519-
mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig(unsigned char sig);
1513+
unsigned char mbedtls_ssl_sig_from_pk_alg(mbedtls_pk_sigalg_t type);
1514+
mbedtls_pk_sigalg_t mbedtls_ssl_pk_sig_alg_from_sig(unsigned char sig);
15201515
#endif
15211516

15221517
mbedtls_md_type_t mbedtls_ssl_md_alg_from_hash(unsigned char hash);
@@ -2414,13 +2409,13 @@ static inline int mbedtls_ssl_sig_alg_is_offered(const mbedtls_ssl_context *ssl,
24142409
return 0;
24152410
}
24162411

2417-
static inline int mbedtls_ssl_get_pk_type_and_md_alg_from_sig_alg(
2418-
uint16_t sig_alg, mbedtls_pk_type_t *pk_type, mbedtls_md_type_t *md_alg)
2412+
static inline int mbedtls_ssl_get_pk_sigalg_and_md_alg_from_sig_alg(
2413+
uint16_t sig_alg, mbedtls_pk_sigalg_t *pk_type, mbedtls_md_type_t *md_alg)
24192414
{
2420-
*pk_type = mbedtls_ssl_pk_alg_from_sig(sig_alg & 0xff);
2415+
*pk_type = mbedtls_ssl_pk_sig_alg_from_sig(sig_alg & 0xff);
24212416
*md_alg = mbedtls_ssl_md_alg_from_hash((sig_alg >> 8) & 0xff);
24222417

2423-
if (*pk_type != MBEDTLS_PK_NONE && *md_alg != MBEDTLS_MD_NONE) {
2418+
if (*pk_type != MBEDTLS_PK_SIGALG_NONE && *md_alg != MBEDTLS_MD_NONE) {
24242419
return 0;
24252420
}
24262421

@@ -2429,19 +2424,19 @@ static inline int mbedtls_ssl_get_pk_type_and_md_alg_from_sig_alg(
24292424
#if defined(PSA_WANT_ALG_SHA_256)
24302425
case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA256:
24312426
*md_alg = MBEDTLS_MD_SHA256;
2432-
*pk_type = MBEDTLS_PK_RSASSA_PSS;
2427+
*pk_type = MBEDTLS_PK_SIGALG_RSA_PSS;
24332428
break;
24342429
#endif /* PSA_WANT_ALG_SHA_256 */
24352430
#if defined(PSA_WANT_ALG_SHA_384)
24362431
case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA384:
24372432
*md_alg = MBEDTLS_MD_SHA384;
2438-
*pk_type = MBEDTLS_PK_RSASSA_PSS;
2433+
*pk_type = MBEDTLS_PK_SIGALG_RSA_PSS;
24392434
break;
24402435
#endif /* PSA_WANT_ALG_SHA_384 */
24412436
#if defined(PSA_WANT_ALG_SHA_512)
24422437
case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA512:
24432438
*md_alg = MBEDTLS_MD_SHA512;
2444-
*pk_type = MBEDTLS_PK_RSASSA_PSS;
2439+
*pk_type = MBEDTLS_PK_SIGALG_RSA_PSS;
24452440
break;
24462441
#endif /* PSA_WANT_ALG_SHA_512 */
24472442
#endif /* PSA_WANT_ALG_RSA_PSS */

library/ssl_msg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5028,8 +5028,8 @@ int mbedtls_ssl_write_change_cipher_spec(mbedtls_ssl_context *ssl)
50285028

50295029
mbedtls_ssl_handshake_increment_state(ssl);
50305030

5031-
if ((ret = mbedtls_ssl_write_handshake_msg(ssl)) != 0) {
5032-
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg", ret);
5031+
if ((ret = mbedtls_ssl_write_handshake_msg_ext(ssl, 1, 1)) != 0) {
5032+
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg_ext", ret);
50335033
return ret;
50345034
}
50355035

library/ssl_tls.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4247,8 +4247,8 @@ static int ssl_write_hello_request(mbedtls_ssl_context *ssl)
42474247
ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE;
42484248
ssl->out_msg[0] = MBEDTLS_SSL_HS_HELLO_REQUEST;
42494249

4250-
if ((ret = mbedtls_ssl_write_handshake_msg(ssl)) != 0) {
4251-
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg", ret);
4250+
if ((ret = mbedtls_ssl_write_handshake_msg_ext(ssl, 1, 1)) != 0) {
4251+
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg_ext", ret);
42524252
return ret;
42534253
}
42544254

@@ -5619,32 +5619,31 @@ unsigned char mbedtls_ssl_sig_from_pk(mbedtls_pk_context *pk)
56195619
return MBEDTLS_SSL_SIG_ANON;
56205620
}
56215621

5622-
unsigned char mbedtls_ssl_sig_from_pk_alg(mbedtls_pk_type_t type)
5622+
unsigned char mbedtls_ssl_sig_from_pk_alg(mbedtls_pk_sigalg_t type)
56235623
{
56245624
switch (type) {
5625-
case MBEDTLS_PK_RSA:
5625+
case MBEDTLS_PK_SIGALG_RSA_PKCS1V15:
56265626
return MBEDTLS_SSL_SIG_RSA;
5627-
case MBEDTLS_PK_ECDSA:
5628-
case MBEDTLS_PK_ECKEY:
5627+
case MBEDTLS_PK_SIGALG_ECDSA:
56295628
return MBEDTLS_SSL_SIG_ECDSA;
56305629
default:
56315630
return MBEDTLS_SSL_SIG_ANON;
56325631
}
56335632
}
56345633

5635-
mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig(unsigned char sig)
5634+
mbedtls_pk_sigalg_t mbedtls_ssl_pk_sig_alg_from_sig(unsigned char sig)
56365635
{
56375636
switch (sig) {
56385637
#if defined(MBEDTLS_RSA_C)
56395638
case MBEDTLS_SSL_SIG_RSA:
5640-
return MBEDTLS_PK_RSA;
5639+
return MBEDTLS_PK_SIGALG_RSA_PKCS1V15;
56415640
#endif
56425641
#if defined(MBEDTLS_KEY_EXCHANGE_ECDSA_CERT_REQ_ANY_ALLOWED_ENABLED)
56435642
case MBEDTLS_SSL_SIG_ECDSA:
5644-
return MBEDTLS_PK_ECDSA;
5643+
return MBEDTLS_PK_SIGALG_ECDSA;
56455644
#endif
56465645
default:
5647-
return MBEDTLS_PK_NONE;
5646+
return MBEDTLS_PK_SIGALG_NONE;
56485647
}
56495648
}
56505649
#endif /* MBEDTLS_PK_C &&
@@ -6726,8 +6725,8 @@ int mbedtls_ssl_write_certificate(mbedtls_ssl_context *ssl)
67266725

67276726
mbedtls_ssl_handshake_increment_state(ssl);
67286727

6729-
if ((ret = mbedtls_ssl_write_handshake_msg(ssl)) != 0) {
6730-
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg", ret);
6728+
if ((ret = mbedtls_ssl_write_handshake_msg_ext(ssl, 1, 1)) != 0) {
6729+
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg_ext", ret);
67316730
return ret;
67326731
}
67336732

@@ -7456,8 +7455,8 @@ int mbedtls_ssl_write_finished(mbedtls_ssl_context *ssl)
74567455
}
74577456
#endif
74587457

7459-
if ((ret = mbedtls_ssl_write_handshake_msg(ssl)) != 0) {
7460-
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg", ret);
7458+
if ((ret = mbedtls_ssl_write_handshake_msg_ext(ssl, 1, 1)) != 0) {
7459+
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg_ext", ret);
74617460
return ret;
74627461
}
74637462

library/ssl_tls12_client.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,7 @@ static int ssl_parse_server_key_exchange(mbedtls_ssl_context *ssl)
18841884
unsigned char hash[MBEDTLS_MD_MAX_SIZE];
18851885

18861886
mbedtls_md_type_t md_alg = MBEDTLS_MD_NONE;
1887-
mbedtls_pk_type_t pk_alg = MBEDTLS_PK_NONE;
1887+
mbedtls_pk_sigalg_t pk_alg = MBEDTLS_PK_SIGALG_NONE;
18881888
unsigned char *params = ssl->in_msg + mbedtls_ssl_hs_hdr_len(ssl);
18891889
size_t params_len = (size_t) (p - params);
18901890
void *rs_ctx = NULL;
@@ -1908,7 +1908,7 @@ static int ssl_parse_server_key_exchange(mbedtls_ssl_context *ssl)
19081908
*/
19091909
MBEDTLS_SSL_CHK_BUF_READ_PTR(p, end, 2);
19101910
sig_alg = MBEDTLS_GET_UINT16_BE(p, 0);
1911-
if (mbedtls_ssl_get_pk_type_and_md_alg_from_sig_alg(
1911+
if (mbedtls_ssl_get_pk_sigalg_and_md_alg_from_sig_alg(
19121912
sig_alg, &pk_alg, &md_alg) != 0 &&
19131913
!mbedtls_ssl_sig_alg_is_offered(ssl, sig_alg) &&
19141914
!mbedtls_ssl_sig_alg_is_supported(ssl, sig_alg)) {
@@ -1922,7 +1922,7 @@ static int ssl_parse_server_key_exchange(mbedtls_ssl_context *ssl)
19221922
}
19231923
p += 2;
19241924

1925-
if (!mbedtls_pk_can_do(peer_pk, pk_alg)) {
1925+
if (!mbedtls_pk_can_do(peer_pk, (mbedtls_pk_type_t) pk_alg)) {
19261926
MBEDTLS_SSL_DEBUG_MSG(1,
19271927
("bad server key exchange message"));
19281928
mbedtls_ssl_send_alert_message(
@@ -1978,7 +1978,7 @@ static int ssl_parse_server_key_exchange(mbedtls_ssl_context *ssl)
19781978
/*
19791979
* Verify signature
19801980
*/
1981-
if (!mbedtls_pk_can_do(peer_pk, pk_alg)) {
1981+
if (!mbedtls_pk_can_do(peer_pk, (mbedtls_pk_type_t) pk_alg)) {
19821982
MBEDTLS_SSL_DEBUG_MSG(1, ("bad server key exchange message"));
19831983
mbedtls_ssl_send_alert_message(
19841984
ssl,
@@ -1994,7 +1994,7 @@ static int ssl_parse_server_key_exchange(mbedtls_ssl_context *ssl)
19941994
#endif
19951995

19961996
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
1997-
if (pk_alg == MBEDTLS_PK_RSASSA_PSS) {
1997+
if (pk_alg == MBEDTLS_PK_SIGALG_RSA_PSS) {
19981998
ret = mbedtls_pk_verify_ext((mbedtls_pk_sigalg_t) pk_alg, peer_pk,
19991999
md_alg, hash, hashlen,
20002000
p, sig_len);
@@ -2014,7 +2014,7 @@ static int ssl_parse_server_key_exchange(mbedtls_ssl_context *ssl)
20142014
MBEDTLS_SSL_ALERT_LEVEL_FATAL,
20152015
MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR);
20162016
}
2017-
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_pk_verify", ret);
2017+
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_pk_verify_restartable", ret);
20182018
#if defined(MBEDTLS_SSL_ECP_RESTARTABLE_ENABLED)
20192019
if (ret == MBEDTLS_ERR_ECP_IN_PROGRESS) {
20202020
ret = MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS;
@@ -2565,8 +2565,8 @@ static int ssl_write_client_key_exchange(mbedtls_ssl_context *ssl)
25652565

25662566
mbedtls_ssl_handshake_increment_state(ssl);
25672567

2568-
if ((ret = mbedtls_ssl_write_handshake_msg(ssl)) != 0) {
2569-
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg", ret);
2568+
if ((ret = mbedtls_ssl_write_handshake_msg_ext(ssl, 1, 1)) != 0) {
2569+
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg_ext", ret);
25702570
return ret;
25712571
}
25722572

@@ -2708,7 +2708,7 @@ static int ssl_write_certificate_verify(mbedtls_ssl_context *ssl)
27082708
out_buf_len - 6 - offset,
27092709
&n,
27102710
rs_ctx)) != 0) {
2711-
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_pk_sign", ret);
2711+
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_pk_sign_restartable", ret);
27122712
#if defined(MBEDTLS_SSL_ECP_RESTARTABLE_ENABLED)
27132713
if (ret == MBEDTLS_ERR_ECP_IN_PROGRESS) {
27142714
ret = MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS;
@@ -2725,8 +2725,8 @@ static int ssl_write_certificate_verify(mbedtls_ssl_context *ssl)
27252725

27262726
mbedtls_ssl_handshake_increment_state(ssl);
27272727

2728-
if ((ret = mbedtls_ssl_write_handshake_msg(ssl)) != 0) {
2729-
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg", ret);
2728+
if ((ret = mbedtls_ssl_write_handshake_msg_ext(ssl, 1, 1)) != 0) {
2729+
MBEDTLS_SSL_DEBUG_RET(1, "mbedtls_ssl_write_handshake_msg_ext", ret);
27302730
return ret;
27312731
}
27322732

0 commit comments

Comments
 (0)