33
44/**
55 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6- * SPDX-License-Identifier: Apache-2.0.
6+ * SPDX-License-Identifier: Apache-2.0
77 */
88
99#include "aws/s3/s3_client.h"
@@ -43,19 +43,29 @@ struct aws_s3_upload_request_checksum_context {
4343 *
4444 * @param allocator Memory allocator
4545 * @param checksum_config Meta request level checksum configuration (can be NULL)
46- * @param checksum_buffer User-provided checksum buffer (can be NULL)
4746 * @return New checksum context or NULL on error
4847 */
4948AWS_S3_API
5049struct aws_s3_upload_request_checksum_context * aws_s3_upload_request_checksum_context_new (
5150 struct aws_allocator * allocator ,
5251 const struct aws_s3_meta_request_checksum_config_storage * checksum_config );
5352
53+ /**
54+ * Create a new upload request checksum context with an existing checksum value.
55+ * This is useful when resuming uploads or when the checksum is pre-calculated.
56+ * Returns with reference count of 1.
57+ *
58+ * @param allocator Memory allocator
59+ * @param checksum_config Meta request level checksum configuration (can be NULL)
60+ * @param existing_checksum Pre-calculated checksum value as a byte cursor
61+ * @return New checksum context or NULL on error (e.g., if checksum size doesn't match algorithm)
62+ */
5463AWS_S3_API
55- struct aws_s3_upload_request_checksum_context * aws_s3_upload_request_checksum_context_new_with_exist_checksum (
64+ struct aws_s3_upload_request_checksum_context * aws_s3_upload_request_checksum_context_new_with_existing_checksum (
5665 struct aws_allocator * allocator ,
5766 const struct aws_s3_meta_request_checksum_config_storage * checksum_config ,
58- struct aws_byte_cursor exist_checksum );
67+ struct aws_byte_cursor existing_checksum );
68+
5969/**
6070 * Acquire a reference to the upload request checksum context.
6171 * Use this when transferring ownership to another function/structure.
@@ -79,43 +89,55 @@ struct aws_s3_upload_request_checksum_context *aws_s3_upload_request_checksum_co
7989 struct aws_s3_upload_request_checksum_context * context );
8090
8191/**
82- * Check if checksum calculation is needed based on context state
92+ * Check if checksum calculation is needed based on context state.
93+ * Returns true if the context has a valid algorithm and the checksum has not been calculated yet.
94+ *
95+ * @param context The checksum context to check
96+ * @return true if checksum calculation is needed, false otherwise
8397 */
8498AWS_S3_API
8599bool aws_s3_upload_request_checksum_context_should_calculate (
86100 const struct aws_s3_upload_request_checksum_context * context );
87101
88102/**
89- * Check if checksum should be added to HTTP headers
103+ * Check if checksum should be added to HTTP headers.
104+ * Returns true if the context has a valid algorithm and the location is set to header.
105+ *
106+ * @param context The checksum context to check
107+ * @return true if checksum should be added to headers, false otherwise
90108 */
91109AWS_S3_API
92110bool aws_s3_upload_request_checksum_context_should_add_header (
93111 const struct aws_s3_upload_request_checksum_context * context );
94112
95113/**
96- * Check if checksum should be added as trailer (chunked encoding)
114+ * Check if checksum should be added as trailer (chunked encoding).
115+ * Returns true if the context has a valid algorithm and the location is set to trailer.
116+ *
117+ * @param context The checksum context to check
118+ * @return true if checksum should be added as trailer, false otherwise
97119 */
98120AWS_S3_API
99121bool aws_s3_upload_request_checksum_context_should_add_trailer (
100122 const struct aws_s3_upload_request_checksum_context * context );
101123
102124/**
103125 * Get the checksum buffer to use for output.
104- * Returns the user buffer if provided, otherwise the internal buffer.
126+ * Returns the internal buffer for storing the calculated checksum.
127+ *
128+ * @param context The checksum context
129+ * @return Pointer to the checksum buffer, or NULL if context is invalid
105130 */
106131AWS_S3_API
107132struct aws_byte_buf * aws_s3_upload_request_checksum_context_get_output_buffer (
108133 struct aws_s3_upload_request_checksum_context * context );
109134
110135/**
111- * Validate that the checksum buffer size matches the expected size for the algorithm
112- */
113- AWS_S3_API
114- int aws_s3_upload_request_checksum_context_validate_buffer_size (
115- const struct aws_s3_upload_request_checksum_context * context );
116-
117- /**
118- * Get a cursor to the current checksum value (for use in headers/trailers)
136+ * Get a cursor to the current checksum value (for use in headers/trailers).
137+ * Returns an empty cursor if the checksum has not been calculated yet.
138+ *
139+ * @param context The checksum context
140+ * @return Byte cursor to the calculated checksum, or empty cursor if not available
119141 */
120142AWS_S3_API
121143struct aws_byte_cursor aws_s3_upload_request_checksum_context_get_checksum_cursor (
0 commit comments