-
Notifications
You must be signed in to change notification settings - Fork 128
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
[Core] - Support azure-core version without OpenSSL dependency #2839
Conversation
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.
This change will result in non-unique UUIDs on linux platforms. std::random is not cryptographically secure on linux
…-uuid-without-openssl
…re-sdk-for-cpp into update-uuid-without-openssl
Linux perf results: 64-bit Mersenne Twister by Matsumoto 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.
I am not sure we should expose the build crypto option, if we can remove the openssl dependency all together.
Will review base64 impl in a bit, do we have sufficient test coverage for it?
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.
I think we need more testing of the base64 implementation, especially around edge cases (for integer overflow) and invalid input.
sdk/core/azure-core/src/base64.cpp
Outdated
|
||
while (sourceIndex < static_cast<int64_t>(inputSize) - 4) | ||
{ | ||
int64_t result = base64Decode(inputPtr + sourceIndex); |
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 result
is negative, it means invalid input and we should throw.
We need test cases like the following, which are invalid input:
"A" - too small
"AB" - too small
"ABC" - too small
"ABCD==" - not a multiple of 4
"ABCD====" - invalid padding count
"A%%%" - non-base64 chars
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.
The input has to be of characters from "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
sdk/core/azure-core/src/base64.cpp
Outdated
i0 |= i3; | ||
i0 |= i2; | ||
|
||
base64WriteThreeLowOrderBytes(destinationPtr, i0); |
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.
Same here and elsewhere - add input validation checks (if i0 < 0) and throw for invalid input
sdk/core/azure-core/src/base64.cpp
Outdated
destination.resize(resultSize); | ||
destination.shrink_to_fit(); |
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.
Resizing strings and vectors after the fact seems to be a relatively expensive operation.
@CaseyCarter how do we avoid this, and maybe just create the vector of the right size at the end without having to do linear data copy or re-allocation? In .NET/C#, this was relatively easy with span/slicing for buffers.
sdk/core/azure-core/test/perf/inc/azure/core/test/uuid_test.hpp
Outdated
Show resolved
Hide resolved
sdk/core/azure-core/src/base64.cpp
Outdated
int64_t sourceIndex = 0; | ||
int64_t destinationIndex = 0; |
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.
Ditto "indices into memory buffers, these should be size_t
"
sdk/core/azure-core/src/base64.cpp
Outdated
int64_t result = base64Decode(inputPtr + sourceIndex); | ||
base64WriteThreeLowOrderBytes(destinationPtr, result); | ||
destinationPtr += 3; | ||
destinationIndex += 3; |
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.
destinationIndex
is unused.
Co-authored-by: Ahson Khan <ahkha@microsoft.com> Co-authored-by: Casey Carter <cartec69@gmail.com>
Co-authored-by: Ahson Khan <ahkha@microsoft.com>
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.
Casey has some good feedback, can we at least open work items? Re: random seems pretty important. Prefix increment, not so important, but I'd take it as well, but I am biased.
…-uuid-without-openssl
…re-sdk-for-cpp into update-uuid-without-openssl
…-uuid-without-openssl
An azure-core lib version without OpenSSL is required for the speech service which will consume only UUID (and HTTP in some future).
This PR makes some changes to the current azure core components consuming OpenSSL :
fixes: #2790