Ejemplo n.º 1
0
        /// <summary>
        /// Signs one chunk of a request when transferring a payload using multiple chunks
        /// </summary>
        /// <param name="chunkBody">Content of the current chunk to sign</param>
        /// <param name="previousSignature">Signature of the previously signed chunk</param>
        /// <param name="headerSigningResult">Signing result for the "seed" signature consisting of headers</param>
        /// <returns>Signature of the current chunk</returns>
        public string SignChunk(Stream chunkBody, string previousSignature, AWS4aSigningResult headerSigningResult)
        {
            var signingConfig = PrepareCRTSigningConfig(AwsSignatureType.HTTP_REQUEST_CHUNK, headerSigningResult);

            signingConfig.SignedBodyHeader = AwsSignedBodyHeaderType.NONE;

            // The previous signature may be padded with '*' up to 144 characters, which is used
            // when actually sending a chunk but not when calculating the next chunk's signature.
            previousSignature = previousSignature.TrimEnd('*');

            var signingResult = AwsSigner.SignChunk(chunkBody, Encoding.UTF8.GetBytes(previousSignature), signingConfig);

            return(Encoding.UTF8.GetString(signingResult.Get().Signature));
        }