rebootescrow: eliminate copy during read
Instead of reading into a std::string, read directly into the std::vector of bytes This saves a copy and reduces memory overhead slightly. Test: atest VtsHalRebootEscrowTargetTest Bug: 148177693 Change-Id: I4dfe552f21394fb0891858b34a481b489dc3c684
This commit is contained in:
parent
2801b037cd
commit
08018dd925
1 changed files with 3 additions and 4 deletions
|
@ -55,13 +55,12 @@ ndk::ScopedAStatus RebootEscrow::retrieveKey(std::vector<int8_t>* _aidl_return)
|
|||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
||||
}
|
||||
|
||||
std::string encodedString;
|
||||
if (!::android::base::ReadFdToString(fd, &encodedString)) {
|
||||
LOG(WARNING) << "Could not read device to string";
|
||||
std::vector<uint8_t> encodedBytes(hadamard::OUTPUT_SIZE_BYTES);
|
||||
if (!::android::base::ReadFully(fd, &encodedBytes[0], encodedBytes.size())) {
|
||||
LOG(WARNING) << "Could not read device";
|
||||
return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
|
||||
}
|
||||
|
||||
std::vector<uint8_t> encodedBytes(encodedString.begin(), encodedString.end());
|
||||
auto keyBytes = hadamard::DecodeKey(encodedBytes);
|
||||
|
||||
std::vector<int8_t> signedKeyBytes(keyBytes.begin(), keyBytes.end());
|
||||
|
|
Loading…
Reference in a new issue