platform2: Switch over to using base64 functions from libchromeos
Replaced existing implementations of Base64Encode/Base64Decode
with the functions from libchromeos, which were added as part
of an earlier change (see CL:247690).
BUG=None
TEST=`FEATURES=test emerge-link cryptohome debugd metrics privetd update_engine`
Change-Id: I8cec677ce2c2fd3b97ca2228d35c2cf5cd133f4c
Reviewed-on: https://chromium-review.googlesource.com/247792
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/delta_performer.cc b/delta_performer.cc
index 280913c..bcbfb46 100644
--- a/delta_performer.cc
+++ b/delta_performer.cc
@@ -17,6 +17,7 @@
#include <base/format_macros.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
+#include <chromeos/data_encoding.h>
#include <google/protobuf/repeated_field.h>
#include "update_engine/bzip_extent_writer.h"
@@ -272,15 +273,10 @@
namespace {
void LogPartitionInfoHash(const PartitionInfo& info, const string& tag) {
- string sha256;
- if (OmahaHashCalculator::Base64Encode(info.hash().data(),
- info.hash().size(),
- &sha256)) {
- LOG(INFO) << "PartitionInfo " << tag << " sha256: " << sha256
- << " size: " << info.size();
- } else {
- LOG(ERROR) << "Base64Encode failed for tag: " << tag;
- }
+ string sha256 = chromeos::data_encoding::Base64Encode(info.hash().data(),
+ info.hash().size());
+ LOG(INFO) << "PartitionInfo " << tag << " sha256: " << sha256
+ << " size: " << info.size();
}
void LogPartitionInfo(const DeltaArchiveManifest& manifest) {
@@ -884,13 +880,14 @@
}
// Convert base64-encoded signature to raw bytes.
- vector<char> metadata_signature;
- if (!OmahaHashCalculator::Base64Decode(install_plan_->metadata_signature,
- &metadata_signature)) {
+ chromeos::Blob signature;
+ if (!chromeos::data_encoding::Base64Decode(install_plan_->metadata_signature,
+ &signature)) {
LOG(ERROR) << "Unable to decode base64 metadata signature: "
<< install_plan_->metadata_signature;
return ErrorCode::kDownloadMetadataSignatureError;
}
+ vector<char> metadata_signature{signature.begin(), signature.end()};
// See if we should use the public RSA key in the Omaha response.
base::FilePath path_to_public_key(public_key_path_);
@@ -1180,11 +1177,7 @@
}
string StringForHashBytes(const void* bytes, size_t size) {
- string ret;
- if (!OmahaHashCalculator::Base64Encode(bytes, size, &ret)) {
- ret = "<unknown>";
- }
- return ret;
+ return chromeos::data_encoding::Base64Encode(bytes, size);
}
} // namespace