@@ -1875,7 +1875,7 @@ void pk_psa_sign(int psa_type, int bits, int rsa_padding)
1875
1875
#endif /* MBEDTLS_PK_CAN_ECDSA_SIGN */
1876
1876
1877
1877
/* Export public key from the non-opaque PK context we just created. */
1878
- #if defined(MBEDTLS_PK_WRITE_C)
1878
+ #if defined(MBEDTLS_PK_PARSE_C) && defined( MBEDTLS_PK_WRITE_C)
1879
1879
ret = mbedtls_pk_write_pubkey_der(&pk, legacy_pub_key, sizeof(legacy_pub_key));
1880
1880
TEST_ASSERT(ret >= 0);
1881
1881
legacy_pub_key_len = (size_t) ret;
@@ -1884,7 +1884,7 @@ void pk_psa_sign(int psa_type, int bits, int rsa_padding)
1884
1884
memmove(legacy_pub_key,
1885
1885
legacy_pub_key + sizeof(legacy_pub_key) - legacy_pub_key_len,
1886
1886
legacy_pub_key_len);
1887
- #else /* MBEDTLS_PK_WRITE_C */
1887
+ #else /* MBEDTLS_PK_PARSE_C && MBEDTLS_PK_WRITE_C */
1888
1888
#if defined(MBEDTLS_PK_CAN_ECDSA_SIGN)
1889
1889
if (PSA_KEY_TYPE_IS_ECC_KEY_PAIR(psa_type)) {
1890
1890
TEST_EQUAL(mbedtls_ecp_point_write_binary(&(mbedtls_pk_ec_ro(pk)->grp),
@@ -1905,7 +1905,7 @@ void pk_psa_sign(int psa_type, int bits, int rsa_padding)
1905
1905
memmove(legacy_pub_key, end, legacy_pub_key_len);
1906
1906
}
1907
1907
#endif /* MBEDTLS_RSA_C */
1908
- #endif /* MBEDTLS_PK_WRITE_C */
1908
+ #endif /* MBEDTLS_PK_PARSE_C && MBEDTLS_PK_WRITE_C */
1909
1909
1910
1910
/* Turn the PK context into an opaque one. */
1911
1911
TEST_EQUAL(mbedtls_pk_get_psa_attributes(&pk, PSA_KEY_USAGE_SIGN_HASH, &attributes), 0);
@@ -1932,18 +1932,18 @@ void pk_psa_sign(int psa_type, int bits, int rsa_padding)
1932
1932
}
1933
1933
1934
1934
/* Export public key from the opaque PK context. */
1935
- #if defined(MBEDTLS_PK_WRITE_C)
1935
+ #if defined(MBEDTLS_PK_PARSE_C) && defined( MBEDTLS_PK_WRITE_C)
1936
1936
ret = mbedtls_pk_write_pubkey_der(&pk, opaque_pub_key, sizeof(opaque_pub_key));
1937
1937
TEST_ASSERT(ret >= 0);
1938
1938
opaque_pub_key_len = (size_t) ret;
1939
1939
/* mbedtls_pk_write_pubkey_der() writes backwards in the data buffer. */
1940
1940
memmove(opaque_pub_key,
1941
1941
opaque_pub_key + sizeof(opaque_pub_key) - opaque_pub_key_len,
1942
1942
opaque_pub_key_len);
1943
- #else /* MBEDTLS_PK_WRITE_C */
1943
+ #else /* MBEDTLS_PK_PARSE_C && MBEDTLS_PK_WRITE_C */
1944
1944
TEST_EQUAL(psa_export_public_key(key_id, opaque_pub_key, sizeof(opaque_pub_key),
1945
1945
&opaque_pub_key_len), PSA_SUCCESS);
1946
- #endif /* MBEDTLS_PK_WRITE_C */
1946
+ #endif /* MBEDTLS_PK_PARSE_C && MBEDTLS_PK_WRITE_C */
1947
1947
1948
1948
/* Check that the public keys of opaque and non-opaque PK contexts match. */
1949
1949
TEST_EQUAL(opaque_pub_key_len, legacy_pub_key_len);
@@ -1955,9 +1955,9 @@ void pk_psa_sign(int psa_type, int bits, int rsa_padding)
1955
1955
1956
1956
/* Create a new non-opaque PK context to verify the signature. */
1957
1957
mbedtls_pk_init(&pk);
1958
- #if defined(MBEDTLS_PK_PARSE_C)
1958
+ #if defined(MBEDTLS_PK_PARSE_C) && defined(MBEDTLS_PK_WRITE_C)
1959
1959
TEST_EQUAL(mbedtls_pk_parse_public_key(&pk, legacy_pub_key, legacy_pub_key_len), 0);
1960
- #else /* MBEDTLS_PK_PARSE_C */
1960
+ #else /* MBEDTLS_PK_PARSE_C && MBEDTLS_PK_WRITE_C */
1961
1961
#if defined(MBEDTLS_PK_CAN_ECDSA_SIGN)
1962
1962
if (PSA_KEY_TYPE_IS_ECC_KEY_PAIR(psa_type)) {
1963
1963
TEST_EQUAL(mbedtls_pk_setup(&pk, mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY)), 0);
@@ -1974,7 +1974,7 @@ void pk_psa_sign(int psa_type, int bits, int rsa_padding)
1974
1974
legacy_pub_key_len), 0);
1975
1975
}
1976
1976
#endif /* MBEDTLS_RSA_C */
1977
- #endif /* MBEDTLS_PK_PARSE_C */
1977
+ #endif /* MBEDTLS_PK_PARSE_C && MBEDTLS_PK_WRITE_C */
1978
1978
1979
1979
#if defined(MBEDTLS_RSA_C)
1980
1980
if (PSA_KEY_TYPE_IS_RSA(psa_type)) {
0 commit comments