Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f424086
cleanup ec loading
DmitriyMusatkin Oct 10, 2025
d9ad56a
fix
DmitriyMusatkin Oct 13, 2025
46b8cf8
test and win build fix
DmitriyMusatkin Oct 13, 2025
9329072
lint
DmitriyMusatkin Oct 13, 2025
04de02c
test fix
DmitriyMusatkin Oct 13, 2025
e1022e4
fix
DmitriyMusatkin Oct 13, 2025
dfb363a
Add codecov
DmitriyMusatkin Oct 13, 2025
d55902c
wrong name
DmitriyMusatkin Oct 13, 2025
33df892
docs
DmitriyMusatkin Oct 13, 2025
cffe68d
Merge branch 'main' into ec_pkcs8
DmitriyMusatkin Oct 13, 2025
0b6a6d3
add pkcs8 parsing test
DmitriyMusatkin Oct 13, 2025
21deb54
address comments
DmitriyMusatkin Oct 14, 2025
0e9cbd5
small refactor
DmitriyMusatkin Oct 14, 2025
0330000
test fix
DmitriyMusatkin Oct 14, 2025
aa69808
zero
DmitriyMusatkin Oct 14, 2025
04c33c9
loggin:
DmitriyMusatkin Oct 14, 2025
398dca0
revert
DmitriyMusatkin Oct 14, 2025
853480d
fix lc
DmitriyMusatkin Oct 14, 2025
d1d2990
gen pub if missing
DmitriyMusatkin Oct 14, 2025
622aa13
remove for now
DmitriyMusatkin Oct 14, 2025
07cc6a8
logs
DmitriyMusatkin Oct 14, 2025
b9515f5
set pub
DmitriyMusatkin Oct 14, 2025
c35d64a
fix and lint
DmitriyMusatkin Oct 14, 2025
7b9a83d
typo
DmitriyMusatkin Oct 14, 2025
ac70d69
restore advance fix
DmitriyMusatkin Oct 15, 2025
efbb69e
Update source/unix/opensslcrypto_ecc.c
DmitriyMusatkin Oct 16, 2025
cbd51fb
addressing comments
DmitriyMusatkin Oct 16, 2025
255dfd7
address comments
DmitriyMusatkin Oct 16, 2025
f05bd77
Merge branch 'main' into ec_pkcs8
DmitriyMusatkin Oct 16, 2025
160e398
error preconditions
DmitriyMusatkin Oct 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Code coverage check

on:
push:

env:
BUILDER_VERSION: v0.9.74
BUILDER_SOURCE: releases
BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net
PACKAGE_NAME: aws-c-cal
RUN: ${{ github.run_id }}-${{ github.run_number }}
CRT_CI_ROLE: ${{ secrets.CRT_CI_ROLE_ARN }}
AWS_DEFAULT_REGION: us-east-1

permissions:
id-token: write # This is required for requesting the JWT

jobs:
codecov-linux:
runs-on: ubuntu-24.04
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Checkout Sources
uses: actions/checkout@v4
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
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
Comment on lines +30 to +32
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.

19 changes: 19 additions & 0 deletions include/aws/cal/private/der.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ enum aws_der_type {
/* forms */
AWS_DER_FORM_CONSTRUCTED = 0x20,
AWS_DER_FORM_PRIMITIVE = 0x00,

/* context specific */
/* TODO: we should probably handle tags more generically, but for now first 2 tags cover all cases. */
AWS_DER_CONTEXT_SPECIFIC_TAG0 = 0xa0,
AWS_DER_CONTEXT_SPECIFIC_TAG1 = 0xa1,
};

AWS_EXTERN_C_BEGIN
Expand Down Expand Up @@ -164,6 +169,14 @@ AWS_CAL_API int aws_der_encoder_get_contents(struct aws_der_encoder *encoder, st
*/
AWS_CAL_API struct aws_der_decoder *aws_der_decoder_new(struct aws_allocator *allocator, struct aws_byte_cursor input);

/**
* Initializes new decoder from string at the current location.
* Useful for cases where asn1 structure is nested inside another one, ex. ec pkcs8.
* @param decoder Current decoder
* @return Initialized decoder, or NULL
*/
AWS_CAL_API struct aws_der_decoder *aws_der_decoder_nested_tlv_decoder(struct aws_der_decoder *decoder);

/**
* Cleans up a DER encoder
* @param decoder The encoder to clean up
Expand All @@ -177,6 +190,12 @@ AWS_CAL_API void aws_der_decoder_destroy(struct aws_der_decoder *decoder);
*/
AWS_CAL_API bool aws_der_decoder_next(struct aws_der_decoder *decoder);

/**
* Resets der decoder to the start.
* @param decoder The decoder to reset
*/
AWS_CAL_API void aws_der_decoder_reset(struct aws_der_decoder *decoder);

/**
* The type of the current TLV
* @param decoder The decoder to inspect
Expand Down
10 changes: 8 additions & 2 deletions include/aws/cal/private/ecc.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ struct aws_der_decoder;

AWS_EXTERN_C_BEGIN

/*
* Helper to load keypair from various ASN1 format.
* Note: there are several formats in the wild: Sec1 and PKCS8 for private key and X509 for public key.
* This function attempts to automatically recognize the format and load from it.
* Depending on data available in the asn, either private or public key might be empty (zeroed out).
*/
AWS_CAL_API int aws_der_decoder_load_ecc_key_pair(
struct aws_der_decoder *decoder,
struct aws_byte_cursor *out_public_x_coor,
struct aws_byte_cursor *out_public_y_coor,
struct aws_byte_cursor *out_public_x_coord,
struct aws_byte_cursor *out_public_y_coord,
struct aws_byte_cursor *out_private_d,
enum aws_ecc_curve_name *out_curve_name);

Expand Down
13 changes: 13 additions & 0 deletions source/der.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,15 @@ struct aws_der_decoder *aws_der_decoder_new(struct aws_allocator *allocator, str
return NULL;
}

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 NULL;
}
return aws_der_decoder_new(decoder->allocator, cursor);
}

void aws_der_decoder_destroy(struct aws_der_decoder *decoder) {
if (!decoder) {
return;
Expand Down Expand Up @@ -467,6 +476,10 @@ bool aws_der_decoder_next(struct aws_der_decoder *decoder) {
return (++decoder->tlv_idx < (int)decoder->tlvs.length);
}

void aws_der_decoder_reset(struct aws_der_decoder *decoder) {
decoder->tlv_idx = -1;
}

static struct der_tlv s_decoder_tlv(struct aws_der_decoder *decoder) {
AWS_FATAL_ASSERT(decoder->tlv_idx < (int)decoder->tlvs.length);
struct der_tlv tlv = {0};
Expand Down
Loading