public static byte[] getSignatureKey(string key, string dateStamp, string regionName, string serviceName) { byte[] bytes = Encoding.UTF8.GetBytes(("AWS4" + key).ToCharArray()); byte[] key1 = Sigv4.HmacSHA256(dateStamp, bytes); byte[] key2 = Sigv4.HmacSHA256(regionName, key1); return(Sigv4.HmacSHA256("aws4_request", Sigv4.HmacSHA256(serviceName, key2))); }
private void calculate_canon_headers() { StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair <string, string> header in this.headers) { if (Sigv4.should_include_in_canon_headers(header)) { stringBuilder.Append(header.Key).Append(":").Append(header.Value).Append("\n"); } } this.canon_headers = stringBuilder.ToString(); }
private void calculate_signed_headers() { StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair <string, string> header in this.headers) { if (Sigv4.should_include_in_canon_headers(header)) { stringBuilder.Append(header.Key).Append(";"); } } stringBuilder.Remove(stringBuilder.Length - 1, 1); this.signed_headers = stringBuilder.ToString(); }
private void calculate_auth_header() { byte[] numArray1 = new byte[32]; byte[] numArray2 = new byte[32]; Sigv4.hmac_sha256(Encoding.Default.GetBytes("AWS4" + this.secret_key), this.date, numArray1); Sigv4.hmac_sha256(numArray1, this.sig_v4_ctx.region, numArray2); Sigv4.hmac_sha256(numArray2, this.sig_v4_ctx.service, numArray1); Sigv4.hmac_sha256(numArray1, "aws4_request", numArray2); Sigv4.hmac_sha256(numArray2, this.str_to_sign, numArray1); string str = BitConverter.ToString(numArray1).Replace("-", ""); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("AWS4-HMAC-SHA256").Append(" ").Append("Credential=").Append(this.akid).Append("/").Append(this.credential_scope).Append(", ").Append("SignedHeaders=").Append(this.signed_headers).Append(", ").Append("Signature=").Append(str); this.auth_header = stringBuilder.ToString(); }
private void calculate_str_to_sign() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("AWS4-HMAC-SHA256").Append("\n").Append(this.date_time).Append("\n").Append(this.credential_scope).Append("\n").Append(Sigv4.sha256_hex(this.canon_request)); this.str_to_sign = stringBuilder.ToString(); }
private void calculate_canon_request() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(this.req.Method()).Append("\n").Append(this.canon_path).Append("\n").Append(this.canon_query_args).Append("\n").Append(this.canon_headers).Append("\n").Append(this.signed_headers).Append("\n").Append(Sigv4.sha256_hex(this.req.data())); this.canon_request = stringBuilder.ToString(); }