-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Crypto] Replace OpenSSL-specific flag with public API to check SHA256 digest initialization #36608
Conversation
PR #36608: Size comparison from 04e6a68 to c5ffbc1 Full report (25 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, nrfconnect, qpg, stm32, telink, tizen)
|
c5ffbc1
to
758706d
Compare
This is a follow_up to project-chip#36386 based on a post-merge comment, - an OpenSSL-specific mInitialized flag was added to HASH_SHA256 to check if digest computation was initialised, which isn't used for other Crypto Backends - Fix: replace by a Public API `IsInitialized`, with its implementation for OpenSSL/BoringSSL
758706d
to
49e008f
Compare
PR #36608: Size comparison from 04e6a68 to 49e008f Full report (69 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
* | ||
* @return True if the context is correctly initialized; otherwise, false. | ||
*/ | ||
bool IsInitialized(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this need implementations for the non-OpenSSL/BoringSSL backends?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also: this looks like an API that API consumers should call before they do anything with the object.... but they very much don't do that, and if they tried it would not work with most of the backends. Why is this public API at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. The method used here should be used more widely whenever the context is used at all. I would expect this API to be private since it's only used internally and should never be false. The idea is to avoid double-free or leaks, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this was a mistake, the IsInitialized
is only to be used internally by Hash_SHA256_stream
within the OpenSSL backend. So I will make IsInitialized
protected.
@bzbarsky-apple Should I add a stub for IsInitialized
in other backends or only add a comment in the *.h
that it is only implemented in OpenSSL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's private/protected, it really does not matter; someone who tries to use it will know what they are doing and notice they need to implement it. So comment saying "implement this if your backend needs it" is fine.
…hip#36608) This is a follow_up to project-chip#36386 based on a post-merge comment, - an OpenSSL-specific mInitialized flag was added to HASH_SHA256 to check if digest computation was initialised, which isn't used for other Crypto Backends - Fix: replace by a Public API `IsInitialized`, with its implementation for OpenSSL/BoringSSL
…hip#36608) This is a follow_up to project-chip#36386 based on a post-merge comment, - an OpenSSL-specific mInitialized flag was added to HASH_SHA256 to check if digest computation was initialised, which isn't used for other Crypto Backends - Fix: replace by a Public API `IsInitialized`, with its implementation for OpenSSL/BoringSSL
This is a follow_up to #36386 based on a post-merge comment.
an OpenSSL-specific
mInitialized
flag was added to HASH_SHA256 to check if digest computation was initialized, which isn't used for other Crypto Backends.It also added platform-specific
#ifdefs
to the a platform-agnostic header.Fix: replace by a Public API
IsInitialized
, with its implementation for OpenSSL/BoringSSL