-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathawsv4.hpp
70 lines (51 loc) · 2.77 KB
/
awsv4.hpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef AWSV4_HPP
#define AWSV4_HPP
#include <cstdio>
#include <cstring>
#include <stdexcept>
#include <algorithm>
#include <map>
#include <ctime>
#include <iostream>
#include <sstream>
#include "Poco/URI.h"
#include "Poco/StringTokenizer.h"
#include "openssl/sha.h"
#include "openssl/hmac.h"
namespace AWSV4 {
const std::string ENDL{"\n"};
const std::string POST{"GET"};
const std::string STRING_TO_SIGN_ALGO{"AWS4-HMAC-SHA256"};
const std::string AWS4{"AWS4"};
const std::string AWS4_REQUEST{"aws4_request"};
void sha256(const std::string str, unsigned char outputBuffer[SHA256_DIGEST_LENGTH]) noexcept;
const std::string sha256_base16(const std::string) noexcept;
const std::string canonicalize_uri(const Poco::URI& uri) noexcept;
const std::string canonicalize_query(const Poco::URI& uri) noexcept;
const std::map<std::string,std::string> canonicalize_headers(const std::vector<std::string>& headers) noexcept;
const std::string map_headers_string(const std::map<std::string,std::string>& header_key2val) noexcept;
const std::string map_signed_headers(const std::map<std::string,std::string>& header_key2val) noexcept;
const std::string canonicalize_request(const std::string& http_request_method,
const std::string& canonical_uri,
const std::string& canonical_query_string,
const std::string& canonical_headers,
const std::string& signed_headers,
const std::string& payload) noexcept;
const std::string string_to_sign(const std::string& algorithm,
const std::time_t& request_date,
const std::string& credential_scope,
const std::string& hashed_canonical_request) noexcept;
const std::string sign(const std::string key, const std::string msg);
const std::string ISO8601_date(const std::time_t& t) noexcept;
const std::string utc_yyyymmdd(const std::time_t& t) noexcept;
const std::string credential_scope(const std::time_t& t,
const std::string region,
const std::string service,
const std::string s) noexcept;
const std::string calculate_signature(const std::time_t& request_date,
const std::string secret,
const std::string region,
const std::string service,
const std::string string_to_sign) noexcept;
}
#endif