Skip to content

Implement PBKDF2 EVP_PKEY_METHOD - #4087

Closed
johndoe31415 wants to merge 10 commits into
openssl:masterfrom
johndoe31415:pkey_pbkdf2
Closed

johndoe31415 wants to merge 10 commits into
openssl:masterfrom
johndoe31415:pkey_pbkdf2

Conversation

@johndoe31415

@johndoe31415 johndoe31415 commented Aug 4, 2017 •

Copy link
Copy Markdown
Contributor

This adds a EVP_PKEY_METHOD for the PBKDF2. Test cases have been copied
from the PBE and all pass. Zero-length passwords and salts are
supported (although when using a string to set them, only pass/salt
work, but not hexpass/hexsalt with an empty string argument). Test case
in test/pkey_meth_kdf_test.c currently only commited in code, but unused
(will be later merged/squashed with the similar scrypt PR).

This has been cherry-picked from a commit off #4026 and split into two PRs, as a request from @snhenson.

Checklist
  • documentation is added or updated
  • tests are added or updated

@johndoe31415

Copy link
Copy Markdown
Contributor Author

I believe this PR is now ready for review. It's rebased to master. Some minor fixes are "SquashMe" commits that I'd squash (together with any other review commits) into the two main ones just before it's ready for merging.

@paulidale paulidale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All bar one suggestion are tiny nits.
The one that isn't is making this feature build time configurable.

Comment thread crypto/kdf/pbkdf2.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no blank line here

Comment thread crypto/evp/pmeth_lib.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably be optional -- i.e. configurable. Guarded by OPENSSL_NO_PBKDF2 most likely.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't currently an option that disables PBKDF2 support: it is always present.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to give it a shot and try to introduce "no-pbkdf2", if that's okay for you?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snhenson thanks for letting me know that.
Adding one seems reasonable -- more so since it is done :)

Comment thread doc/man7/pbkdf2.pod Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop the comma after the i.e.

Comment thread doc/man7/pbkdf2.pod Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/an/a/

@paulidale

Copy link
Copy Markdown
Contributor

A rebase is also required.

@johndoe31415

Copy link
Copy Markdown
Contributor Author

Hi @paulidale, thanks for your review! I have fixed your nits and am looking into adding a "no-pbkdf2" configuration now. Rebased & squashed everything else.

@johndoe31415

johndoe31415 commented Aug 9, 2017 •

Copy link
Copy Markdown
Contributor Author

Ah, interesting point: no-pbkdf2 implies no-scrypt as well, because scrypt internally uses PBKDF2 for derivation. I'm not sure how to specify that depencency in "Configure" and I have zero perl experience... any pointers on how to proceed?

Edit: Currently proceeding by replacing all "ifndef OPENSSL_NO_SCRYPT" by "if !defined(OPENSSL_NO_SCRYPT) && !defined(OPENSSL_NO_PBKDF2)" -- but am not sure if that's the solution we're looking for.

@johndoe31415

Copy link
Copy Markdown
Contributor Author

So, I have produced a patch that makes PBKDF2 disableable. However, there's serveral issues remaining. First, I receive a warning during build:

WARNING: mkdef.pl doesn't know the following algorithms:
	PBKDF2

I've looked at mkdef.pl and see that PBKDF2 is mentioned nowhere -- but since I have no clue what it does or what implications changing @known_algorithms has, I've not touched it.

Secondly, test fail now:

../test/recipes/01-test_symbol_presence.t
../test/recipes/30-test_evp.t

