userver: crypto::aws Namespace Reference
Loading...
Searching...
No Matches
crypto::aws Namespace Reference

Detailed Description

AWS Signature Version 4.

Classes

struct  SignV4Request
struct  V4TimeScope
 Date and credential scope used to sign a request. More...

Functions

void SignRequestV4 (::http::headers::HeaderMap &headers, const SignV4Request &request)
V4TimeScope MakeV4TimeScope (std::string_view region, std::string_view service)
std::string MakeCanonicalRequest (std::string_view http_method, std::string_view canonical_uri, std::string_view canonical_query, std::string_view canonical_headers, std::string_view signed_headers, std::string_view payload_hash)
 Canonical request string: method, URI, query, headers, signed headers, payload hash.
std::string MakeV4StringToSign (std::string_view canonical_request, const V4TimeScope &scope)
 AWS4-HMAC-SHA256 string to sign for canonical_request.
std::string MakeV4Signature (std::string_view string_to_sign, const V4TimeScope &scope, std::string_view region, std::string_view service, std::string_view secret_key)
 HMAC-SHA256 signature of string_to_sign with the derived signing key.

Variables

constexpr std::string_view kAws4HmacSha256 = "AWS4-HMAC-SHA256"
constexpr std::string_view kAws4Request = "aws4_request"
constexpr std::string_view kUnsignedPayload = "UNSIGNED-PAYLOAD"
constexpr ::http::headers::PredefinedHeader kAmzDate {"X-Amz-Date"}
constexpr ::http::headers::PredefinedHeader kAmzContentSha256 {"X-Amz-Content-Sha256"}

Function Documentation

◆ MakeV4TimeScope()

V4TimeScope crypto::aws::MakeV4TimeScope ( std::string_view region,
std::string_view service )

Builds YYYYMMDDThhmmssZ, YYYYMMDD and {date}/{region}/{service}/aws4_request from the current time (utils::datetime::Now, mockable in tests).

◆ SignRequestV4()

void crypto::aws::SignRequestV4 ( ::http::headers::HeaderMap & headers,
const SignV4Request & request )

Adds X-Amz-Date, X-Amz-Content-Sha256 and Authorization to headers.

Exceptions
std::runtime_errorif Host is missing or empty

Variable Documentation

◆ kAmzContentSha256

::http::headers::PredefinedHeader crypto::aws::kAmzContentSha256 {"X-Amz-Content-Sha256"}
inline

Definition at line 25 of file aws.hpp.

◆ kAmzDate

::http::headers::PredefinedHeader crypto::aws::kAmzDate {"X-Amz-Date"}
inline

Definition at line 24 of file aws.hpp.

◆ kAws4HmacSha256

std::string_view crypto::aws::kAws4HmacSha256 = "AWS4-HMAC-SHA256"
inlineconstexpr

◆ kAws4Request

std::string_view crypto::aws::kAws4Request = "aws4_request"
inlineconstexpr

Definition at line 21 of file aws.hpp.

◆ kUnsignedPayload

std::string_view crypto::aws::kUnsignedPayload = "UNSIGNED-PAYLOAD"
inlineconstexpr

Definition at line 22 of file aws.hpp.