Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions storage/innobase/xtrabackup/src/xbcloud/azure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ void Azure_signer::sign_request(const std::string &container,

std::string decoded_access_key = base64_decode(access_key);

trim(decoded_access_key);

auto signature =
base64_encode(hmac_sha256(decoded_access_key, string_to_sign));

Expand Down
9 changes: 5 additions & 4 deletions storage/innobase/xtrabackup/src/xbcloud/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,15 @@ std::string base64_encode(const T &s) {

template <typename T>
std::string base64_decode(const T &s) {
uint64 decoded_size = ::base64_needed_decoded_length(s.size());
std::unique_ptr<char[]> buf(new char[decoded_size]);
uint64 max_decoded_size = ::base64_needed_decoded_length(s.size());
std::unique_ptr<char[]> buf(new char[max_decoded_size]);

if (::base64_decode(&s[0], s.size(), buf.get(), NULL, 0) == 0) {
auto decoded_size = ::base64_decode(&s[0], s.size(), buf.get(), NULL, 0);
if (decoded_size <= 0) {
return std::string();
}

return std::string(buf.get());
return std::string(buf.get(), decoded_size);
}

template <typename T>
Expand Down
12 changes: 6 additions & 6 deletions storage/innobase/xtrabackup/src/xbcloud/xbcloud-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,15 @@ TEST(azure_signer, basicDNS) {
req.append_payload("test", 4);
Azure_signer signer(
"my-storage-account",
"zUfvsKXc6+2RMJCwvnElnG/"
"Kk7wxQ8V4TPXIuZ53qFwJNtpLUEjYdBe9iGTkMgwUGFHVfFgn2qkgoqDP/b3OAg==",
"zUfvsKXcAO2RMJCwvnElnG/"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this key contains a NULL byte when decoded, and it ends in \r to check that the request signing is correctly done

"Kk7wxQ8V4TPXIuZ53qFwJNtpLUEjYdBe9iGTkMgwUGFHVfFgn2qkgoqDP/i3ODQ==",
0);
signer.sign_request("mycontainer", "myblob", req, 1555892546);

ASSERT_STREQ(
req.headers().at("Authorization").c_str(),
"SharedKey "
"my-storage-account:uZABJWDbfXO/SuDZbxrJnd00kCDV61cevqi423k21A4=");
"my-storage-account:3RNUoT7aggagRnzDebBh1JDGhJocV0e2MKb9ChNvAcM=");
}

TEST(azure_signer, storageClass) {
Expand All @@ -579,13 +579,13 @@ TEST(azure_signer, storageClass) {
req.append_payload("test", 4);
Azure_signer signer(
"my-storage-account",
"zUfvsKXc6+2RMJCwvnElnG/"
"Kk7wxQ8V4TPXIuZ53qFwJNtpLUEjYdBe9iGTkMgwUGFHVfFgn2qkgoqDP/i3OAg==",
"zUfvsKXcAO2RMJCwvnElnG/"
"Kk7wxQ8V4TPXIuZ53qFwJNtpLUEjYdBe9iGTkMgwUGFHVfFgn2qkgoqDP/i3ODQ==",
0, "storage_class");
signer.sign_request("mycontainer", "myblob", req, 1555892546);

ASSERT_STREQ(
req.headers().at("Authorization").c_str(),
"SharedKey "
"my-storage-account:vq5FiJaSj9mrTxeEyp3RRfptEFug4PEozawQG5A+ZHs=");
"my-storage-account:b/lbriWK8eQ9uMx97nP0vR894wm+oYsq99Sz0JoH/9k=");
}