Apparently, the EVP test is not designed to skip non-built-in tests (likely we're going to have the same issue with scrypt, I fear).

@richsalz

richsalz commented Aug 9, 2017

Copy link
Copy Markdown
Contributor

You should probably put something like this into opensslconf.h.in

/* no-pbkdf2 imlpies no-scrypt */
# if defined(OPENSSL_NO_PBKDF2) && !defined (OPENSSL_NO_SCRYPT)
#  define OPENSSL_NO_SCRYPT
# endif

@johndoe31415

Copy link
Copy Markdown
Contributor Author

@richsalz, ah, yes of course! Great suggestion, just commited it. Squashed it as well so that the back-and-forth doesn't show up when viewing the single commit.

@johndoe31415

Copy link
Copy Markdown
Contributor Author

Just made another change to the code: Previously, I would have let the PKCS#12 GOST MAC fail with the same error code that it would have failed if PBKDF2 derivation failed. This is nonsense and horrible for the user. Therefore, the new error code PKCS12_R_MISSING_PBKDF2 is introduced in crypto/pkcs12/p12_mutl.c for this case.

@kaduk

kaduk commented Aug 9, 2017

Copy link
Copy Markdown
Contributor

No need to put the scrypt/pbkdf2 dependency in opensslconf.h.in -- Configure itself has logic for cascading dependencies. Look for @disable_cascades and add an entry that "pbkdf2" -> ["scrypt"]

@kaduk

kaduk commented Aug 9, 2017

Copy link
Copy Markdown
Contributor

Oh, and for mkdef.pl, known_algorithms is what you want -- it's just the list of things that can be enabled/disabled by configure and produce OPENSSL_NO_BLAH preprocessor symbols.

@johndoe31415

Copy link
Copy Markdown
Contributor Author

@kaduk, thanks a lot for your hints, it worked perfectly. This also took care of the failed 01-symbol-presence test. I'm looking into 30-evp right now to find an elegant way of ignoring KDFs that we will know in advance aren't included in the build (and thus, will fail).

@kaduk

kaduk commented Aug 9, 2017

Copy link
Copy Markdown
Contributor

I'm looking into 30-evp right now to find an elegant way of ignoring KDFs that we will know in advance aren't included in the build

look at test/evp_test.c and strcmp(alg, "pbkdf2") -- right above it is some logic for handling OPENSSL_NO_SCRYPT that you can crib from.

@johndoe31415

Copy link
Copy Markdown
Contributor Author

Hi @kaduk, ah, yes! Had just found it, it really was a easy copy/paste. Tests run fine now! I'll squash the whole no-pbkdf2 thing right away so it's easily reviewable.

Thanks to you all again for your support and patience. You're all amazingly helpful, this is great!

@paulidale paulidale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for going above and beyond making this configurable.

@mattcaswell

Copy link
Copy Markdown
Member

Travis is failing. Looks like make update is required.

@johndoe31415

Copy link
Copy Markdown
Contributor Author

Thanks, @mattcaswell -- indeed it needed a make update. Just did it and will squash the patch later.

Comment thread Configure Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why we've made this disablable at all? In general I think we should be avoiding adding too many disablable options unless there is a good reason for it. In this case it looks like it adds additional complexity without a lot of gain. In any case, if we do decide to retain this, then INSTALL will need an update with details of the new option.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered too. Why would we need to disable this? It complicates matters and adds additional needs for #ifdefs for it. We didn't have an option to disable it in 1.1.0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I do think it's a good idea to be able to strip down the code basis to the bare minimum (ultimately maybe one day have the ability to have a OpenSSL version that's stripped down so much it can conveniently run on very small embedded systems, maybe even in PSK-only DTLS or something along the lines). That said, it does increase complexity. Since it's a completely separate commit, it's your judgement if you want to take it mainline or not. I think there's good arguments to be made for either choice, so no hurt feelings :-)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested this as a possible improvement. I'm not attached to it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this commit in the PR should be dropped.

Comment thread doc/man7/pbkdf2.pod Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use SHA256 instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 09555b7f.

Comment thread doc/man7/pbkdf2.pod Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pod file doesn't seem appropriate for section 7 - it looks more like it should be section 3. We are using section 7 for a generic introduction to a topic with references off to section 3 man pages for documentation on specific functions. This page is documenting specific functions. (I think the same comment could be applied to the recently added scrypt.pod file).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had a discussion over where general algorithm descriptions should go. Should we hang them off a (possibly obscure) ctrl operation manual page or reference the algorithm name itself? IIRC the conclusion was the algorithm name was better and it should go in section 7.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm struggling to see the difference between the content on this page, and the other pages in section 3. It certainly seems quite different to the rest of the section 7 pages. IMO this should be moved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah well I'm looking more at similarities between this and the man7 stuff. There we have descriptions of how to use specific algorithms such as Ed25519 and X25519. In the cases of those two though there is no associated ctrl operation so they can't go anywhere else.

In the case of scrypt and PBKDF2 there are some ctrls we can associate with it so they could go in manual pages which reference them.

That would also apply to the RSA-PSS manual page too, should that be moved?

Just trying to see how we can handle this all consistently.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all depends on what you actually want to document and how that documentation should be reached. man7 pages should be general descriptions on a topic, so a general description of PBKDF2 in OpenSSL would be fitting for man7. These would typically not have a SYNOPSIS section, or a very short one, mostly referring to the header associated with the stuff described (see for example bio.pod).

However, there's also the documentation of specific functions (or macros as the case may be), and they should rather be in man3, with a collection of the function names in the NAME section and a fleshed out SYNOPSIS section.

With that in mind, I agree with @mattcaswell regarding this page, it looks much more like a man3 page than a man7 one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible this page should be split into two. I can absolutely understand that one would wish for man pbkdf2 to give a general description of PBKDF2! I would expect such a page to refer to the functions that can be use to control this aspect, like L<EVP_PKEY_CTX_set1_pbe_pass(3)>...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine either way -- but I'm holding off on this until you've come to consensus, if that's okay? In any case if we move the PBKDF2 docs to man3, I'd also apply the same to the scrypt man page in a different PR (that's already on master as man7).

Comment thread doc/man7/pbkdf2.pod Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should list all the functions described in this page (see other section 3 pages for examples)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Also, technically, one would want the documentation for the individual functions to be easily accessible, i.e. man EVP_PKEY_CTX_set1_pbe_pass should give us this page. For that to happen, that function name must be mentioned in the NAME section.

Comment thread doc/man7/pbkdf2.pod Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"memory-hard"? I have no idea what that means...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Stronger Key Derivation via Sequential Memory-Hard Functions", Percival 2009:

Definition 1. A memory-hard algorithm on a Random Access Machine is an al-
gorithm which uses S(n) space and T (n) operations, where S(n) ∈ Ω T (n) 1−ǫ .

A memory-hard algorithm is thus an algorithm which asymptotically uses almost
as many memory locations as it uses operations 5 ; it can also be thought of as an
algorithm which comes close to using the most memory possible for a given number
of operations, since by treating memory addresses as keys to a hash table it is trivial
to limit a Random Access Machine to an address space proportional to its running
time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks

Comment thread doc/man7/pbkdf2.pod Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all depends on what you actually want to document and how that documentation should be reached. man7 pages should be general descriptions on a topic, so a general description of PBKDF2 in OpenSSL would be fitting for man7. These would typically not have a SYNOPSIS section, or a very short one, mostly referring to the header associated with the stuff described (see for example bio.pod).

However, there's also the documentation of specific functions (or macros as the case may be), and they should rather be in man3, with a collection of the function names in the NAME section and a fleshed out SYNOPSIS section.

With that in mind, I agree with @mattcaswell regarding this page, it looks much more like a man3 page than a man7 one.

Comment thread doc/man7/pbkdf2.pod Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Also, technically, one would want the documentation for the individual functions to be easily accessible, i.e. man EVP_PKEY_CTX_set1_pbe_pass should give us this page. For that to happen, that function name must be mentioned in the NAME section.

Comment thread doc/man7/pbkdf2.pod Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible this page should be split into two. I can absolutely understand that one would wish for man pbkdf2 to give a general description of PBKDF2! I would expect such a page to refer to the functions that can be use to control this aspect, like L<EVP_PKEY_CTX_set1_pbe_pass(3)>...

Comment thread include/openssl/kdf.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather rename EVP_PKEY_CTRL_SCRYPT_SALT to EVP_PKEY_CTRL_SALT and reuse that.

Comment thread include/openssl/kdf.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For similar reasons, I can see a future where other KDFs also have an iteration count parameter, so it might be appropriate to give a more generic name (i.e. remove _PBKDF2)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is addressed by 4ca36747. Thanks for the comment!

Comment thread include/openssl/kdf.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename EVP_PKEY_CTX_set1_scrypt_salt to EVP_PKEY_CTX_set1_pbe_salt and have it use EVP_PKEY_CTRL_SALT, then remove this one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm -- but what about HKDF? HKDF already uses EVP_PKEY_CTRL_HKDF_SALT (EVP_PKEY_ALG_CTRL + 4).

In order to be consistent, shouldn't that then also use the generic CTRL_SALT? Because then we have a conflict: currently on master, both EVP_PKEY_CTRL_HKDF_SALT (+4) and EVP_PKEY_CTRL_SCRYPT_SALT (+9) are used. So consolidating the two might break something either way (although scrypt has only been in the code for a very short number of days, so not that dramatic probably). If you have an idea how you'd want this to look, I'd get cracking.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, hadn't noticed the HKDF salt control. Yes, I agree with you, that one should probably be generalised as well. Doing this should be fairly straight forward, because as you say, SCRYPT and PBKDF2 are new... So what I would suggest is to generalise the control macros that make sense to do this with (if you want to be really radical, you could generalise all the HKDF ones), and then create alias macros where needed... So I could imagine this:

# define EVP_PKEY_CTRL_MD                       (EVP_PKEY_ALG_CTRL + 3)
# define EVP_PKEY_CTRL_SALT                     (EVP_PKEY_ALG_CTRL + 4)
# define EVP_PKEY_CTRL_KEY                      (EVP_PKEY_ALG_CTRL + 5)
# define EVP_PKEY_CTRL_INFO                     (EVP_PKEY_ALG_CTRL + 6)
# define EVP_PKEY_CTRL_MODE                     (EVP_PKEY_ALG_CTRL + 7)

/* Backward compatibility macros */
# define EVP_PKEY_CTRL_HKDF_MD                  EVP_PKEY_CTRL_MD
# define EVP_PKEY_CTRL_HKDF_SALT                EVP_PKEY_CTRL_SALT
# define EVP_PKEY_CTRL_HKDF_KEY                 EVP_PKEY_CTRL_KEY
# define EVP_PKEY_CTRL_HKDF_INFO                EVP_PKEY_CTRL_INFO
# define EVP_PKEY_CTRL_HKDF_MODE                EVP_PKEY_CTRL_MODE

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and then, convert the diverse function macros accordingly, i.e. add macros like EVP_PKEY_CTX_set1_pbe_salt and make alias macros out of the old (like EVP_PKEY_CTX_set1_hkdf_salt).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, very KDF specific parameter controls, like EVP_PKEY_CTRL_SCRYPT_N, should probably stay the same. So in the end, it's a matter of judging if a parameter is very specific, or is common for more than one KDF.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and adressing this in a separate PR seems like a very wise move. I'll make sure to have a look.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, I like the suggestion and just created a PR for it: #4197 -- in order to fully test all KDFs (old and new-style getters), I've also created a second PR #4196 that adds missing tests -- but you already know this since you've already approved it :-)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it depends on the meaning you attaching to the ctrl. The existing EVP_PKEY_CTRL_MD is used for signatures and indicates the digest to sign/verify with. In fact the code in EVP_PKEY_CTX_ctrl_str with the "digest" string only works for signatures.

If we want to generalise this to mean "the digest associated with the operation" which isn't just signatures then that at least will need changing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd originally suggested that we use different ctrl values for "salt" because there is some difference in the way the salt is used and especially its encoding between algorithms. However the meaning of "random data to thwart dictionary attacks" applies to at least the PBE cases so I'm fine with those having the same value.

@snhenson snhenson Aug 20, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point we'll need to classify some of these algorithms so they can't be used inappropriately. For example an attempt to use a KDF to verify signatures or a non-PBE KDF where a PBE is required. I'd regarded a PBE as a subset of a KDF which always accepts a password parameter.

In future I'd like to add ASN.1 support to PBEs so they can be handled entirely through EVP_PKEY instead of the various different APIs we currently have. That would tidy up things like PKCS#8 handling quite a bit.

@levitte

levitte commented Mar 19, 2018

Copy link
Copy Markdown
Member

Where are we with this one, @openssl?

@johndoe31415

Copy link
Copy Markdown
Contributor Author

Oh wow, I completely dropped the ball on this. To be honest I kind of thought that it'd been already merged. Okay with you, @levitte, if I upgrade the suggested changes and rebase against master?

@levitte

levitte commented Mar 19, 2018

Copy link
Copy Markdown
Member

Please do.
I can't promise it will go into 1.1.1 at this point, though, but it should still be cared for.

This adds a EVP_PKEY_METHOD for the PBKDF2. Test cases have been copied
from the PBE and all pass. Zero-length passwords and salts are
supported (although when using a string to set them, only pass/salt
work, but not hexpass/hexsalt with an empty string argument).
Added manpage for the PKEY API to PBKDF2 and linked to it from the
scrypt man page.
Add the no-pbkdf2 configuration option that entirely disables PBKDF2.
Note that this also implicitly disables scrypt and PKCS#12 GOST MAC. For
the latter, a new error code is introduced (PKCS12_R_MISSING_PBKDF2).
Use Configure-driven (no-pbkdf implies no-scrypt) dependency management,
as suggested by @kaduk. Also include PBKDF2 in the mkdef.pl script. Fix
EVP KDF and EVP PBE tests for both scrypt and PBKDF2 (skip tests if
algorithms not compiled in instead of failing).
This reverts commit bbac07b.

In discussion it was agreed that PBKDF2 is so essential that making it
disableable only adds complexity that's unnecessary.
After revert of bbac07b, PBKDF2 is now not a disableable symbol
anymore.
Moved MAN7 to MAN3 and started some algorithmic description of PBKDF2,
as @levitte suggested.
In the discussion, there was some disagreement -- however, merging of
key/salt seemed to have consensus. Not changing the others (yet?).
@johndoe31415

Copy link
Copy Markdown
Contributor Author

Alright, gave it another shot. I left the original structure intact and didn't do any squashing so it's clearly visible what I've changed. New patches start with d7e3230.

First, I've reverted the possibility to disable PBKDF2, as requested by @mattcaswell.

Then, I've taken the input of @levitte and @snhenson regarding merging the different PKEY #defines -- there was still no definite consensus (at least as I read it), but I believe that everyone wanted to merge salt/key values so that's how I implemented it.

Lastly, I've given a rough draft of how a man7 PBKDF2 could look like and moved the current man7 to man3, as suggested by @levitte. If this is the direction you imagine the man7 to look like, please let me know and I'll polish and extended it. Otherwise I'd just drop it.

Note that I've added some special handling for the previous scrypt-specific salt #define (scrypt has been in master for about half a year now and I don't think it's appropriate to ignore). Also note that tests 70-test_sslcbcpadding.t and 70-test_sslrecords.t are failing (but are failing on master as well, so I don't think I'm at fault).

@levitte

levitte commented Mar 19, 2018

Copy link
Copy Markdown
Member

Also note that tests 70-test_sslcbcpadding.t and 70-test_sslrecords.t are failing (but are failing on master as well, so I don't think I'm at fault).

Regarding that, #5679 may be the chosen solution...

@levitte

levitte commented Mar 19, 2018

Copy link
Copy Markdown
Member

This looks oh so much better in my view. @mattcaswell, do you have some thoughts on this?

@paulidale

Copy link
Copy Markdown
Contributor

Is this really a PKEY method? Might a new EVP interface for KDFs make more sense?

@levitte

levitte commented Mar 29, 2018

Copy link
Copy Markdown
Member

Unfortunately, some tests are failing. Please see the CIs...

Also, this PR hasn't been marked with a milestone. I'm assuming post-1.1.1 at this point, does @openssl agree?

@johndoe31415

Copy link
Copy Markdown
Contributor Author

Hi @levitte, I'll check it out -- did run the local tests but admittedly didn't check the CI.

So I'll beef up the man7 in the way that I'd started out? Does this look good to everyone?

@levitte

levitte commented Mar 29, 2018

Copy link
Copy Markdown
Member

@paulidale, re your question, this is no weirder than the other KDFs in crypto/kdf. So yes, these are implemented as PKEY methods, which might be confusing, but I think it's been made this way because they are usually a component in PKEY protected session keys.

@levitte

levitte commented Mar 29, 2018

Copy link
Copy Markdown
Member

@johndoe31415:

did run the local tests but admittedly didn't check the CI.

It worries me a bit that the default configuration fails its tests in Travis ;-)

