Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
4 changes: 2 additions & 2 deletions source/pem.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ static struct aws_byte_cursor s_pem_type_private_rsa_pkcs1_cur =
AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("RSA PRIVATE KEY");
static struct aws_byte_cursor s_pem_type_public_rsa_pkcs1_cur = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("RSA PUBLIC KEY");
static struct aws_byte_cursor s_pem_type_private_dsa_pkcs1_cur =
AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("RSA PRIVATE KEY");
static struct aws_byte_cursor s_pem_type_public_dsa_pkcs1_cur = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("RSA PUBLIC KEY");
AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("DSA PRIVATE KEY");
static struct aws_byte_cursor s_pem_type_public_dsa_pkcs1_cur = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("DSA PUBLIC KEY");
static struct aws_byte_cursor s_pem_type_pkcs7_cur = AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("PKCS7");
static struct aws_byte_cursor s_pem_type_pkcs7_signed_data_cur =
AWS_BYTE_CUR_INIT_FROM_STRING_LITERAL("PKCS #7 SIGNED DATA");
Expand Down
2 changes: 2 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ add_test_case(test_resolver_low_frequency_starvation)

add_test_case(test_pem_single_cert_parse)
add_test_case(test_pem_private_key_parse)
add_test_case(test_pem_dsa_private_key_parse)
add_test_case(test_pem_dsa_public_key_parse)
add_test_case(test_pem_cert_chain_parse)
add_test_case(test_pem_cert_parse_from_file)
add_test_case(test_pem_cert_parse_from_file_crlf)
Expand Down
44 changes: 44 additions & 0 deletions tests/pem_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,50 @@ static int s_test_pem_private_key_parse(struct aws_allocator *allocator, void *c
}
AWS_TEST_CASE(test_pem_private_key_parse, s_test_pem_private_key_parse)

static int s_test_pem_dsa_private_key_parse(struct aws_allocator *allocator, void *ctx) {
(void)ctx;
static const char *s_private_key_pem = "-----BEGIN DSA PRIVATE KEY-----\n"
"-----END DSA PRIVATE KEY-----";

struct aws_byte_cursor pem_data = aws_byte_cursor_from_c_str(s_private_key_pem);
struct aws_array_list output_list;

ASSERT_SUCCESS(aws_pem_objects_init_from_file_contents(&output_list, allocator, pem_data));
ASSERT_UINT_EQUALS(1, aws_array_list_length(&output_list));

struct aws_pem_object *pem_object = NULL;
aws_array_list_get_at_ptr(&output_list, (void **)&pem_object, 0);
ASSERT_CURSOR_VALUE_CSTRING_EQUALS(aws_byte_cursor_from_string(pem_object->type_string), "DSA PRIVATE KEY");
ASSERT_INT_EQUALS(AWS_PEM_TYPE_PRIVATE_DSA_PKCS1, pem_object->type);

aws_pem_objects_clean_up(&output_list);

return AWS_OP_SUCCESS;
}
AWS_TEST_CASE(test_pem_dsa_private_key_parse, s_test_pem_dsa_private_key_parse)

static int s_test_pem_dsa_public_key_parse(struct aws_allocator *allocator, void *ctx) {
(void)ctx;
static const char *s_public_key_pem = "-----BEGIN DSA PUBLIC KEY-----\n"
"-----END DSA PUBLIC KEY-----";

struct aws_byte_cursor pem_data = aws_byte_cursor_from_c_str(s_public_key_pem);
struct aws_array_list output_list;

ASSERT_SUCCESS(aws_pem_objects_init_from_file_contents(&output_list, allocator, pem_data));
ASSERT_UINT_EQUALS(1, aws_array_list_length(&output_list));

struct aws_pem_object *pem_object = NULL;
aws_array_list_get_at_ptr(&output_list, (void **)&pem_object, 0);
ASSERT_CURSOR_VALUE_CSTRING_EQUALS(aws_byte_cursor_from_string(pem_object->type_string), "DSA PUBLIC KEY");
ASSERT_INT_EQUALS(AWS_PEM_TYPE_PUBLIC_DSA_PKCS1, pem_object->type);

aws_pem_objects_clean_up(&output_list);

return AWS_OP_SUCCESS;
}
AWS_TEST_CASE(test_pem_dsa_public_key_parse, s_test_pem_dsa_public_key_parse)

static int s_test_pem_cert_chain_comments_and_whitespace(struct aws_allocator *allocator, void *ctx) {
(void)ctx;

Expand Down
Loading