From 844611e0efdc3614e986ef4966ebe990d6174ffb Mon Sep 17 00:00:00 2001 From: Dmitriy Musatkin Date: Fri, 6 Oct 2023 11:45:34 -0700 Subject: [PATCH] lint --- include/aws/io/io.h | 2 +- include/aws/io/pem.h | 58 ++++++++++++++++++++++---------------------- source/io.c | 2 +- source/pem.c | 12 ++++----- tests/pem_test.c | 6 ++--- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/include/aws/io/io.h b/include/aws/io/io.h index 15d9dcea6..011e1a779 100644 --- a/include/aws/io/io.h +++ b/include/aws/io/io.h @@ -252,7 +252,7 @@ enum aws_io_errors { AWS_IO_TLS_ERROR_READ_FAILURE, - AWS_ERROR_PEM_MALFORMED_OBJECT, + AWS_ERROR_PEM_MALFORMED, AWS_IO_ERROR_END_RANGE = AWS_ERROR_ENUM_END_RANGE(AWS_C_IO_PACKAGE_ID), AWS_IO_INVALID_FILE_HANDLE = AWS_ERROR_INVALID_FILE_HANDLE, diff --git a/include/aws/io/pem.h b/include/aws/io/pem.h index 95f497249..ed9d5913a 100644 --- a/include/aws/io/pem.h +++ b/include/aws/io/pem.h @@ -10,37 +10,37 @@ AWS_EXTERN_C_BEGIN /* - * Naming follows OpenSSL convention for PEM types. + * Naming follows OpenSSL convention for PEM types. * Refer to comment after each enum value for the type string it represents. -*/ + */ enum aws_pem_object_type { AWS_PEM_TYPE_UNKNOWN = 0, - AWS_PEM_TYPE_X509_OLD, /* X509 CERTIFICATE */ - AWS_PEM_TYPE_X509, /* CERTIFICATE */ - AWS_PEM_TYPE_X509_TRUSTED, /* TRUSTED CERTIFICATE */ - AWS_PEM_TYPE_X509_REQ_OLD, /* NEW CERTIFICATE REQUEST */ - AWS_PEM_TYPE_X509_REQ, /* CERTIFICATE REQUEST */ - AWS_PEM_TYPE_X509_CRL, /* X509 CRL */ - AWS_PEM_TYPE_EVP_PKEY, /* ANY PRIVATE KEY */ - AWS_PEM_TYPE_PUBLIC_PKCS8, /* PUBLIC KEY */ - AWS_PEM_TYPE_PRIVATE_RSA_PKCS1, /* RSA PRIVATE KEY */ - AWS_PEM_TYPE_PUBLIC_RSA_PKCS1, /* RSA PUBLIC KEY */ - AWS_PEM_TYPE_PRIVATE_DSA_PKCS1, /* RSA PRIVATE KEY */ - AWS_PEM_TYPE_PUBLIC_DSA_PKCS1, /* RSA PUBLIC KEY */ - AWS_PEM_TYPE_PKCS7, /* PKCS7 */ - AWS_PEM_TYPE_PKCS7_SIGNED_DATA, /* PKCS #7 SIGNED DATA */ + AWS_PEM_TYPE_X509_OLD, /* X509 CERTIFICATE */ + AWS_PEM_TYPE_X509, /* CERTIFICATE */ + AWS_PEM_TYPE_X509_TRUSTED, /* TRUSTED CERTIFICATE */ + AWS_PEM_TYPE_X509_REQ_OLD, /* NEW CERTIFICATE REQUEST */ + AWS_PEM_TYPE_X509_REQ, /* CERTIFICATE REQUEST */ + AWS_PEM_TYPE_X509_CRL, /* X509 CRL */ + AWS_PEM_TYPE_EVP_PKEY, /* ANY PRIVATE KEY */ + AWS_PEM_TYPE_PUBLIC_PKCS8, /* PUBLIC KEY */ + AWS_PEM_TYPE_PRIVATE_RSA_PKCS1, /* RSA PRIVATE KEY */ + AWS_PEM_TYPE_PUBLIC_RSA_PKCS1, /* RSA PUBLIC KEY */ + AWS_PEM_TYPE_PRIVATE_DSA_PKCS1, /* RSA PRIVATE KEY */ + AWS_PEM_TYPE_PUBLIC_DSA_PKCS1, /* RSA PUBLIC KEY */ + AWS_PEM_TYPE_PKCS7, /* PKCS7 */ + AWS_PEM_TYPE_PKCS7_SIGNED_DATA, /* PKCS #7 SIGNED DATA */ AWS_PEM_TYPE_PRIVATE_PKCS8_ENCRYPTED, /* ENCRYPTED PRIVATE KEY */ - AWS_PEM_TYPE_PRIVATE_PKCS8, /* PRIVATE KEY */ - AWS_PEM_TYPE_DH_PARAMETERS, /* X9.42 DH PARAMETERS */ - AWS_PEM_TYPE_DH_PARAMETERS_X942, /* X9.42 DH PARAMETERS */ - AWS_PEM_TYPE_SSL_SESSION_PARAMETERS, /* SSL SESSION PARAMETERS */ - AWS_PEM_TYPE_DSA_PARAMETERS, /* DSA PARAMETERS */ - AWS_PEM_TYPE_ECDSA_PUBLIC, /* ECDSA PUBLIC KEY */ - AWS_PEM_TYPE_EC_PARAMETERS, /* EC PARAMETERS */ - AWS_PEM_TYPE_EC_PRIVATE, /* EC PRIVATE KEY */ - AWS_PEM_TYPE_PARAMETERS, /* PARAMETERS */ - AWS_PEM_TYPE_CMS, /* CMS */ - AWS_PEM_TYPE_SM2_PARAMETERS /* SM2 PARAMETERS */ + AWS_PEM_TYPE_PRIVATE_PKCS8, /* PRIVATE KEY */ + AWS_PEM_TYPE_DH_PARAMETERS, /* X9.42 DH PARAMETERS */ + AWS_PEM_TYPE_DH_PARAMETERS_X942, /* X9.42 DH PARAMETERS */ + AWS_PEM_TYPE_SSL_SESSION_PARAMETERS, /* SSL SESSION PARAMETERS */ + AWS_PEM_TYPE_DSA_PARAMETERS, /* DSA PARAMETERS */ + AWS_PEM_TYPE_ECDSA_PUBLIC, /* ECDSA PUBLIC KEY */ + AWS_PEM_TYPE_EC_PARAMETERS, /* EC PARAMETERS */ + AWS_PEM_TYPE_EC_PRIVATE, /* EC PRIVATE KEY */ + AWS_PEM_TYPE_PARAMETERS, /* PARAMETERS */ + AWS_PEM_TYPE_CMS, /* CMS */ + AWS_PEM_TYPE_SM2_PARAMETERS /* SM2 PARAMETERS */ }; /* @@ -68,7 +68,7 @@ AWS_IO_API void aws_pem_objects_clean_up(struct aws_array_list *pem_objects); * If it comes across an object it cannot read, list of all object read until * that point is returned. * If no objects can be read PEM or objects could not be base 64 decoded, - * AWS_ERROR_PEM_MALFORMED_OBJECT is raised. + * AWS_ERROR_PEM_MALFORMED is raised. * out_pem_objects stores aws_pem_object struct by value. * Caller must initialize out_pem_objects before calling the function. * This code is slow, and it allocates, so please try @@ -84,7 +84,7 @@ AWS_IO_API int aws_decode_pem_to_object_list( * If it comes across an object it cannot read, list of all object read until * that point is returned. * If no objects can be read PEM or objects could not be base 64 decoded, - * AWS_ERROR_PEM_MALFORMED_OBJECT is raised. + * AWS_ERROR_PEM_MALFORMED is raised. * out_pem_objects stores aws_pem_object struct by value. * Caller must initialize out_pem_objects before calling the function. * This code is slow, and it allocates, so please try diff --git a/source/io.c b/source/io.c index 54b3f1e69..c47ce97a9 100644 --- a/source/io.c +++ b/source/io.c @@ -304,7 +304,7 @@ static struct aws_error_info s_errors[] = { AWS_DEFINE_ERROR_INFO_IO( AWS_IO_TLS_ERROR_READ_FAILURE, "Failure during TLS read."), - AWS_DEFINE_ERROR_INFO_IO(AWS_ERROR_PEM_MALFORMED_OBJECT, "Malformed PEM object encountered."), + AWS_DEFINE_ERROR_INFO_IO(AWS_ERROR_PEM_MALFORMED, "Malformed PEM object encountered."), }; /* clang-format on */ diff --git a/source/pem.c b/source/pem.c index 2714f4ad8..b1ac9ae4c 100644 --- a/source/pem.c +++ b/source/pem.c @@ -228,7 +228,7 @@ static struct aws_byte_cursor s_delim_cur = AWS_BYTE_CUR_INIT_FROM_STRING_LITERA int s_extract_header_type_cur(struct aws_byte_cursor cur, struct aws_byte_cursor *out) { if (!aws_byte_cursor_starts_with(&cur, &s_begin_header_cur)) { AWS_LOGF_ERROR(AWS_LS_IO_PEM, "Invalid PEM buffer: invalid begin token"); - return aws_raise_error(AWS_ERROR_PEM_MALFORMED_OBJECT); + return aws_raise_error(AWS_ERROR_PEM_MALFORMED); } aws_byte_cursor_advance(&cur, s_begin_header_cur.len); @@ -237,7 +237,7 @@ int s_extract_header_type_cur(struct aws_byte_cursor cur, struct aws_byte_cursor if (!aws_byte_cursor_eq(&cur, &s_delim_cur)) { AWS_LOGF_ERROR(AWS_LS_IO_PEM, "Invalid PEM buffer: invalid end token"); - return aws_raise_error(AWS_ERROR_PEM_MALFORMED_OBJECT); + return aws_raise_error(AWS_ERROR_PEM_MALFORMED); } *out = type_cur; @@ -257,7 +257,7 @@ static int s_convert_pem_to_raw_base64( if (aws_byte_cursor_split_on_char(&pem, '\n', &split_buffers)) { aws_array_list_clean_up(&split_buffers); AWS_LOGF_ERROR(AWS_LS_IO_PEM, "Invalid PEM buffer: failed to split on newline"); - return aws_raise_error(AWS_ERROR_PEM_MALFORMED_OBJECT); + return aws_raise_error(AWS_ERROR_PEM_MALFORMED); } enum aws_pem_parse_state state = BEGIN; @@ -359,7 +359,7 @@ static int s_convert_pem_to_raw_base64( AWS_LOGF_ERROR(AWS_LS_IO_PEM, "Invalid PEM buffer."); aws_pem_objects_clean_up(pem_objects); - return aws_raise_error(AWS_ERROR_PEM_MALFORMED_OBJECT); + return aws_raise_error(AWS_ERROR_PEM_MALFORMED); } int aws_decode_pem_to_object_list( @@ -382,7 +382,7 @@ int aws_decode_pem_to_object_list( size_t decoded_len = 0; if (aws_base64_compute_decoded_len(&byte_cur, &decoded_len)) { AWS_LOGF_ERROR(AWS_LS_IO_PEM, "Failed to get length for decoded base64 pem object."); - aws_raise_error(AWS_ERROR_PEM_MALFORMED_OBJECT); + aws_raise_error(AWS_ERROR_PEM_MALFORMED); goto on_error; } @@ -391,7 +391,7 @@ int aws_decode_pem_to_object_list( if (aws_base64_decode(&byte_cur, &decoded_buffer)) { AWS_LOGF_ERROR(AWS_LS_IO_PEM, "Failed to base 64 decode pem object."); - aws_raise_error(AWS_ERROR_PEM_MALFORMED_OBJECT); + aws_raise_error(AWS_ERROR_PEM_MALFORMED); aws_byte_buf_clean_up_secure(&decoded_buffer); goto on_error; } diff --git a/tests/pem_test.c b/tests/pem_test.c index 61a9627a0..8a4822828 100644 --- a/tests/pem_test.c +++ b/tests/pem_test.c @@ -1004,7 +1004,7 @@ static int s_test_pem_invalid_parse(struct aws_allocator *allocator, void *ctx) struct aws_array_list output_list; ASSERT_SUCCESS(aws_array_list_init_dynamic(&output_list, allocator, 1, sizeof(struct aws_pem_object))); - ASSERT_ERROR(AWS_ERROR_PEM_MALFORMED_OBJECT, aws_decode_pem_to_object_list(allocator, pem_data, &output_list)); + ASSERT_ERROR(AWS_ERROR_PEM_MALFORMED, aws_decode_pem_to_object_list(allocator, pem_data, &output_list)); ASSERT_UINT_EQUALS(0, aws_array_list_length(&output_list)); aws_array_list_clean_up(&output_list); @@ -1037,7 +1037,7 @@ static int s_test_pem_valid_data_invalid_parse(struct aws_allocator *allocator, struct aws_array_list output_list; ASSERT_SUCCESS(aws_array_list_init_dynamic(&output_list, allocator, 1, sizeof(struct aws_pem_object))); - ASSERT_ERROR(AWS_ERROR_PEM_MALFORMED_OBJECT, aws_decode_pem_to_object_list(allocator, pem_data, &output_list)); + ASSERT_ERROR(AWS_ERROR_PEM_MALFORMED, aws_decode_pem_to_object_list(allocator, pem_data, &output_list)); ASSERT_UINT_EQUALS(0, aws_array_list_length(&output_list)); aws_array_list_clean_up(&output_list); @@ -1109,7 +1109,7 @@ static int s_test_pem_invalid_in_chain_parse(struct aws_allocator *allocator, vo struct aws_array_list output_list; ASSERT_SUCCESS(aws_array_list_init_dynamic(&output_list, allocator, 1, sizeof(struct aws_pem_object))); - ASSERT_ERROR(AWS_ERROR_PEM_MALFORMED_OBJECT, aws_decode_pem_to_object_list(allocator, pem_data, &output_list)); + ASSERT_ERROR(AWS_ERROR_PEM_MALFORMED, aws_decode_pem_to_object_list(allocator, pem_data, &output_list)); ASSERT_UINT_EQUALS(0, aws_array_list_length(&output_list)); aws_array_list_clean_up(&output_list);