So I'll beef up the man7 in the way that I'd started out? Does this look good to everyone?

I'm not sure if we're still at the debate of whether it should be split up into a man3 part and a man7 part or not... The man7 file looked pretty much ok for a first read, but I'll have a second look. However, if it needs flashing out, please carry on!

Comment thread doc/man3/pbkdf2.pod

=head1 NAME

pbkdf2 - PBKDF2 key derivation function

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of pbkdf2, you must enumerate the names of all the functions described in this document. In other words, something like this:

EVP_PKEY_CTX_set1_pbe_pass, EVP_PKEY_CTX_set1_pbkdf2_salt,
EVP_PKEY_CTX_set_pbkdf2_md, EVP_PKEY_CTX_set_pbkdf2_iter
- PBKDF2 key derivation functions

Also, this file needs to be renamed to one of the function names (please avoid EVP_PKEY_CTX_set1_pbe_pass.pod, though... that one is mentioned in more than one place and will probably show up elsewhere).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I just saw docs/man7/scrypt.pod and understand where you got your example from... I'll ahem take a closer look at it, it seems to need a split'n'rewrite)

Comment thread doc/man3/pbkdf2.pod
L<EVP_PKEY_CTX_new(3)>,
L<EVP_PKEY_CTX_ctrl_str(3)>,
L<EVP_PKEY_derive(3)>,
L<scrypt(7)>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we'd mention scrypt(7) here...

