@@ -7,7 +7,7 @@ package aws.sdk.kotlin.crt.auth.signing
77
88import aws.sdk.kotlin.crt.asyncCrtJniCall
99import aws.sdk.kotlin.crt.auth.credentials.JniCredentialsProvider
10- import aws.sdk.kotlin.crt.http.HttpRequest
10+ import aws.sdk.kotlin.crt.http.*
1111import aws.sdk.kotlin.crt.http.from
1212import aws.sdk.kotlin.crt.http.into
1313import kotlinx.coroutines.future.await
@@ -50,6 +50,24 @@ public actual object AwsSigner {
5050 AwsSigningResult (signedRequest, jniResult.signature)
5151 }
5252 }
53+
54+ /* *
55+ * Signs a body chunk according to the supplied signing configuration
56+ * @param chunkBody the chunk payload to sign
57+ * @param prevSignature the signature of the previous component of the request (either the initial request itself
58+ * for the first chunk or the previous chunk otherwise)
59+ * @param config signing configuration
60+ * @return signing result, which provides access to all signing-related result properties
61+ */
62+ public actual suspend fun signChunk (chunkBody : ByteArray , prevSignature : ByteArray , config : AwsSigningConfig ): AwsSigningResult {
63+ val ktStream = HttpRequestBodyStream .fromByteArray(chunkBody)
64+ val bodyStream = JniRequestBodyStream (ktStream)
65+ return asyncCrtJniCall {
66+ val signFuture = AwsSignerJni .sign(bodyStream, prevSignature, config.into())
67+ val jniResult = signFuture.await()
68+ AwsSigningResult (null , jniResult.signature)
69+ }
70+ }
5371}
5472
5573private fun AwsSigningConfig.into (): AwsSigningConfigJni {
0 commit comments