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

0 length passwords not accepted when importing PKCS8 encrypted key #4716

Closed
engineercrypto opened this issue Nov 10, 2017 · 7 comments
Closed
Milestone

Comments

@engineercrypto
Copy link

One of my colleagues reports that 0 length passwords are not accepted when importing a PKCS8 encrypted key. To see why, go to pem_pkey.c:116 (in branch 1.0.2 stable). Notice that the comparison for password length is <= 0 rather than < 0, which disallows 0 length passwords.

Note that the PKCS 8 and PKCS 5 specifications do not disallow 0 length passwords, so this is a bug.

@levitte
Copy link
Member

levitte commented Nov 10, 2017

It's been like this since the beginning of time, or at least as far as I can look through history (d02b48c is the import of SSLeay 0.8.1b, see crypto/pem/pem_lib.c). I'm not sure I'd call that a bug visavi the specs, unless the specs forbid applications and libraries from rejecting 0 length passphrases.

Of course, we can change this, and it's a fairly simple change. What says the rest of @openssl?

@openssl openssl deleted a comment from nahoMw Nov 11, 2017
@richsalz
Copy link
Contributor

pkcs8 has the -nocrypt flag, I would prefer we just require that to be used.

@levitte
Copy link
Member

levitte commented Nov 11, 2017

Ah, thanks for the reminder

@levitte
Copy link
Member

levitte commented Nov 11, 2017

@engineercrypto, is that a satisfactory answer?

@engineercrypto
Copy link
Author

engineercrypto commented Nov 13, 2017 via email

@mattcaswell mattcaswell added this to the 1.1.1 milestone Jan 22, 2018
@levitte
Copy link
Member

levitte commented May 4, 2018

Looking at this again, I see that @engineercrypto is right that it's not satisfactory, as what they are looking for is to have an encryption key derived from a 0-length password rather than not encrypting at all. There's a nuance between the two.

I see no harm at all making the desired change.

@levitte
Copy link
Member

levitte commented May 4, 2018

Actually, looking again at the code, the 1 length limitation is kinda silly in the cases where we ask PEM_def_callback for a minimum of 0 characters!

levitte added a commit to levitte/openssl that referenced this issue May 4, 2018
levitte added a commit that referenced this issue May 12, 2018
… length

Fixes #4716

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from #6173)

(cherry picked from commit c82c346)
levitte added a commit that referenced this issue May 12, 2018
… length

Fixes #4716

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from #6173)

(cherry picked from commit c82c346)
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

No branches or pull requests

4 participants