-
Notifications
You must be signed in to change notification settings - Fork 45
Refactor ec key import #229
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
Conversation
| python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')" | ||
| chmod a+x builder | ||
| ./builder build -p ${{ env.PACKAGE_NAME }} --compiler=gcc --cmake-extra=-DASSERT_LOCK_HELD=ON --coverage |
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.
> aws --region us-east-1 secretsmanager get-secret-value --secret-id codecov-token
No token found for aws-c-cal, check https://app.codecov.io/github/awslabs/aws-c-cal/settings for token and add it to codecov-token in secret-manager.
This actually failed, but I didn't have the non-zero exit code in the builder...
Should be fixed by awslabs/aws-crt-builder#340
Also, I put the token in the secrete manager now, so it should work now.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
source/ecc.c
Outdated
|
|
||
| /* tag 0 is optional params */ | ||
| if (aws_der_decoder_tlv_type(decoder) == AWS_DER_CONTEXT_SPECIFIC_TAG0) { | ||
| aws_der_decoder_next(decoder); |
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.
check for reaching the end or not after _next
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 was somewhat on purpose to account for cases where there is 2 optional fields back to back. anyways rewrote this to make it more clear.
source/ecc.c
Outdated
| if (aws_der_decoder_tlv_type(decoder) == AWS_DER_CONTEXT_SPECIFIC_TAG0) { | ||
| aws_der_decoder_next(decoder); | ||
|
|
||
| if (aws_der_decoder_tlv_type(decoder) == AWS_DER_OBJECT_IDENTIFIER) { |
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.
else we ignore 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.
lets just hard fail. its not a valid asn if its not object identifier
| struct aws_der_decoder *aws_der_decoder_nested_tlv_decoder(struct aws_der_decoder *decoder) { | ||
| struct aws_byte_cursor cursor; | ||
| AWS_ZERO_STRUCT(cursor); | ||
| if (aws_der_decoder_tlv_string(decoder, &cursor)) { |
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 familiar with the der decoder, but looks like this is only used once, and seems like a very specific case the nested der is a string type?
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.
Yeah, this is a bit of unusual case.
basically instead of inlining the fields of the nested structure, it is turned into octet string.
we need to parse the nested structure, so we need to read the string and start a new decoder.
there are legacy reasons for why its done this way, but they are kinda boring.
this is a helper to initialize a new decoder from a string at current location. we need it once now. there are more keys in the wild that have similar structure, so it might be helpful in general.
im not tied to this, it was just simpler without having to expose allocator for decoder.
source/unix/opensslcrypto_ecc.c
Outdated
| return AWS_OP_SUCCESS; | ||
|
|
||
| on_error: | ||
| EC_POINT_free(point); |
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.
Loos like our previous logic has a null protection, but not here.
According to Google AI summary:
Safe to use: You can pass NULL to BN_free() without any risk. It is a safe operation, [says the Ubuntu Manpage](https://manpages.ubuntu.com/manpages/noble/man3/BN_clear_free.3ssl.html).
Wow, the doc it linked seems legit.
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.
openssl is kinda inconsistent about those. those 3 frees are fine and can handle null (ex. https://github.com/aws/aws-lc/blob/0fed4dbc456406bdaf7158fd55d05a52d9998ce4/crypto/fipsmodule/ec/ec.c#L595 and similar in openssl).
but let me add null check just for consistency cause we usually check.
Co-authored-by: Dengke Tang <[email protected]>
Issue #, if available:
Description of changes:
Replace the logic of iterating through the asn1 structure looking for fields that seem to match expected ec key, with approach of looking for several concrete key structures.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.