Repository navigation
Add EVP/KDF API - #6674
Add EVP/KDF API#6674davidmakepeace wants to merge 1 commit into
Conversation
a4b5940 to
1615c66
Compare
868ad00 to
2a1efeb
Compare
|
We've got a single step KDF (SP 800-56) implemented and passing test vectors but it will need some cleanup to fit into this framework. The intention is to submit this it after this PR has been accepted or at least after the final form of these changes are determined. |
|
Thought from today: this interface should deal with NULL result buffers better. Some of the algorithms use this to request the size of the result. The rest are variably sized and don't support this functionality. Uniformity would be better here. My suggestion is that a new API is introduced that requests the size of the result (which matches digests) and that this returns 0 or -1 for variable size outcomes (I favour zero). Then, the NULL checking can be removed from the new APIs and handed off to the legacy wrappers. Thoughts? |
|
Do we really need the uint64 in the scrypt interface? |
|
The scrypt page on tarsnap seems to indicate that at least |
|
Sure it can technically go that high - but pragmatically would anyone ever exceed 2^32 - that I seriously doubt is realistic in any context |
|
@paulidale, it would be great if you could rebase and fix the conflicts. |
|
I'll ask @davidmakepeace to update tomorrow. |
|
Oh oops, I mixed you guys up... sorry :-/ |
|
I'm fatter and uglier. I figured it would have been hard to mix us up :) |
|
@davidmakepeace any chance you will rebase this PR soonish, it's been indicated as a base to be used to implement SSHKDF and it'd be nice to start on a fresh rebase that does not conflict with master |
cd71808 to
bfa7eaa
Compare
1cbe3c6 to
bafba46
Compare
|
This was great work, @davidmakepeace |
Changed PKEY/KDF API to call the new API. Added wrappers for PKCS5_PBKDF2_HMAC() and EVP_PBE_scrypt() to call the new EVP KDF APIs. Documentation updated. Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Richard Levitte <[email protected]> (Merged from #6674)
|
219 days in coming. A great effort and a very worthwhile contribution. Thanks to all who assisted and contributed. The various follow on KDFs can now be tapped onto this work. @slontis has single step KDF, @romen has one too I believe. No doubt there are others. Let the floodgates open to the pressure of the 617th. |
|
This search shows all the KDF related PRs. I'll have a quick run through, as I'm sure some can just be closed by now |
|
I must be missing something, but I don't see a way to run PBKDF2 using command line tools (see #4021), just the TLS KDF, HKDF and scrypt... |
It seems that PBKDF2 does not appear in crypto/evp/pkey_kdf.c like the others do. @davidmakepeace is this an accidental omission or was there a reason for that? |
|
I suppose only KDF algorithms that were previously implemented in the PKEY interface were ported via wrapping the KDF API. Anything newly implemented (PBKDF2, SSHKDF, ...) does not have this wrapping as the PKEY interface should be seen as legacy for kdfs? |
Yes, perhaps that is the reason. That has the unfortunate side-effect that they're not available to pkeyutl. That might suggest that pkeyutl should be ported to use the new API - which is itself problematic since the whole structure of pkeyutl is focused around handling EVP_PKEY objects (hence the name of the application). Or alternatively we decide to retrofit the PKEY interface for these "new" KDFs. |
|
Didn't someone submit a PR to create a `openssl kdf' command? I think I remember seeing that, but can't find it right now |
|
Yes, the PBKDF2 algorithm was not previously supported by the PKEY interface, which is now considered legacy with respect to KDF algorithms. We could change the pkeyutl app to use the KDF API for KDFs. Alternatively a new kdf app could be added specifically for KDFs. |
|
A KDF app seems like a good option to me. |
|
I had added a mac app, but not a kdf one. |
|
there are two purposes, primary is to verify if a different implementation implements the KDF correctly[1], and secondary is for tools like https://testssl.sh/ so yes, diagnostics/debugging 1 - including a situation where the KDF is implemented in an engine or pkcs11 module |
|
Added KDF app PR: #8762 |
|
Added EVP_KDF PR: #8808 |
…d wrappers for PKCS5_PBKDF2_HMAC() and EVP_PBE_scrypt() to call the new EVP KDF APIs. Documentation updated. Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl/openssl#6674) (cherry picked from commit 5a285addbf39f91d567f95f04b2b41764127950d) [Yilin: rebase babassl master] Signed-off-by: YiLin.Li <[email protected]>
…d wrappers for PKCS5_PBKDF2_HMAC() and EVP_PBE_scrypt() to call the new EVP KDF APIs. Documentation updated. Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl/openssl#6674) (cherry picked from commit 5a285addbf39f91d567f95f04b2b41764127950d) [Yilin: rebase babassl master] Signed-off-by: YiLin.Li <[email protected]>
…d wrappers for PKCS5_PBKDF2_HMAC() and EVP_PBE_scrypt() to call the new EVP KDF APIs. Documentation updated. Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl/openssl#6674) (cherry picked from commit 5a285addbf39f91d567f95f04b2b41764127950d) [Yilin: rebase babassl master] Signed-off-by: YiLin.Li <[email protected]>
…d wrappers for PKCS5_PBKDF2_HMAC() and EVP_PBE_scrypt() to call the new EVP KDF APIs. Documentation updated. Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl/openssl#6674) (cherry picked from commit 5a285addbf39f91d567f95f04b2b41764127950d) [Yilin: rebase babassl master] Signed-off-by: YiLin.Li <[email protected]>
…d wrappers for PKCS5_PBKDF2_HMAC() and EVP_PBE_scrypt() to call the new EVP KDF APIs. Documentation updated. Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl/openssl#6674) (cherry picked from commit 5a285addbf39f91d567f95f04b2b41764127950d) [Yilin: rebase babassl master] Signed-off-by: YiLin.Li <[email protected]>
…d wrappers for PKCS5_PBKDF2_HMAC() and EVP_PBE_scrypt() to call the new EVP KDF APIs. Documentation updated. Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl/openssl#6674) (cherry picked from commit 5a285addbf39f91d567f95f04b2b41764127950d) [Yilin: rebase babassl master] Signed-off-by: YiLin.Li <[email protected]>
…d wrappers for PKCS5_PBKDF2_HMAC() and EVP_PBE_scrypt() to call the new EVP KDF APIs. Documentation updated. Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl/openssl#6674) (cherry picked from commit 5a285addbf39f91d567f95f04b2b41764127950d) [Yilin: rebase babassl master] Signed-off-by: YiLin.Li <[email protected]>
…d wrappers for PKCS5_PBKDF2_HMAC() and EVP_PBE_scrypt() to call the new EVP KDF APIs. Documentation updated. Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl/openssl#6674) (cherry picked from commit 5a285addbf39f91d567f95f04b2b41764127950d) [Yilin: rebase babassl master] Signed-off-by: YiLin.Li <[email protected]>
…d wrappers for PKCS5_PBKDF2_HMAC() and EVP_PBE_scrypt() to call the new EVP KDF APIs. Documentation updated. Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl/openssl#6674) (cherry picked from commit 5a285addbf39f91d567f95f04b2b41764127950d) [Yilin: rebase babassl master] Signed-off-by: YiLin.Li <[email protected]>
…d wrappers for PKCS5_PBKDF2_HMAC() and EVP_PBE_scrypt() to call the new EVP KDF APIs. Documentation updated. Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl/openssl#6674) (cherry picked from commit 5a285addbf39f91d567f95f04b2b41764127950d) [Yilin: rebase babassl master] Signed-off-by: YiLin.Li <[email protected]>
…d wrappers for PKCS5_PBKDF2_HMAC() and EVP_PBE_scrypt() to call the new EVP KDF APIs. Documentation updated. Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Richard Levitte <[email protected]> (Merged from openssl/openssl#6674) (cherry picked from commit 5a285addbf39f91d567f95f04b2b41764127950d) [Yilin: rebase babassl master] Signed-off-by: YiLin.Li <[email protected]>
This PR adds a new EVP/KDF API that collects all KDFs and PRFs under the one API.
#include <openssl/kdf.h>Currently some KDFs are available directly (PBKDF2 and scrypt) while others are available through the PKEY API (scrypt, TLS1 PRF and HKDF) even though the PKEY API was originally intended for Public Key algorithms. Note that the low level KDF functions (PKCS5_PBKDF2_HMAC and EVP_PBE_scrypt) are defined in openssl/evp.h even though EVP is the high level interface.
The new API is modeled after the current KDF support under the PKEY API in order to minimize the work required to update applications to use the new API. Support is included for PBKDF2, scrypt, TLS1 PRF and HKDF. PBKDF1 and PKCS12 KDF are not implemented.
The low level KDF functions and PKEY KDF support have been changed to wrap the new API. Other parts of OpenSSL have not yet been updated to call the new API.
Documentation to follow.