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

ENCODER & DECODER: Allow decoder implementations to specify "carry on" #14834

Closed
wants to merge 6 commits into from

Conversation

levitte
Copy link
Member

@levitte levitte commented Apr 12, 2021

So far, decoder implementations would return true (1) for a successful
decode all the way, including what the callback it called returned,
and false (0) in all other cases.

This construction didn't allow to stop to decoding process on fatal
errors, nor to choose what to report in the provider code.

This is now changed so that decoders are made to return false only on
fatal errors, and return true for all other cases, even if that didn't
result in a constructed object (EVP_PKEY for example).
The success of the decoding process is now all about successfully
constructing the final object, rather than about the return value of
the decoding chain.

Fixes #14423

@levitte levitte added branch: master Merge to master branch approval: review pending This pull request needs review by a committer labels Apr 12, 2021
@levitte
Copy link
Member Author

levitte commented Apr 12, 2021

Currently still draft. I've a kink to work out, and documentation changes to do.

@levitte
Copy link
Member Author

levitte commented Apr 16, 2021

@t8m:

So perhaps the draft status should be now lifted?

Not quite. Documentation needs changes

So far, decoder implementations would return true (1) for a successful
decode all the way, including what the callback it called returned,
and false (0) in all other cases.

This construction didn't allow to stop to decoding process on fatal
errors, nor to choose what to report in the provider code.

This is now changed so that decoders implementations are made to
return false only on errors that should stop the decoding process from
carrying on with other implementations, and return true for all other
cases, even if that didn't result in a constructed object (EVP_PKEY
for example), essentially making it OK to return "empty handed".

The success of the decoding process is now all about successfully
constructing the final object, rather than about the return value of
the decoding chain.  If no construction is attempted, the central
decoding processing code concludes that whatever the input consisted
of, it's not supported by the available decoder implementations.

Fixes openssl#14423
… failure

This includes the special decoder used in our STOREMGMT 'file:' implementation
The EVP test didn't recognise ERR_R_UNSUPPORTED, now does
The error report filter was fragile, as it could potentially have to
be updated when other parts of libcrypto got updated, making a goose
chase and a maintenance problem.

We change this to regard d2i errors as something we don't care so much
about, since they are mainly part of the guessing mechanism.  The
success of the ossl_store_handle_load_result() call is based on
whether an object was actually created or not anyway.
@levitte levitte marked this pull request as ready for review April 16, 2021 14:17
@levitte levitte changed the title [DRAFT] ENCODER & DECODER: Allow decoder implementations to specify "carry on" ENCODER & DECODER: Allow decoder implementations to specify "carry on" Apr 16, 2021
@levitte
Copy link
Member Author

levitte commented Apr 16, 2021

There, this is not a draft any more

crypto/store/store_result.c Outdated Show resolved Hide resolved
crypto/store/store_result.c Outdated Show resolved Hide resolved
crypto/store/store_result.c Outdated Show resolved Hide resolved
crypto/store/store_result.c Outdated Show resolved Hide resolved
@levitte
Copy link
Member Author

levitte commented Apr 19, 2021

I made the ERR_set_mark() / ERR_pop_to_mark() more selective as you desired, @t8m. Tests on my laptop don't seem to mind

@t8m t8m 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 Apr 20, 2021
@openssl-machine openssl-machine 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 Apr 21, 2021
@openssl-machine
Copy link
Collaborator

This pull request is ready to merge

@levitte
Copy link
Member Author

levitte commented Apr 21, 2021

Merged

f996595 ENCODER & DECODER: Allow decoder implementations to specify "carry on"
9cc97dd Adapt our decoder implementations to the new way to indicate succes / failure
7aef200 TEST: Adapt the EVP test
1fbf707 STORE: Discard the error report filter in crypto/store/store_result.c

openssl-machine pushed a commit that referenced this pull request Apr 21, 2021
So far, decoder implementations would return true (1) for a successful
decode all the way, including what the callback it called returned,
and false (0) in all other cases.

This construction didn't allow to stop to decoding process on fatal
errors, nor to choose what to report in the provider code.

This is now changed so that decoders implementations are made to
return false only on errors that should stop the decoding process from
carrying on with other implementations, and return true for all other
cases, even if that didn't result in a constructed object (EVP_PKEY
for example), essentially making it OK to return "empty handed".

The success of the decoding process is now all about successfully
constructing the final object, rather than about the return value of
the decoding chain.  If no construction is attempted, the central
decoding processing code concludes that whatever the input consisted
of, it's not supported by the available decoder implementations.

Fixes #14423

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #14834)
openssl-machine pushed a commit that referenced this pull request Apr 21, 2021
… failure

This includes the special decoder used in our STOREMGMT 'file:' implementation

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #14834)
openssl-machine pushed a commit that referenced this pull request Apr 21, 2021
The EVP test didn't recognise ERR_R_UNSUPPORTED, now does

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #14834)
openssl-machine pushed a commit that referenced this pull request Apr 21, 2021
The error report filter was fragile, as it could potentially have to
be updated when other parts of libcrypto got updated, making a goose
chase and a maintenance problem.

We change this to regard d2i errors as something we don't care so much
about, since they are mainly part of the guessing mechanism.  The
success of the ossl_store_handle_load_result() call is based on
whether an object was actually created or not anyway.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #14834)
@levitte levitte closed this Apr 21, 2021
@levitte levitte deleted the fix-14423 branch April 21, 2021 08:55
@paulidale paulidale mentioned this pull request Apr 22, 2021
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decoder implementations must be able to signal "please carry on" even if they can't decode the input
4 participants