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

Rename the field 'provctx and data' to 'algctx' inside some EVP objects. #15275

Closed
wants to merge 3 commits into from

Conversation

slontis
Copy link
Member

@slontis slontis commented May 14, 2021

Fixes #14284

This was a bit confusing since some objects need an actual provider
context to be passed (e.g. asym_cipher_gettable_ctx_params)
This 'data' field is an opaque ptr returned from new_ctx() operations. The
ptr points to data created inside a providers implementation of an
algorithm. This ptr is then passed to the provider algorithm for all
subsequent operations (such as init(), update(), and free()).

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

@slontis slontis added branch: master Merge to master branch approval: review pending This pull request needs review by a committer labels May 14, 2021
include/crypto/evp.h Outdated Show resolved Hide resolved
@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label May 14, 2021
Copy link
Member

@levitte levitte left a comment

Choose a reason for hiding this comment

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

data is too nondescript in my view, could just as well be xyzzy. I understand wanting to avoid the confusion with the provider context, though.
So here's another idea.

crypto/evp/evp_local.h Outdated Show resolved Hide resolved
crypto/evp/evp_local.h Outdated Show resolved Hide resolved
include/crypto/evp.h Outdated Show resolved Hide resolved
include/crypto/evp.h Outdated Show resolved Hide resolved
include/crypto/evp.h Outdated Show resolved Hide resolved
include/crypto/evp.h Outdated Show resolved Hide resolved
@levitte
Copy link
Member

levitte commented May 14, 2021

Side note: I like what the checksums github action does. Nice work @t8m!

…ontaining

pointers to provider size algorithm contexts.

Fixes openssl#14284

The gettable_ctx_params methods were confusingly passing a 'provctx' and
a provider context which are completely different objects.
Some objects such as EVP_KDF used 'data' while others such as EVP_MD used 'provctx'.

For libcrypto this 'ctx' is an opaque ptr returned when a providers algorithm
implementation creates an internal context using a new_ctx() method.
Hence the new name 'algctx'.
@slontis slontis changed the title Rename the field 'provctx' to 'data' inside some EVP_xxx_CTX objects. Rename the field 'provctx and data' to 'algctx' inside some EVP objects. May 18, 2021
@slontis
Copy link
Member Author

slontis commented May 18, 2021

Changed all of them to use algctx

Copy link
Member

@levitte levitte left a comment

Choose a reason for hiding this comment

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

Other than this, I'm happy, and especially that you fixed the MAC code accordingly!

/*
* Opaque ctx returned from a providers digest algorithm implementation
* OSSL_FUNC_digest_newctx()
*/
Copy link
Member

Choose a reason for hiding this comment

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

This comment seems a bit bloated at this point. How about /* Algorithm-specific ctx */?

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer the longer comment.

Copy link
Member

@levitte levitte May 18, 2021

Choose a reason for hiding this comment

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

So why only here and not everywhere where we have the algctx field?

Copy link
Member

Choose a reason for hiding this comment

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

Change to make them all more verbose noted.

I find it amazing, though, that extended verbosity is chosen for this item specifically. I kinda understand it considering that there seems to be a lot of confusion... but in a year, will we still feel the same?

Copy link
Member

Choose a reason for hiding this comment

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

Anyway, I'm not going to block on terms of verbosity, just wanted to express my surprise over this choice, this time

Copy link
Member Author

Choose a reason for hiding this comment

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

This may be trying to be kind to others trying to understand what it is.

/*
* Opaque ctx returned from a providers cipher algorithm implementation
* OSSL_FUNC_cipher_newctx()
*/
Copy link
Member

Choose a reason for hiding this comment

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

This comment seems a bit bloated at this point. How about /* Algorithm-specific ctx */?

@paulidale paulidale 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 May 18, 2021
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.

Nice cleanup!

@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 May 19, 2021
@openssl-machine
Copy link
Collaborator

This pull request is ready to merge

…jects containing pointers to provider size algorithm contexts.
@slontis
Copy link
Member Author

slontis commented May 20, 2021

Changed the comments..

include/crypto/evp.h Show resolved Hide resolved
…jects containing pointers to provider size algorithm contexts.
@paulidale
Copy link
Contributor

Merged to master.

@paulidale paulidale closed this May 24, 2021
openssl-machine pushed a commit that referenced this pull request May 24, 2021
…ontaining

pointers to provider size algorithm contexts.

Fixes #14284

The gettable_ctx_params methods were confusingly passing a 'provctx' and
a provider context which are completely different objects.
Some objects such as EVP_KDF used 'data' while others such as EVP_MD used 'provctx'.

For libcrypto this 'ctx' is an opaque ptr returned when a providers algorithm
implementation creates an internal context using a new_ctx() method.
Hence the new name 'algctx'.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #15275)
@slontis
Copy link
Member Author

slontis commented May 24, 2021

Thanks Pauli..

devnexen pushed a commit to devnexen/openssl that referenced this pull request Jul 7, 2021
…ontaining

pointers to provider size algorithm contexts.

Fixes openssl#14284

The gettable_ctx_params methods were confusingly passing a 'provctx' and
a provider context which are completely different objects.
Some objects such as EVP_KDF used 'data' while others such as EVP_MD used 'provctx'.

For libcrypto this 'ctx' is an opaque ptr returned when a providers algorithm
implementation creates an internal context using a new_ctx() method.
Hence the new name 'algctx'.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from openssl#15275)
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 severity: fips change The pull request changes FIPS provider sources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change provctx fields in EVP_xxx_CTX structures to data.
6 participants