Commit c0cb1f4d authored by Eric Roman's avatar Eric Roman Committed by Commit Bot

Make use of new hex decoding functions for //base code.

Bug: 1021236
Change-Id: I96599537914475508a3404b4771aeab9fa117a05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1896341
Auto-Submit: Eric Roman <eroman@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712481}
parent c4d32c23
......@@ -116,10 +116,10 @@ std::string HexEncodeString(const std::string& input) {
std::string HexDecodeString(const std::string& input) {
if (input.empty())
return std::string();
std::vector<uint8_t> bytes;
bool result = HexStringToBytes(input, &bytes);
std::string bytes;
bool result = HexStringToString(input, &bytes);
DCHECK(result);
return std::string(reinterpret_cast<const char*>(&bytes[0]), bytes.size());
return bytes;
}
} // namespace
......
......@@ -92,20 +92,11 @@ bool GetValueAsUnguessableToken(const Value& value, UnguessableToken* token) {
return false;
}
// TODO(dcheng|yucliu): Make a function that accepts non vector variant and
// reads a fixed number of bytes.
std::vector<uint8_t> high_low_bytes;
if (!HexStringToBytes(value.GetString(), &high_low_bytes)) {
return false;
}
UnguessableTokenRepresentation representation;
if (high_low_bytes.size() != sizeof(representation.buffer)) {
if (!HexStringToSpan(value.GetString(), representation.buffer)) {
return false;
}
std::copy(high_low_bytes.begin(), high_low_bytes.end(),
std::begin(representation.buffer));
*token = UnguessableToken::Deserialize(representation.field.high,
representation.field.low);
return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment