Merge latest oemcrypto-v17 change

No-Typo-Check: Not related to this change.

Bug: 161477208
Change-Id: I99e4780f6855b7045aa0cd5a49c13d2d0d51ed64
This commit is contained in:
Kyle Zhang
2022-01-21 05:58:12 +00:00
committed by Fred Gylys-Colwell
parent c924960962
commit 642965c678
176 changed files with 301013 additions and 296749 deletions

View File

@@ -12,6 +12,10 @@
#include "log.h"
using wvutil::a2b_hex;
using wvutil::b2a_hex;
using wvutil::FileSystem;
namespace wvcdm {
FileSystem* RebootTest::file_system_;
@@ -29,11 +33,11 @@ std::string EncodeString(const std::string& data) {
// If there are any unprintable characters, except whitespace, or if we
// close a brace before we open it, then just use hex.
if (!printable || braces_count < 0) {
return "0x" + wvcdm::b2a_hex(data) + ",";
return "0x" + b2a_hex(data) + ",";
}
}
// If we left any braces open, then use hex.
if (braces_count != 0) return "0x" + wvcdm::b2a_hex(data) + ",";
if (braces_count != 0) return "0x" + b2a_hex(data) + ",";
return "{" + data + "},";
}
@@ -47,12 +51,12 @@ std::string EncodeKey(const std::string& data) {
}
// When decoding, we assume that a key starting with "0x" is in hex. So we
// can't have any keys that start with "0x".
if (data.substr(0, 2) == "0x") return "0x" + wvcdm::b2a_hex(data) + ":";
if (data.substr(0, 2) == "0x") return "0x" + b2a_hex(data) + ":";
// If the key is just is not printable, or if it has unmatched braces, then
// we use hex. Otherwise, we surround the whole string with braces.
for (size_t i = 0; i < data.length(); i++) {
if (!isprint(data[i]) || (data[i] == ':')) {
return "0x" + wvcdm::b2a_hex(data) + ":";
return "0x" + b2a_hex(data) + ":";
}
}
return data + ":";
@@ -107,8 +111,7 @@ std::string DecodeString(const std::string& encoded, size_t* index) {
while (*index < encoded.length()) {
if (encoded[*index] == ',') {
size_t end = *index;
std::vector<uint8_t> result =
wvcdm::a2b_hex(encoded.substr(start, end - start));
std::vector<uint8_t> result = a2b_hex(encoded.substr(start, end - start));
(*index)++; // absorb the comma.
return std::string(result.begin(), result.end());
}
@@ -134,8 +137,7 @@ std::string DecodeKey(const std::string& encoded, size_t* index) {
size_t start = *index + 2;
while (*index < encoded.length() && encoded[*index] != ':') (*index)++;
size_t end = *index;
std::vector<uint8_t> result =
wvcdm::a2b_hex(encoded.substr(start, end - start));
std::vector<uint8_t> result = a2b_hex(encoded.substr(start, end - start));
(*index)++; // skip the colon.
return std::string(result.begin(), result.end());
}