Skip to content

Conversation

@DmitriyMusatkin
Copy link
Contributor

@DmitriyMusatkin DmitriyMusatkin commented Oct 13, 2025

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.

Comment on lines +30 to +32
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
Copy link
Contributor

@TingDaoK TingDaoK Oct 13, 2025

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.

@codecov-commenter
Copy link

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);
Copy link
Contributor

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

Copy link
Contributor Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

else we ignore it?

Copy link
Contributor Author

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)) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

return AWS_OP_SUCCESS;

on_error:
EC_POINT_free(point);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@DmitriyMusatkin DmitriyMusatkin merged commit 5fa1cd7 into main Oct 16, 2025
58 checks passed
@DmitriyMusatkin DmitriyMusatkin deleted the ec_pkcs8 branch October 16, 2025 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants