public static byte[] ComposeSigningKey(string awsSecretAccessKey, string region, string date, string service)
{
char[] ksecret = null;
try
{
ksecret = (Scheme + awsSecretAccessKey).ToCharArray();
var hashDate = ComputeKeyedHash(SignerAlgorithm, Encoding.UTF8.GetBytes(ksecret), Encoding.UTF8.GetBytes(date));
var hashRegion = ComputeKeyedHash(SignerAlgorithm, hashDate, Encoding.UTF8.GetBytes(region));
var hashService = ComputeKeyedHash(SignerAlgorithm, hashRegion, Encoding.UTF8.GetBytes(service));
return ComputeKeyedHash(SignerAlgorithm, hashService, TerminatorBytes);
}
finally
{
// clean up all secrets, regardless of how initially seeded (for simplicity)
if (ksecret != null)
Array.Clear(ksecret, 0, ksecret.Length);
}
}