const char* const http_auth = info.env->get("HTTP_AUTHORIZATION");
string auth_str = http_auth;
-#define AWS4_HMAC_SHA256_STR "AWS4-HMAC-SHA256"
-#define CREDENTIALS_PREFIX_LEN (sizeof(AWS4_HMAC_SHA256_STR) - 1)
- uint64_t min_len = CREDENTIALS_PREFIX_LEN + 1;
+ constexpr size_t min_len = strlen(AWS4_HMAC_SHA256_STR) + 1;
if (auth_str.length() < min_len) {
dout(10) << "credentials string is too short" << dendl;
return -EINVAL;
namespace auth {
namespace s3 {
+static constexpr char AWS4_HMAC_SHA256_STR[] = "AWS4-HMAC-SHA256";
+
static constexpr char AWS4_EMPTY_PAYLOAD_HASH[] = \
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
static inline std::pair<AwsVersion, AwsRoute>
discover_aws_flavour(const req_info& info)
{
+ using rgw::auth::s3::AWS4_HMAC_SHA256_STR;
+
AwsVersion version = AwsVersion::UNKOWN;
AwsRoute route = AwsRoute::UNKOWN;
/* Authorization in Header */
route = AwsRoute::HEADERS;
- if (!strncmp(http_auth, "AWS4-HMAC-SHA256", 16)) {
+ if (!strncmp(http_auth, AWS4_HMAC_SHA256_STR,
+ strlen(AWS4_HMAC_SHA256_STR))) {
/* AWS v4 */
version = AwsVersion::V4;
} else if (!strncmp(http_auth, "AWS ", 4)) {
} else {
route = AwsRoute::QUERY_STRING;
- if (info.args.get("X-Amz-Algorithm") == "AWS4-HMAC-SHA256") {
+ if (info.args.get("X-Amz-Algorithm") == AWS4_HMAC_SHA256_STR) {
/* AWS v4 */
version = AwsVersion::V4;
} else if (!info.args.get("AWSAccessKeyId").empty()) {