summaryrefslogtreecommitdiff
path: root/utils.cc
diff options
context:
space:
mode:
authorAlex Vakulenko <avakulenko@chromium.org>2015-02-09 12:51:24 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-11 06:00:08 +0000
commit981a9fb68ec5fe56f57b3ecb117a0dc681bf5e83 (patch)
tree65adde019c9e30e7abf2b390492d64d978ea95cf /utils.cc
parentb8ccad0a8ac2632da2788b47d85e62e334bbe652 (diff)
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>
Diffstat (limited to 'utils.cc')
-rw-r--r--utils.cc16
1 files changed, 7 insertions, 9 deletions
diff --git a/utils.cc b/utils.cc
index 9a596a71..2007e9b9 100644
--- a/utils.cc
+++ b/utils.cc
@@ -36,6 +36,7 @@
#include <base/strings/string_split.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
+#include <chromeos/data_encoding.h>
#include <glib.h>
#include "update_engine/clock_interface.h"
@@ -1463,18 +1464,15 @@ string StringVectorToString(const vector<string> &vec_str) {
}
string CalculateP2PFileId(const string& payload_hash, size_t payload_size) {
- string encoded_hash;
- OmahaHashCalculator::Base64Encode(payload_hash.c_str(),
- payload_hash.size(),
- &encoded_hash);
+ string encoded_hash = chromeos::data_encoding::Base64Encode(payload_hash);
return base::StringPrintf("cros_update_size_%zu_hash_%s",
- payload_size,
- encoded_hash.c_str());
+ payload_size,
+ encoded_hash.c_str());
}
bool DecodeAndStoreBase64String(const string& base64_encoded,
base::FilePath *out_path) {
- vector<char> contents;
+ chromeos::Blob contents;
out_path->clear();
@@ -1483,7 +1481,7 @@ bool DecodeAndStoreBase64String(const string& base64_encoded,
return false;
}
- if (!OmahaHashCalculator::Base64Decode(base64_encoded, &contents) ||
+ if (!chromeos::data_encoding::Base64Decode(base64_encoded, &contents) ||
contents.size() == 0) {
LOG(ERROR) << "Error decoding base64.";
return false;
@@ -1495,7 +1493,7 @@ bool DecodeAndStoreBase64String(const string& base64_encoded,
return false;
}
- if (fwrite(&contents[0], 1, contents.size(), file) != contents.size()) {
+ if (fwrite(contents.data(), 1, contents.size(), file) != contents.size()) {
PLOG(ERROR) << "Error writing to temporary file.";
if (fclose(file) != 0)
PLOG(ERROR) << "Error closing temporary file.";