diff --git a/include/aws/auth/auth.h b/include/aws/auth/auth.h
new file mode 100644
index 0000000000000000000000000000000000000000..fcd50cd09279cf6154ebd0aa5b1c36727cf505dd
--- /dev/null
+++ b/include/aws/auth/auth.h
@@ -0,0 +1,94 @@
+#ifndef AWS_AUTH_AUTH_H
+#define AWS_AUTH_AUTH_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+#define AWS_C_AUTH_PACKAGE_ID 6
+
+/**
+ * Auth-specific error codes
+ */
+enum aws_auth_errors {
+ AWS_AUTH_PROFILE_PARSE_RECOVERABLE_ERROR = AWS_ERROR_SDKUTILS_PARSE_RECOVERABLE,
+ AWS_AUTH_PROFILE_PARSE_FATAL_ERROR = AWS_ERROR_SDKUTILS_PARSE_FATAL,
+ AWS_AUTH_SIGNING_UNSUPPORTED_ALGORITHM = AWS_ERROR_ENUM_BEGIN_RANGE(AWS_C_AUTH_PACKAGE_ID),
+ AWS_AUTH_SIGNING_MISMATCHED_CONFIGURATION,
+ AWS_AUTH_SIGNING_NO_CREDENTIALS,
+ AWS_AUTH_SIGNING_ILLEGAL_REQUEST_QUERY_PARAM,
+ AWS_AUTH_SIGNING_ILLEGAL_REQUEST_HEADER,
+ AWS_AUTH_SIGNING_INVALID_CONFIGURATION,
+ AWS_AUTH_CREDENTIALS_PROVIDER_INVALID_ENVIRONMENT,
+ AWS_AUTH_CREDENTIALS_PROVIDER_INVALID_DELEGATE,
+ AWS_AUTH_CREDENTIALS_PROVIDER_PROFILE_SOURCE_FAILURE,
+ AWS_AUTH_CREDENTIALS_PROVIDER_IMDS_SOURCE_FAILURE,
+ AWS_AUTH_CREDENTIALS_PROVIDER_STS_SOURCE_FAILURE,
+ AWS_AUTH_CREDENTIALS_PROVIDER_HTTP_STATUS_FAILURE,
+ AWS_AUTH_PROVIDER_PARSER_UNEXPECTED_RESPONSE,
+ AWS_AUTH_CREDENTIALS_PROVIDER_ECS_SOURCE_FAILURE,
+ AWS_AUTH_CREDENTIALS_PROVIDER_X509_SOURCE_FAILURE,
+ AWS_AUTH_CREDENTIALS_PROVIDER_PROCESS_SOURCE_FAILURE,
+ AWS_AUTH_CREDENTIALS_PROVIDER_STS_WEB_IDENTITY_SOURCE_FAILURE,
+ AWS_AUTH_SIGNING_UNSUPPORTED_SIGNATURE_TYPE,
+ AWS_AUTH_SIGNING_MISSING_PREVIOUS_SIGNATURE,
+ AWS_AUTH_SIGNING_INVALID_CREDENTIALS,
+ AWS_AUTH_CANONICAL_REQUEST_MISMATCH,
+ AWS_AUTH_SIGV4A_SIGNATURE_VALIDATION_FAILURE,
+ AWS_AUTH_CREDENTIALS_PROVIDER_COGNITO_SOURCE_FAILURE,
+ AWS_AUTH_CREDENTIALS_PROVIDER_DELEGATE_FAILURE,
+ AWS_AUTH_SSO_TOKEN_PROVIDER_SOURCE_FAILURE,
+ AWS_AUTH_SSO_TOKEN_INVALID,
+ AWS_AUTH_SSO_TOKEN_EXPIRED,
+ AWS_AUTH_CREDENTIALS_PROVIDER_SSO_SOURCE_FAILURE,
+ AWS_AUTH_IMDS_CLIENT_SOURCE_FAILURE,
+ AWS_AUTH_PROFILE_STS_CREDENTIALS_PROVIDER_CYCLE_FAILURE,
+ AWS_AUTH_CREDENTIALS_PROVIDER_ECS_INVALID_TOKEN_FILE_PATH,
+ AWS_AUTH_CREDENTIALS_PROVIDER_ECS_INVALID_HOST,
+
+ AWS_AUTH_ERROR_END_RANGE = AWS_ERROR_ENUM_END_RANGE(AWS_C_AUTH_PACKAGE_ID)
+};
+
+/**
+ * Auth-specific logging subjects
+ */
+enum aws_auth_log_subject {
+ AWS_LS_AUTH_GENERAL = AWS_LOG_SUBJECT_BEGIN_RANGE(AWS_C_AUTH_PACKAGE_ID),
+ AWS_LS_AUTH_PROFILE,
+ AWS_LS_AUTH_CREDENTIALS_PROVIDER,
+ AWS_LS_AUTH_SIGNING,
+ AWS_LS_IMDS_CLIENT,
+
+ AWS_LS_AUTH_LAST = AWS_LOG_SUBJECT_END_RANGE(AWS_C_AUTH_PACKAGE_ID)
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes internal datastructures used by aws-c-auth.
+ * Must be called before using any functionality in aws-c-auth.
+ *
+ * @param allocator memory allocator to use for any module-level memory allocation
+ */
+AWS_AUTH_API
+void aws_auth_library_init(struct aws_allocator *allocator);
+
+/**
+ * Clean up internal datastructures used by aws-c-auth.
+ * Must not be called until application is done using functionality in aws-c-auth.
+ */
+AWS_AUTH_API
+void aws_auth_library_clean_up(void);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_AUTH_AUTH_H */
diff --git a/include/aws/auth/aws_imds_client.h b/include/aws/auth/aws_imds_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..f9f5580f2edba5c1c6751d72fe5332982732ac10
--- /dev/null
+++ b/include/aws/auth/aws_imds_client.h
@@ -0,0 +1,489 @@
+#ifndef AWS_AUTH_IMDS_CLIENT_H
+#define AWS_AUTH_IMDS_CLIENT_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+#include
+#include
+#include
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+typedef void(aws_imds_client_shutdown_completed_fn)(void *user_data);
+
+/**
+ * Optional callback and user data to be invoked when an imds client has fully shut down
+ */
+struct aws_imds_client_shutdown_options {
+ aws_imds_client_shutdown_completed_fn *shutdown_callback;
+ void *shutdown_user_data;
+};
+
+/**
+ * Configuration options when creating an imds client
+ */
+struct aws_imds_client_options {
+ /*
+ * Completion callback to be invoked when the client has fully shut down
+ */
+ struct aws_imds_client_shutdown_options shutdown_options;
+
+ /*
+ * Client bootstrap to use when this client makes network connections
+ */
+ struct aws_client_bootstrap *bootstrap;
+
+ /*
+ * Retry strategy instance that governs how failed requests are retried
+ */
+ struct aws_retry_strategy *retry_strategy;
+
+ /*
+ * What version of the imds protocol to use
+ *
+ * Defaults to IMDS_PROTOCOL_V2
+ */
+ enum aws_imds_protocol_version imds_version;
+
+ /*
+ * If true, fallback from v2 to v1 will be disabled for all cases
+ */
+ bool ec2_metadata_v1_disabled;
+
+ /*
+ * Table holding all cross-system functional dependencies for an imds client.
+ *
+ * For mocking the http layer in tests, leave NULL otherwise
+ */
+ struct aws_auth_http_system_vtable *function_table;
+};
+
+/*
+ * Standard callback for instance metadata queries
+ */
+typedef void(
+ aws_imds_client_on_get_resource_callback_fn)(const struct aws_byte_buf *resource, int error_code, void *user_data);
+
+/**
+ * https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html
+ */
+struct aws_imds_iam_profile {
+ struct aws_date_time last_updated;
+ struct aws_byte_cursor instance_profile_arn;
+ struct aws_byte_cursor instance_profile_id;
+};
+
+/**
+ * Block of per-instance EC2-specific data
+ *
+ * https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-identity-documents.html
+ */
+struct aws_imds_instance_info {
+ /* an array of aws_byte_cursor */
+ struct aws_array_list marketplace_product_codes;
+ struct aws_byte_cursor availability_zone;
+ struct aws_byte_cursor private_ip;
+ struct aws_byte_cursor version;
+ struct aws_byte_cursor instance_id;
+ /* an array of aws_byte_cursor */
+ struct aws_array_list billing_products;
+ struct aws_byte_cursor instance_type;
+ struct aws_byte_cursor account_id;
+ struct aws_byte_cursor image_id;
+ struct aws_date_time pending_time;
+ struct aws_byte_cursor architecture;
+ struct aws_byte_cursor kernel_id;
+ struct aws_byte_cursor ramdisk_id;
+ struct aws_byte_cursor region;
+};
+
+/* the item typed stored in array is pointer to aws_byte_cursor */
+typedef void(
+ aws_imds_client_on_get_array_callback_fn)(const struct aws_array_list *array, int error_code, void *user_data);
+
+typedef void(aws_imds_client_on_get_credentials_callback_fn)(
+ const struct aws_credentials *credentials,
+ int error_code,
+ void *user_data);
+
+typedef void(aws_imds_client_on_get_iam_profile_callback_fn)(
+ const struct aws_imds_iam_profile *iam_profile_info,
+ int error_code,
+ void *user_data);
+
+typedef void(aws_imds_client_on_get_instance_info_callback_fn)(
+ const struct aws_imds_instance_info *instance_info,
+ int error_code,
+ void *user_data);
+
+/**
+ * AWS EC2 Metadata Client is used to retrieve AWS EC2 Instance Metadata info.
+ */
+struct aws_imds_client;
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Creates a new imds client
+ *
+ * @param allocator memory allocator to use for creation and queries
+ * @param options configuration options for the imds client
+ *
+ * @return a newly-constructed imds client, or NULL on failure
+ */
+AWS_AUTH_API
+struct aws_imds_client *aws_imds_client_new(
+ struct aws_allocator *allocator,
+ const struct aws_imds_client_options *options);
+
+/**
+ * Increments the ref count on the client
+ *
+ * @param client imds client to acquire a reference to
+ */
+AWS_AUTH_API
+void aws_imds_client_acquire(struct aws_imds_client *client);
+
+/**
+ * Decrements the ref count on the client
+ *
+ * @param client imds client to release a reference to
+ */
+AWS_AUTH_API
+void aws_imds_client_release(struct aws_imds_client *client);
+
+/**
+ * Queries a generic resource (string) from the ec2 instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param resource_path path of the resource to query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_resource_async(
+ struct aws_imds_client *client,
+ struct aws_byte_cursor resource_path,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the ami id of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_ami_id(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the ami launch index of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_ami_launch_index(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the ami manifest path of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_ami_manifest_path(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the list of ancestor ami ids of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_ancestor_ami_ids(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_array_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the instance-action of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_instance_action(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the instance id of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_instance_id(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the instance type of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_instance_type(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the mac address of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_mac_address(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the private ip address of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_private_ip_address(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the availability zone of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_availability_zone(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the product codes of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_product_codes(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the public key of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_public_key(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the ramdisk id of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_ramdisk_id(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the reservation id of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_reservation_id(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the list of the security groups of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_security_groups(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_array_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the list of block device mappings of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_block_device_mapping(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_array_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the attached iam role of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_attached_iam_role(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets temporary credentials based on the attached iam role of the ec2 instance
+ *
+ * @param client imds client to use for the query
+ * @param iam_role_name iam role name to get temporary credentials through
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_credentials(
+ struct aws_imds_client *client,
+ struct aws_byte_cursor iam_role_name,
+ aws_imds_client_on_get_credentials_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the iam profile information of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_iam_profile(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_iam_profile_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the user data of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_user_data(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the signature of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_instance_signature(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_resource_callback_fn callback,
+ void *user_data);
+
+/**
+ * Gets the instance information data block of the ec2 instance from the instance metadata document
+ *
+ * @param client imds client to use for the query
+ * @param callback callback function to invoke on query success or failure
+ * @param user_data opaque data to invoke the completion callback with
+ * @return AWS_OP_SUCCESS if the query was successfully started, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_imds_client_get_instance_info(
+ struct aws_imds_client *client,
+ aws_imds_client_on_get_instance_info_callback_fn callback,
+ void *user_data);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_AUTH_IMDS_CLIENT_H */
diff --git a/include/aws/auth/credentials.h b/include/aws/auth/credentials.h
new file mode 100644
index 0000000000000000000000000000000000000000..ce87c9c4a17eb8b5fe9ed41c31fc7bd5691dfe63
--- /dev/null
+++ b/include/aws/auth/credentials.h
@@ -0,0 +1,1277 @@
+#ifndef AWS_AUTH_CREDENTIALS_H
+#define AWS_AUTH_CREDENTIALS_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_client_bootstrap;
+struct aws_auth_http_system_vtable;
+struct aws_credentials;
+struct aws_credentials_provider;
+struct aws_ecc_key_pair;
+struct aws_string;
+
+extern const uint16_t aws_sts_assume_role_default_duration_secs;
+
+/*
+ * Signature for the credentials sourcing callback
+ */
+typedef void(aws_on_get_credentials_callback_fn)(struct aws_credentials *credentials, int error_code, void *user_data);
+
+typedef int(aws_credentials_provider_get_credentials_fn)(
+ struct aws_credentials_provider *provider,
+ aws_on_get_credentials_callback_fn callback,
+ void *user_data);
+typedef void(aws_credentials_provider_destroy_fn)(struct aws_credentials_provider *provider);
+
+/*
+ * Common function table that all credentials provider implementations must support
+ */
+struct aws_credentials_provider_vtable {
+ aws_credentials_provider_get_credentials_fn *get_credentials;
+ aws_credentials_provider_destroy_fn *destroy;
+};
+
+typedef void(aws_credentials_provider_shutdown_completed_fn)(void *user_data);
+
+/*
+ * All credentials providers support an optional shutdown callback that
+ * gets invoked, with appropriate user data, when the resources used by the provider
+ * are no longer in use. For example, the imds provider uses this to
+ * signal when it is no longer using the client bootstrap used in its
+ * internal connection manager.
+ */
+struct aws_credentials_provider_shutdown_options {
+ aws_credentials_provider_shutdown_completed_fn *shutdown_callback;
+ void *shutdown_user_data;
+};
+
+/**
+ * A baseclass for credentials providers. A credentials provider is an object that has an asynchronous
+ * query function for retrieving AWS credentials.
+ *
+ * Ref-counted. Thread-safe.
+ */
+struct aws_credentials_provider {
+ struct aws_credentials_provider_vtable *vtable;
+ struct aws_allocator *allocator;
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+ void *impl;
+ struct aws_atomic_var ref_count;
+};
+
+/*
+ * Config structs for creating all the different credentials providers
+ */
+
+/**
+ * Configuration options for a provider that returns a fixed set of credentials
+ */
+struct aws_credentials_provider_static_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+ struct aws_byte_cursor access_key_id;
+ struct aws_byte_cursor secret_access_key;
+ struct aws_byte_cursor session_token;
+ struct aws_byte_cursor account_id;
+};
+
+/**
+ * Configuration options for a provider that returns credentials based on environment variable values
+ */
+struct aws_credentials_provider_environment_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+};
+
+/**
+ * Configuration options for a provider that sources credentials from the aws config and credentials files
+ * (by default ~/.aws/config and ~/.aws/credentials)
+ */
+struct aws_credentials_provider_profile_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /*
+ * Override of what profile to use to source credentials from ('default' by default)
+ */
+ struct aws_byte_cursor profile_name_override;
+
+ /*
+ * Override path to the profile config file (~/.aws/config by default)
+ */
+ struct aws_byte_cursor config_file_name_override;
+
+ /*
+ * Override path to the profile credentials file (~/.aws/credentials by default)
+ */
+ struct aws_byte_cursor credentials_file_name_override;
+
+ /**
+ * (Optional)
+ * Use a cached merged profile collection. A merge collection has both config file
+ * (~/.aws/config) and credentials file based profile collection (~/.aws/credentials) using
+ * `aws_profile_collection_new_from_merge`.
+ * If this option is provided, `config_file_name_override` and `credentials_file_name_override` will be ignored.
+ */
+ struct aws_profile_collection *profile_collection_cached;
+
+ /*
+ * Bootstrap to use for any network connections made while sourcing credentials (for example,
+ * a profile that uses assume-role will need to hit STS)
+ */
+ struct aws_client_bootstrap *bootstrap;
+
+ /*
+ * Client TLS context to use for any secure network connections made while sourcing credentials
+ * (for example, a profile that uses assume-role will need to hit STS).
+ *
+ * If a TLS context is needed, and you did not pass one in, it will be created automatically.
+ * However, you are encouraged to pass in a shared one since these are expensive objects.
+ * If using BYO_CRYPTO, you must provide the TLS context since it cannot be created automatically.
+ */
+ struct aws_tls_ctx *tls_ctx;
+
+ /* For mocking the http layer in tests, leave NULL otherwise */
+ struct aws_auth_http_system_vtable *function_table;
+};
+
+/**
+ * Configuration options for a provider that functions as a caching decorator. Credentials sourced through this
+ * provider will be cached within it until their expiration time. When the cached credentials expire, new
+ * credentials will be fetched when next queried.
+ */
+struct aws_credentials_provider_cached_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /*
+ * The provider to cache credentials query results from
+ */
+ struct aws_credentials_provider *source;
+
+ /*
+ * An optional expiration time period for sourced credentials. For a given set of cached credentials,
+ * the refresh time period will be the minimum of this time and any expiration timestamp on the credentials
+ * themselves.
+ */
+ uint64_t refresh_time_in_milliseconds;
+
+ /* For mocking, leave NULL otherwise */
+ aws_io_clock_fn *high_res_clock_fn;
+ aws_io_clock_fn *system_clock_fn;
+};
+
+/**
+ * Configuration options for a provider that queries, in order, a list of providers. This provider uses the
+ * first set of credentials successfully queried. Providers are queried one at a time; a provider is not queried
+ * until the preceding provider has failed to source credentials.
+ */
+struct aws_credentials_provider_chain_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /*
+ * Pointer to an array of credentials providers to use
+ */
+ struct aws_credentials_provider **providers;
+
+ /*
+ * Number of elements in the array of credentials providers
+ */
+ size_t provider_count;
+};
+
+/*
+ * EC2 IMDS_V1 takes one http request to get resource, while IMDS_V2 takes one more token (Http PUT) request
+ * to get secure token used in following request.
+ */
+enum aws_imds_protocol_version {
+ /**
+ * Defaults to IMDS_PROTOCOL_V2. It can be set to either one and IMDS Client
+ * will figure out (by looking at response code) which protocol an instance
+ * is using. But a more clear setting will reduce unnecessary network request.
+ */
+ IMDS_PROTOCOL_V2,
+ IMDS_PROTOCOL_V1,
+};
+
+/**
+ * Configuration options for the provider that sources credentials from ec2 instance metadata
+ */
+struct aws_credentials_provider_imds_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /*
+ * Connection bootstrap to use for any network connections made while sourcing credentials
+ */
+ struct aws_client_bootstrap *bootstrap;
+
+ /*
+ * Which version of the imds query protocol to use.
+ */
+ enum aws_imds_protocol_version imds_version;
+
+ /*
+ * If true, fallback from v2 to v1 will be disabled for all cases
+ */
+ bool ec2_metadata_v1_disabled;
+
+ /* For mocking the http layer in tests, leave NULL otherwise */
+ struct aws_auth_http_system_vtable *function_table;
+};
+
+/*
+ * Configuration options for the provider that sources credentials from ECS container metadata.
+ * The ECS creds provider can be used to access creds via either a relative URI to a fixed endpoint
+ * (http://169.254.170.2) or via a full URI specified by environment variables (in order of priority):
+ * AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
+ * AWS_CONTAINER_CREDENTIALS_FULL_URI
+ *
+ *`AWS_CONTAINER_CREDENTIALS_FULL_URI` URL must satisfy one of the following:
+ * 1. The URL begins with `https`.
+ * 2. The resolved IP address is within the loopback CIDR (IPv4 127.0.0.0/8, IPv6 ::1/128), ECS container address
+ * (169.254.170.2), or EKS Pod Identity address (169.254.170.23 or fd00:ec2::23).
+ *
+ * For the Authorization token, there are two ways (in order of priority):
+ * 1. AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE (an env var which contains the absolute path to the token file. The file
+ * will be re-read for each call to get credentials.)
+ * 2. AWS_CONTAINER_AUTHORIZATION_TOKEN (an env var that contains a static auth token)
+ */
+struct aws_credentials_provider_ecs_environment_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /*
+ * (Required)
+ * Connection bootstrap to use for any network connections made while sourcing credentials
+ */
+ struct aws_client_bootstrap *bootstrap;
+
+ /*
+ * (Required)
+ * Client TLS context to use when making a query. This will only be used if the AWS_CONTAINER_CREDENTIALS_FULL_URI
+ * is set and starts with https
+ */
+ struct aws_tls_ctx *tls_ctx;
+
+ /* For mocking the http layer in tests, leave NULL otherwise */
+ struct aws_auth_http_system_vtable *function_table;
+};
+
+/*
+ * Configuration options for the provider that sources credentials from ECS container metadata.
+ * This options struct doesn't read anything from the environment and requires everything to be explicitly passed in. If
+ * you need to read properties from the environment, use the `aws_credentials_provider_ecs_environment_options`.
+ *
+ *`host` must satisfy one of the following:
+ * 1. tls_context is set
+ * 2. The resolved IP address is within the loopback CIDR (IPv4 127.0.0.0/8, IPv6 ::1/128), ECS container address
+ * (169.254.170.2), or EKS Pod Identity address (169.254.170.23 or fd00:ec2::23).
+ */
+struct aws_credentials_provider_ecs_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /*
+ * Connection bootstrap to use for any network connections made while sourcing credentials
+ */
+ struct aws_client_bootstrap *bootstrap;
+
+ /*
+ * Host to query credentials from
+ */
+ struct aws_byte_cursor host;
+
+ /*
+ * Http path and query string for the credentials query
+ */
+ struct aws_byte_cursor path_and_query;
+
+ /*
+ * Authorization token file path to include in the credentials query. The file will be re-read for each call to
+ * get_credentials.
+ * This has higher priority than `auth_token`.
+ */
+ struct aws_byte_cursor auth_token_file_path;
+
+ /*
+ * Authorization token to include in the credentials query.
+ * No effect if `auth_token_file_path` is set.
+ */
+ struct aws_byte_cursor auth_token;
+
+ /*
+ * Client TLS context to use when making query.
+ * If set, port 443 is used. If NULL, port 80 is used.
+ */
+ struct aws_tls_ctx *tls_ctx;
+
+ /* For mocking the http layer in tests, leave NULL otherwise */
+ struct aws_auth_http_system_vtable *function_table;
+
+ /*
+ * Port to query credentials from. If zero, 80/443 will be used based on whether or not tls is enabled.
+ */
+ uint32_t port;
+};
+
+/**
+ * Configuration options for the X509 credentials provider
+ *
+ * The x509 credentials provider sources temporary credentials from AWS IoT Core using TLS mutual authentication.
+ * See details: https://docs.aws.amazon.com/iot/latest/developerguide/authorizing-direct-aws.html
+ * An end to end demo with detailed steps can be found here:
+ * https://aws.amazon.com/blogs/security/how-to-eliminate-the-need-for-hardcoded-aws-credentials-in-devices-by-using-the-aws-iot-credentials-provider/
+ */
+struct aws_credentials_provider_x509_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /*
+ * Connection bootstrap to use for any network connections made while sourcing credentials
+ */
+ struct aws_client_bootstrap *bootstrap;
+
+ /* TLS connection options that have been initialized with your x509 certificate and private key */
+ const struct aws_tls_connection_options *tls_connection_options;
+
+ /* IoT thing name you registered with AWS IOT for your device, it will be used in http request header */
+ struct aws_byte_cursor thing_name;
+
+ /* Iot role alias you created with AWS IoT for your IAM role, it will be used in http request path */
+ struct aws_byte_cursor role_alias;
+
+ /**
+ * Per-account X509 credentials sourcing endpoint.
+ */
+ struct aws_byte_cursor endpoint;
+
+ /**
+ * (Optional) Http proxy configuration for the http request that fetches credentials
+ */
+ const struct aws_http_proxy_options *proxy_options;
+
+ /* For mocking the http layer in tests, leave NULL otherwise */
+ struct aws_auth_http_system_vtable *function_table;
+};
+
+/**
+ * Configuration options for the STS web identity provider
+ *
+ * Sts with web identity credentials provider sources a set of temporary security credentials for users who have been
+ * authenticated in a mobile or web application with a web identity provider.
+ * Example providers include Amazon Cognito, Login with Amazon, Facebook, Google, or any OpenID Connect-compatible
+ * identity provider like Elastic Kubernetes Service
+ * https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html
+ * The required parameters used in the request (region, roleArn, sessionName, tokenFilePath) are automatically resolved
+ * by SDK from envrionment variables or config file if not set.
+ ---------------------------------------------------------------------------------
+ | Parameter | Environment Variable Name | Config File Property Name |
+ ----------------------------------------------------------------------------------
+ | region | AWS_REGION/AWS_DEFAULT_REGION| region |
+ | role_arn | AWS_ROLE_ARN | role_arn |
+ | role_session_name | AWS_ROLE_SESSION_NAME | role_session_name |
+ | token_file_path | AWS_WEB_IDENTITY_TOKEN_FILE | web_identity_token_file |
+ |--------------------------------------------------------------------------------|
+ * The order of resolution is the following
+ * 1. Parameters
+ * 2. Environment Variables (in case of region, the AWS_REGION is preferred over the AWS_DEFAULT_REGION)
+ * 3. Config File
+ */
+struct aws_credentials_provider_sts_web_identity_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /*
+ * Connection bootstrap to use for any network connections made while sourcing credentials
+ */
+ struct aws_client_bootstrap *bootstrap;
+
+ /**
+ * (Optional)
+ * Use a cached config profile collection. You can also pass a merged collection.
+ */
+ struct aws_profile_collection *config_profile_collection_cached;
+
+ /*
+ * Client TLS context to use when querying STS web identity provider.
+ * Required.
+ */
+ struct aws_tls_ctx *tls_ctx;
+
+ /* For mocking the http layer in tests, leave NULL otherwise */
+ struct aws_auth_http_system_vtable *function_table;
+
+ /*
+ * (Optional)
+ * Override of what profile to use, if not set, 'default' will be used.
+ */
+ struct aws_byte_cursor profile_name_override;
+
+ /*
+ * (Optional)
+ * Override of region, if not set, it will be resolved from env or profile.
+ */
+ struct aws_byte_cursor region;
+ /*
+ * (Optional)
+ * Override of role_arn, if not set, it will be resolved from env or profile.
+ */
+ struct aws_byte_cursor role_arn;
+ /*
+ * (Optional)
+ * Override of role_session_name, if not set, it will be resolved from env or profile.
+ */
+ struct aws_byte_cursor role_session_name;
+ /*
+ * (Optional)
+ * Override of token_file_path, if not set, it will be resolved from env or profile.
+ */
+ struct aws_byte_cursor token_file_path;
+};
+
+/*
+ * Configuration for the SSOCredentialsProvider that sends a GetRoleCredentialsRequest to the AWS Single
+ * Sign-On Service to maintain short-lived sessions to use for authentication.
+ *
+ * https://docs.aws.amazon.com/sdkref/latest/guide/feature-sso-credentials.html
+ */
+struct aws_credentials_provider_sso_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /*
+ * Override of what profile to use to source credentials from ('default' by default)
+ */
+ struct aws_byte_cursor profile_name_override;
+
+ /*
+ * Override path to the profile config file (~/.aws/config by default)
+ */
+ struct aws_byte_cursor config_file_name_override;
+
+ /**
+ * (Optional)
+ * Use a cached config profile collection. You can also pass a merged collection.
+ * config_file_name_override will be ignored if this option is provided.
+ */
+ struct aws_profile_collection *config_file_cached;
+
+ /*
+ * Connection bootstrap to use for any network connections made while sourcing credentials
+ * Required.
+ */
+ struct aws_client_bootstrap *bootstrap;
+
+ /*
+ * Client TLS context to use when querying SSO provider.
+ * Required.
+ */
+ struct aws_tls_ctx *tls_ctx;
+
+ /* For mocking, leave NULL otherwise */
+ struct aws_auth_http_system_vtable *function_table;
+ aws_io_clock_fn *system_clock_fn;
+};
+
+/**
+ * Configuration options for the STS credentials provider.
+ * STS Credentials Provider will try to automatically resolve the region and use a regional STS endpoint if successful.
+ * The region resolution order is the following:
+ * 1. AWS_REGION environment variable
+ * 2. AWS_DEFAULT_REGION environment variable
+ * 3. The region property in the config file.
+ */
+struct aws_credentials_provider_sts_options {
+ /*
+ * Connection bootstrap to use for any network connections made while sourcing credentials
+ */
+ struct aws_client_bootstrap *bootstrap;
+
+ /*
+ * Client TLS context to use when querying STS.
+ * Required.
+ */
+ struct aws_tls_ctx *tls_ctx;
+
+ /*
+ * Credentials provider to be used to sign the requests made to STS to fetch credentials.
+ */
+ struct aws_credentials_provider *creds_provider;
+
+ /*
+ * Arn of the role to assume by fetching credentials for
+ */
+ struct aws_byte_cursor role_arn;
+
+ /*
+ * Assumed role session identifier to be associated with the sourced credentials
+ */
+ struct aws_byte_cursor session_name;
+
+ /*
+ * (Optional) Unique identifier for assuming a role in another account
+ */
+ struct aws_byte_cursor external_id;
+
+ /*
+ * How long sourced credentials should remain valid for, in seconds. 900 is the minimum allowed value.
+ */
+ uint16_t duration_seconds;
+
+ /**
+ * (Optional) Http proxy configuration for the AssumeRole http request that fetches credentials
+ */
+ const struct aws_http_proxy_options *http_proxy_options;
+
+ /**
+ * (Optional)
+ * Uses a cached config file profile collection (~/.aws/config). You can also pass a merged profile collection,
+ * which contains both a config file and a credentials file.
+ * If provided, config_file_name_override is ignored.
+ */
+ struct aws_profile_collection *profile_collection_cached;
+
+ /*
+ * (Optional)
+ * Override of what profile to use; if not set, 'default' will be used.
+ */
+ struct aws_byte_cursor profile_name_override;
+
+ /*
+ * (Optional)
+ * Override path to the profile config file (~/.aws/config by default).
+ */
+ struct aws_byte_cursor config_file_name_override;
+
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /* For mocking, leave NULL otherwise */
+ struct aws_auth_http_system_vtable *function_table;
+ aws_io_clock_fn *system_clock_fn;
+};
+
+/**
+ *
+ * Configuration options for the process credentials provider
+ *
+ * The process credentials provider sources credentials from running a command or process.
+ * The command to run is sourced from a profile in the AWS config file, using the standard
+ * profile selection rules. The profile key the command is read from is "credential_process."
+ * E.g.:
+ * [default]
+ * credential_process=/opt/amazon/bin/my-credential-fetcher --argsA=abc
+ * On successfully running the command, the output should be a json data with the following
+ * format:
+ * {
+ "Version": 1,
+ "AccessKeyId": "accesskey",
+ "SecretAccessKey": "secretAccessKey"
+ "SessionToken": "....",
+ "Expiration": "2019-05-29T00:21:43Z"
+ }
+ * Version here identifies the command output format version.
+ */
+struct aws_credentials_provider_process_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+ /**
+ * In which profile name to look for credential_process,
+ * if not provided, we will try environment variable: AWS_PROFILE.
+ */
+ struct aws_byte_cursor profile_to_use;
+
+ /**
+ * (Optional)
+ * Use a cached config profile collection. You can also pass a merged collection.
+ */
+ struct aws_profile_collection *config_profile_collection_cached;
+};
+
+/**
+ * Configuration options for the default credentials provider chain.
+ */
+struct aws_credentials_provider_chain_default_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /*
+ * Connection bootstrap to use for any network connections made while sourcing credentials
+ */
+ struct aws_client_bootstrap *bootstrap;
+
+ /*
+ * Client TLS context to use for any secure network connections made while sourcing credentials.
+ *
+ * If not provided the default chain will construct a new one, but these
+ * are expensive objects so you are encouraged to pass in a shared one.
+ *
+ * Must be provided if using BYO_CRYPTO.
+ */
+ struct aws_tls_ctx *tls_ctx;
+
+ /**
+ * (Optional)
+ * Use a cached merged profile collection. A merge collection has both config file
+ * (~/.aws/config) and credentials file based profile collection (~/.aws/credentials) using
+ * `aws_profile_collection_new_from_merge`.
+ */
+ struct aws_profile_collection *profile_collection_cached;
+
+ /*
+ * (Optional)
+ * Override of what profile to use, if not set, 'default' will be used.
+ */
+ struct aws_byte_cursor profile_name_override;
+
+ /*
+ * (Optional)
+ * If enabled, the Environment Credentials Provider is not added to the chain.
+ */
+ bool skip_environment_credentials_provider;
+};
+
+typedef int(aws_credentials_provider_delegate_get_credentials_fn)(
+ void *delegate_user_data,
+ aws_on_get_credentials_callback_fn callback,
+ void *callback_user_data);
+
+/**
+ * Configuration options for the delegate credentials provider.
+ */
+struct aws_credentials_provider_delegate_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /**
+ * Delegated get_credentials() callback.
+ */
+ aws_credentials_provider_delegate_get_credentials_fn *get_credentials;
+
+ /**
+ * User data for delegated callbacks.
+ */
+ void *delegate_user_data;
+};
+
+/**
+ * A (string) pair defining an identity provider and a valid login token sourced from it.
+ */
+struct aws_cognito_identity_provider_token_pair {
+
+ /**
+ * Name of an identity provider
+ */
+ struct aws_byte_cursor identity_provider_name;
+
+ /**
+ * Valid login token source from the identity provider
+ */
+ struct aws_byte_cursor identity_provider_token;
+};
+
+typedef void(aws_credentials_provider_cognito_get_token_pairs_completion_fn)(
+ struct aws_cognito_identity_provider_token_pair *logins,
+ size_t login_count,
+ int error_code,
+ void *completion_user_data);
+
+typedef int(aws_credentials_provider_cognito_get_token_pairs_async_fn)(
+ void *get_token_pairs_user_data,
+ aws_credentials_provider_cognito_get_token_pairs_completion_fn *completion_callback,
+ void *completion_user_data);
+
+/**
+ * Configuration options needed to create a Cognito-based Credentials Provider
+ */
+struct aws_credentials_provider_cognito_options {
+ struct aws_credentials_provider_shutdown_options shutdown_options;
+
+ /**
+ * Cognito service regional endpoint to source credentials from.
+ */
+ struct aws_byte_cursor endpoint;
+
+ /**
+ * Cognito identity to fetch credentials relative to.
+ */
+ struct aws_byte_cursor identity;
+
+ /**
+ * Optional set of identity provider token pairs to allow for authenticated identity access.
+ */
+ struct aws_cognito_identity_provider_token_pair *logins;
+ size_t login_count;
+
+ /**
+ * Optional ARN of the role to be assumed when multiple roles were received in the token from the identity provider.
+ */
+ struct aws_byte_cursor *custom_role_arn;
+
+ /**
+ * Connection bootstrap to use for network connections made while sourcing credentials
+ */
+ struct aws_client_bootstrap *bootstrap;
+
+ /**
+ * Client TLS context to use when querying cognito credentials.
+ * Required.
+ */
+ struct aws_tls_ctx *tls_ctx;
+
+ /**
+ * (Optional) Http proxy configuration for the http request that fetches credentials
+ */
+ const struct aws_http_proxy_options *http_proxy_options;
+
+ /* For mocking the http layer in tests, leave NULL otherwise */
+ struct aws_auth_http_system_vtable *function_table;
+
+ /**
+ * Optional async function to allow for dynamic augmentation of the token pair set on a per-request basis.
+ */
+ aws_credentials_provider_cognito_get_token_pairs_async_fn *get_token_pairs;
+
+ /**
+ * User data that should be passed in to the get_token_pairs function as the first parameter. In practice, this
+ * will be a reference to a CRT binding object.
+ */
+ void *get_token_pairs_user_data;
+};
+
+/**
+ * Configuration options for `aws_credentials_new_with_options`
+ */
+struct aws_credentials_options {
+
+ /* Value for the aws access key id field */
+ struct aws_byte_cursor access_key_id_cursor;
+ /* Value for the secret access key field */
+ struct aws_byte_cursor secret_access_key_cursor;
+ /* (Optional) security token associated with the credentials */
+ struct aws_byte_cursor session_token_cursor;
+ /* (Optional) account id associated with the credentials */
+ struct aws_byte_cursor account_id_cursor;
+ /* Time point, in seconds since epoch, that the credentials will no longer be valid.
+ * For credentials that do not expire, use UINT64_MAX. */
+ uint64_t expiration_timepoint_seconds;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/*
+ * Credentials APIs
+ *
+ * expiration_timepoint_seconds is the timepoint, in seconds since epoch, that the credentials will no longer
+ * be valid. For credentials that do not expire, use UINT64_MAX.
+ */
+
+/**
+ * Creates a new set of aws credentials
+ *
+ * @param allocator memory allocator to use
+ * @param access_key_id_cursor value for the aws access key id field
+ * @param secret_access_key_cursor value for the secret access key field
+ * @param session_token_cursor (optional) security token associated with the credentials
+ * @param expiration_timepoint_seconds timepoint, in seconds since epoch, that the credentials will no longer
+ * be valid past. For credentials that do not expire, use UINT64_MAX
+ *
+ * @return a valid credentials object, or NULL
+ */
+AWS_AUTH_API
+struct aws_credentials *aws_credentials_new(
+ struct aws_allocator *allocator,
+ struct aws_byte_cursor access_key_id_cursor,
+ struct aws_byte_cursor secret_access_key_cursor,
+ struct aws_byte_cursor session_token_cursor,
+ uint64_t expiration_timepoint_seconds);
+
+/**
+ * Creates a new set of aws credentials with account_id
+ *
+ * @param allocator memory allocator to use
+ * @param access_key_id_cursor value for the aws access key id field
+ * @param secret_access_key_cursor value for the secret access key field
+ * @param session_token_cursor (optional) security token associated with the credentials
+ * @param account_id (optional) value for the account_id field
+ * @param expiration_timepoint_seconds timepoint, in seconds since epoch, that the credentials will no longer
+ * be valid past. For credentials that do not expire, use UINT64_MAX
+ *
+ * @return a valid credentials object, or NULL
+ */
+AWS_AUTH_API
+struct aws_credentials *aws_credentials_new_with_options(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_options *options);
+
+/**
+ * Creates a new set of aws anonymous credentials.
+ * Use Anonymous credentials, when you want to skip the signing process.
+ *
+ * @param allocator memory allocator to use
+ *
+ * @return a valid credentials object, or NULL
+ */
+AWS_AUTH_API
+struct aws_credentials *aws_credentials_new_anonymous(struct aws_allocator *allocator);
+
+/**
+ * Creates a new set of AWS credentials
+ *
+ * @param allocator memory allocator to use
+ * @param access_key_id value for the aws access key id field
+ * @param secret_access_key value for the secret access key field
+ * @param session_token (optional) security token associated with the credentials
+ * @param expiration_timepoint_seconds timepoint, in seconds since epoch, that the credentials will no longer
+ * be valid past. For credentials that do not expire, use UINT64_MAX
+ *
+ * @return a valid credentials object, or NULL
+ */
+AWS_AUTH_API
+struct aws_credentials *aws_credentials_new_from_string(
+ struct aws_allocator *allocator,
+ const struct aws_string *access_key_id,
+ const struct aws_string *secret_access_key,
+ const struct aws_string *session_token,
+ uint64_t expiration_timepoint_seconds);
+
+/**
+ * Creates a set of AWS credentials that includes an ECC key pair. These credentials do not have a value for
+ * the secret access key; the ecc key takes over that field's role in sigv4a signing.
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param access_key_id access key id for the credential set
+ * @param ecc_key ecc key to use during signing when using these credentials
+ * @param session_token (optional) session token associated with the credentials
+ * @param expiration_timepoint_in_seconds (optional) if session-based, time at which these credentials expire
+ * @return a new pair of AWS credentials, or NULL
+ */
+AWS_AUTH_API
+struct aws_credentials *aws_credentials_new_ecc(
+ struct aws_allocator *allocator,
+ struct aws_byte_cursor access_key_id,
+ struct aws_ecc_key_pair *ecc_key,
+ struct aws_byte_cursor session_token,
+ uint64_t expiration_timepoint_in_seconds);
+
+/*
+ * Takes a pair of AWS credentials and performs the sigv4a key expansion algorithm to generate a unique
+ * ecc P256 key pair based on the credentials. The ecc key is written to the buffer in DER format.
+ *
+ * Sigv4a signing takes the raw DER-encoded ecc key as an optional parameter in signing (if not present,
+ * key expansion will be done for the caller before signing).
+ */
+AWS_AUTH_API
+struct aws_credentials *aws_credentials_new_ecc_from_aws_credentials(
+ struct aws_allocator *allocator,
+ const struct aws_credentials *credentials);
+
+/**
+ * Add a reference to some credentials
+ *
+ * @param credentials credentials to increment the ref count on
+ */
+AWS_AUTH_API
+void aws_credentials_acquire(const struct aws_credentials *credentials);
+
+/**
+ * Remove a reference to some credentials
+ *
+ * @param credentials credentials to decrement the ref count on
+ */
+AWS_AUTH_API
+void aws_credentials_release(const struct aws_credentials *credentials);
+
+/**
+ * Get the AWS access key id from a set of credentials
+ *
+ * @param credentials credentials to get the access key id from
+ * @return a byte cursor to the access key id
+ */
+AWS_AUTH_API
+struct aws_byte_cursor aws_credentials_get_access_key_id(const struct aws_credentials *credentials);
+
+/**
+ * Get the AWS secret access key from a set of credentials
+ *
+ * @param credentials credentials to get the secret access key from
+ * @return a byte cursor to the secret access key
+ */
+AWS_AUTH_API
+struct aws_byte_cursor aws_credentials_get_secret_access_key(const struct aws_credentials *credentials);
+
+/**
+ * Get the AWS session token from a set of credentials
+ *
+ * @param credentials credentials to get the session token from
+ * @return a byte cursor to the session token or an empty byte cursor if there is no session token
+ */
+AWS_AUTH_API
+struct aws_byte_cursor aws_credentials_get_session_token(const struct aws_credentials *credentials);
+
+/**
+ * Get the AWS account id from a set of credentials
+ *
+ * @param credentials to get the account id from
+ * @return a byte cursor to the account id or an empty byte cursor if there is no account id
+ */
+AWS_AUTH_API
+struct aws_byte_cursor aws_credentials_get_account_id(const struct aws_credentials *credentials);
+
+/**
+ * Get the expiration timepoint (in seconds since epoch) associated with a set of credentials
+ *
+ * @param credentials credentials to get the expiration timepoint for
+ * @return the time, in seconds since epoch, the credentials will expire; UINT64_MAX for credentials
+ * without a specific expiration time
+ */
+AWS_AUTH_API
+uint64_t aws_credentials_get_expiration_timepoint_seconds(const struct aws_credentials *credentials);
+
+/**
+ * Get the elliptic curve key associated with this set of credentials
+ * @param credentials credentials to get the the elliptic curve key for
+ * @return the elliptic curve key associated with the credentials, or NULL if no key is associated with
+ * these credentials
+ */
+AWS_AUTH_API
+struct aws_ecc_key_pair *aws_credentials_get_ecc_key_pair(const struct aws_credentials *credentials);
+
+/**
+ * If credentials are anonymous, then the signing process is skipped.
+ *
+ * @param credentials credentials to check
+ *
+ * @return true if the credentials are anonymous; false otherwise.
+ */
+AWS_AUTH_API
+bool aws_credentials_is_anonymous(const struct aws_credentials *credentials);
+
+/**
+ * Derives an ecc key pair (based on the nist P256 curve) from the access key id and secret access key components
+ * of a set of AWS credentials using an internal key derivation specification. Used to perform sigv4a signing in
+ * the hybrid mode based on AWS credentials.
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param credentials AWS credentials to derive the ECC key from using the AWS sigv4a key derivation specification
+ * @return a new ecc key pair or NULL on failure
+ */
+AWS_AUTH_API
+struct aws_ecc_key_pair *aws_ecc_key_pair_new_ecdsa_p256_key_from_aws_credentials(
+ struct aws_allocator *allocator,
+ const struct aws_credentials *credentials);
+
+/*
+ * Credentials provider APIs
+ */
+
+/**
+ * Release a reference to a credentials provider
+ *
+ * @param provider provider to decrement the ref count on
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_release(struct aws_credentials_provider *provider);
+
+/*
+ * Add a reference to a credentials provider
+ *
+ * @param provider provider to increment the ref count on
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_acquire(struct aws_credentials_provider *provider);
+
+/*
+ * Async function for retrieving credentials from a provider
+ *
+ * @param provider credentials provider to source from
+ * @param callback completion callback to invoke when the fetch has completed or failed
+ * @param user_data user data to pass to the completion callback
+ *
+ * @return AWS_OP_SUCCESS if the fetch was successfully started, AWS_OP_ERR otherwise. The completion
+ * callback will only be invoked if-and-only-if the return value was AWS_OP_SUCCESS.
+ *
+ */
+AWS_AUTH_API
+int aws_credentials_provider_get_credentials(
+ struct aws_credentials_provider *provider,
+ aws_on_get_credentials_callback_fn callback,
+ void *user_data);
+
+/*
+ * Credentials provider variant creation
+ */
+
+/**
+ * Creates a simple provider that just returns a fixed set of credentials
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_static(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_static_options *options);
+
+/**
+ * Creates a simple anonymous credentials provider
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param shutdown_options an optional shutdown callback that gets
+ * invoked when the resources used by the provider are no longer in use.
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_anonymous(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_shutdown_options *shutdown_options);
+
+/**
+ * Creates a provider that returns credentials sourced from the environment variables:
+ *
+ * AWS_ACCESS_KEY_ID
+ * AWS_SECRET_ACCESS_KEY
+ * AWS_SESSION_TOKEN
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_environment(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_environment_options *options);
+
+/**
+ * Creates a provider that functions as a caching decorating of another provider.
+ *
+ * For example, the default chain is implemented as:
+ *
+ * CachedProvider -> ProviderChain(EnvironmentProvider -> ProfileProvider -> ECS/EC2IMD etc...)
+ *
+ * A reference is taken on the target provider
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_cached(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_cached_options *options);
+
+/**
+ * Creates a provider that sources credentials from key-value profiles loaded from the aws credentials
+ * file ("~/.aws/credentials" by default) and the aws config file ("~/.aws/config" by
+ * default)
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_profile(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_profile_options *options);
+
+/**
+ * Creates a provider that assumes an IAM role via. STS AssumeRole() API. This provider will fetch new credentials
+ * upon each call to aws_credentials_provider_get_credentials().
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_sts(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_sts_options *options);
+
+/**
+ * Creates a provider that sources credentials from an ordered sequence of providers, with the overall result
+ * being from the first provider to return a valid set of credentials
+ *
+ * References are taken on all supplied providers
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_chain(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_chain_options *options);
+
+/**
+ * Creates a provider that sources credentials from the ec2 instance metadata service
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_imds(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_imds_options *options);
+
+/**
+ * Creates a provider that sources credentials from the ecs role credentials service and reads the required params from
+ * environment variables
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_ecs_from_environment(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_ecs_environment_options *options);
+
+/**
+ * Creates a provider that sources credentials from the ecs role credentials service
+ * This function doesn't read anything from the environment and requires everything to be explicitly passed in.
+ * If you need to read properties from the environment, use the `aws_credentials_provider_new_ecs_from_environment`.
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_ecs(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_ecs_options *options);
+
+/**
+ * Creates a provider that sources credentials from IoT Core
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_x509(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_x509_options *options);
+
+/**
+ * Creates a provider that sources credentials from STS using AssumeRoleWithWebIdentity
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_sts_web_identity(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_sts_web_identity_options *options);
+
+/**
+ * Creates a provider that sources credentials from SSO using a SSOToken.
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_sso(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_sso_options *options);
+
+/*
+ * Creates a provider that sources credentials from running an external command or process
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_process(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_process_options *options);
+
+/**
+ * Create a credentials provider depends on provided vtable to fetch the credentials.
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_delegate(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_delegate_options *options);
+
+/**
+ * Creates a provider that sources credentials from the Cognito-Identity service via an
+ * invocation of the GetCredentialsForIdentity API call.
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_cognito(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_cognito_options *options);
+
+/**
+ * Creates a cognito-based provider that has a caching layer wrapped around it
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options cognito-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_cognito_caching(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_cognito_options *options);
+
+/**
+ * Creates the default provider chain used by most AWS SDKs.
+ *
+ * Generally:
+ *
+ * (1) Environment
+ * (2) Profile
+ * - STSCredentialsProvider
+ * - ProcessCredentialsProvider
+ * - ProfileCredentialsProvider
+ * (3) STS web identity
+ * (4) (conditional, off by default) ECS
+ * (5) (conditional, on by default) EC2 Instance Metadata
+ *
+ * Support for environmental control of the default provider chain is not yet
+ * implemented.
+ *
+ * @param allocator memory allocator to use for all memory allocation
+ * @param options provider-specific configuration options
+ *
+ * @return the newly-constructed credentials provider, or NULL if an error occurred.
+ */
+AWS_AUTH_API
+struct aws_credentials_provider *aws_credentials_provider_new_chain_default(
+ struct aws_allocator *allocator,
+ const struct aws_credentials_provider_chain_default_options *options);
+
+AWS_AUTH_API extern const struct aws_auth_http_system_vtable *g_aws_credentials_provider_http_function_table;
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_AUTH_CREDENTIALS_H */
diff --git a/include/aws/auth/exports.h b/include/aws/auth/exports.h
new file mode 100644
index 0000000000000000000000000000000000000000..9f8fe013fcfa52347bbe5bb35e63a6f689cf3b61
--- /dev/null
+++ b/include/aws/auth/exports.h
@@ -0,0 +1,29 @@
+#ifndef AWS_AUTH_EXPORTS_H
+#define AWS_AUTH_EXPORTS_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#if defined(USE_WINDOWS_DLL_SEMANTICS) || defined(WIN32)
+# ifdef AWS_AUTH_USE_IMPORT_EXPORT
+# ifdef AWS_AUTH_EXPORTS
+# define AWS_AUTH_API __declspec(dllexport)
+# else
+# define AWS_AUTH_API __declspec(dllimport)
+# endif /* AWS_AUTH_EXPORTS */
+# else
+# define AWS_AUTH_API
+# endif /*USE_IMPORT_EXPORT */
+
+#else
+# if ((__GNUC__ >= 4) || defined(__clang__)) && defined(AWS_AUTH_USE_IMPORT_EXPORT) && defined(AWS_AUTH_EXPORTS)
+# define AWS_AUTH_API __attribute__((visibility("default")))
+# else
+# define AWS_AUTH_API
+# endif /* __GNUC__ >= 4 || defined(__clang__) */
+
+#endif /* defined(USE_WINDOWS_DLL_SEMANTICS) || defined(WIN32) */
+
+#endif /* AWS_AUTH_EXPORTS_H */
diff --git a/include/aws/auth/signable.h b/include/aws/auth/signable.h
new file mode 100644
index 0000000000000000000000000000000000000000..86c32de69b045427fa1910e4f106e411e80cb46b
--- /dev/null
+++ b/include/aws/auth/signable.h
@@ -0,0 +1,237 @@
+#ifndef AWS_AUTH_SIGNABLE_H
+#define AWS_AUTH_SIGNABLE_H
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_http_message;
+struct aws_http_headers;
+struct aws_input_stream;
+struct aws_signable;
+struct aws_string;
+
+/*
+ * While not referenced directly in this file, this is the structure expected to be in the property lists
+ */
+struct aws_signable_property_list_pair {
+ struct aws_byte_cursor name;
+ struct aws_byte_cursor value;
+};
+
+typedef int(aws_signable_get_property_fn)(
+ const struct aws_signable *signable,
+ const struct aws_string *name,
+ struct aws_byte_cursor *out_value);
+
+typedef int(aws_signable_get_property_list_fn)(
+ const struct aws_signable *signable,
+ const struct aws_string *name,
+ struct aws_array_list **out_list);
+
+typedef int(aws_signable_get_payload_stream_fn)(
+ const struct aws_signable *signable,
+ struct aws_input_stream **out_input_stream);
+
+typedef void(aws_signable_destroy_fn)(struct aws_signable *signable);
+
+struct aws_signable_vtable {
+ aws_signable_get_property_fn *get_property;
+ aws_signable_get_property_list_fn *get_property_list;
+ aws_signable_get_payload_stream_fn *get_payload_stream;
+ aws_signable_destroy_fn *destroy;
+};
+
+/**
+ * Signable is a generic interface for any kind of object that can be cryptographically signed.
+ *
+ * Like signing_result, the signable interface presents
+ *
+ * (1) Properties - A set of key-value pairs
+ * (2) Property Lists - A set of named key-value pair lists
+ *
+ * as well as
+ *
+ * (3) A message payload modeled as a stream
+ *
+ * When creating a signable "subclass" the query interface should map to retrieving
+ * the properties of the underlying object needed by signing algorithms that can operate on it.
+ *
+ * As an example, if a signable implementation wrapped an http request, you would query
+ * request elements like method and uri from the property interface, headers would be queried
+ * via the property list interface, and the request body would map to the payload stream.
+ *
+ * String constants that map to agreed on keys for particular signable types
+ * ("METHOD", "URI", "HEADERS", etc...) are exposed in appropriate header files.
+ */
+struct aws_signable {
+ struct aws_allocator *allocator;
+ void *impl;
+ struct aws_signable_vtable *vtable;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Cleans up and frees all resources associated with a signable instance
+ *
+ * @param signable signable object to destroy
+ */
+AWS_AUTH_API
+void aws_signable_destroy(struct aws_signable *signable);
+
+/**
+ * Retrieves a property (key-value pair) from a signable. Global property name constants are
+ * included below.
+ *
+ * @param signable signable object to retrieve a property from
+ * @param name name of the property to query
+ * @param out_value output parameter for the property's value
+ *
+ * @return AWS_OP_SUCCESS if the property was successfully fetched, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_signable_get_property(
+ const struct aws_signable *signable,
+ const struct aws_string *name,
+ struct aws_byte_cursor *out_value);
+
+/**
+ * Retrieves a named property list (list of key-value pairs) from a signable. Global property list name
+ * constants are included below.
+ *
+ * @param signable signable object to retrieve a property list from
+ * @param name name of the property list to fetch
+ * @param out_property_list output parameter for the fetched property list
+ *
+ * @return AWS_OP_SUCCESS if the property list was successfully fetched, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_signable_get_property_list(
+ const struct aws_signable *signable,
+ const struct aws_string *name,
+ struct aws_array_list **out_property_list);
+
+/**
+ * Retrieves the signable's message payload as a stream.
+ *
+ * @param signable signable to get the payload of
+ * @param out_input_stream output parameter for the payload stream
+ *
+ * @return AWS_OP_SUCCESS if successful, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_signable_get_payload_stream(const struct aws_signable *signable, struct aws_input_stream **out_input_stream);
+
+/*
+ * Some global property and property-list name constants
+ */
+
+/**
+ * Name of the property list that wraps the headers of an http request
+ */
+AWS_AUTH_API extern const struct aws_string *g_aws_http_headers_property_list_name;
+
+/**
+ * Name of the property list that wraps the query params of an http request. Only used by signing_result.
+ * For input to a http signing algorithm, query params are assumed to be part of the uri.
+ */
+AWS_AUTH_API extern const struct aws_string *g_aws_http_query_params_property_list_name;
+
+/**
+ * Name of the property that holds the method of an http request
+ */
+AWS_AUTH_API extern const struct aws_string *g_aws_http_method_property_name;
+
+/**
+ * Name of the property that holds the URI of an http request
+ */
+AWS_AUTH_API extern const struct aws_string *g_aws_http_uri_property_name;
+
+/**
+ * Name of the property that holds the signature value. This is always added to signing results.
+ * Depending on the requested signature type, the signature may be padded or encoded differently:
+ * (1) Header - hex encoding of the binary signature value
+ * (2) QueryParam - hex encoding of the binary signature value
+ * (3) Chunk/Sigv4 - hex encoding of the binary signature value
+ * (4) Chunk/Sigv4a - fixed-size-rhs-padded (with AWS_SIGV4A_SIGNATURE_PADDING_BYTE) hex encoding of the
+ * binary signature value
+ * (5) Event - binary signature value (NYI)
+ */
+AWS_AUTH_API extern const struct aws_string *g_aws_signature_property_name;
+
+/**
+ * Name of the property that holds the (hex-encoded) signature value of the signing event that preceded this one.
+ * This property must appear on signables that represent chunks or events.
+ */
+AWS_AUTH_API extern const struct aws_string *g_aws_previous_signature_property_name;
+
+/**
+ * Name of the property that holds the canonical request associated with this signable.
+ * This property must appear on signables that represent an http request's canonical request.
+ */
+AWS_AUTH_API extern const struct aws_string *g_aws_canonical_request_property_name;
+
+/*
+ * Common signable constructors
+ */
+
+/**
+ * Creates a signable wrapper around an http request.
+ *
+ * @param allocator memory allocator to use to create the signable
+ * @param request http request to create a signable for
+ *
+ * @return the new signable object, or NULL if failure
+ */
+AWS_AUTH_API
+struct aws_signable *aws_signable_new_http_request(struct aws_allocator *allocator, struct aws_http_message *request);
+
+/**
+ * Creates a signable that represents a unit of chunked encoding within an http request.
+ * This can also be used for Transcribe event signing with encoded payload as chunk_data.
+ *
+ * @param allocator memory allocator use to create the signable
+ * @param chunk_data stream representing the data in the chunk; it should be in its final, encoded form
+ * @param previous_signature the signature computed in the most recent signing that preceded this one. It can be
+ * found by copying the "signature" property from the signing_result of that most recent signing.
+ *
+ * @return the new signable object, or NULL if failure
+ */
+AWS_AUTH_API
+struct aws_signable *aws_signable_new_chunk(
+ struct aws_allocator *allocator,
+ struct aws_input_stream *chunk_data,
+ struct aws_byte_cursor previous_signature);
+
+/**
+ * Creates a signable wrapper around a set of headers.
+ *
+ * @param allocator memory allocator use to create the signable
+ * @param trailing_headers http headers to create a signable for
+ * @param previous_signature the signature computed in the most recent signing that preceded this one. It can be
+ * found by copying the "signature" property from the signing_result of that most recent signing.
+ *
+ * @return the new signable object, or NULL if failure
+ */
+AWS_AUTH_API
+struct aws_signable *aws_signable_new_trailing_headers(
+ struct aws_allocator *allocator,
+ struct aws_http_headers *trailing_headers,
+ struct aws_byte_cursor previous_signature);
+
+/**
+ * Creates a signable that represents a pre-computed canonical request from an http request
+ * @param allocator memory allocator use to create the signable
+ * @param canonical_request text of the canonical request
+ * @return the new signable object, or NULL if failure
+ */
+AWS_AUTH_API
+struct aws_signable *aws_signable_new_canonical_request(
+ struct aws_allocator *allocator,
+ struct aws_byte_cursor canonical_request);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_AUTH_SIGNABLE_H */
diff --git a/include/aws/auth/signing.h b/include/aws/auth/signing.h
new file mode 100644
index 0000000000000000000000000000000000000000..fe481c6898148c33dc0f873f4481caa53e4e2e69
--- /dev/null
+++ b/include/aws/auth/signing.h
@@ -0,0 +1,138 @@
+#ifndef AWS_AUTH_SIGNER_H
+#define AWS_AUTH_SIGNER_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_ecc_key_pair;
+struct aws_signable;
+struct aws_signing_result;
+
+/**
+ * Gets called by the signing function when the signing is complete.
+ *
+ * Note that result will be destroyed after this function returns, so either copy it,
+ * or do all necessary adjustments inside the callback.
+ *
+ * When performing event or chunk signing, you will need to copy out the signature value in order
+ * to correctly configure the signable that wraps the event or chunk you want signed next. The signature is
+ * found in the "signature" property on the signing result. This value must be added as the
+ * "previous-signature" property on the next signable.
+ */
+typedef void(aws_signing_complete_fn)(struct aws_signing_result *result, int error_code, void *userdata);
+
+AWS_EXTERN_C_BEGIN
+
+/*
+ * Takes a signable object and a configuration struct and computes the changes to the signable necessary
+ * for compliance with the signer's signing algorithm.
+ *
+ * This signing function currently supports only the sigv4 algorithm.
+ *
+ * When using this signing function to sign AWS http requests:
+ *
+ * (1) Do not add the following headers to requests before signing:
+ * x-amz-content-sha256,
+ * X-Amz-Date,
+ * Authorization
+ *
+ * (2) Do not add the following query params to requests before signing:
+ * X-Amz-Signature,
+ * X-Amz-Date,
+ * X-Amz-Credential,
+ * X-Amz-Algorithm,
+ * X-Amz-SignedHeaders
+ *
+ * The signing result will tell exactly what header and/or query params to add to the request
+ * to become a fully-signed AWS http request.
+ *
+ *
+ * When using this signing function to sign chunks:
+ *
+ * (1) Use aws_signable_new_chunk() to create the signable object representing the chunk
+ *
+ * The signing result will include the chunk's signature as the "signature" property.
+ *
+ *
+ */
+
+/**
+ * (Asynchronous) entry point to sign something (a request, a chunk, an event) with an AWS signing process.
+ * Depending on the configuration, the signing process may or may not complete synchronously.
+ *
+ * @param allocator memory allocator to use throughout the signing process
+ * @param signable the thing to be signed. See signable.h for common constructors for signables that
+ * wrap different types.
+ * @param base_config pointer to a signing configuration, currently this must be of type aws_signing_config_aws
+ * @param on_complete completion callback to be invoked when signing has finished
+ * @param user_data opaque user data that will be passed to the completion callback
+ *
+ * @return AWS_OP_SUCCESS if the signing attempt was *initiated* successfully, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_sign_request_aws(
+ struct aws_allocator *allocator,
+ const struct aws_signable *signable,
+ const struct aws_signing_config_base *base_config,
+ aws_signing_complete_fn *on_complete,
+ void *userdata);
+
+/**
+ * Test-only API used for cross-library signing verification tests
+ *
+ * Verifies:
+ * (1) The canonical request generated during sigv4a signing of the request matches what is passed in
+ * (2) The signature passed in is a valid ECDSA signature of the hashed string-to-sign derived from the
+ * canonical request
+ *
+ * @param allocator memory allocator to use throughout the signing verification process
+ * @param signable the thing to be signed. See signable.h for common constructors for signables that
+ * wrap different types.
+ * @param base_config pointer to a signing configuration, currently this must be of type aws_signing_config_aws
+ * @param expected_canonical_request_cursor expected result when building the canonical request
+ * @param signature_cursor the actual signature computed from a previous signing of the signable
+ * @param ecc_key_pub_x the x coordinate of the public part of the ecc key to verify the signature
+ * @param ecc_key_pub_y the y coordinate of the public part of the ecc key to verify the signature
+ *
+ * @return AWS_OP_SUCCESS if the signing attempt was *initiated* successfully, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_verify_sigv4a_signing(
+ struct aws_allocator *allocator,
+ const struct aws_signable *signable,
+ const struct aws_signing_config_base *base_config,
+ struct aws_byte_cursor expected_canonical_request_cursor,
+ struct aws_byte_cursor signature_cursor,
+ struct aws_byte_cursor ecc_key_pub_x,
+ struct aws_byte_cursor ecc_key_pub_y);
+
+/**
+ * Another helper function to check a computed sigv4a signature.
+ */
+AWS_AUTH_API
+int aws_validate_v4a_authorization_value(
+ struct aws_allocator *allocator,
+ struct aws_ecc_key_pair *ecc_key,
+ struct aws_byte_cursor string_to_sign_cursor,
+ struct aws_byte_cursor signature_value_cursor);
+
+/**
+ * Removes any padding added to the end of a sigv4a signature. Signature must be hex-encoded.
+ * @param signature signature to remove padding from
+ * @return cursor that ranges over only the valid hex encoding of the sigv4a signature
+ */
+AWS_AUTH_API
+struct aws_byte_cursor aws_trim_padded_sigv4a_signature(struct aws_byte_cursor signature);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_AUTH_SIGNER_H */
diff --git a/include/aws/auth/signing_config.h b/include/aws/auth/signing_config.h
new file mode 100644
index 0000000000000000000000000000000000000000..fa63fbee4508e29490e8d9cf8a2db6a0c6878936
--- /dev/null
+++ b/include/aws/auth/signing_config.h
@@ -0,0 +1,314 @@
+#ifndef AWS_AUTH_SIGNING_CONFIG_H
+#define AWS_AUTH_SIGNING_CONFIG_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_credentials;
+
+typedef bool(aws_should_sign_header_fn)(const struct aws_byte_cursor *name, void *userdata);
+
+/**
+ * A primitive RTTI indicator for signing configuration structs
+ *
+ * There must be one entry per config structure type and it's a fatal error
+ * to put the wrong value in the "config_type" member of your config structure.
+ */
+enum aws_signing_config_type { AWS_SIGNING_CONFIG_AWS = 1 };
+
+/**
+ * All signing configuration structs must match this by having
+ * the config_type member as the first member.
+ */
+struct aws_signing_config_base {
+ enum aws_signing_config_type config_type;
+};
+
+/**
+ * What version of the AWS signing process should we use.
+ */
+enum aws_signing_algorithm {
+ AWS_SIGNING_ALGORITHM_V4,
+ AWS_SIGNING_ALGORITHM_V4_ASYMMETRIC,
+ AWS_SIGNING_ALGORITHM_V4_S3EXPRESS,
+};
+
+/**
+ * What sort of signature should be computed from the signable?
+ */
+enum aws_signature_type {
+ /**
+ * A signature for a full http request should be computed, with header updates applied to the signing result.
+ */
+ AWS_ST_HTTP_REQUEST_HEADERS,
+
+ /**
+ * A signature for a full http request should be computed, with query param updates applied to the signing result.
+ */
+ AWS_ST_HTTP_REQUEST_QUERY_PARAMS,
+
+ /**
+ * Compute a signature for a payload chunk. The signable's input stream should be the chunk data and the
+ * signable should contain the most recent signature value (either the original http request or the most recent
+ * chunk) in the "previous-signature" property.
+ */
+ AWS_ST_HTTP_REQUEST_CHUNK,
+
+ /**
+ * Compute a signature for an event stream event. The signable's input stream should be the encoded event-stream
+ * message (headers + payload), the signable should contain the most recent signature value (either the original
+ * http request or the most recent event) in the "previous-signature" property.
+ *
+ * This option is only supported for Sigv4 for now.
+ */
+ AWS_ST_HTTP_REQUEST_EVENT,
+
+ /**
+ * Compute a signature for an http request via it's already-computed canonical request. Only the authorization
+ * signature header is added to the signing result.
+ */
+ AWS_ST_CANONICAL_REQUEST_HEADERS,
+
+ /**
+ * Compute a signature for an http request via it's already-computed canonical request. Only the authorization
+ * signature query param is added to the signing result.
+ */
+ AWS_ST_CANONICAL_REQUEST_QUERY_PARAMS,
+
+ /**
+ * Compute a signature for the trailing headers.
+ * the signable should contain the most recent signature value (either the original http request or the most recent
+ * chunk) in the "previous-signature" property.
+ */
+ AWS_ST_HTTP_REQUEST_TRAILING_HEADERS
+};
+
+/**
+ * The SHA-256 of an empty string:
+ * 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
+ * For use with `aws_signing_config_aws.signed_body_value`.
+ */
+AWS_AUTH_API extern const struct aws_byte_cursor g_aws_signed_body_value_empty_sha256;
+
+/**
+ * 'UNSIGNED-PAYLOAD'
+ * For use with `aws_signing_config_aws.signed_body_value`.
+ */
+AWS_AUTH_API extern const struct aws_byte_cursor g_aws_signed_body_value_unsigned_payload;
+
+/**
+ * 'STREAMING-UNSIGNED-PAYLOAD-TRAILER'
+ * For use with `aws_signing_config_aws.signed_body_value`.
+ */
+AWS_AUTH_API extern const struct aws_byte_cursor g_aws_signed_body_value_streaming_unsigned_payload_trailer;
+
+/**
+ * 'STREAMING-AWS4-HMAC-SHA256-PAYLOAD'
+ * For use with `aws_signing_config_aws.signed_body_value`.
+ */
+AWS_AUTH_API extern const struct aws_byte_cursor g_aws_signed_body_value_streaming_aws4_hmac_sha256_payload;
+
+/**
+ * 'STREAMING-AWS4-HMAC-SHA256-PAYLOAD-TRAILER'
+ * For use with `aws_signing_config_aws.signed_body_value`.
+ */
+AWS_AUTH_API extern const struct aws_byte_cursor g_aws_signed_body_value_streaming_aws4_hmac_sha256_payload_trailer;
+
+/**
+ * 'STREAMING-AWS4-ECDSA-P256-SHA256-PAYLOAD'
+ * For use with `aws_signing_config_aws.signed_body_value`.
+ */
+AWS_AUTH_API extern const struct aws_byte_cursor g_aws_signed_body_value_streaming_aws4_ecdsa_p256_sha256_payload;
+
+/**
+ * 'STREAMING-AWS4-ECDSA-P256-SHA256-PAYLOAD-TRAILER'
+ * For use with `aws_signing_config_aws.signed_body_value`.
+ */
+AWS_AUTH_API extern const struct aws_byte_cursor
+ g_aws_signed_body_value_streaming_aws4_ecdsa_p256_sha256_payload_trailer;
+
+/**
+ * 'STREAMING-AWS4-HMAC-SHA256-EVENTS'
+ * For use with `aws_signing_config_aws.signed_body_value`.
+ *
+ * Event signing is only supported for Sigv4 for now.
+ */
+AWS_AUTH_API extern const struct aws_byte_cursor g_aws_signed_body_value_streaming_aws4_hmac_sha256_events;
+
+/**
+ * Controls if signing adds a header containing the canonical request's body value
+ */
+enum aws_signed_body_header_type {
+ /**
+ * Do not add a header
+ */
+ AWS_SBHT_NONE,
+
+ /**
+ * Add the "x-amz-content-sha256" header with the canonical request's body value
+ */
+ AWS_SBHT_X_AMZ_CONTENT_SHA256,
+};
+
+/**
+ * A configuration structure for use in AWS-related signing. Currently covers sigv4 only, but is not required to.
+ */
+struct aws_signing_config_aws {
+
+ /**
+ * What kind of config structure is this?
+ */
+ enum aws_signing_config_type config_type;
+
+ /**
+ * What signing algorithm to use.
+ */
+ enum aws_signing_algorithm algorithm;
+
+ /**
+ * What sort of signature should be computed?
+ */
+ enum aws_signature_type signature_type;
+
+ /*
+ * Region-related configuration
+ * (1) If Sigv4, the region to sign against
+ * (2) If Sigv4a, the value of the X-amzn-region-set header (added in signing)
+ */
+ struct aws_byte_cursor region;
+
+ /**
+ * name of service to sign a request for
+ */
+ struct aws_byte_cursor service;
+
+ /**
+ * Raw date to use during the signing process.
+ */
+ struct aws_date_time date;
+
+ /**
+ * Optional function to control which headers are a part of the canonical request.
+ * Skipping auth-required headers will result in an unusable signature. Headers injected by the signing process
+ * are not skippable.
+ *
+ * This function does not override the internal check function (x-amzn-trace-id, user-agent), but rather
+ * supplements it. In particular, a header will get signed if and only if it returns true to both
+ * the internal check (skips x-amzn-trace-id, user-agent) and this function (if defined).
+ */
+ aws_should_sign_header_fn *should_sign_header;
+ void *should_sign_header_ud;
+
+ /*
+ * Put all flags in here at the end. If this grows, stay aware of bit-space overflow and ABI compatibility.
+ */
+ struct {
+ /**
+ * We assume the uri will be encoded once in preparation for transmission. Certain services
+ * do not decode before checking signature, requiring us to actually double-encode the uri in the canonical
+ * request in order to pass a signature check.
+ */
+ uint32_t use_double_uri_encode : 1;
+
+ /**
+ * Controls whether or not the uri paths should be normalized when building the canonical request
+ */
+ uint32_t should_normalize_uri_path : 1;
+
+ /**
+ * Controls whether "X-Amz-Security-Token" is omitted from the canonical request.
+ * "X-Amz-Security-Token" is added during signing, as a header or
+ * query param, when credentials have a session token.
+ * If false (the default), this parameter is included in the canonical request.
+ * If true, this parameter is still added, but omitted from the canonical request.
+ */
+ uint32_t omit_session_token : 1;
+ } flags;
+
+ /**
+ * Optional string to use as the canonical request's body value.
+ * If string is empty, a value will be calculated from the payload during signing.
+ * Typically, this is the SHA-256 of the (request/chunk/event) payload, written as lowercase hex.
+ * If this has been precalculated, it can be set here. Special values used by certain services can also be set
+ * (e.g. "UNSIGNED-PAYLOAD" "STREAMING-AWS4-HMAC-SHA256-PAYLOAD" "STREAMING-AWS4-HMAC-SHA256-EVENTS").
+ */
+ struct aws_byte_cursor signed_body_value;
+
+ /**
+ * Controls what body "hash" header, if any, should be added to the canonical request and the signed request:
+ * AWS_SBHT_NONE - no header should be added
+ * AWS_SBHT_X_AMZ_CONTENT_SHA256 - the body "hash" should be added in the X-Amz-Content-Sha256 header
+ */
+ enum aws_signed_body_header_type signed_body_header;
+
+ /*
+ * Signing key control:
+ *
+ * If "credentials" is valid:
+ * use it
+ * Else if "credentials_provider" is valid
+ * query credentials from the provider
+ * If sigv4a is being used
+ * use the ecc-based credentials derived from the query result
+ * Else
+ * use the query result
+ * Else
+ * fail
+ *
+ */
+
+ /*
+ * AWS Credentials to sign with. If Sigv4a is the algorithm and the credentials supplied are not ecc-based,
+ * a temporary ecc-based credentials object will be built and used instead.
+ */
+ const struct aws_credentials *credentials;
+
+ /*
+ * AWS credentials provider to fetch credentials from. If the signing algorithm is asymmetric sigv4, then the
+ * ecc-based credentials will be derived from the fetched credentials.
+ */
+ struct aws_credentials_provider *credentials_provider;
+
+ /**
+ * If non-zero and the signing transform is query param, then signing will add X-Amz-Expires to the query
+ * string, equal to the value specified here. If this value is zero or if header signing is being used then
+ * this parameter has no effect.
+ */
+ uint64_t expiration_in_seconds;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Returns a c-string that describes the supplied signing algorithm
+ *
+ * @param algorithm signing algorithm to get a friendly string name for
+ *
+ * @return friendly string name of the supplied algorithm, or "Unknown" if the algorithm is not recognized
+ */
+AWS_AUTH_API
+const char *aws_signing_algorithm_to_string(enum aws_signing_algorithm algorithm);
+
+/**
+ * Checks a signing configuration for invalid settings combinations.
+ *
+ * @param config signing configuration to validate
+ *
+ * @return - AWS_OP_SUCCESS if the configuration is valid, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_validate_aws_signing_config_aws(const struct aws_signing_config_aws *config);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_AUTH_SIGNING_CONFIG_H */
diff --git a/include/aws/auth/signing_result.h b/include/aws/auth/signing_result.h
new file mode 100644
index 0000000000000000000000000000000000000000..309665adc19a3f3881f906e930e0948fd126d549
--- /dev/null
+++ b/include/aws/auth/signing_result.h
@@ -0,0 +1,169 @@
+#ifndef AWS_AUTH_SIGNING_RESULT_H
+#define AWS_AUTH_SIGNING_RESULT_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_array_list;
+struct aws_byte_cursor;
+struct aws_http_message;
+struct aws_string;
+
+struct aws_signing_result_property {
+ struct aws_string *name;
+ struct aws_string *value;
+};
+
+/**
+ * A structure for tracking all the signer-requested changes to a signable. Interpreting
+ * these changes is signing-algorithm specific.
+ *
+ * A signing result consists of
+ *
+ * (1) Properties - A set of key-value pairs
+ * (2) Property Lists - A set of named key-value pair lists
+ *
+ * The hope is that these two generic structures are enough to model the changes required
+ * by any generic message-signing algorithm.
+ *
+ * Note that the key-value pairs of a signing_result are different types (but same intent) as
+ * the key-value pairs in the signable interface. This is because the signing result stands alone
+ * and owns its own copies of all values, whereas a signable can wrap an existing object and thus
+ * use non-owning references (like byte cursors) if appropriate to its implementation.
+ */
+struct aws_signing_result {
+ struct aws_allocator *allocator;
+ struct aws_hash_table properties;
+ struct aws_hash_table property_lists;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initialize a signing result to its starting state
+ *
+ * @param result signing result to initialize
+ * @param allocator allocator to use for all memory allocation
+ *
+ * @return AWS_OP_SUCCESS if initialization was successful, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_signing_result_init(struct aws_signing_result *result, struct aws_allocator *allocator);
+
+/**
+ * Clean up all resources held by the signing result
+ *
+ * @param result signing result to clean up resources for
+ */
+AWS_AUTH_API
+void aws_signing_result_clean_up(struct aws_signing_result *result);
+
+/**
+ * Sets the value of a property on a signing result
+ *
+ * @param result signing result to modify
+ * @param property_name name of the property to set
+ * @param property_value value that the property should assume
+ *
+ * @return AWS_OP_SUCCESS if the set was successful, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_signing_result_set_property(
+ struct aws_signing_result *result,
+ const struct aws_string *property_name,
+ const struct aws_byte_cursor *property_value);
+
+/**
+ * Gets the value of a property on a signing result
+ *
+ * @param result signing result to query from
+ * @param property_name name of the property to query the value of
+ * @param out_property_value output parameter for the property value
+ *
+ * @return AWS_OP_SUCCESS if the get was successful, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_signing_result_get_property(
+ const struct aws_signing_result *result,
+ const struct aws_string *property_name,
+ struct aws_string **out_property_value);
+
+/**
+ * Adds a key-value pair to a named property list. If the named list does not yet exist, it will be created as
+ * an empty list before the pair is added. No uniqueness checks are made against existing pairs.
+ *
+ * @param result signing result to modify
+ * @param list_name name of the list to add the property key-value pair to
+ * @param property_name key value of the key-value pair to append
+ * @param property_value property value of the key-value pair to append
+ *
+ * @return AWS_OP_SUCCESS if the operation was successful, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_signing_result_append_property_list(
+ struct aws_signing_result *result,
+ const struct aws_string *list_name,
+ const struct aws_byte_cursor *property_name,
+ const struct aws_byte_cursor *property_value);
+
+/**
+ * Gets a named property list on the signing result. If the list does not exist, *out_list will be set to null
+ *
+ * @param result signing result to query
+ * @param list_name name of the list of key-value pairs to get
+ * @param out_list output parameter for the list of key-value pairs
+ *
+ */
+AWS_AUTH_API
+void aws_signing_result_get_property_list(
+ const struct aws_signing_result *result,
+ const struct aws_string *list_name,
+ struct aws_array_list **out_list);
+
+/**
+ * Looks for a property within a named property list on the signing result. If the list does not exist, or the property
+ * does not exist within the list, *out_value will be set to NULL.
+ *
+ * @param result signing result to query
+ * @param list_name name of the list of key-value pairs to search through for the property
+ * @param property_name name of the property to search for within the list
+ * @param out_value output parameter for the property value, if found
+ *
+ */
+AWS_AUTH_API
+void aws_signing_result_get_property_value_in_property_list(
+ const struct aws_signing_result *result,
+ const struct aws_string *list_name,
+ const struct aws_string *property_name,
+ struct aws_string **out_value);
+
+/*
+ * Specific implementation that applies a signing result to a mutable http request
+ *
+ * @param request http request to apply the signing result to
+ * @param allocator memory allocator to use for all memory allocation
+ * @param result signing result to apply to the request
+ *
+ * @return AWS_OP_SUCCESS if the application operation was successful, AWS_OP_ERR otherwise
+ */
+AWS_AUTH_API
+int aws_apply_signing_result_to_http_request(
+ struct aws_http_message *request,
+ struct aws_allocator *allocator,
+ const struct aws_signing_result *result);
+
+AWS_AUTH_API extern const struct aws_string *g_aws_signing_authorization_header_name;
+AWS_AUTH_API extern const struct aws_string *g_aws_signing_authorization_query_param_name;
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_AUTH_SIGNING_RESULT_H */
diff --git a/include/aws/cal/cal.h b/include/aws/cal/cal.h
new file mode 100644
index 0000000000000000000000000000000000000000..df2f1a9bdb2ed37238333e474ac7ee33545e0899
--- /dev/null
+++ b/include/aws/cal/cal.h
@@ -0,0 +1,61 @@
+#ifndef AWS_CAL_CAL_H
+#define AWS_CAL_CAL_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_allocator;
+
+#define AWS_C_CAL_PACKAGE_ID 7
+
+enum aws_cal_errors {
+ AWS_ERROR_CAL_SIGNATURE_VALIDATION_FAILED = AWS_ERROR_ENUM_BEGIN_RANGE(AWS_C_CAL_PACKAGE_ID),
+ AWS_ERROR_CAL_MISSING_REQUIRED_KEY_COMPONENT,
+ AWS_ERROR_CAL_INVALID_KEY_LENGTH_FOR_ALGORITHM,
+ AWS_ERROR_CAL_UNKNOWN_OBJECT_IDENTIFIER,
+ AWS_ERROR_CAL_MALFORMED_ASN1_ENCOUNTERED,
+ AWS_ERROR_CAL_MISMATCHED_DER_TYPE,
+ AWS_ERROR_CAL_UNSUPPORTED_ALGORITHM,
+ AWS_ERROR_CAL_BUFFER_TOO_LARGE_FOR_ALGORITHM,
+ AWS_ERROR_CAL_INVALID_CIPHER_MATERIAL_SIZE_FOR_ALGORITHM,
+ AWS_ERROR_CAL_DER_UNSUPPORTED_NEGATIVE_INT,
+ AWS_ERROR_CAL_UNSUPPORTED_KEY_FORMAT,
+ AWS_ERROR_CAL_CRYPTO_OPERATION_FAILED,
+ AWS_ERROR_CAL_END_RANGE = AWS_ERROR_ENUM_END_RANGE(AWS_C_CAL_PACKAGE_ID)
+};
+
+enum aws_cal_log_subject {
+ AWS_LS_CAL_GENERAL = AWS_LOG_SUBJECT_BEGIN_RANGE(AWS_C_CAL_PACKAGE_ID),
+ AWS_LS_CAL_ECC,
+ AWS_LS_CAL_HASH,
+ AWS_LS_CAL_HMAC,
+ AWS_LS_CAL_DER,
+ AWS_LS_CAL_LIBCRYPTO_RESOLVE,
+ AWS_LS_CAL_RSA,
+ AWS_LS_CAL_ED25519,
+
+ AWS_LS_CAL_LAST = AWS_LOG_SUBJECT_END_RANGE(AWS_C_CAL_PACKAGE_ID)
+};
+
+AWS_EXTERN_C_BEGIN
+
+AWS_CAL_API void aws_cal_library_init(struct aws_allocator *allocator);
+AWS_CAL_API void aws_cal_library_clean_up(void);
+
+/*
+ * Every CRT thread that might invoke aws-lc functionality should call this as part of the thread at_exit process
+ */
+AWS_CAL_API void aws_cal_thread_clean_up(void);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_CAL_CAL_H */
diff --git a/include/aws/cal/ecc.h b/include/aws/cal/ecc.h
new file mode 100644
index 0000000000000000000000000000000000000000..4941fa93e92eb4c360efc6ec65e0db5139d997b8
--- /dev/null
+++ b/include/aws/cal/ecc.h
@@ -0,0 +1,185 @@
+#ifndef AWS_CAL_ECC_H
+#define AWS_CAL_ECC_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+
+#include
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+enum aws_ecc_curve_name {
+ AWS_CAL_ECDSA_P256,
+ AWS_CAL_ECDSA_P384,
+};
+
+struct aws_ecc_key_pair;
+
+typedef void aws_ecc_key_pair_destroy_fn(struct aws_ecc_key_pair *key_pair);
+typedef int aws_ecc_key_pair_sign_message_fn(
+ const struct aws_ecc_key_pair *key_pair,
+ const struct aws_byte_cursor *message,
+ struct aws_byte_buf *signature_output);
+typedef int aws_ecc_key_pair_derive_public_key_fn(struct aws_ecc_key_pair *key_pair);
+typedef int aws_ecc_key_pair_verify_signature_fn(
+ const struct aws_ecc_key_pair *signer,
+ const struct aws_byte_cursor *message,
+ const struct aws_byte_cursor *signature);
+typedef size_t aws_ecc_key_pair_signature_length_fn(const struct aws_ecc_key_pair *signer);
+
+struct aws_ecc_key_pair_vtable {
+ aws_ecc_key_pair_destroy_fn *destroy;
+ aws_ecc_key_pair_derive_public_key_fn *derive_pub_key;
+ aws_ecc_key_pair_sign_message_fn *sign_message;
+ aws_ecc_key_pair_verify_signature_fn *verify_signature;
+ aws_ecc_key_pair_signature_length_fn *signature_length;
+};
+
+struct aws_ecc_key_pair {
+ struct aws_allocator *allocator;
+ struct aws_atomic_var ref_count;
+ enum aws_ecc_curve_name curve_name;
+ struct aws_byte_buf key_buf;
+ struct aws_byte_buf pub_x;
+ struct aws_byte_buf pub_y;
+ struct aws_byte_buf priv_d;
+ struct aws_ecc_key_pair_vtable *vtable;
+ void *impl;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Adds one to an ecc key pair's ref count.
+ */
+AWS_CAL_API void aws_ecc_key_pair_acquire(struct aws_ecc_key_pair *key_pair);
+
+/**
+ * Subtracts one from an ecc key pair's ref count. If ref count reaches zero, the key pair is destroyed.
+ */
+AWS_CAL_API void aws_ecc_key_pair_release(struct aws_ecc_key_pair *key_pair);
+
+/**
+ * Creates an Elliptic Curve private key that can be used for signing.
+ * Returns a new instance of aws_ecc_key_pair if the key was successfully built.
+ * Otherwise returns NULL. Note: priv_key::len must match the appropriate length
+ * for the selected curve_name.
+ */
+AWS_CAL_API struct aws_ecc_key_pair *aws_ecc_key_pair_new_from_private_key(
+ struct aws_allocator *allocator,
+ enum aws_ecc_curve_name curve_name,
+ const struct aws_byte_cursor *priv_key);
+
+#if !defined(AWS_OS_IOS)
+/**
+ * Creates an Elliptic Curve public/private key pair that can be used for signing and verifying.
+ * Returns a new instance of aws_ecc_key_pair if the key was successfully built.
+ * Otherwise returns NULL.
+ * Note: On Apple platforms this function is only supported on MacOS. This is
+ * due to usage of SecItemExport, which is only available on MacOS 10.7+
+ * (yes, MacOS only and no other Apple platforms). There are alternatives for
+ * ios and other platforms, but they are ugly to use. Hence for now it only
+ * supports this call on MacOS.
+ */
+AWS_CAL_API struct aws_ecc_key_pair *aws_ecc_key_pair_new_generate_random(
+ struct aws_allocator *allocator,
+ enum aws_ecc_curve_name curve_name);
+#endif /* !AWS_OS_IOS */
+
+/**
+ * Creates an Elliptic Curve public key that can be used for verifying.
+ * Returns a new instance of aws_ecc_key_pair if the key was successfully built.
+ * Otherwise returns NULL. Note: public_key_x::len and public_key_y::len must
+ * match the appropriate length for the selected curve_name.
+ */
+AWS_CAL_API struct aws_ecc_key_pair *aws_ecc_key_pair_new_from_public_key(
+ struct aws_allocator *allocator,
+ enum aws_ecc_curve_name curve_name,
+ const struct aws_byte_cursor *public_key_x,
+ const struct aws_byte_cursor *public_key_y);
+
+/**
+ * Creates an Elliptic Curve public/private key pair from a DER encoded key pair.
+ * Returns a new instance of aws_ecc_key_pair if the key was successfully built.
+ * Otherwise returns NULL. Whether or not signing or verification can be perform depends
+ * on if encoded_keys is a public/private pair or a public key.
+ */
+AWS_CAL_API struct aws_ecc_key_pair *aws_ecc_key_pair_new_from_asn1(
+ struct aws_allocator *allocator,
+ const struct aws_byte_cursor *encoded_keys);
+
+/**
+ * Creates an Elliptic curve public key from x and y coordinates encoded as hex strings
+ * Returns a new instance of aws_ecc_key_pair if the key was successfully built.
+ * Otherwise returns NULL.
+ */
+AWS_CAL_API struct aws_ecc_key_pair *aws_ecc_key_new_from_hex_coordinates(
+ struct aws_allocator *allocator,
+ enum aws_ecc_curve_name curve_name,
+ struct aws_byte_cursor pub_x_hex_cursor,
+ struct aws_byte_cursor pub_y_hex_cursor);
+
+/**
+ * Derives a public key from the private key if supported by this operating system (not supported on OSX).
+ * key_pair::pub_x and key_pair::pub_y will be set with the raw key buffers.
+ */
+AWS_CAL_API int aws_ecc_key_pair_derive_public_key(struct aws_ecc_key_pair *key_pair);
+
+/**
+ * Get the curve name from the oid. OID here is the payload of the DER encoded ASN.1 part (doesn't include
+ * type specifier or length. On success, the value of curve_name will be set.
+ */
+AWS_CAL_API int aws_ecc_curve_name_from_oid(struct aws_byte_cursor *oid, enum aws_ecc_curve_name *curve_name);
+
+/**
+ * Get the DER encoded OID from the curve_name. The OID in this case will not contain the type or the length specifier.
+ */
+AWS_CAL_API int aws_ecc_oid_from_curve_name(enum aws_ecc_curve_name curve_name, struct aws_byte_cursor *oid);
+
+/**
+ * Uses the key_pair's private key to sign message. The output will be in signature. Signature must be large enough
+ * to hold the signature. Check aws_ecc_key_pair_signature_length() for the appropriate size. Signature will be DER
+ * encoded.
+ *
+ * It is the callers job to make sure message is the appropriate cryptographic digest for this operation. It's usually
+ * something like a SHA256.
+ */
+AWS_CAL_API int aws_ecc_key_pair_sign_message(
+ const struct aws_ecc_key_pair *key_pair,
+ const struct aws_byte_cursor *message,
+ struct aws_byte_buf *signature);
+
+/**
+ * Uses the key_pair's public key to verify signature of message. Signature should be DER
+ * encoded.
+ *
+ * It is the callers job to make sure message is the appropriate cryptographic digest for this operation. It's usually
+ * something like a SHA256.
+ *
+ * returns AWS_OP_SUCCESS if the signature is valid.
+ */
+AWS_CAL_API int aws_ecc_key_pair_verify_signature(
+ const struct aws_ecc_key_pair *key_pair,
+ const struct aws_byte_cursor *message,
+ const struct aws_byte_cursor *signature);
+AWS_CAL_API size_t aws_ecc_key_pair_signature_length(const struct aws_ecc_key_pair *key_pair);
+
+AWS_CAL_API void aws_ecc_key_pair_get_public_key(
+ const struct aws_ecc_key_pair *key_pair,
+ struct aws_byte_cursor *pub_x,
+ struct aws_byte_cursor *pub_y);
+
+AWS_CAL_API void aws_ecc_key_pair_get_private_key(
+ const struct aws_ecc_key_pair *key_pair,
+ struct aws_byte_cursor *private_d);
+
+AWS_CAL_API size_t aws_ecc_key_coordinate_byte_size_from_curve_name(enum aws_ecc_curve_name curve_name);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_CAL_ECC_H */
diff --git a/include/aws/cal/ed25519.h b/include/aws/cal/ed25519.h
new file mode 100644
index 0000000000000000000000000000000000000000..4d54848fa4f9fc447d2fe50dacdfc16e60b51f0a
--- /dev/null
+++ b/include/aws/cal/ed25519.h
@@ -0,0 +1,88 @@
+#ifndef AWS_CAL_ED25519_H
+#define AWS_CAL_ED25519_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_ed25519_key_pair;
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Generate new Ed25519 key.
+ * Returns a new instance of aws_ed25519_key_pair if the key was successfully generated.
+ * Otherwise returns NULL.
+ * Note: keygen is not supported on all platforms and will return NULL for the key
+ * and raise AWS_ERROR_CAL_UNSUPPORTED_ALGORITHM.
+ * Examples of unsupported cases:
+ * - openssl pre 1.1.1 (Note: aws-lc and boringssl both expose the needed functions)
+ * - win/mac builds without special flag that forces linking to libcrypto to support this
+ */
+AWS_CAL_API struct aws_ed25519_key_pair *aws_ed25519_key_pair_new_generate(struct aws_allocator *allocator);
+
+/**
+ * Adds one to an Ed25519 key pair's ref count.
+ * Returns key_pair pointer.
+ */
+AWS_CAL_API struct aws_ed25519_key_pair *aws_ed25519_key_pair_acquire(struct aws_ed25519_key_pair *key_pair);
+
+/**
+ * Subtracts one from an Ed25519 key pair's ref count. If ref count reaches zero, the key pair is destroyed.
+ * Always returns NULL.
+ */
+AWS_CAL_API struct aws_ed25519_key_pair *aws_ed25519_key_pair_release(struct aws_ed25519_key_pair *key_pair);
+
+enum aws_ed25519_key_export_format {
+ /* Export the key as raw bytes */
+ AWS_CAL_ED25519_KEY_EXPORT_RAW,
+
+ /**
+ * Export the key to openssh format.
+ * This will only export the key block, framing (i.e. pem) is left as exercise for the caller.
+ * b64 encoding is done as convenience since common framing formats require it.
+ */
+ AWS_CAL_ED25519_KEY_EXPORT_OPENSSH_B64,
+};
+
+/*
+ * Get public key for the key pair.
+ * Key in specified format is appended to the buffer.
+ * The buffer must be initialized before this call, with sufficient capacity to hold the result.
+ * Use aws_ed25519_key_pair_get_public_key_size to figure out how much capacity buffer needs for a given format.
+ */
+AWS_CAL_API int aws_ed25519_key_pair_get_public_key(
+ const struct aws_ed25519_key_pair *key_pair,
+ enum aws_ed25519_key_export_format format,
+ struct aws_byte_buf *out);
+
+/**
+ * Gets the size of the exported public key.
+ */
+AWS_CAL_API size_t aws_ed25519_key_pair_get_public_key_size(enum aws_ed25519_key_export_format format);
+
+/*
+ * Get private key for the key pair.
+ * Key in specified format is appended to the buffer.
+ * The buffer must be initialized before this call, with sufficient capacity to hold the result.
+ * Use aws_ed25519_key_pair_get_private_key_size to figure out how much capacity buffer needs for a given format.
+ */
+AWS_CAL_API int aws_ed25519_key_pair_get_private_key(
+ const struct aws_ed25519_key_pair *key_pair,
+ enum aws_ed25519_key_export_format format,
+ struct aws_byte_buf *out);
+
+/**
+ * Gets the size of the exported private key.
+ */
+AWS_CAL_API size_t aws_ed25519_key_pair_get_private_key_size(enum aws_ed25519_key_export_format format);
+
+AWS_EXTERN_C_END
+
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_CAL_ED25519_H */
diff --git a/include/aws/cal/exports.h b/include/aws/cal/exports.h
new file mode 100644
index 0000000000000000000000000000000000000000..a0074e540c913b8bc3a91d59dea0f6ed3e1e1078
--- /dev/null
+++ b/include/aws/cal/exports.h
@@ -0,0 +1,28 @@
+#ifndef AWS_CAL_EXPORTS_H
+#define AWS_CAL_EXPORTS_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#if defined(AWS_CRT_USE_WINDOWS_DLL_SEMANTICS) || defined(_WIN32)
+# ifdef AWS_CAL_USE_IMPORT_EXPORT
+# ifdef AWS_CAL_EXPORTS
+# define AWS_CAL_API __declspec(dllexport)
+# else
+# define AWS_CAL_API __declspec(dllimport)
+# endif /* AWS_CAL_EXPORTS */
+# else
+# define AWS_CAL_API
+# endif /* AWS_CAL_USE_IMPORT_EXPORT */
+
+#else /* defined (AWS_CRT_USE_WINDOWS_DLL_SEMANTICS) || defined (_WIN32) */
+
+# if defined(AWS_CAL_USE_IMPORT_EXPORT) && defined(AWS_CAL_EXPORTS)
+# define AWS_CAL_API __attribute__((visibility("default")))
+# else
+# define AWS_CAL_API
+# endif
+
+#endif /* defined (AWS_CRT_USE_WINDOWS_DLL_SEMANTICS) || defined (_WIN32) */
+
+#endif /* AWS_CAL_EXPORTS_H */
diff --git a/include/aws/cal/hash.h b/include/aws/cal/hash.h
new file mode 100644
index 0000000000000000000000000000000000000000..97d6e3c3a2cbc82f2c9b85304221dd4163b3e671
--- /dev/null
+++ b/include/aws/cal/hash.h
@@ -0,0 +1,139 @@
+#ifndef AWS_CAL_HASH_H_
+#define AWS_CAL_HASH_H_
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+#define AWS_SHA256_LEN 32
+#define AWS_SHA1_LEN 20
+#define AWS_MD5_LEN 16
+
+struct aws_hash;
+
+struct aws_hash_vtable {
+ const char *alg_name;
+ const char *provider;
+ void (*destroy)(struct aws_hash *hash);
+ int (*update)(struct aws_hash *hash, const struct aws_byte_cursor *buf);
+ int (*finalize)(struct aws_hash *hash, struct aws_byte_buf *out);
+};
+
+struct aws_hash {
+ struct aws_allocator *allocator;
+ struct aws_hash_vtable *vtable;
+ size_t digest_size;
+ bool good;
+ void *impl;
+};
+
+typedef struct aws_hash *(aws_hash_new_fn)(struct aws_allocator *allocator);
+
+AWS_EXTERN_C_BEGIN
+/**
+ * Allocates and initializes a sha256 hash instance.
+ */
+AWS_CAL_API struct aws_hash *aws_sha256_new(struct aws_allocator *allocator);
+/**
+ * Allocates and initializes a sha1 hash instance.
+ */
+AWS_CAL_API struct aws_hash *aws_sha1_new(struct aws_allocator *allocator);
+/**
+ * Allocates and initializes an md5 hash instance.
+ */
+AWS_CAL_API struct aws_hash *aws_md5_new(struct aws_allocator *allocator);
+
+/**
+ * Cleans up and deallocates hash.
+ */
+AWS_CAL_API void aws_hash_destroy(struct aws_hash *hash);
+/**
+ * Updates the running hash with to_hash. this can be called multiple times.
+ */
+AWS_CAL_API int aws_hash_update(struct aws_hash *hash, const struct aws_byte_cursor *to_hash);
+/**
+ * Completes the hash computation and writes the final digest to output.
+ * Allocation of output is the caller's responsibility. If you specify
+ * truncate_to to something other than 0, the output will be truncated to that
+ * number of bytes. For example, if you want a SHA256 digest as the first 16
+ * bytes, set truncate_to to 16. If you want the full digest size, just set this
+ * to 0.
+ */
+AWS_CAL_API int aws_hash_finalize(struct aws_hash *hash, struct aws_byte_buf *output, size_t truncate_to);
+
+/**
+ * Computes the md5 hash over input and writes the digest output to 'output'.
+ * Use this if you don't need to stream the data you're hashing and you can load
+ * the entire input to hash into memory.
+ */
+AWS_CAL_API int aws_md5_compute(
+ struct aws_allocator *allocator,
+ const struct aws_byte_cursor *input,
+ struct aws_byte_buf *output,
+ size_t truncate_to);
+
+/**
+ * Computes the sha256 hash over input and writes the digest output to 'output'.
+ * Use this if you don't need to stream the data you're hashing and you can load
+ * the entire input to hash into memory. If you specify truncate_to to something
+ * other than 0, the output will be truncated to that number of bytes. For
+ * example, if you want a SHA256 digest as the first 16 bytes, set truncate_to
+ * to 16. If you want the full digest size, just set this to 0.
+ */
+AWS_CAL_API int aws_sha256_compute(
+ struct aws_allocator *allocator,
+ const struct aws_byte_cursor *input,
+ struct aws_byte_buf *output,
+ size_t truncate_to);
+
+/**
+ * Computes the sha1 hash over input and writes the digest output to 'output'.
+ * Use this if you don't need to stream the data you're hashing and you can load
+ * the entire input to hash into memory. If you specify truncate_to to something
+ * other than 0, the output will be truncated to that number of bytes. For
+ * example, if you want a SHA1 digest as the first 16 bytes, set truncate_to
+ * to 16. If you want the full digest size, just set this to 0.
+ */
+AWS_CAL_API int aws_sha1_compute(
+ struct aws_allocator *allocator,
+ const struct aws_byte_cursor *input,
+ struct aws_byte_buf *output,
+ size_t truncate_to);
+
+/**
+ * Set the implementation of md5 to use. If you compiled without BYO_CRYPTO,
+ * you do not need to call this. However, if use this, we will honor it,
+ * regardless of compile options. This may be useful for testing purposes. If
+ * you did set BYO_CRYPTO, and you do not call this function you will
+ * segfault.
+ */
+AWS_CAL_API void aws_set_md5_new_fn(aws_hash_new_fn *fn);
+
+/**
+ * Set the implementation of sha256 to use. If you compiled without
+ * BYO_CRYPTO, you do not need to call this. However, if use this, we will
+ * honor it, regardless of compile options. This may be useful for testing
+ * purposes. If you did set BYO_CRYPTO, and you do not call this function
+ * you will segfault.
+ */
+AWS_CAL_API void aws_set_sha256_new_fn(aws_hash_new_fn *fn);
+
+/**
+ * Set the implementation of sha1 to use. If you compiled without
+ * BYO_CRYPTO, you do not need to call this. However, if use this, we will
+ * honor it, regardless of compile options. This may be useful for testing
+ * purposes. If you did set BYO_CRYPTO, and you do not call this function
+ * you will segfault.
+ */
+AWS_CAL_API void aws_set_sha1_new_fn(aws_hash_new_fn *fn);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_CAL_HASH_H_ */
diff --git a/include/aws/cal/hmac.h b/include/aws/cal/hmac.h
new file mode 100644
index 0000000000000000000000000000000000000000..d02d7013978916db9b433e14b06b93fe091e0a66
--- /dev/null
+++ b/include/aws/cal/hmac.h
@@ -0,0 +1,87 @@
+#ifndef AWS_CAL_HMAC_H_
+#define AWS_CAL_HMAC_H_
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+#define AWS_SHA256_HMAC_LEN 32
+
+struct aws_hmac;
+
+struct aws_hmac_vtable {
+ const char *alg_name;
+ const char *provider;
+ void (*destroy)(struct aws_hmac *hmac);
+ int (*update)(struct aws_hmac *hmac, const struct aws_byte_cursor *buf);
+ int (*finalize)(struct aws_hmac *hmac, struct aws_byte_buf *out);
+};
+
+struct aws_hmac {
+ struct aws_allocator *allocator;
+ struct aws_hmac_vtable *vtable;
+ size_t digest_size;
+ bool good;
+ void *impl;
+};
+
+typedef struct aws_hmac *(aws_hmac_new_fn)(struct aws_allocator *allocator, const struct aws_byte_cursor *secret);
+
+AWS_EXTERN_C_BEGIN
+/**
+ * Allocates and initializes a sha256 hmac instance. Secret is the key to be
+ * used for the hmac process.
+ */
+AWS_CAL_API struct aws_hmac *aws_sha256_hmac_new(struct aws_allocator *allocator, const struct aws_byte_cursor *secret);
+
+/**
+ * Cleans up and deallocates hmac.
+ */
+AWS_CAL_API void aws_hmac_destroy(struct aws_hmac *hmac);
+
+/**
+ * Updates the running hmac with to_hash. this can be called multiple times.
+ */
+AWS_CAL_API int aws_hmac_update(struct aws_hmac *hmac, const struct aws_byte_cursor *to_hmac);
+/**
+ * Completes the hmac computation and writes the final digest to output.
+ * Allocation of output is the caller's responsibility. If you specify
+ * truncate_to to something other than 0, the output will be truncated to that
+ * number of bytes. For example if you want a SHA256 digest as the first 16
+ * bytes, set truncate_to to 16. If you want the full digest size, just set this
+ * to 0.
+ */
+AWS_CAL_API int aws_hmac_finalize(struct aws_hmac *hmac, struct aws_byte_buf *output, size_t truncate_to);
+/**
+ * Computes the sha256 hmac over input and writes the digest output to 'output'.
+ * Use this if you don't need to stream the data you're hashing and you can load
+ * the entire input to hash into memory. If you specify truncate_to to something
+ * other than 0, the output will be truncated to that number of bytes. For
+ * example if you want a SHA256 HMAC digest as the first 16 bytes, set
+ * truncate_to to 16. If you want the full digest size, just set this to 0.
+ */
+AWS_CAL_API int aws_sha256_hmac_compute(
+ struct aws_allocator *allocator,
+ const struct aws_byte_cursor *secret,
+ const struct aws_byte_cursor *to_hmac,
+ struct aws_byte_buf *output,
+ size_t truncate_to);
+/**
+ * Set the implementation of sha256 hmac to use. If you compiled without
+ * BYO_CRYPTO, you do not need to call this. However, if use this, we will
+ * honor it, regardless of compile options. This may be useful for testing
+ * purposes. If you did set BYO_CRYPTO, and you do not call this function
+ * you will segfault.
+ */
+AWS_CAL_API void aws_set_sha256_hmac_new_fn(aws_hmac_new_fn *fn);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_CAL_HASH_H_ */
diff --git a/include/aws/cal/rsa.h b/include/aws/cal/rsa.h
new file mode 100644
index 0000000000000000000000000000000000000000..8a640b3fe42cdfb45da727f597284f5d427b2ee2
--- /dev/null
+++ b/include/aws/cal/rsa.h
@@ -0,0 +1,175 @@
+#ifndef AWS_CAL_RSA_H
+#define AWS_CAL_RSA_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_rsa_key_pair;
+
+enum aws_rsa_encryption_algorithm {
+ AWS_CAL_RSA_ENCRYPTION_PKCS1_5,
+ AWS_CAL_RSA_ENCRYPTION_OAEP_SHA256,
+ AWS_CAL_RSA_ENCRYPTION_OAEP_SHA512,
+};
+
+enum aws_rsa_signature_algorithm {
+ AWS_CAL_RSA_SIGNATURE_PKCS1_5_SHA256,
+ AWS_CAL_RSA_SIGNATURE_PKCS1_5_SHA1,
+ AWS_CAL_RSA_SIGNATURE_PSS_SHA256,
+};
+
+/*
+ * Note: prefer using standard key sizes - 1024, 2048, 4096.
+ * Other key sizes will work, but which key sizes are supported may vary by
+ * platform. Typically, multiples of 64 should work on all platforms.
+ */
+enum {
+ AWS_CAL_RSA_MIN_SUPPORTED_KEY_SIZE_IN_BITS = 1024,
+ AWS_CAL_RSA_MAX_SUPPORTED_KEY_SIZE_IN_BITS = 4096,
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Creates an RSA public key from RSAPublicKey as defined in rfc 8017 (aka PKCS1).
+ * Returns a new instance of aws_rsa_key_pair if the key was successfully built.
+ * Otherwise returns NULL.
+ */
+AWS_CAL_API struct aws_rsa_key_pair *aws_rsa_key_pair_new_from_public_key_pkcs1(
+ struct aws_allocator *allocator,
+ struct aws_byte_cursor key);
+
+/**
+ * Creates an RSA private key from RSAPrivateKey as defined in rfc 8017 (aka PKCS1).
+ * Returns a new instance of aws_rsa_key_pair if the key was successfully built.
+ * Otherwise returns NULL.
+ */
+AWS_CAL_API struct aws_rsa_key_pair *aws_rsa_key_pair_new_from_private_key_pkcs1(
+ struct aws_allocator *allocator,
+ struct aws_byte_cursor key);
+
+/**
+ * Creates an RSA private key from PrivateKeyInfo as defined in rfc 5208 (aka PKCS8).
+ * Returns a new instance of aws_rsa_key_pair if the key was successfully built.
+ * Otherwise returns NULL.
+ */
+AWS_CAL_API struct aws_rsa_key_pair *aws_rsa_key_pair_new_from_private_key_pkcs8(
+ struct aws_allocator *allocator,
+ struct aws_byte_cursor key);
+
+/**
+ * Adds one to an RSA key pair's ref count.
+ * Returns key_pair pointer.
+ */
+AWS_CAL_API struct aws_rsa_key_pair *aws_rsa_key_pair_acquire(struct aws_rsa_key_pair *key_pair);
+
+/**
+ * Subtracts one from an RSA key pair's ref count. If ref count reaches zero, the key pair is destroyed.
+ * Always returns NULL.
+ */
+AWS_CAL_API struct aws_rsa_key_pair *aws_rsa_key_pair_release(struct aws_rsa_key_pair *key_pair);
+
+/**
+ * Max plaintext size that can be encrypted by the key (i.e. max data size
+ * supported by the key - bytes needed for padding).
+ */
+AWS_CAL_API size_t aws_rsa_key_pair_max_encrypt_plaintext_size(
+ const struct aws_rsa_key_pair *key_pair,
+ enum aws_rsa_encryption_algorithm algorithm);
+
+/*
+ * Uses the key_pair's private key to encrypt the plaintext. The output will be
+ * in out. out must be large enough to to hold the ciphertext. Check
+ * aws_rsa_key_pair_block_length() for output upper bound.
+ */
+AWS_CAL_API int aws_rsa_key_pair_encrypt(
+ const struct aws_rsa_key_pair *key_pair,
+ enum aws_rsa_encryption_algorithm algorithm,
+ struct aws_byte_cursor plaintext,
+ struct aws_byte_buf *out);
+
+/*
+ * Uses the key_pair's private key to decrypt the ciphertext. The output will be
+ * in out. out must be large enough to to hold the ciphertext. Check
+ * aws_rsa_key_pair_block_length() for output upper bound.
+ */
+AWS_CAL_API int aws_rsa_key_pair_decrypt(
+ const struct aws_rsa_key_pair *key_pair,
+ enum aws_rsa_encryption_algorithm algorithm,
+ struct aws_byte_cursor ciphertext,
+ struct aws_byte_buf *out);
+
+/*
+ * Max size for a block supported by a given key pair.
+ */
+AWS_CAL_API size_t aws_rsa_key_pair_block_length(const struct aws_rsa_key_pair *key_pair);
+
+/**
+ * Uses the key_pair's private key to sign message. The output will be in out. out must be large enough
+ * to hold the signature. Check aws_rsa_key_pair_signature_length() for the appropriate size.
+ *
+ * It is the callers job to make sure message is the appropriate cryptographic digest for this operation. It's usually
+ * something like a SHA256.
+ */
+AWS_CAL_API int aws_rsa_key_pair_sign_message(
+ const struct aws_rsa_key_pair *key_pair,
+ enum aws_rsa_signature_algorithm algorithm,
+ struct aws_byte_cursor digest,
+ struct aws_byte_buf *out);
+
+/**
+ * Uses the key_pair's public key to verify signature of message.
+ *
+ * It is the callers job to make sure message is the appropriate cryptographic digest for this operation. It's usually
+ * something like a SHA256.
+ *
+ * returns AWS_OP_SUCCESS if the signature is valid.
+ * raises AWS_ERROR_CAL_SIGNATURE_VALIDATION_FAILED if signature validation failed
+ */
+AWS_CAL_API int aws_rsa_key_pair_verify_signature(
+ const struct aws_rsa_key_pair *key_pair,
+ enum aws_rsa_signature_algorithm algorithm,
+ struct aws_byte_cursor digest,
+ struct aws_byte_cursor signature);
+
+/*
+ * Max size for a signature supported by a given key pair.
+ */
+AWS_CAL_API size_t aws_rsa_key_pair_signature_length(const struct aws_rsa_key_pair *key_pair);
+
+enum aws_rsa_key_export_format {
+ AWS_CAL_RSA_KEY_EXPORT_PKCS1,
+};
+
+/*
+ * Get public key for the key pair.
+ * Inits out to a copy of key.
+ * Any encoding on top of that (ex. b64) is left up to user.
+ * Note: this function is currently not supported on windows for generated keys.
+ */
+AWS_CAL_API int aws_rsa_key_pair_get_public_key(
+ const struct aws_rsa_key_pair *key_pair,
+ enum aws_rsa_key_export_format format,
+ struct aws_byte_buf *out);
+
+/*
+ * Get private key for the key pair.
+ * Inits out to a copy of key.
+ * Any encoding on top of that (ex. b64) is left up to user.
+ * Note: this function is currently not supported on Windows for generated keys.
+ */
+AWS_CAL_API int aws_rsa_key_pair_get_private_key(
+ const struct aws_rsa_key_pair *key_pair,
+ enum aws_rsa_key_export_format format,
+ struct aws_byte_buf *out);
+
+AWS_EXTERN_C_END
+
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_CAL_RSA_H */
diff --git a/include/aws/cal/symmetric_cipher.h b/include/aws/cal/symmetric_cipher.h
new file mode 100644
index 0000000000000000000000000000000000000000..df2a11da412bccb10f2fd0084ac8afb03ece3fd2
--- /dev/null
+++ b/include/aws/cal/symmetric_cipher.h
@@ -0,0 +1,259 @@
+#ifndef AWS_CAL_SYMMETRIC_CIPHER_H
+#define AWS_CAL_SYMMETRIC_CIPHER_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+#define AWS_AES_256_CIPHER_BLOCK_SIZE 16
+#define AWS_AES_256_KEY_BIT_LEN 256
+#define AWS_AES_256_KEY_BYTE_LEN (AWS_AES_256_KEY_BIT_LEN / 8)
+
+struct aws_symmetric_cipher;
+
+typedef struct aws_symmetric_cipher *(aws_aes_cbc_256_new_fn)(struct aws_allocator *allocator,
+ const struct aws_byte_cursor *key,
+ const struct aws_byte_cursor *iv);
+
+typedef struct aws_symmetric_cipher *(aws_aes_ctr_256_new_fn)(struct aws_allocator *allocator,
+ const struct aws_byte_cursor *key,
+ const struct aws_byte_cursor *iv);
+
+typedef struct aws_symmetric_cipher *(aws_aes_gcm_256_new_fn)(struct aws_allocator *allocator,
+ const struct aws_byte_cursor *key,
+ const struct aws_byte_cursor *iv,
+ const struct aws_byte_cursor *aad);
+
+typedef struct aws_symmetric_cipher *(aws_aes_keywrap_256_new_fn)(struct aws_allocator *allocator,
+ const struct aws_byte_cursor *key);
+
+enum aws_symmetric_cipher_state {
+ AWS_SYMMETRIC_CIPHER_READY,
+ AWS_SYMMETRIC_CIPHER_FINALIZED,
+ AWS_SYMMETRIC_CIPHER_ERROR,
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Creates an instance of AES CBC with 256-bit key.
+ * If key and iv are NULL, they will be generated internally.
+ * You can get the generated key and iv back by calling:
+ *
+ * aws_symmetric_cipher_get_key() and
+ * aws_symmetric_cipher_get_initialization_vector()
+ *
+ * respectively.
+ *
+ * If they are set, that key and iv will be copied internally and used by the cipher.
+ *
+ * Returns NULL on failure. You can check aws_last_error() to get the error code indicating the failure cause.
+ */
+AWS_CAL_API struct aws_symmetric_cipher *aws_aes_cbc_256_new(
+ struct aws_allocator *allocator,
+ const struct aws_byte_cursor *key,
+ const struct aws_byte_cursor *iv);
+
+/**
+ * Creates an instance of AES CTR with 256-bit key.
+ * If key and iv are NULL, they will be generated internally.
+ * You can get the generated key and iv back by calling:
+ *
+ * aws_symmetric_cipher_get_key() and
+ * aws_symmetric_cipher_get_initialization_vector()
+ *
+ * respectively.
+ *
+ * If they are set, that key and iv will be copied internally and used by the cipher.
+ *
+ * Returns NULL on failure. You can check aws_last_error() to get the error code indicating the failure cause.
+ */
+AWS_CAL_API struct aws_symmetric_cipher *aws_aes_ctr_256_new(
+ struct aws_allocator *allocator,
+ const struct aws_byte_cursor *key,
+ const struct aws_byte_cursor *iv);
+
+/**
+ * Creates an instance of AES GCM with 256-bit key.
+ * If key, iv are NULL, they will be generated internally.
+ * You can get the generated key and iv back by calling:
+ *
+ * aws_symmetric_cipher_get_key() and
+ * aws_symmetric_cipher_get_initialization_vector()
+ *
+ * respectively.
+ *
+ * If aad is set it will be copied and applied to the cipher.
+ *
+ * If they are set, that key and iv will be copied internally and used by the cipher.
+ *
+ * For decryption purposes tag can be provided via aws_symmetric_cipher_set_tag method.
+ * Note: for decrypt operations, tag must be provided before first decrypt is called.
+ * (this is a windows bcrypt limitations, but for consistency sake same limitation is extended to other platforms)
+ * Tag generated during encryption can be retrieved using aws_symmetric_cipher_get_tag method
+ * after finalize is called.
+ *
+ * Returns NULL on failure. You can check aws_last_error() to get the error code indicating the failure cause.
+ */
+AWS_CAL_API struct aws_symmetric_cipher *aws_aes_gcm_256_new(
+ struct aws_allocator *allocator,
+ const struct aws_byte_cursor *key,
+ const struct aws_byte_cursor *iv,
+ const struct aws_byte_cursor *aad);
+
+/**
+ * Creates an instance of AES Keywrap with 256-bit key.
+ * If key is NULL, it will be generated internally.
+ * You can get the generated key back by calling:
+ *
+ * aws_symmetric_cipher_get_key()
+ *
+ * If key is set, that key will be copied internally and used by the cipher.
+ *
+ * Returns NULL on failure. You can check aws_last_error() to get the error code indicating the failure cause.
+ */
+AWS_CAL_API struct aws_symmetric_cipher *aws_aes_keywrap_256_new(
+ struct aws_allocator *allocator,
+ const struct aws_byte_cursor *key);
+
+/**
+ * Cleans up internal resources and state for cipher and then deallocates it.
+ */
+AWS_CAL_API void aws_symmetric_cipher_destroy(struct aws_symmetric_cipher *cipher);
+
+/**
+ * Encrypts the value in to_encrypt and writes the encrypted data into out.
+ * If out is dynamic it will be expanded. If it is not, and out is not large enough to handle
+ * the encrypted output, the call will fail. If you're trying to optimize to use a stack based array
+ * or something, make sure it's at least as large as the size of to_encrypt + an extra BLOCK to account for
+ * padding etc...
+ *
+ * returns AWS_OP_SUCCESS on success. Call aws_last_error() to determine the failure cause if it returns
+ * AWS_OP_ERR;
+ */
+AWS_CAL_API int aws_symmetric_cipher_encrypt(
+ struct aws_symmetric_cipher *cipher,
+ struct aws_byte_cursor to_encrypt,
+ struct aws_byte_buf *out);
+
+/**
+ * Decrypts the value in to_decrypt and writes the decrypted data into out.
+ * If out is dynamic it will be expanded. If it is not, and out is not large enough to handle
+ * the decrypted output, the call will fail. If you're trying to optimize to use a stack based array
+ * or something, make sure it's at least as large as the size of to_decrypt + an extra BLOCK to account for
+ * padding etc...
+ *
+ * returns AWS_OP_SUCCESS on success. Call aws_last_error() to determine the failure cause if it returns
+ * AWS_OP_ERR;
+ */
+AWS_CAL_API int aws_symmetric_cipher_decrypt(
+ struct aws_symmetric_cipher *cipher,
+ struct aws_byte_cursor to_decrypt,
+ struct aws_byte_buf *out);
+
+/**
+ * Encrypts any remaining data that was reserved for final padding, loads GMACs etc... and if there is any
+ * writes any remaining encrypted data to out. If out is dynamic it will be expanded. If it is not, and
+ * out is not large enough to handle the decrypted output, the call will fail. If you're trying to optimize
+ * to use a stack based array or something, make sure it's at least as large as the size of 2 BLOCKs to account for
+ * padding etc...
+ *
+ * After invoking this function, you MUST call aws_symmetric_cipher_reset() before invoking any encrypt/decrypt
+ * operations on this cipher again.
+ *
+ * returns AWS_OP_SUCCESS on success. Call aws_last_error() to determine the failure cause if it returns
+ * AWS_OP_ERR;
+ */
+AWS_CAL_API int aws_symmetric_cipher_finalize_encryption(struct aws_symmetric_cipher *cipher, struct aws_byte_buf *out);
+
+/**
+ * Decrypts any remaining data that was reserved for final padding, loads GMACs etc... and if there is any
+ * writes any remaining decrypted data to out. If out is dynamic it will be expanded. If it is not, and
+ * out is not large enough to handle the decrypted output, the call will fail. If you're trying to optimize
+ * to use a stack based array or something, make sure it's at least as large as the size of 2 BLOCKs to account for
+ * padding etc...
+ *
+ * After invoking this function, you MUST call aws_symmetric_cipher_reset() before invoking any encrypt/decrypt
+ * operations on this cipher again.
+ *
+ * returns AWS_OP_SUCCESS on success. Call aws_last_error() to determine the failure cause if it returns
+ * AWS_OP_ERR;
+ */
+AWS_CAL_API int aws_symmetric_cipher_finalize_decryption(struct aws_symmetric_cipher *cipher, struct aws_byte_buf *out);
+
+/**
+ * Resets the cipher state for starting a new encrypt or decrypt operation. Note encrypt/decrypt cannot be mixed on the
+ * same cipher without a call to reset in between them. However, this leaves the key, iv etc... materials setup for
+ * immediate reuse.
+ * Note: GCM tag is not preserved between operations. If you intend to do encrypt followed directly by decrypt, make
+ * sure to make a copy of tag before reseting the cipher and pass that copy for decryption.
+ *
+ * Warning: In most cases it's a really bad idea to reset a cipher and perform another operation using that cipher.
+ * Key and IV should not be reused for different operations. Instead of reseting the cipher, destroy the cipher
+ * and create new one with a new key/iv pair. Use reset at your own risk, and only after careful consideration.
+ *
+ * returns AWS_OP_SUCCESS on success. Call aws_last_error() to determine the failure cause if it returns
+ * AWS_OP_ERR;
+ */
+AWS_CAL_API int aws_symmetric_cipher_reset(struct aws_symmetric_cipher *cipher);
+
+/**
+ * Gets the current GMAC tag. If not AES GCM, this function will just return an empty cursor.
+ * The memory in this cursor is unsafe as it refers to the internal buffer.
+ * This was done because the use case doesn't require fetching these during an
+ * encryption or decryption operation and it dramatically simplifies the API.
+ * Only use this function between other calls to this API as any function call can alter the value of this tag.
+ *
+ * If you need to access it in a different pattern, copy the values to your own buffer first.
+ */
+AWS_CAL_API struct aws_byte_cursor aws_symmetric_cipher_get_tag(const struct aws_symmetric_cipher *cipher);
+
+/**
+ * Sets the GMAC tag on the cipher. Does nothing for ciphers that do not support tag.
+ */
+AWS_CAL_API void aws_symmetric_cipher_set_tag(struct aws_symmetric_cipher *cipher, struct aws_byte_cursor tag);
+
+/**
+ * Gets the original initialization vector as a cursor.
+ * The memory in this cursor is unsafe as it refers to the internal buffer.
+ * This was done because the use case doesn't require fetching these during an
+ * encryption or decryption operation and it dramatically simplifies the API.
+ *
+ * Unlike some other fields, this value does not change after the inital construction of the cipher.
+ *
+ * For some algorithms, such as AES Keywrap, this will return an empty cursor.
+ */
+AWS_CAL_API struct aws_byte_cursor aws_symmetric_cipher_get_initialization_vector(
+ const struct aws_symmetric_cipher *cipher);
+
+/**
+ * Gets the original key.
+ *
+ * The memory in this cursor is unsafe as it refers to the internal buffer.
+ * This was done because the use case doesn't require fetching these during an
+ * encryption or decryption operation and it dramatically simplifies the API.
+ *
+ * Unlike some other fields, this value does not change after the inital construction of the cipher.
+ */
+AWS_CAL_API struct aws_byte_cursor aws_symmetric_cipher_get_key(const struct aws_symmetric_cipher *cipher);
+
+/**
+ * Returns true if the state of the cipher is good, and otherwise returns false.
+ * Most operations, other than aws_symmetric_cipher_reset() will fail if this function is returning false.
+ * aws_symmetric_cipher_reset() will reset the state to a good state if possible.
+ */
+AWS_CAL_API bool aws_symmetric_cipher_is_good(const struct aws_symmetric_cipher *cipher);
+
+/**
+ * Retuns the current state of the cipher. Ther state of the cipher can be ready for use, finalized, or has encountered
+ * an error. if the cipher is in a finished or error state, it must be reset before further use.
+ */
+AWS_CAL_API enum aws_symmetric_cipher_state aws_symmetric_cipher_get_state(const struct aws_symmetric_cipher *cipher);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+#endif /* AWS_CAL_SYMMETRIC_CIPHER_H */
diff --git a/include/aws/common/allocator.h b/include/aws/common/allocator.h
new file mode 100644
index 0000000000000000000000000000000000000000..8d092055faa03422e3b6895f54f4eff05fbc303a
--- /dev/null
+++ b/include/aws/common/allocator.h
@@ -0,0 +1,234 @@
+#ifndef AWS_COMMON_ALLOCATOR_H
+#define AWS_COMMON_ALLOCATOR_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+AWS_EXTERN_C_BEGIN
+
+/*
+ * Quick guide to allocators:
+ * CRT offers several flavours of allocators:
+ * - default: basic allocator that invokes system one directly.
+ * - aligned: basic allocator that aligns small allocations on 8 byte
+ * boundary and big buffers on 32/64 byte (system dependent) boundary.
+ * Aligned mem can improve perf on some operations, like memcpy or hashes.
+ * Depending on a system, can result in higher peak memory count in heavy
+ * acquire/free scenarios (ex. s3), due to memory fragmentation related to how
+ * aligned allocators work (over allocate, find aligned offset, release extra memory)
+ * - wrapped_cf: wraps MacOS's Security Framework allocator.
+ * - mem_tracer: wraps any allocator and provides tracing functionality to allocations
+ * - small_block_allocator: pools smaller allocations into preallocated buckets.
+ * Not actively maintained. Avoid if possible.
+ */
+
+/* Allocator structure. An instance of this will be passed around for anything needing memory allocation */
+struct aws_allocator {
+ void *(*mem_acquire)(struct aws_allocator *allocator, size_t size);
+ void (*mem_release)(struct aws_allocator *allocator, void *ptr);
+ /* Optional method; if not supported, this pointer must be NULL */
+ void *(*mem_realloc)(struct aws_allocator *allocator, void *oldptr, size_t oldsize, size_t newsize);
+ /* Optional method; if not supported, this pointer must be NULL */
+ void *(*mem_calloc)(struct aws_allocator *allocator, size_t num, size_t size);
+ void *impl;
+};
+
+/**
+ * Inexpensive (constant time) check of data-structure invariants.
+ */
+AWS_COMMON_API
+bool aws_allocator_is_valid(const struct aws_allocator *alloc);
+
+AWS_COMMON_API
+struct aws_allocator *aws_default_allocator(void);
+
+/*
+ * Allocator that align small allocations on 8 byte boundary and big allocations
+ * on 32/64 byte boundary.
+ */
+AWS_COMMON_API
+struct aws_allocator *aws_aligned_allocator(void);
+
+#ifdef __MACH__
+/* Avoid pulling in CoreFoundation headers in a header file. */
+struct __CFAllocator; /* NOLINT(bugprone-reserved-identifier) */
+typedef const struct __CFAllocator *CFAllocatorRef;
+
+/**
+ * Wraps a CFAllocator around aws_allocator. For Mac only. Use this anytime you need a CFAllocatorRef for interacting
+ * with Apple Frameworks. Unfortunately, it allocates memory so we can't make it static file scope, be sure to call
+ * aws_wrapped_cf_allocator_destroy when finished.
+ */
+AWS_COMMON_API
+CFAllocatorRef aws_wrapped_cf_allocator_new(struct aws_allocator *allocator);
+
+/**
+ * Cleans up any resources alloced in aws_wrapped_cf_allocator_new.
+ */
+AWS_COMMON_API
+void aws_wrapped_cf_allocator_destroy(CFAllocatorRef allocator);
+#endif
+
+/**
+ * Returns at least `size` of memory ready for usage. In versions v0.6.8 and prior, this function was allowed to return
+ * NULL. In later versions, if allocator->mem_acquire() returns NULL, this function will assert and exit. To handle
+ * conditions where OOM is not a fatal error, allocator->mem_acquire() is responsible for finding/reclaiming/running a
+ * GC etc...before returning.
+ */
+AWS_COMMON_API
+void *aws_mem_acquire(struct aws_allocator *allocator, size_t size);
+
+/**
+ * Allocates a block of memory for an array of num elements, each of them size bytes long, and initializes all its bits
+ * to zero. In versions v0.6.8 and prior, this function was allowed to return NULL.
+ * In later versions, if allocator->mem_calloc() returns NULL, this function will assert and exit. To handle
+ * conditions where OOM is not a fatal error, allocator->mem_calloc() is responsible for finding/reclaiming/running a
+ * GC etc...before returning.
+ */
+AWS_COMMON_API
+void *aws_mem_calloc(struct aws_allocator *allocator, size_t num, size_t size);
+
+/**
+ * Allocates many chunks of bytes into a single block. Expects to be called with alternating void ** (dest), size_t
+ * (size). The first void ** will be set to the root of the allocation. Alignment is assumed to be sizeof(intmax_t).
+ *
+ * This is useful for allocating structs using the pimpl pattern, as you may allocate the public object and impl object
+ * in the same contiguous block of memory.
+ *
+ * Returns a pointer to the allocation.
+ *
+ * In versions v0.6.8 and prior, this function was allowed to return
+ * NULL. In later versions, if allocator->mem_acquire() returns NULL, this function will assert and exit. To handle
+ * conditions where OOM is not a fatal error, allocator->mem_acquire() is responsible for finding/reclaiming/running a
+ * GC etc...before returning.
+ */
+AWS_COMMON_API
+void *aws_mem_acquire_many(struct aws_allocator *allocator, size_t count, ...);
+
+/**
+ * Releases ptr back to whatever allocated it.
+ * Nothing happens if ptr is NULL.
+ */
+AWS_COMMON_API
+void aws_mem_release(struct aws_allocator *allocator, void *ptr);
+
+/**
+ * Attempts to adjust the size of the pointed-to memory buffer from oldsize to
+ * newsize. The pointer (*ptr) may be changed if the memory needs to be
+ * reallocated.
+ *
+ * In versions v0.6.8 and prior, this function was allowed to return
+ * NULL. In later versions, if allocator->mem_realloc() returns NULL, this function will assert and exit. To handle
+ * conditions where OOM is not a fatal error, allocator->mem_realloc() is responsible for finding/reclaiming/running a
+ * GC etc...before returning.
+ */
+AWS_COMMON_API
+int aws_mem_realloc(struct aws_allocator *allocator, void **ptr, size_t oldsize, size_t newsize);
+/*
+ * Maintainer note: The above function doesn't return the pointer (as with
+ * standard C realloc) as this pattern becomes error-prone when OOMs occur.
+ * In particular, we want to avoid losing the old pointer when an OOM condition
+ * occurs, so we prefer to take the old pointer as an in/out reference argument
+ * that we can leave unchanged on failure.
+ */
+
+enum aws_mem_trace_level {
+ AWS_MEMTRACE_NONE = 0, /* no tracing */
+ AWS_MEMTRACE_BYTES = 1, /* just track allocation sizes and total allocated */
+ AWS_MEMTRACE_STACKS = 2, /* capture callstacks for each allocation */
+};
+
+/*
+ * Wraps an allocator and tracks all external allocations. If aws_mem_trace_dump() is called
+ * and there are still allocations active, they will be reported to the aws_logger at TRACE level.
+ * allocator - The allocator to wrap
+ * deprecated - Deprecated arg, ignored.
+ * level - The level to track allocations at
+ * frames_per_stack is how many frames to store per callstack if AWS_MEMTRACE_STACKS is in use,
+ * otherwise it is ignored. 8 tends to be a pretty good number balancing storage space vs useful stacks.
+ * Returns the tracer allocator, which should be used for all allocations that should be tracked.
+ */
+AWS_COMMON_API
+struct aws_allocator *aws_mem_tracer_new(
+ struct aws_allocator *allocator,
+ struct aws_allocator *deprecated,
+ enum aws_mem_trace_level level,
+ size_t frames_per_stack);
+
+/*
+ * Unwraps the traced allocator and cleans up the tracer.
+ * Returns the original allocator
+ */
+AWS_COMMON_API
+struct aws_allocator *aws_mem_tracer_destroy(struct aws_allocator *trace_allocator);
+
+/*
+ * If there are outstanding allocations, dumps them to log, along with any information gathered
+ * based on the trace level set when aws_mem_trace() was called.
+ * Should be passed the tracer allocator returned from aws_mem_trace().
+ */
+AWS_COMMON_API
+void aws_mem_tracer_dump(struct aws_allocator *trace_allocator);
+
+/*
+ * Returns the current number of bytes in outstanding allocations
+ */
+AWS_COMMON_API
+size_t aws_mem_tracer_bytes(struct aws_allocator *trace_allocator);
+
+/*
+ * Returns the current number of outstanding allocations
+ */
+AWS_COMMON_API
+size_t aws_mem_tracer_count(struct aws_allocator *trace_allocator);
+
+/*
+ * Creates a new Small Block Allocator which fronts the supplied parent allocator. The SBA will intercept
+ * and handle small allocs, and will forward anything larger to the parent allocator.
+ * If multi_threaded is true, the internal allocator will protect its internal data structures with a mutex
+ */
+AWS_COMMON_API
+struct aws_allocator *aws_small_block_allocator_new(struct aws_allocator *allocator, bool multi_threaded);
+
+/*
+ * Destroys a Small Block Allocator instance and frees its memory to the parent allocator. The parent
+ * allocator will otherwise be unaffected.
+ */
+AWS_COMMON_API
+void aws_small_block_allocator_destroy(struct aws_allocator *sba_allocator);
+
+/*
+ * Returns the number of bytes currently active in the SBA
+ */
+AWS_COMMON_API
+size_t aws_small_block_allocator_bytes_active(struct aws_allocator *sba_allocator);
+
+/*
+ * Returns the number of bytes reserved in pages/bins inside the SBA, e.g. the
+ * current system memory used by the SBA
+ */
+AWS_COMMON_API
+size_t aws_small_block_allocator_bytes_reserved(struct aws_allocator *sba_allocator);
+
+/*
+ * Returns the page size that the SBA is using
+ */
+AWS_COMMON_API
+size_t aws_small_block_allocator_page_size(struct aws_allocator *sba_allocator);
+
+/*
+ * Returns the amount of memory in each page available to user allocations
+ */
+AWS_COMMON_API
+size_t aws_small_block_allocator_page_size_available(struct aws_allocator *sba_allocator);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_ALLOCATOR_H */
diff --git a/include/aws/common/array_list.h b/include/aws/common/array_list.h
new file mode 100644
index 0000000000000000000000000000000000000000..4cd05bb7d1178b48c97d782d3449e8a666f79eeb
--- /dev/null
+++ b/include/aws/common/array_list.h
@@ -0,0 +1,241 @@
+#ifndef AWS_COMMON_ARRAY_LIST_H
+#define AWS_COMMON_ARRAY_LIST_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+#include
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+enum { AWS_ARRAY_LIST_DEBUG_FILL = 0xDD };
+
+struct aws_array_list {
+ struct aws_allocator *alloc;
+ size_t current_size;
+ size_t length;
+ size_t item_size;
+ void *data;
+};
+
+/**
+ * Prototype for a comparator function for sorting elements.
+ *
+ * a and b should be cast to pointers to the element type held in the list
+ * before being dereferenced. The function should compare the elements and
+ * return a positive number if a > b, zero if a = b, and a negative number
+ * if a < b.
+ */
+typedef int(aws_array_list_comparator_fn)(const void *a, const void *b);
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes an array list with an array of size initial_item_allocation * item_size. In this mode, the array size
+ * will grow by a factor of 2 upon insertion if space is not available. initial_item_allocation is the number of
+ * elements you want space allocated for. item_size is the size of each element in bytes. Mixing items types is not
+ * supported by this API.
+ */
+AWS_STATIC_IMPL
+int aws_array_list_init_dynamic(
+ struct aws_array_list *AWS_RESTRICT list,
+ struct aws_allocator *alloc,
+ size_t initial_item_allocation,
+ size_t item_size);
+
+/**
+ * Initializes an array list with a preallocated array of void *. item_count is the number of elements in the array,
+ * and item_size is the size in bytes of each element. Mixing items types is not supported
+ * by this API. Once this list is full, new items will be rejected.
+ */
+AWS_STATIC_IMPL
+void aws_array_list_init_static(
+ struct aws_array_list *AWS_RESTRICT list,
+ void *raw_array,
+ size_t item_count,
+ size_t item_size);
+
+/**
+ * Initializes an array list with a preallocated array of *already-initialized* elements. item_count is the number of
+ * elements in the array, and item_size is the size in bytes of each element.
+ *
+ * Once initialized, nothing further can be added to the list, since it will be full and cannot resize.
+ *
+ * Primary use case is to treat an already-initialized C array as an array list.
+ */
+AWS_STATIC_IMPL
+void aws_array_list_init_static_from_initialized(
+ struct aws_array_list *AWS_RESTRICT list,
+ void *raw_array,
+ size_t item_count,
+ size_t item_size);
+
+/**
+ * Set of properties of a valid aws_array_list.
+ */
+AWS_STATIC_IMPL
+bool aws_array_list_is_valid(const struct aws_array_list *AWS_RESTRICT list);
+
+/**
+ * Deallocates any memory that was allocated for this list, and resets list for reuse or deletion.
+ */
+AWS_STATIC_IMPL
+void aws_array_list_clean_up(struct aws_array_list *AWS_RESTRICT list);
+
+/**
+ * Erases and then deallocates any memory that was allocated for this list, and resets list for reuse or deletion.
+ */
+AWS_STATIC_IMPL
+void aws_array_list_clean_up_secure(struct aws_array_list *AWS_RESTRICT list);
+
+/**
+ * Pushes the memory pointed to by val onto the end of internal list
+ */
+AWS_STATIC_IMPL
+int aws_array_list_push_back(struct aws_array_list *AWS_RESTRICT list, const void *val);
+
+/**
+ * Copies the element at the front of the list if it exists. If list is empty, AWS_ERROR_LIST_EMPTY will be raised
+ */
+AWS_STATIC_IMPL
+int aws_array_list_front(const struct aws_array_list *AWS_RESTRICT list, void *val);
+
+/**
+ * Pushes the memory pointed to by val onto the front of internal list.
+ * This call results in shifting all of the elements in the list. Avoid this call unless that
+ * is intended behavior.
+ */
+AWS_STATIC_IMPL
+int aws_array_list_push_front(struct aws_array_list *AWS_RESTRICT list, const void *val);
+
+/**
+ * Deletes the element at the front of the list if it exists. If list is empty, AWS_ERROR_LIST_EMPTY will be raised.
+ * This call results in shifting all of the elements at the end of the array to the front. Avoid this call unless that
+ * is intended behavior.
+ */
+AWS_STATIC_IMPL
+int aws_array_list_pop_front(struct aws_array_list *AWS_RESTRICT list);
+
+/**
+ * Delete N elements from the front of the list.
+ * Remaining elements are shifted to the front of the list.
+ * If the list has less than N elements, the list is cleared.
+ * This call is more efficient than calling aws_array_list_pop_front() N times.
+ */
+AWS_STATIC_IMPL
+void aws_array_list_pop_front_n(struct aws_array_list *AWS_RESTRICT list, size_t n);
+
+/**
+ * Deletes the element this index in the list if it exists.
+ * If element does not exist, AWS_ERROR_INVALID_INDEX will be raised.
+ * This call results in shifting all remaining elements towards the front.
+ * Avoid this call unless that is intended behavior.
+ */
+AWS_STATIC_IMPL
+int aws_array_list_erase(struct aws_array_list *AWS_RESTRICT list, size_t index);
+
+/**
+ * Copies the element at the end of the list if it exists. If list is empty, AWS_ERROR_LIST_EMPTY will be raised.
+ */
+AWS_STATIC_IMPL
+int aws_array_list_back(const struct aws_array_list *AWS_RESTRICT list, void *val);
+
+/**
+ * Deletes the element at the end of the list if it exists. If list is empty, AWS_ERROR_LIST_EMPTY will be raised.
+ */
+AWS_STATIC_IMPL
+int aws_array_list_pop_back(struct aws_array_list *AWS_RESTRICT list);
+
+/**
+ * Clears all elements in the array and resets length to zero. Size does not change in this operation.
+ */
+AWS_STATIC_IMPL
+void aws_array_list_clear(struct aws_array_list *AWS_RESTRICT list);
+
+/**
+ * If in dynamic mode, shrinks the allocated array size to the minimum amount necessary to store its elements.
+ */
+AWS_COMMON_API
+int aws_array_list_shrink_to_fit(struct aws_array_list *AWS_RESTRICT list);
+
+/**
+ * Copies the elements from from to to. If to is in static mode, it must at least be the same length as from. Any data
+ * in to will be overwritten in this copy.
+ */
+AWS_COMMON_API
+int aws_array_list_copy(const struct aws_array_list *AWS_RESTRICT from, struct aws_array_list *AWS_RESTRICT to);
+
+/**
+ * Swap contents between two dynamic lists. Both lists must use the same allocator.
+ */
+AWS_STATIC_IMPL
+void aws_array_list_swap_contents(
+ struct aws_array_list *AWS_RESTRICT list_a,
+ struct aws_array_list *AWS_RESTRICT list_b);
+
+/**
+ * Returns the number of elements that can fit in the internal array. If list is initialized in dynamic mode,
+ * the capacity changes over time.
+ */
+AWS_STATIC_IMPL
+size_t aws_array_list_capacity(const struct aws_array_list *AWS_RESTRICT list);
+
+/**
+ * Returns the number of elements in the internal array.
+ */
+AWS_STATIC_IMPL
+size_t aws_array_list_length(const struct aws_array_list *AWS_RESTRICT list);
+
+/**
+ * Copies the memory at index to val. If element does not exist, AWS_ERROR_INVALID_INDEX will be raised.
+ */
+AWS_STATIC_IMPL
+int aws_array_list_get_at(const struct aws_array_list *AWS_RESTRICT list, void *val, size_t index);
+
+/**
+ * Copies the memory address of the element at index to *val. If element does not exist, AWS_ERROR_INVALID_INDEX will be
+ * raised.
+ */
+AWS_STATIC_IMPL
+int aws_array_list_get_at_ptr(const struct aws_array_list *AWS_RESTRICT list, void **val, size_t index);
+
+/**
+ * Ensures that the array list has enough capacity to store a value at the specified index. If there is not already
+ * enough capacity, and the list is in dynamic mode, this function will attempt to allocate more memory, expanding the
+ * list. In static mode, if 'index' is beyond the maximum index, AWS_ERROR_INVALID_INDEX will be raised.
+ */
+AWS_COMMON_API
+int aws_array_list_ensure_capacity(struct aws_array_list *AWS_RESTRICT list, size_t index);
+
+/**
+ * Copies the the memory pointed to by val into the array at index. If in dynamic mode, the size will grow by a factor
+ * of two when the array is full. In static mode, AWS_ERROR_INVALID_INDEX will be raised if the index is past the bounds
+ * of the array.
+ */
+AWS_STATIC_IMPL
+int aws_array_list_set_at(struct aws_array_list *AWS_RESTRICT list, const void *val, size_t index);
+
+/**
+ * Swap elements at the specified indices, which must be within the bounds of the array.
+ */
+AWS_COMMON_API
+void aws_array_list_swap(struct aws_array_list *AWS_RESTRICT list, size_t a, size_t b);
+
+/**
+ * Sort elements in the list in-place according to the comparator function.
+ */
+AWS_COMMON_API
+void aws_array_list_sort(struct aws_array_list *AWS_RESTRICT list, aws_array_list_comparator_fn *compare_fn);
+
+AWS_EXTERN_C_END
+#ifndef AWS_NO_STATIC_IMPL
+# include
+#endif /* AWS_NO_STATIC_IMPL */
+
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_ARRAY_LIST_H */
diff --git a/include/aws/common/array_list.inl b/include/aws/common/array_list.inl
new file mode 100644
index 0000000000000000000000000000000000000000..5472104c67636d1baf758cae508df656c0da8609
--- /dev/null
+++ b/include/aws/common/array_list.inl
@@ -0,0 +1,410 @@
+#ifndef AWS_COMMON_ARRAY_LIST_INL
+#define AWS_COMMON_ARRAY_LIST_INL
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+/* This is implicitly included, but helps with editor highlighting */
+#include
+/*
+ * Do not add system headers here; add them to array_list.h. This file is included under extern "C" guards,
+ * which might break system headers.
+ */
+AWS_EXTERN_C_BEGIN
+
+AWS_STATIC_IMPL
+int aws_array_list_init_dynamic(
+ struct aws_array_list *AWS_RESTRICT list,
+ struct aws_allocator *alloc,
+ size_t initial_item_allocation,
+ size_t item_size) {
+
+ AWS_FATAL_PRECONDITION(list != NULL);
+ AWS_FATAL_PRECONDITION(alloc != NULL);
+ AWS_FATAL_PRECONDITION(item_size > 0);
+
+ AWS_ZERO_STRUCT(*list);
+
+ size_t allocation_size = 0;
+ if (aws_mul_size_checked(initial_item_allocation, item_size, &allocation_size)) {
+ goto error;
+ }
+
+ if (allocation_size > 0) {
+ list->data = aws_mem_acquire(alloc, allocation_size);
+ if (!list->data) {
+ goto error;
+ }
+#ifdef DEBUG_BUILD
+ memset(list->data, AWS_ARRAY_LIST_DEBUG_FILL, allocation_size);
+
+#endif
+ list->current_size = allocation_size;
+ }
+ list->item_size = item_size;
+ list->alloc = alloc;
+
+ AWS_FATAL_POSTCONDITION(list->current_size == 0 || list->data);
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return AWS_OP_SUCCESS;
+
+error:
+ AWS_POSTCONDITION(AWS_IS_ZEROED(*list));
+ return AWS_OP_ERR;
+}
+
+AWS_STATIC_IMPL
+void aws_array_list_init_static(
+ struct aws_array_list *AWS_RESTRICT list,
+ void *raw_array,
+ size_t item_count,
+ size_t item_size) {
+
+ AWS_FATAL_PRECONDITION(list != NULL);
+ AWS_FATAL_PRECONDITION(raw_array != NULL);
+ AWS_FATAL_PRECONDITION(item_count > 0);
+ AWS_FATAL_PRECONDITION(item_size > 0);
+
+ AWS_ZERO_STRUCT(*list);
+ list->alloc = NULL;
+
+ size_t current_size = 0;
+ int no_overflow = !aws_mul_size_checked(item_count, item_size, ¤t_size);
+ AWS_FATAL_PRECONDITION(no_overflow);
+ list->current_size = current_size;
+
+ list->item_size = item_size;
+ list->length = 0;
+ list->data = raw_array;
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+}
+
+AWS_STATIC_IMPL
+void aws_array_list_init_static_from_initialized(
+ struct aws_array_list *AWS_RESTRICT list,
+ void *raw_array,
+ size_t item_count,
+ size_t item_size) {
+
+ aws_array_list_init_static(list, raw_array, item_count, item_size);
+ list->length = item_count;
+
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+}
+
+AWS_STATIC_IMPL
+bool aws_array_list_is_valid(const struct aws_array_list *AWS_RESTRICT list) {
+ if (!list) {
+ return false;
+ }
+ size_t required_size = 0;
+ bool required_size_is_valid =
+ (aws_mul_size_checked(list->length, list->item_size, &required_size) == AWS_OP_SUCCESS);
+ bool current_size_is_valid = (list->current_size >= required_size);
+ bool data_is_valid = AWS_IMPLIES(list->current_size == 0, list->data == NULL) &&
+ AWS_IMPLIES(list->current_size != 0, AWS_MEM_IS_WRITABLE(list->data, list->current_size));
+ bool item_size_is_valid = (list->item_size != 0);
+ return required_size_is_valid && current_size_is_valid && data_is_valid && item_size_is_valid;
+}
+
+AWS_STATIC_IMPL
+void aws_array_list_clean_up(struct aws_array_list *AWS_RESTRICT list) {
+ AWS_PRECONDITION(AWS_IS_ZEROED(*list) || aws_array_list_is_valid(list));
+ if (list->alloc && list->data) {
+ aws_mem_release(list->alloc, list->data);
+ }
+
+ AWS_ZERO_STRUCT(*list);
+}
+
+AWS_STATIC_IMPL
+void aws_array_list_clean_up_secure(struct aws_array_list *AWS_RESTRICT list) {
+ AWS_PRECONDITION(AWS_IS_ZEROED(*list) || aws_array_list_is_valid(list));
+ if (list->alloc && list->data) {
+ aws_secure_zero(list->data, list->current_size);
+ aws_mem_release(list->alloc, list->data);
+ }
+
+ AWS_ZERO_STRUCT(*list);
+}
+
+AWS_STATIC_IMPL
+int aws_array_list_push_back(struct aws_array_list *AWS_RESTRICT list, const void *val) {
+ AWS_PRECONDITION(aws_array_list_is_valid(list));
+ AWS_PRECONDITION(
+ val && AWS_MEM_IS_READABLE(val, list->item_size),
+ "Input pointer [val] must point writable memory of [list->item_size] bytes.");
+
+ int err_code = aws_array_list_set_at(list, val, aws_array_list_length(list));
+
+ if (err_code && aws_last_error() == AWS_ERROR_INVALID_INDEX && !list->alloc) {
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return aws_raise_error(AWS_ERROR_LIST_EXCEEDS_MAX_SIZE);
+ }
+
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return err_code;
+}
+
+AWS_STATIC_IMPL
+int aws_array_list_front(const struct aws_array_list *AWS_RESTRICT list, void *val) {
+ AWS_PRECONDITION(aws_array_list_is_valid(list));
+ AWS_PRECONDITION(
+ val && AWS_MEM_IS_WRITABLE(val, list->item_size),
+ "Input pointer [val] must point writable memory of [list->item_size] bytes.");
+ if (aws_array_list_length(list) > 0) {
+ memcpy(val, list->data, list->item_size);
+ AWS_POSTCONDITION(AWS_BYTES_EQ(val, list->data, list->item_size));
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return AWS_OP_SUCCESS;
+ }
+
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return aws_raise_error(AWS_ERROR_LIST_EMPTY);
+}
+
+AWS_STATIC_IMPL
+int aws_array_list_push_front(struct aws_array_list *AWS_RESTRICT list, const void *val) {
+ AWS_PRECONDITION(aws_array_list_is_valid(list));
+ AWS_PRECONDITION(
+ val && AWS_MEM_IS_READABLE(val, list->item_size),
+ "Input pointer [val] must point writable memory of [list->item_size] bytes.");
+ size_t orig_len = aws_array_list_length(list);
+ int err_code = aws_array_list_ensure_capacity(list, orig_len);
+
+ if (err_code && aws_last_error() == AWS_ERROR_INVALID_INDEX && !list->alloc) {
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return aws_raise_error(AWS_ERROR_LIST_EXCEEDS_MAX_SIZE);
+ } else if (err_code) {
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return err_code;
+ }
+ if (orig_len) {
+ memmove((uint8_t *)list->data + list->item_size, list->data, orig_len * list->item_size);
+ }
+ ++list->length;
+ memcpy(list->data, val, list->item_size);
+
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return err_code;
+}
+
+AWS_STATIC_IMPL
+int aws_array_list_pop_front(struct aws_array_list *AWS_RESTRICT list) {
+ AWS_PRECONDITION(aws_array_list_is_valid(list));
+ if (aws_array_list_length(list) > 0) {
+ aws_array_list_pop_front_n(list, 1);
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return AWS_OP_SUCCESS;
+ }
+
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return aws_raise_error(AWS_ERROR_LIST_EMPTY);
+}
+
+AWS_STATIC_IMPL
+void aws_array_list_pop_front_n(struct aws_array_list *AWS_RESTRICT list, size_t n) {
+ AWS_PRECONDITION(aws_array_list_is_valid(list));
+ if (n >= aws_array_list_length(list)) {
+ aws_array_list_clear(list);
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return;
+ }
+
+ if (n > 0) {
+ size_t popping_bytes = list->item_size * n;
+ size_t remaining_items = aws_array_list_length(list) - n;
+ size_t remaining_bytes = remaining_items * list->item_size;
+ memmove(list->data, (uint8_t *)list->data + popping_bytes, remaining_bytes);
+ list->length = remaining_items;
+#ifdef DEBUG_BUILD
+ memset((uint8_t *)list->data + remaining_bytes, AWS_ARRAY_LIST_DEBUG_FILL, popping_bytes);
+#endif
+ }
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+}
+
+int aws_array_list_erase(struct aws_array_list *AWS_RESTRICT list, size_t index) {
+ AWS_PRECONDITION(aws_array_list_is_valid(list));
+
+ const size_t length = aws_array_list_length(list);
+
+ if (index >= length) {
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return aws_raise_error(AWS_ERROR_INVALID_INDEX);
+ }
+
+ if (index == 0) {
+ /* Removing front element */
+ aws_array_list_pop_front(list);
+ } else if (index == (length - 1)) {
+ /* Removing back element */
+ aws_array_list_pop_back(list);
+ } else {
+ /* Removing middle element */
+ uint8_t *item_ptr = (uint8_t *)list->data + (index * list->item_size);
+ uint8_t *next_item_ptr = item_ptr + list->item_size;
+ size_t trailing_items = (length - index) - 1;
+ size_t trailing_bytes = trailing_items * list->item_size;
+ memmove(item_ptr, next_item_ptr, trailing_bytes);
+
+ aws_array_list_pop_back(list);
+ }
+
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return AWS_OP_SUCCESS;
+}
+
+AWS_STATIC_IMPL
+int aws_array_list_back(const struct aws_array_list *AWS_RESTRICT list, void *val) {
+ AWS_PRECONDITION(aws_array_list_is_valid(list));
+ AWS_PRECONDITION(
+ val && AWS_MEM_IS_WRITABLE(val, list->item_size),
+ "Input pointer [val] must point writable memory of [list->item_size] bytes.");
+ if (aws_array_list_length(list) > 0) {
+ size_t last_item_offset = list->item_size * (aws_array_list_length(list) - 1);
+
+ memcpy(val, (void *)((uint8_t *)list->data + last_item_offset), list->item_size);
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return AWS_OP_SUCCESS;
+ }
+
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return aws_raise_error(AWS_ERROR_LIST_EMPTY);
+}
+
+AWS_STATIC_IMPL
+int aws_array_list_pop_back(struct aws_array_list *AWS_RESTRICT list) {
+ AWS_PRECONDITION(aws_array_list_is_valid(list));
+ if (aws_array_list_length(list) > 0) {
+
+ AWS_FATAL_PRECONDITION(list->data);
+
+ size_t last_item_offset = list->item_size * (aws_array_list_length(list) - 1);
+
+ memset((void *)((uint8_t *)list->data + last_item_offset), 0, list->item_size);
+ list->length--;
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return AWS_OP_SUCCESS;
+ }
+
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return aws_raise_error(AWS_ERROR_LIST_EMPTY);
+}
+
+AWS_STATIC_IMPL
+void aws_array_list_clear(struct aws_array_list *AWS_RESTRICT list) {
+ AWS_PRECONDITION(AWS_IS_ZEROED(*list) || aws_array_list_is_valid(list));
+ if (list->data) {
+#ifdef DEBUG_BUILD
+ memset(list->data, AWS_ARRAY_LIST_DEBUG_FILL, list->current_size);
+#endif
+ list->length = 0;
+ }
+ AWS_POSTCONDITION(AWS_IS_ZEROED(*list) || aws_array_list_is_valid(list));
+}
+
+AWS_STATIC_IMPL
+void aws_array_list_swap_contents(
+ struct aws_array_list *AWS_RESTRICT list_a,
+ struct aws_array_list *AWS_RESTRICT list_b) {
+ AWS_FATAL_PRECONDITION(list_a->alloc);
+ AWS_FATAL_PRECONDITION(list_a->alloc == list_b->alloc);
+ AWS_FATAL_PRECONDITION(list_a->item_size == list_b->item_size);
+ AWS_FATAL_PRECONDITION(list_a != list_b);
+ AWS_PRECONDITION(aws_array_list_is_valid(list_a));
+ AWS_PRECONDITION(aws_array_list_is_valid(list_b));
+
+ struct aws_array_list tmp = *list_a;
+ *list_a = *list_b;
+ *list_b = tmp;
+ AWS_POSTCONDITION(aws_array_list_is_valid(list_a));
+ AWS_POSTCONDITION(aws_array_list_is_valid(list_b));
+}
+
+AWS_STATIC_IMPL
+size_t aws_array_list_capacity(const struct aws_array_list *AWS_RESTRICT list) {
+ AWS_FATAL_PRECONDITION(list->item_size);
+ AWS_PRECONDITION(aws_array_list_is_valid(list));
+ size_t capacity = list->current_size / list->item_size;
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return capacity;
+}
+
+AWS_STATIC_IMPL
+size_t aws_array_list_length(const struct aws_array_list *AWS_RESTRICT list) {
+ /*
+ * This assert teaches clang-tidy and friends that list->data cannot be null in a non-empty
+ * list.
+ */
+ AWS_FATAL_PRECONDITION(!list->length || list->data);
+ AWS_PRECONDITION(AWS_IS_ZEROED(*list) || aws_array_list_is_valid(list));
+ size_t len = list->length;
+ AWS_POSTCONDITION(AWS_IS_ZEROED(*list) || aws_array_list_is_valid(list));
+ return len;
+}
+
+AWS_STATIC_IMPL
+int aws_array_list_get_at(const struct aws_array_list *AWS_RESTRICT list, void *val, size_t index) {
+ AWS_PRECONDITION(aws_array_list_is_valid(list));
+ AWS_PRECONDITION(
+ val && AWS_MEM_IS_WRITABLE(val, list->item_size),
+ "Input pointer [val] must point writable memory of [list->item_size] bytes.");
+ if (aws_array_list_length(list) > index) {
+ memcpy(val, (void *)((uint8_t *)list->data + (list->item_size * index)), list->item_size);
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return AWS_OP_SUCCESS;
+ }
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return aws_raise_error(AWS_ERROR_INVALID_INDEX);
+}
+
+AWS_STATIC_IMPL
+int aws_array_list_get_at_ptr(const struct aws_array_list *AWS_RESTRICT list, void **val, size_t index) {
+ AWS_PRECONDITION(aws_array_list_is_valid(list));
+ AWS_PRECONDITION(val != NULL);
+ if (aws_array_list_length(list) > index) {
+ *val = (void *)((uint8_t *)list->data + (list->item_size * index));
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return AWS_OP_SUCCESS;
+ }
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return aws_raise_error(AWS_ERROR_INVALID_INDEX);
+}
+
+AWS_STATIC_IMPL
+int aws_array_list_set_at(struct aws_array_list *AWS_RESTRICT list, const void *val, size_t index) {
+ AWS_PRECONDITION(aws_array_list_is_valid(list));
+ AWS_PRECONDITION(
+ val && AWS_MEM_IS_READABLE(val, list->item_size),
+ "Input pointer [val] must point readable memory of [list->item_size] bytes.");
+
+ if (aws_array_list_ensure_capacity(list, index)) {
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return AWS_OP_ERR;
+ }
+
+ AWS_FATAL_PRECONDITION(list->data);
+
+ memcpy((void *)((uint8_t *)list->data + (list->item_size * index)), val, list->item_size);
+
+ /*
+ * This isn't perfect, but its the best I can come up with for detecting
+ * length changes.
+ */
+ if (index >= aws_array_list_length(list)) {
+ if (aws_add_size_checked(index, 1, &list->length)) {
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return AWS_OP_ERR;
+ }
+ }
+
+ AWS_POSTCONDITION(aws_array_list_is_valid(list));
+ return AWS_OP_SUCCESS;
+}
+
+AWS_EXTERN_C_END
+
+#endif /* AWS_COMMON_ARRAY_LIST_INL */
diff --git a/include/aws/common/atomics.h b/include/aws/common/atomics.h
new file mode 100644
index 0000000000000000000000000000000000000000..a4fa72e38593fed2e7a22cb83a60401cd325e1ef
--- /dev/null
+++ b/include/aws/common/atomics.h
@@ -0,0 +1,329 @@
+#ifndef AWS_COMMON_ATOMICS_H
+#define AWS_COMMON_ATOMICS_H
+
+#include
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+/**
+ * struct aws_atomic_var represents an atomic variable - a value which can hold an integer or pointer
+ * that can be manipulated atomically. struct aws_atomic_vars should normally only be manipulated
+ * with atomics methods defined in this header.
+ */
+struct aws_atomic_var {
+ void *value;
+};
+/* Helpers for extracting the integer and pointer values from aws_atomic_var. */
+#define AWS_ATOMIC_VAR_PTRVAL(var) ((var)->value)
+#define AWS_ATOMIC_VAR_INTVAL(var) (*(aws_atomic_impl_int_t *)(var))
+
+/*
+ * This enumeration specifies the memory ordering properties requested for a particular
+ * atomic operation. The atomic operation may provide stricter ordering than requested.
+ * Note that, within a single thread, all operations are still sequenced (that is, a thread
+ * sees its own atomic writes and reads happening in program order, but other threads may
+ * disagree on this ordering).
+ *
+ * The behavior of these memory orderings are the same as in the C11 atomics API; however,
+ * we only implement a subset that can be portably implemented on the compilers we target.
+ */
+
+enum aws_memory_order {
+ /**
+ * No particular ordering constraints are guaranteed relative to other
+ * operations at all; we merely ensure that the operation itself is atomic.
+ */
+ aws_memory_order_relaxed = 0,
+ /* aws_memory_order_consume - not currently implemented */
+
+ /**
+ * Specifies acquire ordering. No reads or writes on the current thread can be
+ * reordered to happen before this operation. This is typically paired with a release
+ * ordering; any writes that happened on the releasing operation will be visible
+ * after the paired acquire operation.
+ *
+ * Acquire ordering is only meaningful on load or load-store operations.
+ */
+ aws_memory_order_acquire = 2, /* leave a spot for consume if we ever add it */
+
+ /**
+ * Specifies release order. No reads or writes can be reordered to come after this
+ * operation. Typically paired with an acquire operation.
+ *
+ * Release ordering is only meaningful on store or load-store operations.
+ */
+ aws_memory_order_release,
+
+ /**
+ * Specifies acquire-release order; if this operation acts as a load, it acts as an
+ * acquire operation; if it acts as a store, it acts as a release operation; if it's
+ * a load-store, it does both.
+ */
+ aws_memory_order_acq_rel,
+
+ /*
+ * Specifies sequentially consistent order. This behaves as acq_rel, but in addition,
+ * all seq_cst operations appear to occur in some globally consistent order.
+ *
+ * TODO: Figure out how to correctly implement this in MSVC. It appears that interlocked
+ * functions provide only acq_rel ordering.
+ */
+ aws_memory_order_seq_cst
+};
+
+/**
+ * Statically initializes an aws_atomic_var to a given size_t value.
+ */
+#define AWS_ATOMIC_INIT_INT(x) {.value = (void *)(uintptr_t)(x)}
+
+/**
+ * Statically initializes an aws_atomic_var to a given void * value.
+ */
+#define AWS_ATOMIC_INIT_PTR(x) {.value = (void *)(x)}
+
+AWS_EXTERN_C_BEGIN
+
+/*
+ * Note: We do not use the C11 atomics API; this is because we want to make sure the representation
+ * (and behavior) of atomic values is consistent, regardless of what --std= flag you pass to your compiler.
+ * Since C11 atomics can silently introduce locks, we run the risk of creating such ABI inconsistencies
+ * if we decide based on compiler features which atomics API to use, and in practice we expect to have
+ * either the GNU or MSVC atomics anyway.
+ *
+ * As future work, we could test to see if the C11 atomics API on this platform behaves consistently
+ * with the other APIs and use it if it does.
+ */
+
+/**
+ * Initializes an atomic variable with an integer value. This operation should be done before any
+ * other operations on this atomic variable, and must be done before attempting any parallel operations.
+ *
+ * This operation does not imply a barrier. Ensure that you use an acquire-release barrier (or stronger)
+ * when communicating the fact that initialization is complete to the other thread. Launching the thread
+ * implies a sufficiently strong barrier.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_init_int(volatile struct aws_atomic_var *var, size_t n);
+
+/**
+ * Initializes an atomic variable with a pointer value. This operation should be done before any
+ * other operations on this atomic variable, and must be done before attempting any parallel operations.
+ *
+ * This operation does not imply a barrier. Ensure that you use an acquire-release barrier (or stronger)
+ * when communicating the fact that initialization is complete to the other thread. Launching the thread
+ * implies a sufficiently strong barrier.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_init_ptr(volatile struct aws_atomic_var *var, void *p);
+
+/**
+ * Reads an atomic var as an integer, using the specified ordering, and returns the result.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_load_int_explicit(volatile const struct aws_atomic_var *var, enum aws_memory_order memory_order);
+
+/**
+ * Reads an atomic var as an integer, using sequentially consistent ordering, and returns the result.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_load_int(volatile const struct aws_atomic_var *var);
+/**
+ * Reads an atomic var as a pointer, using the specified ordering, and returns the result.
+ */
+AWS_STATIC_IMPL
+void *aws_atomic_load_ptr_explicit(volatile const struct aws_atomic_var *var, enum aws_memory_order memory_order);
+
+/**
+ * Reads an atomic var as a pointer, using sequentially consistent ordering, and returns the result.
+ */
+AWS_STATIC_IMPL
+void *aws_atomic_load_ptr(volatile const struct aws_atomic_var *var);
+
+/**
+ * Stores an integer into an atomic var, using the specified ordering.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_store_int_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order memory_order);
+
+/**
+ * Stores an integer into an atomic var, using sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_store_int(volatile struct aws_atomic_var *var, size_t n);
+
+/**
+ * Stores a pointer into an atomic var, using the specified ordering.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_store_ptr_explicit(volatile struct aws_atomic_var *var, void *p, enum aws_memory_order memory_order);
+
+/**
+ * Stores a pointer into an atomic var, using sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_store_ptr(volatile struct aws_atomic_var *var, void *p);
+
+/**
+ * Exchanges an integer with the value in an atomic_var, using the specified ordering.
+ * Returns the value that was previously in the atomic_var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_exchange_int_explicit(
+ volatile struct aws_atomic_var *var,
+ size_t n,
+ enum aws_memory_order memory_order);
+
+/**
+ * Exchanges an integer with the value in an atomic_var, using sequentially consistent ordering.
+ * Returns the value that was previously in the atomic_var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_exchange_int(volatile struct aws_atomic_var *var, size_t n);
+
+/**
+ * Exchanges a pointer with the value in an atomic_var, using the specified ordering.
+ * Returns the value that was previously in the atomic_var.
+ */
+AWS_STATIC_IMPL
+void *aws_atomic_exchange_ptr_explicit(
+ volatile struct aws_atomic_var *var,
+ void *p,
+ enum aws_memory_order memory_order);
+
+/**
+ * Exchanges an integer with the value in an atomic_var, using sequentially consistent ordering.
+ * Returns the value that was previously in the atomic_var.
+ */
+AWS_STATIC_IMPL
+void *aws_atomic_exchange_ptr(volatile struct aws_atomic_var *var, void *p);
+
+/**
+ * Atomically compares *var to *expected; if they are equal, atomically sets *var = desired. Otherwise, *expected is set
+ * to the value in *var. On success, the memory ordering used was order_success; otherwise, it was order_failure.
+ * order_failure must be no stronger than order_success, and must not be release or acq_rel.
+ * Returns true if the compare was successful and the variable updated to desired.
+ */
+AWS_STATIC_IMPL
+bool aws_atomic_compare_exchange_int_explicit(
+ volatile struct aws_atomic_var *var,
+ size_t *expected,
+ size_t desired,
+ enum aws_memory_order order_success,
+ enum aws_memory_order order_failure);
+
+/**
+ * Atomically compares *var to *expected; if they are equal, atomically sets *var = desired. Otherwise, *expected is set
+ * to the value in *var. Uses sequentially consistent memory ordering, regardless of success or failure.
+ * Returns true if the compare was successful and the variable updated to desired.
+ */
+AWS_STATIC_IMPL
+bool aws_atomic_compare_exchange_int(volatile struct aws_atomic_var *var, size_t *expected, size_t desired);
+
+/**
+ * Atomically compares *var to *expected; if they are equal, atomically sets *var = desired. Otherwise, *expected is set
+ * to the value in *var. On success, the memory ordering used was order_success; otherwise, it was order_failure.
+ * order_failure must be no stronger than order_success, and must not be release or acq_rel.
+ * Returns true if the compare was successful and the variable updated to desired.
+ */
+AWS_STATIC_IMPL
+bool aws_atomic_compare_exchange_ptr_explicit(
+ volatile struct aws_atomic_var *var,
+ void **expected,
+ void *desired,
+ enum aws_memory_order order_success,
+ enum aws_memory_order order_failure);
+
+/**
+ * Atomically compares *var to *expected; if they are equal, atomically sets *var = desired. Otherwise, *expected is set
+ * to the value in *var. Uses sequentially consistent memory ordering, regardless of success or failure.
+ * Returns true if the compare was successful and the variable updated to desired.
+ */
+AWS_STATIC_IMPL
+bool aws_atomic_compare_exchange_ptr(volatile struct aws_atomic_var *var, void **expected, void *desired);
+
+/**
+ * Atomically adds n to *var, and returns the previous value of *var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_add_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order);
+
+/**
+ * Atomically subtracts n from *var, and returns the previous value of *var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_sub_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order);
+
+/**
+ * Atomically ORs n with *var, and returns the previous value of *var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_or_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order);
+
+/**
+ * Atomically ANDs n with *var, and returns the previous value of *var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_and_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order);
+
+/**
+ * Atomically XORs n with *var, and returns the previous value of *var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_xor_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order);
+
+/**
+ * Atomically adds n to *var, and returns the previous value of *var.
+ * Uses sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_add(volatile struct aws_atomic_var *var, size_t n);
+
+/**
+ * Atomically subtracts n from *var, and returns the previous value of *var.
+ * Uses sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_sub(volatile struct aws_atomic_var *var, size_t n);
+
+/**
+ * Atomically ands n into *var, and returns the previous value of *var.
+ * Uses sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_and(volatile struct aws_atomic_var *var, size_t n);
+
+/**
+ * Atomically ors n into *var, and returns the previous value of *var.
+ * Uses sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_or(volatile struct aws_atomic_var *var, size_t n);
+
+/**
+ * Atomically xors n into *var, and returns the previous value of *var.
+ * Uses sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_xor(volatile struct aws_atomic_var *var, size_t n);
+
+/**
+ * Provides the same reordering guarantees as an atomic operation with the specified memory order, without
+ * needing to actually perform an atomic operation.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_thread_fence(enum aws_memory_order order);
+
+AWS_EXTERN_C_END
+
+#ifndef AWS_NO_STATIC_IMPL
+# include
+#endif /* AWS_NO_STATIC_IMPL */
+
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif
diff --git a/include/aws/common/atomics.inl b/include/aws/common/atomics.inl
new file mode 100644
index 0000000000000000000000000000000000000000..306504fb17653dd0d1836ee8561277e24d89c0ce
--- /dev/null
+++ b/include/aws/common/atomics.inl
@@ -0,0 +1,147 @@
+#ifndef AWS_COMMON_ATOMICS_INL
+#define AWS_COMMON_ATOMICS_INL
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Reads an atomic var as an integer, using sequentially consistent ordering, and returns the result.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_load_int(volatile const struct aws_atomic_var *var) {
+ return aws_atomic_load_int_explicit(var, aws_memory_order_seq_cst);
+}
+
+/**
+ * Reads an atomic var as a pointer, using sequentially consistent ordering, and returns the result.
+ */
+AWS_STATIC_IMPL
+void *aws_atomic_load_ptr(volatile const struct aws_atomic_var *var) {
+ return aws_atomic_load_ptr_explicit(var, aws_memory_order_seq_cst);
+}
+
+/**
+ * Stores an integer into an atomic var, using sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_store_int(volatile struct aws_atomic_var *var, size_t n) {
+ aws_atomic_store_int_explicit(var, n, aws_memory_order_seq_cst);
+}
+
+/**
+ * Stores a pointer into an atomic var, using sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_store_ptr(volatile struct aws_atomic_var *var, void *p) {
+ aws_atomic_store_ptr_explicit(var, p, aws_memory_order_seq_cst);
+}
+
+/**
+ * Exchanges an integer with the value in an atomic_var, using sequentially consistent ordering.
+ * Returns the value that was previously in the atomic_var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_exchange_int(volatile struct aws_atomic_var *var, size_t n) {
+ return aws_atomic_exchange_int_explicit(var, n, aws_memory_order_seq_cst);
+}
+
+/**
+ * Exchanges an integer with the value in an atomic_var, using sequentially consistent ordering.
+ * Returns the value that was previously in the atomic_var.
+ */
+AWS_STATIC_IMPL
+void *aws_atomic_exchange_ptr(volatile struct aws_atomic_var *var, void *p) {
+ return aws_atomic_exchange_ptr_explicit(var, p, aws_memory_order_seq_cst);
+}
+
+/**
+ * Atomically compares *var to *expected; if they are equal, atomically sets *var = desired. Otherwise, *expected is set
+ * to the value in *var. Uses sequentially consistent memory ordering, regardless of success or failure.
+ * Returns true if the compare was successful and the variable updated to desired.
+ */
+AWS_STATIC_IMPL
+bool aws_atomic_compare_exchange_int(volatile struct aws_atomic_var *var, size_t *expected, size_t desired) {
+ return aws_atomic_compare_exchange_int_explicit(
+ var, expected, desired, aws_memory_order_seq_cst, aws_memory_order_seq_cst);
+}
+
+/**
+ * Atomically compares *var to *expected; if they are equal, atomically sets *var = desired. Otherwise, *expected is set
+ * to the value in *var. Uses sequentially consistent memory ordering, regardless of success or failure.
+ * Returns true if the compare was successful and the variable updated to desired.
+ */
+AWS_STATIC_IMPL
+bool aws_atomic_compare_exchange_ptr(volatile struct aws_atomic_var *var, void **expected, void *desired) {
+ return aws_atomic_compare_exchange_ptr_explicit(
+ var, expected, desired, aws_memory_order_seq_cst, aws_memory_order_seq_cst);
+}
+
+/**
+ * Atomically adds n to *var, and returns the previous value of *var.
+ * Uses sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_add(volatile struct aws_atomic_var *var, size_t n) {
+ return aws_atomic_fetch_add_explicit(var, n, aws_memory_order_seq_cst);
+}
+
+/**
+ * Atomically subtracts n from *var, and returns the previous value of *var.
+ * Uses sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_sub(volatile struct aws_atomic_var *var, size_t n) {
+ return aws_atomic_fetch_sub_explicit(var, n, aws_memory_order_seq_cst);
+}
+
+/**
+ * Atomically ands n into *var, and returns the previous value of *var.
+ * Uses sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_and(volatile struct aws_atomic_var *var, size_t n) {
+ return aws_atomic_fetch_and_explicit(var, n, aws_memory_order_seq_cst);
+}
+
+/**
+ * Atomically ors n into *var, and returns the previous value of *var.
+ * Uses sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_or(volatile struct aws_atomic_var *var, size_t n) {
+ return aws_atomic_fetch_or_explicit(var, n, aws_memory_order_seq_cst);
+}
+
+/**
+ * Atomically xors n into *var, and returns the previous value of *var.
+ * Uses sequentially consistent ordering.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_xor(volatile struct aws_atomic_var *var, size_t n) {
+ return aws_atomic_fetch_xor_explicit(var, n, aws_memory_order_seq_cst);
+}
+AWS_EXTERN_C_END
+
+/* Include the backend implementation now, because we'll use its typedefs and #defines below */
+#if defined(__GNUC__) || defined(__clang__)
+# if defined(__ATOMIC_RELAXED)
+# include
+# else
+# include
+# endif /* __ATOMIC_RELAXED */
+#elif defined(_MSC_VER)
+# include
+#else
+# error No atomics implementation for your compiler is available
+#endif
+
+#include
+
+#endif /* AWS_COMMON_ATOMICS_INL */
diff --git a/include/aws/common/atomics_gnu.inl b/include/aws/common/atomics_gnu.inl
new file mode 100644
index 0000000000000000000000000000000000000000..711b7795d64f7285095c8161dda810e1a6103816
--- /dev/null
+++ b/include/aws/common/atomics_gnu.inl
@@ -0,0 +1,218 @@
+#ifndef AWS_COMMON_ATOMICS_GNU_INL
+#define AWS_COMMON_ATOMICS_GNU_INL
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+/* These are implicitly included, but help with editor highlighting */
+#include
+#include
+
+#include
+#include
+
+AWS_EXTERN_C_BEGIN
+
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wc11-extensions"
+#else
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+
+typedef size_t aws_atomic_impl_int_t;
+
+static inline int aws_atomic_priv_xlate_order(enum aws_memory_order order) {
+ switch (order) {
+ case aws_memory_order_relaxed:
+ return __ATOMIC_RELAXED;
+ case aws_memory_order_acquire:
+ return __ATOMIC_ACQUIRE;
+ case aws_memory_order_release:
+ return __ATOMIC_RELEASE;
+ case aws_memory_order_acq_rel:
+ return __ATOMIC_ACQ_REL;
+ case aws_memory_order_seq_cst:
+ return __ATOMIC_SEQ_CST;
+ default: /* Unknown memory order */
+ abort();
+ }
+}
+
+/**
+ * Initializes an atomic variable with an integer value. This operation should be done before any
+ * other operations on this atomic variable, and must be done before attempting any parallel operations.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_init_int(volatile struct aws_atomic_var *var, size_t n) {
+ AWS_ATOMIC_VAR_INTVAL(var) = n;
+}
+
+/**
+ * Initializes an atomic variable with a pointer value. This operation should be done before any
+ * other operations on this atomic variable, and must be done before attempting any parallel operations.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_init_ptr(volatile struct aws_atomic_var *var, void *p) {
+ AWS_ATOMIC_VAR_PTRVAL(var) = p;
+}
+
+/**
+ * Reads an atomic var as an integer, using the specified ordering, and returns the result.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_load_int_explicit(volatile const struct aws_atomic_var *var, enum aws_memory_order memory_order) {
+ return __atomic_load_n(&AWS_ATOMIC_VAR_INTVAL(var), aws_atomic_priv_xlate_order(memory_order));
+}
+
+/**
+ * Reads an atomic var as a pointer, using the specified ordering, and returns the result.
+ */
+AWS_STATIC_IMPL
+void *aws_atomic_load_ptr_explicit(volatile const struct aws_atomic_var *var, enum aws_memory_order memory_order) {
+ return __atomic_load_n(&AWS_ATOMIC_VAR_PTRVAL(var), aws_atomic_priv_xlate_order(memory_order));
+}
+
+/**
+ * Stores an integer into an atomic var, using the specified ordering.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_store_int_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order memory_order) {
+ __atomic_store_n(&AWS_ATOMIC_VAR_INTVAL(var), n, aws_atomic_priv_xlate_order(memory_order));
+}
+
+/**
+ * Stores an pointer into an atomic var, using the specified ordering.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_store_ptr_explicit(volatile struct aws_atomic_var *var, void *p, enum aws_memory_order memory_order) {
+ __atomic_store_n(&AWS_ATOMIC_VAR_PTRVAL(var), p, aws_atomic_priv_xlate_order(memory_order));
+}
+
+/**
+ * Exchanges an integer with the value in an atomic_var, using the specified ordering.
+ * Returns the value that was previously in the atomic_var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_exchange_int_explicit(
+ volatile struct aws_atomic_var *var,
+ size_t n,
+ enum aws_memory_order memory_order) {
+ return __atomic_exchange_n(&AWS_ATOMIC_VAR_INTVAL(var), n, aws_atomic_priv_xlate_order(memory_order));
+}
+
+/**
+ * Exchanges a pointer with the value in an atomic_var, using the specified ordering.
+ * Returns the value that was previously in the atomic_var.
+ */
+AWS_STATIC_IMPL
+void *aws_atomic_exchange_ptr_explicit(
+ volatile struct aws_atomic_var *var,
+ void *p,
+ enum aws_memory_order memory_order) {
+ return __atomic_exchange_n(&AWS_ATOMIC_VAR_PTRVAL(var), p, aws_atomic_priv_xlate_order(memory_order));
+}
+
+/**
+ * Atomically compares *var to *expected; if they are equal, atomically sets *var = desired. Otherwise, *expected is set
+ * to the value in *var. On success, the memory ordering used was order_success; otherwise, it was order_failure.
+ * order_failure must be no stronger than order_success, and must not be release or acq_rel.
+ */
+AWS_STATIC_IMPL
+bool aws_atomic_compare_exchange_int_explicit(
+ volatile struct aws_atomic_var *var,
+ size_t *expected,
+ size_t desired,
+ enum aws_memory_order order_success,
+ enum aws_memory_order order_failure) {
+ return __atomic_compare_exchange_n(
+ &AWS_ATOMIC_VAR_INTVAL(var),
+ expected,
+ desired,
+ false,
+ aws_atomic_priv_xlate_order(order_success),
+ aws_atomic_priv_xlate_order(order_failure));
+}
+
+/**
+ * Atomically compares *var to *expected; if they are equal, atomically sets *var = desired. Otherwise, *expected is set
+ * to the value in *var. On success, the memory ordering used was order_success; otherwise, it was order_failure.
+ * order_failure must be no stronger than order_success, and must not be release or acq_rel.
+ */
+AWS_STATIC_IMPL
+bool aws_atomic_compare_exchange_ptr_explicit(
+ volatile struct aws_atomic_var *var,
+ void **expected,
+ void *desired,
+ enum aws_memory_order order_success,
+ enum aws_memory_order order_failure) {
+ return __atomic_compare_exchange_n(
+ &AWS_ATOMIC_VAR_PTRVAL(var),
+ expected,
+ desired,
+ false,
+ aws_atomic_priv_xlate_order(order_success),
+ aws_atomic_priv_xlate_order(order_failure));
+}
+
+/**
+ * Atomically adds n to *var, and returns the previous value of *var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_add_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order) {
+ return __atomic_fetch_add(&AWS_ATOMIC_VAR_INTVAL(var), n, aws_atomic_priv_xlate_order(order));
+}
+
+/**
+ * Atomically subtracts n from *var, and returns the previous value of *var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_sub_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order) {
+ return __atomic_fetch_sub(&AWS_ATOMIC_VAR_INTVAL(var), n, aws_atomic_priv_xlate_order(order));
+}
+
+/**
+ * Atomically ORs n with *var, and returns the previous value of *var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_or_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order) {
+ return __atomic_fetch_or(&AWS_ATOMIC_VAR_INTVAL(var), n, aws_atomic_priv_xlate_order(order));
+}
+
+/**
+ * Atomically ANDs n with *var, and returns the previous value of *var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_and_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order) {
+ return __atomic_fetch_and(&AWS_ATOMIC_VAR_INTVAL(var), n, aws_atomic_priv_xlate_order(order));
+}
+
+/**
+ * Atomically XORs n with *var, and returns the previous value of *var.
+ */
+AWS_STATIC_IMPL
+size_t aws_atomic_fetch_xor_explicit(volatile struct aws_atomic_var *var, size_t n, enum aws_memory_order order) {
+ return __atomic_fetch_xor(&AWS_ATOMIC_VAR_INTVAL(var), n, aws_atomic_priv_xlate_order(order));
+}
+
+/**
+ * Provides the same reordering guarantees as an atomic operation with the specified memory order, without
+ * needing to actually perform an atomic operation.
+ */
+AWS_STATIC_IMPL
+void aws_atomic_thread_fence(enum aws_memory_order order) {
+ __atomic_thread_fence(order);
+}
+
+#ifdef __clang__
+# pragma clang diagnostic pop
+#else
+# pragma GCC diagnostic pop
+#endif
+
+#define AWS_ATOMICS_HAVE_THREAD_FENCE
+AWS_EXTERN_C_END
+#endif /* AWS_COMMON_ATOMICS_GNU_INL */
diff --git a/include/aws/common/byte_order.h b/include/aws/common/byte_order.h
new file mode 100644
index 0000000000000000000000000000000000000000..c2bd0d1b5692c055016cc6bc5aaa62073db74e84
--- /dev/null
+++ b/include/aws/common/byte_order.h
@@ -0,0 +1,76 @@
+#ifndef AWS_COMMON_BYTE_ORDER_H
+#define AWS_COMMON_BYTE_ORDER_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Returns 1 if machine is big endian, 0 if little endian.
+ * If you compile with even -O1 optimization, this check is completely optimized
+ * out at compile time and code which calls "if (aws_is_big_endian())" will do
+ * the right thing without branching.
+ */
+AWS_STATIC_IMPL int aws_is_big_endian(void);
+/**
+ * Convert 64 bit integer from host to network byte order.
+ */
+AWS_STATIC_IMPL uint64_t aws_hton64(uint64_t x);
+/**
+ * Convert 64 bit integer from network to host byte order.
+ */
+AWS_STATIC_IMPL uint64_t aws_ntoh64(uint64_t x);
+
+/**
+ * Convert 32 bit integer from host to network byte order.
+ */
+AWS_STATIC_IMPL uint32_t aws_hton32(uint32_t x);
+
+/**
+ * Convert 32 bit float from host to network byte order.
+ */
+AWS_STATIC_IMPL float aws_htonf32(float x);
+
+/**
+ * Convert 64 bit double from host to network byte order.
+ */
+AWS_STATIC_IMPL double aws_htonf64(double x);
+
+/**
+ * Convert 32 bit integer from network to host byte order.
+ */
+AWS_STATIC_IMPL uint32_t aws_ntoh32(uint32_t x);
+
+/**
+ * Convert 32 bit float from network to host byte order.
+ */
+AWS_STATIC_IMPL float aws_ntohf32(float x);
+/**
+ * Convert 32 bit float from network to host byte order.
+ */
+AWS_STATIC_IMPL double aws_ntohf64(double x);
+
+/**
+ * Convert 16 bit integer from host to network byte order.
+ */
+AWS_STATIC_IMPL uint16_t aws_hton16(uint16_t x);
+
+/**
+ * Convert 16 bit integer from network to host byte order.
+ */
+AWS_STATIC_IMPL uint16_t aws_ntoh16(uint16_t x);
+
+AWS_EXTERN_C_END
+#ifndef AWS_NO_STATIC_IMPL
+# include
+#endif /* AWS_NO_STATIC_IMPL */
+
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_BYTE_ORDER_H */
diff --git a/include/aws/common/cache.h b/include/aws/common/cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..dfac0de6dd3be1fe0cf72c97ae84058f7b6d3d22
--- /dev/null
+++ b/include/aws/common/cache.h
@@ -0,0 +1,87 @@
+#ifndef AWS_COMMON_CACHE_H
+#define AWS_COMMON_CACHE_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_cache;
+
+struct aws_cache_vtable {
+ void (*destroy)(struct aws_cache *cache);
+ int (*find)(struct aws_cache *cache, const void *key, void **p_value);
+ int (*put)(struct aws_cache *cache, const void *key, void *p_value);
+ int (*remove)(struct aws_cache *cache, const void *key);
+ void (*clear)(struct aws_cache *cache);
+ size_t (*get_element_count)(const struct aws_cache *cache);
+};
+
+/**
+ * Base stucture for caches, used the linked hash table implementation.
+ */
+struct aws_cache {
+ struct aws_allocator *allocator;
+ const struct aws_cache_vtable *vtable;
+ struct aws_linked_hash_table table;
+ size_t max_items;
+
+ void *impl;
+};
+
+/* Default implementations */
+void aws_cache_base_default_destroy(struct aws_cache *cache);
+int aws_cache_base_default_find(struct aws_cache *cache, const void *key, void **p_value);
+int aws_cache_base_default_remove(struct aws_cache *cache, const void *key);
+void aws_cache_base_default_clear(struct aws_cache *cache);
+size_t aws_cache_base_default_get_element_count(const struct aws_cache *cache);
+
+AWS_EXTERN_C_BEGIN
+/**
+ * Cleans up the cache. Elements in the cache will be evicted and cleanup
+ * callbacks will be invoked.
+ */
+AWS_COMMON_API
+void aws_cache_destroy(struct aws_cache *cache);
+
+/**
+ * Finds element in the cache by key. If found, *p_value will hold the stored value, and AWS_OP_SUCCESS will be
+ * returned. If not found, AWS_OP_SUCCESS will be returned and *p_value will be NULL.
+ *
+ * If any errors occur AWS_OP_ERR will be returned.
+ */
+AWS_COMMON_API
+int aws_cache_find(struct aws_cache *cache, const void *key, void **p_value);
+
+/**
+ * Puts `p_value` at `key`. If an element is already stored at `key` it will be replaced. If the cache is already full,
+ * an item will be removed based on the cache policy.
+ */
+AWS_COMMON_API
+int aws_cache_put(struct aws_cache *cache, const void *key, void *p_value);
+
+/**
+ * Removes item at `key` from the cache.
+ */
+AWS_COMMON_API
+int aws_cache_remove(struct aws_cache *cache, const void *key);
+
+/**
+ * Clears all items from the cache.
+ */
+AWS_COMMON_API
+void aws_cache_clear(struct aws_cache *cache);
+
+/**
+ * Returns the number of elements in the cache.
+ */
+AWS_COMMON_API
+size_t aws_cache_get_element_count(const struct aws_cache *cache);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_CACHE_H */
diff --git a/include/aws/common/cbor.h b/include/aws/common/cbor.h
new file mode 100644
index 0000000000000000000000000000000000000000..a7369fc6ff3471b63fe97d44f5054e35d121da98
--- /dev/null
+++ b/include/aws/common/cbor.h
@@ -0,0 +1,460 @@
+#ifndef AWS_COMMON_CBOR_H
+#define AWS_COMMON_CBOR_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+AWS_EXTERN_C_BEGIN
+
+/**
+ * The types use by APIs, not 1:1 with major type.
+ * It's an extension for cbor major type in RFC8949 section 3.1
+ * Major type 0 - AWS_CBOR_TYPE_UINT
+ * Major type 1 - AWS_CBOR_TYPE_NEGINT
+ * Major type 2 - AWS_CBOR_TYPE_BYTES/AWS_CBOR_TYPE_INDEF_BYTES_START
+ * Major type 3 - AWS_CBOR_TYPE_TEXT/AWS_CBOR_TYPE_INDEF_TEXT_START
+ * Major type 4 - AWS_CBOR_TYPE_ARRAY_START/AWS_CBOR_TYPE_INDEF_ARRAY_START
+ * Major type 5 - AWS_CBOR_TYPE_MAP_START/AWS_CBOR_TYPE_INDEF_MAP_START
+ * Major type 6 - AWS_CBOR_TYPE_TAG
+ * Major type 7
+ * - 20/21 - AWS_CBOR_TYPE_BOOL
+ * - 22 - AWS_CBOR_TYPE_NULL
+ * - 23 - AWS_CBOR_TYPE_UNDEFINED
+ * - 25/26/27 - AWS_CBOR_TYPE_FLOAT
+ * - 31 - AWS_CBOR_TYPE_BREAK
+ * - rest of value are not supported.
+ */
+enum aws_cbor_type {
+ AWS_CBOR_TYPE_UNKNOWN = 0,
+
+ AWS_CBOR_TYPE_UINT,
+ AWS_CBOR_TYPE_NEGINT,
+ AWS_CBOR_TYPE_FLOAT,
+ AWS_CBOR_TYPE_BYTES,
+ AWS_CBOR_TYPE_TEXT,
+
+ AWS_CBOR_TYPE_ARRAY_START,
+ AWS_CBOR_TYPE_MAP_START,
+
+ AWS_CBOR_TYPE_TAG,
+
+ AWS_CBOR_TYPE_BOOL,
+ AWS_CBOR_TYPE_NULL,
+ AWS_CBOR_TYPE_UNDEFINED,
+ AWS_CBOR_TYPE_BREAK,
+
+ AWS_CBOR_TYPE_INDEF_BYTES_START,
+ AWS_CBOR_TYPE_INDEF_TEXT_START,
+ AWS_CBOR_TYPE_INDEF_ARRAY_START,
+ AWS_CBOR_TYPE_INDEF_MAP_START,
+};
+
+/**
+ * The common tags, refer to RFC8949 section 3.4
+ * Expected value type followed by the tag:
+ * AWS_CBOR_TAG_STANDARD_TIME - AWS_CBOR_TYPE_TEXT
+ * AWS_CBOR_TAG_EPOCH_TIME - AWS_CBOR_TYPE_UINT/AWS_CBOR_TYPE_NEGINT/AWS_CBOR_TYPE_FLOAT
+ * AWS_CBOR_TAG_UNSIGNED_BIGNUM - AWS_CBOR_TYPE_BYTES
+ * AWS_CBOR_TAG_NEGATIVE_BIGNUM - AWS_CBOR_TYPE_BYTES
+ * AWS_CBOR_TAG_DECIMAL_FRACTION - AWS_CBOR_TYPE_ARRAY_START/AWS_CBOR_TYPE_INDEF_ARRAY_START
+ **/
+#define AWS_CBOR_TAG_STANDARD_TIME 0
+#define AWS_CBOR_TAG_EPOCH_TIME 1
+#define AWS_CBOR_TAG_UNSIGNED_BIGNUM 2
+#define AWS_CBOR_TAG_NEGATIVE_BIGNUM 3
+#define AWS_CBOR_TAG_DECIMAL_FRACTION 4
+
+struct aws_cbor_encoder;
+struct aws_cbor_decoder;
+
+/*******************************************************************************
+ * ENCODE
+ ******************************************************************************/
+
+/* Return c-string for aws_cbor_type */
+AWS_COMMON_API
+const char *aws_cbor_type_cstr(enum aws_cbor_type type);
+
+/**
+ * @brief Create a new cbor encoder. Creating a encoder with a temporay buffer.
+ * Every aws_cbor_encoder_write_* will encode directly into the buffer to follow the encoded data.
+ *
+ * @param allocator
+ * @return aws_cbor_encoder
+ */
+AWS_COMMON_API
+struct aws_cbor_encoder *aws_cbor_encoder_new(struct aws_allocator *allocator);
+
+AWS_COMMON_API
+struct aws_cbor_encoder *aws_cbor_encoder_destroy(struct aws_cbor_encoder *encoder);
+
+/**
+ * @brief Get the current encoded data from encoder. The encoded data has the same lifetime as the encoder, and once
+ * any other function call invoked for the encoder, the encoded data is no longer valid.
+ *
+ * @param encoder
+ * @return struct aws_byte_cursor from the encoder buffer.
+ */
+AWS_COMMON_API
+struct aws_byte_cursor aws_cbor_encoder_get_encoded_data(const struct aws_cbor_encoder *encoder);
+
+/**
+ * @brief Clear the current encoded buffer from encoder.
+ *
+ * @param encoder
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_reset(struct aws_cbor_encoder *encoder);
+
+/**
+ * @brief Encode a AWS_CBOR_TYPE_UINT value to "smallest possible" in encoder's buffer.
+ * Referring to RFC8949 section 4.2.1
+ *
+ * TODO: maybe add a width of the encoded value.
+ *
+ * @param encoder
+ * @param value value to encode.
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_uint(struct aws_cbor_encoder *encoder, uint64_t value);
+
+/**
+ * @brief Encode a AWS_CBOR_TYPE_NEGINT value to "smallest possible" in encoder's buffer.
+ * It represents (-1 - value).
+ * Referring to RFC8949 section 4.2.1
+ *
+ *
+ * @param encoder
+ * @param value The argument to encode to negative integer, which is (-1 - expected_val)
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_negint(struct aws_cbor_encoder *encoder, uint64_t value);
+
+/**
+ * @brief Encode a AWS_CBOR_TYPE_FLOAT value to "smallest possible", but will not be encoded into half-precision float,
+ * as it's not well supported cross languages.
+ *
+ * To be more specific, it will be encoded into integer/negative/float
+ * (Order with priority) when the conversation will not cause precision loss.
+ *
+ * @param encoder
+ * @param value value to encode.
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_float(struct aws_cbor_encoder *encoder, double value);
+
+/**
+ * @brief Encode a AWS_CBOR_TYPE_BYTES value to "smallest possible" in encoder's buffer.
+ * Referring to RFC8949 section 4.2.1, the length of "from" will be encoded first and then the value of "from" will
+ * be followed.
+ *
+ * @param encoder
+ * @param from value to encode.
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_bytes(struct aws_cbor_encoder *encoder, struct aws_byte_cursor from);
+
+/**
+ * @brief Encode a AWS_CBOR_TYPE_TEXT value to "smallest possible" in encoder's buffer.
+ * Referring to RFC8949 section 4.2.1, the length of "from" will be encoded first and then the value of "from" will
+ * be followed.
+ *
+ * @param encoder
+ * @param from value to encode.
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_text(struct aws_cbor_encoder *encoder, struct aws_byte_cursor from);
+
+/**
+ * @brief Encode a AWS_CBOR_TYPE_ARRAY_START value to "smallest possible" in encoder's buffer.
+ * Referring to RFC8949 section 4.2.1
+ * The "number_entries" is the cbor data items should be followed as the content of the array.
+ * Notes: it's user's responsibility to keep the integrity of the array to be encoded.
+ *
+ * @param encoder
+ * @param number_entries The number of data item in array.
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_array_start(struct aws_cbor_encoder *encoder, size_t number_entries);
+
+/**
+ * @brief Encode a AWS_CBOR_TYPE_MAP_START value to "smallest possible" in encoder's buffer.
+ * Referring to RFC8949 section 4.2.1
+ * The "number_entries" is the number of pair of cbor data items as key and value should be followed as the content of
+ * the map.
+ *
+ * Notes: it's user's responsibility to keep the integrity of the map to be encoded.
+ *
+ * @param encoder
+ * @param number_entries The number of data item in map.
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_map_start(struct aws_cbor_encoder *encoder, size_t number_entries);
+
+/**
+ * @brief Encode a AWS_CBOR_TYPE_TAG value to "smallest possible" in encoder's buffer.
+ * Referring to RFC8949 section 4.2.1
+ * The following cbor data item will be the content of the tagged value.
+ * Notes: it's user's responsibility to keep the integrity of the tagged value to follow the RFC8949 section 3.4
+ *
+ * @param encoder
+ * @param tag_number The tag value to encode.
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_tag(struct aws_cbor_encoder *encoder, uint64_t tag_number);
+
+/**
+ * @brief Encode a simple value AWS_CBOR_TYPE_NULL
+ *
+ * @param encoder
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_null(struct aws_cbor_encoder *encoder);
+
+/**
+ * @brief Encode a simple value AWS_CBOR_TYPE_UNDEFINED
+ *
+ * @param encoder
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_undefined(struct aws_cbor_encoder *encoder);
+
+/**
+ * @brief Encode a simple value AWS_CBOR_TYPE_BOOL
+ *
+ * @param encoder
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_bool(struct aws_cbor_encoder *encoder, bool value);
+
+/**
+ * @brief Encode a simple value AWS_CBOR_TYPE_BREAK
+ *
+ * Notes: no error checking, it's user's responsibility to track the break
+ * to close the corresponding indef_start
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_break(struct aws_cbor_encoder *encoder);
+
+/**
+ * @brief Encode a AWS_CBOR_TYPE_INDEF_BYTES_START
+ *
+ * Notes: no error checking, it's user's responsibility to add corresponding data and the break
+ * to close the indef_start
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_indef_bytes_start(struct aws_cbor_encoder *encoder);
+/**
+ * @brief Encode a AWS_CBOR_TYPE_INDEF_TEXT_START
+ *
+ * Notes: no error checking, it's user's responsibility to add corresponding data
+ * and the break to close the indef_start
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_indef_text_start(struct aws_cbor_encoder *encoder);
+/**
+ * @brief Encode a AWS_CBOR_TYPE_INDEF_ARRAY_START
+ *
+ * Notes: no error checking, it's user's responsibility to add corresponding data
+ * and the break to close the indef_start
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_indef_array_start(struct aws_cbor_encoder *encoder);
+/**
+ * @brief Encode a AWS_CBOR_TYPE_INDEF_MAP_START
+ *
+ * Notes: no error checking, it's user's responsibility to add corresponding data
+ * and the break to close the indef_start
+ */
+AWS_COMMON_API
+void aws_cbor_encoder_write_indef_map_start(struct aws_cbor_encoder *encoder);
+
+/*******************************************************************************
+ * DECODE
+ ******************************************************************************/
+
+/**
+ * @brief Create a cbor decoder to take src to decode.
+ * The typical usage of decoder will be:
+ * - If the next element type only accept what expected, `aws_cbor_decoder_pop_next_*`
+ * - If the next element type accept different type, invoke `aws_cbor_decoder_peek_type` first, then based on the type
+ * to invoke corresponding `aws_cbor_decoder_pop_next_*`
+ * - If the next element type doesn't have corrsponding value, specifically: AWS_CBOR_TYPE_NULL,
+ * AWS_CBOR_TYPE_UNDEFINED, AWS_CBOR_TYPE_INF_*_START, AWS_CBOR_TYPE_BREAK, call
+ * `aws_cbor_decoder_consume_next_single_element` to consume it and continues for further decoding.
+ * - To ignore the next data item (the element and the content of it), `aws_cbor_decoder_consume_next_whole_data_item`
+ *
+ * Note: it's caller's responsibilty to keep the src outlive the decoder.
+ *
+ * @param allocator
+ * @param src The src data to decode from.
+ * @return decoder
+ */
+AWS_COMMON_API
+struct aws_cbor_decoder *aws_cbor_decoder_new(struct aws_allocator *allocator, struct aws_byte_cursor src);
+
+AWS_COMMON_API
+struct aws_cbor_decoder *aws_cbor_decoder_destroy(struct aws_cbor_decoder *decoder);
+
+/**
+ * @brief Get the length of the remaining bytes of the source. Once the source was decoded, it will be consumed,
+ * and result in decrease of the remaining length of bytes.
+ *
+ * @param decoder
+ * @return The length of bytes remaining of the decoder source.
+ */
+AWS_COMMON_API
+size_t aws_cbor_decoder_get_remaining_length(const struct aws_cbor_decoder *decoder);
+
+/**
+ * @brief Reset the decoder source to a new src.
+ * The previous src will be discarded regardless of the unconsumed bytes.
+ * The decoder will clear its cache if any.
+ *
+ * @param decoder
+ * @param src The src data to decode from..
+ */
+AWS_COMMON_API
+void aws_cbor_decoder_reset_src(struct aws_cbor_decoder *decoder, struct aws_byte_cursor src);
+
+/**
+ * @brief Decode the next element and store it in the decoder cache if there was no element cached.
+ * If there was element cached, just return the type of the cached element.
+ *
+ * @param decoder
+ * @param out_type
+ * @return AWS_OP_SUCCESS if succeed, AWS_OP_ERR for any decoding error and corresponding error code will be raised.
+ */
+AWS_COMMON_API
+int aws_cbor_decoder_peek_type(struct aws_cbor_decoder *decoder, enum aws_cbor_type *out_type);
+
+/**
+ * @brief Consume the next data item, includes all the content within the data item.
+ *
+ * As an example for the following cbor, this function will consume all the data
+ * as it's only one cbor data item, an indefinite map with 2 pair:
+ * 0xbf6346756ef563416d7421ff
+ * BF -- Start indefinite-length map
+ * 63 -- First key, UTF-8 string length 3
+ * 46756e -- "Fun"
+ * F5 -- First value, true
+ * 63 -- Second key, UTF-8 string length 3
+ * 416d74 -- "Amt"
+ * 21 -- Second value, -2
+ * FF -- "break"
+ *
+ * Notes: this function will not ensure the data item is well-formed.
+ *
+ * @param src The src to parse data from
+ * @return AWS_OP_SUCCESS successfully consumed the next data item, otherwise AWS_OP_ERR.
+ */
+AWS_COMMON_API
+int aws_cbor_decoder_consume_next_whole_data_item(struct aws_cbor_decoder *decoder);
+
+/**
+ * @brief Consume the next single element, without the content followed by the element.
+ *
+ * As an example for the following cbor, this function will only consume the
+ * 0xBF, "Start indefinite-length map", not any content of the map represented.
+ * The next element to decode will start from 0x63
+ * 0xbf6346756ef563416d7421ff
+ * BF -- Start indefinite-length map
+ * 63 -- First key, UTF-8 string length 3
+ * 46756e -- "Fun"
+ * F5 -- First value, true
+ * 63 -- Second key, UTF-8 string length 3
+ * 416d74 -- "Amt"
+ * 21 -- Second value, -2
+ * FF -- "break"
+ *
+ * @param decoder The decoder to parse data from
+ * @return AWS_OP_SUCCESS successfully consumed the next element, otherwise AWS_OP_ERR.
+ */
+AWS_COMMON_API
+int aws_cbor_decoder_consume_next_single_element(struct aws_cbor_decoder *decoder);
+
+/**
+ * @brief Get the next element based on the type. If the next element doesn't match the expected type. Error will be
+ * raised. If the next element already been cached, it will consume the cached item when no error was returned.
+ * Specifically:
+ * AWS_CBOR_TYPE_UINT - aws_cbor_decoder_pop_next_unsigned_int_val
+ * AWS_CBOR_TYPE_NEGINT - aws_cbor_decoder_pop_next_negative_int_val, it represents (-1 - *out)
+ * AWS_CBOR_TYPE_FLOAT - aws_cbor_decoder_pop_next_float_val
+ * AWS_CBOR_TYPE_BYTES - aws_cbor_decoder_pop_next_bytes_val
+ * AWS_CBOR_TYPE_TEXT - aws_cbor_decoder_pop_next_text_val
+ *
+ * @param decoder
+ * @param out
+ * @return AWS_OP_SUCCESS successfully consumed the next element and get the result, otherwise AWS_OP_ERR.
+ */
+AWS_COMMON_API
+int aws_cbor_decoder_pop_next_unsigned_int_val(struct aws_cbor_decoder *decoder, uint64_t *out);
+AWS_COMMON_API
+int aws_cbor_decoder_pop_next_negative_int_val(struct aws_cbor_decoder *decoder, uint64_t *out);
+AWS_COMMON_API
+int aws_cbor_decoder_pop_next_float_val(struct aws_cbor_decoder *decoder, double *out);
+AWS_COMMON_API
+int aws_cbor_decoder_pop_next_boolean_val(struct aws_cbor_decoder *decoder, bool *out);
+AWS_COMMON_API
+int aws_cbor_decoder_pop_next_bytes_val(struct aws_cbor_decoder *decoder, struct aws_byte_cursor *out);
+AWS_COMMON_API
+int aws_cbor_decoder_pop_next_text_val(struct aws_cbor_decoder *decoder, struct aws_byte_cursor *out);
+
+/**
+ * @brief Get the next AWS_CBOR_TYPE_ARRAY_START element. Only consume the AWS_CBOR_TYPE_ARRAY_START element and set the
+ * size of array to *out_size, not the content of the array. The next *out_size cbor data items will be the content of
+ * the array for a valid cbor data,
+ *
+ * Notes: For indefinite-length, this function will fail with "AWS_ERROR_CBOR_UNEXPECTED_TYPE". The designed way to
+ * handle indefinite-length is:
+ * - Get AWS_CBOR_TYPE_INDEF_ARRAY_START from _peek_type
+ * - call `aws_cbor_decoder_consume_next_single_element` to pop the indefinite-length start.
+ * - Decode the next data item until AWS_CBOR_TYPE_BREAK read.
+ *
+ * @param decoder
+ * @param out_size store the size of array if succeed.
+ * @return AWS_OP_SUCCESS successfully consumed the next element and get the result, otherwise AWS_OP_ERR.
+ */
+AWS_COMMON_API
+int aws_cbor_decoder_pop_next_array_start(struct aws_cbor_decoder *decoder, uint64_t *out_size);
+
+/**
+ * @brief Get the next AWS_CBOR_TYPE_MAP_START element.
+ * Only consume the AWS_CBOR_TYPE_MAP_START element and set the size of array to *out_size, not the content of the map.
+ * The next *out_size pair of cbor data items as key and value will be the content of the array for a valid cbor data,
+ *
+ * Notes: For indefinite-length, this function will fail with "AWS_ERROR_CBOR_UNEXPECTED_TYPE". The designed way to
+ * handle indefinite-length is:
+ * - Get AWS_CBOR_TYPE_INDEF_MAP_START from _peek_type
+ * - call `aws_cbor_decoder_consume_next_single_element` to pop the indefinite-length start.
+ * - Decode the next data item until AWS_CBOR_TYPE_BREAK read.
+ *
+ * @param decoder
+ * @param out_size store the size of map if succeed.
+ * @return AWS_OP_SUCCESS successfully consumed the next element and get the result, otherwise AWS_OP_ERR.
+ */
+AWS_COMMON_API
+int aws_cbor_decoder_pop_next_map_start(struct aws_cbor_decoder *decoder, uint64_t *out_size);
+
+/**
+ * @brief Get the next AWS_CBOR_TYPE_TAG element.
+ * Only consume the AWS_CBOR_TYPE_TAG element and set the tag ID value to *out_tag_val, not the content of the tagged.
+ * The next cbor data item will be the content of the tagged value for a valid cbor data.
+ *
+ * @param decoder
+ * @param out_tag_val store the value of tag ID.
+ * @return AWS_OP_SUCCESS successfully consumed the next element and get the result, otherwise AWS_OP_ERR.
+ */
+AWS_COMMON_API
+int aws_cbor_decoder_pop_next_tag_val(struct aws_cbor_decoder *decoder, uint64_t *out_tag_val);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif // AWS_COMMON_CBOR_H
diff --git a/include/aws/common/common.h b/include/aws/common/common.h
new file mode 100644
index 0000000000000000000000000000000000000000..b378a4f902165afea49f4d176df9535c4c395aa3
--- /dev/null
+++ b/include/aws/common/common.h
@@ -0,0 +1,48 @@
+#ifndef AWS_COMMON_COMMON_H
+#define AWS_COMMON_COMMON_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include /* for abort() */
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes internal data structures used by aws-c-common.
+ * Must be called before using any functionality in aws-c-common.
+ */
+AWS_COMMON_API
+void aws_common_library_init(struct aws_allocator *allocator);
+
+/**
+ * Shuts down the internal data structures used by aws-c-common.
+ */
+AWS_COMMON_API
+void aws_common_library_clean_up(void);
+
+AWS_COMMON_API
+void aws_common_fatal_assert_library_initialized(void);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_COMMON_H */
diff --git a/include/aws/common/condition_variable.h b/include/aws/common/condition_variable.h
new file mode 100644
index 0000000000000000000000000000000000000000..a4eb1bdfe31cc92a5e31756ee8e9a7c176be20e6
--- /dev/null
+++ b/include/aws/common/condition_variable.h
@@ -0,0 +1,118 @@
+#ifndef AWS_COMMON_CONDITION_VARIABLE_H
+#define AWS_COMMON_CONDITION_VARIABLE_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#ifndef _WIN32
+# include
+#endif
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_mutex;
+
+struct aws_condition_variable;
+
+typedef bool(aws_condition_predicate_fn)(void *);
+
+struct aws_condition_variable {
+#ifdef _WIN32
+ void *condition_handle;
+#else
+ pthread_cond_t condition_handle;
+#endif
+ bool initialized;
+};
+
+/**
+ * Static initializer for condition variable.
+ * You can do something like struct aws_condition_variable var =
+ * AWS_CONDITION_VARIABLE_INIT;
+ *
+ * If on Windows and you get an error about AWS_CONDITION_VARIABLE_INIT being undefined, please include windows.h to get
+ * CONDITION_VARIABLE_INIT.
+ */
+#ifdef _WIN32
+# define AWS_CONDITION_VARIABLE_INIT {.condition_handle = NULL, .initialized = true}
+#else
+# define AWS_CONDITION_VARIABLE_INIT {.condition_handle = PTHREAD_COND_INITIALIZER, .initialized = true}
+#endif
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes a condition variable.
+ */
+AWS_COMMON_API
+int aws_condition_variable_init(struct aws_condition_variable *condition_variable);
+
+/**
+ * Cleans up a condition variable.
+ */
+AWS_COMMON_API
+void aws_condition_variable_clean_up(struct aws_condition_variable *condition_variable);
+
+/**
+ * Notifies/Wakes one waiting thread
+ */
+AWS_COMMON_API
+int aws_condition_variable_notify_one(struct aws_condition_variable *condition_variable);
+
+/**
+ * Notifies/Wakes all waiting threads.
+ */
+AWS_COMMON_API
+int aws_condition_variable_notify_all(struct aws_condition_variable *condition_variable);
+
+/**
+ * Waits the calling thread on a notification from another thread. This function must be called with the mutex locked
+ * by the calling thread otherwise the behavior is undefined. Spurious wakeups can occur and to avoid this causing
+ * any problems use the _pred version of this function.
+ */
+AWS_COMMON_API
+int aws_condition_variable_wait(struct aws_condition_variable *condition_variable, struct aws_mutex *mutex);
+
+/**
+ * Waits the calling thread on a notification from another thread. If predicate returns false, the wait is reentered,
+ * otherwise control returns to the caller. This function must be called with the mutex locked by the calling thread
+ * otherwise the behavior is undefined.
+ */
+AWS_COMMON_API
+int aws_condition_variable_wait_pred(
+ struct aws_condition_variable *condition_variable,
+ struct aws_mutex *mutex,
+ aws_condition_predicate_fn *pred,
+ void *pred_ctx);
+
+/**
+ * Waits the calling thread on a notification from another thread. Times out after time_to_wait. time_to_wait is in
+ * nanoseconds. This function must be called with the mutex locked by the calling thread otherwise the behavior is
+ * undefined. Spurious wakeups can occur and to avoid this causing any problems use the _pred version of this function.
+ */
+AWS_COMMON_API
+int aws_condition_variable_wait_for(
+ struct aws_condition_variable *condition_variable,
+ struct aws_mutex *mutex,
+ int64_t time_to_wait);
+
+/**
+ * Waits the calling thread on a notification from another thread. Times out after time_to_wait. time_to_wait is in
+ * nanoseconds. If predicate returns false, the wait is reentered, otherwise control returns to the caller. This
+ * function must be called with the mutex locked by the calling thread otherwise the behavior is undefined.
+ */
+AWS_COMMON_API
+int aws_condition_variable_wait_for_pred(
+ struct aws_condition_variable *condition_variable,
+ struct aws_mutex *mutex,
+ int64_t time_to_wait,
+ aws_condition_predicate_fn *pred,
+ void *pred_ctx);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_CONDITION_VARIABLE_H */
diff --git a/include/aws/common/config.h b/include/aws/common/config.h
new file mode 100644
index 0000000000000000000000000000000000000000..45c522bbaaa17dd4555525c25381d4fbf2f1a59d
--- /dev/null
+++ b/include/aws/common/config.h
@@ -0,0 +1,33 @@
+#ifndef AWS_COMMON_CONFIG_H
+#define AWS_COMMON_CONFIG_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+/*
+ * This header exposes compiler feature test results determined during cmake
+ * configure time to inline function implementations. The macros defined here
+ * should be considered to be an implementation detail, and can change at any
+ * time.
+ */
+#define AWS_HAVE_GCC_OVERFLOW_MATH_EXTENSIONS
+#define AWS_HAVE_GCC_INLINE_ASM
+/* #undef AWS_HAVE_MSVC_INTRINSICS_X64 */
+#define AWS_HAVE_POSIX_LARGE_FILE_SUPPORT
+#define AWS_HAVE_EXECINFO
+/* #undef AWS_HAVE_WINAPI_DESKTOP */
+#define AWS_HAVE_LINUX_IF_LINK_H
+#define AWS_HAVE_AVX2_INTRINSICS
+#define AWS_HAVE_AVX512_INTRINSICS
+#define AWS_HAVE_MM256_EXTRACT_EPI64
+#define AWS_HAVE_CLMUL
+/* #undef AWS_HAVE_ARM32_CRC */
+/* #undef AWS_HAVE_ARMv8_1 */
+/* #undef AWS_ARCH_ARM64 */
+#define AWS_ARCH_INTEL
+#define AWS_ARCH_INTEL_X64
+#define AWS_USE_CPU_EXTENSIONS
+
+#endif
diff --git a/include/aws/common/cpuid.h b/include/aws/common/cpuid.h
new file mode 100644
index 0000000000000000000000000000000000000000..9ab7d505931ed11f1237a95abad42000314e591a
--- /dev/null
+++ b/include/aws/common/cpuid.h
@@ -0,0 +1,36 @@
+#ifndef AWS_COMMON_CPUID_H
+#define AWS_COMMON_CPUID_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+enum aws_cpu_feature_name {
+ AWS_CPU_FEATURE_CLMUL,
+ AWS_CPU_FEATURE_SSE_4_1,
+ AWS_CPU_FEATURE_SSE_4_2,
+ AWS_CPU_FEATURE_AVX2,
+ AWS_CPU_FEATURE_AVX512,
+ AWS_CPU_FEATURE_ARM_CRC,
+ AWS_CPU_FEATURE_BMI2,
+ AWS_CPU_FEATURE_VPCLMULQDQ,
+ AWS_CPU_FEATURE_ARM_PMULL,
+ AWS_CPU_FEATURE_ARM_CRYPTO,
+ AWS_CPU_FEATURE_COUNT,
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Returns true if a cpu feature is supported, false otherwise.
+ */
+AWS_COMMON_API bool aws_cpu_has_feature(enum aws_cpu_feature_name feature_name);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_CPUID_H */
diff --git a/include/aws/common/cross_process_lock.h b/include/aws/common/cross_process_lock.h
new file mode 100644
index 0000000000000000000000000000000000000000..99ecc5cb6b128425d4f31f56a13072f5b2eb69b0
--- /dev/null
+++ b/include/aws/common/cross_process_lock.h
@@ -0,0 +1,35 @@
+#ifndef AWS_COMMON_CROSS_PROCESS_LOCK_H
+#define AWS_COMMON_CROSS_PROCESS_LOCK_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+#include
+
+struct aws_cross_process_lock;
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Attempts to acquire a system-wide (not per process or per user) lock scoped by instance_nonce.
+ * For any given unique nonce, a lock will be returned by the first caller. Subsequent calls will
+ * return NULL and raise AWS_ERROR_MUTEX_CALLER_NOT_OWNER
+ * until the either the process owning the lock exits or the program owning the lock
+ * calls aws_cross_process_lock_release() explicitly.
+ *
+ * If the process exits before the lock is released, the kernel will unlock it for the next consumer.
+ */
+AWS_COMMON_API
+struct aws_cross_process_lock *aws_cross_process_lock_try_acquire(
+ struct aws_allocator *allocator,
+ struct aws_byte_cursor instance_nonce);
+
+/**
+ * Releases the lock so the next caller (may be another process) can get an instance of the lock.
+ */
+AWS_COMMON_API
+void aws_cross_process_lock_release(struct aws_cross_process_lock *instance_lock);
+
+AWS_EXTERN_C_END
+
+#endif /* AWS_COMMON_CROSS_PROCESS_LOCK_H */
diff --git a/include/aws/common/date_time.h b/include/aws/common/date_time.h
new file mode 100644
index 0000000000000000000000000000000000000000..72ca09a86beb4c83f056191cf076661f041e991c
--- /dev/null
+++ b/include/aws/common/date_time.h
@@ -0,0 +1,167 @@
+#ifndef AWS_COMMON_DATE_TIME_H
+#define AWS_COMMON_DATE_TIME_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+enum {
+ AWS_DATE_TIME_STR_MAX_LEN = 100,
+ AWS_DATE_TIME_STR_MAX_BASIC_LEN = 20,
+};
+
+struct aws_byte_buf;
+struct aws_byte_cursor;
+
+enum aws_date_format {
+ AWS_DATE_FORMAT_RFC822,
+ AWS_DATE_FORMAT_ISO_8601,
+ AWS_DATE_FORMAT_ISO_8601_BASIC,
+ AWS_DATE_FORMAT_AUTO_DETECT,
+};
+
+enum aws_date_month {
+ AWS_DATE_MONTH_JANUARY = 0,
+ AWS_DATE_MONTH_FEBRUARY,
+ AWS_DATE_MONTH_MARCH,
+ AWS_DATE_MONTH_APRIL,
+ AWS_DATE_MONTH_MAY,
+ AWS_DATE_MONTH_JUNE,
+ AWS_DATE_MONTH_JULY,
+ AWS_DATE_MONTH_AUGUST,
+ AWS_DATE_MONTH_SEPTEMBER,
+ AWS_DATE_MONTH_OCTOBER,
+ AWS_DATE_MONTH_NOVEMBER,
+ AWS_DATE_MONTH_DECEMBER,
+};
+
+enum aws_date_day_of_week {
+ AWS_DATE_DAY_OF_WEEK_SUNDAY = 0,
+ AWS_DATE_DAY_OF_WEEK_MONDAY,
+ AWS_DATE_DAY_OF_WEEK_TUESDAY,
+ AWS_DATE_DAY_OF_WEEK_WEDNESDAY,
+ AWS_DATE_DAY_OF_WEEK_THURSDAY,
+ AWS_DATE_DAY_OF_WEEK_FRIDAY,
+ AWS_DATE_DAY_OF_WEEK_SATURDAY,
+};
+
+struct aws_date_time {
+ time_t timestamp;
+ uint16_t milliseconds;
+ char tz[6];
+ struct tm gmt_time;
+ struct tm local_time;
+ bool utc_assumed;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes dt to be the current system time.
+ */
+AWS_COMMON_API void aws_date_time_init_now(struct aws_date_time *dt);
+
+/**
+ * Initializes dt to be the time represented in milliseconds since unix epoch.
+ */
+AWS_COMMON_API void aws_date_time_init_epoch_millis(struct aws_date_time *dt, uint64_t ms_since_epoch);
+
+/**
+ * Initializes dt to be the time represented in seconds.millis since unix epoch.
+ */
+AWS_COMMON_API void aws_date_time_init_epoch_secs(struct aws_date_time *dt, double sec_ms);
+
+/**
+ * Initializes dt to be the time represented by date_str in format 'fmt'. Returns AWS_OP_SUCCESS if the
+ * string was successfully parsed, returns AWS_OP_ERR if parsing failed.
+ *
+ * The parser is lenient regarding AWS_DATE_FORMAT_ISO_8601 vs AWS_DATE_FORMAT_ISO_8601_BASIC.
+ * Regardless of which you pass in, both "2002-10-02T08:05:09Z" and "20021002T080509Z" would be accepted.
+ *
+ * Notes for AWS_DATE_FORMAT_RFC822:
+ * If no time zone information is provided, it is assumed to be local time (please don't do this).
+ *
+ * Only time zones indicating Universal Time (e.g. Z, UT, UTC, or GMT),
+ * or offsets from UTC (e.g. +0100, -0700), are accepted.
+ *
+ * Really, it's just better if you always use Universal Time.
+ */
+AWS_COMMON_API int aws_date_time_init_from_str(
+ struct aws_date_time *dt,
+ const struct aws_byte_buf *date_str,
+ enum aws_date_format fmt);
+
+/**
+ * aws_date_time_init variant that takes a byte_cursor rather than a byte_buf
+ */
+AWS_COMMON_API int aws_date_time_init_from_str_cursor(
+ struct aws_date_time *dt,
+ const struct aws_byte_cursor *date_str_cursor,
+ enum aws_date_format fmt);
+
+/**
+ * Copies the current time as a formatted date string in local time into output_buf. If buffer is too small, it will
+ * return AWS_OP_ERR. A good size suggestion is AWS_DATE_TIME_STR_MAX_LEN bytes. AWS_DATE_FORMAT_AUTO_DETECT is not
+ * allowed.
+ */
+AWS_COMMON_API int aws_date_time_to_local_time_str(
+ const struct aws_date_time *dt,
+ enum aws_date_format fmt,
+ struct aws_byte_buf *output_buf);
+
+/**
+ * Copies the current time as a formatted date string in utc time into output_buf. If buffer is too small, it will
+ * return AWS_OP_ERR. A good size suggestion is AWS_DATE_TIME_STR_MAX_LEN bytes. AWS_DATE_FORMAT_AUTO_DETECT is not
+ * allowed.
+ */
+AWS_COMMON_API int aws_date_time_to_utc_time_str(
+ const struct aws_date_time *dt,
+ enum aws_date_format fmt,
+ struct aws_byte_buf *output_buf);
+
+/**
+ * Copies the current time as a formatted short date string in local time into output_buf. If buffer is too small, it
+ * will return AWS_OP_ERR. A good size suggestion is AWS_DATE_TIME_STR_MAX_LEN bytes. AWS_DATE_FORMAT_AUTO_DETECT is not
+ * allowed.
+ */
+AWS_COMMON_API int aws_date_time_to_local_time_short_str(
+ const struct aws_date_time *dt,
+ enum aws_date_format fmt,
+ struct aws_byte_buf *output_buf);
+
+/**
+ * Copies the current time as a formatted short date string in utc time into output_buf. If buffer is too small, it will
+ * return AWS_OP_ERR. A good size suggestion is AWS_DATE_TIME_STR_MAX_LEN bytes. AWS_DATE_FORMAT_AUTO_DETECT is not
+ * allowed.
+ */
+AWS_COMMON_API int aws_date_time_to_utc_time_short_str(
+ const struct aws_date_time *dt,
+ enum aws_date_format fmt,
+ struct aws_byte_buf *output_buf);
+
+AWS_COMMON_API double aws_date_time_as_epoch_secs(const struct aws_date_time *dt);
+AWS_COMMON_API uint64_t aws_date_time_as_nanos(const struct aws_date_time *dt);
+AWS_COMMON_API uint64_t aws_date_time_as_millis(const struct aws_date_time *dt);
+AWS_COMMON_API uint16_t aws_date_time_year(const struct aws_date_time *dt, bool local_time);
+AWS_COMMON_API enum aws_date_month aws_date_time_month(const struct aws_date_time *dt, bool local_time);
+AWS_COMMON_API uint8_t aws_date_time_month_day(const struct aws_date_time *dt, bool local_time);
+AWS_COMMON_API enum aws_date_day_of_week aws_date_time_day_of_week(const struct aws_date_time *dt, bool local_time);
+AWS_COMMON_API uint8_t aws_date_time_hour(const struct aws_date_time *dt, bool local_time);
+AWS_COMMON_API uint8_t aws_date_time_minute(const struct aws_date_time *dt, bool local_time);
+AWS_COMMON_API uint8_t aws_date_time_second(const struct aws_date_time *dt, bool local_time);
+AWS_COMMON_API bool aws_date_time_dst(const struct aws_date_time *dt, bool local_time);
+
+/**
+ * returns the difference of a and b (a - b) in seconds.
+ */
+AWS_COMMON_API time_t aws_date_time_diff(const struct aws_date_time *a, const struct aws_date_time *b);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_DATE_TIME_H */
diff --git a/include/aws/common/device_random.h b/include/aws/common/device_random.h
new file mode 100644
index 0000000000000000000000000000000000000000..6336f635d2f205e623cecf1970ae82c8ce13b0dc
--- /dev/null
+++ b/include/aws/common/device_random.h
@@ -0,0 +1,50 @@
+#ifndef AWS_COMMON_DEVICE_RANDOM_H
+#define AWS_COMMON_DEVICE_RANDOM_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_byte_buf;
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Get an unpredictably random 64bit number, suitable for cryptographic use.
+ */
+AWS_COMMON_API int aws_device_random_u64(uint64_t *output);
+
+/**
+ * Get an unpredictably random 32bit number, suitable for cryptographic use.
+ */
+AWS_COMMON_API int aws_device_random_u32(uint32_t *output);
+
+/**
+ * Get an unpredictably random 16bit number, suitable for cryptographic use.
+ */
+AWS_COMMON_API int aws_device_random_u16(uint16_t *output);
+
+/**
+ * Get an unpredictably random 8bit number, suitable for cryptographic use.
+ */
+AWS_COMMON_API int aws_device_random_u8(uint8_t *output);
+
+/**
+ * Fill the rest of a buffer with unpredictably random bytes, suitable for cryptographic use.
+ */
+AWS_COMMON_API int aws_device_random_buffer(struct aws_byte_buf *output);
+
+/**
+ * Write N unpredictably random bytes to a buffer, suitable for cryptographic use.
+ * If there is insufficient space in the buffer, AWS_ERROR_SHORT_BUFFER is raised
+ * and the buffer will be unchanged.
+ */
+AWS_COMMON_API int aws_device_random_buffer_append(struct aws_byte_buf *output, size_t n);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_DEVICE_RANDOM_H */
diff --git a/include/aws/common/encoding.h b/include/aws/common/encoding.h
new file mode 100644
index 0000000000000000000000000000000000000000..fef3de71dbacd9e1241c62e7e635cb765fa56d13
--- /dev/null
+++ b/include/aws/common/encoding.h
@@ -0,0 +1,235 @@
+#ifndef AWS_COMMON_ENCODING_H
+#define AWS_COMMON_ENCODING_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+#include
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+AWS_EXTERN_C_BEGIN
+
+/*
+ * computes the length necessary to store the result of aws_hex_encode().
+ * returns -1 on failure, and 0 on success. encoded_length will be set on
+ * success.
+ */
+AWS_COMMON_API
+int aws_hex_compute_encoded_len(size_t to_encode_len, size_t *encoded_length);
+
+/*
+ * Base 16 (hex) encodes the contents of to_encode and stores the result in
+ * output. Assumes the buffer is empty and does not resize on
+ * insufficient capacity.
+ */
+AWS_COMMON_API
+int aws_hex_encode(const struct aws_byte_cursor *AWS_RESTRICT to_encode, struct aws_byte_buf *AWS_RESTRICT output);
+
+/*
+ * Base 16 (hex) encodes the contents of to_encode and appends the result in
+ * output. Grows the destination buffer dynamically if necessary.
+ */
+AWS_COMMON_API
+int aws_hex_encode_append_dynamic(
+ const struct aws_byte_cursor *AWS_RESTRICT to_encode,
+ struct aws_byte_buf *AWS_RESTRICT output);
+
+/*
+ * computes the length necessary to store the result of aws_hex_decode().
+ * returns -1 on failure, and 0 on success. decoded_len will be set on success.
+ */
+AWS_COMMON_API
+int aws_hex_compute_decoded_len(size_t to_decode_len, size_t *decoded_len);
+
+/*
+ * Base 16 (hex) decodes the contents of to_decode and stores the result in
+ * output. If output is NULL, output_size will be set to what the output_size
+ * should be.
+ */
+AWS_COMMON_API
+int aws_hex_decode(const struct aws_byte_cursor *AWS_RESTRICT to_decode, struct aws_byte_buf *AWS_RESTRICT output);
+
+/*
+ * Computes the length necessary to store the output of aws_base64_encode call.
+ * returns -1 on failure, and 0 on success. encoded_length will be set on
+ * success.
+ */
+AWS_COMMON_API
+int aws_base64_compute_encoded_len(size_t to_encode_len, size_t *encoded_len);
+
+/*
+ * Base 64 encodes the contents of to_encode and stores the result in output.
+ */
+AWS_COMMON_API
+int aws_base64_encode(const struct aws_byte_cursor *AWS_RESTRICT to_encode, struct aws_byte_buf *AWS_RESTRICT output);
+
+/*
+ * Computes the length necessary to store the output of aws_base64_decode call.
+ * returns -1 on failure, and 0 on success. decoded_len will be set on success.
+ */
+AWS_COMMON_API
+int aws_base64_compute_decoded_len(const struct aws_byte_cursor *AWS_RESTRICT to_decode, size_t *decoded_len);
+
+/*
+ * Base 64 decodes the contents of to_decode and stores the result in output.
+ */
+AWS_COMMON_API
+int aws_base64_decode(const struct aws_byte_cursor *AWS_RESTRICT to_decode, struct aws_byte_buf *AWS_RESTRICT output);
+
+/* Add a 64 bit unsigned integer to the buffer, ensuring network - byte order
+ * Assumes the buffer size is at least 8 bytes.
+ */
+AWS_STATIC_IMPL void aws_write_u64(uint64_t value, uint8_t *buffer);
+
+/*
+ * Extracts a 64 bit unsigned integer from buffer. Ensures conversion from
+ * network byte order to host byte order. Assumes buffer size is at least 8
+ * bytes.
+ */
+AWS_STATIC_IMPL uint64_t aws_read_u64(const uint8_t *buffer);
+
+/* Add a 32 bit unsigned integer to the buffer, ensuring network - byte order
+ * Assumes the buffer size is at least 4 bytes.
+ */
+AWS_STATIC_IMPL void aws_write_u32(uint32_t value, uint8_t *buffer);
+
+/*
+ * Extracts a 32 bit unsigned integer from buffer. Ensures conversion from
+ * network byte order to host byte order. Assumes the buffer size is at least 4
+ * bytes.
+ */
+AWS_STATIC_IMPL uint32_t aws_read_u32(const uint8_t *buffer);
+
+/* Add a 24 bit unsigned integer to the buffer, ensuring network - byte order
+ * return the new position in the buffer for the next operation.
+ * Note, since this uses uint32_t for storage, the 3 least significant bytes
+ * will be used. Assumes buffer is at least 3 bytes long.
+ */
+AWS_STATIC_IMPL void aws_write_u24(uint32_t value, uint8_t *buffer);
+/*
+ * Extracts a 24 bit unsigned integer from buffer. Ensures conversion from
+ * network byte order to host byte order. Assumes buffer is at least 3 bytes
+ * long.
+ */
+AWS_STATIC_IMPL uint32_t aws_read_u24(const uint8_t *buffer);
+
+/* Add a 16 bit unsigned integer to the buffer, ensuring network-byte order
+ * return the new position in the buffer for the next operation.
+ * Assumes buffer is at least 2 bytes long.
+ */
+AWS_STATIC_IMPL void aws_write_u16(uint16_t value, uint8_t *buffer);
+/*
+ * Extracts a 16 bit unsigned integer from buffer. Ensures conversion from
+ * network byte order to host byte order. Assumes buffer is at least 2 bytes
+ * long.
+ */
+AWS_STATIC_IMPL uint16_t aws_read_u16(const uint8_t *buffer);
+
+enum aws_text_encoding {
+ AWS_TEXT_UNKNOWN,
+ AWS_TEXT_UTF8,
+ AWS_TEXT_UTF16,
+ AWS_TEXT_UTF32,
+ AWS_TEXT_ASCII,
+};
+
+/* Checks the BOM in the buffer to see if encoding can be determined. If there is no BOM or
+ * it is unrecognizable, then AWS_TEXT_UNKNOWN will be returned.
+ */
+AWS_STATIC_IMPL enum aws_text_encoding aws_text_detect_encoding(const uint8_t *bytes, size_t size);
+
+/*
+ * Returns true if aws_text_detect_encoding() determines the text is UTF8 or ASCII.
+ * Note that this immediately returns true if the UTF8 BOM is seen.
+ * To fully validate every byte, use aws_decode_utf8().
+ */
+AWS_STATIC_IMPL bool aws_text_is_utf8(const uint8_t *bytes, size_t size);
+
+struct aws_utf8_decoder_options {
+ /**
+ * Optional.
+ * Callback invoked for each Unicode codepoint.
+ * Use this callback to store codepoints as they're decoded,
+ * or to perform additional validation. RFC-3629 is already enforced,
+ * which forbids codepoints between U+D800 and U+DFFF,
+ * but you may whish to forbid codepoints like U+0000.
+ *
+ * @return AWS_OP_SUCCESS to continue processing the string, otherwise
+ * return AWS_OP_ERROR and raise an error (i.e. AWS_ERROR_INVALID_UTF8)
+ * to stop processing the string and report failure.
+ */
+ int (*on_codepoint)(uint32_t codepoint, void *user_data);
+
+ /* Optional. Pointer passed to on_codepoint callback. */
+ void *user_data;
+};
+
+/**
+ * Decode a complete string of UTF8/ASCII text.
+ * Text is always validated according to RFC-3629 (you may perform additional
+ * validation in the on_codepoint callback).
+ * The text does not need to begin with a UTF8 BOM.
+ * If you need to decode text incrementally as you receive it, use aws_utf8_decoder_new() instead.
+ *
+ * @param bytes Text to decode.
+ * @param options Options for decoding. If NULL is passed, the text is simply validated.
+ *
+ * @return AWS_OP_SUCCESS if successful.
+ * An error is raised if the text is not valid, or the on_codepoint callback raises an error.
+ */
+AWS_COMMON_API int aws_decode_utf8(struct aws_byte_cursor bytes, const struct aws_utf8_decoder_options *options);
+
+struct aws_utf8_decoder;
+
+/**
+ * Create a UTF8/ASCII decoder, which can process text incrementally as you receive it.
+ * Text is always validated according to RFC-3629 (you may perform additional
+ * validation in the on_codepoint callback).
+ * The text does not need to begin with a UTF8 BOM.
+ * To decode text all at once, simply use aws_decode_utf8().
+ *
+ * Feed bytes into the decoder with aws_utf8_decoder_update(),
+ * and call aws_utf8_decoder_finalize() when the text is complete.
+ *
+ * @param allocator Allocator
+ * @param options Options for decoder. If NULL is passed, the text is simply validated.
+ */
+AWS_COMMON_API struct aws_utf8_decoder *aws_utf8_decoder_new(
+ struct aws_allocator *allocator,
+ const struct aws_utf8_decoder_options *options);
+
+AWS_COMMON_API void aws_utf8_decoder_destroy(struct aws_utf8_decoder *decoder);
+AWS_COMMON_API void aws_utf8_decoder_reset(struct aws_utf8_decoder *decoder);
+
+/**
+ * Update the decoder with more bytes of text.
+ * The on_codepoint callback will be invoked for each codepoint encountered.
+ * Raises an error if invalid UTF8 is encountered or the on_codepoint callback reports an error.
+ *
+ * Note: You must call aws_utf8_decoder_finalize() when the text is 100% complete,
+ * to ensure the input was completely valid.
+ */
+AWS_COMMON_API int aws_utf8_decoder_update(struct aws_utf8_decoder *decoder, struct aws_byte_cursor bytes);
+
+/**
+ * Tell the decoder that you've reached the end of your text.
+ * Raises AWS_ERROR_INVALID_UTF8 if the text did not end with a complete UTF8 codepoint.
+ * This also resets the decoder.
+ */
+AWS_COMMON_API int aws_utf8_decoder_finalize(struct aws_utf8_decoder *decoder);
+
+AWS_EXTERN_C_END
+
+#ifndef AWS_NO_STATIC_IMPL
+# include
+#endif /* AWS_NO_STATIC_IMPL */
+
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_ENCODING_H */
diff --git a/include/aws/common/encoding.inl b/include/aws/common/encoding.inl
new file mode 100644
index 0000000000000000000000000000000000000000..6f3e2fef07426784b17a2d910b3f133723939554
--- /dev/null
+++ b/include/aws/common/encoding.inl
@@ -0,0 +1,142 @@
+#ifndef AWS_COMMON_ENCODING_INL
+#define AWS_COMMON_ENCODING_INL
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+#include
+#include
+
+AWS_EXTERN_C_BEGIN
+
+/* Add a 64 bit unsigned integer to the buffer, ensuring network - byte order
+ * Assumes the buffer size is at least 8 bytes.
+ */
+AWS_STATIC_IMPL void aws_write_u64(uint64_t value, uint8_t *buffer) {
+ value = aws_hton64(value);
+
+ memcpy((void *)buffer, &value, sizeof(value));
+}
+
+/*
+ * Extracts a 64 bit unsigned integer from buffer. Ensures conversion from
+ * network byte order to host byte order. Assumes buffer size is at least 8
+ * bytes.
+ */
+AWS_STATIC_IMPL uint64_t aws_read_u64(const uint8_t *buffer) {
+ uint64_t value = 0;
+ memcpy((void *)&value, (void *)buffer, sizeof(value));
+
+ return aws_ntoh64(value);
+}
+
+/* Add a 32 bit unsigned integer to the buffer, ensuring network - byte order
+ * Assumes the buffer size is at least 4 bytes.
+ */
+AWS_STATIC_IMPL void aws_write_u32(uint32_t value, uint8_t *buffer) {
+ value = aws_hton32(value);
+
+ memcpy((void *)buffer, (void *)&value, sizeof(value));
+}
+
+/*
+ * Extracts a 32 bit unsigned integer from buffer. Ensures conversion from
+ * network byte order to host byte order. Assumes the buffer size is at least 4
+ * bytes.
+ */
+AWS_STATIC_IMPL uint32_t aws_read_u32(const uint8_t *buffer) {
+ uint32_t value = 0;
+ memcpy((void *)&value, (void *)buffer, sizeof(value));
+
+ return aws_ntoh32(value);
+}
+
+/* Add a 24 bit unsigned integer to the buffer, ensuring network - byte order
+ * return the new position in the buffer for the next operation.
+ * Note, since this uses uint32_t for storage, the 3 least significant bytes
+ * will be used. Assumes buffer is at least 3 bytes long.
+ */
+AWS_STATIC_IMPL void aws_write_u24(uint32_t value, uint8_t *buffer) {
+ value = aws_hton32(value);
+ memcpy((void *)buffer, (void *)((uint8_t *)&value + 1), sizeof(value) - 1);
+}
+
+/*
+ * Extracts a 24 bit unsigned integer from buffer. Ensures conversion from
+ * network byte order to host byte order. Assumes buffer is at least 3 bytes
+ * long.
+ */
+AWS_STATIC_IMPL uint32_t aws_read_u24(const uint8_t *buffer) {
+ uint32_t value = 0;
+ memcpy((void *)((uint8_t *)&value + 1), (void *)buffer, sizeof(value) - 1);
+
+ return aws_ntoh32(value);
+}
+
+/* Add a 16 bit unsigned integer to the buffer, ensuring network-byte order
+ * return the new position in the buffer for the next operation.
+ * Assumes buffer is at least 2 bytes long.
+ */
+AWS_STATIC_IMPL void aws_write_u16(uint16_t value, uint8_t *buffer) {
+ value = aws_hton16(value);
+
+ memcpy((void *)buffer, (void *)&value, sizeof(value));
+}
+
+/*
+ * Extracts a 16 bit unsigned integer from buffer. Ensures conversion from
+ * network byte order to host byte order. Assumes buffer is at least 2 bytes
+ * long.
+ */
+AWS_STATIC_IMPL uint16_t aws_read_u16(const uint8_t *buffer) {
+ uint16_t value = 0;
+ memcpy((void *)&value, (void *)buffer, sizeof(value));
+
+ return aws_ntoh16(value);
+}
+
+/* Reference: https://unicodebook.readthedocs.io/guess_encoding.html */
+AWS_STATIC_IMPL enum aws_text_encoding aws_text_detect_encoding(const uint8_t *bytes, size_t size) {
+ static const char *UTF_8_BOM = "\xEF\xBB\xBF";
+ static const char *UTF_16_BE_BOM = "\xFE\xFF";
+ static const char *UTF_16_LE_BOM = "\xFF\xFE";
+ static const char *UTF_32_BE_BOM = "\x00\x00\xFE\xFF";
+ static const char *UTF_32_LE_BOM = "\xFF\xFE\x00\x00";
+
+ if (size >= 3) {
+ if (memcmp(bytes, UTF_8_BOM, 3) == 0)
+ return AWS_TEXT_UTF8;
+ }
+ if (size >= 4) {
+ if (memcmp(bytes, UTF_32_LE_BOM, 4) == 0)
+ return AWS_TEXT_UTF32;
+ if (memcmp(bytes, UTF_32_BE_BOM, 4) == 0)
+ return AWS_TEXT_UTF32;
+ }
+ if (size >= 2) {
+ if (memcmp(bytes, UTF_16_LE_BOM, 2) == 0)
+ return AWS_TEXT_UTF16;
+ if (memcmp(bytes, UTF_16_BE_BOM, 2) == 0)
+ return AWS_TEXT_UTF16;
+ }
+ size_t idx = 0;
+ for (; idx < size; ++idx) {
+ if (bytes[idx] & 0x80) {
+ return AWS_TEXT_UNKNOWN;
+ }
+ }
+ return AWS_TEXT_ASCII;
+}
+
+AWS_STATIC_IMPL bool aws_text_is_utf8(const uint8_t *bytes, size_t size) {
+ enum aws_text_encoding encoding = aws_text_detect_encoding(bytes, size);
+ return encoding == AWS_TEXT_UTF8 || encoding == AWS_TEXT_ASCII;
+}
+
+AWS_EXTERN_C_END
+
+#endif /* AWS_COMMON_ENCODING_INL */
diff --git a/include/aws/common/environment.h b/include/aws/common/environment.h
new file mode 100644
index 0000000000000000000000000000000000000000..2958e515438f38690ae7f7de1a5e995c4f71a738
--- /dev/null
+++ b/include/aws/common/environment.h
@@ -0,0 +1,65 @@
+#ifndef AWS_COMMON_ENVIRONMENT_H
+#define AWS_COMMON_ENVIRONMENT_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_string;
+
+/*
+ * Simple shims to the appropriate platform calls for environment variable manipulation.
+ *
+ * Not thread safe to use set/unset unsynced with get. Set/unset only used in unit tests.
+ */
+AWS_EXTERN_C_BEGIN
+
+/*
+ * Get the value of an environment variable. If the variable is not set, the output string will be set to NULL.
+ * Not thread-safe
+ */
+AWS_COMMON_API
+struct aws_string *aws_get_env(struct aws_allocator *allocator, const char *name);
+
+/*
+ * Get the value of an environment variable. If the variable is not set or is empty, the output string will be set to
+ * NULL. Not thread-safe
+ */
+AWS_COMMON_API
+struct aws_string *aws_get_env_nonempty(struct aws_allocator *allocator, const char *name);
+
+/*
+ * *DEPRECATED*
+ * Please use the `aws_get_env` or `aws_get_env_nonempty` instead.
+ * Get the value of an environment variable. If the variable is not set, the output string will be set to NULL.
+ * Not thread-safe
+ */
+AWS_COMMON_API
+int aws_get_environment_value(
+ struct aws_allocator *allocator,
+ const struct aws_string *variable_name,
+ struct aws_string **value_out);
+
+/*
+ * Set the value of an environment variable. On Windows, setting a variable to the empty string will actually unset it.
+ * Not thread-safe
+ */
+AWS_COMMON_API
+int aws_set_environment_value(const struct aws_string *variable_name, const struct aws_string *value);
+
+/*
+ * Unset an environment variable.
+ * Not thread-safe
+ */
+AWS_COMMON_API
+int aws_unset_environment_value(const struct aws_string *variable_name);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_ENVIRONMENT_H */
diff --git a/include/aws/common/error.h b/include/aws/common/error.h
new file mode 100644
index 0000000000000000000000000000000000000000..b8ecdc88b8e8fa1460abc4d76bca6abbe8c8d57f
--- /dev/null
+++ b/include/aws/common/error.h
@@ -0,0 +1,225 @@
+#ifndef AWS_COMMON_ERROR_H
+#define AWS_COMMON_ERROR_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+#define AWS_OP_SUCCESS (0)
+#define AWS_OP_ERR (-1)
+
+/* Each library gets space for 2^^10 error entries */
+#define AWS_ERROR_ENUM_STRIDE_BITS 10
+#define AWS_ERROR_ENUM_STRIDE (1U << AWS_ERROR_ENUM_STRIDE_BITS)
+#define AWS_ERROR_ENUM_BEGIN_RANGE(x) ((x) * AWS_ERROR_ENUM_STRIDE)
+#define AWS_ERROR_ENUM_END_RANGE(x) (((x) + 1) * AWS_ERROR_ENUM_STRIDE - 1)
+
+struct aws_error_info {
+ int error_code;
+ const char *literal_name;
+ const char *error_str;
+ const char *lib_name;
+ const char *formatted_name;
+};
+
+struct aws_error_info_list {
+ const struct aws_error_info *error_list;
+ uint16_t count;
+};
+
+#define AWS_DEFINE_ERROR_INFO(C, ES, LN) \
+ { \
+ .literal_name = #C, \
+ .error_code = (C), \
+ .error_str = (ES), \
+ .lib_name = (LN), \
+ .formatted_name = LN ": " #C ", " ES, \
+ }
+
+typedef void(aws_error_handler_fn)(int err, void *ctx);
+
+AWS_EXTERN_C_BEGIN
+
+/*
+ * Returns the latest error code on the current thread, or 0 if none have
+ * occurred.
+ */
+AWS_COMMON_API
+int aws_last_error(void);
+
+/*
+ * Returns the error str corresponding to `err`.
+ */
+AWS_COMMON_API
+const char *aws_error_str(int err);
+
+/*
+ * Returns the enum name corresponding to `err`.
+ */
+AWS_COMMON_API
+const char *aws_error_name(int err);
+
+/*
+ * Returns the error lib name corresponding to `err`.
+ */
+AWS_COMMON_API
+const char *aws_error_lib_name(int err);
+
+/*
+ * Returns libname concatenated with error string.
+ */
+AWS_COMMON_API
+const char *aws_error_debug_str(int err);
+
+/*
+ * Internal implementation detail.
+ */
+AWS_COMMON_API
+void aws_raise_error_private(int err);
+
+/*
+ * Raises `err` to the installed callbacks, and sets the thread's error.
+ */
+AWS_STATIC_IMPL
+int aws_raise_error(int err);
+
+/*
+ * Resets the `err` back to defaults
+ */
+AWS_COMMON_API
+void aws_reset_error(void);
+/*
+ * Sets `err` to the latest error. Does not invoke callbacks.
+ */
+AWS_COMMON_API
+void aws_restore_error(int err);
+
+/*
+ * Sets an application wide error handler function. This will be overridden by
+ * the thread local handler. The previous handler is returned, this can be used
+ * for restoring an error handler if it needs to be overridden temporarily.
+ * Setting this to NULL will turn off this error callback after it has been
+ * enabled.
+ */
+AWS_COMMON_API
+aws_error_handler_fn *aws_set_global_error_handler_fn(aws_error_handler_fn *handler, void *ctx);
+
+/*
+ * Sets a thread-local error handler function. This will override the global
+ * handler. The previous handler is returned, this can be used for restoring an
+ * error handler if it needs to be overridden temporarily. Setting this to NULL
+ * will turn off this error callback after it has been enabled.
+ */
+AWS_COMMON_API
+aws_error_handler_fn *aws_set_thread_local_error_handler_fn(aws_error_handler_fn *handler, void *ctx);
+
+/** TODO: this needs to be a private function (wait till we have the cmake story
+ * better before moving it though). It should be external for the purpose of
+ * other libs we own, but customers should not be able to hit it without going
+ * out of their way to do so.
+ */
+AWS_COMMON_API
+void aws_register_error_info(const struct aws_error_info_list *error_info);
+
+AWS_COMMON_API
+void aws_unregister_error_info(const struct aws_error_info_list *error_info);
+
+/**
+ * Convert a c library io error into an aws error, and raise it.
+ * If no conversion is found, fallback_aws_error_code is raised.
+ * Always returns AWS_OP_ERR.
+ */
+AWS_COMMON_API
+int aws_translate_and_raise_io_error_or(int error_no, int fallback_aws_error_code);
+
+/**
+ * Convert a c library io error into an aws error, and raise it.
+ * If no conversion is found, AWS_ERROR_SYS_CALL_FAILURE is raised.
+ * Always returns AWS_OP_ERR.
+ */
+AWS_COMMON_API
+int aws_translate_and_raise_io_error(int error_no);
+
+AWS_EXTERN_C_END
+#ifndef AWS_NO_STATIC_IMPL
+# include
+#endif /* AWS_NO_STATIC_IMPL */
+
+enum aws_common_error {
+ AWS_ERROR_SUCCESS = AWS_ERROR_ENUM_BEGIN_RANGE(AWS_C_COMMON_PACKAGE_ID),
+ AWS_ERROR_OOM,
+ AWS_ERROR_NO_SPACE,
+ AWS_ERROR_UNKNOWN,
+ AWS_ERROR_SHORT_BUFFER,
+ AWS_ERROR_OVERFLOW_DETECTED,
+ AWS_ERROR_UNSUPPORTED_OPERATION,
+ AWS_ERROR_INVALID_BUFFER_SIZE,
+ AWS_ERROR_INVALID_HEX_STR,
+ AWS_ERROR_INVALID_BASE64_STR,
+ AWS_ERROR_INVALID_INDEX,
+ AWS_ERROR_THREAD_INVALID_SETTINGS,
+ AWS_ERROR_THREAD_INSUFFICIENT_RESOURCE,
+ AWS_ERROR_THREAD_NO_PERMISSIONS,
+ AWS_ERROR_THREAD_NOT_JOINABLE,
+ AWS_ERROR_THREAD_NO_SUCH_THREAD_ID,
+ AWS_ERROR_THREAD_DEADLOCK_DETECTED,
+ AWS_ERROR_MUTEX_NOT_INIT,
+ AWS_ERROR_MUTEX_TIMEOUT,
+ AWS_ERROR_MUTEX_CALLER_NOT_OWNER,
+ AWS_ERROR_MUTEX_FAILED,
+ AWS_ERROR_COND_VARIABLE_INIT_FAILED,
+ AWS_ERROR_COND_VARIABLE_TIMED_OUT,
+ AWS_ERROR_COND_VARIABLE_ERROR_UNKNOWN,
+ AWS_ERROR_CLOCK_FAILURE,
+ AWS_ERROR_LIST_EMPTY,
+ AWS_ERROR_DEST_COPY_TOO_SMALL,
+ AWS_ERROR_LIST_EXCEEDS_MAX_SIZE,
+ AWS_ERROR_LIST_STATIC_MODE_CANT_SHRINK,
+ AWS_ERROR_PRIORITY_QUEUE_FULL,
+ AWS_ERROR_PRIORITY_QUEUE_EMPTY,
+ AWS_ERROR_PRIORITY_QUEUE_BAD_NODE,
+ AWS_ERROR_HASHTBL_ITEM_NOT_FOUND,
+ AWS_ERROR_INVALID_DATE_STR,
+ AWS_ERROR_INVALID_ARGUMENT,
+ AWS_ERROR_RANDOM_GEN_FAILED,
+ AWS_ERROR_MALFORMED_INPUT_STRING,
+ AWS_ERROR_UNIMPLEMENTED,
+ AWS_ERROR_INVALID_STATE,
+ AWS_ERROR_ENVIRONMENT_GET,
+ AWS_ERROR_ENVIRONMENT_SET,
+ AWS_ERROR_ENVIRONMENT_UNSET,
+ AWS_ERROR_STREAM_UNSEEKABLE,
+ AWS_ERROR_NO_PERMISSION,
+ AWS_ERROR_FILE_INVALID_PATH,
+ AWS_ERROR_MAX_FDS_EXCEEDED,
+ AWS_ERROR_SYS_CALL_FAILURE,
+ AWS_ERROR_C_STRING_BUFFER_NOT_NULL_TERMINATED,
+ AWS_ERROR_STRING_MATCH_NOT_FOUND,
+ AWS_ERROR_DIVIDE_BY_ZERO,
+ AWS_ERROR_INVALID_FILE_HANDLE,
+ AWS_ERROR_OPERATION_INTERUPTED,
+ AWS_ERROR_DIRECTORY_NOT_EMPTY,
+ AWS_ERROR_PLATFORM_NOT_SUPPORTED,
+ AWS_ERROR_INVALID_UTF8,
+ AWS_ERROR_GET_HOME_DIRECTORY_FAILED,
+ AWS_ERROR_INVALID_XML,
+ AWS_ERROR_FILE_OPEN_FAILURE,
+ AWS_ERROR_FILE_READ_FAILURE,
+ AWS_ERROR_FILE_WRITE_FAILURE,
+ AWS_ERROR_INVALID_CBOR,
+ AWS_ERROR_CBOR_UNEXPECTED_TYPE,
+ AWS_ERROR_END_COMMON_RANGE = AWS_ERROR_ENUM_END_RANGE(AWS_C_COMMON_PACKAGE_ID)
+};
+
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_ERROR_H */
diff --git a/include/aws/common/exports.h b/include/aws/common/exports.h
new file mode 100644
index 0000000000000000000000000000000000000000..90f7f174c235ec4323f0d08666b77b9fa0489be2
--- /dev/null
+++ b/include/aws/common/exports.h
@@ -0,0 +1,40 @@
+#ifndef AWS_COMMON_EXPORTS_H
+#define AWS_COMMON_EXPORTS_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#if defined(AWS_CRT_USE_WINDOWS_DLL_SEMANTICS) || defined(_WIN32)
+# ifdef AWS_COMMON_USE_IMPORT_EXPORT
+# ifdef AWS_COMMON_EXPORTS
+# define AWS_COMMON_API __declspec(dllexport)
+# else
+# define AWS_COMMON_API __declspec(dllimport)
+# endif /* AWS_COMMON_EXPORTS */
+# else
+# define AWS_COMMON_API
+# endif /* AWS_COMMON_USE_IMPORT_EXPORT */
+
+#else /* defined (AWS_CRT_USE_WINDOWS_DLL_SEMANTICS) || defined (_WIN32) */
+
+# if defined(AWS_COMMON_USE_IMPORT_EXPORT) && defined(AWS_COMMON_EXPORTS)
+# define AWS_COMMON_API __attribute__((visibility("default")))
+# else
+# define AWS_COMMON_API
+# endif
+
+#endif /* defined (AWS_CRT_USE_WINDOWS_DLL_SEMANTICS) || defined (_WIN32) */
+
+#ifdef AWS_NO_STATIC_IMPL
+# define AWS_STATIC_IMPL AWS_COMMON_API
+#endif
+
+#ifndef AWS_STATIC_IMPL
+/*
+ * In order to allow us to export our inlinable methods in a DLL/.so, we have a designated .c
+ * file where this AWS_STATIC_IMPL macro will be redefined to be non-static.
+ */
+# define AWS_STATIC_IMPL static inline
+#endif
+
+#endif /* AWS_COMMON_EXPORTS_H */
diff --git a/include/aws/common/fifo_cache.h b/include/aws/common/fifo_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..44127aa652e5689992a608ba899ca42632721b2c
--- /dev/null
+++ b/include/aws/common/fifo_cache.h
@@ -0,0 +1,31 @@
+#ifndef AWS_COMMON_FIFO_CACHE_H
+#define AWS_COMMON_FIFO_CACHE_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes the first-in-first-out cache. Sets up the underlying linked hash table.
+ * Once `max_items` elements have been added, the oldest(first-in) item will
+ * be removed. For the other parameters, see aws/common/hash_table.h. Hash table
+ * semantics of these arguments are preserved.
+ */
+AWS_COMMON_API
+struct aws_cache *aws_cache_new_fifo(
+ struct aws_allocator *allocator,
+ aws_hash_fn *hash_fn,
+ aws_hash_callback_eq_fn *equals_fn,
+ aws_hash_callback_destroy_fn *destroy_key_fn,
+ aws_hash_callback_destroy_fn *destroy_value_fn,
+ size_t max_items);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_FIFO_CACHE_H */
diff --git a/include/aws/common/file.h b/include/aws/common/file.h
new file mode 100644
index 0000000000000000000000000000000000000000..23937e866ad4df1264cda0707b32a465637c12a2
--- /dev/null
+++ b/include/aws/common/file.h
@@ -0,0 +1,213 @@
+#ifndef AWS_COMMON_FILE_H
+#define AWS_COMMON_FILE_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+#include
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+#ifdef AWS_OS_WINDOWS
+# define AWS_PATH_DELIM '\\'
+# define AWS_PATH_DELIM_STR "\\"
+#else
+# define AWS_PATH_DELIM '/'
+# define AWS_PATH_DELIM_STR "/"
+#endif
+
+struct aws_string;
+struct aws_directory_iterator;
+
+enum aws_file_type {
+ AWS_FILE_TYPE_FILE = 1,
+ AWS_FILE_TYPE_SYM_LINK = 2,
+ AWS_FILE_TYPE_DIRECTORY = 4,
+};
+
+struct aws_directory_entry {
+ /**
+ * Absolute path to the entry from the current process root.
+ */
+ struct aws_byte_cursor path;
+ /**
+ * Path to the entry relative to the current working directory.
+ */
+ struct aws_byte_cursor relative_path;
+ /**
+ * Bit-field of enum aws_file_type
+ */
+ int file_type;
+ /**
+ * Size of the file on disk.
+ */
+ int64_t file_size;
+};
+
+/**
+ * Invoked during calls to aws_directory_traverse() as an entry is encountered. entry will contain
+ * the parsed directory entry info.
+ *
+ * Return true to continue the traversal, or alternatively, if you have a reason to abort the traversal, return false.
+ */
+typedef bool(aws_on_directory_entry)(const struct aws_directory_entry *entry, void *user_data);
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Deprecated - Use aws_fopen_safe() instead, avoid const char * in public APIs.
+ * Opens file at file_path using mode. Returns the FILE pointer if successful.
+ * Otherwise, aws_last_error() will contain the error that occurred
+ */
+AWS_COMMON_API FILE *aws_fopen(const char *file_path, const char *mode);
+
+/**
+ * Opens file at file_path using mode. Returns the FILE pointer if successful.
+ * Otherwise, aws_last_error() will contain the error that occurred
+ */
+AWS_COMMON_API FILE *aws_fopen_safe(const struct aws_string *file_path, const struct aws_string *mode);
+
+/**
+ * Creates a directory if it doesn't currently exist. If the directory already exists, it's ignored and assumed
+ * successful.
+ *
+ * Returns AWS_OP_SUCCESS on success. Otherwise, check aws_last_error().
+ */
+AWS_COMMON_API int aws_directory_create(const struct aws_string *dir_path);
+/**
+ * Returns true if the directory currently exists. Otherwise, it returns false.
+ */
+AWS_COMMON_API bool aws_directory_exists(const struct aws_string *dir_path);
+/**
+ * Deletes a directory. If the directory is not empty, this will fail unless the recursive parameter is set to true.
+ * If recursive is true then the entire directory and all of its contents will be deleted. If it is set to false,
+ * the directory will be deleted only if it is empty. Returns AWS_OP_SUCCESS if the operation was successful. Otherwise,
+ * aws_last_error() will contain the error that occurred. If the directory doesn't exist, AWS_OP_SUCCESS is still
+ * returned.
+ */
+AWS_COMMON_API int aws_directory_delete(const struct aws_string *dir_path, bool recursive);
+/**
+ * Deletes a file. Returns AWS_OP_SUCCESS if the operation was successful. Otherwise,
+ * aws_last_error() will contain the error that occurred. If the file doesn't exist, AWS_OP_SUCCESS is still returned.
+ */
+AWS_COMMON_API int aws_file_delete(const struct aws_string *file_path);
+
+/**
+ * Moves directory at from to to.
+ * Returns AWS_OP_SUCCESS if the operation was successful. Otherwise,
+ * aws_last_error() will contain the error that occurred.
+ */
+AWS_COMMON_API int aws_directory_or_file_move(const struct aws_string *from, const struct aws_string *to);
+
+/**
+ * Traverse a directory starting at path.
+ *
+ * If you want the traversal to recurse the entire directory, pass recursive as true. Passing false for this parameter
+ * will only iterate the contents of the directory, but will not descend into any directories it encounters.
+ *
+ * If recursive is set to true, the traversal is performed post-order, depth-first
+ * (for practical reasons such as deleting a directory that contains subdirectories or files).
+ *
+ * returns AWS_OP_SUCCESS(0) on success.
+ */
+AWS_COMMON_API int aws_directory_traverse(
+ struct aws_allocator *allocator,
+ const struct aws_string *path,
+ bool recursive,
+ aws_on_directory_entry *on_entry,
+ void *user_data);
+
+/**
+ * Creates a read-only iterator of a directory starting at path. If path is invalid or there's any other error
+ * condition, NULL will be returned. Call aws_last_error() for the exact error in that case.
+ */
+AWS_COMMON_API struct aws_directory_iterator *aws_directory_entry_iterator_new(
+ struct aws_allocator *allocator,
+ const struct aws_string *path);
+
+/**
+ * Moves the iterator to the next entry. Returns AWS_OP_SUCCESS if another entry is available, or AWS_OP_ERR with
+ * AWS_ERROR_LIST_EMPTY as the value for aws_last_error() if no more entries are available.
+ */
+AWS_COMMON_API int aws_directory_entry_iterator_next(struct aws_directory_iterator *iterator);
+
+/**
+ * Moves the iterator to the previous entry. Returns AWS_OP_SUCCESS if another entry is available, or AWS_OP_ERR with
+ * AWS_ERROR_LIST_EMPTY as the value for aws_last_error() if no more entries are available.
+ */
+AWS_COMMON_API int aws_directory_entry_iterator_previous(struct aws_directory_iterator *iterator);
+
+/**
+ * Cleanup and deallocate iterator
+ */
+AWS_COMMON_API void aws_directory_entry_iterator_destroy(struct aws_directory_iterator *iterator);
+
+/**
+ * Gets the aws_directory_entry value for iterator at the current position. Returns NULL if the iterator contains no
+ * entries.
+ */
+AWS_COMMON_API const struct aws_directory_entry *aws_directory_entry_iterator_get_value(
+ const struct aws_directory_iterator *iterator);
+
+/**
+ * Returns true iff the character is a directory separator on ANY supported platform.
+ */
+AWS_COMMON_API
+bool aws_is_any_directory_separator(char value);
+
+/**
+ * Returns the directory separator used by the local platform
+ */
+AWS_COMMON_API
+char aws_get_platform_directory_separator(void);
+
+/**
+ * Normalizes the path by replacing any directory separator with the local platform's directory separator.
+ * @param path path to normalize. Must be writeable.
+ */
+AWS_COMMON_API
+void aws_normalize_directory_separator(struct aws_byte_buf *path);
+
+/**
+ * Returns the current user's home directory.
+ */
+AWS_COMMON_API
+struct aws_string *aws_get_home_directory(struct aws_allocator *allocator);
+
+/**
+ * Returns true if a file or path exists, otherwise, false.
+ */
+AWS_COMMON_API
+bool aws_path_exists(const struct aws_string *path);
+
+/*
+ * Wrapper for highest-resolution platform-dependent seek implementation.
+ * Maps to:
+ *
+ * _fseeki64() on windows
+ * fseeko() on linux
+ *
+ * whence can either be SEEK_SET or SEEK_END
+ *
+ * Returns AWS_OP_SUCCESS, or AWS_OP_ERR (after an error has been raised).
+ */
+AWS_COMMON_API
+int aws_fseek(FILE *file, int64_t offset, int whence);
+
+/*
+ * Wrapper for os-specific file length query. We can't use fseek(END, 0)
+ * because support for it is not technically required.
+ *
+ * Unix flavors call fstat, while Windows variants use GetFileSize on a
+ * HANDLE queried from the libc FILE pointer.
+ */
+AWS_COMMON_API
+int aws_file_get_length(FILE *file, int64_t *length);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_FILE_H */
diff --git a/include/aws/common/hash_table.h b/include/aws/common/hash_table.h
new file mode 100644
index 0000000000000000000000000000000000000000..c2cfadd77800013dd72083b7b91b2e778571dd27
--- /dev/null
+++ b/include/aws/common/hash_table.h
@@ -0,0 +1,454 @@
+#ifndef AWS_COMMON_HASH_TABLE_H
+#define AWS_COMMON_HASH_TABLE_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+enum {
+ AWS_COMMON_HASH_TABLE_ITER_CONTINUE = (1 << 0),
+ AWS_COMMON_HASH_TABLE_ITER_DELETE = (1 << 1),
+ AWS_COMMON_HASH_TABLE_ITER_ERROR = (1 << 2),
+};
+
+/**
+ * Hash table data structure. This module provides an automatically resizing
+ * hash table implementation for general purpose use. The hash table stores a
+ * mapping between void * keys and values; it is expected that in most cases,
+ * these will point to a structure elsewhere in the heap, instead of inlining a
+ * key or value into the hash table element itself.
+ *
+ * Currently, this hash table implements a variant of robin hood hashing, but
+ * we do not guarantee that this won't change in the future.
+ *
+ * Associated with each hash function are four callbacks:
+ *
+ * hash_fn - A hash function from the keys to a uint64_t. It is critical that
+ * the hash function for a key does not change while the key is in the hash
+ * table; violating this results in undefined behavior. Collisions are
+ * tolerated, though naturally with reduced performance.
+ *
+ * equals_fn - An equality comparison function. This function must be
+ * reflexive and consistent with hash_fn.
+ *
+ * destroy_key_fn, destroy_value_fn - Optional callbacks invoked when the
+ * table is cleared or cleaned up and at the caller's option when an element
+ * is removed from the table. Either or both may be set to NULL, which
+ * has the same effect as a no-op destroy function.
+ *
+ * This datastructure can be safely moved between threads, subject to the
+ * requirements of the underlying allocator. It is also safe to invoke
+ * non-mutating operations on the hash table from multiple threads. A suitable
+ * memory barrier must be used when transitioning from single-threaded mutating
+ * usage to multithreaded usage.
+ */
+struct hash_table_state; /* Opaque pointer */
+struct aws_hash_table {
+ struct hash_table_state *p_impl;
+};
+
+/**
+ * Represents an element in the hash table. Various operations on the hash
+ * table may provide pointers to elements stored within the hash table;
+ * generally, calling code may alter value, but must not alter key (or any
+ * information used to compute key's hash code).
+ *
+ * Pointers to elements within the hash are invalidated whenever an operation
+ * which may change the number of elements in the hash is invoked (i.e. put,
+ * delete, clear, and clean_up), regardless of whether the number of elements
+ * actually changes.
+ */
+struct aws_hash_element {
+ const void *key;
+ void *value;
+};
+
+enum aws_hash_iter_status {
+ AWS_HASH_ITER_STATUS_DONE,
+ AWS_HASH_ITER_STATUS_DELETE_CALLED,
+ AWS_HASH_ITER_STATUS_READY_FOR_USE,
+};
+
+struct aws_hash_iter {
+ const struct aws_hash_table *map;
+ struct aws_hash_element element;
+ size_t slot;
+ size_t limit;
+ enum aws_hash_iter_status status;
+ /*
+ * Reserving extra fields for binary compatibility with future expansion of
+ * iterator in case hash table implementation changes.
+ */
+ int unused_0;
+ void *unused_1;
+ void *unused_2;
+};
+
+/**
+ * Prototype for a key hashing function pointer.
+ */
+typedef uint64_t(aws_hash_fn)(const void *key);
+
+/**
+ * Prototype for a hash table equality check function pointer.
+ *
+ * This type is usually used for a function that compares two hash table
+ * keys, but note that the same type is used for a function that compares
+ * two hash table values in aws_hash_table_eq.
+ *
+ * Equality functions used in a hash table must be be reflexive (a == a),
+ * symmetric (a == b => b == a), transitive (a == b, b == c => a == c)
+ * and consistent (result does not change with time).
+ */
+typedef bool(aws_hash_callback_eq_fn)(const void *a, const void *b);
+
+/**
+ * Prototype for a hash table key or value destructor function pointer.
+ *
+ * This function is used to destroy elements in the hash table when the
+ * table is cleared or cleaned up.
+ *
+ * Note that functions which remove individual elements from the hash
+ * table provide options of whether or not to invoke the destructors
+ * on the key and value of a removed element.
+ */
+typedef void(aws_hash_callback_destroy_fn)(void *key_or_value);
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes a hash map with initial capacity for 'size' elements
+ * without resizing. Uses hash_fn to compute the hash of each element.
+ * equals_fn to compute equality of two keys. Whenever an element is
+ * removed without being returned, destroy_key_fn is run on the pointer
+ * to the key and destroy_value_fn is run on the pointer to the value.
+ * Either or both may be NULL if a callback is not desired in this case.
+ */
+AWS_COMMON_API
+int aws_hash_table_init(
+ struct aws_hash_table *map,
+ struct aws_allocator *alloc,
+ size_t size,
+ aws_hash_fn *hash_fn,
+ aws_hash_callback_eq_fn *equals_fn,
+ aws_hash_callback_destroy_fn *destroy_key_fn,
+ aws_hash_callback_destroy_fn *destroy_value_fn);
+
+/**
+ * Deletes every element from map and frees all associated memory.
+ * destroy_fn will be called for each element. aws_hash_table_init
+ * must be called before reusing the hash table.
+ *
+ * This method is idempotent.
+ */
+AWS_COMMON_API
+void aws_hash_table_clean_up(struct aws_hash_table *map);
+
+/**
+ * Safely swaps two hash tables. Note that we swap the entirety of the hash
+ * table, including which allocator is associated.
+ *
+ * Neither hash table is required to be initialized; if one or both is
+ * uninitialized, then the uninitialized state is also swapped.
+ */
+AWS_COMMON_API
+void aws_hash_table_swap(struct aws_hash_table *AWS_RESTRICT a, struct aws_hash_table *AWS_RESTRICT b);
+
+/**
+ * Moves the hash table in 'from' to 'to'. After this move, 'from' will
+ * be identical to the state of the original 'to' hash table, and 'to'
+ * will be in the same state as if it had been passed to aws_hash_table_clean_up
+ * (that is, it will have no memory allocated, and it will be safe to
+ * either discard it or call aws_hash_table_clean_up again).
+ *
+ * Note that 'to' will not be cleaned up. You should make sure that 'to'
+ * is either uninitialized or cleaned up before moving a hashtable into
+ * it.
+ */
+AWS_COMMON_API
+void aws_hash_table_move(struct aws_hash_table *AWS_RESTRICT to, struct aws_hash_table *AWS_RESTRICT from);
+
+/**
+ * Returns the current number of entries in the table.
+ */
+AWS_COMMON_API
+size_t aws_hash_table_get_entry_count(const struct aws_hash_table *map);
+
+/**
+ * Returns an iterator to be used for iterating through a hash table.
+ * Iterator will already point to the first element of the table it finds,
+ * which can be accessed as iter.element.
+ *
+ * This function cannot fail, but if there are no elements in the table,
+ * the returned iterator will return true for aws_hash_iter_done(&iter).
+ */
+AWS_COMMON_API
+struct aws_hash_iter aws_hash_iter_begin(const struct aws_hash_table *map);
+
+/**
+ * Returns true if iterator is done iterating through table, false otherwise.
+ * If this is true, the iterator will not include an element of the table.
+ */
+AWS_COMMON_API
+bool aws_hash_iter_done(const struct aws_hash_iter *iter);
+
+/**
+ * Updates iterator so that it points to next element of hash table.
+ *
+ * This and the two previous functions are designed to be used together with
+ * the following idiom:
+ *
+ * for (struct aws_hash_iter iter = aws_hash_iter_begin(&map);
+ * !aws_hash_iter_done(&iter); aws_hash_iter_next(&iter)) {
+ * const key_type key = *(const key_type *)iter.element.key;
+ * value_type value = *(value_type *)iter.element.value;
+ * // etc.
+ * }
+ *
+ * Note that calling this on an iter which is "done" is idempotent:
+ * i.e. it will return another iter which is "done".
+ */
+AWS_COMMON_API
+void aws_hash_iter_next(struct aws_hash_iter *iter);
+
+/**
+ * Deletes the element currently pointed-to by the hash iterator.
+ * After calling this method, the element member of the iterator
+ * should not be accessed until the next call to aws_hash_iter_next.
+ *
+ * @param destroy_contents If true, the destructors for the key and value
+ * will be called.
+ */
+AWS_COMMON_API
+void aws_hash_iter_delete(struct aws_hash_iter *iter, bool destroy_contents);
+
+/**
+ * Attempts to locate an element at key. If the element is found, a
+ * pointer to the value is placed in *p_elem; if it is not found,
+ * *pElem is set to NULL. Either way, AWS_OP_SUCCESS is returned.
+ *
+ * This method does not change the state of the hash table. Therefore, it
+ * is safe to call _find from multiple threads on the same hash table,
+ * provided no mutating operations happen in parallel.
+ *
+ * Calling code may update the value in the hash table by modifying **pElem
+ * after a successful find. However, this pointer is not guaranteed to
+ * remain usable after a subsequent call to _put, _delete, _clear, or
+ * _clean_up.
+ */
+
+AWS_COMMON_API
+int aws_hash_table_find(const struct aws_hash_table *map, const void *key, struct aws_hash_element **p_elem);
+
+/**
+ * Attempts to locate an element at key. If no such element was found,
+ * creates a new element, with value initialized to NULL. In either case, a
+ * pointer to the element is placed in *p_elem.
+ *
+ * If was_created is non-NULL, *was_created is set to 0 if an existing
+ * element was found, or 1 is a new element was created.
+ *
+ * Returns AWS_OP_SUCCESS if an item was found or created.
+ * Raises AWS_ERROR_OOM if hash table expansion was required and memory
+ * allocation failed.
+ */
+AWS_COMMON_API
+int aws_hash_table_create(
+ struct aws_hash_table *map,
+ const void *key,
+ struct aws_hash_element **p_elem,
+ int *was_created);
+
+/**
+ * Inserts a new element at key, with the given value. If another element
+ * exists at that key, the old element will be overwritten; both old key and
+ * value objects will be destroyed.
+ *
+ * If was_created is non-NULL, *was_created is set to 0 if an existing
+ * element was found, or 1 is a new element was created.
+ *
+ * Returns AWS_OP_SUCCESS if an item was found or created.
+ * Raises AWS_ERROR_OOM if hash table expansion was required and memory
+ * allocation failed.
+ */
+AWS_COMMON_API
+int aws_hash_table_put(struct aws_hash_table *map, const void *key, void *value, int *was_created);
+
+/**
+ * Removes element at key. Always returns AWS_OP_SUCCESS.
+ *
+ * If pValue is non-NULL, the existing value (if any) is moved into
+ * (*value) before removing from the table, and destroy_fn is _not_
+ * invoked. If pValue is NULL, then (if the element existed) destroy_fn
+ * will be invoked on the element being removed.
+ *
+ * If was_present is non-NULL, it is set to 0 if the element was
+ * not present, or 1 if it was present (and is now removed).
+ */
+AWS_COMMON_API
+int aws_hash_table_remove(
+ struct aws_hash_table *map,
+ const void *key,
+ struct aws_hash_element *p_value,
+ int *was_present);
+
+/**
+ * Removes element already known (typically by find()).
+ *
+ * p_value should point to a valid element returned by create() or find().
+ *
+ * NOTE: DO NOT call this method from inside of a aws_hash_table_foreach callback, return
+ * AWS_COMMON_HASH_TABLE_ITER_DELETE instead.
+ */
+AWS_COMMON_API
+int aws_hash_table_remove_element(struct aws_hash_table *map, struct aws_hash_element *p_value);
+
+/**
+ * Iterates through every element in the map and invokes the callback on
+ * that item. Iteration is performed in an arbitrary, implementation-defined
+ * order, and is not guaranteed to be consistent across invocations.
+ *
+ * The callback may change the value associated with the key by overwriting
+ * the value pointed-to by value. In this case, the on_element_removed
+ * callback will not be invoked, unless the callback invokes
+ * AWS_COMMON_HASH_TABLE_ITER_DELETE (in which case the on_element_removed
+ * is given the updated value).
+ *
+ * The callback must return a bitmask of zero or more of the following values
+ * ORed together:
+ *
+ * # AWS_COMMON_HASH_TABLE_ITER_CONTINUE - Continues iteration to the next
+ * element (if not set, iteration stops)
+ * # AWS_COMMON_HASH_TABLE_ITER_DELETE - Deletes the current value and
+ * continues iteration. destroy_fn will NOT be invoked.
+ * # AWS_COMMON_HASH_TABLE_ITER_ERROR - Stop iteration with error.
+ * No action will be taken for the current value and the value before this.
+ * No rolling back. The deleted value before will NOT be back.
+ * aws_hash_table_foreach returns AWS_OP_ERR after stropping the iteration.
+ *
+ * Invoking any method which may change the contents of the hashtable
+ * during iteration results in undefined behavior. However, you may safely
+ * invoke non-mutating operations during an iteration.
+ *
+ * This operation is mutating only if AWS_COMMON_HASH_TABLE_ITER_DELETE
+ * is returned at some point during iteration. Otherwise, it is non-mutating
+ * and is safe to invoke in parallel with other non-mutating operations.
+ */
+
+AWS_COMMON_API
+int aws_hash_table_foreach(
+ struct aws_hash_table *map,
+ int (*callback)(void *context, struct aws_hash_element *p_element),
+ void *context);
+
+/**
+ * Compares two hash tables for equality. Both hash tables must have equivalent
+ * key comparators; values will be compared using the comparator passed into this
+ * function. The key hash function does not need to be equivalent between the
+ * two hash tables.
+ */
+AWS_COMMON_API
+bool aws_hash_table_eq(
+ const struct aws_hash_table *a,
+ const struct aws_hash_table *b,
+ aws_hash_callback_eq_fn *value_eq);
+
+/**
+ * Removes every element from the hash map. destroy_fn will be called for
+ * each element.
+ */
+AWS_COMMON_API
+void aws_hash_table_clear(struct aws_hash_table *map);
+
+/**
+ * Convenience hash function for NULL-terminated C-strings
+ */
+AWS_COMMON_API
+uint64_t aws_hash_c_string(const void *item);
+
+/**
+ * Convenience hash function for struct aws_strings.
+ * Hash is same as used on the string bytes by aws_hash_c_string.
+ */
+AWS_COMMON_API
+uint64_t aws_hash_string(const void *item);
+
+/**
+ * Convenience hash function for struct aws_byte_cursor.
+ * Hash is same as used on the string bytes by aws_hash_c_string.
+ */
+AWS_COMMON_API
+uint64_t aws_hash_byte_cursor_ptr(const void *item);
+
+/**
+ * Convenience hash function which hashes the pointer value directly,
+ * without dereferencing. This can be used in cases where pointer identity
+ * is desired, or where a uintptr_t is encoded into a const void *.
+ */
+AWS_COMMON_API
+uint64_t aws_hash_ptr(const void *item);
+
+AWS_COMMON_API
+uint64_t aws_hash_combine(uint64_t item1, uint64_t item2);
+
+/**
+ * Convenience eq callback for NULL-terminated C-strings
+ */
+AWS_COMMON_API
+bool aws_hash_callback_c_str_eq(const void *a, const void *b);
+
+/**
+ * Convenience eq callback for AWS strings
+ */
+AWS_COMMON_API
+bool aws_hash_callback_string_eq(const void *a, const void *b);
+
+/**
+ * Convenience destroy callback for AWS strings
+ */
+AWS_COMMON_API
+void aws_hash_callback_string_destroy(void *a);
+
+/**
+ * Equality function which compares pointer equality.
+ */
+AWS_COMMON_API
+bool aws_ptr_eq(const void *a, const void *b);
+
+/**
+ * Best-effort check of hash_table_state data-structure invariants
+ */
+AWS_COMMON_API
+bool aws_hash_table_is_valid(const struct aws_hash_table *map);
+
+/**
+ * Given a pointer to a hash_iter, checks that it is well-formed, with all data-structure invariants.
+ */
+AWS_COMMON_API
+bool aws_hash_iter_is_valid(const struct aws_hash_iter *iter);
+
+/**
+ * Helper function to hash keys that are uint64_t values.
+ *
+ * The function is not a strong hash function in any sense; it merely reflects
+ * the uint64 value back. Do not use this function as a hash if you need
+ * the properties of a strong hash function.
+ */
+AWS_COMMON_API uint64_t aws_hash_uint64_t_by_identity(const void *item);
+
+/**
+ * Helper function to compare hash keys that are uint64_t values.
+ */
+AWS_COMMON_API bool aws_hash_compare_uint64_t_eq(const void *a, const void *b);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_HASH_TABLE_H */
diff --git a/include/aws/common/host_utils.h b/include/aws/common/host_utils.h
new file mode 100644
index 0000000000000000000000000000000000000000..0b8285d7a50243464c063f2b5641e2192901beff
--- /dev/null
+++ b/include/aws/common/host_utils.h
@@ -0,0 +1,28 @@
+#ifndef AWS_COMMON_HOST_UTILS_H
+#define AWS_COMMON_HOST_UTILS_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+
+struct aws_byte_cursor;
+
+AWS_PUSH_SANE_WARNING_LEVEL
+AWS_EXTERN_C_BEGIN
+
+/*
+ * Determine whether host cursor is IPv4 string.
+ */
+AWS_COMMON_API bool aws_host_utils_is_ipv4(struct aws_byte_cursor host);
+
+/*
+ * Determine whether host cursor is IPv6 string.
+ * Supports checking for uri encoded strings and scoped literals.
+ */
+AWS_COMMON_API bool aws_host_utils_is_ipv6(struct aws_byte_cursor host, bool is_uri_encoded);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_HOST_UTILS_H */
diff --git a/include/aws/common/json.h b/include/aws/common/json.h
new file mode 100644
index 0000000000000000000000000000000000000000..cfda4cf18aaa5e413ad8a0214cf786dd56f5cb59
--- /dev/null
+++ b/include/aws/common/json.h
@@ -0,0 +1,489 @@
+#ifndef AWS_COMMON_JSON_H
+#define AWS_COMMON_JSON_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_json_value;
+
+AWS_EXTERN_C_BEGIN
+
+// ====================
+// Create and pass type
+
+/**
+ * Creates a new string aws_json_value with the given string and returns a pointer to it.
+ *
+ * Note: You will need to free the memory for the aws_json_value using aws_json_destroy on the aws_json_value or
+ * on the object/array containing the aws_json_value.
+ * Note: might be slower than c_str version due to internal copy
+ * @param string A byte cursor you want to store in the aws_json_value
+ * @param allocator The allocator to use when creating the value
+ * @return A new string aws_json_value
+ */
+AWS_COMMON_API
+struct aws_json_value *aws_json_value_new_string(struct aws_allocator *allocator, struct aws_byte_cursor string);
+
+/**
+ * Creates a new string aws_json_value with the given string and returns a pointer to it.
+ *
+ * Note: You will need to free the memory for the aws_json_value using aws_json_destroy on the aws_json_value or
+ * on the object/array containing the aws_json_value.
+ * @param string c string pointer you want to store in the aws_json_value
+ * @param allocator The allocator to use when creating the value
+ * @return A new string aws_json_value
+ */
+AWS_COMMON_API
+struct aws_json_value *aws_json_value_new_string_from_c_str(struct aws_allocator *allocator, const char *string);
+
+/**
+ * Creates a new number aws_json_value with the given number and returns a pointer to it.
+ *
+ * Note: You will need to free the memory for the aws_json_value using aws_json_destroy on the aws_json_value or
+ * on the object/array containing the aws_json_value.
+ * @param number The number you want to store in the aws_json_value
+ * @param allocator The allocator to use when creating the value
+ * @return A new number aws_json_value
+ */
+AWS_COMMON_API
+struct aws_json_value *aws_json_value_new_number(struct aws_allocator *allocator, double number);
+
+/**
+ * Creates a new array aws_json_value and returns a pointer to it.
+ *
+ * Note: You will need to free the memory for the aws_json_value using aws_json_destroy on the aws_json_value or
+ * on the object/array containing the aws_json_value.
+ * Deleting this array will also destroy any aws_json_values it contains.
+ * @param allocator The allocator to use when creating the value
+ * @return A new array aws_json_value
+ */
+AWS_COMMON_API
+struct aws_json_value *aws_json_value_new_array(struct aws_allocator *allocator);
+
+/**
+ * Creates a new boolean aws_json_value with the given boolean and returns a pointer to it.
+ *
+ * Note: You will need to free the memory for the aws_json_value using aws_json_destroy on the aws_json_value or
+ * on the object/array containing the aws_json_value.
+ * @param boolean The boolean you want to store in the aws_json_value
+ * @param allocator The allocator to use when creating the value
+ * @return A new boolean aws_json_value
+ */
+AWS_COMMON_API
+struct aws_json_value *aws_json_value_new_boolean(struct aws_allocator *allocator, bool boolean);
+
+/**
+ * Creates a new null aws_json_value and returns a pointer to it.
+ *
+ * Note: You will need to free the memory for the aws_json_value using aws_json_destroy on the aws_json_value or
+ * on the object/array containing the aws_json_value.
+ * @param allocator The allocator to use when creating the value
+ * @return A new null aws_json_value
+ */
+AWS_COMMON_API
+struct aws_json_value *aws_json_value_new_null(struct aws_allocator *allocator);
+
+/**
+ * Creates a new object aws_json_value and returns a pointer to it.
+ *
+ * Note: You will need to free the memory for the aws_json_value using aws_json_destroy on the aws_json_value or
+ * on the object/array containing the aws_json_value.
+ * Deleting this object will also destroy any aws_json_values it contains.
+ * @param allocator The allocator to use when creating the value
+ * @return A new object aws_json_value
+ */
+AWS_COMMON_API
+struct aws_json_value *aws_json_value_new_object(struct aws_allocator *allocator);
+// ====================
+
+// ====================
+// Value getters
+
+/**
+ * Gets the string of a string aws_json_value.
+ * @param value The string aws_json_value.
+ * @param output The string
+ * @return AWS_OP_SUCCESS if the value is a string, otherwise AWS_OP_ERR.
+ */
+AWS_COMMON_API
+int aws_json_value_get_string(const struct aws_json_value *value, struct aws_byte_cursor *output);
+
+/**
+ * Gets the number of a number aws_json_value.
+ * @param value The number aws_json_value.
+ * @param output The number
+ * @return AWS_OP_SUCCESS if the value is a number, otherwise AWS_OP_ERR.
+ */
+AWS_COMMON_API
+int aws_json_value_get_number(const struct aws_json_value *value, double *output);
+
+/**
+ * Gets the boolean of a boolean aws_json_value.
+ * @param value The boolean aws_json_value.
+ * @param output The boolean
+ * @return AWS_OP_SUCCESS if the value is a boolean, otherwise AWS_OP_ERR.
+ */
+AWS_COMMON_API
+int aws_json_value_get_boolean(const struct aws_json_value *value, bool *output);
+// ====================
+
+// ====================
+// Object API
+
+/**
+ * Adds a aws_json_value to a object aws_json_value.
+ *
+ * Note that the aws_json_value will be destroyed when the aws_json_value object is destroyed
+ * by calling "aws_json_destroy()"
+ * Note: might be slower than c_str version due to internal copy
+ * @param object The object aws_json_value you want to add a value to.
+ * @param key The key to add the aws_json_value at.
+ * @param value The aws_json_value you want to add.
+ * @return AWS_OP_SUCCESS if adding was successful.
+ * Will return AWS_OP_ERROR if the object passed is invalid or if the passed key
+ * is already in use in the object.
+ */
+AWS_COMMON_API
+int aws_json_value_add_to_object(
+ struct aws_json_value *object,
+ struct aws_byte_cursor key,
+ struct aws_json_value *value);
+
+/**
+ * Adds a aws_json_value to a object aws_json_value.
+ *
+ * Note that the aws_json_value will be destroyed when the aws_json_value object is destroyed
+ * by calling "aws_json_destroy()"
+ * @param object The object aws_json_value you want to add a value to.
+ * @param key The key to add the aws_json_value at.
+ * @param value The aws_json_value you want to add.
+ * @return AWS_OP_SUCCESS if adding was successful.
+ * Will return AWS_OP_ERROR if the object passed is invalid or if the passed key
+ * is already in use in the object.
+ */
+AWS_COMMON_API
+int aws_json_value_add_to_object_c_str(struct aws_json_value *object, const char *key, struct aws_json_value *value);
+
+/**
+ * Returns the aws_json_value at the given key.
+ * Note: might be slower than c_str version due to internal copy
+ * @param object The object aws_json_value you want to get the value from.
+ * @param key The key that the aws_json_value is at. Is case sensitive.
+ * @return The aws_json_value at the given key, otherwise NULL.
+ */
+AWS_COMMON_API
+struct aws_json_value *aws_json_value_get_from_object(const struct aws_json_value *object, struct aws_byte_cursor key);
+
+/**
+ * Returns the aws_json_value at the given key.
+ * Note: same as aws_json_value_get_from_object but with key as const char *.
+ * Prefer this method is you have a key thats already a valid char * as it is likely to be faster.
+ * @param object The object aws_json_value you want to get the value from.
+ * @param key The key that the aws_json_value is at. Is case sensitive.
+ * @return The aws_json_value at the given key, otherwise NULL.
+ */
+AWS_COMMON_API
+struct aws_json_value *aws_json_value_get_from_object_c_str(const struct aws_json_value *object, const char *key);
+
+/**
+ * Checks if there is a aws_json_value at the given key.
+ * Note: might be slower than c_str version due to internal copy
+ * @param object The value aws_json_value you want to check a key in.
+ * @param key The key that you want to check. Is case sensitive.
+ * @return True if a aws_json_value is found.
+ */
+AWS_COMMON_API
+bool aws_json_value_has_key(const struct aws_json_value *object, struct aws_byte_cursor key);
+
+/**
+ * Checks if there is a aws_json_value at the given key.
+ * Note: same as aws_json_value_has_key but with key as const char *.
+ * Prefer this method is you have a key thats already a valid char * as it is likely to be faster.
+ * @param object The value aws_json_value you want to check a key in.
+ * @param key The key that you want to check. Is case sensitive.
+ * @return True if a aws_json_value is found.
+ */
+AWS_COMMON_API
+bool aws_json_value_has_key_c_str(const struct aws_json_value *object, const char *key);
+
+/**
+ * Removes the aws_json_value at the given key.
+ * Note: might be slower than c_str version due to internal copy
+ * @param object The object aws_json_value you want to remove a aws_json_value in.
+ * @param key The key that the aws_json_value is at. Is case sensitive.
+ * @return AWS_OP_SUCCESS if the aws_json_value was removed.
+ * Will return AWS_OP_ERR if the object passed is invalid or if the value
+ * at the key cannot be found.
+ */
+AWS_COMMON_API
+int aws_json_value_remove_from_object(struct aws_json_value *object, struct aws_byte_cursor key);
+
+/**
+ * Removes the aws_json_value at the given key.
+ * Note: same as aws_json_value_remove_from_object but with key as const char *.
+ * Prefer this method is you have a key thats already a valid char * as it is likely to be faster.
+ * @param object The object aws_json_value you want to remove a aws_json_value in.
+ * @param key The key that the aws_json_value is at. Is case sensitive.
+ * @return AWS_OP_SUCCESS if the aws_json_value was removed.
+ * Will return AWS_OP_ERR if the object passed is invalid or if the value
+ * at the key cannot be found.
+ */
+AWS_COMMON_API
+int aws_json_value_remove_from_object_c_str(struct aws_json_value *object, const char *key);
+
+/**
+ * @brief callback for iterating members of an object
+ * Iteration can be controlled as follows:
+ * - return AWS_OP_SUCCESS and out_should_continue is set to true (default value) -
+ * continue iteration without error
+ * - return AWS_OP_SUCCESS and out_continue is set to false -
+ * stop iteration without error
+ * - return AWS_OP_ERR - stop iteration with error
+ */
+typedef int(aws_json_on_member_encountered_const_fn)(
+ const struct aws_byte_cursor *key,
+ const struct aws_json_value *value,
+ bool *out_should_continue,
+ void *user_data);
+
+/**
+ * @brief iterates through members of the object.
+ * iteration is sequential in order fields were initially parsed.
+ * @param object object to iterate over.
+ * @param on_member callback for when member is encountered.
+ * @param user_data user data to pass back in callback.
+ * @return AWS_OP_SUCCESS when iteration finishes completely or exits early,
+ * AWS_OP_ERR if value is not an object.
+ */
+AWS_COMMON_API
+int aws_json_const_iterate_object(
+ const struct aws_json_value *object,
+ aws_json_on_member_encountered_const_fn *on_member,
+ void *user_data);
+
+// ====================
+
+// ====================
+// Array API
+
+/**
+ * Adds a aws_json_value to the given array aws_json_value.
+ *
+ * Note that the aws_json_value will be destroyed when the aws_json_value array is destroyed
+ * by calling "aws_json_destroy()"
+ * @param array The array aws_json_value you want to add an aws_json_value to.
+ * @param value The aws_json_value you want to add.
+ * @return AWS_OP_SUCCESS if adding the aws_json_value was successful.
+ * Will return AWS_OP_ERR if the array passed is invalid.
+ */
+AWS_COMMON_API
+int aws_json_value_add_array_element(struct aws_json_value *array, const struct aws_json_value *value);
+
+/**
+ * Returns the aws_json_value at the given index in the array aws_json_value.
+ * @param array The array aws_json_value.
+ * @param index The index of the aws_json_value you want to access.
+ * @return A pointer to the aws_json_value at the given index in the array, otherwise NULL.
+ */
+AWS_COMMON_API
+struct aws_json_value *aws_json_get_array_element(const struct aws_json_value *array, size_t index);
+
+/**
+ * Returns the number of items in the array aws_json_value.
+ * @param array The array aws_json_value.
+ * @return The number of items in the array_json_value.
+ */
+AWS_COMMON_API
+size_t aws_json_get_array_size(const struct aws_json_value *array);
+
+/**
+ * Removes the aws_json_value at the given index in the array aws_json_value.
+ * @param array The array aws_json_value.
+ * @param index The index containing the aws_json_value you want to remove.
+ * @return AWS_OP_SUCCESS if the aws_json_value at the index was removed.
+ * Will return AWS_OP_ERR if the array passed is invalid or if the index
+ * passed is out of range.
+ */
+AWS_COMMON_API
+int aws_json_value_remove_array_element(struct aws_json_value *array, size_t index);
+
+/**
+ * @brief callback for iterating values of an array.
+ * Iteration can be controlled as follows:
+ * - return AWS_OP_SUCCESS and out_should_continue is set to true (default value) -
+ * continue iteration without error
+ * - return AWS_OP_SUCCESS and out_continue is set to false -
+ * stop iteration without error
+ * - return AWS_OP_ERR - stop iteration with error
+ */
+typedef int(aws_json_on_value_encountered_const_fn)(
+ size_t index,
+ const struct aws_json_value *value,
+ bool *out_should_continue,
+ void *user_data);
+
+/**
+ * @brief iterates through values of an array.
+ * iteration is sequential starting with 0th element.
+ * @param array array to iterate over.
+ * @param on_value callback for when value is encountered.
+ * @param user_data user data to pass back in callback.
+ * @return AWS_OP_SUCCESS when iteration finishes completely or exits early,
+ * AWS_OP_ERR if value is not an array.
+ */
+AWS_COMMON_API
+int aws_json_const_iterate_array(
+ const struct aws_json_value *array,
+ aws_json_on_value_encountered_const_fn *on_value,
+ void *user_data);
+
+// ====================
+
+// ====================
+// Checks
+
+/**
+ * Checks whether two json values are equivalent.
+ * @param a first value to compare.
+ * @param b second value to compare.
+ * @param is_case_sensitive case sensitive compare or not.
+ * @return True is values are equal, false otherwise
+ */
+AWS_COMMON_API
+bool aws_json_value_compare(const struct aws_json_value *a, const struct aws_json_value *b, bool is_case_sensitive);
+
+/**
+ * Duplicates json value.
+ * @param value first value to compare.
+ * @return duplicated value. NULL and last error set if value cannot be duplicated.
+ */
+AWS_COMMON_API
+struct aws_json_value *aws_json_value_duplicate(const struct aws_json_value *value);
+
+/**
+ * Checks if the aws_json_value is a string.
+ * @param value The aws_json_value to check.
+ * @return True if the aws_json_value is a string aws_json_value, otherwise false.
+ */
+AWS_COMMON_API
+bool aws_json_value_is_string(const struct aws_json_value *value);
+
+/**
+ * Checks if the aws_json_value is a number.
+ * @param value The aws_json_value to check.
+ * @return True if the aws_json_value is a number aws_json_value, otherwise false.
+ */
+AWS_COMMON_API
+bool aws_json_value_is_number(const struct aws_json_value *value);
+
+/**
+ * Checks if the aws_json_value is a array.
+ * @param value The aws_json_value to check.
+ * @return True if the aws_json_value is a array aws_json_value, otherwise false.
+ */
+AWS_COMMON_API
+bool aws_json_value_is_array(const struct aws_json_value *value);
+
+/**
+ * Checks if the aws_json_value is a boolean.
+ * @param value The aws_json_value to check.
+ * @return True if the aws_json_value is a boolean aws_json_value, otherwise false.
+ */
+AWS_COMMON_API
+bool aws_json_value_is_boolean(const struct aws_json_value *value);
+
+/**
+ * Checks if the aws_json_value is a null aws_json_value.
+ * @param value The aws_json_value to check.
+ * @return True if the aws_json_value is a null aws_json_value, otherwise false.
+ */
+AWS_COMMON_API
+bool aws_json_value_is_null(const struct aws_json_value *value);
+
+/**
+ * Checks if the aws_json_value is a object aws_json_value.
+ * @param value The aws_json_value to check.
+ * @return True if the aws_json_value is a object aws_json_value, otherwise false.
+ */
+AWS_COMMON_API
+bool aws_json_value_is_object(const struct aws_json_value *value);
+// ====================
+
+// ====================
+// Memory Management
+
+/**
+ * Removes the aws_json_value from memory. If the aws_json_value is a object or array, it will also destroy
+ * attached aws_json_values as well.
+ *
+ * For example, if you called "aws_json_array_add(b, a)" to add an object "a" to an array "b", if you call
+ * "aws_json_destroy(b)" then it will also free "a" automatically. All children/attached aws_json_values are freed
+ * when the parent/root aws_json_value is destroyed.
+ * @param value The aws_json_value to destroy.
+ */
+AWS_COMMON_API
+void aws_json_value_destroy(struct aws_json_value *value);
+// ====================
+
+// ====================
+// Utility
+
+/**
+ * Appends a unformatted JSON string representation of the aws_json_value into the passed byte buffer.
+ * The byte buffer is expected to be already initialized so the function can append the JSON into it.
+ *
+ * Note: The byte buffer will automatically have its size extended if the JSON string is over the byte
+ * buffer capacity AND the byte buffer has an allocator associated with it. If the byte buffer does not
+ * have an allocator associated and the JSON string is over capacity, AWS_OP_ERR will be returned.
+ *
+ * Note: When you are finished with the aws_byte_buf, you must call "aws_byte_buf_clean_up_secure" to free
+ * the memory used, as it will NOT be called automatically.
+ * @param value The aws_json_value to format.
+ * @param output The destination for the JSON string
+ * @return AWS_OP_SUCCESS if the JSON string was allocated to output without any errors
+ * Will return AWS_OP_ERR if the value passed is not an aws_json_value or if there
+ * was an error appending the JSON into the byte buffer.
+ */
+AWS_COMMON_API
+int aws_byte_buf_append_json_string(const struct aws_json_value *value, struct aws_byte_buf *output);
+
+/**
+ * Appends a formatted JSON string representation of the aws_json_value into the passed byte buffer.
+ * The byte buffer is expected to already be initialized so the function can append the JSON into it.
+ *
+ * Note: The byte buffer will automatically have its size extended if the JSON string is over the byte
+ * buffer capacity AND the byte buffer has an allocator associated with it. If the byte buffer does not
+ * have an allocator associated and the JSON string is over capacity, AWS_OP_ERR will be returned.
+ *
+ * Note: When you are finished with the aws_byte_buf, you must call "aws_byte_buf_clean_up_secure" to free
+ * the memory used, as it will NOT be called automatically.
+ * @param value The aws_json_value to format.
+ * @param output The destination for the JSON string
+ * @return AWS_OP_SUCCESS if the JSON string was allocated to output without any errors
+ * Will return AWS_OP_ERR if the value passed is not an aws_json_value or if there
+ * aws an error appending the JSON into the byte buffer.
+ */
+AWS_COMMON_API
+int aws_byte_buf_append_json_string_formatted(const struct aws_json_value *value, struct aws_byte_buf *output);
+
+/**
+ * Parses the JSON string and returns a aws_json_value containing the root of the JSON.
+ * @param allocator The allocator used to create the value
+ * @param string The string containing the JSON.
+ * @return The root aws_json_value of the JSON.
+ */
+AWS_COMMON_API
+struct aws_json_value *aws_json_value_new_from_string(struct aws_allocator *allocator, struct aws_byte_cursor string);
+// ====================
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif // AWS_COMMON_JSON_H
diff --git a/include/aws/common/lifo_cache.h b/include/aws/common/lifo_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..cd547fed79f6dd03366b7477204cd82203c90c80
--- /dev/null
+++ b/include/aws/common/lifo_cache.h
@@ -0,0 +1,31 @@
+#ifndef AWS_COMMON_LIFO_CACHE_H
+#define AWS_COMMON_LIFO_CACHE_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes the last-in-first-out cache. Sets up the underlying linked hash table.
+ * Once `max_items` elements have been added, the latest(last-in) item will
+ * be removed. For the other parameters, see aws/common/hash_table.h. Hash table
+ * semantics of these arguments are preserved.
+ */
+AWS_COMMON_API
+struct aws_cache *aws_cache_new_lifo(
+ struct aws_allocator *allocator,
+ aws_hash_fn *hash_fn,
+ aws_hash_callback_eq_fn *equals_fn,
+ aws_hash_callback_destroy_fn *destroy_key_fn,
+ aws_hash_callback_destroy_fn *destroy_value_fn,
+ size_t max_items);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_LIFO_CACHE_H */
diff --git a/include/aws/common/linked_hash_table.h b/include/aws/common/linked_hash_table.h
new file mode 100644
index 0000000000000000000000000000000000000000..d7fd3c88b7e6b8fb13c13812355cf900ef1f5d47
--- /dev/null
+++ b/include/aws/common/linked_hash_table.h
@@ -0,0 +1,125 @@
+#ifndef AWS_COMMON_LINKED_HASH_TABLE_H
+#define AWS_COMMON_LINKED_HASH_TABLE_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+/**
+ * Simple linked hash table. Preserves insertion order, and can be iterated in insertion order.
+ *
+ * You can also change the order safely without altering the shape of the underlying hash table.
+ */
+struct aws_linked_hash_table {
+ struct aws_allocator *allocator;
+ struct aws_linked_list list;
+ struct aws_hash_table table;
+ aws_hash_callback_destroy_fn *user_on_value_destroy;
+ aws_hash_callback_destroy_fn *user_on_key_destroy;
+};
+
+/**
+ * Linked-List node stored in the table. This is the node type that will be returned in
+ * aws_linked_hash_table_get_iteration_list().
+ */
+struct aws_linked_hash_table_node {
+ struct aws_linked_list_node node;
+ struct aws_linked_hash_table *table;
+ const void *key;
+ void *value;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes the table. Sets up the underlying hash table and linked list.
+ * For the other parameters, see aws/common/hash_table.h. Hash table
+ * semantics of these arguments are preserved.
+ */
+AWS_COMMON_API
+int aws_linked_hash_table_init(
+ struct aws_linked_hash_table *table,
+ struct aws_allocator *allocator,
+ aws_hash_fn *hash_fn,
+ aws_hash_callback_eq_fn *equals_fn,
+ aws_hash_callback_destroy_fn *destroy_key_fn,
+ aws_hash_callback_destroy_fn *destroy_value_fn,
+ size_t initial_item_count);
+
+/**
+ * Cleans up the table. Elements in the table will be evicted and cleanup
+ * callbacks will be invoked.
+ */
+AWS_COMMON_API
+void aws_linked_hash_table_clean_up(struct aws_linked_hash_table *table);
+
+/**
+ * Finds element in the table by key. If found, AWS_OP_SUCCESS will be
+ * returned. If not found, AWS_OP_SUCCESS will be returned and *p_value will be
+ * NULL.
+ *
+ * If any errors occur AWS_OP_ERR will be returned.
+ */
+AWS_COMMON_API
+int aws_linked_hash_table_find(struct aws_linked_hash_table *table, const void *key, void **p_value);
+
+/**
+ * Finds element in the table by key. If found, AWS_OP_SUCCESS will be returned and the item will be moved to the back
+ * of the list.
+ * If not found, AWS_OP_SUCCESS will be returned and *p_value will be NULL.
+ *
+ * Note: this will change the order of elements
+ */
+AWS_COMMON_API
+int aws_linked_hash_table_find_and_move_to_back(struct aws_linked_hash_table *table, const void *key, void **p_value);
+
+/**
+ * Puts `p_value` at `key`. If an element is already stored at `key` it will be replaced.
+ */
+AWS_COMMON_API
+int aws_linked_hash_table_put(struct aws_linked_hash_table *table, const void *key, void *p_value);
+
+/**
+ * Removes item at `key` from the table.
+ */
+AWS_COMMON_API
+int aws_linked_hash_table_remove(struct aws_linked_hash_table *table, const void *key);
+
+/**
+ * Clears all items from the table.
+ */
+AWS_COMMON_API
+void aws_linked_hash_table_clear(struct aws_linked_hash_table *table);
+
+/**
+ * returns number of elements in the table.
+ */
+AWS_COMMON_API
+size_t aws_linked_hash_table_get_element_count(const struct aws_linked_hash_table *table);
+
+/**
+ * Move the aws_linked_hash_table_node to the end of the list.
+ *
+ * Note: this will change the order of elements
+ */
+AWS_COMMON_API
+void aws_linked_hash_table_move_node_to_end_of_list(
+ struct aws_linked_hash_table *table,
+ struct aws_linked_hash_table_node *node);
+
+/**
+ * returns the underlying linked list for iteration.
+ *
+ * The returned list has nodes of the type: aws_linked_hash_table_node. Use AWS_CONTAINER_OF for access to the element.
+ */
+AWS_COMMON_API
+const struct aws_linked_list *aws_linked_hash_table_get_iteration_list(const struct aws_linked_hash_table *table);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_LINKED_HASH_TABLE_H */
diff --git a/include/aws/common/linked_list.h b/include/aws/common/linked_list.h
new file mode 100644
index 0000000000000000000000000000000000000000..bd2e5d891a53257894f7f4c742a50ebcb1add1e9
--- /dev/null
+++ b/include/aws/common/linked_list.h
@@ -0,0 +1,196 @@
+#ifndef AWS_COMMON_LINKED_LIST_H
+#define AWS_COMMON_LINKED_LIST_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_linked_list_node {
+ struct aws_linked_list_node *next;
+ struct aws_linked_list_node *prev;
+};
+
+struct aws_linked_list {
+ struct aws_linked_list_node head;
+ struct aws_linked_list_node tail;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Set node's next and prev pointers to NULL.
+ */
+AWS_STATIC_IMPL void aws_linked_list_node_reset(struct aws_linked_list_node *node);
+
+/**
+ * These functions need to be defined first as they are used in pre
+ * and post conditions.
+ */
+
+/**
+ * Tests if the list is empty.
+ */
+AWS_STATIC_IMPL bool aws_linked_list_empty(const struct aws_linked_list *list);
+
+/**
+ * Checks that a linked list is valid.
+ */
+AWS_STATIC_IMPL bool aws_linked_list_is_valid(const struct aws_linked_list *list);
+/**
+ * Checks that the prev of the next pointer of a node points to the
+ * node. As this checks whether the [next] connection of a node is
+ * bidirectional, it returns false if used for the list tail.
+ */
+AWS_STATIC_IMPL bool aws_linked_list_node_next_is_valid(const struct aws_linked_list_node *node);
+
+/**
+ * Checks that the next of the prev pointer of a node points to the
+ * node. Similarly to the above, this returns false if used for the
+ * head of a list.
+ */
+AWS_STATIC_IMPL bool aws_linked_list_node_prev_is_valid(const struct aws_linked_list_node *node);
+/**
+ * Checks that a linked list satisfies double linked list connectivity
+ * constraints. This check is O(n) as it traverses the whole linked
+ * list to ensure that tail is reachable from head (and vice versa)
+ * and that every connection is bidirectional.
+ *
+ * Note: This check *cannot* go into an infinite loop, because we
+ * ensure that the connection to the next node is
+ * bidirectional. Therefore, if a node's [a] a.next is a previous node
+ * [b] in the list, b.prev != &a and so this check would fail, thus
+ * terminating the loop.
+ */
+AWS_STATIC_IMPL bool aws_linked_list_is_valid_deep(const struct aws_linked_list *list);
+
+/**
+ * Initializes the list. List will be empty after this call.
+ */
+AWS_STATIC_IMPL void aws_linked_list_init(struct aws_linked_list *list);
+
+/**
+ * Returns an iteration pointer for the first element in the list.
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_begin(const struct aws_linked_list *list);
+
+/**
+ * Returns an iteration pointer for one past the last element in the list.
+ */
+AWS_STATIC_IMPL const struct aws_linked_list_node *aws_linked_list_end(const struct aws_linked_list *list);
+
+/**
+ * Returns a pointer for the last element in the list.
+ * Used to begin iterating the list in reverse. Ex:
+ * for (i = aws_linked_list_rbegin(list); i != aws_linked_list_rend(list); i = aws_linked_list_prev(i)) {...}
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_rbegin(const struct aws_linked_list *list);
+
+/**
+ * Returns the pointer to one before the first element in the list.
+ * Used to end iterating the list in reverse.
+ */
+AWS_STATIC_IMPL const struct aws_linked_list_node *aws_linked_list_rend(const struct aws_linked_list *list);
+
+/**
+ * Returns the next element in the list.
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_next(const struct aws_linked_list_node *node);
+
+/**
+ * Returns the previous element in the list.
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_prev(const struct aws_linked_list_node *node);
+
+/**
+ * Inserts to_add immediately after after.
+ */
+AWS_STATIC_IMPL void aws_linked_list_insert_after(
+ struct aws_linked_list_node *after,
+ struct aws_linked_list_node *to_add);
+/**
+ * Swaps the order two nodes in the linked list.
+ */
+AWS_STATIC_IMPL void aws_linked_list_swap_nodes(struct aws_linked_list_node *a, struct aws_linked_list_node *b);
+
+/**
+ * Inserts to_add immediately before before.
+ */
+AWS_STATIC_IMPL void aws_linked_list_insert_before(
+ struct aws_linked_list_node *before,
+ struct aws_linked_list_node *to_add);
+
+/**
+ * Removes the specified node from the list (prev/next point to each other) and
+ * returns the next node in the list.
+ */
+AWS_STATIC_IMPL void aws_linked_list_remove(struct aws_linked_list_node *node);
+
+/**
+ * Append new_node.
+ */
+AWS_STATIC_IMPL void aws_linked_list_push_back(struct aws_linked_list *list, struct aws_linked_list_node *node);
+
+/**
+ * Returns the element in the back of the list.
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_back(const struct aws_linked_list *list);
+
+/**
+ * Returns the element in the back of the list and removes it
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_pop_back(struct aws_linked_list *list);
+
+/**
+ * Prepend new_node.
+ */
+AWS_STATIC_IMPL void aws_linked_list_push_front(struct aws_linked_list *list, struct aws_linked_list_node *node);
+/**
+ * Returns the element in the front of the list.
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_front(const struct aws_linked_list *list);
+/**
+ * Returns the element in the front of the list and removes it
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_pop_front(struct aws_linked_list *list);
+
+AWS_STATIC_IMPL void aws_linked_list_swap_contents(
+ struct aws_linked_list *AWS_RESTRICT a,
+ struct aws_linked_list *AWS_RESTRICT b);
+
+/**
+ * Remove all nodes from one list, and add them to the back of another.
+ *
+ * Example: if dst={1,2} and src={3,4}, they become dst={1,2,3,4} and src={}
+ */
+AWS_STATIC_IMPL void aws_linked_list_move_all_back(
+ struct aws_linked_list *AWS_RESTRICT dst,
+ struct aws_linked_list *AWS_RESTRICT src);
+
+/**
+ * Remove all nodes from one list, and add them to the front of another.
+ *
+ * Example: if dst={2,1} and src={4,3}, they become dst={4,3,2,1} and src={}
+ */
+AWS_STATIC_IMPL void aws_linked_list_move_all_front(
+ struct aws_linked_list *AWS_RESTRICT dst,
+ struct aws_linked_list *AWS_RESTRICT src);
+
+/**
+ * Returns true if the node is currently in a list, false otherwise.
+ */
+AWS_STATIC_IMPL bool aws_linked_list_node_is_in_list(struct aws_linked_list_node *node);
+AWS_EXTERN_C_END
+
+#ifndef AWS_NO_STATIC_IMPL
+# include
+#endif /* AWS_NO_STATIC_IMPL */
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_LINKED_LIST_H */
diff --git a/include/aws/common/linked_list.inl b/include/aws/common/linked_list.inl
new file mode 100644
index 0000000000000000000000000000000000000000..4d7e54dd0663a4c72b90e00bab8b5a5aff20447a
--- /dev/null
+++ b/include/aws/common/linked_list.inl
@@ -0,0 +1,440 @@
+#ifndef AWS_COMMON_LINKED_LIST_INL
+#define AWS_COMMON_LINKED_LIST_INL
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+#include
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Set node's next and prev pointers to NULL.
+ */
+AWS_STATIC_IMPL void aws_linked_list_node_reset(struct aws_linked_list_node *node) {
+ AWS_PRECONDITION(node != NULL);
+ AWS_ZERO_STRUCT(*node);
+ AWS_POSTCONDITION(AWS_IS_ZEROED(*node));
+}
+
+/**
+ * These functions need to be defined first as they are used in pre
+ * and post conditions.
+ */
+
+/**
+ * Tests if the list is empty.
+ */
+AWS_STATIC_IMPL bool aws_linked_list_empty(const struct aws_linked_list *list) {
+ AWS_PRECONDITION(list);
+ return list->head.next == &list->tail;
+}
+
+/**
+ * Checks that a linked list is valid.
+ */
+AWS_STATIC_IMPL bool aws_linked_list_is_valid(const struct aws_linked_list *list) {
+ if (list && list->head.next && list->head.prev == NULL && list->tail.prev && list->tail.next == NULL) {
+#if defined(AWS_DEEP_CHECKS) && (AWS_DEEP_CHECKS == 1)
+ return aws_linked_list_is_valid_deep(list);
+#else
+ return true;
+#endif
+ }
+ return false;
+}
+
+/**
+ * Checks that the prev of the next pointer of a node points to the
+ * node. As this checks whether the [next] connection of a node is
+ * bidirectional, it returns false if used for the list tail.
+ */
+AWS_STATIC_IMPL bool aws_linked_list_node_next_is_valid(const struct aws_linked_list_node *node) {
+ return node && node->next && node->next->prev == node;
+}
+
+/**
+ * Checks that the next of the prev pointer of a node points to the
+ * node. Similarly to the above, this returns false if used for the
+ * head of a list.
+ */
+AWS_STATIC_IMPL bool aws_linked_list_node_prev_is_valid(const struct aws_linked_list_node *node) {
+ return node && node->prev && node->prev->next == node;
+}
+
+/**
+ * Checks that a linked list satisfies double linked list connectivity
+ * constraints. This check is O(n) as it traverses the whole linked
+ * list to ensure that tail is reachable from head (and vice versa)
+ * and that every connection is bidirectional.
+ *
+ * Note: This check *cannot* go into an infinite loop, because we
+ * ensure that the connection to the next node is
+ * bidirectional. Therefore, if a node's [a] a.next is a previous node
+ * [b] in the list, b.prev != &a and so this check would fail, thus
+ * terminating the loop.
+ */
+AWS_STATIC_IMPL bool aws_linked_list_is_valid_deep(const struct aws_linked_list *list) {
+ if (!list) {
+ return false;
+ }
+ /* This could go into an infinite loop for a circular list */
+ const struct aws_linked_list_node *temp = &list->head;
+ /* Head must reach tail by following next pointers */
+ bool head_reaches_tail = false;
+ /* By satisfying the above and that edges are bidirectional, we
+ * also guarantee that tail reaches head by following prev
+ * pointers */
+ while (temp) {
+ if (temp == &list->tail) {
+ head_reaches_tail = true;
+ break;
+ } else if (!aws_linked_list_node_next_is_valid(temp)) {
+ /* Next and prev pointers should connect the same nodes */
+ return false;
+ }
+ temp = temp->next;
+ }
+ return head_reaches_tail;
+}
+
+/**
+ * Initializes the list. List will be empty after this call.
+ */
+AWS_STATIC_IMPL void aws_linked_list_init(struct aws_linked_list *list) {
+ AWS_PRECONDITION(list);
+ list->head.next = &list->tail;
+ list->head.prev = NULL;
+ list->tail.prev = &list->head;
+ list->tail.next = NULL;
+ AWS_POSTCONDITION(aws_linked_list_is_valid(list));
+ AWS_POSTCONDITION(aws_linked_list_empty(list));
+}
+
+/**
+ * Returns an iteration pointer for the first element in the list.
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_begin(const struct aws_linked_list *list) {
+ AWS_PRECONDITION(aws_linked_list_is_valid(list));
+ struct aws_linked_list_node *rval = list->head.next;
+ AWS_POSTCONDITION(aws_linked_list_is_valid(list));
+ AWS_POSTCONDITION(rval == list->head.next);
+ return rval;
+}
+
+/**
+ * Returns an iteration pointer for one past the last element in the list.
+ */
+AWS_STATIC_IMPL const struct aws_linked_list_node *aws_linked_list_end(const struct aws_linked_list *list) {
+ AWS_PRECONDITION(aws_linked_list_is_valid(list));
+ const struct aws_linked_list_node *rval = &list->tail;
+ AWS_POSTCONDITION(aws_linked_list_is_valid(list));
+ AWS_POSTCONDITION(rval == &list->tail);
+ return rval;
+}
+
+/**
+ * Returns a pointer for the last element in the list.
+ * Used to begin iterating the list in reverse. Ex:
+ * for (i = aws_linked_list_rbegin(list); i != aws_linked_list_rend(list); i = aws_linked_list_prev(i)) {...}
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_rbegin(const struct aws_linked_list *list) {
+ AWS_PRECONDITION(aws_linked_list_is_valid(list));
+ struct aws_linked_list_node *rval = list->tail.prev;
+ AWS_POSTCONDITION(aws_linked_list_is_valid(list));
+ AWS_POSTCONDITION(rval == list->tail.prev);
+ return rval;
+}
+
+/**
+ * Returns the pointer to one before the first element in the list.
+ * Used to end iterating the list in reverse.
+ */
+AWS_STATIC_IMPL const struct aws_linked_list_node *aws_linked_list_rend(const struct aws_linked_list *list) {
+ AWS_PRECONDITION(aws_linked_list_is_valid(list));
+ const struct aws_linked_list_node *rval = &list->head;
+ AWS_POSTCONDITION(aws_linked_list_is_valid(list));
+ AWS_POSTCONDITION(rval == &list->head);
+ return rval;
+}
+
+/**
+ * Returns the next element in the list.
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_next(const struct aws_linked_list_node *node) {
+ AWS_PRECONDITION(aws_linked_list_node_next_is_valid(node));
+ struct aws_linked_list_node *rval = node->next;
+ AWS_POSTCONDITION(aws_linked_list_node_next_is_valid(node));
+ AWS_POSTCONDITION(aws_linked_list_node_prev_is_valid(rval));
+ AWS_POSTCONDITION(rval == node->next);
+ return rval;
+}
+
+/**
+ * Returns the previous element in the list.
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_prev(const struct aws_linked_list_node *node) {
+ AWS_PRECONDITION(aws_linked_list_node_prev_is_valid(node));
+ struct aws_linked_list_node *rval = node->prev;
+ AWS_POSTCONDITION(aws_linked_list_node_prev_is_valid(node));
+ AWS_POSTCONDITION(aws_linked_list_node_next_is_valid(rval));
+ AWS_POSTCONDITION(rval == node->prev);
+ return rval;
+}
+
+/**
+ * Inserts to_add immediately after after.
+ */
+AWS_STATIC_IMPL void aws_linked_list_insert_after(
+ struct aws_linked_list_node *after,
+ struct aws_linked_list_node *to_add) {
+ AWS_PRECONDITION(aws_linked_list_node_next_is_valid(after));
+ AWS_PRECONDITION(to_add != NULL);
+ to_add->prev = after;
+ to_add->next = after->next;
+ after->next->prev = to_add;
+ after->next = to_add;
+ AWS_POSTCONDITION(aws_linked_list_node_next_is_valid(after));
+ AWS_POSTCONDITION(aws_linked_list_node_prev_is_valid(to_add));
+ AWS_POSTCONDITION(aws_linked_list_node_next_is_valid(to_add));
+ AWS_POSTCONDITION(after->next == to_add);
+}
+
+/**
+ * Swaps the order two nodes in the linked list.
+ */
+AWS_STATIC_IMPL void aws_linked_list_swap_nodes(struct aws_linked_list_node *a, struct aws_linked_list_node *b) {
+ AWS_PRECONDITION(aws_linked_list_node_prev_is_valid(a));
+ AWS_PRECONDITION(aws_linked_list_node_next_is_valid(a));
+ AWS_PRECONDITION(aws_linked_list_node_prev_is_valid(b));
+ AWS_PRECONDITION(aws_linked_list_node_next_is_valid(b));
+
+ if (a == b) {
+ return;
+ }
+
+ /* snapshot b's value to avoid clobbering its next/prev pointers if a/b are adjacent */
+ struct aws_linked_list_node tmp = *b;
+ a->prev->next = b;
+ a->next->prev = b;
+
+ tmp.prev->next = a;
+ tmp.next->prev = a;
+
+ tmp = *a;
+ *a = *b;
+ *b = tmp;
+
+ AWS_POSTCONDITION(aws_linked_list_node_prev_is_valid(a));
+ AWS_POSTCONDITION(aws_linked_list_node_next_is_valid(a));
+ AWS_POSTCONDITION(aws_linked_list_node_prev_is_valid(b));
+ AWS_POSTCONDITION(aws_linked_list_node_next_is_valid(b));
+}
+
+/**
+ * Inserts to_add immediately before before.
+ */
+AWS_STATIC_IMPL void aws_linked_list_insert_before(
+ struct aws_linked_list_node *before,
+ struct aws_linked_list_node *to_add) {
+ AWS_PRECONDITION(aws_linked_list_node_prev_is_valid(before));
+ AWS_PRECONDITION(to_add != NULL);
+ to_add->next = before;
+ to_add->prev = before->prev;
+ before->prev->next = to_add;
+ before->prev = to_add;
+ AWS_POSTCONDITION(aws_linked_list_node_prev_is_valid(before));
+ AWS_POSTCONDITION(aws_linked_list_node_prev_is_valid(to_add));
+ AWS_POSTCONDITION(aws_linked_list_node_next_is_valid(to_add));
+ AWS_POSTCONDITION(before->prev == to_add);
+}
+
+/**
+ * Removes the specified node from the list (prev/next point to each other) and
+ * returns the next node in the list.
+ */
+AWS_STATIC_IMPL void aws_linked_list_remove(struct aws_linked_list_node *node) {
+ AWS_PRECONDITION(aws_linked_list_node_prev_is_valid(node));
+ AWS_PRECONDITION(aws_linked_list_node_next_is_valid(node));
+ node->prev->next = node->next;
+ node->next->prev = node->prev;
+ aws_linked_list_node_reset(node);
+ AWS_POSTCONDITION(node->next == NULL && node->prev == NULL);
+}
+
+/**
+ * Append new_node.
+ */
+AWS_STATIC_IMPL void aws_linked_list_push_back(struct aws_linked_list *list, struct aws_linked_list_node *node) {
+ AWS_PRECONDITION(aws_linked_list_is_valid(list));
+ AWS_PRECONDITION(node != NULL);
+ aws_linked_list_insert_before(&list->tail, node);
+ AWS_POSTCONDITION(aws_linked_list_is_valid(list));
+ AWS_POSTCONDITION(list->tail.prev == node, "[node] is the new last element of [list]");
+}
+
+/**
+ * Returns the element in the back of the list.
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_back(const struct aws_linked_list *list) {
+ AWS_PRECONDITION(aws_linked_list_is_valid(list));
+ AWS_PRECONDITION(!aws_linked_list_empty(list));
+ struct aws_linked_list_node *rval = list->tail.prev;
+ AWS_POSTCONDITION(aws_linked_list_is_valid(list));
+ AWS_POSTCONDITION(aws_linked_list_node_prev_is_valid(rval));
+ AWS_POSTCONDITION(aws_linked_list_node_next_is_valid(rval));
+ return rval;
+}
+
+/**
+ * Returns the element in the back of the list and removes it
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_pop_back(struct aws_linked_list *list) {
+ AWS_PRECONDITION(!aws_linked_list_empty(list));
+ AWS_PRECONDITION(aws_linked_list_is_valid(list));
+ struct aws_linked_list_node *back = aws_linked_list_back(list);
+ aws_linked_list_remove(back);
+ AWS_POSTCONDITION(back->next == NULL && back->prev == NULL);
+ AWS_POSTCONDITION(aws_linked_list_is_valid(list));
+ return back;
+}
+
+/**
+ * Prepend new_node.
+ */
+AWS_STATIC_IMPL void aws_linked_list_push_front(struct aws_linked_list *list, struct aws_linked_list_node *node) {
+ AWS_PRECONDITION(aws_linked_list_is_valid(list));
+ AWS_PRECONDITION(node != NULL);
+ aws_linked_list_insert_before(list->head.next, node);
+ AWS_POSTCONDITION(aws_linked_list_is_valid(list));
+ AWS_POSTCONDITION(list->head.next == node, "[node] is the new first element of [list]");
+}
+
+/**
+ * Returns the element in the front of the list.
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_front(const struct aws_linked_list *list) {
+ AWS_PRECONDITION(aws_linked_list_is_valid(list));
+ AWS_PRECONDITION(!aws_linked_list_empty(list));
+ struct aws_linked_list_node *rval = list->head.next;
+ AWS_POSTCONDITION(aws_linked_list_is_valid(list));
+ AWS_POSTCONDITION(aws_linked_list_node_prev_is_valid(rval));
+ AWS_POSTCONDITION(aws_linked_list_node_next_is_valid(rval));
+ return rval;
+}
+
+/**
+ * Returns the element in the front of the list and removes it
+ */
+AWS_STATIC_IMPL struct aws_linked_list_node *aws_linked_list_pop_front(struct aws_linked_list *list) {
+ AWS_PRECONDITION(!aws_linked_list_empty(list));
+ AWS_PRECONDITION(aws_linked_list_is_valid(list));
+ struct aws_linked_list_node *front = aws_linked_list_front(list);
+ aws_linked_list_remove(front);
+ AWS_POSTCONDITION(front->next == NULL && front->prev == NULL);
+ AWS_POSTCONDITION(aws_linked_list_is_valid(list));
+ return front;
+}
+
+AWS_STATIC_IMPL void aws_linked_list_swap_contents(
+ struct aws_linked_list *AWS_RESTRICT a,
+ struct aws_linked_list *AWS_RESTRICT b) {
+
+ AWS_PRECONDITION(aws_linked_list_is_valid(a));
+ AWS_PRECONDITION(aws_linked_list_is_valid(b));
+ AWS_PRECONDITION(a != b);
+ struct aws_linked_list_node *a_first = a->head.next;
+ struct aws_linked_list_node *a_last = a->tail.prev;
+
+ /* Move B's contents into A */
+ if (aws_linked_list_empty(b)) {
+ aws_linked_list_init(a);
+ } else {
+ a->head.next = b->head.next;
+ a->head.next->prev = &a->head;
+ a->tail.prev = b->tail.prev;
+ a->tail.prev->next = &a->tail;
+ }
+
+ /* Move A's old contents into B */
+ if (a_first == &a->tail) {
+ aws_linked_list_init(b);
+ } else {
+ b->head.next = a_first;
+ b->head.next->prev = &b->head;
+ b->tail.prev = a_last;
+ b->tail.prev->next = &b->tail;
+ }
+ AWS_POSTCONDITION(aws_linked_list_is_valid(a));
+ AWS_POSTCONDITION(aws_linked_list_is_valid(b));
+}
+
+AWS_STATIC_IMPL void aws_linked_list_move_all_back(
+ struct aws_linked_list *AWS_RESTRICT dst,
+ struct aws_linked_list *AWS_RESTRICT src) {
+
+ AWS_PRECONDITION(aws_linked_list_is_valid(src));
+ AWS_PRECONDITION(aws_linked_list_is_valid(dst));
+ AWS_PRECONDITION(dst != src);
+
+ if (!aws_linked_list_empty(src)) {
+ /* splice src nodes into dst, between the back and tail nodes */
+ struct aws_linked_list_node *dst_back = dst->tail.prev;
+ struct aws_linked_list_node *src_front = src->head.next;
+ struct aws_linked_list_node *src_back = src->tail.prev;
+
+ dst_back->next = src_front;
+ src_front->prev = dst_back;
+
+ dst->tail.prev = src_back;
+ src_back->next = &dst->tail;
+
+ /* reset src */
+ src->head.next = &src->tail;
+ src->tail.prev = &src->head;
+ }
+
+ AWS_POSTCONDITION(aws_linked_list_is_valid(src));
+ AWS_POSTCONDITION(aws_linked_list_is_valid(dst));
+}
+
+AWS_STATIC_IMPL void aws_linked_list_move_all_front(
+ struct aws_linked_list *AWS_RESTRICT dst,
+ struct aws_linked_list *AWS_RESTRICT src) {
+
+ AWS_PRECONDITION(aws_linked_list_is_valid(src));
+ AWS_PRECONDITION(aws_linked_list_is_valid(dst));
+ AWS_PRECONDITION(dst != src);
+
+ if (!aws_linked_list_empty(src)) {
+ /* splice src nodes into dst, between the head and front nodes */
+ struct aws_linked_list_node *dst_front = dst->head.next;
+ struct aws_linked_list_node *src_front = src->head.next;
+ struct aws_linked_list_node *src_back = src->tail.prev;
+
+ dst->head.next = src_front;
+ src_front->prev = &dst->head;
+
+ src_back->next = dst_front;
+ dst_front->prev = src_back;
+
+ /* reset src */
+ src->head.next = &src->tail;
+ src->tail.prev = &src->head;
+ }
+
+ AWS_POSTCONDITION(aws_linked_list_is_valid(src));
+ AWS_POSTCONDITION(aws_linked_list_is_valid(dst));
+}
+
+AWS_STATIC_IMPL bool aws_linked_list_node_is_in_list(struct aws_linked_list_node *node) {
+ return aws_linked_list_node_prev_is_valid(node) && aws_linked_list_node_next_is_valid(node);
+}
+
+AWS_EXTERN_C_END
+
+#endif /* AWS_COMMON_LINKED_LIST_INL */
diff --git a/include/aws/common/log_channel.h b/include/aws/common/log_channel.h
new file mode 100644
index 0000000000000000000000000000000000000000..b6e1f0fc358dd0e7db57a5cd0f92e30067ceaccd
--- /dev/null
+++ b/include/aws/common/log_channel.h
@@ -0,0 +1,75 @@
+
+#ifndef AWS_COMMON_LOG_CHANNEL_H
+#define AWS_COMMON_LOG_CHANNEL_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_string;
+struct aws_log_writer;
+
+/*
+ * Log channel interface and default implementations
+ *
+ * A log channel is an abstraction for the transfer of formatted log data between a source (formatter)
+ * and a sink (writer).
+ */
+struct aws_log_channel;
+
+typedef int(aws_log_channel_send_fn)(struct aws_log_channel *channel, struct aws_string *output);
+typedef void(aws_log_channel_clean_up_fn)(struct aws_log_channel *channel);
+
+struct aws_log_channel_vtable {
+ aws_log_channel_send_fn *send;
+ aws_log_channel_clean_up_fn *clean_up;
+};
+
+struct aws_log_channel {
+ struct aws_log_channel_vtable *vtable;
+ struct aws_allocator *allocator;
+ struct aws_log_writer *writer;
+ void *impl;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/*
+ * Simple channel that results in log lines being written in the same thread they were generated in.
+ *
+ * The passed in log writer is not an ownership transfer. The log channel does not clean up the writer.
+ */
+AWS_COMMON_API
+int aws_log_channel_init_foreground(
+ struct aws_log_channel *channel,
+ struct aws_allocator *allocator,
+ struct aws_log_writer *writer);
+
+/*
+ * Simple channel that sends log lines to a background thread.
+ *
+ * The passed in log writer is not an ownership transfer. The log channel does not clean up the writer.
+ */
+AWS_COMMON_API
+int aws_log_channel_init_background(
+ struct aws_log_channel *channel,
+ struct aws_allocator *allocator,
+ struct aws_log_writer *writer);
+
+/*
+ * Channel cleanup function
+ */
+AWS_COMMON_API
+void aws_log_channel_clean_up(struct aws_log_channel *channel);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_LOG_CHANNEL_H */
diff --git a/include/aws/common/log_formatter.h b/include/aws/common/log_formatter.h
new file mode 100644
index 0000000000000000000000000000000000000000..f7604556299ee8e06eddcd74df4ca0b51a74129a
--- /dev/null
+++ b/include/aws/common/log_formatter.h
@@ -0,0 +1,98 @@
+
+#ifndef AWS_COMMON_LOG_FORMATTER_H
+#define AWS_COMMON_LOG_FORMATTER_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+#include
+#include
+
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_allocator;
+struct aws_string;
+
+/*
+ * Log formatter interface and default implementation
+ *
+ * Log formatters are invoked by the LOGF_* macros to transform a set of arguments into
+ * one or more lines of text to be output to a logging sink (writer).
+ */
+struct aws_log_formatter;
+
+typedef int(aws_log_formatter_format_fn)(
+ struct aws_log_formatter *formatter,
+ struct aws_string **formatted_output,
+ enum aws_log_level level,
+ aws_log_subject_t subject,
+ const char *format,
+ va_list args);
+
+typedef void(aws_log_formatter_clean_up_fn)(struct aws_log_formatter *logger);
+
+struct aws_log_formatter_vtable {
+ aws_log_formatter_format_fn *format;
+ aws_log_formatter_clean_up_fn *clean_up;
+};
+
+struct aws_log_formatter {
+ struct aws_log_formatter_vtable *vtable;
+ struct aws_allocator *allocator;
+ void *impl;
+};
+
+struct aws_log_formatter_standard_options {
+ enum aws_date_format date_format;
+};
+
+struct aws_logging_standard_formatting_data {
+ char *log_line_buffer;
+ size_t total_length;
+ enum aws_log_level level;
+ const char *subject_name;
+ const char *format;
+ enum aws_date_format date_format;
+ struct aws_allocator *allocator; /* not used, just there to make byte_bufs valid */
+
+ size_t amount_written;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/*
+ * Initializes the default log formatter which outputs lines in the format:
+ *
+ * [] [] [] - \n
+ */
+AWS_COMMON_API
+int aws_log_formatter_init_default(
+ struct aws_log_formatter *formatter,
+ struct aws_allocator *allocator,
+ struct aws_log_formatter_standard_options *options);
+
+/*
+ * Cleans up a log formatter (minus the base structure memory) by calling the formatter's clean_up function
+ * via the vtable.
+ */
+AWS_COMMON_API
+void aws_log_formatter_clean_up(struct aws_log_formatter *formatter);
+
+/*
+ * Formats a single log line based on the input + the var args list. Output is written to a fixed-size
+ * buffer supplied in the data struct.
+ */
+AWS_COMMON_API
+int aws_format_standard_log_line(struct aws_logging_standard_formatting_data *formatting_data, va_list args);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_LOG_FORMATTER_H */
diff --git a/include/aws/common/log_writer.h b/include/aws/common/log_writer.h
new file mode 100644
index 0000000000000000000000000000000000000000..54fb98358432d43dd89fe18aaede4c3c38bebef1
--- /dev/null
+++ b/include/aws/common/log_writer.h
@@ -0,0 +1,76 @@
+
+#ifndef AWS_COMMON_LOG_WRITER_H
+#define AWS_COMMON_LOG_WRITER_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_allocator;
+struct aws_string;
+
+/*
+ * Log writer interface and default implementation(s)
+ *
+ * A log writer functions as a sink for formatted log lines. We provide
+ * default implementations that go to stdout, stderr, and a specified file.
+ */
+struct aws_log_writer;
+
+typedef int(aws_log_writer_write_fn)(struct aws_log_writer *writer, const struct aws_string *output);
+typedef void(aws_log_writer_clean_up_fn)(struct aws_log_writer *writer);
+
+struct aws_log_writer_vtable {
+ aws_log_writer_write_fn *write;
+ aws_log_writer_clean_up_fn *clean_up;
+};
+
+struct aws_log_writer {
+ struct aws_log_writer_vtable *vtable;
+ struct aws_allocator *allocator;
+ void *impl;
+};
+
+struct aws_log_writer_file_options {
+ const char *filename;
+ FILE *file;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/*
+ * Initialize a log writer that sends log lines to stdout. Uses C library IO.
+ */
+AWS_COMMON_API
+int aws_log_writer_init_stdout(struct aws_log_writer *writer, struct aws_allocator *allocator);
+
+/*
+ * Initialize a log writer that sends log lines to stderr. Uses C library IO.
+ */
+AWS_COMMON_API
+int aws_log_writer_init_stderr(struct aws_log_writer *writer, struct aws_allocator *allocator);
+
+/*
+ * Initialize a log writer that sends log lines to a file. Uses C library IO.
+ */
+AWS_COMMON_API
+int aws_log_writer_init_file(
+ struct aws_log_writer *writer,
+ struct aws_allocator *allocator,
+ struct aws_log_writer_file_options *options);
+
+/*
+ * Frees all resources used by a log writer with the exception of the base structure memory
+ */
+AWS_COMMON_API
+void aws_log_writer_clean_up(struct aws_log_writer *writer);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_LOG_WRITER_H */
diff --git a/include/aws/common/logging.h b/include/aws/common/logging.h
new file mode 100644
index 0000000000000000000000000000000000000000..444465aa11066d2e7e8155315ee8b56ecc730e7e
--- /dev/null
+++ b/include/aws/common/logging.h
@@ -0,0 +1,360 @@
+#ifndef AWS_COMMON_LOGGING_H
+#define AWS_COMMON_LOGGING_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+#define AWS_LOG_LEVEL_NONE 0
+#define AWS_LOG_LEVEL_FATAL 1
+#define AWS_LOG_LEVEL_ERROR 2
+#define AWS_LOG_LEVEL_WARN 3
+#define AWS_LOG_LEVEL_INFO 4
+#define AWS_LOG_LEVEL_DEBUG 5
+#define AWS_LOG_LEVEL_TRACE 6
+
+/**
+ * Controls what log calls pass through the logger and what log calls get filtered out.
+ * If a log level has a value of X, then all log calls using a level <= X will appear, while
+ * those using a value > X will not occur.
+ *
+ * You can filter both dynamically (by setting the log level on the logger object) or statically
+ * (by defining AWS_STATIC_LOG_LEVEL to be an appropriate integer module-wide). Statically filtered
+ * log calls will be completely compiled out but require a rebuild if you want to get more detail
+ * about what's happening.
+ */
+enum aws_log_level {
+ AWS_LL_NONE = AWS_LOG_LEVEL_NONE,
+ AWS_LL_FATAL = AWS_LOG_LEVEL_FATAL,
+ AWS_LL_ERROR = AWS_LOG_LEVEL_ERROR,
+ AWS_LL_WARN = AWS_LOG_LEVEL_WARN,
+ AWS_LL_INFO = AWS_LOG_LEVEL_INFO,
+ AWS_LL_DEBUG = AWS_LOG_LEVEL_DEBUG,
+ AWS_LL_TRACE = AWS_LOG_LEVEL_TRACE,
+
+ AWS_LL_COUNT
+};
+
+/**
+ * Log subject is a way of designating the topic of logging.
+ *
+ * The general idea is to support a finer-grained approach to log level control. The primary use case
+ * is for situations that require more detailed logging within a specific domain, where enabling that detail
+ * globally leads to an untenable flood of information.
+ *
+ * For example, enable TRACE logging for tls-related log statements (handshake binary payloads), but
+ * only WARN logging everywhere else (because http payloads would blow up the log files).
+ *
+ * Log subject is an enum similar to aws error: each library has its own value-space and someone is
+ * responsible for registering the value <-> string connections.
+ */
+typedef uint32_t aws_log_subject_t;
+
+/* Each library gets space for 2^^10 log subject entries */
+enum {
+ AWS_LOG_SUBJECT_STRIDE_BITS = 10,
+};
+#define AWS_LOG_SUBJECT_STRIDE (1U << AWS_LOG_SUBJECT_STRIDE_BITS)
+#define AWS_LOG_SUBJECT_BEGIN_RANGE(x) ((x) * AWS_LOG_SUBJECT_STRIDE)
+#define AWS_LOG_SUBJECT_END_RANGE(x) (((x) + 1) * AWS_LOG_SUBJECT_STRIDE - 1)
+
+struct aws_log_subject_info {
+ aws_log_subject_t subject_id;
+ const char *subject_name;
+ const char *subject_description;
+};
+
+#define DEFINE_LOG_SUBJECT_INFO(id, name, desc) \
+ {.subject_id = (id), .subject_name = (name), .subject_description = (desc)}
+
+struct aws_log_subject_info_list {
+ struct aws_log_subject_info *subject_list;
+ size_t count;
+};
+
+enum aws_common_log_subject {
+ AWS_LS_COMMON_GENERAL = AWS_LOG_SUBJECT_BEGIN_RANGE(AWS_C_COMMON_PACKAGE_ID),
+ AWS_LS_COMMON_TASK_SCHEDULER,
+ AWS_LS_COMMON_THREAD,
+ AWS_LS_COMMON_MEMTRACE,
+ AWS_LS_COMMON_XML_PARSER,
+ AWS_LS_COMMON_IO,
+ AWS_LS_COMMON_BUS,
+ AWS_LS_COMMON_TEST,
+ AWS_LS_COMMON_JSON_PARSER,
+ AWS_LS_COMMON_CBOR,
+
+ AWS_LS_COMMON_LAST = AWS_LOG_SUBJECT_END_RANGE(AWS_C_COMMON_PACKAGE_ID)
+};
+
+struct aws_logger;
+struct aws_log_formatter;
+struct aws_log_channel;
+struct aws_log_writer;
+
+#ifdef _MSC_VER
+# pragma warning(push)
+# pragma warning(disable : 4623) /* default constructor was implicitly defined as deleted */
+# pragma warning(disable : 4626) /* assignment operator was implicitly defined as deleted */
+# pragma warning(disable : 5027) /* move assignment operator was implicitly defined as deleted */
+#endif
+
+/**
+ * We separate the log level function from the log call itself so that we can do the filter check in the macros (see
+ * below)
+ *
+ * By doing so, we make it so that the variadic format arguments are not even evaluated if the filter check does not
+ * succeed.
+ */
+struct aws_logger_vtable {
+ int (*const log)(
+ struct aws_logger *logger,
+ enum aws_log_level log_level,
+ aws_log_subject_t subject,
+ const char *format,
+ ...)
+#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
+ __attribute__((format(printf, 4, 5)))
+#endif /* non-ms compilers: TODO - find out what versions format support was added in */
+ ;
+ enum aws_log_level (*const get_log_level)(struct aws_logger *logger, aws_log_subject_t subject);
+ void (*const clean_up)(struct aws_logger *logger);
+ int (*set_log_level)(struct aws_logger *logger, enum aws_log_level);
+};
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+
+struct aws_logger {
+ struct aws_logger_vtable *vtable;
+ struct aws_allocator *allocator;
+ void *p_impl;
+};
+
+/**
+ * The base formatted logging macro that all other formatted logging macros resolve to.
+ * Checks for a logger and filters based on log level.
+ */
+#define AWS_LOGF(log_level, subject, ...) \
+ do { \
+ AWS_ASSERT(log_level > 0); \
+ struct aws_logger *logger = aws_logger_get(); \
+ if (logger != NULL && logger->vtable->get_log_level(logger, (subject)) >= (log_level)) { \
+ logger->vtable->log(logger, log_level, subject, __VA_ARGS__); \
+ } \
+ } while (0)
+/**
+ * Unconditional logging macro that takes a logger and does not do a level check or a null check. Intended for
+ * situations when you need to log many things and do a single manual level check before beginning.
+ */
+#define AWS_LOGUF(logger, log_level, subject, ...) \
+ { logger->vtable->log(logger, log_level, subject, __VA_ARGS__); }
+
+/**
+ * LOGF_ variants for each level. These are what should be used directly to do all logging.
+ *
+ * i.e.
+ *
+ * LOGF_FATAL("Device \"%s\" not found", device->name);
+ *
+ *
+ * Later we will likely expose Subject-aware variants
+ */
+#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_LOG_LEVEL_FATAL)
+# define AWS_LOGF_FATAL(subject, ...) AWS_LOGF(AWS_LL_FATAL, subject, __VA_ARGS__)
+#else
+# define AWS_LOGF_FATAL(subject, ...)
+#endif
+
+#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_LOG_LEVEL_ERROR)
+# define AWS_LOGF_ERROR(subject, ...) AWS_LOGF(AWS_LL_ERROR, subject, __VA_ARGS__)
+#else
+# define AWS_LOGF_ERROR(subject, ...)
+#endif
+
+#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_LOG_LEVEL_WARN)
+# define AWS_LOGF_WARN(subject, ...) AWS_LOGF(AWS_LL_WARN, subject, __VA_ARGS__)
+#else
+# define AWS_LOGF_WARN(subject, ...)
+#endif
+
+#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_LOG_LEVEL_INFO)
+# define AWS_LOGF_INFO(subject, ...) AWS_LOGF(AWS_LL_INFO, subject, __VA_ARGS__)
+#else
+# define AWS_LOGF_INFO(subject, ...)
+#endif
+
+#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_LOG_LEVEL_DEBUG)
+# define AWS_LOGF_DEBUG(subject, ...) AWS_LOGF(AWS_LL_DEBUG, subject, __VA_ARGS__)
+#else
+# define AWS_LOGF_DEBUG(subject, ...)
+#endif
+
+#if !defined(AWS_STATIC_LOG_LEVEL) || (AWS_STATIC_LOG_LEVEL >= AWS_LOG_LEVEL_TRACE)
+# define AWS_LOGF_TRACE(subject, ...) AWS_LOGF(AWS_LL_TRACE, subject, __VA_ARGS__)
+#else
+# define AWS_LOGF_TRACE(subject, ...)
+#endif
+
+/*
+ * Standard logger implementation composing three sub-components:
+ *
+ * The formatter takes var args input from the user and produces a formatted log line
+ * The writer takes a formatted log line and outputs it somewhere
+ * The channel is the transport between the two
+ */
+struct aws_logger_pipeline {
+ struct aws_log_formatter *formatter;
+ struct aws_log_channel *channel;
+ struct aws_log_writer *writer;
+ struct aws_allocator *allocator;
+ struct aws_atomic_var level;
+};
+
+/**
+ * Options for aws_logger_init_standard().
+ * Set `filename` to open a file for logging and close it when the logger cleans up.
+ * Set `file` to use a file that is already open, such as `stderr` or `stdout`.
+ */
+struct aws_logger_standard_options {
+ enum aws_log_level level;
+ const char *filename;
+ FILE *file;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Sets the aws logger used globally across the process. Not thread-safe. Must only be called once.
+ */
+AWS_COMMON_API
+void aws_logger_set(struct aws_logger *logger);
+
+/**
+ * Gets the aws logger used globally across the process.
+ */
+AWS_COMMON_API
+struct aws_logger *aws_logger_get(void);
+
+/**
+ * Gets the aws logger used globally across the process if the logging level is at least the inputted level.
+ *
+ * @param subject log subject to perform the level check versus, not currently used
+ * @param level logging level to check against in order to return the logger
+ * @return the current logger if the current logging level is at or more detailed then the supplied logging level
+ */
+AWS_COMMON_API
+struct aws_logger *aws_logger_get_conditional(aws_log_subject_t subject, enum aws_log_level level);
+
+/**
+ * Cleans up all resources used by the logger; simply invokes the clean_up v-function
+ */
+AWS_COMMON_API
+void aws_logger_clean_up(struct aws_logger *logger);
+
+/**
+ * Sets the current logging level for the logger. Loggers are not require to support this.
+ * @param logger logger to set the log level for
+ * @param level new log level for the logger
+ * @return AWS_OP_SUCCESS if the level was successfully set, AWS_OP_ERR otherwise
+ */
+AWS_COMMON_API
+int aws_logger_set_log_level(struct aws_logger *logger, enum aws_log_level level);
+
+/**
+ * Converts a log level to a c-string constant. Intended primarily to support building log lines that
+ * include the level in them, i.e.
+ *
+ * [ERROR] 10:34:54.642 01-31-19 - Json parse error....
+ */
+AWS_COMMON_API
+int aws_log_level_to_string(enum aws_log_level log_level, const char **level_string);
+
+/**
+ * Converts a c-string constant to a log level value. Uses case-insensitive comparison
+ * and simply iterates all possibilities until a match or nothing remains. If no match
+ * is found, AWS_OP_ERR is returned.
+ */
+AWS_COMMON_API
+int aws_string_to_log_level(const char *level_string, enum aws_log_level *log_level);
+
+/**
+ * Converts an aws_thread_id_t to a c-string. For portability, aws_thread_id_t
+ * must not be printed directly. Intended primarily to support building log
+ * lines that include the thread id in them. The parameter `buffer` must
+ * point-to a char buffer of length `bufsz == AWS_THREAD_ID_T_REPR_BUFSZ`. The
+ * thread id representation is returned in `buffer`.
+ */
+AWS_COMMON_API
+int aws_thread_id_t_to_string(aws_thread_id_t thread_id, char *buffer, size_t bufsz);
+
+/**
+ * Get subject name from log subject.
+ */
+AWS_COMMON_API
+const char *aws_log_subject_name(aws_log_subject_t subject);
+
+/**
+ * Connects log subject strings with log subject integer values
+ */
+AWS_COMMON_API
+void aws_register_log_subject_info_list(struct aws_log_subject_info_list *log_subject_list);
+
+/**
+ * Disconnects log subject strings with log subject integer values
+ */
+AWS_COMMON_API
+void aws_unregister_log_subject_info_list(struct aws_log_subject_info_list *log_subject_list);
+
+/*
+ * Initializes a pipeline logger that is built from the default formatter, a background thread-based channel, and
+ * a file writer. The default logger in almost all circumstances.
+ */
+AWS_COMMON_API
+int aws_logger_init_standard(
+ struct aws_logger *logger,
+ struct aws_allocator *allocator,
+ struct aws_logger_standard_options *options);
+
+/*
+ * Initializes a pipeline logger from components that have already been initialized. This is not an ownership transfer.
+ * After the pipeline logger is cleaned up, the components will have to manually be cleaned up by the user.
+ */
+AWS_COMMON_API
+int aws_logger_init_from_external(
+ struct aws_logger *logger,
+ struct aws_allocator *allocator,
+ struct aws_log_formatter *formatter,
+ struct aws_log_channel *channel,
+ struct aws_log_writer *writer,
+ enum aws_log_level level);
+
+/*
+ * Pipeline logger vtable for custom configurations
+ */
+AWS_COMMON_API
+extern struct aws_logger_vtable g_pipeline_logger_owned_vtable;
+
+/*
+ * Initializes a logger that does not perform any allocation during logging. Log lines larger than the internal
+ * constant are truncated. Formatting matches the standard logger. Used for memory tracing logging.
+ * If no file or filename is set in the aws_logger_standard_options, then it will use stderr.
+ */
+AWS_COMMON_API
+int aws_logger_init_noalloc(
+ struct aws_logger *logger,
+ struct aws_allocator *allocator,
+ struct aws_logger_standard_options *options);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_LOGGING_H */
diff --git a/include/aws/common/lru_cache.h b/include/aws/common/lru_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..b99551a79b250a16711e487cd752e8856b6d3348
--- /dev/null
+++ b/include/aws/common/lru_cache.h
@@ -0,0 +1,44 @@
+#ifndef AWS_COMMON_LRU_CACHE_H
+#define AWS_COMMON_LRU_CACHE_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes the Least-recently-used cache. Sets up the underlying linked hash table.
+ * Once `max_items` elements have been added, the least recently used item will be removed. For the other parameters,
+ * see aws/common/hash_table.h. Hash table semantics of these arguments are preserved.(Yes the one that was the answer
+ * to that interview question that one time).
+ */
+AWS_COMMON_API
+struct aws_cache *aws_cache_new_lru(
+ struct aws_allocator *allocator,
+ aws_hash_fn *hash_fn,
+ aws_hash_callback_eq_fn *equals_fn,
+ aws_hash_callback_destroy_fn *destroy_key_fn,
+ aws_hash_callback_destroy_fn *destroy_value_fn,
+ size_t max_items);
+
+/**
+ * Accesses the least-recently-used element, sets it to most-recently-used
+ * element, and returns the value.
+ */
+AWS_COMMON_API
+void *aws_lru_cache_use_lru_element(struct aws_cache *cache);
+
+/**
+ * Accesses the most-recently-used element and returns its value.
+ */
+AWS_COMMON_API
+void *aws_lru_cache_get_mru_element(const struct aws_cache *cache);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_LRU_CACHE_H */
diff --git a/include/aws/common/macros.h b/include/aws/common/macros.h
new file mode 100644
index 0000000000000000000000000000000000000000..03e50a218627b3364017fa166fca8246a39a7f2e
--- /dev/null
+++ b/include/aws/common/macros.h
@@ -0,0 +1,183 @@
+#ifndef AWS_COMMON_MACROS_H
+#define AWS_COMMON_MACROS_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+/* clang-format off */
+
+/* Use these macros in public header files to suppress unreasonable compiler
+ * warnings. Public header files are included by external applications,
+ * which may set their warning levels pedantically high.
+ *
+ * Developers of AWS libraries should hesitate before adding more warnings to this macro.
+ * Prefer disabling the warning within a .c file, or in the library's CFLAGS,
+ * or push/pop the warning around a single problematic declaration. */
+#if defined(_MSC_VER)
+# define AWS_PUSH_SANE_WARNING_LEVEL \
+ __pragma(warning(push)) \
+ __pragma(warning(disable : 4820)) /* padding added to struct */ \
+ __pragma(warning(disable : 4514)) /* unreferenced inline function has been removed */ \
+ __pragma(warning(disable : 5039)) /* reference to potentially throwing function passed to extern C function */
+# define AWS_POP_SANE_WARNING_LEVEL __pragma(warning(pop))
+#else
+# define AWS_PUSH_SANE_WARNING_LEVEL
+# define AWS_POP_SANE_WARNING_LEVEL
+#endif
+/* clang-format on */
+
+#ifdef __cplusplus
+# define AWS_EXTERN_C_BEGIN extern "C" {
+# define AWS_EXTERN_C_END }
+#else
+# define AWS_EXTERN_C_BEGIN
+# define AWS_EXTERN_C_END
+#endif /* __cplusplus */
+
+#define AWS_CONCAT(A, B) A##B
+#define AWS_STATIC_ASSERT0(cond, msg) typedef char AWS_CONCAT(static_assertion_, msg)[(!!(cond)) * 2 - 1]
+#define AWS_STATIC_ASSERT1(cond, line) AWS_STATIC_ASSERT0(cond, AWS_CONCAT(at_line_, line))
+#define AWS_STATIC_ASSERT(cond) AWS_STATIC_ASSERT1(cond, __LINE__)
+
+/* https://stackoverflow.com/questions/9183993/msvc-variadic-macro-expansion */
+#define GLUE(x, y) x y
+
+#define RETURN_ARG_COUNT(_1_, _2_, _3_, _4_, _5_, count, ...) count
+#define EXPAND_ARGS(args) RETURN_ARG_COUNT args
+#define COUNT_ARGS_MAX5(...) EXPAND_ARGS((__VA_ARGS__, 5, 4, 3, 2, 1, 0))
+
+#define OVERLOAD_MACRO2(name, count) name##count
+#define OVERLOAD_MACRO1(name, count) OVERLOAD_MACRO2(name, count)
+#define OVERLOAD_MACRO(name, count) OVERLOAD_MACRO1(name, count)
+
+#define CALL_OVERLOAD(name, ...) GLUE(OVERLOAD_MACRO(name, COUNT_ARGS_MAX5(__VA_ARGS__)), (__VA_ARGS__))
+
+#define CALL_OVERLOAD_TEST1(x) x
+#define CALL_OVERLOAD_TEST2(x, y) y
+#define CALL_OVERLOAD_TEST3(x, y, z) z
+#define CALL_OVERLOAD_TEST(...) CALL_OVERLOAD(CALL_OVERLOAD_TEST, __VA_ARGS__)
+AWS_STATIC_ASSERT(CALL_OVERLOAD_TEST(1) == 1);
+AWS_STATIC_ASSERT(CALL_OVERLOAD_TEST(1, 2) == 2);
+AWS_STATIC_ASSERT(CALL_OVERLOAD_TEST(1, 2, 3) == 3);
+
+enum { AWS_CACHE_LINE = 64 };
+/**
+ * Format macro for strings of a specified length.
+ * Allows non null-terminated strings to be used with the printf family of functions.
+ * Ex: printf("scheme is " PRInSTR, 4, "http://example.org"); // outputs: "scheme is http"
+ */
+#define PRInSTR "%.*s"
+
+#if defined(_MSC_VER)
+# include
+# define AWS_ALIGNED_TYPEDEF(from, to, alignment) typedef __declspec(align(alignment)) from to
+# define AWS_LIKELY(x) x
+# define AWS_UNLIKELY(x) x
+# define AWS_FORCE_INLINE __forceinline
+# define AWS_NO_INLINE __declspec(noinline)
+# define AWS_VARIABLE_LENGTH_ARRAY(type, name, length) type *name = _alloca(sizeof(type) * (length))
+# define AWS_DECLSPEC_NORETURN __declspec(noreturn)
+# define AWS_ATTRIBUTE_NORETURN
+#else
+# if defined(__GNUC__) || defined(__clang__)
+# define AWS_ALIGNED_TYPEDEF(from, to, alignment) typedef from to __attribute__((aligned(alignment)))
+# define AWS_TYPE_OF(a) __typeof__(a)
+# define AWS_LIKELY(x) __builtin_expect(!!(x), 1)
+# define AWS_UNLIKELY(x) __builtin_expect(!!(x), 0)
+# define AWS_FORCE_INLINE __attribute__((always_inline))
+# define AWS_NO_INLINE __attribute__((noinline))
+# define AWS_DECLSPEC_NORETURN
+# define AWS_ATTRIBUTE_NORETURN __attribute__((noreturn))
+# if defined(__cplusplus)
+# define AWS_VARIABLE_LENGTH_ARRAY(type, name, length) type *name = alloca(sizeof(type) * (length))
+# else
+# define AWS_VARIABLE_LENGTH_ARRAY(type, name, length) type name[length]
+# endif /* defined(__cplusplus) */
+# endif /* defined(__GNUC__) || defined(__clang__) */
+#endif /* defined(_MSC_VER) */
+
+#if defined(__has_feature)
+# if __has_feature(address_sanitizer)
+# define AWS_SUPPRESS_ASAN __attribute__((no_sanitize("address")))
+# endif
+#elif defined(__SANITIZE_ADDRESS__)
+# if defined(__GNUC__)
+# define AWS_SUPPRESS_ASAN __attribute__((no_sanitize_address))
+# elif defined(_MSC_VER)
+# define AWS_SUPPRESS_ASAN __declspec(no_sanitize_address)
+# endif
+#endif
+
+#if !defined(AWS_SUPPRESS_ASAN)
+# define AWS_SUPPRESS_ASAN
+#endif
+
+#if defined(__has_feature)
+# if __has_feature(thread_sanitizer)
+# define AWS_SUPPRESS_TSAN __attribute__((no_sanitize("thread")))
+# endif
+#elif defined(__SANITIZE_THREAD__)
+# if defined(__GNUC__)
+# define AWS_SUPPRESS_TSAN __attribute__((no_sanitize_thread))
+# else
+# define AWS_SUPPRESS_TSAN
+# endif
+#else
+# define AWS_SUPPRESS_TSAN
+#endif
+
+#if !defined(AWS_SUPPRESS_TSAN)
+# define AWS_SUPPRESS_TSAN
+#endif
+
+#if defined(__has_feature)
+# if __has_feature(undefined_behavior_sanitizer)
+# define AWS_SUPPRESS_UBSAN __attribute__((no_sanitize("undefined")))
+# endif
+#elif defined(__SANITIZE_UNDEFINED__)
+# if defined(__GNUC__)
+# define AWS_SUPPRESS_UBSAN __attribute__((no_sanitize_undefined))
+# else
+# define AWS_SUPPRESS_UBSAN
+# endif
+#else
+# define AWS_SUPPRESS_UBSAN
+#endif
+
+#if !defined(AWS_SUPPRESS_UBSAN)
+# define AWS_SUPPRESS_UBSAN
+#endif
+
+/* If this is C++, restrict isn't supported. If this is not at least C99 on gcc and clang, it isn't supported.
+ * If visual C++ building in C mode, the restrict definition is __restrict.
+ * This just figures all of that out based on who's including this header file. */
+#if defined(__cplusplus)
+# define AWS_RESTRICT
+#else
+# if defined(_MSC_VER)
+# define AWS_RESTRICT __restrict
+# else
+# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+# define AWS_RESTRICT restrict
+# else
+# define AWS_RESTRICT
+# endif /* defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L */
+# endif /* defined(_MSC_VER) */
+#endif /* defined(__cplusplus) */
+
+#if defined(_MSC_VER)
+# define AWS_THREAD_LOCAL __declspec(thread)
+#else
+# define AWS_THREAD_LOCAL __thread
+#endif
+
+#define AWS_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
+/**
+ * from a pointer and a type of the struct containing the node
+ * this will get you back to the pointer of the object. member is the name of
+ * the instance of struct aws_linked_list_node in your struct.
+ */
+#define AWS_CONTAINER_OF(ptr, type, member) ((type *)((uint8_t *)(ptr) - offsetof(type, member)))
+
+#endif /* AWS_COMMON_MACROS_H */
diff --git a/include/aws/common/math.cbmc.inl b/include/aws/common/math.cbmc.inl
new file mode 100644
index 0000000000000000000000000000000000000000..e54b22b8b93d272b84632fad019e9d2abbbe8a6a
--- /dev/null
+++ b/include/aws/common/math.cbmc.inl
@@ -0,0 +1,107 @@
+#ifndef AWS_COMMON_MATH_CBMC_INL
+#define AWS_COMMON_MATH_CBMC_INL
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+/*
+ * This header is already included, but include it again to make editor
+ * highlighting happier.
+ */
+#include
+
+AWS_EXTERN_C_BEGIN
+
+/* This header does safe operations. Supressing the checks within these functions
+ * avoids unnecessary CBMC assertions
+ */
+#pragma CPROVER check push
+#pragma CPROVER check disable "unsigned-overflow"
+
+/**
+ * Multiplies a * b. If the result overflows, returns 2^64 - 1.
+ */
+AWS_STATIC_IMPL uint64_t aws_mul_u64_saturating(uint64_t a, uint64_t b) {
+ if (__CPROVER_overflow_mult(a, b))
+ return UINT64_MAX;
+ return a * b;
+}
+
+/**
+ * If a * b overflows, returns AWS_OP_ERR; otherwise multiplies
+ * a * b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_mul_u64_checked(uint64_t a, uint64_t b, uint64_t *r) {
+ if (__CPROVER_overflow_mult(a, b))
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ *r = a * b;
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Multiplies a * b. If the result overflows, returns 2^32 - 1.
+ */
+AWS_STATIC_IMPL uint32_t aws_mul_u32_saturating(uint32_t a, uint32_t b) {
+ if (__CPROVER_overflow_mult(a, b))
+ return UINT32_MAX;
+ return a * b;
+}
+
+/**
+ * If a * b overflows, returns AWS_OP_ERR; otherwise multiplies
+ * a * b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_mul_u32_checked(uint32_t a, uint32_t b, uint32_t *r) {
+ if (__CPROVER_overflow_mult(a, b))
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ *r = a * b;
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Adds a + b. If the result overflows returns 2^64 - 1.
+ */
+AWS_STATIC_IMPL uint64_t aws_add_u64_saturating(uint64_t a, uint64_t b) {
+ if (__CPROVER_overflow_plus(a, b))
+ return UINT64_MAX;
+ return a + b;
+}
+
+/**
+ * If a + b overflows, returns AWS_OP_ERR; otherwise adds
+ * a + b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_add_u64_checked(uint64_t a, uint64_t b, uint64_t *r) {
+ if (__CPROVER_overflow_plus(a, b))
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ *r = a + b;
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Adds a + b. If the result overflows returns 2^32 - 1.
+ */
+AWS_STATIC_IMPL uint32_t aws_add_u32_saturating(uint32_t a, uint32_t b) {
+ if (__CPROVER_overflow_plus(a, b))
+ return UINT32_MAX;
+ return a + b;
+}
+
+/**
+ * If a + b overflows, returns AWS_OP_ERR; otherwise adds
+ * a + b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_add_u32_checked(uint32_t a, uint32_t b, uint32_t *r) {
+ if (__CPROVER_overflow_plus(a, b))
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ *r = a + b;
+ return AWS_OP_SUCCESS;
+}
+
+#pragma CPROVER check pop
+
+AWS_EXTERN_C_END
+
+#endif /* AWS_COMMON_MATH_CBMC_INL */
diff --git a/include/aws/common/math.fallback.inl b/include/aws/common/math.fallback.inl
new file mode 100644
index 0000000000000000000000000000000000000000..f1adc49a652d145acbf7d37966227b8aa9139c41
--- /dev/null
+++ b/include/aws/common/math.fallback.inl
@@ -0,0 +1,199 @@
+#ifndef AWS_COMMON_MATH_FALLBACK_INL
+#define AWS_COMMON_MATH_FALLBACK_INL
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+/*
+ * This header is already included, but include it again to make editor
+ * highlighting happier.
+ */
+#include
+#include
+
+AWS_EXTERN_C_BEGIN
+/**
+ * Multiplies a * b. If the result overflows, returns 2^64 - 1.
+ */
+AWS_STATIC_IMPL uint64_t aws_mul_u64_saturating(uint64_t a, uint64_t b) {
+ if (a > 0 && b > 0 && a > (UINT64_MAX / b))
+ return UINT64_MAX;
+ return a * b;
+}
+
+/**
+ * If a * b overflows, returns AWS_OP_ERR; otherwise multiplies
+ * a * b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_mul_u64_checked(uint64_t a, uint64_t b, uint64_t *r) {
+ if (a > 0 && b > 0 && a > (UINT64_MAX / b))
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ *r = a * b;
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Multiplies a * b. If the result overflows, returns 2^32 - 1.
+ */
+AWS_STATIC_IMPL uint32_t aws_mul_u32_saturating(uint32_t a, uint32_t b) {
+ if (a > 0 && b > 0 && a > (UINT32_MAX / b))
+ return UINT32_MAX;
+ return a * b;
+}
+
+/**
+ * If a * b overflows, returns AWS_OP_ERR; otherwise multiplies
+ * a * b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_mul_u32_checked(uint32_t a, uint32_t b, uint32_t *r) {
+ if (a > 0 && b > 0 && a > (UINT32_MAX / b))
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ *r = a * b;
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Adds a + b. If the result overflows returns 2^64 - 1.
+ */
+AWS_STATIC_IMPL uint64_t aws_add_u64_saturating(uint64_t a, uint64_t b) {
+ if ((b > 0) && (a > (UINT64_MAX - b)))
+ return UINT64_MAX;
+ return a + b;
+}
+
+/**
+ * If a + b overflows, returns AWS_OP_ERR; otherwise adds
+ * a + b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_add_u64_checked(uint64_t a, uint64_t b, uint64_t *r) {
+ if ((b > 0) && (a > (UINT64_MAX - b)))
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ *r = a + b;
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Adds a + b. If the result overflows returns 2^32 - 1.
+ */
+AWS_STATIC_IMPL uint32_t aws_add_u32_saturating(uint32_t a, uint32_t b) {
+ if ((b > 0) && (a > (UINT32_MAX - b)))
+ return UINT32_MAX;
+ return a + b;
+}
+
+/**
+ * If a + b overflows, returns AWS_OP_ERR; otherwise adds
+ * a + b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_add_u32_checked(uint32_t a, uint32_t b, uint32_t *r) {
+ if ((b > 0) && (a > (UINT32_MAX - b)))
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ *r = a + b;
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Search from the MSB to LSB, looking for a 1
+ */
+AWS_STATIC_IMPL size_t aws_clz_u32(uint32_t n) {
+ return aws_clz_i32((int32_t)n);
+}
+
+AWS_STATIC_IMPL size_t aws_clz_i32(int32_t n) {
+ size_t idx = 0;
+ if (n == 0) {
+ return sizeof(n) * 8;
+ }
+ /* sign bit is the first bit */
+ if (n < 0) {
+ return 0;
+ }
+ while (n >= 0) {
+ ++idx;
+ n <<= 1;
+ }
+ return idx;
+}
+
+AWS_STATIC_IMPL size_t aws_clz_u64(uint64_t n) {
+ return aws_clz_i64((int64_t)n);
+}
+
+AWS_STATIC_IMPL size_t aws_clz_i64(int64_t n) {
+ size_t idx = 0;
+ if (n == 0) {
+ return sizeof(n) * 8;
+ }
+ /* sign bit is the first bit */
+ if (n < 0) {
+ return 0;
+ }
+ while (n >= 0) {
+ ++idx;
+ n <<= 1;
+ }
+ return idx;
+}
+
+AWS_STATIC_IMPL size_t aws_clz_size(size_t n) {
+#if SIZE_BITS == 64
+ return aws_clz_u64(n);
+#else
+ return aws_clz_u32(n);
+#endif
+}
+
+/**
+ * Search from the LSB to MSB, looking for a 1
+ */
+AWS_STATIC_IMPL size_t aws_ctz_u32(uint32_t n) {
+ return aws_ctz_i32((int32_t)n);
+}
+
+AWS_STATIC_IMPL size_t aws_ctz_i32(int32_t n) {
+ int32_t idx = 0;
+ const int32_t max_bits = (int32_t)(SIZE_BITS / sizeof(uint8_t));
+ if (n == 0) {
+ return sizeof(n) * 8;
+ }
+ while (idx < max_bits) {
+ if (n & (1 << idx)) {
+ break;
+ }
+ ++idx;
+ }
+ return (size_t)idx;
+}
+
+AWS_STATIC_IMPL size_t aws_ctz_u64(uint64_t n) {
+ return aws_ctz_i64((int64_t)n);
+}
+
+AWS_STATIC_IMPL size_t aws_ctz_i64(int64_t n) {
+ int64_t idx = 0;
+ const int64_t max_bits = (int64_t)(SIZE_BITS / sizeof(uint8_t));
+ if (n == 0) {
+ return sizeof(n) * 8;
+ }
+ while (idx < max_bits) {
+ if (n & (1ULL << idx)) {
+ break;
+ }
+ ++idx;
+ }
+ return (size_t)idx;
+}
+
+AWS_STATIC_IMPL size_t aws_ctz_size(size_t n) {
+#if SIZE_BITS == 64
+ return aws_ctz_u64(n);
+#else
+ return aws_ctz_u32(n);
+#endif
+}
+
+AWS_EXTERN_C_END
+
+#endif /* AWS_COMMON_MATH_FALLBACK_INL */
diff --git a/include/aws/common/math.gcc_arm64_asm.inl b/include/aws/common/math.gcc_arm64_asm.inl
new file mode 100644
index 0000000000000000000000000000000000000000..b068fff169b1ed1883648ceece242f232cab642b
--- /dev/null
+++ b/include/aws/common/math.gcc_arm64_asm.inl
@@ -0,0 +1,184 @@
+#ifndef AWS_COMMON_MATH_GCC_ARM64_ASM_INL
+#define AWS_COMMON_MATH_GCC_ARM64_ASM_INL
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+/*
+ * This header is already included, but include it again to make editor
+ * highlighting happier.
+ */
+#include
+#include
+
+/* clang-format off */
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Multiplies a * b. If the result overflows, returns 2^64 - 1.
+ */
+AWS_STATIC_IMPL uint64_t aws_mul_u64_saturating(uint64_t a, uint64_t b) {
+ /* We can use inline assembly to do this efficiently on arm64 by doing
+ a high-mul and checking the upper 64 bits of a 64x64->128b multiply
+ are zero */
+ uint64_t tmp = 0, res = 0;
+ __asm__("umulh %x[hmul], %x[arga], %x[argb]\n"
+ "mul %x[res], %x[arga], %x[argb]\n"
+ "cmp %x[hmul], #0\n"
+ "csinv %x[res], %x[res], xzr, eq\n"
+ : /* inout: hmul is upper 64b, r is the result */ [hmul] "+&r"(tmp), [res]"+&r"(res)
+ : /* in: a and b */ [arga] "r"(a), [argb] "r"(b)
+ : /* clobbers: cc (cmp clobbers condition codes) */ "cc");
+
+ return res;
+}
+
+/**
+ * If a * b overflows, returns AWS_OP_ERR; otherwise multiplies
+ * a * b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_mul_u64_checked(uint64_t a, uint64_t b, uint64_t *r) {
+ /* We can use inline assembly to do this efficiently on arm64 by doing
+ a high-mul and checking the upper 64 bits of a 64x64->128b multiply
+ are zero */
+
+ uint64_t tmp, res;
+ __asm__("umulh %x[hmul], %x[arga], %x[argb]\n"
+ "mul %x[res], %x[arga], %x[argb]\n"
+ : /* inout: hmul is upper 64b, r is the result */ [hmul] "=&r"(tmp), [res]"=&r"(res)
+ : /* in: a and b */ [arga] "r"(a), [argb] "r"(b));
+
+ *r = res;
+ if (tmp) {
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ }
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Multiplies a * b. If the result overflows, returns 2^32 - 1.
+ */
+AWS_STATIC_IMPL uint32_t aws_mul_u32_saturating(uint32_t a, uint32_t b) {
+ /* We can use inline assembly to do this efficiently on arm64 by doing
+ a high-mul and checking the upper 32 bits of a 32x32->64b multiply
+ are zero */
+
+ uint64_t res = 0;
+ __asm__("umull %x[res], %w[arga], %w[argb]\n"
+ "cmp xzr, %x[res], lsr #32\n"
+ "csinv %w[res], %w[res], wzr, eq\n"
+ : /* inout: res contains both lower/upper 32b */ [res]"+&r"(res)
+ : /* in: a and b */ [arga] "r"(a), [argb] "r"(b)
+ : /* clobbers: cc (cmp clobbers condition codes) */ "cc");
+
+ return res & 0xffffffff;
+}
+
+/**
+ * If a * b overflows, returns AWS_OP_ERR; otherwise multiplies
+ * a * b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_mul_u32_checked(uint32_t a, uint32_t b, uint32_t *r) {
+ /* We can use inline assembly to do this efficiently on arm64 by doing
+ a high-mul and checking the upper 32 bits of a 32x32->64b multiply
+ are zero */
+
+ uint64_t res;
+ __asm__("umull %x[res], %w[arga], %w[argb]\n"
+ : /* inout: res is both upper/lower 32b */ [res]"=r"(res)
+ : /* in: a and b */ [arga] "r"(a), [argb] "r"(b));
+
+ *r = res & 0xffffffff;
+ if (res >> 32) {
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ }
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * If a + b overflows, returns AWS_OP_ERR; otherwise adds
+ * a + b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_add_u64_checked(uint64_t a, uint64_t b, uint64_t *r) {
+ /* We can use inline assembly to do this efficiently on arm64 by doing a
+ * 64b + 64b add and checking the carry out */
+
+ uint64_t res, flag;
+ __asm__("adds %x[res], %x[arga], %x[argb]\n"
+ "csinv %x[flag], xzr, xzr, cc\n"
+ : /* inout: res is the result of addition; flag is -1 if carry happened */
+ [res]"=&r"(res), [flag] "=r"(flag)
+ : /* in: a and b */ [arga] "r"(a), [argb] "r"(b)
+ : /* clobbers: cc (cmp clobbers condition codes) */ "cc");
+
+ *r = res;
+ if (flag) {
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ }
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Adds a + b. If the result overflows, returns 2^64 - 1.
+ */
+AWS_STATIC_IMPL uint64_t aws_add_u64_saturating(uint64_t a, uint64_t b) {
+ /* We can use inline assembly to do this efficiently on arm64 by doing a
+ * 64b + 64b add and checking the carry out */
+
+ uint64_t res;
+ __asm__("adds %x[res], %x[arga], %x[argb]\n"
+ "csinv %x[res], %x[res], xzr, cc\n"
+ : /* inout: res is the result */ [res]"=&r"(res)
+ : /* in: a and b */ [arga] "r"(a), [argb] "r"(b)
+ : /* clobbers: cc (cmp clobbers condition codes) */ "cc");
+
+ return res;
+}
+
+/**
+ * If a + b overflows, returns AWS_OP_ERR; otherwise adds
+ * a + b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_add_u32_checked(uint32_t a, uint32_t b, uint32_t *r) {
+ /* We can use inline assembly to do this efficiently on arm64 by doing a
+ * 32b + 32b add and checking the carry out */
+
+ uint32_t res, flag;
+ __asm__("adds %w[res], %w[arga], %w[argb]\n"
+ "csinv %w[flag], wzr, wzr, cc\n"
+ : /* inout: res is 32b result */ [res]"=&r"(res), [flag] "=r"(flag)
+ : /* in: a and b */ [arga] "r"(a), [argb] "r"(b)
+ : /* clobbers: cc (cmp clobbers condition codes) */ "cc");
+
+ *r = res;
+ if (flag) {
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ }
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Adds a + b. If the result overflows, returns 2^32 - 1.
+ */
+AWS_STATIC_IMPL uint32_t aws_add_u32_saturating(uint32_t a, uint32_t b) {
+ /* We can use inline assembly to do this efficiently on arm64 by doing a
+ * 32b + 32b add and checking the carry out */
+
+ uint32_t res = 0;
+ __asm__("adds %w[res], %w[arga], %w[argb]\n"
+ "csinv %w[res], %w[res], wzr, cc\n"
+ : /* inout: res is the result */ [res]"+&r"(res)
+ : /* in: a and b */ [arga] "r"(a), [argb] "r"(b)
+ : /* clobbers: cc (cmp clobbers condition codes) */ "cc");
+
+ return res;
+}
+
+AWS_EXTERN_C_END
+
+/* clang-format on */
+
+#endif /* AWS_COMMON_MATH_GCC_ARM64_ASM_INL */
diff --git a/include/aws/common/math.gcc_overflow.inl b/include/aws/common/math.gcc_overflow.inl
new file mode 100644
index 0000000000000000000000000000000000000000..24ce3f0e00fef650843885f384778d8366134218
--- /dev/null
+++ b/include/aws/common/math.gcc_overflow.inl
@@ -0,0 +1,115 @@
+#ifndef AWS_COMMON_MATH_GCC_OVERFLOW_INL
+#define AWS_COMMON_MATH_GCC_OVERFLOW_INL
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+/*
+ * This header is already included, but include it again to make editor
+ * highlighting happier.
+ */
+#include
+#include
+
+AWS_EXTERN_C_BEGIN
+/**
+ * Multiplies a * b. If the result overflows, returns 2^64 - 1.
+ */
+AWS_STATIC_IMPL uint64_t aws_mul_u64_saturating(uint64_t a, uint64_t b) {
+ uint64_t res;
+
+ if (__builtin_mul_overflow(a, b, &res)) {
+ res = UINT64_MAX;
+ }
+
+ return res;
+}
+
+/**
+ * If a * b overflows, returns AWS_OP_ERR; otherwise multiplies
+ * a * b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_mul_u64_checked(uint64_t a, uint64_t b, uint64_t *r) {
+ if (__builtin_mul_overflow(a, b, r)) {
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ }
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Multiplies a * b. If the result overflows, returns 2^32 - 1.
+ */
+AWS_STATIC_IMPL uint32_t aws_mul_u32_saturating(uint32_t a, uint32_t b) {
+ uint32_t res;
+
+ if (__builtin_mul_overflow(a, b, &res)) {
+ res = UINT32_MAX;
+ }
+
+ return res;
+}
+
+/**
+ * If a * b overflows, returns AWS_OP_ERR; otherwise multiplies
+ * a * b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_mul_u32_checked(uint32_t a, uint32_t b, uint32_t *r) {
+ if (__builtin_mul_overflow(a, b, r)) {
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ }
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * If a + b overflows, returns AWS_OP_ERR; otherwise adds
+ * a + b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_add_u64_checked(uint64_t a, uint64_t b, uint64_t *r) {
+ if (__builtin_add_overflow(a, b, r)) {
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ }
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Adds a + b. If the result overflows, returns 2^64 - 1.
+ */
+AWS_STATIC_IMPL uint64_t aws_add_u64_saturating(uint64_t a, uint64_t b) {
+ uint64_t res;
+
+ if (__builtin_add_overflow(a, b, &res)) {
+ res = UINT64_MAX;
+ }
+
+ return res;
+}
+
+/**
+ * If a + b overflows, returns AWS_OP_ERR; otherwise adds
+ * a + b, returns the result in *r, and returns AWS_OP_SUCCESS.
+ */
+AWS_STATIC_IMPL int aws_add_u32_checked(uint32_t a, uint32_t b, uint32_t *r) {
+ if (__builtin_add_overflow(a, b, r)) {
+ return aws_raise_error(AWS_ERROR_OVERFLOW_DETECTED);
+ }
+ return AWS_OP_SUCCESS;
+}
+
+/**
+ * Adds a + b. If the result overflows, returns 2^32 - 1.
+ */
+AWS_STATIC_IMPL uint32_t aws_add_u32_saturating(uint32_t a, uint32_t b) {
+ uint32_t res;
+
+ if (__builtin_add_overflow(a, b, &res)) {
+ res = UINT32_MAX;
+ }
+
+ return res;
+}
+
+AWS_EXTERN_C_END
+
+#endif /* AWS_COMMON_MATH_GCC_OVERFLOW_INL */
diff --git a/include/aws/common/package.h b/include/aws/common/package.h
new file mode 100644
index 0000000000000000000000000000000000000000..c93fd5109ca44cb80f45050176b950b68161e23b
--- /dev/null
+++ b/include/aws/common/package.h
@@ -0,0 +1,21 @@
+#ifndef AWS_COMMON_PACKAGE_H
+#define AWS_COMMON_PACKAGE_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+/*
+ * Preliminary cap on the number of possible aws-c-libraries participating in shared enum ranges for
+ * errors, log subjects, and other cross-library enums. Expandable as needed
+ */
+#define AWS_PACKAGE_SLOTS 32
+
+/*
+ * Each aws-c-* and aws-crt-* library has a unique package id starting from zero. These are used to macro-calculate
+ * correct ranges for the cross-library enumerations.
+ */
+#define AWS_C_COMMON_PACKAGE_ID 0
+
+#endif /* AWS_COMMON_PACKAGE_H */
diff --git a/include/aws/common/priority_queue.h b/include/aws/common/priority_queue.h
new file mode 100644
index 0000000000000000000000000000000000000000..26b35e9911ca0be02a02a28b18d0267e3a47a151
--- /dev/null
+++ b/include/aws/common/priority_queue.h
@@ -0,0 +1,205 @@
+#ifndef AWS_COMMON_PRIORITY_QUEUE_H
+#define AWS_COMMON_PRIORITY_QUEUE_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+/* The comparator should return a positive value if the second argument has a
+ * higher priority than the first; Otherwise, it should return a negative value
+ * or zero. NOTE: priority_queue pops its highest priority element first. For
+ * example: int cmp(const void *a, const void *b) { return a < b; } would result
+ * in a max heap, while: int cmp(const void *a, const void *b) { return a > b; }
+ * would result in a min heap.
+ */
+typedef int(aws_priority_queue_compare_fn)(const void *a, const void *b);
+
+struct aws_priority_queue {
+ /**
+ * predicate that determines the priority of the elements in the queue.
+ */
+ aws_priority_queue_compare_fn *pred;
+
+ /**
+ * The underlying container storing the queue elements.
+ */
+ struct aws_array_list container;
+
+ /**
+ * An array of pointers to backpointer elements. This array is initialized when
+ * the first call to aws_priority_queue_push_bp is made, and is subsequently maintained
+ * through any heap node manipulations.
+ *
+ * Each element is a struct aws_priority_queue_node *, pointing to a backpointer field
+ * owned by the calling code, or a NULL. The backpointer field is continually updated
+ * with information needed to locate and remove a specific node later on.
+ */
+ struct aws_array_list backpointers;
+};
+
+struct aws_priority_queue_node {
+ /** The current index of the node in question, or SIZE_MAX if the node has been removed. */
+ size_t current_index;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes a priority queue struct for use. This mode will grow memory automatically (exponential model)
+ * Default size is the inital size of the queue
+ * item_size is the size of each element in bytes. Mixing items types is not supported by this API.
+ * pred is the function that will be used to determine priority.
+ */
+AWS_COMMON_API
+int aws_priority_queue_init_dynamic(
+ struct aws_priority_queue *queue,
+ struct aws_allocator *alloc,
+ size_t default_size,
+ size_t item_size,
+ aws_priority_queue_compare_fn *pred);
+
+/**
+ * Initializes a priority queue struct for use. This mode will not allocate any additional memory. When the heap fills
+ * new enqueue operations will fail with AWS_ERROR_PRIORITY_QUEUE_FULL.
+ *
+ * Heaps initialized using this call do not support the aws_priority_queue_push_ref call with a non-NULL backpointer
+ * parameter.
+ *
+ * heap is the raw memory allocated for this priority_queue
+ * item_count is the maximum number of elements the raw heap can contain
+ * item_size is the size of each element in bytes. Mixing items types is not supported by this API.
+ * pred is the function that will be used to determine priority.
+ */
+AWS_COMMON_API
+void aws_priority_queue_init_static(
+ struct aws_priority_queue *queue,
+ void *heap,
+ size_t item_count,
+ size_t item_size,
+ aws_priority_queue_compare_fn *pred);
+
+/**
+ * Checks that the backpointer at a specific index of the queue is
+ * NULL or points to a correctly allocated aws_priority_queue_node.
+ */
+bool aws_priority_queue_backpointer_index_valid(const struct aws_priority_queue *const queue, size_t index);
+
+/**
+ * Checks that the backpointers of the priority queue are either NULL
+ * or correctly allocated to point at aws_priority_queue_nodes. This
+ * check is O(n), as it accesses every backpointer in a loop, and thus
+ * shouldn't be used carelessly.
+ */
+bool aws_priority_queue_backpointers_valid_deep(const struct aws_priority_queue *const queue);
+
+/**
+ * Checks that the backpointers of the priority queue satisfy validity
+ * constraints.
+ */
+bool aws_priority_queue_backpointers_valid(const struct aws_priority_queue *const queue);
+
+/**
+ * Set of properties of a valid aws_priority_queue.
+ */
+AWS_COMMON_API
+bool aws_priority_queue_is_valid(const struct aws_priority_queue *const queue);
+
+/**
+ * Cleans up any internally allocated memory and resets the struct for reuse or deletion.
+ */
+AWS_COMMON_API
+void aws_priority_queue_clean_up(struct aws_priority_queue *queue);
+
+/**
+ * Copies item into the queue and places it in the proper priority order. Complexity: O(log(n)).
+ */
+AWS_COMMON_API
+int aws_priority_queue_push(struct aws_priority_queue *queue, void *item);
+
+/**
+ * Copies item into the queue and places it in the proper priority order. Complexity: O(log(n)).
+ *
+ * If the backpointer parameter is non-null, the heap will continually update the pointed-to field
+ * with information needed to remove the node later on. *backpointer must remain valid until the node
+ * is removed from the heap, and may be updated on any mutating operation on the priority queue.
+ *
+ * If the node is removed, the backpointer will be set to a sentinel value that indicates that the
+ * node has already been removed. It is safe (and a no-op) to call aws_priority_queue_remove with
+ * such a sentinel value.
+ */
+AWS_COMMON_API
+int aws_priority_queue_push_ref(
+ struct aws_priority_queue *queue,
+ void *item,
+ struct aws_priority_queue_node *backpointer);
+
+/**
+ * Copies the element of the highest priority, and removes it from the queue.. Complexity: O(log(n)).
+ * If queue is empty, AWS_ERROR_PRIORITY_QUEUE_EMPTY will be raised.
+ */
+AWS_COMMON_API
+int aws_priority_queue_pop(struct aws_priority_queue *queue, void *item);
+
+/**
+ * Removes a specific node from the priority queue. Complexity: O(log(n))
+ * After removing a node (using either _remove or _pop), the backpointer set at push_ref time is set
+ * to a sentinel value. If this sentinel value is passed to aws_priority_queue_remove,
+ * AWS_ERROR_PRIORITY_QUEUE_BAD_NODE will be raised. Note, however, that passing uninitialized
+ * aws_priority_queue_nodes, or ones from different priority queues, results in undefined behavior.
+ */
+AWS_COMMON_API
+int aws_priority_queue_remove(struct aws_priority_queue *queue, void *item, const struct aws_priority_queue_node *node);
+
+/**
+ * Obtains a pointer to the element of the highest priority. Complexity: constant time.
+ * If queue is empty, AWS_ERROR_PRIORITY_QUEUE_EMPTY will be raised.
+ */
+AWS_COMMON_API
+int aws_priority_queue_top(const struct aws_priority_queue *queue, void **item);
+
+/**
+ * Removes all elements from the queue, but does not free internal memory.
+ */
+AWS_COMMON_API
+void aws_priority_queue_clear(struct aws_priority_queue *queue);
+
+/**
+ * Current number of elements in the queue
+ */
+AWS_COMMON_API
+size_t aws_priority_queue_size(const struct aws_priority_queue *queue);
+
+/**
+ * Current allocated capacity for the queue, in dynamic mode this grows over time, in static mode, this will never
+ * change.
+ */
+AWS_COMMON_API
+size_t aws_priority_queue_capacity(const struct aws_priority_queue *queue);
+
+/**
+ * Initializes a queue node to a default value that indicates the node is not in the queue.
+ *
+ * @param node priority queue node to initialize with a default value
+ */
+AWS_COMMON_API
+void aws_priority_queue_node_init(struct aws_priority_queue_node *node);
+
+/**
+ * Checks if a priority queue node is currently in a priority queue.
+ *
+ * @param node priority queue node to check usage for
+ *
+ * @return true if the node is in a queue, false otherwise
+ */
+AWS_COMMON_API
+bool aws_priority_queue_node_is_in_queue(const struct aws_priority_queue_node *node);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_PRIORITY_QUEUE_H */
diff --git a/include/aws/common/ref_count.h b/include/aws/common/ref_count.h
new file mode 100644
index 0000000000000000000000000000000000000000..43fbde5e549f8b646dac447c33fb11b667c96684
--- /dev/null
+++ b/include/aws/common/ref_count.h
@@ -0,0 +1,56 @@
+#ifndef AWS_COMMON_REF_COUNT_H
+#define AWS_COMMON_REF_COUNT_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+/*
+ * A utility type for making ref-counted types, reminiscent of std::shared_ptr in C++
+ */
+struct aws_ref_count {
+ struct aws_atomic_var ref_count;
+ void *object;
+ aws_simple_completion_callback *on_zero_fn;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes a ref-counter structure. After initialization, the ref count will be 1.
+ *
+ * @param ref_count ref-counter to initialize
+ * @param object object being ref counted
+ * @param on_zero_fn function to invoke when the ref count reaches zero
+ */
+AWS_COMMON_API void aws_ref_count_init(
+ struct aws_ref_count *ref_count,
+ void *object,
+ aws_simple_completion_callback *on_zero_fn);
+
+/**
+ * Increments a ref-counter's ref count
+ *
+ * @param ref_count ref-counter to increment the count for
+ * @return the object being ref-counted
+ */
+AWS_COMMON_API void *aws_ref_count_acquire(struct aws_ref_count *ref_count);
+
+/**
+ * Decrements a ref-counter's ref count. Invokes the on_zero callback if the ref count drops to zero
+ * @param ref_count ref-counter to decrement the count for
+ * @return the value of the decremented ref count
+ */
+AWS_COMMON_API size_t aws_ref_count_release(struct aws_ref_count *ref_count);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_REF_COUNT_H */
diff --git a/include/aws/common/ring_buffer.h b/include/aws/common/ring_buffer.h
new file mode 100644
index 0000000000000000000000000000000000000000..e798d5d1d2b84aaa0c73d5957f2f18f5942ba700
--- /dev/null
+++ b/include/aws/common/ring_buffer.h
@@ -0,0 +1,104 @@
+#ifndef AWS_COMMON_RING_BUFFER_H
+#define AWS_COMMON_RING_BUFFER_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+/**
+ * Lockless ring buffer implementation that is thread safe assuming a single thread acquires and a single thread
+ * releases. For any other use case (other than the single-threaded use-case), you must manage thread-safety manually.
+ *
+ * Also, a very important note: release must happen in the same order as acquire. If you do not your application, and
+ * possibly computers within a thousand mile radius, may die terrible deaths, and the local drinking water will be
+ * poisoned for generations with fragments of what is left of your radioactive corrupted memory.
+ */
+struct aws_ring_buffer {
+ struct aws_allocator *allocator;
+ uint8_t *allocation;
+ struct aws_atomic_var head;
+ struct aws_atomic_var tail;
+ uint8_t *allocation_end;
+};
+
+struct aws_byte_buf;
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes a ring buffer with an allocation of size `size`. Returns AWS_OP_SUCCESS on a successful initialization,
+ * AWS_OP_ERR otherwise.
+ */
+AWS_COMMON_API int aws_ring_buffer_init(struct aws_ring_buffer *ring_buf, struct aws_allocator *allocator, size_t size);
+
+/*
+ * Checks whether atomic_ptr correctly points to a memory location within the bounds of the aws_ring_buffer
+ */
+AWS_STATIC_IMPL bool aws_ring_buffer_check_atomic_ptr(
+ const struct aws_ring_buffer *ring_buf,
+ const uint8_t *atomic_ptr);
+/**
+ * Checks whether the ring buffer is empty
+ */
+AWS_STATIC_IMPL bool aws_ring_buffer_is_empty(const struct aws_ring_buffer *ring_buf);
+
+/**
+ * Evaluates the set of properties that define the shape of all valid aws_ring_buffer structures.
+ * It is also a cheap check, in the sense it run in constant time (i.e., no loops or recursion).
+ */
+AWS_STATIC_IMPL bool aws_ring_buffer_is_valid(const struct aws_ring_buffer *ring_buf);
+
+/**
+ * Cleans up the ring buffer's resources.
+ */
+AWS_COMMON_API void aws_ring_buffer_clean_up(struct aws_ring_buffer *ring_buf);
+
+/**
+ * Attempts to acquire `requested_size` buffer and stores the result in `dest` if successful. Returns AWS_OP_SUCCESS if
+ * the requested size was available for use, AWS_OP_ERR otherwise.
+ */
+AWS_COMMON_API int aws_ring_buffer_acquire(
+ struct aws_ring_buffer *ring_buf,
+ size_t requested_size,
+ struct aws_byte_buf *dest);
+
+/**
+ * Attempts to acquire `requested_size` buffer and stores the result in `dest` if successful. If not available, it will
+ * attempt to acquire anywhere from 1 byte to `requested_size`. Returns AWS_OP_SUCCESS if some buffer space is available
+ * for use, AWS_OP_ERR otherwise.
+ */
+AWS_COMMON_API int aws_ring_buffer_acquire_up_to(
+ struct aws_ring_buffer *ring_buf,
+ size_t minimum_size,
+ size_t requested_size,
+ struct aws_byte_buf *dest);
+
+/**
+ * Releases `buf` back to the ring buffer for further use. RELEASE MUST HAPPEN in the SAME ORDER AS ACQUIRE.
+ * If you do not, your application, and possibly computers within a thousand mile radius, may die terrible deaths,
+ * and the local drinking water will be poisoned for generations
+ * with fragments of what is left of your radioactive corrupted memory.
+ */
+AWS_COMMON_API void aws_ring_buffer_release(struct aws_ring_buffer *ring_buffer, struct aws_byte_buf *buf);
+
+/**
+ * Returns true if the memory in `buf` was vended by this ring buffer, false otherwise.
+ * Make sure `buf->buffer` and `ring_buffer->allocation` refer to the same memory region.
+ */
+AWS_COMMON_API bool aws_ring_buffer_buf_belongs_to_pool(
+ const struct aws_ring_buffer *ring_buffer,
+ const struct aws_byte_buf *buf);
+
+AWS_EXTERN_C_END
+
+#ifndef AWS_NO_STATIC_IMPL
+# include
+#endif /* AWS_NO_STATIC_IMPL */
+
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_RING_BUFFER_H */
diff --git a/include/aws/common/ring_buffer.inl b/include/aws/common/ring_buffer.inl
new file mode 100644
index 0000000000000000000000000000000000000000..34e76a4a1390504cd5076ddab92351ecf875a30b
--- /dev/null
+++ b/include/aws/common/ring_buffer.inl
@@ -0,0 +1,44 @@
+#ifndef AWS_COMMON_RING_BUFFER_INL
+#define AWS_COMMON_RING_BUFFER_INL
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+AWS_EXTERN_C_BEGIN
+/*
+ * Checks whether atomic_ptr correctly points to a memory location within the bounds of the aws_ring_buffer
+ */
+AWS_STATIC_IMPL bool aws_ring_buffer_check_atomic_ptr(
+ const struct aws_ring_buffer *ring_buf,
+ const uint8_t *atomic_ptr) {
+ return ((atomic_ptr != NULL) && (atomic_ptr >= ring_buf->allocation && atomic_ptr <= ring_buf->allocation_end));
+}
+
+/**
+ * Checks whether the ring buffer is empty
+ */
+AWS_STATIC_IMPL bool aws_ring_buffer_is_empty(const struct aws_ring_buffer *ring_buf) {
+ uint8_t *head = (uint8_t *)aws_atomic_load_ptr(&ring_buf->head);
+ uint8_t *tail = (uint8_t *)aws_atomic_load_ptr(&ring_buf->tail);
+ return head == tail;
+}
+
+/**
+ * Evaluates the set of properties that define the shape of all valid aws_ring_buffer structures.
+ * It is also a cheap check, in the sense it run in constant time (i.e., no loops or recursion).
+ */
+AWS_STATIC_IMPL bool aws_ring_buffer_is_valid(const struct aws_ring_buffer *ring_buf) {
+ uint8_t *head = (uint8_t *)aws_atomic_load_ptr(&ring_buf->head);
+ uint8_t *tail = (uint8_t *)aws_atomic_load_ptr(&ring_buf->tail);
+ bool head_in_range = aws_ring_buffer_check_atomic_ptr(ring_buf, head);
+ bool tail_in_range = aws_ring_buffer_check_atomic_ptr(ring_buf, tail);
+ /* if head points-to the first element of the buffer then tail must too */
+ bool valid_head_tail = (head != ring_buf->allocation) || (tail == ring_buf->allocation);
+ return ring_buf && (ring_buf->allocation != NULL) && head_in_range && tail_in_range && valid_head_tail &&
+ (ring_buf->allocator != NULL);
+}
+AWS_EXTERN_C_END
+#endif /* AWS_COMMON_RING_BUFFER_INL */
diff --git a/include/aws/common/rw_lock.h b/include/aws/common/rw_lock.h
new file mode 100644
index 0000000000000000000000000000000000000000..3ee778537688d0c930ce578143070c750b1ca3e3
--- /dev/null
+++ b/include/aws/common/rw_lock.h
@@ -0,0 +1,71 @@
+#ifndef AWS_COMMON_RW_LOCK_H
+#define AWS_COMMON_RW_LOCK_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#ifdef _WIN32
+/* NOTE: Do not use this macro before including windows.h */
+# define AWSSRW_TO_WINDOWS(pCV) (PSRWLOCK) pCV
+#else
+# include
+#endif
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_rw_lock {
+#ifdef _WIN32
+ void *lock_handle;
+#else
+ pthread_rwlock_t lock_handle;
+#endif
+};
+
+#ifdef _WIN32
+# define AWS_RW_LOCK_INIT {.lock_handle = NULL}
+#else
+# define AWS_RW_LOCK_INIT {.lock_handle = PTHREAD_RWLOCK_INITIALIZER}
+#endif
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Initializes a new platform instance of mutex.
+ */
+AWS_COMMON_API int aws_rw_lock_init(struct aws_rw_lock *lock);
+
+/**
+ * Cleans up internal resources.
+ */
+AWS_COMMON_API void aws_rw_lock_clean_up(struct aws_rw_lock *lock);
+
+/**
+ * Blocks until it acquires the lock. While on some platforms such as Windows,
+ * this may behave as a reentrant mutex, you should not treat it like one. On
+ * platforms it is possible for it to be non-reentrant, it will be.
+ */
+AWS_COMMON_API int aws_rw_lock_rlock(struct aws_rw_lock *lock);
+AWS_COMMON_API int aws_rw_lock_wlock(struct aws_rw_lock *lock);
+
+/**
+ * Attempts to acquire the lock but returns immediately if it can not.
+ * While on some platforms such as Windows, this may behave as a reentrant mutex,
+ * you should not treat it like one. On platforms it is possible for it to be non-reentrant, it will be.
+ * Note: For windows, minimum support server version is Windows Server 2008 R2 [desktop apps | UWP apps]
+ */
+AWS_COMMON_API int aws_rw_lock_try_rlock(struct aws_rw_lock *lock);
+AWS_COMMON_API int aws_rw_lock_try_wlock(struct aws_rw_lock *lock);
+
+/**
+ * Releases the lock.
+ */
+AWS_COMMON_API int aws_rw_lock_runlock(struct aws_rw_lock *lock);
+AWS_COMMON_API int aws_rw_lock_wunlock(struct aws_rw_lock *lock);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_RW_LOCK_H */
diff --git a/include/aws/common/statistics.h b/include/aws/common/statistics.h
new file mode 100644
index 0000000000000000000000000000000000000000..efeed7228010cea76a6c5067da466ca5506aa1d6
--- /dev/null
+++ b/include/aws/common/statistics.h
@@ -0,0 +1,146 @@
+#ifndef AWS_COMMON_STATISTICS_H
+#define AWS_COMMON_STATISTICS_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_array_list;
+
+typedef uint32_t aws_crt_statistics_category_t;
+
+/* Each library gets space for 2^^8 category entries */
+enum {
+ AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS = 8,
+};
+
+#define AWS_CRT_STATISTICS_CATEGORY_STRIDE (1U << AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS)
+#define AWS_CRT_STATISTICS_CATEGORY_BEGIN_RANGE(x) ((x) * AWS_CRT_STATISTICS_CATEGORY_STRIDE)
+#define AWS_CRT_STATISTICS_CATEGORY_END_RANGE(x) (((x) + 1) * AWS_CRT_STATISTICS_CATEGORY_STRIDE - 1)
+
+/**
+ * The common-specific range of the aws_crt_statistics_category cross-library enum.
+ *
+ * This enum functions as an RTTI value that lets statistics handler's interpret (via cast) a
+ * specific statistics structure if the RTTI value is understood.
+ *
+ * Common doesn't have any statistics structures presently, so its range is essentially empty.
+ *
+ */
+enum aws_crt_common_statistics_category {
+ AWSCRT_STAT_CAT_INVALID = AWS_CRT_STATISTICS_CATEGORY_BEGIN_RANGE(AWS_C_COMMON_PACKAGE_ID)
+};
+
+/**
+ * Pattern-struct that functions as a base "class" for all statistics structures. To conform
+ * to the pattern, a statistics structure must have its first member be the category. In that
+ * case it becomes "safe" to cast from aws_crt_statistics_base to the specific statistics structure
+ * based on the category value.
+ */
+struct aws_crt_statistics_base {
+ aws_crt_statistics_category_t category;
+};
+
+/**
+ * The start and end time, in milliseconds-since-epoch, that a set of statistics was gathered over.
+ */
+struct aws_crt_statistics_sample_interval {
+ uint64_t begin_time_ms;
+ uint64_t end_time_ms;
+};
+
+struct aws_crt_statistics_handler;
+
+/*
+ * Statistics intake function. The array_list is a list of pointers to aws_crt_statistics_base "derived" (via
+ * pattern) objects. The handler should iterate the list and downcast elements whose RTTI category it understands,
+ * while skipping those it does not understand.
+ */
+typedef void(aws_crt_statistics_handler_process_statistics_fn)(
+ struct aws_crt_statistics_handler *handler,
+ struct aws_crt_statistics_sample_interval *interval,
+ struct aws_array_list *stats,
+ void *context);
+
+/*
+ * Destroys a statistics handler implementation
+ */
+typedef void(aws_crt_statistics_handler_destroy_fn)(struct aws_crt_statistics_handler *handler);
+
+/*
+ * The period, in milliseconds, that the handler would like to be informed of statistics. Statistics generators are
+ * not required to honor this value, but should if able.
+ */
+typedef uint64_t(aws_crt_statistics_handler_get_report_interval_ms_fn)(struct aws_crt_statistics_handler *);
+
+/**
+ * Vtable for functions that all statistics handlers must implement
+ */
+struct aws_crt_statistics_handler_vtable {
+ aws_crt_statistics_handler_process_statistics_fn *process_statistics;
+ aws_crt_statistics_handler_destroy_fn *destroy;
+ aws_crt_statistics_handler_get_report_interval_ms_fn *get_report_interval_ms;
+};
+
+/**
+ * Base structure for all statistics handler implementations.
+ *
+ * A statistics handler is an object that listens to a stream of polymorphic (via the category RTTI enum) statistics
+ * structures emitted from some arbitrary source. In the initial implementation, statistics handlers are primarily
+ * attached to channels, where they monitor IO throughput and state data (from channel handlers) to determine a
+ * connection's health.
+ *
+ * Statistics handlers are a generalization of the timeout and bandwidth filters that are often associated with
+ * SDK network connections. Configurable, default implementations are defined at the protocol level (http, etc...)
+ * where they can be attached at connection (channel) creation time.
+ */
+struct aws_crt_statistics_handler {
+ struct aws_crt_statistics_handler_vtable *vtable;
+ struct aws_allocator *allocator;
+ void *impl;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Submits a list of statistics objects to a statistics handler for processing
+ *
+ * handler - the statistics handler that will process the statistics objects
+ * interval - time period over which the statistics were gathered
+ * stats - list of pointers to structures that can be case to aws_crt_statistics_base (i.e. have category as a first
+ * member)
+ * context - (optional) additional context specific to where the statistics handler has been attached
+ */
+AWS_COMMON_API
+void aws_crt_statistics_handler_process_statistics(
+ struct aws_crt_statistics_handler *handler,
+ struct aws_crt_statistics_sample_interval *interval,
+ struct aws_array_list *stats,
+ void *context);
+
+/**
+ * Queries the frequency (via an interval in milliseconds) which a statistics handler would like to be informed
+ * of statistics.
+ */
+AWS_COMMON_API
+uint64_t aws_crt_statistics_handler_get_report_interval_ms(struct aws_crt_statistics_handler *handler);
+
+/**
+ * completely destroys a statistics handler. The handler's cleanup function must clean up the impl portion completely
+ * (including its allocation, if done separately).
+ */
+AWS_COMMON_API
+void aws_crt_statistics_handler_destroy(struct aws_crt_statistics_handler *handler);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_STATISTICS_H */
diff --git a/include/aws/common/stdbool.h b/include/aws/common/stdbool.h
new file mode 100644
index 0000000000000000000000000000000000000000..f022bfe348f4a9f6a63f6ae327851a8166d654b8
--- /dev/null
+++ b/include/aws/common/stdbool.h
@@ -0,0 +1,30 @@
+/* clang-format off */
+/* clang-format gets confused by the #define bool line, and gives crazy indenting */
+#ifndef AWS_COMMON_STDBOOL_H
+#define AWS_COMMON_STDBOOL_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#ifndef NO_STDBOOL
+# include /* NOLINT(fuchsia-restrict-system-includes) */
+#else
+# ifndef __cplusplus
+# define bool _Bool
+# define true 1
+# define false 0
+# elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
+# define _Bool bool
+# if __cplusplus < 201103L
+/* For C++98, define bool, false, true as a GNU extension. */
+# define bool bool
+# define false false
+# define true true
+# endif /* __cplusplus < 201103L */
+# endif /* __cplusplus */
+#endif /* NO_STDBOOL */
+
+#endif /* AWS_COMMON_STDBOOL_H */
+/* clang-format on */
diff --git a/include/aws/common/system_info.h b/include/aws/common/system_info.h
new file mode 100644
index 0000000000000000000000000000000000000000..91da41f9d8f607a46c082710166b19ed60319063
--- /dev/null
+++ b/include/aws/common/system_info.h
@@ -0,0 +1,155 @@
+#ifndef AWS_COMMON_SYSTEM_INFO_H
+#define AWS_COMMON_SYSTEM_INFO_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+enum aws_platform_os {
+ AWS_PLATFORM_OS_WINDOWS,
+ AWS_PLATFORM_OS_MAC,
+ AWS_PLATFORM_OS_UNIX,
+};
+
+struct aws_cpu_info {
+ int32_t cpu_id;
+ bool suspected_hyper_thread;
+};
+
+struct aws_system_environment;
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Allocates and initializes information about the system the current process is executing on.
+ * If successful returns an instance of aws_system_environment. If it fails, it will return NULL.
+ *
+ * Note: This api is used internally and is still early in its evolution.
+ * It may change in incompatible ways in the future.
+ */
+AWS_COMMON_API
+struct aws_system_environment *aws_system_environment_load(struct aws_allocator *allocator);
+
+AWS_COMMON_API
+struct aws_system_environment *aws_system_environment_acquire(struct aws_system_environment *env);
+
+AWS_COMMON_API
+void aws_system_environment_release(struct aws_system_environment *env);
+
+/**
+ * Returns the virtualization vendor for the specified compute environment, e.g. "Xen, Amazon EC2, etc..."
+ *
+ * The return value may be empty and in that case no vendor was detected.
+ */
+AWS_COMMON_API
+struct aws_byte_cursor aws_system_environment_get_virtualization_vendor(const struct aws_system_environment *env);
+
+/**
+ * Returns the product name for the specified compute environment. For example, the Amazon EC2 Instance type.
+ *
+ * The return value may be empty and in that case no vendor was detected.
+ */
+AWS_COMMON_API
+struct aws_byte_cursor aws_system_environment_get_virtualization_product_name(const struct aws_system_environment *env);
+
+/**
+ * Returns the number of processors for the specified compute environment.
+ */
+AWS_COMMON_API
+size_t aws_system_environment_get_processor_count(struct aws_system_environment *env);
+
+/**
+ * Returns the number of separate cpu groupings (multi-socket configurations or NUMA).
+ */
+AWS_COMMON_API
+size_t aws_system_environment_get_cpu_group_count(const struct aws_system_environment *env);
+
+/* Returns the OS this was built under */
+AWS_COMMON_API
+enum aws_platform_os aws_get_platform_build_os(void);
+
+/* Returns the number of online processors available for usage. */
+AWS_COMMON_API
+size_t aws_system_info_processor_count(void);
+
+/**
+ * Returns the logical processor groupings on the system (such as multiple numa nodes).
+ */
+AWS_COMMON_API
+uint16_t aws_get_cpu_group_count(void);
+
+/**
+ * For a group, returns the number of CPUs it contains.
+ */
+AWS_COMMON_API
+size_t aws_get_cpu_count_for_group(uint16_t group_idx);
+
+/**
+ * Fills in cpu_ids_array with the cpu_id's for the group. To obtain the size to allocate for cpu_ids_array
+ * and the value for argument for cpu_ids_array_length, call aws_get_cpu_count_for_group().
+ */
+AWS_COMMON_API
+void aws_get_cpu_ids_for_group(uint16_t group_idx, struct aws_cpu_info *cpu_ids_array, size_t cpu_ids_array_length);
+
+/* Returns true if a debugger is currently attached to the process. */
+AWS_COMMON_API
+bool aws_is_debugger_present(void);
+
+/* If a debugger is attached to the process, trip a breakpoint. */
+AWS_COMMON_API
+void aws_debug_break(void);
+
+#if defined(AWS_HAVE_EXECINFO) || defined(_WIN32) || defined(__APPLE__)
+# define AWS_BACKTRACE_STACKS_AVAILABLE
+#endif
+
+/*
+ * Records a stack trace from the call site.
+ * Returns the number of stack entries/stack depth captured, or 0 if the operation
+ * is not supported on this platform
+ */
+AWS_COMMON_API
+size_t aws_backtrace(void **stack_frames, size_t num_frames);
+
+/*
+ * Converts stack frame pointers to symbols, if symbols are available
+ * Returns an array up to stack_depth long, that needs to be free()ed.
+ * stack_depth should be the length of frames.
+ * Returns NULL if the platform does not support stack frame translation
+ * or an error occurs
+ */
+char **aws_backtrace_symbols(void *const *stack_frames, size_t stack_depth);
+
+/*
+ * Converts stack frame pointers to symbols, using all available system
+ * tools to try to produce a human readable result. This call will not be
+ * quick, as it shells out to addr2line or similar tools.
+ * On Windows, this is the same as aws_backtrace_symbols()
+ * Returns an array up to stack_depth long that needs to be free()ed. Missing
+ * frames will be NULL.
+ * Returns NULL if the platform does not support stack frame translation
+ * or an error occurs
+ */
+char **aws_backtrace_addr2line(void *const *stack_frames, size_t stack_depth);
+
+/**
+ * Print a backtrace from either the current stack, or (if provided) the current exception/signal
+ * call_site_data is siginfo_t* on POSIX, and LPEXCEPTION_POINTERS on Windows, and can be null
+ */
+AWS_COMMON_API
+void aws_backtrace_print(FILE *fp, void *call_site_data);
+
+/* Log the callstack from the current stack to the currently configured aws_logger */
+AWS_COMMON_API
+void aws_backtrace_log(int log_level);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_SYSTEM_INFO_H */
diff --git a/include/aws/common/system_resource_util.h b/include/aws/common/system_resource_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..ffe8d53e4fac6662213fb3f4c3c497e0af62302e
--- /dev/null
+++ b/include/aws/common/system_resource_util.h
@@ -0,0 +1,30 @@
+#ifndef AWS_COMMON_SYSTEM_RESOURCE_UTIL_H
+#define AWS_COMMON_SYSTEM_RESOURCE_UTIL_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+AWS_EXTERN_C_BEGIN
+
+struct aws_memory_usage_stats {
+ size_t maxrss; /* max resident set size in kilobytes since program start */
+ size_t page_faults; /* num of page faults since program start */
+
+ size_t _reserved[8];
+};
+
+/*
+ * Get memory usage for current process.
+ * Raises AWS_ERROR_SYS_CALL_FAILURE on failure.
+ */
+AWS_COMMON_API int aws_init_memory_usage_for_current_process(struct aws_memory_usage_stats *memory_usage);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_SYSTEM_RESOURCE_UTIL_H */
diff --git a/include/aws/common/task_scheduler.h b/include/aws/common/task_scheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..a51d6e41e71506996a8332f0c5297553e67adce4
--- /dev/null
+++ b/include/aws/common/task_scheduler.h
@@ -0,0 +1,132 @@
+#ifndef AWS_COMMON_TASK_SCHEDULER_H
+#define AWS_COMMON_TASK_SCHEDULER_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_task;
+
+typedef enum aws_task_status {
+ AWS_TASK_STATUS_RUN_READY,
+ AWS_TASK_STATUS_CANCELED,
+} aws_task_status;
+
+/**
+ * A scheduled function.
+ */
+typedef void(aws_task_fn)(struct aws_task *task, void *arg, enum aws_task_status);
+
+/*
+ * A task object.
+ * Once added to the scheduler, a task must remain in memory until its function is executed.
+ */
+struct aws_task {
+ aws_task_fn *fn;
+ void *arg;
+ uint64_t timestamp;
+ struct aws_linked_list_node node;
+ struct aws_priority_queue_node priority_queue_node;
+ const char *type_tag;
+
+ /* honor the ABI compat */
+ union {
+ bool scheduled;
+ size_t reserved;
+ } abi_extension;
+};
+
+struct aws_task_scheduler {
+ struct aws_allocator *alloc;
+ struct aws_priority_queue timed_queue; /* Tasks scheduled to run at specific times */
+ struct aws_linked_list timed_list; /* If timed_queue runs out of memory, further timed tests are stored here */
+ struct aws_linked_list asap_list; /* Tasks scheduled to run as soon as possible */
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Init an aws_task
+ */
+AWS_COMMON_API
+void aws_task_init(struct aws_task *task, aws_task_fn *fn, void *arg, const char *type_tag);
+
+/*
+ * Runs or cancels a task
+ */
+AWS_COMMON_API
+void aws_task_run(struct aws_task *task, enum aws_task_status status);
+
+/**
+ * Initializes a task scheduler instance.
+ */
+AWS_COMMON_API
+int aws_task_scheduler_init(struct aws_task_scheduler *scheduler, struct aws_allocator *alloc);
+
+/**
+ * Empties and executes all queued tasks, passing the AWS_TASK_STATUS_CANCELED status to the task function.
+ * Cleans up any memory allocated, and prepares the instance for reuse or deletion.
+ */
+AWS_COMMON_API
+void aws_task_scheduler_clean_up(struct aws_task_scheduler *scheduler);
+
+AWS_COMMON_API
+bool aws_task_scheduler_is_valid(const struct aws_task_scheduler *scheduler);
+
+/**
+ * Returns whether the scheduler has any scheduled tasks.
+ * next_task_time (optional) will be set to time of the next task, note that 0 will be set if tasks were
+ * added via aws_task_scheduler_schedule_now() and UINT64_MAX will be set if no tasks are scheduled at all.
+ */
+AWS_COMMON_API
+bool aws_task_scheduler_has_tasks(const struct aws_task_scheduler *scheduler, uint64_t *next_task_time);
+
+/**
+ * Schedules a task to run immediately.
+ * The task should not be cleaned up or modified until its function is executed.
+ */
+AWS_COMMON_API
+void aws_task_scheduler_schedule_now(struct aws_task_scheduler *scheduler, struct aws_task *task);
+
+/**
+ * Schedules a task to run at time_to_run.
+ * The task should not be cleaned up or modified until its function is executed.
+ */
+AWS_COMMON_API
+void aws_task_scheduler_schedule_future(
+ struct aws_task_scheduler *scheduler,
+ struct aws_task *task,
+ uint64_t time_to_run);
+
+/**
+ * Removes task from the scheduler and invokes the task with the AWS_TASK_STATUS_CANCELED status.
+ */
+AWS_COMMON_API
+void aws_task_scheduler_cancel_task(struct aws_task_scheduler *scheduler, struct aws_task *task);
+
+/**
+ * Sequentially execute all tasks scheduled to run at, or before current_time.
+ * AWS_TASK_STATUS_RUN_READY will be passed to the task function as the task status.
+ *
+ * If a task schedules another task, the new task will not be executed until the next call to this function.
+ */
+AWS_COMMON_API
+void aws_task_scheduler_run_all(struct aws_task_scheduler *scheduler, uint64_t current_time);
+
+/**
+ * Convert a status value to a c-string suitable for logging
+ */
+AWS_COMMON_API
+const char *aws_task_status_to_c_str(enum aws_task_status status);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_TASK_SCHEDULER_H */
diff --git a/include/aws/common/thread.h b/include/aws/common/thread.h
new file mode 100644
index 0000000000000000000000000000000000000000..84180e69030c4c35e15607ccb2f04e967586d29b
--- /dev/null
+++ b/include/aws/common/thread.h
@@ -0,0 +1,270 @@
+#ifndef AWS_COMMON_THREAD_H
+#define AWS_COMMON_THREAD_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+#include
+
+#ifndef _WIN32
+# include
+#endif
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+enum aws_thread_detach_state {
+ AWS_THREAD_NOT_CREATED = 1,
+ AWS_THREAD_JOINABLE,
+ AWS_THREAD_JOIN_COMPLETED,
+ AWS_THREAD_MANAGED,
+};
+
+/**
+ * Specifies the join strategy used on an aws_thread, which in turn controls whether or not a thread participates
+ * in the managed thread system. The managed thread system provides logic to guarantee a join on all participating
+ * threads at the cost of laziness (the user cannot control when joins happen).
+ *
+ * Manual - thread does not participate in the managed thread system; any joins must be done by the user. This
+ * is the default. The user must call aws_thread_clean_up(), but only after any desired join operation has completed.
+ * Not doing so will cause the windows handle to leak.
+ *
+ * Managed - the managed thread system will automatically perform a join some time after the thread's run function
+ * has completed. It is an error to call aws_thread_join on a thread configured with the managed join strategy. The
+ * managed thread system will call aws_thread_clean_up() on the thread after the background join has completed.
+ *
+ * Additionally, an API exists, aws_thread_join_all_managed(), which blocks and returns when all outstanding threads
+ * with the managed strategy have fully joined. This API is useful for tests (rather than waiting for many individual
+ * signals) and program shutdown or DLL unload. This API is automatically invoked by the common library clean up
+ * function. If the common library clean up is called from a managed thread, this will cause deadlock.
+ *
+ * Lazy thread joining is done only when threads finish their run function or when the user calls
+ * aws_thread_join_all_managed(). This means it may be a long time between thread function completion and the join
+ * being applied, but the queue of unjoined threads is always one or fewer so there is no critical resource
+ * backlog.
+ *
+ * Currently, only event loop group async cleanup and host resolver threads participate in the managed thread system.
+ * Additionally, event loop threads will increment and decrement the pending join count (they are manually joined
+ * internally) in order to have an accurate view of internal thread usage and also to prevent failure to release
+ * an event loop group fully from allowing aws_thread_join_all_managed() from running to completion when its
+ * intent is such that it should block instead.
+ */
+enum aws_thread_join_strategy {
+ AWS_TJS_MANUAL = 0,
+ AWS_TJS_MANAGED,
+};
+
+/**
+ * Thread names should be 15 characters or less.
+ * Longer names will not display on Linux.
+ * This length does not include a null terminator.
+ */
+#define AWS_THREAD_NAME_RECOMMENDED_STRLEN 15
+
+struct aws_thread_options {
+ size_t stack_size;
+ /* default is -1. If you set this to anything >= 0, and the platform supports it, the thread will be pinned to
+ * that cpu. Also, we assume you're doing this for memory throughput purposes. On unix systems,
+ * If libnuma.so is available, upon the thread launching, the memory policy for that thread will be set to
+ * allocate on the numa node that cpu-core is on.
+ *
+ * On windows, this will cause the thread affinity to be set, but currently we don't do anything to tell the OS
+ * how to allocate memory on a node.
+ *
+ * On Apple and Android platforms, this setting doesn't do anything at all.
+ */
+ int32_t cpu_id;
+
+ enum aws_thread_join_strategy join_strategy;
+
+ /**
+ * Thread name, for debugging purpose.
+ * The length should not exceed AWS_THREAD_NAME_RECOMMENDED_STRLEN(15)
+ * if you want it to display properly on all platforms.
+ */
+ struct aws_byte_cursor name;
+};
+
+#ifdef _WIN32
+typedef union {
+ void *ptr;
+} aws_thread_once;
+# define AWS_THREAD_ONCE_STATIC_INIT {NULL}
+typedef unsigned long aws_thread_id_t;
+#else
+typedef pthread_once_t aws_thread_once;
+# define AWS_THREAD_ONCE_STATIC_INIT PTHREAD_ONCE_INIT
+typedef pthread_t aws_thread_id_t;
+#endif
+
+/*
+ * Buffer size needed to represent aws_thread_id_t as a string (2 hex chars per byte
+ * plus '\0' terminator). Needed for portable printing because pthread_t is
+ * opaque.
+ */
+#define AWS_THREAD_ID_T_REPR_BUFSZ (sizeof(aws_thread_id_t) * 2 + 1)
+
+struct aws_thread {
+ struct aws_allocator *allocator;
+ enum aws_thread_detach_state detach_state;
+#ifdef _WIN32
+ void *thread_handle;
+#endif
+ aws_thread_id_t thread_id;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Returns an instance of system default thread options.
+ */
+AWS_COMMON_API
+const struct aws_thread_options *aws_default_thread_options(void);
+
+AWS_COMMON_API void aws_thread_call_once(aws_thread_once *flag, void (*call_once)(void *), void *user_data);
+
+/**
+ * Initializes a new platform specific thread object struct (not the os-level
+ * thread itself).
+ */
+AWS_COMMON_API
+int aws_thread_init(struct aws_thread *thread, struct aws_allocator *allocator);
+
+/**
+ * Creates an OS level thread and associates it with func. context will be passed to func when it is executed.
+ * options will be applied to the thread if they are applicable for the platform.
+ *
+ * After launch, you may join on the thread. A successfully launched thread must have clean_up called on it in order
+ * to avoid a handle leak. If you do not join before calling clean_up, the thread will become detached.
+ *
+ * Managed threads must not have join or clean_up called on them by external code.
+ */
+AWS_COMMON_API
+int aws_thread_launch(
+ struct aws_thread *thread,
+ void (*func)(void *arg),
+ void *arg,
+ const struct aws_thread_options *options);
+
+/**
+ * Gets the id of thread
+ */
+AWS_COMMON_API
+aws_thread_id_t aws_thread_get_id(struct aws_thread *thread);
+
+/**
+ * Gets the detach state of the thread. For example, is it safe to call join on
+ * this thread? Has it been detached()?
+ */
+AWS_COMMON_API
+enum aws_thread_detach_state aws_thread_get_detach_state(struct aws_thread *thread);
+
+/**
+ * Joins the calling thread to a thread instance. Returns when thread is
+ * finished. Calling this from the associated OS thread will cause a deadlock.
+ */
+AWS_COMMON_API
+int aws_thread_join(struct aws_thread *thread);
+
+/**
+ * Blocking call that waits for all managed threads to complete their join call. This can only be called
+ * from the main thread or a non-managed thread.
+ *
+ * This gets called automatically from library cleanup.
+ *
+ * By default the wait is unbounded, but that default can be overridden via aws_thread_set_managed_join_timeout_ns()
+ */
+AWS_COMMON_API
+int aws_thread_join_all_managed(void);
+
+/**
+ * Overrides how long, in nanoseconds, that aws_thread_join_all_managed will wait for threads to complete.
+ * A value of zero will result in an unbounded wait.
+ */
+AWS_COMMON_API
+void aws_thread_set_managed_join_timeout_ns(uint64_t timeout_in_ns);
+
+/**
+ * Cleans up the thread handle. Don't call this on a managed thread. If you wish to join the thread, you must join
+ * before calling this function.
+ */
+AWS_COMMON_API
+void aws_thread_clean_up(struct aws_thread *thread);
+
+/**
+ * Returns the thread id of the calling thread.
+ */
+AWS_COMMON_API
+aws_thread_id_t aws_thread_current_thread_id(void);
+
+/**
+ * Compare thread ids.
+ */
+AWS_COMMON_API
+bool aws_thread_thread_id_equal(aws_thread_id_t t1, aws_thread_id_t t2);
+
+/**
+ * Sleeps the current thread by nanos.
+ */
+AWS_COMMON_API
+void aws_thread_current_sleep(uint64_t nanos);
+
+typedef void(aws_thread_atexit_fn)(void *user_data);
+
+/**
+ * Adds a callback to the chain to be called when the current thread joins.
+ * Callbacks are called from the current thread, in the reverse order they
+ * were added, after the thread function returns.
+ * If not called from within an aws_thread, has no effect.
+ */
+AWS_COMMON_API
+int aws_thread_current_at_exit(aws_thread_atexit_fn *callback, void *user_data);
+
+/**
+ * Increments the count of unjoined threads in the managed thread system. Used by managed threads and
+ * event loop threads. Additional usage requires the user to join corresponding threads themselves and
+ * correctly increment/decrement even in the face of launch/join errors.
+ *
+ * aws_thread_join_all_managed() will not return until this count has gone to zero.
+ */
+AWS_COMMON_API void aws_thread_increment_unjoined_count(void);
+
+/**
+ * Decrements the count of unjoined threads in the managed thread system. Used by managed threads and
+ * event loop threads. Additional usage requires the user to join corresponding threads themselves and
+ * correctly increment/decrement even in the face of launch/join errors.
+ *
+ * aws_thread_join_all_managed() will not return until this count has gone to zero.
+ */
+AWS_COMMON_API void aws_thread_decrement_unjoined_count(void);
+
+/**
+ * Gets name of the current thread.
+ * Caller is responsible for destroying returned string.
+ * If thread does not have a name, AWS_OP_SUCCESS is returned and out_name is
+ * set to NULL.
+ * If underlying OS call fails, AWS_ERROR_SYS_CALL_FAILURE will be raised
+ * If OS does not support getting thread name, AWS_ERROR_PLATFORM_NOT_SUPPORTED
+ * will be raised
+ */
+AWS_COMMON_API int aws_thread_current_name(struct aws_allocator *allocator, struct aws_string **out_name);
+
+/**
+ * Gets name of the thread.
+ * Caller is responsible for destroying returned string.
+ * If thread does not have a name, AWS_OP_SUCCESS is returned and out_name is
+ * set to NULL.
+ * If underlying OS call fails, AWS_ERROR_SYS_CALL_FAILURE will be raised
+ * If OS does not support getting thread name, AWS_ERROR_PLATFORM_NOT_SUPPORTED
+ * will be raised
+ */
+AWS_COMMON_API int aws_thread_name(
+ struct aws_allocator *allocator,
+ aws_thread_id_t thread_id,
+ struct aws_string **out_name);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_THREAD_H */
diff --git a/include/aws/common/time.h b/include/aws/common/time.h
new file mode 100644
index 0000000000000000000000000000000000000000..f5cfe31ad50175adb755ce1e15ebb53f72b7cc09
--- /dev/null
+++ b/include/aws/common/time.h
@@ -0,0 +1,32 @@
+#ifndef AWS_COMMON_TIME_H
+#define AWS_COMMON_TIME_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Cross platform friendly version of timegm
+ */
+AWS_COMMON_API time_t aws_timegm(struct tm *const t);
+
+/**
+ * Cross platform friendly version of localtime_r
+ */
+AWS_COMMON_API void aws_localtime(time_t time, struct tm *t);
+
+/**
+ * Cross platform friendly version of gmtime_r
+ */
+AWS_COMMON_API void aws_gmtime(time_t time, struct tm *t);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_TIME_H */
diff --git a/include/aws/common/uri.h b/include/aws/common/uri.h
new file mode 100644
index 0000000000000000000000000000000000000000..137ba7df800e7e9f1871b344ecebc31f2278bca0
--- /dev/null
+++ b/include/aws/common/uri.h
@@ -0,0 +1,187 @@
+#ifndef AWS_COMMON_URI_H
+#define AWS_COMMON_URI_H
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+/**
+ * Data representing a URI. uri_str is always allocated and filled in.
+ * The other portions are merely storing offsets into uri_str.
+ */
+struct aws_uri {
+ size_t self_size;
+ struct aws_allocator *allocator;
+ struct aws_byte_buf uri_str;
+ struct aws_byte_cursor scheme;
+ struct aws_byte_cursor authority;
+ struct aws_byte_cursor userinfo;
+ struct aws_byte_cursor user;
+ struct aws_byte_cursor password;
+ struct aws_byte_cursor host_name;
+ uint32_t port;
+ struct aws_byte_cursor path;
+ struct aws_byte_cursor query_string;
+ struct aws_byte_cursor path_and_query;
+};
+
+/**
+ * key/value pairs for a query string. If the query fragment was not in format key=value, the fragment value
+ * will be stored in key
+ */
+struct aws_uri_param {
+ struct aws_byte_cursor key;
+ struct aws_byte_cursor value;
+};
+
+/**
+ * Arguments for building a URI instance. All members must
+ * be initialized before passing them to aws_uri_init().
+ *
+ * query_string and query_params are exclusive to each other. If you set
+ * query_string, do not prepend it with '?'
+ */
+struct aws_uri_builder_options {
+ struct aws_byte_cursor scheme;
+ struct aws_byte_cursor path;
+ struct aws_byte_cursor host_name;
+ uint32_t port;
+ struct aws_array_list *query_params;
+ struct aws_byte_cursor query_string;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Parses 'uri_str' and initializes uri. Returns AWS_OP_SUCCESS, on success, AWS_OP_ERR on failure.
+ * After calling this function, the parts can be accessed.
+ */
+AWS_COMMON_API int aws_uri_init_parse(
+ struct aws_uri *uri,
+ struct aws_allocator *allocator,
+ const struct aws_byte_cursor *uri_str);
+
+/**
+ * Initializes uri to values specified in options. Returns AWS_OP_SUCCESS, on success, AWS_OP_ERR on failure.
+ * After calling this function, the parts can be accessed.
+ */
+AWS_COMMON_API int aws_uri_init_from_builder_options(
+ struct aws_uri *uri,
+ struct aws_allocator *allocator,
+ struct aws_uri_builder_options *options);
+AWS_COMMON_API void aws_uri_clean_up(struct aws_uri *uri);
+
+/**
+ * Returns the scheme portion of the uri (e.g. http, https, ftp, ftps, etc...). If the scheme was not present
+ * in the uri, the returned value will be empty. It is the users job to determine the appropriate defaults
+ * if this field is empty, based on protocol, port, etc...
+ */
+AWS_COMMON_API const struct aws_byte_cursor *aws_uri_scheme(const struct aws_uri *uri);
+
+/**
+ * Returns the authority portion of the uri (host[:port]). If it was not present, this was a request uri. In that
+ * case, the value will be empty.
+ */
+AWS_COMMON_API const struct aws_byte_cursor *aws_uri_authority(const struct aws_uri *uri);
+
+/**
+ * Returns the path portion of the uri, including any leading '/'. If not present, this value will be empty.
+ */
+AWS_COMMON_API const struct aws_byte_cursor *aws_uri_path(const struct aws_uri *uri);
+
+/**
+ * Returns the query string portion of the uri, minus the '?'. If not present, this value will be empty.
+ */
+AWS_COMMON_API const struct aws_byte_cursor *aws_uri_query_string(const struct aws_uri *uri);
+
+/**
+ * Returns the 'host_name' portion of the authority. If no authority was present, this value will be empty.
+ */
+AWS_COMMON_API const struct aws_byte_cursor *aws_uri_host_name(const struct aws_uri *uri);
+
+/**
+ * Returns the port portion of the authority if it was present, otherwise, returns 0.
+ * If this is 0, it is the users job to determine the correct port based on scheme and protocol.
+ */
+AWS_COMMON_API uint32_t aws_uri_port(const struct aws_uri *uri);
+
+/**
+ * Returns the path and query portion of the uri (i.e., the thing you send across the wire).
+ */
+AWS_COMMON_API const struct aws_byte_cursor *aws_uri_path_and_query(const struct aws_uri *uri);
+
+/**
+ * For iterating over the params in the query string.
+ * `param` is an in/out argument used to track progress, it MUST be zeroed out to start.
+ * If true is returned, `param` contains the value of the next param.
+ * If false is returned, there are no further params.
+ *
+ * Edge cases:
+ * 1) Entries without '=' sign are treated as having a key and no value.
+ * Example: First param in query string "a&b=c" has key="a" value=""
+ *
+ * 2) Blank entries are skipped.
+ * Example: The only param in query string "&&a=b" is key="a" value="b"
+ */
+AWS_COMMON_API bool aws_query_string_next_param(struct aws_byte_cursor query_string, struct aws_uri_param *param);
+
+/**
+ * Parses query string and stores the parameters in 'out_params'. Returns AWS_OP_SUCCESS on success and
+ * AWS_OP_ERR on failure. The user is responsible for initializing out_params with item size of struct aws_query_param.
+ * The user is also responsible for cleaning up out_params when finished.
+ */
+AWS_COMMON_API int aws_query_string_params(struct aws_byte_cursor query_string, struct aws_array_list *out_params);
+
+/**
+ * For iterating over the params in the uri query string.
+ * `param` is an in/out argument used to track progress, it MUST be zeroed out to start.
+ * If true is returned, `param` contains the value of the next param.
+ * If false is returned, there are no further params.
+ *
+ * Edge cases:
+ * 1) Entries without '=' sign are treated as having a key and no value.
+ * Example: First param in query string "a&b=c" has key="a" value=""
+ *
+ * 2) Blank entries are skipped.
+ * Example: The only param in query string "&&a=b" is key="a" value="b"
+ */
+AWS_COMMON_API bool aws_uri_query_string_next_param(const struct aws_uri *uri, struct aws_uri_param *param);
+
+/**
+ * Parses query string and stores the parameters in 'out_params'. Returns AWS_OP_SUCCESS on success and
+ * AWS_OP_ERR on failure. The user is responsible for initializing out_params with item size of struct aws_query_param.
+ * The user is also responsible for cleaning up out_params when finished.
+ */
+AWS_COMMON_API int aws_uri_query_string_params(const struct aws_uri *uri, struct aws_array_list *out_params);
+
+/**
+ * Writes the uri path encoding of a cursor to a buffer. This is the modified version of rfc3986 used by
+ * sigv4 signing.
+ */
+AWS_COMMON_API int aws_byte_buf_append_encoding_uri_path(
+ struct aws_byte_buf *buffer,
+ const struct aws_byte_cursor *cursor);
+
+/**
+ * Writes the uri query param encoding (passthrough alnum + '-' '_' '~' '.') of a UTF-8 cursor to a buffer
+ * For example, reading "a b_c" would write "a%20b_c".
+ */
+AWS_COMMON_API int aws_byte_buf_append_encoding_uri_param(
+ struct aws_byte_buf *buffer,
+ const struct aws_byte_cursor *cursor);
+
+/**
+ * Writes the uri decoding of a UTF-8 cursor to a buffer,
+ * replacing %xx escapes by their single byte equivalent.
+ * For example, reading "a%20b_c" would write "a b_c".
+ */
+AWS_COMMON_API int aws_byte_buf_append_decoding_uri(struct aws_byte_buf *buffer, const struct aws_byte_cursor *cursor);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_URI_H */
diff --git a/include/aws/common/uuid.h b/include/aws/common/uuid.h
new file mode 100644
index 0000000000000000000000000000000000000000..60e12d703f1e9cfc4681650027f18cc7ecbb5c94
--- /dev/null
+++ b/include/aws/common/uuid.h
@@ -0,0 +1,35 @@
+#ifndef AWS_COMMON_UUID_H
+#define AWS_COMMON_UUID_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_byte_cursor;
+struct aws_byte_buf;
+
+struct aws_uuid {
+ uint8_t uuid_data[16];
+};
+
+/* 36 bytes for the UUID plus one more for the null terminator. */
+enum { AWS_UUID_STR_LEN = 37 };
+/* 32 bytes for the UUID (no dashes) plus one more for the null terminator. */
+enum { AWS_UUID_STR_COMPACT_LEN = 33 };
+
+AWS_EXTERN_C_BEGIN
+
+AWS_COMMON_API int aws_uuid_init(struct aws_uuid *uuid);
+AWS_COMMON_API int aws_uuid_init_from_str(struct aws_uuid *uuid, const struct aws_byte_cursor *uuid_str);
+AWS_COMMON_API int aws_uuid_to_str(const struct aws_uuid *uuid, struct aws_byte_buf *output);
+AWS_COMMON_API int aws_uuid_to_str_compact(const struct aws_uuid *uuid, struct aws_byte_buf *output);
+AWS_COMMON_API bool aws_uuid_equals(const struct aws_uuid *a, const struct aws_uuid *b);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_UUID_H */
diff --git a/include/aws/common/xml_parser.h b/include/aws/common/xml_parser.h
new file mode 100644
index 0000000000000000000000000000000000000000..2d31d007b11e209bb50baedc8499b649e790e3e5
--- /dev/null
+++ b/include/aws/common/xml_parser.h
@@ -0,0 +1,97 @@
+#ifndef AWS_COMMON_XML_PARSER_H
+#define AWS_COMMON_XML_PARSER_H
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+/* WARNING: This is not a public API. It is only intended for use within the aws-c libraries. */
+#include
+#include
+
+#include
+
+AWS_PUSH_SANE_WARNING_LEVEL
+
+struct aws_xml_node;
+
+struct aws_xml_attribute {
+ struct aws_byte_cursor name;
+ struct aws_byte_cursor value;
+};
+
+/**
+ * Callback for when an xml node is encountered in the document. As a user you have a few options:
+ *
+ * 1. fail the parse by returning AWS_OP_ERR (after an error has been raised). This will stop any further parsing.
+ * 2. call aws_xml_node_traverse() on the node to descend into the node with a new callback and user_data.
+ * 3. call aws_xml_node_as_body() to retrieve the contents of the node as text.
+ *
+ * You MUST NOT call both aws_xml_node_traverse() and aws_xml_node_as_body() on the same node.
+ *
+ * return true to continue the parsing operation.
+ */
+typedef int(aws_xml_parser_on_node_encountered_fn)(struct aws_xml_node *node, void *user_data);
+
+struct aws_xml_parser_options {
+ /* xml document to parse. */
+ struct aws_byte_cursor doc;
+
+ /* Max node depth used for parsing document. */
+ size_t max_depth;
+
+ /* Callback invoked on the root node */
+ aws_xml_parser_on_node_encountered_fn *on_root_encountered;
+
+ /* User data for callback */
+ void *user_data;
+};
+
+AWS_EXTERN_C_BEGIN
+
+/**
+ * Parse an XML document.
+ * WARNING: This is not a public API. It is only intended for use within the aws-c libraries.
+ */
+AWS_COMMON_API
+int aws_xml_parse(struct aws_allocator *allocator, const struct aws_xml_parser_options *options);
+
+/**
+ * Writes the contents of the body of node into out_body. out_body is an output parameter in this case. Upon success,
+ * out_body will contain the body of the node.
+ */
+AWS_COMMON_API
+int aws_xml_node_as_body(struct aws_xml_node *node, struct aws_byte_cursor *out_body);
+
+/**
+ * Traverse node and invoke on_node_encountered when a nested node is encountered.
+ */
+AWS_COMMON_API
+int aws_xml_node_traverse(
+ struct aws_xml_node *node,
+ aws_xml_parser_on_node_encountered_fn *on_node_encountered,
+ void *user_data);
+
+/*
+ * Get the name of an xml node.
+ */
+AWS_COMMON_API
+struct aws_byte_cursor aws_xml_node_get_name(const struct aws_xml_node *node);
+
+/*
+ * Get the number of attributes for an xml node.
+ */
+AWS_COMMON_API
+size_t aws_xml_node_get_num_attributes(const struct aws_xml_node *node);
+
+/*
+ * Get an attribute for an xml node by its index.
+ */
+AWS_COMMON_API
+struct aws_xml_attribute aws_xml_node_get_attribute(const struct aws_xml_node *node, size_t attribute_index);
+
+AWS_EXTERN_C_END
+AWS_POP_SANE_WARNING_LEVEL
+
+#endif /* AWS_COMMON_XML_PARSER_H */
diff --git a/include/aws/common/zero.inl b/include/aws/common/zero.inl
new file mode 100644
index 0000000000000000000000000000000000000000..25887bf3ea8598a2fef98e66b1ed32dcb9e4c921
--- /dev/null
+++ b/include/aws/common/zero.inl
@@ -0,0 +1,49 @@
+#ifndef AWS_COMMON_ZERO_INL
+#define AWS_COMMON_ZERO_INL
+
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include
+#include
+#include
+#include
+
+AWS_EXTERN_C_BEGIN
+/**
+ * Returns whether each byte is zero.
+ */
+AWS_STATIC_IMPL
+bool aws_is_mem_zeroed(const void *buf, size_t bufsize) {
+ /* Optimization idea: vectorized instructions to check more than 64 bits at a time. */
+
+ /* Check 64 bits at a time */
+ const uint64_t *buf_u64 = (const uint64_t *)buf;
+ const size_t num_u64_checks = bufsize / 8;
+ size_t i;
+ for (i = 0; i < num_u64_checks; ++i) {
+ if (buf_u64[i]) {
+ return false;
+ }
+ }
+
+ /* Update buf to where u64 checks left off */
+ buf = buf_u64 + num_u64_checks;
+ bufsize = bufsize % 8;
+
+ /* Check 8 bits at a time */
+ const uint8_t *buf_u8 = (const uint8_t *)buf;
+ for (i = 0; i < bufsize; ++i) {
+ if (buf_u8[i]) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+AWS_EXTERN_C_END
+
+#endif /* AWS_COMMON_ZERO_INL */
diff --git a/include/aws/config/ConfigServiceClient.h b/include/aws/config/ConfigServiceClient.h
new file mode 100644
index 0000000000000000000000000000000000000000..4aa04e78653a5e4d66b57de88ec246db57033b67
--- /dev/null
+++ b/include/aws/config/ConfigServiceClient.h
@@ -0,0 +1,3309 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#pragma once
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace Aws
+{
+namespace ConfigService
+{
+ AWS_CONFIGSERVICE_API extern const char SERVICE_NAME[];
+ /**
+ * Config Config provides a way to keep track of the
+ * configurations of all the Amazon Web Services resources associated with your
+ * Amazon Web Services account. You can use Config to get the current and
+ * historical configurations of each Amazon Web Services resource and also to get
+ * information about the relationship between the resources. An Amazon Web Services
+ * resource can be an Amazon Compute Cloud (Amazon EC2) instance, an Elastic Block
+ * Store (EBS) volume, an elastic network Interface (ENI), or a security group. For
+ * a complete list of resources currently supported by Config, see Supported
+ * Amazon Web Services resources.
You can access and manage Config
+ * through the Amazon Web Services Management Console, the Amazon Web Services
+ * Command Line Interface (Amazon Web Services CLI), the Config API, or the Amazon
+ * Web Services SDKs for Config. This reference guide contains documentation for
+ * the Config API and the Amazon Web Services CLI commands that you can use to
+ * manage Config. The Config API uses the Signature Version 4 protocol for signing
+ * requests. For more information about how to sign a request with this protocol,
+ * see Signature
+ * Version 4 Signing Process. For detailed information about Config features
+ * and their associated actions or commands, as well as how to work with Amazon Web
+ * Services Management Console, see What
+ * Is Config in the Config Developer Guide.
+ */
+ class AWS_CONFIGSERVICE_API ConfigServiceClient : smithy::client::AwsSmithyClientT,
+ Aws::Crt::Variant,
+ ConfigServiceEndpointProviderBase,
+ smithy::client::JsonOutcomeSerializer,
+ smithy::client::JsonOutcome,
+ Aws::Client::ConfigServiceErrorMarshaller>,
+ Aws::Client::ClientWithAsyncTemplateMethods
+ {
+ public:
+ static const char* GetServiceName();
+ static const char* GetAllocationTag();
+ inline const char* GetServiceClientName() const override { return "Config Service"; }
+
+ typedef ConfigServiceClientConfiguration ClientConfigurationType;
+ typedef ConfigServiceEndpointProvider EndpointProviderType;
+
+ /**
+ * Initializes client to use DefaultCredentialProviderChain, with default http client factory, and optional client config. If client config
+ * is not specified, it will be initialized to default values.
+ */
+ ConfigServiceClient(const Aws::ConfigService::ConfigServiceClientConfiguration& clientConfiguration = Aws::ConfigService::ConfigServiceClientConfiguration(),
+ std::shared_ptr endpointProvider = nullptr);
+
+ /**
+ * Initializes client to use SimpleAWSCredentialsProvider, with default http client factory, and optional client config. If client config
+ * is not specified, it will be initialized to default values.
+ */
+ ConfigServiceClient(const Aws::Auth::AWSCredentials& credentials,
+ std::shared_ptr endpointProvider = nullptr,
+ const Aws::ConfigService::ConfigServiceClientConfiguration& clientConfiguration = Aws::ConfigService::ConfigServiceClientConfiguration());
+
+ /**
+ * Initializes client to use specified credentials provider with specified client config. If http client factory is not supplied,
+ * the default http client factory will be used
+ */
+ ConfigServiceClient(const std::shared_ptr& credentialsProvider,
+ std::shared_ptr endpointProvider = nullptr,
+ const Aws::ConfigService::ConfigServiceClientConfiguration& clientConfiguration = Aws::ConfigService::ConfigServiceClientConfiguration());
+
+
+ /* Legacy constructors due deprecation */
+ /**
+ * Initializes client to use DefaultCredentialProviderChain, with default http client factory, and optional client config. If client config
+ * is not specified, it will be initialized to default values.
+ */
+ ConfigServiceClient(const Aws::Client::ClientConfiguration& clientConfiguration);
+
+ /**
+ * Initializes client to use SimpleAWSCredentialsProvider, with default http client factory, and optional client config. If client config
+ * is not specified, it will be initialized to default values.
+ */
+ ConfigServiceClient(const Aws::Auth::AWSCredentials& credentials,
+ const Aws::Client::ClientConfiguration& clientConfiguration);
+
+ /**
+ * Initializes client to use specified credentials provider with specified client config. If http client factory is not supplied,
+ * the default http client factory will be used
+ */
+ ConfigServiceClient(const std::shared_ptr& credentialsProvider,
+ const Aws::Client::ClientConfiguration& clientConfiguration);
+
+ /* End of legacy constructors due deprecation */
+ virtual ~ConfigServiceClient();
+
+ /**
+ * Adds all resource types specified in the ResourceTypes list to
+ * the RecordingGroup
+ * of specified configuration recorder and includes those resource types when
+ * recording.
For this operation, the specified configuration recorder must
+ * use a RecordingStrategy
+ * that is either INCLUSION_BY_RESOURCE_TYPES or
+ * EXCLUSION_BY_RESOURCE_TYPES.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::AssociateResourceTypesOutcome AssociateResourceTypes(const Model::AssociateResourceTypesRequest& request) const;
+
+ /**
+ * A Callable wrapper for AssociateResourceTypes that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::AssociateResourceTypesOutcomeCallable AssociateResourceTypesCallable(const AssociateResourceTypesRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::AssociateResourceTypes, request);
+ }
+
+ /**
+ * An Async wrapper for AssociateResourceTypes that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void AssociateResourceTypesAsync(const AssociateResourceTypesRequestT& request, const AssociateResourceTypesResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::AssociateResourceTypes, request, handler, context);
+ }
+
+ /**
+ * Returns the current configuration items for resources that are present in
+ * your Config aggregator. The operation also returns a list of resources that are
+ * not processed in the current request. If there are no unprocessed resources, the
+ * operation returns an empty unprocessedResourceIdentifiers list.
+ *
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::BatchGetAggregateResourceConfigOutcome BatchGetAggregateResourceConfig(const Model::BatchGetAggregateResourceConfigRequest& request) const;
+
+ /**
+ * A Callable wrapper for BatchGetAggregateResourceConfig that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::BatchGetAggregateResourceConfigOutcomeCallable BatchGetAggregateResourceConfigCallable(const BatchGetAggregateResourceConfigRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::BatchGetAggregateResourceConfig, request);
+ }
+
+ /**
+ * An Async wrapper for BatchGetAggregateResourceConfig that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void BatchGetAggregateResourceConfigAsync(const BatchGetAggregateResourceConfigRequestT& request, const BatchGetAggregateResourceConfigResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::BatchGetAggregateResourceConfig, request, handler, context);
+ }
+
+ /**
+ * Returns the BaseConfigurationItem for one or more requested
+ * resources. The operation also returns a list of resources that are not processed
+ * in the current request. If there are no unprocessed resources, the operation
+ * returns an empty unprocessedResourceKeys list.
-
The API
+ * does not return results for deleted resources.
-
The API does
+ * not return any tags for the requested resources. This information is filtered
+ * out of the supplementaryConfiguration section of the API response.
+ *
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::BatchGetResourceConfigOutcome BatchGetResourceConfig(const Model::BatchGetResourceConfigRequest& request) const;
+
+ /**
+ * A Callable wrapper for BatchGetResourceConfig that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::BatchGetResourceConfigOutcomeCallable BatchGetResourceConfigCallable(const BatchGetResourceConfigRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::BatchGetResourceConfig, request);
+ }
+
+ /**
+ * An Async wrapper for BatchGetResourceConfig that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void BatchGetResourceConfigAsync(const BatchGetResourceConfigRequestT& request, const BatchGetResourceConfigResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::BatchGetResourceConfig, request, handler, context);
+ }
+
+ /**
+ * Deletes the authorization granted to the specified configuration aggregator
+ * account in a specified region.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteAggregationAuthorizationOutcome DeleteAggregationAuthorization(const Model::DeleteAggregationAuthorizationRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteAggregationAuthorization that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteAggregationAuthorizationOutcomeCallable DeleteAggregationAuthorizationCallable(const DeleteAggregationAuthorizationRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteAggregationAuthorization, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteAggregationAuthorization that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteAggregationAuthorizationAsync(const DeleteAggregationAuthorizationRequestT& request, const DeleteAggregationAuthorizationResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteAggregationAuthorization, request, handler, context);
+ }
+
+ /**
+ * Deletes the specified Config rule and all of its evaluation results.
+ * Config sets the state of a rule to DELETING until the deletion
+ * is complete. You cannot update a rule while it is in this state. If you make a
+ * PutConfigRule or DeleteConfigRule request for the
+ * rule, you will receive a ResourceInUseException.
You can
+ * check the state of a rule by using the DescribeConfigRules
+ * request.
Recommendation: Stop recording resource compliance
+ * before deleting rules
It is highly recommended that you stop
+ * recording for the AWS::Config::ResourceCompliance resource type
+ * before you delete rules in your account. Deleting rules creates CIs for
+ * AWS::Config::ResourceCompliance and can affect your Config configuration
+ * recorder costs. If you are deleting rules which evaluate a large number of
+ * resource types, this can lead to a spike in the number of CIs recorded.
+ * Best practice:
-
Stop recording
+ * AWS::Config::ResourceCompliance
-
Delete
+ * rule(s)
-
Turn on recording for
+ * AWS::Config::ResourceCompliance
See
+ * Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteConfigRuleOutcome DeleteConfigRule(const Model::DeleteConfigRuleRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteConfigRule that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteConfigRuleOutcomeCallable DeleteConfigRuleCallable(const DeleteConfigRuleRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteConfigRule, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteConfigRule that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteConfigRuleAsync(const DeleteConfigRuleRequestT& request, const DeleteConfigRuleResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteConfigRule, request, handler, context);
+ }
+
+ /**
+ * Deletes the specified configuration aggregator and the aggregated data
+ * associated with the aggregator.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteConfigurationAggregatorOutcome DeleteConfigurationAggregator(const Model::DeleteConfigurationAggregatorRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteConfigurationAggregator that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteConfigurationAggregatorOutcomeCallable DeleteConfigurationAggregatorCallable(const DeleteConfigurationAggregatorRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteConfigurationAggregator, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteConfigurationAggregator that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteConfigurationAggregatorAsync(const DeleteConfigurationAggregatorRequestT& request, const DeleteConfigurationAggregatorResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteConfigurationAggregator, request, handler, context);
+ }
+
+ /**
+ * Deletes the customer managed configuration recorder.
This operation
+ * does not delete the configuration information that was previously recorded. You
+ * will be able to access the previously recorded information by using the GetResourceConfigHistory
+ * operation, but you will not be able to access this information in the Config
+ * console until you have created a new customer managed configuration
+ * recorder.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteConfigurationRecorderOutcome DeleteConfigurationRecorder(const Model::DeleteConfigurationRecorderRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteConfigurationRecorder that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteConfigurationRecorderOutcomeCallable DeleteConfigurationRecorderCallable(const DeleteConfigurationRecorderRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteConfigurationRecorder, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteConfigurationRecorder that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteConfigurationRecorderAsync(const DeleteConfigurationRecorderRequestT& request, const DeleteConfigurationRecorderResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteConfigurationRecorder, request, handler, context);
+ }
+
+ /**
+ * Deletes the specified conformance pack and all the Config rules, remediation
+ * actions, and all evaluation results within that conformance pack.
Config
+ * sets the conformance pack to DELETE_IN_PROGRESS until the deletion
+ * is complete. You cannot update a conformance pack while it is in this
+ * state.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteConformancePackOutcome DeleteConformancePack(const Model::DeleteConformancePackRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteConformancePack that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteConformancePackOutcomeCallable DeleteConformancePackCallable(const DeleteConformancePackRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteConformancePack, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteConformancePack that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteConformancePackAsync(const DeleteConformancePackRequestT& request, const DeleteConformancePackResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteConformancePack, request, handler, context);
+ }
+
+ /**
+ * Deletes the delivery channel.
Before you can delete the delivery
+ * channel, you must stop the customer managed configuration recorder. You can use
+ * the StopConfigurationRecorder operation to stop the customer managed
+ * configuration recorder.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteDeliveryChannelOutcome DeleteDeliveryChannel(const Model::DeleteDeliveryChannelRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteDeliveryChannel that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteDeliveryChannelOutcomeCallable DeleteDeliveryChannelCallable(const DeleteDeliveryChannelRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteDeliveryChannel, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteDeliveryChannel that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteDeliveryChannelAsync(const DeleteDeliveryChannelRequestT& request, const DeleteDeliveryChannelResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteDeliveryChannel, request, handler, context);
+ }
+
+ /**
+ * Deletes the evaluation results for the specified Config rule. You can specify
+ * one Config rule per request. After you delete the evaluation results, you can
+ * call the StartConfigRulesEvaluation API to start evaluating your Amazon
+ * Web Services resources against the rule.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteEvaluationResultsOutcome DeleteEvaluationResults(const Model::DeleteEvaluationResultsRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteEvaluationResults that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteEvaluationResultsOutcomeCallable DeleteEvaluationResultsCallable(const DeleteEvaluationResultsRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteEvaluationResults, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteEvaluationResults that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteEvaluationResultsAsync(const DeleteEvaluationResultsRequestT& request, const DeleteEvaluationResultsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteEvaluationResults, request, handler, context);
+ }
+
+ /**
+ * Deletes the specified organization Config rule and all of its evaluation
+ * results from all member accounts in that organization.
Only a management
+ * account and a delegated administrator account can delete an organization Config
+ * rule. When calling this API with a delegated administrator, you must ensure
+ * Organizations ListDelegatedAdministrator permissions are added.
+ * Config sets the state of a rule to DELETE_IN_PROGRESS until the deletion is
+ * complete. You cannot update a rule while it is in this state.
See
+ * Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteOrganizationConfigRuleOutcome DeleteOrganizationConfigRule(const Model::DeleteOrganizationConfigRuleRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteOrganizationConfigRule that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteOrganizationConfigRuleOutcomeCallable DeleteOrganizationConfigRuleCallable(const DeleteOrganizationConfigRuleRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteOrganizationConfigRule, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteOrganizationConfigRule that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteOrganizationConfigRuleAsync(const DeleteOrganizationConfigRuleRequestT& request, const DeleteOrganizationConfigRuleResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteOrganizationConfigRule, request, handler, context);
+ }
+
+ /**
+ * Deletes the specified organization conformance pack and all of the Config
+ * rules and remediation actions from all member accounts in that organization.
+ *
Only a management account or a delegated administrator account can
+ * delete an organization conformance pack. When calling this API with a delegated
+ * administrator, you must ensure Organizations
+ * ListDelegatedAdministrator permissions are added.
Config
+ * sets the state of a conformance pack to DELETE_IN_PROGRESS until the deletion is
+ * complete. You cannot update a conformance pack while it is in this state.
+ *
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteOrganizationConformancePackOutcome DeleteOrganizationConformancePack(const Model::DeleteOrganizationConformancePackRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteOrganizationConformancePack that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteOrganizationConformancePackOutcomeCallable DeleteOrganizationConformancePackCallable(const DeleteOrganizationConformancePackRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteOrganizationConformancePack, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteOrganizationConformancePack that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteOrganizationConformancePackAsync(const DeleteOrganizationConformancePackRequestT& request, const DeleteOrganizationConformancePackResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteOrganizationConformancePack, request, handler, context);
+ }
+
+ /**
+ * Deletes pending authorization requests for a specified aggregator account in
+ * a specified region.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeletePendingAggregationRequestOutcome DeletePendingAggregationRequest(const Model::DeletePendingAggregationRequestRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeletePendingAggregationRequest that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeletePendingAggregationRequestOutcomeCallable DeletePendingAggregationRequestCallable(const DeletePendingAggregationRequestRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeletePendingAggregationRequest, request);
+ }
+
+ /**
+ * An Async wrapper for DeletePendingAggregationRequest that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeletePendingAggregationRequestAsync(const DeletePendingAggregationRequestRequestT& request, const DeletePendingAggregationRequestResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeletePendingAggregationRequest, request, handler, context);
+ }
+
+ /**
+ * Deletes the remediation configuration.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteRemediationConfigurationOutcome DeleteRemediationConfiguration(const Model::DeleteRemediationConfigurationRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteRemediationConfiguration that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteRemediationConfigurationOutcomeCallable DeleteRemediationConfigurationCallable(const DeleteRemediationConfigurationRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteRemediationConfiguration, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteRemediationConfiguration that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteRemediationConfigurationAsync(const DeleteRemediationConfigurationRequestT& request, const DeleteRemediationConfigurationResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteRemediationConfiguration, request, handler, context);
+ }
+
+ /**
+ * Deletes one or more remediation exceptions mentioned in the resource
+ * keys.
Config generates a remediation exception when a problem
+ * occurs executing a remediation action to a specific resource. Remediation
+ * exceptions blocks auto-remediation until the exception is cleared.
+ * See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteRemediationExceptionsOutcome DeleteRemediationExceptions(const Model::DeleteRemediationExceptionsRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteRemediationExceptions that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteRemediationExceptionsOutcomeCallable DeleteRemediationExceptionsCallable(const DeleteRemediationExceptionsRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteRemediationExceptions, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteRemediationExceptions that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteRemediationExceptionsAsync(const DeleteRemediationExceptionsRequestT& request, const DeleteRemediationExceptionsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteRemediationExceptions, request, handler, context);
+ }
+
+ /**
+ * Records the configuration state for a custom resource that has been deleted.
+ * This API records a new ConfigurationItem with a ResourceDeleted status. You can
+ * retrieve the ConfigurationItems recorded for this resource in your Config
+ * History.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteResourceConfigOutcome DeleteResourceConfig(const Model::DeleteResourceConfigRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteResourceConfig that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteResourceConfigOutcomeCallable DeleteResourceConfigCallable(const DeleteResourceConfigRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteResourceConfig, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteResourceConfig that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteResourceConfigAsync(const DeleteResourceConfigRequestT& request, const DeleteResourceConfigResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteResourceConfig, request, handler, context);
+ }
+
+ /**
+ * Deletes the retention configuration.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteRetentionConfigurationOutcome DeleteRetentionConfiguration(const Model::DeleteRetentionConfigurationRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteRetentionConfiguration that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteRetentionConfigurationOutcomeCallable DeleteRetentionConfigurationCallable(const DeleteRetentionConfigurationRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteRetentionConfiguration, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteRetentionConfiguration that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteRetentionConfigurationAsync(const DeleteRetentionConfigurationRequestT& request, const DeleteRetentionConfigurationResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteRetentionConfiguration, request, handler, context);
+ }
+
+ /**
+ * Deletes an existing service-linked configuration recorder.
This
+ * operation does not delete the configuration information that was previously
+ * recorded. You will be able to access the previously recorded information by
+ * using the GetResourceConfigHistory
+ * operation, but you will not be able to access this information in the Config
+ * console until you have created a new service-linked configuration recorder for
+ * the same service.
The recording scope determines if you
+ * receive configuration items
The recording scope is set by the
+ * service that is linked to the configuration recorder and determines whether you
+ * receive configuration items (CIs) in the delivery channel. If the recording
+ * scope is internal, you will not receive CIs in the delivery channel.
+ * See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteServiceLinkedConfigurationRecorderOutcome DeleteServiceLinkedConfigurationRecorder(const Model::DeleteServiceLinkedConfigurationRecorderRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteServiceLinkedConfigurationRecorder that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteServiceLinkedConfigurationRecorderOutcomeCallable DeleteServiceLinkedConfigurationRecorderCallable(const DeleteServiceLinkedConfigurationRecorderRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteServiceLinkedConfigurationRecorder, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteServiceLinkedConfigurationRecorder that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteServiceLinkedConfigurationRecorderAsync(const DeleteServiceLinkedConfigurationRecorderRequestT& request, const DeleteServiceLinkedConfigurationRecorderResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteServiceLinkedConfigurationRecorder, request, handler, context);
+ }
+
+ /**
+ * Deletes the stored query for a single Amazon Web Services account and a
+ * single Amazon Web Services Region.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeleteStoredQueryOutcome DeleteStoredQuery(const Model::DeleteStoredQueryRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeleteStoredQuery that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeleteStoredQueryOutcomeCallable DeleteStoredQueryCallable(const DeleteStoredQueryRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeleteStoredQuery, request);
+ }
+
+ /**
+ * An Async wrapper for DeleteStoredQuery that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeleteStoredQueryAsync(const DeleteStoredQueryRequestT& request, const DeleteStoredQueryResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeleteStoredQuery, request, handler, context);
+ }
+
+ /**
+ * Schedules delivery of a configuration snapshot to the Amazon S3 bucket in the
+ * specified delivery channel. After the delivery has started, Config sends the
+ * following notifications using an Amazon SNS topic that you have specified.
+ * -
Notification of the start of the delivery.
-
+ *
Notification of the completion of the delivery, if the delivery was
+ * successfully completed.
-
Notification of delivery failure, if
+ * the delivery failed.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DeliverConfigSnapshotOutcome DeliverConfigSnapshot(const Model::DeliverConfigSnapshotRequest& request) const;
+
+ /**
+ * A Callable wrapper for DeliverConfigSnapshot that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DeliverConfigSnapshotOutcomeCallable DeliverConfigSnapshotCallable(const DeliverConfigSnapshotRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DeliverConfigSnapshot, request);
+ }
+
+ /**
+ * An Async wrapper for DeliverConfigSnapshot that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DeliverConfigSnapshotAsync(const DeliverConfigSnapshotRequestT& request, const DeliverConfigSnapshotResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DeliverConfigSnapshot, request, handler, context);
+ }
+
+ /**
+ * Returns a list of compliant and noncompliant rules with the number of
+ * resources for compliant and noncompliant rules. Does not display rules that do
+ * not have compliance results.
The results can return an empty
+ * result page, but if you have a nextToken, the results are displayed
+ * on the next page.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeAggregateComplianceByConfigRulesOutcome DescribeAggregateComplianceByConfigRules(const Model::DescribeAggregateComplianceByConfigRulesRequest& request) const;
+
+ /**
+ * A Callable wrapper for DescribeAggregateComplianceByConfigRules that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeAggregateComplianceByConfigRulesOutcomeCallable DescribeAggregateComplianceByConfigRulesCallable(const DescribeAggregateComplianceByConfigRulesRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeAggregateComplianceByConfigRules, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeAggregateComplianceByConfigRules that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeAggregateComplianceByConfigRulesAsync(const DescribeAggregateComplianceByConfigRulesRequestT& request, const DescribeAggregateComplianceByConfigRulesResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeAggregateComplianceByConfigRules, request, handler, context);
+ }
+
+ /**
+ * Returns a list of the existing and deleted conformance packs and their
+ * associated compliance status with the count of compliant and noncompliant Config
+ * rules within each conformance pack. Also returns the total rule count which
+ * includes compliant rules, noncompliant rules, and rules that cannot be evaluated
+ * due to insufficient data.
The results can return an empty result
+ * page, but if you have a nextToken, the results are displayed on the
+ * next page.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeAggregateComplianceByConformancePacksOutcome DescribeAggregateComplianceByConformancePacks(const Model::DescribeAggregateComplianceByConformancePacksRequest& request) const;
+
+ /**
+ * A Callable wrapper for DescribeAggregateComplianceByConformancePacks that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeAggregateComplianceByConformancePacksOutcomeCallable DescribeAggregateComplianceByConformancePacksCallable(const DescribeAggregateComplianceByConformancePacksRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeAggregateComplianceByConformancePacks, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeAggregateComplianceByConformancePacks that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeAggregateComplianceByConformancePacksAsync(const DescribeAggregateComplianceByConformancePacksRequestT& request, const DescribeAggregateComplianceByConformancePacksResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeAggregateComplianceByConformancePacks, request, handler, context);
+ }
+
+ /**
+ * Returns a list of authorizations granted to various aggregator accounts and
+ * regions.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeAggregationAuthorizationsOutcome DescribeAggregationAuthorizations(const Model::DescribeAggregationAuthorizationsRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeAggregationAuthorizations that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeAggregationAuthorizationsOutcomeCallable DescribeAggregationAuthorizationsCallable(const DescribeAggregationAuthorizationsRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeAggregationAuthorizations, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeAggregationAuthorizations that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeAggregationAuthorizationsAsync(const DescribeAggregationAuthorizationsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeAggregationAuthorizationsRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeAggregationAuthorizations, request, handler, context);
+ }
+
+ /**
+ * Indicates whether the specified Config rules are compliant. If a rule is
+ * noncompliant, this operation returns the number of Amazon Web Services resources
+ * that do not comply with the rule.
A rule is compliant if all of the
+ * evaluated resources comply with it. It is noncompliant if any of these resources
+ * do not comply.
If Config has no current evaluation results for the rule,
+ * it returns INSUFFICIENT_DATA. This result might indicate one of the
+ * following conditions:
-
Config has never invoked an evaluation
+ * for the rule. To check whether it has, use the
+ * DescribeConfigRuleEvaluationStatus action to get the
+ * LastSuccessfulInvocationTime and
+ * LastFailedInvocationTime.
-
The rule's Lambda
+ * function is failing to send evaluation results to Config. Verify that the role
+ * you assigned to your configuration recorder includes the
+ * config:PutEvaluations permission. If the rule is a custom rule,
+ * verify that the Lambda execution role includes the
+ * config:PutEvaluations permission.
-
The rule's
+ * Lambda function has returned NOT_APPLICABLE for all evaluation
+ * results. This can occur if the resources were deleted or removed from the rule's
+ * scope.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeComplianceByConfigRuleOutcome DescribeComplianceByConfigRule(const Model::DescribeComplianceByConfigRuleRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeComplianceByConfigRule that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeComplianceByConfigRuleOutcomeCallable DescribeComplianceByConfigRuleCallable(const DescribeComplianceByConfigRuleRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeComplianceByConfigRule, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeComplianceByConfigRule that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeComplianceByConfigRuleAsync(const DescribeComplianceByConfigRuleResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeComplianceByConfigRuleRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeComplianceByConfigRule, request, handler, context);
+ }
+
+ /**
+ * Indicates whether the specified Amazon Web Services resources are compliant.
+ * If a resource is noncompliant, this operation returns the number of Config rules
+ * that the resource does not comply with.
A resource is compliant if it
+ * complies with all the Config rules that evaluate it. It is noncompliant if it
+ * does not comply with one or more of these rules.
If Config has no current
+ * evaluation results for the resource, it returns INSUFFICIENT_DATA.
+ * This result might indicate one of the following conditions about the rules that
+ * evaluate the resource:
-
Config has never invoked an evaluation
+ * for the rule. To check whether it has, use the
+ * DescribeConfigRuleEvaluationStatus action to get the
+ * LastSuccessfulInvocationTime and
+ * LastFailedInvocationTime.
-
The rule's Lambda
+ * function is failing to send evaluation results to Config. Verify that the role
+ * that you assigned to your configuration recorder includes the
+ * config:PutEvaluations permission. If the rule is a custom rule,
+ * verify that the Lambda execution role includes the
+ * config:PutEvaluations permission.
-
The rule's
+ * Lambda function has returned NOT_APPLICABLE for all evaluation
+ * results. This can occur if the resources were deleted or removed from the rule's
+ * scope.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeComplianceByResourceOutcome DescribeComplianceByResource(const Model::DescribeComplianceByResourceRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeComplianceByResource that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeComplianceByResourceOutcomeCallable DescribeComplianceByResourceCallable(const DescribeComplianceByResourceRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeComplianceByResource, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeComplianceByResource that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeComplianceByResourceAsync(const DescribeComplianceByResourceResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeComplianceByResourceRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeComplianceByResource, request, handler, context);
+ }
+
+ /**
+ * Returns status information for each of your Config managed rules. The status
+ * includes information such as the last time Config invoked the rule, the last
+ * time Config failed to invoke the rule, and the related error for the last
+ * failure.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeConfigRuleEvaluationStatusOutcome DescribeConfigRuleEvaluationStatus(const Model::DescribeConfigRuleEvaluationStatusRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeConfigRuleEvaluationStatus that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeConfigRuleEvaluationStatusOutcomeCallable DescribeConfigRuleEvaluationStatusCallable(const DescribeConfigRuleEvaluationStatusRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeConfigRuleEvaluationStatus, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeConfigRuleEvaluationStatus that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeConfigRuleEvaluationStatusAsync(const DescribeConfigRuleEvaluationStatusResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeConfigRuleEvaluationStatusRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeConfigRuleEvaluationStatus, request, handler, context);
+ }
+
+ /**
+ * Returns details about your Config rules.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeConfigRulesOutcome DescribeConfigRules(const Model::DescribeConfigRulesRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeConfigRules that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeConfigRulesOutcomeCallable DescribeConfigRulesCallable(const DescribeConfigRulesRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeConfigRules, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeConfigRules that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeConfigRulesAsync(const DescribeConfigRulesResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeConfigRulesRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeConfigRules, request, handler, context);
+ }
+
+ /**
+ * Returns status information for sources within an aggregator. The status
+ * includes information about the last time Config verified authorization between
+ * the source account and an aggregator account. In case of a failure, the status
+ * contains the related error code or message.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeConfigurationAggregatorSourcesStatusOutcome DescribeConfigurationAggregatorSourcesStatus(const Model::DescribeConfigurationAggregatorSourcesStatusRequest& request) const;
+
+ /**
+ * A Callable wrapper for DescribeConfigurationAggregatorSourcesStatus that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeConfigurationAggregatorSourcesStatusOutcomeCallable DescribeConfigurationAggregatorSourcesStatusCallable(const DescribeConfigurationAggregatorSourcesStatusRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeConfigurationAggregatorSourcesStatus, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeConfigurationAggregatorSourcesStatus that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeConfigurationAggregatorSourcesStatusAsync(const DescribeConfigurationAggregatorSourcesStatusRequestT& request, const DescribeConfigurationAggregatorSourcesStatusResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeConfigurationAggregatorSourcesStatus, request, handler, context);
+ }
+
+ /**
+ * Returns the details of one or more configuration aggregators. If the
+ * configuration aggregator is not specified, this operation returns the details
+ * for all the configuration aggregators associated with the account.
+ *
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeConfigurationAggregatorsOutcome DescribeConfigurationAggregators(const Model::DescribeConfigurationAggregatorsRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeConfigurationAggregators that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeConfigurationAggregatorsOutcomeCallable DescribeConfigurationAggregatorsCallable(const DescribeConfigurationAggregatorsRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeConfigurationAggregators, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeConfigurationAggregators that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeConfigurationAggregatorsAsync(const DescribeConfigurationAggregatorsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeConfigurationAggregatorsRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeConfigurationAggregators, request, handler, context);
+ }
+
+ /**
+ * Returns the current status of the configuration recorder you specify as well
+ * as the status of the last recording event for the configuration recorders.
+ * For a detailed status of recording events over time, add your Config events
+ * to Amazon CloudWatch metrics and use CloudWatch metrics.
If a
+ * configuration recorder is not specified, this operation returns the status for
+ * the customer managed configuration recorder configured for the account, if
+ * applicable.
When making a request to this operation, you can only
+ * specify one configuration recorder.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeConfigurationRecorderStatusOutcome DescribeConfigurationRecorderStatus(const Model::DescribeConfigurationRecorderStatusRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeConfigurationRecorderStatus that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeConfigurationRecorderStatusOutcomeCallable DescribeConfigurationRecorderStatusCallable(const DescribeConfigurationRecorderStatusRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeConfigurationRecorderStatus, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeConfigurationRecorderStatus that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeConfigurationRecorderStatusAsync(const DescribeConfigurationRecorderStatusResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeConfigurationRecorderStatusRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeConfigurationRecorderStatus, request, handler, context);
+ }
+
+ /**
+ * Returns details for the configuration recorder you specify.
If a
+ * configuration recorder is not specified, this operation returns details for the
+ * customer managed configuration recorder configured for the account, if
+ * applicable.
When making a request to this operation, you can only
+ * specify one configuration recorder.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeConfigurationRecordersOutcome DescribeConfigurationRecorders(const Model::DescribeConfigurationRecordersRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeConfigurationRecorders that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeConfigurationRecordersOutcomeCallable DescribeConfigurationRecordersCallable(const DescribeConfigurationRecordersRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeConfigurationRecorders, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeConfigurationRecorders that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeConfigurationRecordersAsync(const DescribeConfigurationRecordersResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeConfigurationRecordersRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeConfigurationRecorders, request, handler, context);
+ }
+
+ /**
+ * Returns compliance details for each rule in that conformance pack.
+ * You must provide exact rule names.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeConformancePackComplianceOutcome DescribeConformancePackCompliance(const Model::DescribeConformancePackComplianceRequest& request) const;
+
+ /**
+ * A Callable wrapper for DescribeConformancePackCompliance that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeConformancePackComplianceOutcomeCallable DescribeConformancePackComplianceCallable(const DescribeConformancePackComplianceRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeConformancePackCompliance, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeConformancePackCompliance that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeConformancePackComplianceAsync(const DescribeConformancePackComplianceRequestT& request, const DescribeConformancePackComplianceResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeConformancePackCompliance, request, handler, context);
+ }
+
+ /**
+ * Provides one or more conformance packs deployment status.
If
+ * there are no conformance packs then you will see an empty result.
+ * See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeConformancePackStatusOutcome DescribeConformancePackStatus(const Model::DescribeConformancePackStatusRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeConformancePackStatus that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeConformancePackStatusOutcomeCallable DescribeConformancePackStatusCallable(const DescribeConformancePackStatusRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeConformancePackStatus, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeConformancePackStatus that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeConformancePackStatusAsync(const DescribeConformancePackStatusResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeConformancePackStatusRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeConformancePackStatus, request, handler, context);
+ }
+
+ /**
+ * Returns a list of one or more conformance packs.
See Also:
+ * AWS
+ * API Reference
+ */
+ virtual Model::DescribeConformancePacksOutcome DescribeConformancePacks(const Model::DescribeConformancePacksRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeConformancePacks that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeConformancePacksOutcomeCallable DescribeConformancePacksCallable(const DescribeConformancePacksRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeConformancePacks, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeConformancePacks that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeConformancePacksAsync(const DescribeConformancePacksResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeConformancePacksRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeConformancePacks, request, handler, context);
+ }
+
+ /**
+ * Returns the current status of the specified delivery channel. If a delivery
+ * channel is not specified, this operation returns the current status of all
+ * delivery channels associated with the account.
Currently, you can
+ * specify only one delivery channel per region in your account.
+ * See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeDeliveryChannelStatusOutcome DescribeDeliveryChannelStatus(const Model::DescribeDeliveryChannelStatusRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeDeliveryChannelStatus that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeDeliveryChannelStatusOutcomeCallable DescribeDeliveryChannelStatusCallable(const DescribeDeliveryChannelStatusRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeDeliveryChannelStatus, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeDeliveryChannelStatus that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeDeliveryChannelStatusAsync(const DescribeDeliveryChannelStatusResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeDeliveryChannelStatusRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeDeliveryChannelStatus, request, handler, context);
+ }
+
+ /**
+ * Returns details about the specified delivery channel. If a delivery channel
+ * is not specified, this operation returns the details of all delivery channels
+ * associated with the account.
Currently, you can specify only one
+ * delivery channel per region in your account.
See Also:
+ * AWS
+ * API Reference
+ */
+ virtual Model::DescribeDeliveryChannelsOutcome DescribeDeliveryChannels(const Model::DescribeDeliveryChannelsRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeDeliveryChannels that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeDeliveryChannelsOutcomeCallable DescribeDeliveryChannelsCallable(const DescribeDeliveryChannelsRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeDeliveryChannels, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeDeliveryChannels that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeDeliveryChannelsAsync(const DescribeDeliveryChannelsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeDeliveryChannelsRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeDeliveryChannels, request, handler, context);
+ }
+
+ /**
+ * Provides organization Config rule deployment status for an organization.
+ * The status is not considered successful until organization Config rule
+ * is successfully deployed in all the member accounts with an exception of
+ * excluded accounts.
When you specify the limit and the next token, you
+ * receive a paginated response. Limit and next token are not applicable if you
+ * specify organization Config rule names. It is only applicable, when you request
+ * all the organization Config rules.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeOrganizationConfigRuleStatusesOutcome DescribeOrganizationConfigRuleStatuses(const Model::DescribeOrganizationConfigRuleStatusesRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeOrganizationConfigRuleStatuses that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeOrganizationConfigRuleStatusesOutcomeCallable DescribeOrganizationConfigRuleStatusesCallable(const DescribeOrganizationConfigRuleStatusesRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeOrganizationConfigRuleStatuses, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeOrganizationConfigRuleStatuses that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeOrganizationConfigRuleStatusesAsync(const DescribeOrganizationConfigRuleStatusesResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeOrganizationConfigRuleStatusesRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeOrganizationConfigRuleStatuses, request, handler, context);
+ }
+
+ /**
+ * Returns a list of organization Config rules.
When you specify
+ * the limit and the next token, you receive a paginated response.
Limit and
+ * next token are not applicable if you specify organization Config rule names. It
+ * is only applicable, when you request all the organization Config rules.
+ * For accounts within an organization
If you deploy an
+ * organizational rule or conformance pack in an organization administrator
+ * account, and then establish a delegated administrator and deploy an
+ * organizational rule or conformance pack in the delegated administrator account,
+ * you won't be able to see the organizational rule or conformance pack in the
+ * organization administrator account from the delegated administrator account or
+ * see the organizational rule or conformance pack in the delegated administrator
+ * account from organization administrator account. The
+ * DescribeOrganizationConfigRules and
+ * DescribeOrganizationConformancePacks APIs can only see and interact
+ * with the organization-related resource that were deployed from within the
+ * account calling those APIs.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeOrganizationConfigRulesOutcome DescribeOrganizationConfigRules(const Model::DescribeOrganizationConfigRulesRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeOrganizationConfigRules that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeOrganizationConfigRulesOutcomeCallable DescribeOrganizationConfigRulesCallable(const DescribeOrganizationConfigRulesRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeOrganizationConfigRules, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeOrganizationConfigRules that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeOrganizationConfigRulesAsync(const DescribeOrganizationConfigRulesResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeOrganizationConfigRulesRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeOrganizationConfigRules, request, handler, context);
+ }
+
+ /**
+ * Provides organization conformance pack deployment status for an organization.
+ *
The status is not considered successful until organization
+ * conformance pack is successfully deployed in all the member accounts with an
+ * exception of excluded accounts.
When you specify the limit and the next
+ * token, you receive a paginated response. Limit and next token are not applicable
+ * if you specify organization conformance pack names. They are only applicable,
+ * when you request all the organization conformance packs.
See
+ * Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeOrganizationConformancePackStatusesOutcome DescribeOrganizationConformancePackStatuses(const Model::DescribeOrganizationConformancePackStatusesRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeOrganizationConformancePackStatuses that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeOrganizationConformancePackStatusesOutcomeCallable DescribeOrganizationConformancePackStatusesCallable(const DescribeOrganizationConformancePackStatusesRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeOrganizationConformancePackStatuses, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeOrganizationConformancePackStatuses that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeOrganizationConformancePackStatusesAsync(const DescribeOrganizationConformancePackStatusesResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeOrganizationConformancePackStatusesRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeOrganizationConformancePackStatuses, request, handler, context);
+ }
+
+ /**
+ * Returns a list of organization conformance packs.
When you
+ * specify the limit and the next token, you receive a paginated response.
+ * Limit and next token are not applicable if you specify organization
+ * conformance packs names. They are only applicable, when you request all the
+ * organization conformance packs.
For accounts within an
+ * organization
If you deploy an organizational rule or conformance
+ * pack in an organization administrator account, and then establish a delegated
+ * administrator and deploy an organizational rule or conformance pack in the
+ * delegated administrator account, you won't be able to see the organizational
+ * rule or conformance pack in the organization administrator account from the
+ * delegated administrator account or see the organizational rule or conformance
+ * pack in the delegated administrator account from organization administrator
+ * account. The DescribeOrganizationConfigRules and
+ * DescribeOrganizationConformancePacks APIs can only see and interact
+ * with the organization-related resource that were deployed from within the
+ * account calling those APIs.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeOrganizationConformancePacksOutcome DescribeOrganizationConformancePacks(const Model::DescribeOrganizationConformancePacksRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeOrganizationConformancePacks that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeOrganizationConformancePacksOutcomeCallable DescribeOrganizationConformancePacksCallable(const DescribeOrganizationConformancePacksRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeOrganizationConformancePacks, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeOrganizationConformancePacks that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeOrganizationConformancePacksAsync(const DescribeOrganizationConformancePacksResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeOrganizationConformancePacksRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeOrganizationConformancePacks, request, handler, context);
+ }
+
+ /**
+ * Returns a list of all pending aggregation requests.
See Also:
+ * AWS
+ * API Reference
+ */
+ virtual Model::DescribePendingAggregationRequestsOutcome DescribePendingAggregationRequests(const Model::DescribePendingAggregationRequestsRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribePendingAggregationRequests that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribePendingAggregationRequestsOutcomeCallable DescribePendingAggregationRequestsCallable(const DescribePendingAggregationRequestsRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribePendingAggregationRequests, request);
+ }
+
+ /**
+ * An Async wrapper for DescribePendingAggregationRequests that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribePendingAggregationRequestsAsync(const DescribePendingAggregationRequestsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribePendingAggregationRequestsRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribePendingAggregationRequests, request, handler, context);
+ }
+
+ /**
+ * Returns the details of one or more remediation configurations.
See
+ * Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeRemediationConfigurationsOutcome DescribeRemediationConfigurations(const Model::DescribeRemediationConfigurationsRequest& request) const;
+
+ /**
+ * A Callable wrapper for DescribeRemediationConfigurations that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeRemediationConfigurationsOutcomeCallable DescribeRemediationConfigurationsCallable(const DescribeRemediationConfigurationsRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeRemediationConfigurations, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeRemediationConfigurations that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeRemediationConfigurationsAsync(const DescribeRemediationConfigurationsRequestT& request, const DescribeRemediationConfigurationsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeRemediationConfigurations, request, handler, context);
+ }
+
+ /**
+ * Returns the details of one or more remediation exceptions. A detailed view of
+ * a remediation exception for a set of resources that includes an explanation of
+ * an exception and the time when the exception will be deleted. When you specify
+ * the limit and the next token, you receive a paginated response.
+ * Config generates a remediation exception when a problem occurs executing a
+ * remediation action to a specific resource. Remediation exceptions blocks
+ * auto-remediation until the exception is cleared.
When you specify the
+ * limit and the next token, you receive a paginated response.
Limit and
+ * next token are not applicable if you request resources in batch. It is only
+ * applicable, when you request all resources.
See Also:
+ * AWS
+ * API Reference
+ */
+ virtual Model::DescribeRemediationExceptionsOutcome DescribeRemediationExceptions(const Model::DescribeRemediationExceptionsRequest& request) const;
+
+ /**
+ * A Callable wrapper for DescribeRemediationExceptions that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeRemediationExceptionsOutcomeCallable DescribeRemediationExceptionsCallable(const DescribeRemediationExceptionsRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeRemediationExceptions, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeRemediationExceptions that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeRemediationExceptionsAsync(const DescribeRemediationExceptionsRequestT& request, const DescribeRemediationExceptionsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeRemediationExceptions, request, handler, context);
+ }
+
+ /**
+ * Provides a detailed view of a Remediation Execution for a set of resources
+ * including state, timestamps for when steps for the remediation execution occur,
+ * and any error messages for steps that have failed. When you specify the limit
+ * and the next token, you receive a paginated response.
See Also:
+ * AWS
+ * API Reference
+ */
+ virtual Model::DescribeRemediationExecutionStatusOutcome DescribeRemediationExecutionStatus(const Model::DescribeRemediationExecutionStatusRequest& request) const;
+
+ /**
+ * A Callable wrapper for DescribeRemediationExecutionStatus that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeRemediationExecutionStatusOutcomeCallable DescribeRemediationExecutionStatusCallable(const DescribeRemediationExecutionStatusRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeRemediationExecutionStatus, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeRemediationExecutionStatus that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeRemediationExecutionStatusAsync(const DescribeRemediationExecutionStatusRequestT& request, const DescribeRemediationExecutionStatusResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeRemediationExecutionStatus, request, handler, context);
+ }
+
+ /**
+ * Returns the details of one or more retention configurations. If the retention
+ * configuration name is not specified, this operation returns the details for all
+ * the retention configurations for that account.
Currently, Config
+ * supports only one retention configuration per region in your account.
+ * See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DescribeRetentionConfigurationsOutcome DescribeRetentionConfigurations(const Model::DescribeRetentionConfigurationsRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for DescribeRetentionConfigurations that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DescribeRetentionConfigurationsOutcomeCallable DescribeRetentionConfigurationsCallable(const DescribeRetentionConfigurationsRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DescribeRetentionConfigurations, request);
+ }
+
+ /**
+ * An Async wrapper for DescribeRetentionConfigurations that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DescribeRetentionConfigurationsAsync(const DescribeRetentionConfigurationsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const DescribeRetentionConfigurationsRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DescribeRetentionConfigurations, request, handler, context);
+ }
+
+ /**
+ * Removes all resource types specified in the ResourceTypes list
+ * from the RecordingGroup
+ * of configuration recorder and excludes these resource types when recording.
+ * For this operation, the configuration recorder must use a RecordingStrategy
+ * that is either INCLUSION_BY_RESOURCE_TYPES or
+ * EXCLUSION_BY_RESOURCE_TYPES.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::DisassociateResourceTypesOutcome DisassociateResourceTypes(const Model::DisassociateResourceTypesRequest& request) const;
+
+ /**
+ * A Callable wrapper for DisassociateResourceTypes that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::DisassociateResourceTypesOutcomeCallable DisassociateResourceTypesCallable(const DisassociateResourceTypesRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::DisassociateResourceTypes, request);
+ }
+
+ /**
+ * An Async wrapper for DisassociateResourceTypes that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void DisassociateResourceTypesAsync(const DisassociateResourceTypesRequestT& request, const DisassociateResourceTypesResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::DisassociateResourceTypes, request, handler, context);
+ }
+
+ /**
+ * Returns the evaluation results for the specified Config rule for a specific
+ * resource in a rule. The results indicate which Amazon Web Services resources
+ * were evaluated by the rule, when each resource was last evaluated, and whether
+ * each resource complies with the rule.
The results can return an
+ * empty result page. But if you have a nextToken, the results are
+ * displayed on the next page.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetAggregateComplianceDetailsByConfigRuleOutcome GetAggregateComplianceDetailsByConfigRule(const Model::GetAggregateComplianceDetailsByConfigRuleRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetAggregateComplianceDetailsByConfigRule that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetAggregateComplianceDetailsByConfigRuleOutcomeCallable GetAggregateComplianceDetailsByConfigRuleCallable(const GetAggregateComplianceDetailsByConfigRuleRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetAggregateComplianceDetailsByConfigRule, request);
+ }
+
+ /**
+ * An Async wrapper for GetAggregateComplianceDetailsByConfigRule that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetAggregateComplianceDetailsByConfigRuleAsync(const GetAggregateComplianceDetailsByConfigRuleRequestT& request, const GetAggregateComplianceDetailsByConfigRuleResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetAggregateComplianceDetailsByConfigRule, request, handler, context);
+ }
+
+ /**
+ * Returns the number of compliant and noncompliant rules for one or more
+ * accounts and regions in an aggregator.
The results can return an
+ * empty result page, but if you have a nextToken, the results are displayed on the
+ * next page.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetAggregateConfigRuleComplianceSummaryOutcome GetAggregateConfigRuleComplianceSummary(const Model::GetAggregateConfigRuleComplianceSummaryRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetAggregateConfigRuleComplianceSummary that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetAggregateConfigRuleComplianceSummaryOutcomeCallable GetAggregateConfigRuleComplianceSummaryCallable(const GetAggregateConfigRuleComplianceSummaryRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetAggregateConfigRuleComplianceSummary, request);
+ }
+
+ /**
+ * An Async wrapper for GetAggregateConfigRuleComplianceSummary that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetAggregateConfigRuleComplianceSummaryAsync(const GetAggregateConfigRuleComplianceSummaryRequestT& request, const GetAggregateConfigRuleComplianceSummaryResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetAggregateConfigRuleComplianceSummary, request, handler, context);
+ }
+
+ /**
+ * Returns the count of compliant and noncompliant conformance packs across all
+ * Amazon Web Services accounts and Amazon Web Services Regions in an aggregator.
+ * You can filter based on Amazon Web Services account ID or Amazon Web Services
+ * Region.
The results can return an empty result page, but if you
+ * have a nextToken, the results are displayed on the next page.
+ * See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetAggregateConformancePackComplianceSummaryOutcome GetAggregateConformancePackComplianceSummary(const Model::GetAggregateConformancePackComplianceSummaryRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetAggregateConformancePackComplianceSummary that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetAggregateConformancePackComplianceSummaryOutcomeCallable GetAggregateConformancePackComplianceSummaryCallable(const GetAggregateConformancePackComplianceSummaryRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetAggregateConformancePackComplianceSummary, request);
+ }
+
+ /**
+ * An Async wrapper for GetAggregateConformancePackComplianceSummary that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetAggregateConformancePackComplianceSummaryAsync(const GetAggregateConformancePackComplianceSummaryRequestT& request, const GetAggregateConformancePackComplianceSummaryResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetAggregateConformancePackComplianceSummary, request, handler, context);
+ }
+
+ /**
+ * Returns the resource counts across accounts and regions that are present in
+ * your Config aggregator. You can request the resource counts by providing filters
+ * and GroupByKey.
For example, if the input contains accountID 12345678910
+ * and region us-east-1 in filters, the API returns the count of resources in
+ * account ID 12345678910 and region us-east-1. If the input contains ACCOUNT_ID as
+ * a GroupByKey, the API returns resource counts for all source accounts that are
+ * present in your aggregator.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetAggregateDiscoveredResourceCountsOutcome GetAggregateDiscoveredResourceCounts(const Model::GetAggregateDiscoveredResourceCountsRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetAggregateDiscoveredResourceCounts that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetAggregateDiscoveredResourceCountsOutcomeCallable GetAggregateDiscoveredResourceCountsCallable(const GetAggregateDiscoveredResourceCountsRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetAggregateDiscoveredResourceCounts, request);
+ }
+
+ /**
+ * An Async wrapper for GetAggregateDiscoveredResourceCounts that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetAggregateDiscoveredResourceCountsAsync(const GetAggregateDiscoveredResourceCountsRequestT& request, const GetAggregateDiscoveredResourceCountsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetAggregateDiscoveredResourceCounts, request, handler, context);
+ }
+
+ /**
+ * Returns configuration item that is aggregated for your specific resource in a
+ * specific source account and region.
The API does not return
+ * results for deleted resources.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetAggregateResourceConfigOutcome GetAggregateResourceConfig(const Model::GetAggregateResourceConfigRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetAggregateResourceConfig that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetAggregateResourceConfigOutcomeCallable GetAggregateResourceConfigCallable(const GetAggregateResourceConfigRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetAggregateResourceConfig, request);
+ }
+
+ /**
+ * An Async wrapper for GetAggregateResourceConfig that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetAggregateResourceConfigAsync(const GetAggregateResourceConfigRequestT& request, const GetAggregateResourceConfigResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetAggregateResourceConfig, request, handler, context);
+ }
+
+ /**
+ * Returns the evaluation results for the specified Config rule. The results
+ * indicate which Amazon Web Services resources were evaluated by the rule, when
+ * each resource was last evaluated, and whether each resource complies with the
+ * rule.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetComplianceDetailsByConfigRuleOutcome GetComplianceDetailsByConfigRule(const Model::GetComplianceDetailsByConfigRuleRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetComplianceDetailsByConfigRule that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetComplianceDetailsByConfigRuleOutcomeCallable GetComplianceDetailsByConfigRuleCallable(const GetComplianceDetailsByConfigRuleRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetComplianceDetailsByConfigRule, request);
+ }
+
+ /**
+ * An Async wrapper for GetComplianceDetailsByConfigRule that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetComplianceDetailsByConfigRuleAsync(const GetComplianceDetailsByConfigRuleRequestT& request, const GetComplianceDetailsByConfigRuleResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetComplianceDetailsByConfigRule, request, handler, context);
+ }
+
+ /**
+ * Returns the evaluation results for the specified Amazon Web Services
+ * resource. The results indicate which Config rules were used to evaluate the
+ * resource, when each rule was last invoked, and whether the resource complies
+ * with each rule.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetComplianceDetailsByResourceOutcome GetComplianceDetailsByResource(const Model::GetComplianceDetailsByResourceRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for GetComplianceDetailsByResource that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetComplianceDetailsByResourceOutcomeCallable GetComplianceDetailsByResourceCallable(const GetComplianceDetailsByResourceRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetComplianceDetailsByResource, request);
+ }
+
+ /**
+ * An Async wrapper for GetComplianceDetailsByResource that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetComplianceDetailsByResourceAsync(const GetComplianceDetailsByResourceResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const GetComplianceDetailsByResourceRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetComplianceDetailsByResource, request, handler, context);
+ }
+
+ /**
+ * Returns the number of Config rules that are compliant and noncompliant, up to
+ * a maximum of 25 for each.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetComplianceSummaryByConfigRuleOutcome GetComplianceSummaryByConfigRule(const Model::GetComplianceSummaryByConfigRuleRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for GetComplianceSummaryByConfigRule that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetComplianceSummaryByConfigRuleOutcomeCallable GetComplianceSummaryByConfigRuleCallable(const GetComplianceSummaryByConfigRuleRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetComplianceSummaryByConfigRule, request);
+ }
+
+ /**
+ * An Async wrapper for GetComplianceSummaryByConfigRule that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetComplianceSummaryByConfigRuleAsync(const GetComplianceSummaryByConfigRuleResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const GetComplianceSummaryByConfigRuleRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetComplianceSummaryByConfigRule, request, handler, context);
+ }
+
+ /**
+ * Returns the number of resources that are compliant and the number that are
+ * noncompliant. You can specify one or more resource types to get these numbers
+ * for each resource type. The maximum number returned is 100.
See
+ * Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetComplianceSummaryByResourceTypeOutcome GetComplianceSummaryByResourceType(const Model::GetComplianceSummaryByResourceTypeRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for GetComplianceSummaryByResourceType that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetComplianceSummaryByResourceTypeOutcomeCallable GetComplianceSummaryByResourceTypeCallable(const GetComplianceSummaryByResourceTypeRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetComplianceSummaryByResourceType, request);
+ }
+
+ /**
+ * An Async wrapper for GetComplianceSummaryByResourceType that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetComplianceSummaryByResourceTypeAsync(const GetComplianceSummaryByResourceTypeResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const GetComplianceSummaryByResourceTypeRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetComplianceSummaryByResourceType, request, handler, context);
+ }
+
+ /**
+ * Returns compliance details of a conformance pack for all Amazon Web Services
+ * resources that are monitered by conformance pack.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetConformancePackComplianceDetailsOutcome GetConformancePackComplianceDetails(const Model::GetConformancePackComplianceDetailsRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetConformancePackComplianceDetails that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetConformancePackComplianceDetailsOutcomeCallable GetConformancePackComplianceDetailsCallable(const GetConformancePackComplianceDetailsRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetConformancePackComplianceDetails, request);
+ }
+
+ /**
+ * An Async wrapper for GetConformancePackComplianceDetails that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetConformancePackComplianceDetailsAsync(const GetConformancePackComplianceDetailsRequestT& request, const GetConformancePackComplianceDetailsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetConformancePackComplianceDetails, request, handler, context);
+ }
+
+ /**
+ * Returns compliance details for the conformance pack based on the cumulative
+ * compliance results of all the rules in that conformance pack.
See
+ * Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetConformancePackComplianceSummaryOutcome GetConformancePackComplianceSummary(const Model::GetConformancePackComplianceSummaryRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetConformancePackComplianceSummary that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetConformancePackComplianceSummaryOutcomeCallable GetConformancePackComplianceSummaryCallable(const GetConformancePackComplianceSummaryRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetConformancePackComplianceSummary, request);
+ }
+
+ /**
+ * An Async wrapper for GetConformancePackComplianceSummary that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetConformancePackComplianceSummaryAsync(const GetConformancePackComplianceSummaryRequestT& request, const GetConformancePackComplianceSummaryResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetConformancePackComplianceSummary, request, handler, context);
+ }
+
+ /**
+ * Returns the policy definition containing the logic for your Config Custom
+ * Policy rule.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetCustomRulePolicyOutcome GetCustomRulePolicy(const Model::GetCustomRulePolicyRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for GetCustomRulePolicy that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetCustomRulePolicyOutcomeCallable GetCustomRulePolicyCallable(const GetCustomRulePolicyRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetCustomRulePolicy, request);
+ }
+
+ /**
+ * An Async wrapper for GetCustomRulePolicy that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetCustomRulePolicyAsync(const GetCustomRulePolicyResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const GetCustomRulePolicyRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetCustomRulePolicy, request, handler, context);
+ }
+
+ /**
+ * Returns the resource types, the number of each resource type, and the total
+ * number of resources that Config is recording in this region for your Amazon Web
+ * Services account.
Example
-
Config
+ * is recording three resource types in the US East (Ohio) Region for your account:
+ * 25 EC2 instances, 20 IAM users, and 15 S3 buckets.
-
You make a
+ * call to the GetDiscoveredResourceCounts action and specify that you
+ * want all resource types.
-
Config returns the following:
+ * -
The resource types (EC2 instances, IAM users, and S3 buckets).
+ * -
The number of each resource type (25, 20, and 15).
-
+ *
The total number of all resources (60).
The
+ * response is paginated. By default, Config lists 100 ResourceCount objects
+ * on each page. You can customize this number with the limit
+ * parameter. The response includes a nextToken string. To get the
+ * next page of results, run the request again and specify the string for the
+ * nextToken parameter.
If you make a call to the
+ * GetDiscoveredResourceCounts action, you might not immediately receive
+ * resource counts in the following situations:
It might take a few minutes for Config to record and count your
+ * resources. Wait a few minutes and then retry the
+ * GetDiscoveredResourceCounts action.
See Also:
+ * AWS
+ * API Reference
+ */
+ virtual Model::GetDiscoveredResourceCountsOutcome GetDiscoveredResourceCounts(const Model::GetDiscoveredResourceCountsRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for GetDiscoveredResourceCounts that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetDiscoveredResourceCountsOutcomeCallable GetDiscoveredResourceCountsCallable(const GetDiscoveredResourceCountsRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetDiscoveredResourceCounts, request);
+ }
+
+ /**
+ * An Async wrapper for GetDiscoveredResourceCounts that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetDiscoveredResourceCountsAsync(const GetDiscoveredResourceCountsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const GetDiscoveredResourceCountsRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetDiscoveredResourceCounts, request, handler, context);
+ }
+
+ /**
+ * Returns detailed status for each member account within an organization for a
+ * given organization Config rule.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetOrganizationConfigRuleDetailedStatusOutcome GetOrganizationConfigRuleDetailedStatus(const Model::GetOrganizationConfigRuleDetailedStatusRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetOrganizationConfigRuleDetailedStatus that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetOrganizationConfigRuleDetailedStatusOutcomeCallable GetOrganizationConfigRuleDetailedStatusCallable(const GetOrganizationConfigRuleDetailedStatusRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetOrganizationConfigRuleDetailedStatus, request);
+ }
+
+ /**
+ * An Async wrapper for GetOrganizationConfigRuleDetailedStatus that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetOrganizationConfigRuleDetailedStatusAsync(const GetOrganizationConfigRuleDetailedStatusRequestT& request, const GetOrganizationConfigRuleDetailedStatusResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetOrganizationConfigRuleDetailedStatus, request, handler, context);
+ }
+
+ /**
+ * Returns detailed status for each member account within an organization for a
+ * given organization conformance pack.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetOrganizationConformancePackDetailedStatusOutcome GetOrganizationConformancePackDetailedStatus(const Model::GetOrganizationConformancePackDetailedStatusRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetOrganizationConformancePackDetailedStatus that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetOrganizationConformancePackDetailedStatusOutcomeCallable GetOrganizationConformancePackDetailedStatusCallable(const GetOrganizationConformancePackDetailedStatusRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetOrganizationConformancePackDetailedStatus, request);
+ }
+
+ /**
+ * An Async wrapper for GetOrganizationConformancePackDetailedStatus that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetOrganizationConformancePackDetailedStatusAsync(const GetOrganizationConformancePackDetailedStatusRequestT& request, const GetOrganizationConformancePackDetailedStatusResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetOrganizationConformancePackDetailedStatus, request, handler, context);
+ }
+
+ /**
+ * Returns the policy definition containing the logic for your organization
+ * Config Custom Policy rule.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetOrganizationCustomRulePolicyOutcome GetOrganizationCustomRulePolicy(const Model::GetOrganizationCustomRulePolicyRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetOrganizationCustomRulePolicy that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetOrganizationCustomRulePolicyOutcomeCallable GetOrganizationCustomRulePolicyCallable(const GetOrganizationCustomRulePolicyRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetOrganizationCustomRulePolicy, request);
+ }
+
+ /**
+ * An Async wrapper for GetOrganizationCustomRulePolicy that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetOrganizationCustomRulePolicyAsync(const GetOrganizationCustomRulePolicyRequestT& request, const GetOrganizationCustomRulePolicyResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetOrganizationCustomRulePolicy, request, handler, context);
+ }
+
+ /**
+ * For accurate reporting on the compliance status, you must record
+ * the AWS::Config::ResourceCompliance resource type. For more
+ * information, see Selecting
+ * Which Resources Config Records.
Returns a list of
+ * ConfigurationItems for the specified resource. The list contains
+ * details about each state of the resource during the specified time interval. If
+ * you specified a retention period to retain your ConfigurationItems
+ * between a minimum of 30 days and a maximum of 7 years (2557 days), Config
+ * returns the ConfigurationItems for the specified retention period.
+ *
The response is paginated. By default, Config returns a limit of 10
+ * configuration items per page. You can customize this number with the
+ * limit parameter. The response includes a nextToken
+ * string. To get the next page of results, run the request again and specify the
+ * string for the nextToken parameter.
Each call to the
+ * API is limited to span a duration of seven days. It is likely that the number of
+ * records returned is smaller than the specified limit. In such
+ * cases, you can make another call, using the nextToken.
+ * See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetResourceConfigHistoryOutcome GetResourceConfigHistory(const Model::GetResourceConfigHistoryRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetResourceConfigHistory that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetResourceConfigHistoryOutcomeCallable GetResourceConfigHistoryCallable(const GetResourceConfigHistoryRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetResourceConfigHistory, request);
+ }
+
+ /**
+ * An Async wrapper for GetResourceConfigHistory that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetResourceConfigHistoryAsync(const GetResourceConfigHistoryRequestT& request, const GetResourceConfigHistoryResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetResourceConfigHistory, request, handler, context);
+ }
+
+ /**
+ * Returns a summary of resource evaluation for the specified resource
+ * evaluation ID from the proactive rules that were run. The results indicate which
+ * evaluation context was used to evaluate the rules, which resource details were
+ * evaluated, the evaluation mode that was run, and whether the resource details
+ * comply with the configuration of the proactive rules.
To see
+ * additional information about the evaluation result, such as which rule flagged a
+ * resource as NON_COMPLIANT, use the GetComplianceDetailsByResource
+ * API. For more information, see the Examples
+ * section.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetResourceEvaluationSummaryOutcome GetResourceEvaluationSummary(const Model::GetResourceEvaluationSummaryRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetResourceEvaluationSummary that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetResourceEvaluationSummaryOutcomeCallable GetResourceEvaluationSummaryCallable(const GetResourceEvaluationSummaryRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetResourceEvaluationSummary, request);
+ }
+
+ /**
+ * An Async wrapper for GetResourceEvaluationSummary that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetResourceEvaluationSummaryAsync(const GetResourceEvaluationSummaryRequestT& request, const GetResourceEvaluationSummaryResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetResourceEvaluationSummary, request, handler, context);
+ }
+
+ /**
+ * Returns the details of a specific stored query.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::GetStoredQueryOutcome GetStoredQuery(const Model::GetStoredQueryRequest& request) const;
+
+ /**
+ * A Callable wrapper for GetStoredQuery that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::GetStoredQueryOutcomeCallable GetStoredQueryCallable(const GetStoredQueryRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::GetStoredQuery, request);
+ }
+
+ /**
+ * An Async wrapper for GetStoredQuery that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void GetStoredQueryAsync(const GetStoredQueryRequestT& request, const GetStoredQueryResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::GetStoredQuery, request, handler, context);
+ }
+
+ /**
+ * Accepts a resource type and returns a list of resource identifiers that are
+ * aggregated for a specific resource type across accounts and regions. A resource
+ * identifier includes the resource type, ID, (if available) the custom resource
+ * name, source account, and source region. You can narrow the results to include
+ * only resources that have specific resource IDs, or a resource name, or source
+ * account ID, or source region.
For example, if the input consists of
+ * accountID 12345678910 and the region is us-east-1 for resource type
+ * AWS::EC2::Instance then the API returns all the EC2 instance
+ * identifiers of accountID 12345678910 and region us-east-1.
See
+ * Also:
AWS
+ * API Reference
+ */
+ virtual Model::ListAggregateDiscoveredResourcesOutcome ListAggregateDiscoveredResources(const Model::ListAggregateDiscoveredResourcesRequest& request) const;
+
+ /**
+ * A Callable wrapper for ListAggregateDiscoveredResources that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::ListAggregateDiscoveredResourcesOutcomeCallable ListAggregateDiscoveredResourcesCallable(const ListAggregateDiscoveredResourcesRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::ListAggregateDiscoveredResources, request);
+ }
+
+ /**
+ * An Async wrapper for ListAggregateDiscoveredResources that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void ListAggregateDiscoveredResourcesAsync(const ListAggregateDiscoveredResourcesRequestT& request, const ListAggregateDiscoveredResourcesResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::ListAggregateDiscoveredResources, request, handler, context);
+ }
+
+ /**
+ * Returns a list of configuration recorders depending on the filters you
+ * specify.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::ListConfigurationRecordersOutcome ListConfigurationRecorders(const Model::ListConfigurationRecordersRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for ListConfigurationRecorders that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::ListConfigurationRecordersOutcomeCallable ListConfigurationRecordersCallable(const ListConfigurationRecordersRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::ListConfigurationRecorders, request);
+ }
+
+ /**
+ * An Async wrapper for ListConfigurationRecorders that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void ListConfigurationRecordersAsync(const ListConfigurationRecordersResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const ListConfigurationRecordersRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::ListConfigurationRecorders, request, handler, context);
+ }
+
+ /**
+ * Returns a list of conformance pack compliance scores. A compliance score is
+ * the percentage of the number of compliant rule-resource combinations in a
+ * conformance pack compared to the number of total possible rule-resource
+ * combinations in the conformance pack. This metric provides you with a high-level
+ * view of the compliance state of your conformance packs. You can use it to
+ * identify, investigate, and understand the level of compliance in your
+ * conformance packs.
Conformance packs with no evaluation results
+ * will have a compliance score of INSUFFICIENT_DATA.
+ * See Also:
AWS
+ * API Reference
+ */
+ virtual Model::ListConformancePackComplianceScoresOutcome ListConformancePackComplianceScores(const Model::ListConformancePackComplianceScoresRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for ListConformancePackComplianceScores that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::ListConformancePackComplianceScoresOutcomeCallable ListConformancePackComplianceScoresCallable(const ListConformancePackComplianceScoresRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::ListConformancePackComplianceScores, request);
+ }
+
+ /**
+ * An Async wrapper for ListConformancePackComplianceScores that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void ListConformancePackComplianceScoresAsync(const ListConformancePackComplianceScoresResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const ListConformancePackComplianceScoresRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::ListConformancePackComplianceScores, request, handler, context);
+ }
+
+ /**
+ * Accepts a resource type and returns a list of resource identifiers for the
+ * resources of that type. A resource identifier includes the resource type, ID,
+ * and (if available) the custom resource name. The results consist of resources
+ * that Config has discovered, including those that Config is not currently
+ * recording. You can narrow the results to include only resources that have
+ * specific resource IDs or a resource name.
You can specify either
+ * resource IDs or a resource name, but not both, in the same request.
+ * The response is paginated. By default, Config lists 100 resource identifiers
+ * on each page. You can customize this number with the limit
+ * parameter. The response includes a nextToken string. To get the
+ * next page of results, run the request again and specify the string for the
+ * nextToken parameter.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::ListDiscoveredResourcesOutcome ListDiscoveredResources(const Model::ListDiscoveredResourcesRequest& request) const;
+
+ /**
+ * A Callable wrapper for ListDiscoveredResources that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::ListDiscoveredResourcesOutcomeCallable ListDiscoveredResourcesCallable(const ListDiscoveredResourcesRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::ListDiscoveredResources, request);
+ }
+
+ /**
+ * An Async wrapper for ListDiscoveredResources that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void ListDiscoveredResourcesAsync(const ListDiscoveredResourcesRequestT& request, const ListDiscoveredResourcesResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::ListDiscoveredResources, request, handler, context);
+ }
+
+ /**
+ * Returns a list of proactive resource evaluations.
See Also:
+ * AWS
+ * API Reference
+ */
+ virtual Model::ListResourceEvaluationsOutcome ListResourceEvaluations(const Model::ListResourceEvaluationsRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for ListResourceEvaluations that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::ListResourceEvaluationsOutcomeCallable ListResourceEvaluationsCallable(const ListResourceEvaluationsRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::ListResourceEvaluations, request);
+ }
+
+ /**
+ * An Async wrapper for ListResourceEvaluations that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void ListResourceEvaluationsAsync(const ListResourceEvaluationsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const ListResourceEvaluationsRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::ListResourceEvaluations, request, handler, context);
+ }
+
+ /**
+ * Lists the stored queries for a single Amazon Web Services account and a
+ * single Amazon Web Services Region. The default is 100.
See Also:
+ * AWS
+ * API Reference
+ */
+ virtual Model::ListStoredQueriesOutcome ListStoredQueries(const Model::ListStoredQueriesRequest& request = {}) const;
+
+ /**
+ * A Callable wrapper for ListStoredQueries that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::ListStoredQueriesOutcomeCallable ListStoredQueriesCallable(const ListStoredQueriesRequestT& request = {}) const
+ {
+ return SubmitCallable(&ConfigServiceClient::ListStoredQueries, request);
+ }
+
+ /**
+ * An Async wrapper for ListStoredQueries that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void ListStoredQueriesAsync(const ListStoredQueriesResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr, const ListStoredQueriesRequestT& request = {}) const
+ {
+ return SubmitAsync(&ConfigServiceClient::ListStoredQueries, request, handler, context);
+ }
+
+ /**
+ * List the tags for Config resource.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::ListTagsForResourceOutcome ListTagsForResource(const Model::ListTagsForResourceRequest& request) const;
+
+ /**
+ * A Callable wrapper for ListTagsForResource that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::ListTagsForResourceOutcomeCallable ListTagsForResourceCallable(const ListTagsForResourceRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::ListTagsForResource, request);
+ }
+
+ /**
+ * An Async wrapper for ListTagsForResource that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void ListTagsForResourceAsync(const ListTagsForResourceRequestT& request, const ListTagsForResourceResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::ListTagsForResource, request, handler, context);
+ }
+
+ /**
+ * Authorizes the aggregator account and region to collect data from the source
+ * account and region.
Tags are added at creation and cannot be
+ * updated with this operation
+ * PutAggregationAuthorization is an idempotent API. Subsequent
+ * requests won’t create a duplicate resource if one was already created. If a
+ * following request has different tags values, Config will ignore
+ * these differences and treat it as an idempotent request of the previous. In this
+ * case, tags will not be updated, even if they are different.
+ * Use TagResource
+ * and UntagResource
+ * to update tags after creation.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutAggregationAuthorizationOutcome PutAggregationAuthorization(const Model::PutAggregationAuthorizationRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutAggregationAuthorization that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutAggregationAuthorizationOutcomeCallable PutAggregationAuthorizationCallable(const PutAggregationAuthorizationRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutAggregationAuthorization, request);
+ }
+
+ /**
+ * An Async wrapper for PutAggregationAuthorization that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void PutAggregationAuthorizationAsync(const PutAggregationAuthorizationRequestT& request, const PutAggregationAuthorizationResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::PutAggregationAuthorization, request, handler, context);
+ }
+
+ /**
+ * Adds or updates an Config rule to evaluate if your Amazon Web Services
+ * resources comply with your desired configurations. For information on how many
+ * Config rules you can have per account, see
+ * Service Limits in the Config Developer Guide.
There
+ * are two types of rules: Config Managed Rules and Config Custom
+ * Rules. You can use PutConfigRule to create both Config Managed
+ * Rules and Config Custom Rules.
Config Managed Rules are predefined,
+ * customizable rules created by Config. For a list of managed rules, see List
+ * of Config Managed Rules. If you are adding an Config managed rule, you must
+ * specify the rule's identifier for the SourceIdentifier key.
+ * Config Custom Rules are rules that you create from scratch. There are two
+ * ways to create Config custom rules: with Lambda functions (
+ * Lambda Developer Guide) and with Guard (Guard GitHub
+ * Repository), a policy-as-code language. Config custom rules created with
+ * Lambda are called Config Custom Lambda Rules and Config custom rules
+ * created with Guard are called Config Custom Policy Rules.
If you
+ * are adding a new Config Custom Lambda rule, you first need to create an Lambda
+ * function that the rule invokes to evaluate your resources. When you use
+ * PutConfigRule to add a Custom Lambda rule to Config, you must
+ * specify the Amazon Resource Name (ARN) that Lambda assigns to the function. You
+ * specify the ARN in the SourceIdentifier key. This key is part of
+ * the Source object, which is part of the ConfigRule
+ * object.
For any new Config rule that you add, specify the
+ * ConfigRuleName in the ConfigRule object. Do not
+ * specify the ConfigRuleArn or the ConfigRuleId. These
+ * values are generated by Config for new rules.
If you are updating a rule
+ * that you added previously, you can specify the rule by
+ * ConfigRuleName, ConfigRuleId, or
+ * ConfigRuleArn in the ConfigRule data type that you use
+ * in this request.
For more information about developing and using Config
+ * rules, see Evaluating
+ * Resources with Config Rules in the Config Developer Guide.
+ * Tags are added at creation and cannot be updated with this operation
+ *
PutConfigRule is an idempotent API. Subsequent requests
+ * won’t create a duplicate resource if one was already created. If a following
+ * request has different tags values, Config will ignore these
+ * differences and treat it as an idempotent request of the previous. In this case,
+ * tags will not be updated, even if they are different.
Use TagResource
+ * and UntagResource
+ * to update tags after creation.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutConfigRuleOutcome PutConfigRule(const Model::PutConfigRuleRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutConfigRule that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutConfigRuleOutcomeCallable PutConfigRuleCallable(const PutConfigRuleRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutConfigRule, request);
+ }
+
+ /**
+ * An Async wrapper for PutConfigRule that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void PutConfigRuleAsync(const PutConfigRuleRequestT& request, const PutConfigRuleResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::PutConfigRule, request, handler, context);
+ }
+
+ /**
+ * Creates and updates the configuration aggregator with the selected source
+ * accounts and regions. The source account can be individual account(s) or an
+ * organization.
accountIds that are passed will be replaced
+ * with existing accounts. If you want to add additional accounts into the
+ * aggregator, call DescribeConfigurationAggregators to get the
+ * previous accounts and then append new ones.
Config should be
+ * enabled in source accounts and regions you want to aggregate.
If your
+ * source type is an organization, you must be signed in to the management account
+ * or a registered delegated administrator and all the features must be enabled in
+ * your organization. If the caller is a management account, Config calls
+ * EnableAwsServiceAccess API to enable integration between Config and
+ * Organizations. If the caller is a registered delegated administrator, Config
+ * calls ListDelegatedAdministrators API to verify whether the caller
+ * is a valid delegated administrator.
To register a delegated
+ * administrator, see Register
+ * a Delegated Administrator in the Config developer guide.
+ * Tags are added at creation and cannot be updated with this
+ * operation
PutConfigurationAggregator is an idempotent
+ * API. Subsequent requests won’t create a duplicate resource if one was already
+ * created. If a following request has different tags values, Config
+ * will ignore these differences and treat it as an idempotent request of the
+ * previous. In this case, tags will not be updated, even if they are
+ * different.
Use TagResource
+ * and UntagResource
+ * to update tags after creation.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutConfigurationAggregatorOutcome PutConfigurationAggregator(const Model::PutConfigurationAggregatorRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutConfigurationAggregator that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutConfigurationAggregatorOutcomeCallable PutConfigurationAggregatorCallable(const PutConfigurationAggregatorRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutConfigurationAggregator, request);
+ }
+
+ /**
+ * An Async wrapper for PutConfigurationAggregator that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void PutConfigurationAggregatorAsync(const PutConfigurationAggregatorRequestT& request, const PutConfigurationAggregatorResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::PutConfigurationAggregator, request, handler, context);
+ }
+
+ /**
+ * Creates or updates the customer managed configuration recorder.
You
+ * can use this operation to create a new customer managed configuration recorder
+ * or to update the roleARN and the recordingGroup for an
+ * existing customer managed configuration recorder.
To start the customer
+ * managed configuration recorder and begin recording configuration changes for the
+ * resource types you specify, use the StartConfigurationRecorder
+ * operation.
For more information, see
+ * Working with the Configuration Recorder in the Config Developer
+ * Guide.
One customer managed configuration recorder per
+ * account per Region
You can create only one customer managed
+ * configuration recorder for each account for each Amazon Web Services Region.
+ * Default is to record all supported resource types, excluding the global
+ * IAM resource types
If you have not specified values for the
+ * recordingGroup field, the default for the customer managed
+ * configuration recorder is to record all supported resource types, excluding the
+ * global IAM resource types: AWS::IAM::Group,
+ * AWS::IAM::Policy, AWS::IAM::Role, and
+ * AWS::IAM::User.
Tags are added at creation and cannot be
+ * updated
PutConfigurationRecorder is an idempotent API.
+ * Subsequent requests won’t create a duplicate resource if one was already
+ * created. If a following request has different tags values, Config will ignore
+ * these differences and treat it as an idempotent request of the previous. In this
+ * case, tags will not be updated, even if they are different.
Use TagResource
+ * and UntagResource
+ * to update tags after creation.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutConfigurationRecorderOutcome PutConfigurationRecorder(const Model::PutConfigurationRecorderRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutConfigurationRecorder that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutConfigurationRecorderOutcomeCallable PutConfigurationRecorderCallable(const PutConfigurationRecorderRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutConfigurationRecorder, request);
+ }
+
+ /**
+ * An Async wrapper for PutConfigurationRecorder that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void PutConfigurationRecorderAsync(const PutConfigurationRecorderRequestT& request, const PutConfigurationRecorderResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::PutConfigurationRecorder, request, handler, context);
+ }
+
+ /**
+ * Creates or updates a conformance pack. A conformance pack is a collection of
+ * Config rules that can be easily deployed in an account and a region and across
+ * an organization. For information on how many conformance packs you can have per
+ * account, see
+ * Service Limits in the Config Developer Guide.
This API
+ * creates a service-linked role AWSServiceRoleForConfigConforms in
+ * your account. The service-linked role is created only when the role does not
+ * exist in your account.
You must specify only one of the follow
+ * parameters: TemplateS3Uri, TemplateBody or
+ * TemplateSSMDocumentDetails.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutConformancePackOutcome PutConformancePack(const Model::PutConformancePackRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutConformancePack that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutConformancePackOutcomeCallable PutConformancePackCallable(const PutConformancePackRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutConformancePack, request);
+ }
+
+ /**
+ * An Async wrapper for PutConformancePack that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void PutConformancePackAsync(const PutConformancePackRequestT& request, const PutConformancePackResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::PutConformancePack, request, handler, context);
+ }
+
+ /**
+ * Creates or updates a delivery channel to deliver configuration information
+ * and other compliance information.
You can use this operation to create a
+ * new delivery channel or to update the Amazon S3 bucket and the Amazon SNS topic
+ * of an existing delivery channel.
For more information, see
+ * Working with the Delivery Channel in the Config Developer
+ * Guide.
One delivery channel per account per Region
+ *
You can have only one delivery channel for each account for each Amazon
+ * Web Services Region.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutDeliveryChannelOutcome PutDeliveryChannel(const Model::PutDeliveryChannelRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutDeliveryChannel that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutDeliveryChannelOutcomeCallable PutDeliveryChannelCallable(const PutDeliveryChannelRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutDeliveryChannel, request);
+ }
+
+ /**
+ * An Async wrapper for PutDeliveryChannel that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void PutDeliveryChannelAsync(const PutDeliveryChannelRequestT& request, const PutDeliveryChannelResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::PutDeliveryChannel, request, handler, context);
+ }
+
+ /**
+ * Used by an Lambda function to deliver evaluation results to Config. This
+ * operation is required in every Lambda function that is invoked by an Config
+ * rule.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutEvaluationsOutcome PutEvaluations(const Model::PutEvaluationsRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutEvaluations that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutEvaluationsOutcomeCallable PutEvaluationsCallable(const PutEvaluationsRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutEvaluations, request);
+ }
+
+ /**
+ * An Async wrapper for PutEvaluations that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void PutEvaluationsAsync(const PutEvaluationsRequestT& request, const PutEvaluationsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::PutEvaluations, request, handler, context);
+ }
+
+ /**
+ * Add or updates the evaluations for process checks. This API checks if the
+ * rule is a process check when the name of the Config rule is
+ * provided.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutExternalEvaluationOutcome PutExternalEvaluation(const Model::PutExternalEvaluationRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutExternalEvaluation that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutExternalEvaluationOutcomeCallable PutExternalEvaluationCallable(const PutExternalEvaluationRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutExternalEvaluation, request);
+ }
+
+ /**
+ * An Async wrapper for PutExternalEvaluation that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void PutExternalEvaluationAsync(const PutExternalEvaluationRequestT& request, const PutExternalEvaluationResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::PutExternalEvaluation, request, handler, context);
+ }
+
+ /**
+ * Adds or updates an Config rule for your entire organization to evaluate if
+ * your Amazon Web Services resources comply with your desired configurations. For
+ * information on how many organization Config rules you can have per account, see
+ *
+ * Service Limits in the Config Developer Guide.
Only a
+ * management account and a delegated administrator can create or update an
+ * organization Config rule. When calling this API with a delegated administrator,
+ * you must ensure Organizations ListDelegatedAdministrator
+ * permissions are added. An organization can have up to 3 delegated
+ * administrators.
This API enables organization service access through the
+ * EnableAWSServiceAccess action and creates a service-linked role
+ * AWSServiceRoleForConfigMultiAccountSetup in the management or
+ * delegated administrator account of your organization. The service-linked role is
+ * created only when the role does not exist in the caller account. Config verifies
+ * the existence of role with GetRole action.
To use this API
+ * with delegated administrator, register a delegated administrator by calling
+ * Amazon Web Services Organization register-delegated-administrator
+ * for config-multiaccountsetup.amazonaws.com.
There are two
+ * types of rules: Config Managed Rules and Config Custom Rules. You
+ * can use PutOrganizationConfigRule to create both Config Managed
+ * Rules and Config Custom Rules.
Config Managed Rules are predefined,
+ * customizable rules created by Config. For a list of managed rules, see List
+ * of Config Managed Rules. If you are adding an Config managed rule, you must
+ * specify the rule's identifier for the RuleIdentifier key.
+ * Config Custom Rules are rules that you create from scratch. There are two
+ * ways to create Config custom rules: with Lambda functions (
+ * Lambda Developer Guide) and with Guard (Guard GitHub
+ * Repository), a policy-as-code language. Config custom rules created with
+ * Lambda are called Config Custom Lambda Rules and Config custom rules
+ * created with Guard are called Config Custom Policy Rules.
If you
+ * are adding a new Config Custom Lambda rule, you first need to create an Lambda
+ * function in the management account or a delegated administrator that the rule
+ * invokes to evaluate your resources. You also need to create an IAM role in the
+ * managed account that can be assumed by the Lambda function. When you use
+ * PutOrganizationConfigRule to add a Custom Lambda rule to Config,
+ * you must specify the Amazon Resource Name (ARN) that Lambda assigns to the
+ * function.
Prerequisite: Ensure you call
+ * EnableAllFeatures API to enable all features in an
+ * organization.
Make sure to specify one of either
+ * OrganizationCustomPolicyRuleMetadata for Custom Policy rules,
+ * OrganizationCustomRuleMetadata for Custom Lambda rules, or
+ * OrganizationManagedRuleMetadata for managed rules.
+ * See Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutOrganizationConfigRuleOutcome PutOrganizationConfigRule(const Model::PutOrganizationConfigRuleRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutOrganizationConfigRule that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutOrganizationConfigRuleOutcomeCallable PutOrganizationConfigRuleCallable(const PutOrganizationConfigRuleRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutOrganizationConfigRule, request);
+ }
+
+ /**
+ * An Async wrapper for PutOrganizationConfigRule that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void PutOrganizationConfigRuleAsync(const PutOrganizationConfigRuleRequestT& request, const PutOrganizationConfigRuleResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::PutOrganizationConfigRule, request, handler, context);
+ }
+
+ /**
+ * Deploys conformance packs across member accounts in an Amazon Web Services
+ * Organization. For information on how many organization conformance packs and how
+ * many Config rules you can have per account, see
+ * Service Limits in the Config Developer Guide.
Only a
+ * management account and a delegated administrator can call this API. When calling
+ * this API with a delegated administrator, you must ensure Organizations
+ * ListDelegatedAdministrator permissions are added. An organization
+ * can have up to 3 delegated administrators.
This API enables organization
+ * service access for config-multiaccountsetup.amazonaws.com through
+ * the EnableAWSServiceAccess action and creates a service-linked role
+ * AWSServiceRoleForConfigMultiAccountSetup in the management or
+ * delegated administrator account of your organization. The service-linked role is
+ * created only when the role does not exist in the caller account. To use this API
+ * with delegated administrator, register a delegated administrator by calling
+ * Amazon Web Services Organization register-delegate-admin for
+ * config-multiaccountsetup.amazonaws.com.
Prerequisite:
+ * Ensure you call EnableAllFeatures API to enable all features in an
+ * organization.
You must specify either the TemplateS3Uri or
+ * the TemplateBody parameter, but not both. If you provide both
+ * Config uses the TemplateS3Uri parameter and ignores the
+ * TemplateBody parameter.
Config sets the state of a
+ * conformance pack to CREATE_IN_PROGRESS and UPDATE_IN_PROGRESS until the
+ * conformance pack is created or updated. You cannot update a conformance pack
+ * while it is in this state.
See Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutOrganizationConformancePackOutcome PutOrganizationConformancePack(const Model::PutOrganizationConformancePackRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutOrganizationConformancePack that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutOrganizationConformancePackOutcomeCallable PutOrganizationConformancePackCallable(const PutOrganizationConformancePackRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutOrganizationConformancePack, request);
+ }
+
+ /**
+ * An Async wrapper for PutOrganizationConformancePack that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void PutOrganizationConformancePackAsync(const PutOrganizationConformancePackRequestT& request, const PutOrganizationConformancePackResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::PutOrganizationConformancePack, request, handler, context);
+ }
+
+ /**
+ * Adds or updates the remediation configuration with a specific Config rule
+ * with the selected target or action. The API creates the
+ * RemediationConfiguration object for the Config rule. The Config
+ * rule must already exist for you to add a remediation configuration. The target
+ * (SSM document) must exist and have permissions to use the target.
+ * Be aware of backward incompatible changes
If you make
+ * backward incompatible changes to the SSM document, you must call this again to
+ * ensure the remediations can run.
This API does not support adding
+ * remediation configurations for service-linked Config Rules such as Organization
+ * Config rules, the rules deployed by conformance packs, and rules deployed by
+ * Amazon Web Services Security Hub.
Required fields
+ *
For manual remediation configuration, you need to provide a value for
+ * automationAssumeRole or use a value in the
+ * assumeRolefield to remediate your resources. The SSM automation
+ * document can use either as long as it maps to a valid parameter.
However,
+ * for automatic remediation configuration, the only valid assumeRole
+ * field value is AutomationAssumeRole and you need to provide a value
+ * for AutomationAssumeRole to remediate your resources.
+ * Auto remediation can be initiated even for compliant resources
+ *
If you enable auto remediation for a specific Config rule using the PutRemediationConfigurations
+ * API or the Config console, it initiates the remediation process for all
+ * non-compliant resources for that specific rule. The auto remediation process
+ * relies on the compliance data snapshot which is captured on a periodic basis.
+ * Any non-compliant resource that is updated between the snapshot schedule will
+ * continue to be remediated based on the last known compliance data snapshot.
+ * This means that in some cases auto remediation can be initiated even for
+ * compliant resources, since the bootstrap processor uses a database that can have
+ * stale evaluation results based on the last known compliance data snapshot.
+ * See Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutRemediationConfigurationsOutcome PutRemediationConfigurations(const Model::PutRemediationConfigurationsRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutRemediationConfigurations that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutRemediationConfigurationsOutcomeCallable PutRemediationConfigurationsCallable(const PutRemediationConfigurationsRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutRemediationConfigurations, request);
+ }
+
+ /**
+ * An Async wrapper for PutRemediationConfigurations that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void PutRemediationConfigurationsAsync(const PutRemediationConfigurationsRequestT& request, const PutRemediationConfigurationsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::PutRemediationConfigurations, request, handler, context);
+ }
+
+ /**
+ * A remediation exception is when a specified resource is no longer considered
+ * for auto-remediation. This API adds a new exception or updates an existing
+ * exception for a specified resource with a specified Config rule.
+ * Exceptions block auto remediation
Config generates a remediation
+ * exception when a problem occurs running a remediation action for a specified
+ * resource. Remediation exceptions blocks auto-remediation until the exception is
+ * cleared.
Manual remediation is recommended when
+ * placing an exception
When placing an exception on an Amazon Web
+ * Services resource, it is recommended that remediation is set as manual
+ * remediation until the given Config rule for the specified resource evaluates the
+ * resource as NON_COMPLIANT. Once the resource has been evaluated as
+ * NON_COMPLIANT, you can add remediation exceptions and change the
+ * remediation type back from Manual to Auto if you want to use auto-remediation.
+ * Otherwise, using auto-remediation before a NON_COMPLIANT evaluation
+ * result can delete resources before the exception is applied.
+ * Exceptions can only be performed on non-compliant resources
+ * Placing an exception can only be performed on resources that are
+ * NON_COMPLIANT. If you use this API for COMPLIANT
+ * resources or resources that are NOT_APPLICABLE, a remediation
+ * exception will not be generated. For more information on the conditions that
+ * initiate the possible Config evaluation results, see Concepts
+ * | Config Rules in the Config Developer Guide.
+ * Exceptions cannot be placed on service-linked remediation actions
+ * You cannot place an exception on service-linked remediation actions, such as
+ * remediation actions put by an organizational conformance pack.
+ * Auto remediation can be initiated even for compliant resources
+ *
If you enable auto remediation for a specific Config rule using the PutRemediationConfigurations
+ * API or the Config console, it initiates the remediation process for all
+ * non-compliant resources for that specific rule. The auto remediation process
+ * relies on the compliance data snapshot which is captured on a periodic basis.
+ * Any non-compliant resource that is updated between the snapshot schedule will
+ * continue to be remediated based on the last known compliance data snapshot.
+ * This means that in some cases auto remediation can be initiated even for
+ * compliant resources, since the bootstrap processor uses a database that can have
+ * stale evaluation results based on the last known compliance data snapshot.
+ * See Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutRemediationExceptionsOutcome PutRemediationExceptions(const Model::PutRemediationExceptionsRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutRemediationExceptions that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutRemediationExceptionsOutcomeCallable PutRemediationExceptionsCallable(const PutRemediationExceptionsRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutRemediationExceptions, request);
+ }
+
+ /**
+ * An Async wrapper for PutRemediationExceptions that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template
+ void PutRemediationExceptionsAsync(const PutRemediationExceptionsRequestT& request, const PutRemediationExceptionsResponseReceivedHandler& handler, const std::shared_ptr& context = nullptr) const
+ {
+ return SubmitAsync(&ConfigServiceClient::PutRemediationExceptions, request, handler, context);
+ }
+
+ /**
+ * Records the configuration state for the resource provided in the request. The
+ * configuration state of a resource is represented in Config as Configuration
+ * Items. Once this API records the configuration item, you can retrieve the list
+ * of configuration items for the custom resource type using existing Config APIs.
+ *
The custom resource type must be registered with CloudFormation.
+ * This API accepts the configuration item registered with CloudFormation.
+ * When you call this API, Config only stores configuration state of the
+ * resource provided in the request. This API does not change or remediate the
+ * configuration of the resource.
Write-only schema properites are not
+ * recorded as part of the published configuration item.
See
+ * Also:
AWS
+ * API Reference
+ */
+ virtual Model::PutResourceConfigOutcome PutResourceConfig(const Model::PutResourceConfigRequest& request) const;
+
+ /**
+ * A Callable wrapper for PutResourceConfig that returns a future to the operation so that it can be executed in parallel to other requests.
+ */
+ template
+ Model::PutResourceConfigOutcomeCallable PutResourceConfigCallable(const PutResourceConfigRequestT& request) const
+ {
+ return SubmitCallable(&ConfigServiceClient::PutResourceConfig, request);
+ }
+
+ /**
+ * An Async wrapper for PutResourceConfig that queues the request into a thread executor and triggers associated callback when operation has finished.
+ */
+ template