Repository navigation
mbedtls: call psa_crypto_init() in the AES-GCM and HMAC init paths - #826
Open
vikramdattu wants to merge 1 commit into
Open
vikramdattu wants to merge 1 commit into
vikramdattu wants to merge 1 commit into
Conversation
Only the AES-ICM backend initialized PSA. AES-GCM and HMAC relied on it having run first, which srtp_init() guarantees by self-testing AES-ICM before them. Using either type without srtp_init() made the key import fail: AES-GCM init returned srtp_err_status_init_fail and HMAC init srtp_err_status_auth_fail. Call psa_crypto_init() in both, as AES-ICM does. It is idempotent. 2_x_dev already does this (cisco#813). Add mbedtls_init_driver, which initializes both types without srtp_init() in its own process.
Contributor
Author
|
@pabuhler PTAL |
pabuhler
reviewed
Oct 19, 2026
pabuhler
left a comment
Member
There was a problem hiding this comment.
As you state this code is not really needed at present as there is no public API that needs these extra inits.
I think it is ok to add it but am not sure if the test is needed, it creates overhead for something that will get caught if any public API is ever added.
Also the test only really tests one of the invocations, would need to run it twice once for HMAC and once for GCM.
I would suggest removing it or else fixing it, if you fix then please include top of file comments similar to other files in the repo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the mbedTLS (PSA) backend, only
srtp_aes_icm_mbedtls_context_init()callspsa_crypto_init().srtp_aes_gcm_mbedtls_context_init()andsrtp_hmac_mbedtls_init()rely on it having run already.Through the public API that always holds:
srtp_init()self-tests AES-ICM before AES-GCM and HMAC, and that self-test initializes PSA. Using either type withoutsrtp_init()(for example from a test harness or a custom crypto kernel setup) fails, because the key import runs before PSA is initialized:srtp_err_status_init_fail.srtp_err_status_auth_fail.This calls
psa_crypto_init()in both, at the same point and with the same error handling as AES-ICM. It is idempotent, so thesrtp_init()path is unchanged. This bringsmainin line with2_x_dev, whose mbedTLS 4 / PSA path (#813) already calls it in all three backends.Test:
mbedtls_init_driver(mbedTLS builds only, CMake and meson) initializes both types withoutsrtp_init(). It is a separate executable because PSA initialization is process-wide: insidetest_srtp, an earlier test would already have initialized it.It fails without the fix and passes with it. Tested on mbedTLS 4.1.0: all 14 ctest tests pass with
ENABLE_WARNINGS_AS_ERRORS=ON, and all 14 meson tests pass.