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

Fix some decoder issues including a regression #21603

Closed
wants to merge 5 commits into from

Conversation

mattcaswell
Copy link
Member

The PEM_read_bio_Parameters[_ex] function does not have the capability of specifying a password callback. We should not use the fallback password callback in this case because it will attempt to send a prompt for the password which might not be the correct thing to do. We should just not use a password in that case.

#Fixes #21588

While fixing the above I noticed some other odd behaviour with the decoders and fixed that too.

We're always supposed to add the fallback "unsupported" error if we don't have anything better. However in some cases this wasn't happening because we were incorrectly setting "flag_construct_called" - even though the construct function had failed.

msblob only decodes public/private keys (not just params). pvk only decodes private keys. If the requested selection doesn't intersect with the above then don't consider those decoders.

msblob only decodes public/private keys (not just params).
pvk only decodes private keys.

If the requested selection doesn't intersect with the above then don't
consider those decoders.
We're always supposed to add the fallback "unsupported" error if we don't
have anything better. However in some cases this wasn't happening because
we were incorrectly setting "flag_construct_called" - even though the
construct function had failed.
The PEM_read_bio_Parameters[_ex] function does not have the capability
of specifying a password callback. We should not use the fallback password
callback in this case because it will attempt to send a prompt for the
password which might not be the correct thing to do. We should just not
use a password in that case.

Fixes openssl#21588
We must not ask for a password when attempting to read parameters.
@mattcaswell mattcaswell added branch: master Merge to master branch approval: review pending This pull request needs review by a committer approval: otc review pending This pull request needs review by an OTC member branch: 3.0 Merge to openssl-3.0 branch severity: regression The issue/pr is a regression from previous released version branch: 3.1 Merge to openssl-3.1 labels Jul 31, 2023
@t8m t8m added the triaged: bug The issue/pr is/fixes a bug label Jul 31, 2023
@t8m t8m removed the approval: otc review pending This pull request needs review by an OTC member label Jul 31, 2023
@t-j-h t-j-h added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Jul 31, 2023
@t-j-h
Copy link
Member

t-j-h commented Jul 31, 2023

Okay for master of course. This does seem enough like a bug fix to be considered for backfit if @t8m thinks it should go into 3.1 and 3.0.

@t8m
Copy link
Member

t8m commented Jul 31, 2023

Yes, imo this is bug fix and should go to all 3.x branches.

@t8m t8m added the tests: present The PR has suitable tests present label Jul 31, 2023
test/pemtest.c Outdated Show resolved Hide resolved
ok = (rv > 0);
if (ok)
if (ok) {
data->flag_construct_called = 1;
Copy link
Member

Choose a reason for hiding this comment

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

If this is correct behavior then it may be worth changing the name of the 'flag_construct_called', since technically beforehand it is doing what was described i.e. the constructor was called..

Copy link
Member

Choose a reason for hiding this comment

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

I have no objection to @mattcaswell renaming it - I don't particularly find the current names all that enlightening.
My approval stands with or without the renaming being suggested by @slontis

Copy link
Member Author

Choose a reason for hiding this comment

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

That seems to be more "refactor" than bug fix which I'd rather not do in this PR since it is aimed at backport.

Copy link
Member

Choose a reason for hiding this comment

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

I am actually not sure if this change hasn't some other unwanted consequences. Apparently the test suite passes but there might be a performance impact or some corner cases (which we do not test) might be broken.

Copy link
Member Author

Choose a reason for hiding this comment

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

I doubt it will cause much problem. There are very few places where this flag is ever read. It's read in OSSL_DECODER_from_bio to determine whether to add an error to the stack or not (which is actually the reason for this fix, because it was omitting adding an error in cases where it should). It's also read later on in the same function to determine whether a following decoder successfully called construct (and therefore we should stop looking).

Copy link
Member

Choose a reason for hiding this comment

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

OK, I am fine with merging this now. But perhaps @levitte could look at the consequences when he returns from his vacation.

@mattcaswell
Copy link
Member Author

Trivial fixup pushed (whitespace only), addressing @slontis's comment. I assume the approvals still stand.

@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

ok = (rv > 0);
if (ok)
if (ok) {
data->flag_construct_called = 1;
Copy link
Member

Choose a reason for hiding this comment

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

OK, I am fine with merging this now. But perhaps @levitte could look at the consequences when he returns from his vacation.

@t8m t8m added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Aug 1, 2023
@t8m
Copy link
Member

t8m commented Aug 1, 2023

Merged to master, 3.1 and 3.0 branches. Thank you.

@t8m t8m closed this Aug 1, 2023
openssl-machine pushed a commit that referenced this pull request Aug 1, 2023
msblob only decodes public/private keys (not just params).
pvk only decodes private keys.

If the requested selection doesn't intersect with the above then don't
consider those decoders.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21603)
openssl-machine pushed a commit that referenced this pull request Aug 1, 2023
We're always supposed to add the fallback "unsupported" error if we don't
have anything better. However in some cases this wasn't happening because
we were incorrectly setting "flag_construct_called" - even though the
construct function had failed.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21603)
openssl-machine pushed a commit that referenced this pull request Aug 1, 2023
The PEM_read_bio_Parameters[_ex] function does not have the capability
of specifying a password callback. We should not use the fallback password
callback in this case because it will attempt to send a prompt for the
password which might not be the correct thing to do. We should just not
use a password in that case.

Fixes #21588

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21603)
openssl-machine pushed a commit that referenced this pull request Aug 1, 2023
We must not ask for a password when attempting to read parameters.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21603)
openssl-machine pushed a commit that referenced this pull request Aug 1, 2023
msblob only decodes public/private keys (not just params).
pvk only decodes private keys.

If the requested selection doesn't intersect with the above then don't
consider those decoders.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21603)

(cherry picked from commit 6207f2b)
openssl-machine pushed a commit that referenced this pull request Aug 1, 2023
We're always supposed to add the fallback "unsupported" error if we don't
have anything better. However in some cases this wasn't happening because
we were incorrectly setting "flag_construct_called" - even though the
construct function had failed.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21603)

(cherry picked from commit 564e5b7)
openssl-machine pushed a commit that referenced this pull request Aug 1, 2023
The PEM_read_bio_Parameters[_ex] function does not have the capability
of specifying a password callback. We should not use the fallback password
callback in this case because it will attempt to send a prompt for the
password which might not be the correct thing to do. We should just not
use a password in that case.

Fixes #21588

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21603)

(cherry picked from commit 0d0791e)
openssl-machine pushed a commit that referenced this pull request Aug 1, 2023
We must not ask for a password when attempting to read parameters.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21603)

(cherry picked from commit df3d609)
openssl-machine pushed a commit that referenced this pull request Aug 1, 2023
msblob only decodes public/private keys (not just params).
pvk only decodes private keys.

If the requested selection doesn't intersect with the above then don't
consider those decoders.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21603)

(cherry picked from commit 6207f2b)
openssl-machine pushed a commit that referenced this pull request Aug 1, 2023
We're always supposed to add the fallback "unsupported" error if we don't
have anything better. However in some cases this wasn't happening because
we were incorrectly setting "flag_construct_called" - even though the
construct function had failed.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21603)

(cherry picked from commit 564e5b7)
openssl-machine pushed a commit that referenced this pull request Aug 1, 2023
The PEM_read_bio_Parameters[_ex] function does not have the capability
of specifying a password callback. We should not use the fallback password
callback in this case because it will attempt to send a prompt for the
password which might not be the correct thing to do. We should just not
use a password in that case.

Fixes #21588

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21603)

(cherry picked from commit 0d0791e)
openssl-machine pushed a commit that referenced this pull request Aug 1, 2023
We must not ask for a password when attempting to read parameters.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #21603)

(cherry picked from commit df3d609)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Aug 2, 2023
msblob only decodes public/private keys (not just params).
pvk only decodes private keys.

If the requested selection doesn't intersect with the above then don't
consider those decoders.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21603)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Aug 2, 2023
We're always supposed to add the fallback "unsupported" error if we don't
have anything better. However in some cases this wasn't happening because
we were incorrectly setting "flag_construct_called" - even though the
construct function had failed.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21603)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Aug 2, 2023
The PEM_read_bio_Parameters[_ex] function does not have the capability
of specifying a password callback. We should not use the fallback password
callback in this case because it will attempt to send a prompt for the
password which might not be the correct thing to do. We should just not
use a password in that case.

Fixes openssl#21588

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21603)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Aug 2, 2023
We must not ask for a password when attempting to read parameters.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21603)
xl32 pushed a commit to xl32/openssl that referenced this pull request Sep 29, 2023
msblob only decodes public/private keys (not just params).
pvk only decodes private keys.

If the requested selection doesn't intersect with the above then don't
consider those decoders.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21603)

(cherry picked from commit 6207f2b)
xl32 pushed a commit to xl32/openssl that referenced this pull request Sep 29, 2023
We're always supposed to add the fallback "unsupported" error if we don't
have anything better. However in some cases this wasn't happening because
we were incorrectly setting "flag_construct_called" - even though the
construct function had failed.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21603)

(cherry picked from commit 564e5b7)
xl32 pushed a commit to xl32/openssl that referenced this pull request Sep 29, 2023
The PEM_read_bio_Parameters[_ex] function does not have the capability
of specifying a password callback. We should not use the fallback password
callback in this case because it will attempt to send a prompt for the
password which might not be the correct thing to do. We should just not
use a password in that case.

Fixes openssl#21588

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21603)

(cherry picked from commit 0d0791e)
xl32 pushed a commit to xl32/openssl that referenced this pull request Sep 29, 2023
We must not ask for a password when attempting to read parameters.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#21603)

(cherry picked from commit df3d609)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Merge to master branch branch: 3.0 Merge to openssl-3.0 branch branch: 3.1 Merge to openssl-3.1 severity: regression The issue/pr is a regression from previous released version tests: present The PR has suitable tests present triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x) : something has changed since v3.0 !
5 participants