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

Cache constants for fetched EVP_cipher #10461

Closed
wants to merge 1 commit into from

Conversation

slontis
Copy link
Member

@slontis slontis commented Nov 18, 2019

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

@richsalz
Copy link
Contributor

much gain for few lines of code; nice!

@slontis slontis added approval: otc review pending This pull request needs review by an OTC member branch: master Merge to master branch labels Nov 18, 2019
@slontis slontis added this to In progress in 3.0 New Core + FIPS via automation Nov 18, 2019
@beldmit
Copy link
Member

beldmit commented Nov 18, 2019

Is it safe enough to cache flags? I'm not familiar with the provider code so are the cached values cached per implementation?

@slontis
Copy link
Member Author

slontis commented Nov 18, 2019

The values that are cached here are equivalent to values that were in the old const EVP_CIPHER structs.. i.e- they are constant default values that should not change. The flags should be treated in the same way as the key_length (i.e this is the constant default key length).

@beldmit
Copy link
Member

beldmit commented Nov 18, 2019

I'm not sure about flags because some of them can be implementation-defined (e.g. EVP_CIPH_FLAG_FIPS).

@slontis
Copy link
Member Author

slontis commented Nov 18, 2019

The values have been stored into the EVP_cipher during the fetch operation as they need to exist before either the new_ctx method or the ctx_int have been called.

e.g- it needs to handle the sequence
ciph = EVP_CIPHER_fetch(.....)
len = EVP_CIPHER_key_length(ciph)

@slontis
Copy link
Member Author

slontis commented Nov 18, 2019

I'm not sure about flags because some of them can be implementation-defined (e.g. EVP_CIPH_FLAG_FIPS).

Well that particular one is a dead flag left over from the old fips module.
If you want values that change then they belong in the ctx.
i.e: EVP_CIPHER_CTX_set_flags()

3.0 New Core + FIPS automation moved this from In progress to Reviewer approved Nov 20, 2019
Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

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

This changes the semantics so that all the ciphers have to support all these cached constant parameters. However IMO that is actually a good thing. We could even add to documentation that these cached constant functions cannot fail if we wanted to make life of application writers easier.

@paulidale
Copy link
Contributor

@t8m, I don't think it changes the semantics quite like that: a cipher that doesn't know/support one of the cached parameters won't return it from the get query and it will default to zero. True, the unsupported return code won't happen anymore.

It would be an easy enough change to keep the unsupported return code, if that is preferable.

I like the idea of all ciphers supporting all of these constants. I do wonder what the IV length for an ECB mode cipher should be. Unsupported seems more reasonable than zero.

@levitte
Copy link
Member

levitte commented Nov 20, 2019

Why do you want to distinguish an unsupported IV length from zero? Is there a practical reason?

@paulidale
Copy link
Contributor

It's the first example of a change that sprung to mind -- agreed, it isn't a good one 😴

This does represent a (small) change of behaviour which is the issue.

@levitte
Copy link
Member

levitte commented Nov 20, 2019

Actually, this gets us back to pre-3.0 behavior, no?

@levitte levitte added approval: done This pull request has the required number of approvals and removed approval: otc review pending This pull request needs review by an OTC member labels Nov 20, 2019
@paulidale
Copy link
Contributor

@levitte, did you intend to approve this? It is still missing an OMC approval....

Copy link
Contributor

@paulidale paulidale left a comment

Choose a reason for hiding this comment

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

Replacing @slontis (for review purposes).

@levitte
Copy link
Member

levitte commented Nov 21, 2019

@levitte, did you intend to approve this? It is still missing an OMC approval....

I was too quick on the labeling... but since you approved, all's good.

@paulidale paulidale 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 Nov 22, 2019
@p-steuer p-steuer self-assigned this Nov 25, 2019
openssl-machine pushed a commit that referenced this pull request Nov 25, 2019
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
(Merged from #10461)
@p-steuer
Copy link
Member

merged.

master: 3c957bc

@p-steuer p-steuer closed this Nov 25, 2019
3.0 New Core + FIPS automation moved this from Reviewer approved to Done Nov 25, 2019
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

7 participants