1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use DateTime;
use Utc;
use ;
// Base Implementation of the V4 Signing method. The idea is that we would build one for AWS, Google,
// and any other service that uses the standard V4 signing method.
// For uploads, we use the unsigned payload option. To sign the payload
// we would need to read the body and hash it which we dont want to do. We
// want to keep the body bytes out of the guest to avoid memory utilization.
// See: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html
// The spec says that we put the literal string UNSIGNED-PAYLOAD in the payload
// instead of hex-encoded hash value
// SHA256 HMAC
// Create a hex output of the hash