Repository navigation
Add Mbed TLS 3.6 pk_parse_key and a complete x509_crt_profile - #92
padelsbach wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the Mbed TLS compatibility updates.
No open issues 🎉
What changed in this PR
Improves the Mbed TLS compatibility layer by adding 3.6-compatible key-parsing signatures and exposing the certificate-profile structure.
Changes:
- Adds inline wrappers accepting 3.6’s RNG arguments without using them.
- Publishes certificate-profile fields while preserving existing behavior: profiles are not applied.
- Adds regression tests and updates compatibility documentation.
| File | Description |
|---|---|
wolfpsa/mbedtls/pk.h |
Adds 3.6 key-parsing wrappers and remapping macros. |
wolfpsa/mbedtls_compat/mbedtls/x509_crt.h |
Exposes the complete certificate-profile structure. |
test/mbedtls_compat/ssl_test.c |
Tests custom profile construction and unchanged handshake behavior. |
test/mbedtls_compat/mbedtls3_test.c |
Tests RNG-accepting parsing signatures, parsed keys, and errors. |
src/mbedtls/x509.c |
Removes the private placeholder profile definition. |
docs/mbedtls-compatibility.md |
Documents parsing wrappers, profile fields, and limitations. |
Review effort: Balanced
1df4a91 to
aa3c6c5
Compare
| (void)p_rng; | ||
| return mbedtls_pk_parse_key(ctx, key, keylen, pwd, pwdlen); | ||
| } | ||
| #define mbedtls_pk_parse_key wolfPSA_MbedPkParseKey |
There was a problem hiding this comment.
Since #84 landed, mbedtls3_test.c calls mbedtls_pk_parse_key with 5 args and mbedtls_pk_parse_keyfile with 3 (around lines 1079, 1082 and 1160), and these macros make them fail to compile after the merge. Please rebase and pass TestRng, NULL there.
| #define MBEDTLS_X509_ID_FLAG(id) (UINT32_C(1) << ((id) - 1)) | ||
|
|
||
| /* Not used: wolfSSL applies its own key and hash limits. Presets are 0. */ | ||
| typedef struct mbedtls_x509_crt_profile { |
There was a problem hiding this comment.
With the struct public, an application's stricter profile now compiles but mbedtls_ssl_conf_cert_profile still ignores it, where before the opaque type failed the build. Either keep it opaque or apply at least rsa_min_bitlen through wolfSSL's minimum key sizes.
| char unused; | ||
| }; | ||
|
|
||
| const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default = { 0 }; |
There was a problem hiding this comment.
Now that applications can read _default, _next and _suiteb, their all-zero fields say nothing is allowed and there is no RSA minimum. Please initialize them with Mbed TLS 3.6's values, or say in the header that the fields are not Mbed TLS's limits.
| mbedtls_pk_init(&byBuf); | ||
| mbedtls_pk_init(&byFile); | ||
| len = ReadPem(keys[i].file, pem, sizeof(pem)); | ||
| ok = mbedtls_pk_parse_key(&byBuf, pem, len, NULL, 0, TestRng, |
There was a problem hiding this comment.
The docs say these wrappers never call f_rng, but TestRng always succeeds, so this would still pass if they did. An RNG that counts its calls and returns an error would check it.
Applications that use the 3.x API to parse keys do not build due to extra params in 3.6's
mbedtls_pk_parse_keyandmbedtls_pk_parse_keyfile. Add a remap macro (similar to the method done in #87) to provide the 3.x definition. Also, publishmbedtls_x509_crt_profilein the public header file since it is used by applications.