Repository navigation
Offer PBE key streching via command line app - #1533
johndoe31415 wants to merge 7 commits into
Conversation
The key streching functions PBKDF2 and scrypt currently do not have any way of performing key derivation via the command line interface. This patch adds an app called "pbe" which offers this functionality.
The key streching functions PBKDF2 and scrypt currently do not have any way of performing key derivation via the command line interface. This patch adds an app called "pbe" which offers this functionality.
|
Looking good. We need three things: doc/apps/pbe.pod, a change to apps/progs.pl, and a CLA. :) |
Added a POD documentation for the PBE command line utility. Auto-generated apps/progs.h from the contained Perl script. Added bailing if a message digest was supplied when using scrypt.
|
Hi Rich, I added a POD documentation, curious to your feedback. I looked into apps/progs.pl and that's when I first saw that apps/progs.h is supposed to be autogenerated from apps/progs.pl -- I did that and it worked perfectly. So I'm not sure if apps/progs.pl really needs modification. I'm also unsure what you mean by CLA, if you give me some more pointers, I'll happy to work on this. Something which I would like to include are testcases for the command-line application. I'm unhappy with the fact there are none as of now. However, I don't seem able to find where the CLI is tested within the source tree. If you'd give me a pointer to where this should be implemented, I'd happily provide sensible testcases (using the test vectors from the RFCs and the scrypt and also cross-checking against other implementations). Cheers, |
Comparison between signed/unsigned int caused -Werror=sign-compare to break the build. Fixed.
Previously, the 128 MiB limit was hardcoded in the PBE command line app. Now the -memsize parameter allows to allocate more resources to OpenSSL during computation of the PBE.
Rename from "memsize" to the better fitting "maxalloc"
|
Some feedback from Steve: "Well crypto/kdf/hkdf.c is the kind of thing I mean. My thinking is we do something similar for scrypt/PBKDF2 settable via ctrls or strings." |
|
You mean for the CLI tool or the general KDF API? I agree that it's not really nice the way two very similar functions (PBKDF2 and scrypt in this case) are accessed in the API (i.e., very differently). But wouldn't that be completely orthogonal to the CLI interface issue? Or does Steve mean for the CLI interface he'd like to see a kindof string parsing API? Something like this: $ echo -n foo | openssl cli -kdf pbkdf2 itercnt=1000 i.e., having the function-specific parameters as a command line argument (or actually maybe as many, separated by spaces, not commata). If you give me a pointer on what would be a direction you guys feel worth moving forward, I'd work on it. Sent the ICLA in just now, BTW. |
Signed-off-by: Kurt Roeckx <[email protected]> Reviewed-by: Rich Salz <[email protected]> RT: openssl#4192, MR: openssl#1533 (cherry picked from commit d938e8d)
|
Would like to bump this, since I run every few months into the need to do PBKD and the original PR dates back almost 2 years now :-( I do want this functionality in OpenSSL and I'd happily work on it, but please tell me how you want it so it can make it into vanilla. |
|
Just to expand on my comment. PBE algorithms are a class of key derivation functions and we already have a command line interface for KDFs which is pkeyutl. There are examples of how to do this which wrap the TLS PRF and HKDF under crypto/kdf. You can use the TLS PRF with a command like this: I'm suggesting we have a similar wrapper for PBE algorithms so you'd have a kdf_scrypt.c and kdf_pbkdf2.c files in there and they're provide an EVP_PKEY interface to scrypt and PBKDF2 as KDFs. A PBE could be a special case that (for example) always understood the "password" argument. So if this was done then you'd automatically get access to the underlying algorithm with something like this: Or we could have a -pbe option instead of -kdf which behaves exactly like -kdf except it handles passwords in the usual way, prompting if necessary. |
|
I'm closing this PR, haven't had the time (and, to be entirely honest, motivation) to work on this anymore and am abandoning it. |
Squashed commits of the rejected PR archived here. For discussion on this, see openssl#318 and openssl#1533 Code in its current form does not work. Archival purposes only.
The key streching functions PBKDF2 and scrypt currently do not have any way of performing key derivation via the command line interface. This patch adds an app called "pbe" which offers this functionality.
It is a rebased version of PR #318, but I accidentally messed up the merge, so this starts fresh and removes all the commit noise.
Modifications from PR #318 are that OPT_PAIR is now used to parse the -kdf parameter and OPENSSL_NO_SCRYPT is honored.