Comment thread doc/man3/pbkdf2.pod
=head1 DESCRIPTION

The EVP_PKEY_PBKDF2 algorithm implements the PBKDF2 password based key
derivation function, as described in RFC 2898. It is an iterative HMAC-based

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add the reference L<pbkdf2(7)> here too, or possibly instead of "RFC 2898"... you're choice exactly which you do.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In second thought, since docs/man7/pbkdf2.pod mentions the RFC, I'm not sure it needs to be mentioned here. The CONFORMING TO section below should be enough.

Comment thread doc/man7/scrypt.pod
L<EVP_PKEY_CTX_new(3)>,
L<EVP_PKEY_CTX_ctrl_str(3)>,
L<EVP_PKEY_derive(3)>
L<pbkdf2(7)>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

@mattcaswell mattcaswell added this to the Post 1.1.1 milestone Mar 29, 2018
@mattcaswell

Copy link
Copy Markdown
Member

I'm assuming post-1.1.1

Agreed.

@paulidale

Copy link
Copy Markdown
Contributor

#6674 obsoletes this one I think.
Unless we want a PKEY API for PBKDF2 when another generic KDF API is available.

@levitte

levitte commented Feb 13, 2019

Copy link
Copy Markdown
Member

#6674 obsoletes this one I think.

Indeed. Closing this.

@levitte levitte closed this Feb 13, 2019
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.

7 participants