SSS - S3 Toolkit 0.9.6
S3 client library and applications
Loading...
Searching...
No Matches
Sign

AWS S3v4 signing functions. More...

Data Structures

struct  sss::ComputeSignatureConfig
 Arguments for ComputeSignature and SignHeaders functions. More...
 
struct  sss::S3SignUrlConfig
 Arguments to SignedURL function. More...
 
struct  sss::Signature
 Signature information. More...
 

Functions

Signature sss::ComputeSignature (const ComputeSignatureConfig &cfg)
 Compute signature.
 
std::string sss::SignedURL (const S3SignUrlConfig &cfg)
 Generate presigned URL.
 
Headers sss::SignHeaders (const ComputeSignatureConfig &cfg)
 Sign headers.
 

Detailed Description

AWS S3v4 signing functions.

Function Documentation

◆ ComputeSignature()

Signature sss::ComputeSignature ( const ComputeSignatureConfig cfg)

Compute signature.

See also
ComputeSignatureConfig
Signature

Example

Signing a GET request for downloading object /bucket1/key1. This code is exteacted from a test case which outputs results in CSV format where success is mapped to '1' and failure to '0'.

const string signature =
"2ff4da4766da392b60b3278d2993398ee3f05fbf45aae378a66b489d266a4e87";
const ComputeSignatureConfig cfg{.access = "08XW32=0H=G7=HBLCG",
.secret =
"y8a=4KnHBxTtOuH5zduTxjfFIjBXfwfBWfjF",
.endpoint = "http://localhost:9000",
.method = "GET",
.bucket = "bucket1",
.key = "key1",
.headers = {{"x-amz-meta-mymeta", "123"}},
.dates = {"20230418T153022Z", "20230418"}};
cout << "Sign,"
<< "Sign request," << (signature == ComputeSignature(cfg).signature)
<< ',' << endl;
Signature ComputeSignature(const ComputeSignatureConfig &cfg)
Compute signature.
Definition aws_sign.cpp:226
Arguments for ComputeSignature and SignHeaders functions.
Definition aws_sign.h:67
std::string signature
computed HMAC hash
Definition aws_sign.h:99

Expected output

Sign,Sign request,1
Parameters
[in]cfgargumets
See also
ComputeSignatureConfig
Returns
signature information to be added to header to sign
See also
Signature

References sss::begin(), sss::CreateSignatureKey(), sss::Time::dateStamp, sss::end(), sss::GetDates(), sss::Hex(), sss::URL::host, sss::ParseURL(), sss::ComputeSignatureConfig::payloadHash, sss::URL::port, sss::Time::timeStamp, sss::ToLower(), sss::ToUpper(), and sss::UrlEncode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SignedURL()

string sss::SignedURL ( const S3SignUrlConfig cfg)

Generate presigned URL.

See also
S3SignUrlConfig
Parameters
[in]cfgarguments
See also
S3SignUrlConfig
Returns
signed URL.

Presign url, 'expiration' time must be specified in seconds @warnihg: x-amz- fields seem not to be required to sign, metatdata x-amz-meta work without adding to signed headers

References sss::S3SignUrlConfig::access, sss::begin(), sss::S3SignUrlConfig::bucket, sss::CreateSignatureKey(), sss::S3SignUrlConfig::dates, sss::Time::dateStamp, sss::end(), sss::S3SignUrlConfig::endpoint, sss::S3SignUrlConfig::expiration, sss::GetDates(), sss::S3SignUrlConfig::headers, sss::Hex(), sss::URL::host, sss::S3SignUrlConfig::key, sss::S3SignUrlConfig::method, sss::S3SignUrlConfig::params, sss::ParseURL(), sss::URL::port, sss::S3SignUrlConfig::region, sss::S3SignUrlConfig::secret, sss::Time::timeStamp, and sss::UrlEncode().

+ Here is the call graph for this function:

◆ SignHeaders()

Headers sss::SignHeaders ( const ComputeSignatureConfig cfg)

Sign headers.

Parameters
[in]cfgconfiguration information for computing signature; headers are passed as a data member and returned together with the additional signed header.
Returns
map of {header name->header value} pairs.
See also
ComputeSignatureConfig

Sign HTTP headers: return dictionary with {key, value} pairs containing per-header information.

References sss::begin(), sss::ComputeSignature(), and sss::end().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: