
A lightweight and fast ASN.1 encoder/decoder prototype library written in C, with no external dependencies.
If not enabled all logging macros expand to empty loops and will be removed from the binary.
Filter debug messages at runtime to prevent verbose screen
Abstracts mutex locking to ensure log messages don't get scrambled when accessed by multiple threads.
Define Log Levels, the macros will remove unused logging functions from runtime.
Use context instances, allow different parts of your program to have different log levels.
Log to one ore more files as astream simultaneously and independentily withouth any issues
asn1_encoder_t ctx;
asn1_encoder_init(&ctx, buffer, sizeof(buffer));
const uint8_t hello_str[] = "hello";
asn1_encode_octet_string(&ctx, hello_str, sizeof(hello_str) - 1);
asn1_encode_integer(&ctx, -123);
size_t content_len = sizeof(buffer) - ctx.current_pos;
asn1_encode_tag_and_length(&ctx, ASN1_TAG_SEQUENCE, content_len);
const uint8_t* data = asn1_encoder_get_data(&ctx, &final_len);
Create the sender and reciever tasks, create the scheduler with a tickrate of 1 ms . Pass the reciever task handle as user data to the sender task. The sender task is now “aware” of the recievers taskhandle and can send messages
asn1_decoder_t ctx;
asn1_decoder_init(&ctx, encoded_data, final_len);
asn1_decoder_t seq_ctx;
asn1_decoder_enter_constructed(&ctx, &seq_ctx, ASN1_TAG_SEQUENCE);
int64_t int_val;
asn1_decode_integer(&seq_ctx, &int_val);
const uint8_t* str_data;
size_t str_len;
asn1_decode_string_like(&seq_ctx, ASN1_TAG_OCTET_STRING, &str_data, &str_len);
Dereference the reciever task handle from user data. Create a static stack variable and send data to the reciever using its dereferenced taskhandle.
asn1_error_t err = x509_parse_and_print_certificate(
github_der,
sizeof(github_der),
0
);