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: set params on all encoder/decoder instances, unconditionally #13156

Closed

Conversation

levitte
Copy link
Member

@levitte levitte commented Oct 16, 2020

OSSL_DECODER_CTX_set_params() and OSSL_ENCODER_CTX_set_params() would
stop as soon as a decoder / encoder instance failed, which leaves the
rest of them with a possibly previous and different value.

Instead, these functions will now call them all, but will return 0 if
any of the instance calls failed.

…ditionally

OSSL_DECODER_CTX_set_params() and OSSL_ENCODER_CTX_set_params() would
stop as soon as a decoder / encoder instance failed, which leaves the
rest of them with a possibly previous and different value.

Instead, these functions will now call them all, but will return 0 if
any of the instance calls failed.
@levitte levitte added branch: master Merge to master branch approval: review pending This pull request needs review by a committer labels Oct 16, 2020
@levitte levitte added this to the 3.0.0 beta1 milestone Oct 16, 2020
@levitte levitte added this to In progress in 3.0 New Core + FIPS via automation Oct 16, 2020
Copy link
Member

@mattcaswell mattcaswell left a comment

Choose a reason for hiding this comment

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

I'm wondering if it is correct to fail if any of the encoders/decoders fail. If some pass and others fail that might be ok. But I can't think what better behaviour might look like.

3.0 New Core + FIPS automation moved this from In progress to Reviewer approved Oct 16, 2020
@mattcaswell mattcaswell 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 Oct 16, 2020
@levitte
Copy link
Member Author

levitte commented Oct 16, 2020

I'm wondering if it is correct to fail if any of the encoders/decoders fail. If some pass and others fail that might be ok. But I can't think what better behaviour might look like.

We'd have to have the concept of half failures... whatever that would mean. (30% failed, 50% failed, 74.3% failed... maybe we should return a float 😆)

@mattcaswell
Copy link
Member

You could have 0 == all failed, 1 == some success, 2 == all success. That way anything greater than 0 is just "success", and if you want to know that they all succeeded then you could get that information too.

@mattcaswell
Copy link
Member

Mind you, what does "fail" actually mean for an encoder/decoder? Does it mean I don't understand this, or does it mean I do understand this, tried to process it, but couldn't. If the latter then perhaps it is ok to just say if any fail then the overall result is 0.

@h-vetinari
Copy link
Contributor

You could have 0 == all failed, 1 == some success, 2 == all success.

I'm aware openssl has an idiosyncratic relationship with error codes, but seeing this, I have to ask: why not

0 == all passed
1,2,3,... == number of failures

?

@mattcaswell
Copy link
Member

I'm aware openssl has an idiosyncratic relationship with error codes, but seeing this

Because virtually all functions return 0 for fail and 1 for success (including all the other *_set_params functions). This would reverse the logic, which would be hugely confusing.

@levitte
Copy link
Member Author

levitte commented Oct 16, 2020

Should we really re-invent yet another return code structure? We already have a couple of fairly common ones:

  • the binary (0 or 1)
  • positive vs negative (1 = success; 0, -1, -2, ... = diverse "levels" of failure)

These both allow using fn(...) > 0 to find out if a call was successful. Now you're inventing new return code structures with wildly different patterns!

If there is to be some kind of count of failures, I'd suggest going for the negative, that would at least be some sort of compatible with already existing patterns. 1 = success, 0 = all failed, -n = negated count of failures.

Seriously, though, I'm not sure why the count of failures is relevant. What is the caller going to do with that? That any of the en-/decoder instances has failed should tell the caller that they shouldn't expect any well defined result if they continue to use the OSSL_ENCODER_CTX where setting the params failed.

@h-vetinari
Copy link
Contributor

All good, was just asking because "1 == some success, 2 == all success" IMO sounds like a footgun waiting to happen.

  • positive vs negative (1 = success; 0, -1, -2, ... = diverse "levels" of failure)
  • 1 = success, 0 = all failed, -n = negated count of failures.

Both reasonable.

@levitte
Copy link
Member Author

levitte commented Oct 16, 2020

Either way, this PR is approved... I guess we can come back to failure rates at another time, if that turns out to be relevant

@mattcaswell
Copy link
Member

Either way, this PR is approved... I guess we can come back to failure rates at another time, if that turns out to be relevant

Yes, its fine. Just me thinking out aloud.

@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.

@levitte levitte 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 Oct 17, 2020
@levitte
Copy link
Member Author

levitte commented Oct 17, 2020

Merged

9096809 ENCODER & DECODER: set params on all encoder/decoder instances, unconditionally

@levitte levitte closed this Oct 17, 2020
3.0 New Core + FIPS automation moved this from Reviewer approved to Done Oct 17, 2020
openssl-machine pushed a commit that referenced this pull request Oct 17, 2020
…ditionally

OSSL_DECODER_CTX_set_params() and OSSL_ENCODER_CTX_set_params() would
stop as soon as a decoder / encoder instance failed, which leaves the
rest of them with a possibly previous and different value.

Instead, these functions will now call them all, but will return 0 if
any of the instance calls failed.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #13156)
@levitte levitte deleted the fix-endecoder-set-ctx-params-20201016 branch October 17, 2020 09:58
@paulnelsontx paulnelsontx added this to Ready to merge in 3.0.0 estimator Dec 1, 2020
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
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants