Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[noup] zephyr: Update to support MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG #76

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

frkv
Copy link

@frkv frkv commented Jan 24, 2025

-This commit add support for MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
which adds support for PRNG (seeded by TRNG) without using
the legacy Mbed TLS APIs in ctr_drbg.c and entropy.c. When the
configuration MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is enabled there
is a new function available in the system that is used to override
this behavior. This function is called mbedtls_psa_external_get_random
but for compatibility with the f_rng/p_rng signature the
function mbedtls_psa_get_random (found in mbedtls/psa_util.h) is
used directly in code.
-Added a function pointer called hostap_rng_fn which is set
to mbedtls_psa_get_random if MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is
enabled, otherwise it is set to the legacy API mbedtls_ctr_drbg_random.
-Added a context pointer called hostap_rng_ctx that is set to
MBEDTLS_PSA_RANDOM_STATE (NULL) if MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
is set, otherwise it points to the existing ctr_drbg context.
-Updated all calls using legacy APIs making use of the f_rng/p_rng
pattern to use hostap_rng_fn and hostap_rng_ctx in crypto_mbedtls_alt
-Added forward declaration of hostap_rng_fn and hostap_rng_ctx in
tls_mbedtls_alt.c and changed every API-call making use of the
f_rng/p_rng pattern.

-This commit add support for MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
 which adds support for PRNG (seeded by TRNG) without using
 the legacy Mbed TLS APIs in ctr_drbg.c and entropy.c. When the
 configuration MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is enabled there
 is a new function available in the system that is used to override
 this behavior. This function is called mbedtls_psa_external_get_random
 but for compatibility with the f_rng/p_rng signature the
 function mbedtls_psa_get_random (found in mbedtls/psa_util.h) is
 used directly in code.
-Added a function pointer called hostap_rng_fn which is set
 to mbedtls_psa_get_random if MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is
 enabled, otherwise it is set to the legacy API mbedtls_ctr_drbg_random.
-Added a context pointer called hostap_rng_ctx that is set to
 MBEDTLS_PSA_RANDOM_STATE (NULL) if MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
 is set, otherwise it points to the existing ctr_drbg context.
-Updated all calls using legacy APIs making use of the f_rng/p_rng
 pattern to use hostap_rng_fn and hostap_rng_ctx in crypto_mbedtls_alt
-Added forward declaration of hostap_rng_fn and hostap_rng_ctx in
 tls_mbedtls_alt.c and changed every API-call making use of the
 f_rng/p_rng pattern.

Signed-off-by: Frank Audun Kvamtrø <[email protected]>
@krish2718
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants