/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include #include static int s_test_pem_single_cert_parse(struct aws_allocator *allocator, void *ctx) { (void)ctx; static const char *s_rsa_1024_sha224_client_crt_pem = "-----BEGIN CERTIFICATE-----\n" "MIICeDCCAeGgAwIBAgIJAObttnPKQhVlMA0GCSqGSIb3DQEBDgUAMF8xCzAJBgNV\n" "BAYTAlVTMQswCQYDVQQIDAJXQTEQMA4GA1UEBwwHU2VhdHRsZTEPMA0GA1UECgwG\n" "QW1hem9uMQwwCgYDVQQLDANzMm4xEjAQBgNVBAMMCWxvY2FsaG9zdDAgFw0xNzA4\n" "MDEyMjQzMzJaGA8yMTE3MDcwODIyNDMzMlowXzELMAkGA1UEBhMCVVMxCzAJBgNV\n" "BAgMAldBMRAwDgYDVQQHDAdTZWF0dGxlMQ8wDQYDVQQKDAZBbWF6b24xDDAKBgNV\n" "BAsMA3MybjESMBAGA1UEAwwJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GN\n" "ADCBiQKBgQCisRoXXcTh4ejn/sUjGosLlE7GlpLGtvWFEEX6Vl3klVoQdkyabLIH\n" "7bHB2P7uyt9bPzeqvWYjuepDBSQUUeb6Mkqfx237bTy8JhXIfpIhbgksTk7IPzgo\n" "XLPl1oNl7uB9HQaDQ7UPlaKbfp1gNvs6uGOH4vvyhhJGiblNJKnVwwIDAQABozow\n" "ODALBgNVHQ8EBAMCBDAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwFAYDVR0RBA0wC4IJ\n" "MTI3LjAuMC4xMA0GCSqGSIb3DQEBDgUAA4GBACleH44LSYhzHHaV70VbnLbtbv8T\n" "eaUvzstFW6YvdP1XnZKssZNdvMhoiMuMD5n40/iPbv+grtjxacRQCinLk1SEjpsu\n" "3lw90Ds0Ksd/Pdsv7d0cCiJkjadON+ZQEEJ2FP/G19KZFxC3GLk9sxIUXyUW0TXn\n" "YxwtPz26+xvPRWCS\n" "-----END CERTIFICATE-----"; static const uint8_t s_expected[] = { 0x30, 0x82, 0x02, 0x78, 0x30, 0x82, 0x01, 0xe1, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xe6, 0xed, 0xb6, 0x73, 0xca, 0x42, 0x15, 0x65, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0e, 0x05, 0x00, 0x30, 0x5f, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x57, 0x41, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x53, 0x65, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x06, 0x41, 0x6d, 0x61, 0x7a, 0x6f, 0x6e, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x03, 0x73, 0x32, 0x6e, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x20, 0x17, 0x0d, 0x31, 0x37, 0x30, 0x38, 0x30, 0x31, 0x32, 0x32, 0x34, 0x33, 0x33, 0x32, 0x5a, 0x18, 0x0f, 0x32, 0x31, 0x31, 0x37, 0x30, 0x37, 0x30, 0x38, 0x32, 0x32, 0x34, 0x33, 0x33, 0x32, 0x5a, 0x30, 0x5f, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x02, 0x57, 0x41, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x53, 0x65, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x06, 0x41, 0x6d, 0x61, 0x7a, 0x6f, 0x6e, 0x31, 0x0c, 0x30, 0x0a, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x03, 0x73, 0x32, 0x6e, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xa2, 0xb1, 0x1a, 0x17, 0x5d, 0xc4, 0xe1, 0xe1, 0xe8, 0xe7, 0xfe, 0xc5, 0x23, 0x1a, 0x8b, 0x0b, 0x94, 0x4e, 0xc6, 0x96, 0x92, 0xc6, 0xb6, 0xf5, 0x85, 0x10, 0x45, 0xfa, 0x56, 0x5d, 0xe4, 0x95, 0x5a, 0x10, 0x76, 0x4c, 0x9a, 0x6c, 0xb2, 0x07, 0xed, 0xb1, 0xc1, 0xd8, 0xfe, 0xee, 0xca, 0xdf, 0x5b, 0x3f, 0x37, 0xaa, 0xbd, 0x66, 0x23, 0xb9, 0xea, 0x43, 0x05, 0x24, 0x14, 0x51, 0xe6, 0xfa, 0x32, 0x4a, 0x9f, 0xc7, 0x6d, 0xfb, 0x6d, 0x3c, 0xbc, 0x26, 0x15, 0xc8, 0x7e, 0x92, 0x21, 0x6e, 0x09, 0x2c, 0x4e, 0x4e, 0xc8, 0x3f, 0x38, 0x28, 0x5c, 0xb3, 0xe5, 0xd6, 0x83, 0x65, 0xee, 0xe0, 0x7d, 0x1d, 0x06, 0x83, 0x43, 0xb5, 0x0f, 0x95, 0xa2, 0x9b, 0x7e, 0x9d, 0x60, 0x36, 0xfb, 0x3a, 0xb8, 0x63, 0x87, 0xe2, 0xfb, 0xf2, 0x86, 0x12, 0x46, 0x89, 0xb9, 0x4d, 0x24, 0xa9, 0xd5, 0xc3, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x3a, 0x30, 0x38, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03, 0x02, 0x04, 0x30, 0x30, 0x13, 0x06, 0x03, 0x55, 0x1d, 0x25, 0x04, 0x0c, 0x30, 0x0a, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x30, 0x14, 0x06, 0x03, 0x55, 0x1d, 0x11, 0x04, 0x0d, 0x30, 0x0b, 0x82, 0x09, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0e, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x29, 0x5e, 0x1f, 0x8e, 0x0b, 0x49, 0x88, 0x73, 0x1c, 0x76, 0x95, 0xef, 0x45, 0x5b, 0x9c, 0xb6, 0xed, 0x6e, 0xff, 0x13, 0x79, 0xa5, 0x2f, 0xce, 0xcb, 0x45, 0x5b, 0xa6, 0x2f, 0x74, 0xfd, 0x57, 0x9d, 0x92, 0xac, 0xb1, 0x93, 0x5d, 0xbc, 0xc8, 0x68, 0x88, 0xcb, 0x8c, 0x0f, 0x99, 0xf8, 0xd3, 0xf8, 0x8f, 0x6e, 0xff, 0xa0, 0xae, 0xd8, 0xf1, 0x69, 0xc4, 0x50, 0x0a, 0x29, 0xcb, 0x93, 0x54, 0x84, 0x8e, 0x9b, 0x2e, 0xde, 0x5c, 0x3d, 0xd0, 0x3b, 0x34, 0x2a, 0xc7, 0x7f, 0x3d, 0xdb, 0x2f, 0xed, 0xdd, 0x1c, 0x0a, 0x22, 0x64, 0x8d, 0xa7, 0x4e, 0x37, 0xe6, 0x50, 0x10, 0x42, 0x76, 0x14, 0xff, 0xc6, 0xd7, 0xd2, 0x99, 0x17, 0x10, 0xb7, 0x18, 0xb9, 0x3d, 0xb3, 0x12, 0x14, 0x5f, 0x25, 0x16, 0xd1, 0x35, 0xe7, 0x63, 0x1c, 0x2d, 0x3f, 0x3d, 0xba, 0xfb, 0x1b, 0xcf, 0x45, 0x60, 0x92}; struct aws_byte_cursor pem_data = aws_byte_cursor_from_c_str(s_rsa_1024_sha224_client_crt_pem); struct aws_array_list output_list; ASSERT_SUCCESS(aws_array_list_init_dynamic(&output_list, allocator, 1, sizeof(struct aws_byte_buf))); ASSERT_SUCCESS(aws_decode_pem_to_buffer_list(allocator, &pem_data, &output_list)); ASSERT_UINT_EQUALS(1, aws_array_list_length(&output_list)); struct aws_byte_buf *cert_data = NULL; aws_array_list_get_at_ptr(&output_list, (void **)&cert_data, 0); ASSERT_BIN_ARRAYS_EQUALS(s_expected, sizeof(s_expected), cert_data->buffer, cert_data->len); aws_cert_chain_clean_up(&output_list); aws_array_list_clean_up(&output_list); return AWS_OP_SUCCESS; } AWS_TEST_CASE(test_pem_single_cert_parse, s_test_pem_single_cert_parse) static int s_test_pem_cert_chain_parse(struct aws_allocator *allocator, void *ctx) { (void)ctx; static const char *s_rsa_2048_pkcs1_crt_pem = "-----BEGIN CERTIFICATE-----\n" "MIICrTCCAZUCAn3VMA0GCSqGSIb3DQEBBQUAMB4xHDAaBgNVBAMME3MyblRlc3RJ\n" "bnRlcm1lZGlhdGUwIBcNMTYwMzMwMTg1NzQzWhgPMjExNjAzMDYxODU3NDNaMBgx\n" "FjAUBgNVBAMMDXMyblRlc3R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DMzMDE4NTYzOVoYDzIxMTYwMzA2MTg1NjM5\n" "WjAWMRQwEgYDVQQDDAtzMm5UZXN0Um9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEP\n" "ADCCAQoCggEBAMY5532000oaeed7Jmo3ssx1723ZDLpn3WGz6FxpWM0zsKA/YvdD\n" "7J6qXDvfxU6dZlmsCS+bSNAqpARKmKsBEDPTsdLmrN1V1clOxvKm6GvU1eloRTw6\n" "xukEUXJ+uxrQMLYvSJBiCBVGI+UYNCK5c6guNMRYBCGdk5/iayjmK0Nxz1918Cx9\n" "z4va8HPAgYIz0ogOdYB21O9FQGPdH1mYqRzljcSsZ7EFo1P8HJr8oKK76ZeYi2or\n" "pjzMHGnlufHaul508wQPeFAMa1Tku3HyGZRaieRAck6+QcO2NujXxKNyCBlWON23\n" "FQTuBjN/CAl74MZtcAM2hVSmpm9t4cWVN5MCAwEAAaNQME4wHQYDVR0OBBYEFE2X\n" "AbNDryMlBpMNI6Ce927uUFwTMB8GA1UdIwQYMBaAFE2XAbNDryMlBpMNI6Ce927u\n" "UFwTMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAAXkVvQdXDmozPix\n" "uZi1o9cw4Si0syqfJ4sSunrzPbbmw/Qxhth5V7XGrnsQVNxamgnbzpjGhiBF6isM\n" "ldj33zQYtke+ojOjFlhEvrPo6eW29RkLBEtJadGs2bkMLztJbf+cbH2u6irzr6S4\n" "3OgVOSuB+zG56ksTnEVmum+C/8tSIAyi3eaoStPcgEU8+3/KMrH7uuenmTOCKdD1\n" "FvSDHXT9qPgTttVQGXbXzJEr5tGE+Py6yib5uoJ0dJZNtjs7HOQEDk5J0wZaX0DC\n" "MShYLiN5qLJAk0qwl+js488BJ18M9dg4TxdBYFkwHSzKXSj9TJN77Bb0RZr8LL9T\n" "r9IyvfU=\n" "-----END CERTIFICATE-----"; static const uint8_t s_expected_intermediate_1[] = { 0x30, 0x82, 0x02, 0xad, 0x30, 0x82, 0x01, 0x95, 0x02, 0x02, 0x7d, 0xd5, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x1e, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x13, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x30, 0x20, 0x17, 0x0d, 0x31, 0x36, 0x30, 0x33, 0x33, 0x30, 0x31, 0x38, 0x35, 0x37, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x32, 0x31, 0x31, 0x36, 0x30, 0x33, 0x30, 0x36, 0x31, 0x38, 0x35, 0x37, 0x34, 0x33, 0x5a, 0x30, 0x18, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0d, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xd1, 0xc3, 0xa0, 0x2e, 0x61, 0x70, 0x1e, 0x45, 0x3d, 0x18, 0xba, 0x9b, 0x42, 0x7c, 0x98, 0xd1, 0x07, 0xf1, 0x03, 0x27, 0x2c, 0x86, 0x5e, 0x7b, 0xfe, 0xf1, 0x35, 0x76, 0x1f, 0x55, 0x89, 0x5a, 0x13, 0x0b, 0x93, 0xca, 0x8d, 0x0f, 0x6e, 0xeb, 0xef, 0xd0, 0x3a, 0x12, 0x36, 0xd5, 0x98, 0x96, 0x8e, 0x57, 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x06, 0x9d, 0x86, 0xac, 0xb0, 0x4e, 0x74, 0x39, 0x87, 0xbb, 0x0d, 0x07, 0x01, 0xe3, 0x3b, 0xe7, 0xc6, 0x60, 0x17, 0xa7, 0x9d, 0x49, 0x20, 0xde, 0x28, 0xa2, 0x4b, 0x54, 0x53, 0xda, 0x0a, 0x20, 0xce, 0x72, 0xd9, 0xc8, 0x04, 0x59, 0xd9, 0x89, 0xcd, 0xea, 0x8f, 0x00, 0xd6, 0x31, 0x7f, 0x46, 0x48, 0x3e, 0x54, 0xe0, 0x11, 0x39, 0x27, 0x2b, 0x0d, 0x43, 0xcd, 0xff, 0x30, 0x94, 0xae, 0x66, 0x15, 0xb6, 0xc6, 0xe0, 0xb3, 0xd0, 0x87, 0x59, 0xa4, 0x0d, 0x57, 0x30, 0x41, 0x5d, 0xe8, 0x80, 0x6e, 0xa4, 0x18, 0xc4, 0x5a, 0xee, 0x77, 0x87, 0xfb, 0xa4, 0x85, 0x90, 0xda, 0x40, 0x2a, 0xe3, 0xc2, 0xa2, 0x37, 0xb8, 0x34, 0x01, 0x3e, 0x59, 0x0e, 0x6f, 0x7b, 0x5c, 0x24, 0xee, 0x72, 0x11, 0x4d, 0x0c, 0x03, 0x00, 0x5e}; static const uint8_t s_expected_intermediate_2[] = { 0x30, 0x82, 0x03, 0x29, 0x30, 0x82, 0x02, 0x11, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x57, 0x16, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x16, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0b, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x30, 0x20, 0x17, 0x0d, 0x31, 0x36, 0x30, 0x33, 0x33, 0x30, 0x31, 0x38, 0x35, 0x37, 0x30, 0x39, 0x5a, 0x18, 0x0f, 0x32, 0x31, 0x31, 0x36, 0x30, 0x33, 0x30, 0x36, 0x31, 0x38, 0x35, 0x37, 0x30, 0x39, 0x5a, 0x30, 0x1e, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x13, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xcc, 0xfe, 0x2d, 0xde, 0x72, 0x5c, 0x58, 0x72, 0xf7, 0x9d, 0x3c, 0x21, 0x27, 0x55, 0xee, 0x80, 0xfc, 0x76, 0x2c, 0x60, 0xf7, 0x8f, 0xd6, 0xa2, 0x81, 0x65, 0x08, 0x5b, 0xa6, 0xeb, 0x97, 0xd3, 0xad, 0x63, 0x15, 0x92, 0xb0, 0x95, 0xe7, 0x1b, 0xd1, 0xe6, 0xae, 0xd4, 0xf3, 0x91, 0x2d, 0xb7, 0x2c, 0x60, 0xae, 0x34, 0xbb, 0x7c, 0x54, 0xce, 0x80, 0x39, 0xbb, 0xa4, 0x34, 0x79, 0xb0, 0xee, 0xa8, 0xf6, 0xea, 0x48, 0x99, 0x02, 0x6b, 0x3b, 0x21, 0xeb, 0xa7, 0x2e, 0xf5, 0x24, 0xe5, 0xf2, 0xe6, 0xdb, 0x93, 0xba, 0x08, 0xf0, 0xb2, 0x63, 0x50, 0x91, 0x61, 0x87, 0x2d, 0x89, 0x9a, 0x6f, 0x64, 0xad, 0x78, 0x4f, 0xc9, 0x1b, 0x1c, 0x53, 0xe0, 0x97, 0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x94, 0x29, 0x55, 0x95, 0x94, 0xbd, 0x37, 0xb0, 0x7b, 0x8e, 0x82, 0x01, 0x40, 0x09, 0xd9, 0x47, 0x72, 0x43, 0xc1, 0x30, 0x46, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x3f, 0x30, 0x3d, 0x80, 0x14, 0x4d, 0x97, 0x01, 0xb3, 0x43, 0xaf, 0x23, 0x25, 0x06, 0x93, 0x0d, 0x23, 0xa0, 0x9e, 0xf7, 0x6e, 0xee, 0x50, 0x5c, 0x13, 0xa1, 0x1a, 0xa4, 0x18, 0x30, 0x16, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0b, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x82, 0x09, 0x00, 0xd0, 0xd4, 0x90, 0x7f, 0x94, 0x61, 0xdc, 0xf5, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x37, 0x3b, 0x74, 0xbd, 0x55, 0x3d, 0x04, 0x0b, 0x5c, 0x86, 0xe3, 0x1c, 0x8d, 0x35, 0x46, 0x7b, 0xf8, 0x2c, 0xc5, 0xb8, 0x50, 0x3a, 0xba, 0x23, 0xb7, 0xf3, 0x28, 0x1c, 0x37, 0x93, 0x73, 0xd6, 0x83, 0x4f, 0xcb, 0x67, 0x90, 0x7a, 0xbe, 0xef, 0x62, 0x6a, 0xc7, 0xb6, 0xa3, 0x7a, 0x81, 0x2f, 0xe8, 0xd4, 0x08, 0x39, 0x17, 0xc6, 0xcb, 0x44, 0x2a, 0x9e, 0xb9, 0x94, 0xec, 0x38, 0x6f, 0x34, 0x3b, 0x6f, 0x47, 0x90, 0xd8, 0x6c, 0xe7, 0x16, 0x29, 0xad, 0xd5, 0x3c, 0xd8, 0x0a, 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, 0x03, 0x01, 0x30, 0x82, 0x01, 0xe9, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xd0, 0xd4, 0x90, 0x7f, 0x94, 0x61, 0xdc, 0xf5, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x16, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0b, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x30, 0x20, 0x17, 0x0d, 0x31, 0x36, 0x30, 0x33, 0x33, 0x30, 0x31, 0x38, 0x35, 0x36, 0x33, 0x39, 0x5a, 0x18, 0x0f, 0x32, 0x31, 0x31, 0x36, 0x30, 0x33, 0x30, 0x36, 0x31, 0x38, 0x35, 0x36, 0x33, 0x39, 0x5a, 0x30, 0x16, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0b, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xc6, 0x39, 0xe7, 0x7d, 0xb4, 0xd3, 0x4a, 0x1a, 0x79, 0xe7, 0x7b, 0x26, 0x6a, 0x37, 0xb2, 0xcc, 0x75, 0xef, 0x6d, 0xd9, 0x0c, 0xba, 0x67, 0xdd, 0x61, 0xb3, 0xe8, 0x5c, 0x69, 0x58, 0xcd, 0x33, 0xb0, 0xa0, 0x3f, 0x62, 0xf7, 0x43, 0xec, 0x9e, 0xaa,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08, 0x19, 0x56, 0x38, 0xdd, 0xb7, 0x15, 0x04, 0xee, 0x06, 0x33, 0x7f, 0x08, 0x09, 0x7b, 0xe0, 0xc6, 0x6d, 0x70, 0x03, 0x36, 0x85, 0x54, 0xa6, 0xa6, 0x6f, 0x6d, 0xe1, 0xc5, 0x95, 0x37, 0x93, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x4d, 0x97, 0x01, 0xb3, 0x43, 0xaf, 0x23, 0x25, 0x06, 0x93, 0x0d, 0x23, 0xa0, 0x9e, 0xf7, 0x6e, 0xee, 0x50, 0x5c, 0x13, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x4d, 0x97, 0x01, 0xb3, 0x43, 0xaf, 0x23, 0x25, 0x06, 0x93, 0x0d, 0x23, 0xa0, 0x9e, 0xf7, 0x6e, 0xee, 0x50, 0x5c, 0x13, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x05, 0xe4, 0x56, 0xf4, 0x1d, 0x5c, 0x39, 0xa8, 0xcc, 0xf8, 0xb1, 0xb9, 0x98, 0xb5, 0xa3, 0xd7, 0x30, 0xe1, 0x28, 0xb4, 0xb3, 0x2a, 0x9f, 0x27, 0x8b, 0x12, 0xba, 0x7a, 0xf3, 0x3d, 0xb6, 0xe6, 0xc3, 0xf4, 0x31, 0x86, 0xd8, 0x79, 0x57, 0xb5, 0xc6, 0xae, 0x7b, 0x10, 0x54, 0xdc, 0x5a, 0x9a, 0x09, 0xdb, 0xce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0xca, 0x5d, 0x28, 0xfd, 0x4c, 0x93, 0x7b, 0xec, 0x16, 0xf4, 0x45, 0x9a, 0xfc, 0x2c, 0xbf, 0x53, 0xaf, 0xd2, 0x32, 0xbd, 0xf5, }; struct aws_byte_cursor pem_data = aws_byte_cursor_from_c_str(s_rsa_2048_pkcs1_crt_pem); struct aws_array_list output_list; ASSERT_SUCCESS(aws_array_list_init_dynamic(&output_list, allocator, 1, sizeof(struct aws_byte_buf))); ASSERT_SUCCESS(aws_decode_pem_to_buffer_list(allocator, &pem_data, &output_list)); ASSERT_UINT_EQUALS(3, aws_array_list_length(&output_list)); struct aws_byte_buf *cert_data = NULL; aws_array_list_get_at_ptr(&output_list, (void **)&cert_data, 0); ASSERT_BIN_ARRAYS_EQUALS( s_expected_intermediate_1, sizeof(s_expected_intermediate_1), cert_data->buffer, cert_data->len); aws_array_list_get_at_ptr(&output_list, (void **)&cert_data, 1); ASSERT_BIN_ARRAYS_EQUALS( s_expected_intermediate_2, sizeof(s_expected_intermediate_2), cert_data->buffer, cert_data->len); aws_array_list_get_at_ptr(&output_list, (void **)&cert_data, 2); ASSERT_BIN_ARRAYS_EQUALS(s_expected_leaf, sizeof(s_expected_leaf), cert_data->buffer, cert_data->len); aws_cert_chain_clean_up(&output_list); aws_array_list_clean_up(&output_list); return AWS_OP_SUCCESS; } AWS_TEST_CASE(test_pem_cert_chain_parse, s_test_pem_cert_chain_parse) static int s_test_pem_private_key_parse(struct aws_allocator *allocator, void *ctx) { (void)ctx; static const char *s_private_key_pem = "-----BEGIN RSA PRIVATE KEY-----\n" "MIIEpAIBAAKCAQEA12pXSPgORAMlQtYRbxuz/Ocaoran3C2Fjyjhu0vucSEZSwxD\n" "Jp75TBQEMafSpSEKAQLeDt7xuDRDYn52V4UE6cF+xTWhtzsf7mhN/lHaDPcvR2AS\n" "PAEkzkil8KCLY4e6tTxSwQ97splNuEZ099HoJYTTLFaReIfd1D3zZ1EYcSw8w+GZ\n" "2SxEUfYUSL2CFmIY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RDdHgE2P75ER/zm8CgYEArAxx6bepT3syIWiYww3itYBJofS26zP9++Zs\n" "T9rX5hT5IbMo5vwIJqO0+mDVrwQfu9Wc7vnwjhm+pEy4qfPW6Hn7SNppxnY6itZo\n" "J4/azOIeaM92B5h3Pv0gxBFK8YyjO8beXurx+79ENuOtfFxd8knOe/Mplcnpurjt\n" "SeVJuG8CgYBxEYouOM9UuZlblXQXfudTWWf+x5CEWxyJgKaktHEh3iees1gB7ZPb\n" "OewLa8AYVjqbNgS/r/aUFjpBbCov8ICxcy86SuGda10LDFX83sbyMm8XhktfyC3L\n" "54irVW5mNUDcA8s9+DloeTlUlJIr8J/RADC9rpqHLaZzcdvpIMhVsw==\n" "-----END RSA PRIVATE KEY-----"; static const uint8_t s_expected[] = { 0x30, 0x82, 0x04, 0xa4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xd7, 0x6a, 0x57, 0x48, 0xf8, 0x0e, 0x44, 0x03, 0x25, 0x42, 0xd6, 0x11, 0x6f, 0x1b, 0xb3, 0xfc, 0xe7, 0x1a, 0xa2, 0xb6, 0xa7, 0xdc, 0x2d, 0x85, 0x8f, 0x28, 0xe1, 0xbb, 0x4b, 0xee, 0x71, 0x21, 0x19, 0x4b, 0x0c, 0x43, 0x26, 0x9e, 0xf9, 0x4c, 0x14, 0x04, 0x31, 0xa7, 0xd2, 0xa5, 0x21, 0x0a, 0x01, 0x02, 0xde, 0x0e, 0xde, 0xf1, 0xb8, 0x34, 0x43, 0x62, 0x7e, 0x76, 0x57, 0x85, 0x04, 0xe9, 0xc1, 0x7e, 0xc5, 0x35, 0xa1, 0xb7, 0x3b, 0x1f, 0xee, 0x68, 0x4d, 0xfe, 0x51, 0xda, 0x0c, 0xf7, 0x2f, 0x47, 0x60, 0x12, 0x3c, 0x01, 0x24, 0xce, 0x48, 0xa5, 0xf0, 0xa0, 0x8b, 0x63, 0x87, 0xba, 0xb5, 0x3c, 0x52, 0xc1, 0x0f, 0x7b, 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0xfb, 0xbf, 0x44, 0x36, 0xe3, 0xad, 0x7c, 0x5c, 0x5d, 0xf2, 0x49, 0xce, 0x7b, 0xf3, 0x29, 0x95, 0xc9, 0xe9, 0xba, 0xb8, 0xed, 0x49, 0xe5, 0x49, 0xb8, 0x6f, 0x02, 0x81, 0x80, 0x71, 0x11, 0x8a, 0x2e, 0x38, 0xcf, 0x54, 0xb9, 0x99, 0x5b, 0x95, 0x74, 0x17, 0x7e, 0xe7, 0x53, 0x59, 0x67, 0xfe, 0xc7, 0x90, 0x84, 0x5b, 0x1c, 0x89, 0x80, 0xa6, 0xa4, 0xb4, 0x71, 0x21, 0xde, 0x27, 0x9e, 0xb3, 0x58, 0x01, 0xed, 0x93, 0xdb, 0x39, 0xec, 0x0b, 0x6b, 0xc0, 0x18, 0x56, 0x3a, 0x9b, 0x36, 0x04, 0xbf, 0xaf, 0xf6, 0x94, 0x16, 0x3a, 0x41, 0x6c, 0x2a, 0x2f, 0xf0, 0x80, 0xb1, 0x73, 0x2f, 0x3a, 0x4a, 0xe1, 0x9d, 0x6b, 0x5d, 0x0b, 0x0c, 0x55, 0xfc, 0xde, 0xc6, 0xf2, 0x32, 0x6f, 0x17, 0x86, 0x4b, 0x5f, 0xc8, 0x2d, 0xcb, 0xe7, 0x88, 0xab, 0x55, 0x6e, 0x66, 0x35, 0x40, 0xdc, 0x03, 0xcb, 0x3d, 0xf8, 0x39, 0x68, 0x79, 0x39, 0x54, 0x94, 0x92, 0x2b, 0xf0, 0x9f, 0xd1, 0x00, 0x30, 0xbd, 0xae, 0x9a, 0x87, 0x2d, 0xa6, 0x73, 0x71, 0xdb, 0xe9, 0x20, 0xc8, 0x55, 0xb3, }; 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_array_list_init_dynamic(&output_list, allocator, 1, sizeof(struct aws_byte_buf))); ASSERT_SUCCESS(aws_decode_pem_to_buffer_list(allocator, &pem_data, &output_list)); ASSERT_UINT_EQUALS(1, aws_array_list_length(&output_list)); struct aws_byte_buf *cert_data = NULL; aws_array_list_get_at_ptr(&output_list, (void **)&cert_data, 0); ASSERT_BIN_ARRAYS_EQUALS(s_expected, sizeof(s_expected), cert_data->buffer, cert_data->len); aws_cert_chain_clean_up(&output_list); aws_array_list_clean_up(&output_list); return AWS_OP_SUCCESS; } AWS_TEST_CASE(test_pem_private_key_parse, s_test_pem_private_key_parse) static int s_test_pem_cert_parse_from_file(struct aws_allocator *allocator, void *ctx) { (void)ctx; static const uint8_t s_expected[] = { 0x30, 0x82, 0x03, 0xec, 0x30, 0x82, 0x02, 0xd4, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0x84, 0x7d, 0x2e, 0xed, 0x4d, 0xfc, 0x26, 0x87, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x81, 0x9a, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x57, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x74, 0x6f, 0x6e, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x53, 0x65, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x06, 0x41, 0x6d, 0x61, 0x7a, 0x6f, 0x6e, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x04, 0x53, 0x44, 0x4b, 0x73, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x31, 0x30, 0x30, 0x2e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x21, 0x61, 0x77, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2d, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x40, 0x61, 0x6d, 0x61, 0x7a, 0x6f, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x36, 0x31, 0x36, 0x30, 0x36, 0x31, 0x37, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x32, 0x33, 0x30, 0x39, 0x31, 0x38, 0x30, 0x36, 0x31, 0x37, 0x30, 0x30, 0x5a, 0x30, 0x81, 0x9a, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x57, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x74, 0x6f, 0x6e, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x07, 0x53, 0x65, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x06, 0x41, 0x6d, 0x61, 0x7a, 0x6f, 0x6e, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x04, 0x53, 0x44, 0x4b, 0x73, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x31, 0x30, 0x30, 0x2e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x21, 0x61, 0x77, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2d, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x40, 0x61, 0x6d, 0x61, 0x7a, 0x6f, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xd7, 0x6a, 0x57, 0x48, 0xf8, 0x0e, 0x44, 0x03, 0x25, 0x42, 0xd6, 0x11, 0x6f, 0x1b, 0xb3, 0xfc, 0xe7, 0x1a, 0xa2, 0xb6, 0xa7, 0xdc, 0x2d, 0x85, 0x8f, 0x28, 0xe1, 0xbb, 0x4b, 0xee, 0x71, 0x21, 0x19, 0x4b, 0x0c, 0x43, 0x26, 0x9e, 0xf9, 0x4c, 0x14, 0x04, 0x31, 0xa7, 0xd2, 0xa5, 0x21, 0x0a, 0x01, 0x02, 0xde, 0x0e, 0xde, 0xf1, 0xb8, 0x34, 0x43, 0x62, 0x7e, 0x76, 0x57, 0x85, 0x04, 0xe9, 0xc1, 0x7e, 0xc5, 0x35, 0xa1, 0xb7, 0x3b, 0x1f, 0xee, 0x68, 0x4d, 0xfe, 0x51, 0xda, 0x0c, 0xf7, 0x2f, 0x47, 0x60, 0x12, 0x3c, 0x01, 0x24, 0xce, 0x48, 0xa5, 0xf0, 0xa0, 0x8b, 0x63, 0x87, 0xba, 0xb5, 0x3c, 0x52, 0xc1, 0x0f, 0x7b, 0xb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x55, 0x1d, 0x11, 0x04, 0x13, 0x30, 0x11, 0x82, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x87, 0x04, 0x7f, 0x00, 0x00, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x07, 0xb4, 0x9a, 0x48, 0x4e, 0x6d, 0x71, 0x32, 0xf4, 0x35, 0x89, 0xf5, 0xe1, 0xe8, 0x27, 0x5e, 0xe3, 0x51, 0x0d, 0x54, 0xf2, 0xde, 0x1e, 0x2f, 0x9a, 0x0d, 0xdd, 0x02, 0xd4, 0xce, 0x15, 0x93, 0x8b, 0xe6, 0x75, 0x77, 0xc2, 0x41, 0xf6, 0xbf, 0xfc, 0xac, 0x25, 0x96, 0xea, 0x80, 0x38, 0x68, 0xe2, 0xa5, 0x72, 0x9a, 0x31, 0xa2, 0x95, 0x43, 0xa9, 0x90, 0x39, 0x64, 0xe3, 0x6c, 0x29, 0x37, 0x0c, 0x7a, 0xb7, 0x18, 0x97, 0x47, 0x0e, 0x16, 0x79, 0x2f, 0x9a, 0x92, 0x7b, 0x51, 0xac, 0xe4, 0x4c, 0x70, 0xc2, 0xe4, 0xf3, 0x7f, 0x2b, 0x63, 0x53, 0x2c, 0x3b, 0xdb, 0xf1, 0xef, 0x84, 0xda, 0xf3, 0x71, 0x6c, 0x6e, 0xb8, 0x41, 0x48, 0xae, 0xb5, 0x12, 0x1b, 0x20, 0xec, 0xdf, 0xff, 0x9f, 0x2b, 0x2d, 0x66, 0x52, 0x0a, 0x72, 0x17, 0x99, 0xa5, 0x4d, 0x28, 0x29, 0x8a, 0x9c, 0xc8, 0x51, 0xd0, 0xe8, 0x5c, 0x42, 0x66, 0x3e, 0xef, 0x06, 0xda, 0x72, 0xea, 0xa8, 0x5a, 0x5a, 0x02, 0x0f, 0xa2, 0x68, 0x80, 0xa9, 0x9a, 0xa4, 0x30, 0x8c, 0x9e, 0x69, 0x75, 0xa5, 0x5c, 0x34, 0x8b, 0x71, 0x49, 0xe5, 0x3a, 0x1a, 0x74, 0xa9, 0x51, 0x86, 0xee, 0x06, 0xf9, 0x54, 0x37, 0x0c, 0xf6, 0x17, 0x8a, 0x1e, 0xc3, 0x54, 0x6d, 0xa9, 0x52, 0x4a, 0x2f, 0xf8, 0xd0, 0xe3, 0x56, 0xc2, 0x61, 0x14, 0xfd, 0x7c, 0x77, 0x2b, 0x5b, 0x8b, 0x93, 0x2c, 0x6e, 0x76, 0x46, 0xa9, 0x00, 0x34, 0x8d, 0x55, 0x42, 0x6a, 0xe2, 0x6b, 0xa3, 0xd8, 0xe6, 0x5a, 0x5b, 0x65, 0x98, 0xa8, 0xb1, 0x85, 0x01, 0x92, 0x42, 0xf4, 0xd6, 0x73, 0x4d, 0xc6, 0xf6, 0xf1, 0x34, 0x36, 0x16, 0x44, 0xc6, 0x09, 0xc7, 0x94, 0x46, 0x1c, 0x06, 0x94, 0x84, 0xa9, 0x4f, 0x41, 0x0b, 0x46, 0xa6, 0xb4, 0x48, 0x1a, 0x14, 0x45, }; struct aws_array_list output_list; ASSERT_SUCCESS(aws_array_list_init_dynamic(&output_list, allocator, 1, sizeof(struct aws_byte_buf))); ASSERT_SUCCESS(aws_read_and_decode_pem_file_to_buffer_list(allocator, "unittests.crt", &output_list)); ASSERT_UINT_EQUALS(1, aws_array_list_length(&output_list)); struct aws_byte_buf *cert_data = NULL; aws_array_list_get_at_ptr(&output_list, (void **)&cert_data, 0); ASSERT_BIN_ARRAYS_EQUALS(s_expected, sizeof(s_expected), cert_data->buffer, cert_data->len); aws_cert_chain_clean_up(&output_list); aws_array_list_clean_up(&output_list); return AWS_OP_SUCCESS; } AWS_TEST_CASE(test_pem_cert_parse_from_file, s_test_pem_cert_parse_from_file) static int s_test_pem_private_key_parse_from_file(struct aws_allocator *allocator, void *ctx) { (void)ctx; static const uint8_t s_expected[] = { 0x30, 0x82, 0x04, 0xa4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xd7, 0x6a, 0x57, 0x48, 0xf8, 0x0e, 0x44, 0x03, 0x25, 0x42, 0xd6, 0x11, 0x6f, 0x1b, 0xb3, 0xfc, 0xe7, 0x1a, 0xa2, 0xb6, 0xa7, 0xdc, 0x2d, 0x85, 0x8f, 0x28, 0xe1, 0xbb, 0x4b, 0xee, 0x71, 0x21, 0x19, 0x4b, 0x0c, 0x43, 0x26, 0x9e, 0xf9, 0x4c, 0x14, 0x04, 0x31, 0xa7, 0xd2, 0xa5, 0x21, 0x0a, 0x01, 0x02, 0xde, 0x0e, 0xde, 0xf1, 0xb8, 0x34, 0x43, 0x62, 0x7e, 0x76, 0x57, 0x85, 0x04, 0xe9, 0xc1, 0x7e, 0xc5, 0x35, 0xa1, 0xb7, 0x3b, 0x1f, 0xee, 0x68, 0x4d, 0xfe, 0x51, 0xda, 0x0c, 0xf7, 0x2f, 0x47, 0x60, 0x12, 0x3c, 0x01, 0x24, 0xce, 0x48, 0xa5, 0xf0, 0xa0, 0x8b, 0x63, 0x87, 0xba, 0xb5, 0x3c, 0x52, 0xc1, 0x0f, 0x7b, 0xb2, 0x99, 0x4d, 0xb8, 0x46, 0x74, 0xf7, 0xd1, 0xe8, 0x25, 0x84, 0xd3, 0x2c, 0x56, 0x91, 0x78, 0x87, 0xdd, 0xd4, 0x3d, 0xf3, 0x67, 0x51, 0x18, 0x71, 0x2c, 0x3c, 0xc3, 0xe1, 0x99, 0xd9, 0x2c, 0x44, 0x51, 0xf6, 0x14, 0x48, 0xbd, 0x82, 0x16, 0x62, 0x18, 0x4a, 0x44, 0x23, 0x9e, 0x5b, 0x09, 0x08, 0x8a, 0x42, 0xa0, 0x68, 0x03, 0x88, 0x10, 0x0f, 0x6c, 0x85, 0x09, 0x3b, 0x72, 0x96, 0x04, 0x35, 0xf4, 0x26, 0x01, 0x83, 0x6f,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39, 0xec, 0x0b, 0x6b, 0xc0, 0x18, 0x56, 0x3a, 0x9b, 0x36, 0x04, 0xbf, 0xaf, 0xf6, 0x94, 0x16, 0x3a, 0x41, 0x6c, 0x2a, 0x2f, 0xf0, 0x80, 0xb1, 0x73, 0x2f, 0x3a, 0x4a, 0xe1, 0x9d, 0x6b, 0x5d, 0x0b, 0x0c, 0x55, 0xfc, 0xde, 0xc6, 0xf2, 0x32, 0x6f, 0x17, 0x86, 0x4b, 0x5f, 0xc8, 0x2d, 0xcb, 0xe7, 0x88, 0xab, 0x55, 0x6e, 0x66, 0x35, 0x40, 0xdc, 0x03, 0xcb, 0x3d, 0xf8, 0x39, 0x68, 0x79, 0x39, 0x54, 0x94, 0x92, 0x2b, 0xf0, 0x9f, 0xd1, 0x00, 0x30, 0xbd, 0xae, 0x9a, 0x87, 0x2d, 0xa6, 0x73, 0x71, 0xdb, 0xe9, 0x20, 0xc8, 0x55, 0xb3, }; struct aws_array_list output_list; ASSERT_SUCCESS(aws_array_list_init_dynamic(&output_list, allocator, 1, sizeof(struct aws_byte_buf))); ASSERT_SUCCESS(aws_read_and_decode_pem_file_to_buffer_list(allocator, "unittests.key", &output_list)); ASSERT_UINT_EQUALS(1, aws_array_list_length(&output_list)); struct aws_byte_buf *cert_data = NULL; aws_array_list_get_at_ptr(&output_list, (void **)&cert_data, 0); ASSERT_BIN_ARRAYS_EQUALS(s_expected, sizeof(s_expected), cert_data->buffer, cert_data->len); aws_cert_chain_clean_up(&output_list); aws_array_list_clean_up(&output_list); return AWS_OP_SUCCESS; } AWS_TEST_CASE(test_pem_private_key_parse_from_file, s_test_pem_private_key_parse_from_file) static int s_test_pem_cert_chain_comments_and_whitespace(struct aws_allocator *allocator, void *ctx) { (void)ctx; static const char *s_pem_data_str = "# -----Comment\n" "// Style\n" "/* from */\n" "''' multiple\n" "!* languages\n" "\n" "-----BEGIN CERTIFICATE-----\n" "MIICrTCCAZUCAn3VMA0GCSqGSIb3DQEBBQUAMB4xHDAa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ShYLiN5qLJAk0qwl+js488BJ18M9dg4TxdBYFkwHSzKXSj9TJN77Bb0RZr8LL9T\n" "r9IyvfU=\n" "-----END CERTIFICATE-----"; static const uint8_t s_expected_intermediate_1[] = { 0x30, 0x82, 0x02, 0xad, 0x30, 0x82, 0x01, 0x95, 0x02, 0x02, 0x7d, 0xd5, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x1e, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x13, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x30, 0x20, 0x17, 0x0d, 0x31, 0x36, 0x30, 0x33, 0x33, 0x30, 0x31, 0x38, 0x35, 0x37, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x32, 0x31, 0x31, 0x36, 0x30, 0x33, 0x30, 0x36, 0x31, 0x38, 0x35, 0x37, 0x34, 0x33, 0x5a, 0x30, 0x18, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0d, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xd1, 0xc3, 0xa0, 0x2e, 0x61, 0x70, 0x1e, 0x45, 0x3d, 0x18, 0xba, 0x9b, 0x42, 0x7c, 0x98, 0xd1, 0x07, 0xf1, 0x03, 0x27, 0x2c, 0x86, 0x5e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 0xdf, 0xee, 0xbd, 0x58, 0x0b, 0x37, 0xab, 0xba, 0x38, 0x8f, 0xe5, 0x24, 0x87, 0xa6, 0x16, 0x37, 0x19, 0x0a, 0xbc, 0xf0, 0xa7, 0xa6, 0x7c, 0x57, 0x33, 0xa7, 0xfe, 0x06, 0x9d, 0x86, 0xac, 0xb0, 0x4e, 0x74, 0x39, 0x87, 0xbb, 0x0d, 0x07, 0x01, 0xe3, 0x3b, 0xe7, 0xc6, 0x60, 0x17, 0xa7, 0x9d, 0x49, 0x20, 0xde, 0x28, 0xa2, 0x4b, 0x54, 0x53, 0xda, 0x0a, 0x20, 0xce, 0x72, 0xd9, 0xc8, 0x04, 0x59, 0xd9, 0x89, 0xcd, 0xea, 0x8f, 0x00, 0xd6, 0x31, 0x7f, 0x46, 0x48, 0x3e, 0x54, 0xe0, 0x11, 0x39, 0x27, 0x2b, 0x0d, 0x43, 0xcd, 0xff, 0x30, 0x94, 0xae, 0x66, 0x15, 0xb6, 0xc6, 0xe0, 0xb3, 0xd0, 0x87, 0x59, 0xa4, 0x0d, 0x57, 0x30, 0x41, 0x5d, 0xe8, 0x80, 0x6e, 0xa4, 0x18, 0xc4, 0x5a, 0xee, 0x77, 0x87, 0xfb, 0xa4, 0x85, 0x90, 0xda, 0x40, 0x2a, 0xe3, 0xc2, 0xa2, 0x37, 0xb8, 0x34, 0x01, 0x3e, 0x59, 0x0e, 0x6f, 0x7b, 0x5c, 0x24, 0xee, 0x72, 0x11, 0x4d, 0x0c, 0x03, 0x00, 0x5e}; static const uint8_t s_expected_intermediate_2[] = { 0x30, 0x82, 0x03, 0x29, 0x30, 0x82, 0x02, 0x11, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x57, 0x16, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x16, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0b, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x30, 0x20, 0x17, 0x0d, 0x31, 0x36, 0x30, 0x33, 0x33, 0x30, 0x31, 0x38, 0x35, 0x37, 0x30, 0x39, 0x5a, 0x18, 0x0f, 0x32, 0x31, 0x31, 0x36, 0x30, 0x33, 0x30, 0x36, 0x31, 0x38, 0x35, 0x37, 0x30, 0x39, 0x5a, 0x30, 0x1e, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x13, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xcc, 0xfe, 0x2d, 0xde, 0x72, 0x5c, 0x58, 0x72, 0xf7, 0x9d, 0x3c, 0x21, 0x27, 0x55, 0xee, 0x80, 0xfc, 0x76, 0x2c, 0x60, 0xf7, 0x8f, 0xd6, 0xa2, 0x81, 0x65, 0x08, 0x5b, 0xa6, 0xeb, 0x97, 0xd3, 0xad, 0x63, 0x15, 0x92, 0xb0, 0x95, 0xe7, 0x1b, 0xd1, 0xe6, 0xae, 0xd4, 0xf3, 0x91, 0x2d, 0xb7, 0x2c, 0x60, 0xae, 0x34, 0xbb, 0x7c, 0x54, 0xce, 0x80, 0x39, 0xbb, 0xa4, 0x34, 0x79, 0xb0, 0xee, 0xa8, 0xf6, 0xea, 0x48, 0x99, 0x02, 0x6b, 0x3b, 0x21, 0xeb, 0xa7, 0x2e, 0xf5, 0x24, 0xe5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x77, 0x30, 0x75, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x6a, 0x94, 0x29, 0x55, 0x95, 0x94, 0xbd, 0x37, 0xb0, 0x7b, 0x8e, 0x82, 0x01, 0x40, 0x09, 0xd9, 0x47, 0x72, 0x43, 0xc1, 0x30, 0x46, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x3f, 0x30, 0x3d, 0x80, 0x14, 0x4d, 0x97, 0x01, 0xb3, 0x43, 0xaf, 0x23, 0x25, 0x06, 0x93, 0x0d, 0x23, 0xa0, 0x9e, 0xf7, 0x6e, 0xee, 0x50, 0x5c, 0x13, 0xa1, 0x1a, 0xa4, 0x18, 0x30, 0x16, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0b, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x82, 0x09, 0x00, 0xd0, 0xd4, 0x90, 0x7f, 0x94, 0x61, 0xdc, 0xf5, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x37, 0x3b, 0x74, 0xbd, 0x55, 0x3d, 0x04, 0x0b, 0x5c, 0x86, 0xe3, 0x1c, 0x8d, 0x35, 0x46, 0x7b, 0xf8, 0x2c, 0xc5, 0xb8, 0x50, 0x3a, 0xba, 0x23, 0xb7, 0xf3, 0x28, 0x1c, 0x37, 0x93, 0x73, 0xd6, 0x83, 0x4f, 0xcb, 0x67, 0x90, 0x7a, 0xbe, 0xef, 0x62, 0x6a, 0xc7, 0xb6, 0xa3, 0x7a, 0x81, 0x2f, 0xe8, 0xd4, 0x08,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xbe, 0x4c, 0x3d, 0xc4, 0x99, 0x29, 0xff, 0x1b, 0x6c, 0x7a, 0x1e, 0x67, 0xeb, 0xee, 0x5a, 0xe9, 0x6c, 0x88, 0x44, 0x68, 0x3f, 0xb2}; static const uint8_t s_expected_leaf[] = { 0x30, 0x82, 0x03, 0x01, 0x30, 0x82, 0x01, 0xe9, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xd0, 0xd4, 0x90, 0x7f, 0x94, 0x61, 0xdc, 0xf5, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x16, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0b, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x30, 0x20, 0x17, 0x0d, 0x31, 0x36, 0x30, 0x33, 0x33, 0x30, 0x31, 0x38, 0x35, 0x36, 0x33, 0x39, 0x5a, 0x18, 0x0f, 0x32, 0x31, 0x31, 0x36, 0x30, 0x33, 0x30, 0x36, 0x31, 0x38, 0x35, 0x36, 0x33, 0x39, 0x5a, 0x30, 0x16, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0b, 0x73, 0x32, 0x6e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x6f, 0x74, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xc6, 0x39, 0xe7, 0x7d, 0xb4, 0xd3, 0x4a, 0x1a, 0x79, 0xe7, 0x7b, 0x26, 0x6a, 0x37,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x78, 0x50, 0x0c, 0x6b, 0x54, 0xe4, 0xbb, 0x71, 0xf2, 0x19, 0x94, 0x5a, 0x89, 0xe4, 0x40, 0x72, 0x4e, 0xbe, 0x41, 0xc3, 0xb6, 0x36, 0xe8, 0xd7, 0xc4, 0xa3, 0x72, 0x08, 0x19, 0x56, 0x38, 0xdd, 0xb7, 0x15, 0x04, 0xee, 0x06, 0x33, 0x7f, 0x08, 0x09, 0x7b, 0xe0, 0xc6, 0x6d, 0x70, 0x03, 0x36, 0x85, 0x54, 0xa6, 0xa6, 0x6f, 0x6d, 0xe1, 0xc5, 0x95, 0x37, 0x93, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x4d, 0x97, 0x01, 0xb3, 0x43, 0xaf, 0x23, 0x25, 0x06, 0x93, 0x0d, 0x23, 0xa0, 0x9e, 0xf7, 0x6e, 0xee, 0x50, 0x5c, 0x13, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x4d, 0x97, 0x01, 0xb3, 0x43, 0xaf, 0x23, 0x25, 0x06, 0x93, 0x0d, 0x23, 0xa0, 0x9e, 0xf7, 0x6e, 0xee, 0x50, 0x5c, 0x13, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x05, 0xe4, 0x56, 0xf4, 0x1d, 0x5c, 0x39, 0xa8, 0xcc, 0xf8, 0xb1, 0xb9, 0x98, 0xb5, 0xa3, 0xd7, 0x30, 0xe1, 0x28, 0xb4, 0xb3, 0x2a, 0x9f, 0x27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, 0x79, 0xa8, 0xb2, 0x40, 0x93, 0x4a, 0xb0, 0x97, 0xe8, 0xec, 0xe3, 0xcf, 0x01, 0x27, 0x5f, 0x0c, 0xf5, 0xd8, 0x38, 0x4f, 0x17, 0x41, 0x60, 0x59, 0x30, 0x1d, 0x2c, 0xca, 0x5d, 0x28, 0xfd, 0x4c, 0x93, 0x7b, 0xec, 0x16, 0xf4, 0x45, 0x9a, 0xfc, 0x2c, 0xbf, 0x53, 0xaf, 0xd2, 0x32, 0xbd, 0xf5, }; struct aws_byte_cursor pem_data = aws_byte_cursor_from_c_str(s_pem_data_str); struct aws_array_list output_list; ASSERT_SUCCESS(aws_array_list_init_dynamic(&output_list, allocator, 1, sizeof(struct aws_byte_buf))); ASSERT_SUCCESS(aws_decode_pem_to_buffer_list(allocator, &pem_data, &output_list)); ASSERT_UINT_EQUALS(3, aws_array_list_length(&output_list)); struct aws_byte_buf *cert_data = NULL; aws_array_list_get_at_ptr(&output_list, (void **)&cert_data, 0); ASSERT_BIN_ARRAYS_EQUALS( s_expected_intermediate_1, sizeof(s_expected_intermediate_1), cert_data->buffer, cert_data->len); aws_array_list_get_at_ptr(&output_list, (void **)&cert_data, 1); ASSERT_BIN_ARRAYS_EQUALS( s_expected_intermediate_2, sizeof(s_expected_intermediate_2), cert_data->buffer, cert_data->len); aws_array_list_get_at_ptr(&output_list, (void **)&cert_data, 2); ASSERT_BIN_ARRAYS_EQUALS(s_expected_leaf, sizeof(s_expected_leaf), cert_data->buffer, cert_data->len); aws_cert_chain_clean_up(&output_list); aws_array_list_clean_up(&output_list); return AWS_OP_SUCCESS; } AWS_TEST_CASE(test_pem_cert_chain_comments_and_whitespace, s_test_pem_cert_chain_comments_and_whitespace) static int s_test_pem_invalid_parse(struct aws_allocator *allocator, void *ctx) { (void)ctx; /* Maintainers note: I removed a '-' from the beginning */ static const char *s_invalid_pem = "----BEGIN CERTIFICATE-----\n" "MIICeDCCAeGgAwIBAgIJAObttnPKQhVlMA0GCSqGSIb3DQEBDgUAMF8xCzAJBgNV\n" "BAYTAlVTMQswCQYDVQQIDAJXQTEQMA4GA1UEBwwHU2VhdHRsZTEPMA0GA1UECgwG\n" "QW1hem9uMQwwCgYDVQQLDANzMm4xEjAQBgNVBAMMCWxvY2FsaG9zdDAgFw0xNzA4\n" "MDEyMjQzMzJaGA8yMTE3MDcwODIyNDMzMlowXzELMAkGA1UEBhMCVVMxCzAJBgNV\n" "BAgMAldBMRAwDgYDVQQHDAdTZWF0dGxlMQ8wDQYDVQQKDAZBbWF6b24xDDAKBgNV\n" "BAsMA3MybjESMBAGA1UEAwwJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GN\n" "ADCBiQKBgQCisRoXXcTh4ejn/sUjGosLlE7GlpLGtvWFEEX6Vl3klVoQdkyabLIH\n" "7bHB2P7uyt9bPzeqvWYjuepDBSQUUeb6Mkqfx237bTy8JhXIfpIhbgksTk7IPzgo\n" "XLPl1oNl7uB9HQaDQ7UPlaKbfp1gNvs6uGOH4vvyhhJGiblNJKnVwwIDAQABozow\n" "ODALBgNVHQ8EBAMCBDAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwFAYDVR0RBA0wC4IJ\n" "MTI3LjAuMC4xMA0GCSqGSIb3DQEBDgUAA4GBACleH44LSYhzHHaV70VbnLbtbv8T\n" "eaUvzstFW6YvdP1XnZKssZNdvMhoiMuMD5n40/iPbv+grtjxacRQCinLk1SEjpsu\n" "3lw90Ds0Ksd/Pdsv7d0cCiJkjadON+ZQEEJ2FP/G19KZFxC3GLk9sxIUXyUW0TXn\n" "YxwtPz26+xvPRWCS\n" "-----END CERTIFICATE-----"; struct aws_byte_cursor pem_data = aws_byte_cursor_from_c_str(s_invalid_pem); struct aws_array_list output_list; ASSERT_SUCCESS(aws_array_list_init_dynamic(&output_list, allocator, 1, sizeof(struct aws_byte_buf))); ASSERT_ERROR(AWS_IO_FILE_VALIDATION_FAILURE, aws_decode_pem_to_buffer_list(allocator, &pem_data, &output_list)); ASSERT_UINT_EQUALS(0, aws_array_list_length(&output_list)); aws_array_list_clean_up(&output_list); return AWS_OP_SUCCESS; } AWS_TEST_CASE(test_pem_invalid_parse, s_test_pem_invalid_parse) static int s_test_pem_valid_data_invalid_parse(struct aws_allocator *allocator, void *ctx) { (void)ctx; /* Maintainers note: I added a character (the 'q') to the end to make the base64 invalid */ static const char *s_invalid_data = "-----BEGIN CERTIFICATE-----\n" "MIICeDCCAeGgAwIBAgIJAObttnPKQhVlMA0GCSqGSIb3DQEBDgUAMF8xCzAJBgNV\n" "BAYTAlVTMQswCQYDVQQIDAJXQTEQMA4GA1UEBwwHU2VhdHRsZTEPMA0GA1UECgwG\n" "QW1hem9uMQwwCgYDVQQLDANzMm4xEjAQBgNVBAMMCWxvY2FsaG9zdDAgFw0xNzA4\n" "MDEyMjQzMzJaGA8yMTE3MDcwODIyNDMzMlowXzELMAkGA1UEBhMCVVMxCzAJBgNV\n" "BAgMAldBMRAwDgYDVQQHDAdTZWF0dGxlMQ8wDQYDVQQKDAZBbWF6b24xDDAKBgNV\n" "BAsMA3MybjESMBAGA1UEAwwJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GN\n" "ADCBiQKBgQCisRoXXcTh4ejn/sUjGosLlE7GlpLGtvWFEEX6Vl3klVoQdkyabLIH\n" "7bHB2P7uyt9bPzeqvWYjuepDBSQUUeb6Mkqfx237bTy8JhXIfpIhbgksTk7IPzgo\n" "XLPl1oNl7uB9HQaDQ7UPlaKbfp1gNvs6uGOH4vvyhhJGiblNJKnVwwIDAQABozow\n" "ODALBgNVHQ8EBAMCBDAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwFAYDVR0RBA0wC4IJ\n" "MTI3LjAuMC4xMA0GCSqGSIb3DQEBDgUAA4GBACleH44LSYhzHHaV70VbnLbtbv8T\n" "eaUvzstFW6YvdP1XnZKssZNdvMhoiMuMD5n40/iPbv+grtjxacRQCinLk1SEjpsu\n" "3lw90Ds0Ksd/Pdsv7d0cCiJkjadON+ZQEEJ2FP/G19KZFxC3GLk9sxIUXyUW0TXn\n" "YxwtPz26+xvPRWCSq\n" "-----END CERTIFICATE-----"; struct aws_byte_cursor pem_data = aws_byte_cursor_from_c_str(s_invalid_data); struct aws_array_list output_list; ASSERT_SUCCESS(aws_array_list_init_dynamic(&output_list, allocator, 1, sizeof(struct aws_byte_buf))); ASSERT_ERROR(AWS_IO_FILE_VALIDATION_FAILURE, aws_decode_pem_to_buffer_list(allocator, &pem_data, &output_list)); ASSERT_UINT_EQUALS(0, aws_array_list_length(&output_list)); aws_array_list_clean_up(&output_list); return AWS_OP_SUCCESS; } AWS_TEST_CASE(test_pem_valid_data_invalid_parse, s_test_pem_valid_data_invalid_parse) static int s_test_pem_invalid_in_chain_parse(struct aws_allocator *allocator, void *ctx) { (void)ctx; /* Maintainers note: I added a character (the 'f') to the end of the 3rd cert to make the base64 invalid */ static const char *s_invalid_data = "-----BEGIN CERTIFICATE-----\n" "MIICrTCCAZUCAn3VMA0GCSqGSIb3DQEBBQUAMB4xHDAaBgNVBAMME3MyblRlc3RJ\n" "bnRlcm1lZGlhdGUwIBcNMTYwMzMwMTg1NzQzWhgPMjExNjAzMDYxODU3NDNaMBgx\n" "FjAUBgNVBAMMDXMyblRlc3RTZXJ2ZXIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw\n" "ggEKAoIBAQDRw6AuYXAeRT0YuptCfJjRB/EDJyyGXnv+8TV2H1WJWhMLk8qND27r\n" "79A6EjbVmJaOV9qrokVqpDmXS712Z3BDprJ+1LFMymm3A+AFuK/skeGy0skik+Tg\n" "MmFT5XBVvmsw4uB1S9uUqktHauXgjhFPPsfvk4ewL4LulVEN2TEeI1Odj4CaMxAO\n" "Iuowm8wI2OHVzRHlrRmyJ9hYGuHHQ2TaTGIjr3WpAFuXi9pHGGMYa0uXAVPmgjdE\n" "XZ8t46u/ZKQ9W1uJkZEVKhcijT7G2VBrsBUq0CDiL+TDaGfthnBzUc9zt4fx/S/3\n"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wQPeFAMa1Tku3HyGZRaieRAck6+QcO2NujXxKNyCBlWON23\n" "FQTuBjN/CAl74MZtcAM2hVSmpm9t4cWVN5MCAwEAAaNQME4wHQYDVR0OBBYEFE2X\n" "AbNDryMlBpMNI6Ce927uUFwTMB8GA1UdIwQYMBaAFE2XAbNDryMlBpMNI6Ce927u\n" "UFwTMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAAXkVvQdXDmozPix\n" "uZi1o9cw4Si0syqfJ4sSunrzPbbmw/Qxhth5V7XGrnsQVNxamgnbzpjGhiBF6isM\n" "ldj33zQYtke+ojOjFlhEvrPo6eW29RkLBEtJadGs2bkMLztJbf+cbH2u6irzr6S4\n" "3OgVOSuB+zG56ksTnEVmum+C/8tSIAyi3eaoStPcgEU8+3/KMrH7uuenmTOCKdD1\n" "FvSDHXT9qPgTttVQGXbXzJEr5tGE+Py6yib5uoJ0dJZNtjs7HOQEDk5J0wZaX0DC\n" "MShYLiN5qLJAk0qwl+js488BJ18M9dg4TxdBYFkwHSzKXSj9TJN77Bb0RZr8LL9T\n" "r9IyvfUf=\n" "-----END CERTIFICATE-----"; struct aws_byte_cursor pem_data = aws_byte_cursor_from_c_str(s_invalid_data); struct aws_array_list output_list; ASSERT_SUCCESS(aws_array_list_init_dynamic(&output_list, allocator, 1, sizeof(struct aws_byte_buf))); ASSERT_ERROR(AWS_IO_FILE_VALIDATION_FAILURE, aws_decode_pem_to_buffer_list(allocator, &pem_data, &output_list)); ASSERT_UINT_EQUALS(0, aws_array_list_length(&output_list)); aws_array_list_clean_up(&output_list); return AWS_OP_SUCCESS; } AWS_TEST_CASE(test_pem_invalid_in_chain_parse, s_test_pem_invalid_in_chain_parse)