-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Driver-only hashes: PKCS5 #6145
Comments
Ouch, I really missed something big while writing this task: Then change calling sites to use the new function instead of the old one (we're not allowed to use deprecated functions in the library, as we must compile successfully with In terms of implementation, I think that should work. Wdyt @AndrzejKurek ? |
Sure, no problem :) It's just a cosmetic change, I'll add it. |
There's one issue with this approach: we shouldn't use the deprecated functions in any configuration. |
Right, I was thinking about this yesterday but apparently didn't think hard enough :) I think the easiest way out of this is to have a static function So, something like: #if defined(MBEDTLS_MD_C)
static int pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx, ... ) {
/* current implementation of mbedtls_pkcs5_pbkdf2_hmac() */
}
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
int mbedtls_pkcs5_pbkdf2_hmac( ... ) { /* call the above */ }
#endif
#endif /* MD */
int mbedtls_pkcs5_pbkdf2_hmac_ext( mbedtls_md_type_t ... ) {
#if defined(MBEDTLS_MD_C)
/* handle ctx and call the static function */
#else
/* PSA implementation */
#endif
} Wdyt? |
Yep, that's exactly what I had in mind by mentioning a deprecated wrapper :) I'll update the PR with this solution. |
PKCS#5, aka RFC 8018, is a standard for password-based encryption. It defines PBKDF2-HMAC and uses it to derived encryption keys from passwords. It can optionally be used by
pkparse.c
in order to parse some types of encrypted keys. Currently our implementation (pkcs5.c
) uses MD to compute HMACs, so it doesn't work when hashes are provided only by drivers; this task is to make it work.mbedtls_pkcs5_pbkdf2_hmac()
so that it takes anmbedtls_md_type_t
rather than anmbedtls_md_context_t
as its first parameter. This frees callers from having to bother withmd_info
,md_init()
,md_setup()
,md_free()
and centralizes use of MD in one place. Adapt callers including theself_test
function. (Note: this is similar to what was done withmgf_mask()
in Driver hashes rsa v21 #6141.)mbedtls_pkcs5_pbkdf2_hmac()
based on PSA, to be used only whenMD_C
is not available (in order to preserve backwards compatibility: the PSA version requirespsa_crypto_init()
to have been called, we don't want to impose this requirement on existing code, but we can impose it in builds where this just didn't work at all before). (Again, this is similar tomgf_mask()
in Driver hashes rsa v21 #6141.)check_config.h
: PKCS5 now only requiresMD_C || PSA_CRYPTO_C
(plusCIPHER_C
as before).unset PKCS5_C
lines fromall.sh
componentscomponent_test_crypto_full_no_md()
andcomponent_test_psa_crypto_config_accel_hash_use_psa()
.test_suite_pkcs5.data
, replacingMBEDTLS_SHAxxx_C
withMBEDTLS_HAS_ALG_SHA_xxx_VIA_MD_OR_PSA
(fromlegacy_or_psa.h
which needs to be#include
d in the.function
file).test_suite_pkparse.data
for tests that depend onPKCS5_C
(again,legacy_or_psa.h
needs to be#include
d in the.function
file).test_suite_pkcs5
andtest_suite_pkparse
: seedocs/architecture/psa-migration/outcome-analysis.sh
(don't forget to removeunse PKCS5_C
inreference_config()
and editSUITES
in your copy).Depends on: #6141, for fixed definitions of
VIA_MD_OR_PSA
macros (could also just cherry-pick the commit "Fix definition of MD_OR_PSA macros" from that PR).The text was updated successfully, but these errors were encountered: