Source release 18.7.0
This commit is contained in:
@@ -151,7 +151,6 @@ void AdvanceDestBuffer(OEMCrypto_DestBufferDesc* dest_buffer, size_t bytes) {
|
||||
switch (dest_buffer->type) {
|
||||
case OEMCrypto_BufferType_Clear:
|
||||
dest_buffer->buffer.clear.clear_buffer += bytes;
|
||||
dest_buffer->buffer.clear.clear_buffer_length -= bytes;
|
||||
return;
|
||||
|
||||
case OEMCrypto_BufferType_Secure:
|
||||
@@ -2511,6 +2510,17 @@ bool CryptoSession::GetBuildInformation(RequestedSecurityLevel security_level,
|
||||
return false;
|
||||
}
|
||||
info->resize(info_length);
|
||||
// Some OEMCrypto implementations may include trailing null
|
||||
// bytes in the output. Trim them here.
|
||||
while (!info->empty() && info->back() == '\0') {
|
||||
info->pop_back();
|
||||
}
|
||||
if (info->empty()) {
|
||||
LOGE("BuildInformation() returned corrupted data: length = %zu",
|
||||
info_length);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3219,6 +3229,11 @@ OEMCryptoResult CryptoSession::DecryptSample(
|
||||
}
|
||||
|
||||
fake_sample.buffers.input_data_length = length;
|
||||
if (fake_sample.buffers.output_descriptor.type ==
|
||||
OEMCrypto_BufferType_Clear) {
|
||||
fake_sample.buffers.output_descriptor.buffer.clear
|
||||
.clear_buffer_length = length;
|
||||
}
|
||||
fake_sample.subsamples = &clear_subsample;
|
||||
fake_sample.subsamples_length = 1;
|
||||
|
||||
@@ -3246,6 +3261,11 @@ OEMCryptoResult CryptoSession::DecryptSample(
|
||||
}
|
||||
|
||||
fake_sample.buffers.input_data_length = length;
|
||||
if (fake_sample.buffers.output_descriptor.type ==
|
||||
OEMCrypto_BufferType_Clear) {
|
||||
fake_sample.buffers.output_descriptor.buffer.clear
|
||||
.clear_buffer_length = length;
|
||||
}
|
||||
fake_sample.subsamples = &encrypted_subsample;
|
||||
fake_sample.subsamples_length = 1;
|
||||
|
||||
@@ -3338,6 +3358,10 @@ OEMCryptoResult CryptoSession::LegacyCopyBufferInChunks(
|
||||
// Calculate the size of the next chunk.
|
||||
const size_t chunk_size = std::min(remaining_input_data, max_chunk_size);
|
||||
|
||||
if (output_descriptor.type == OEMCrypto_BufferType_Clear) {
|
||||
output_descriptor.buffer.clear.clear_buffer_length = chunk_size;
|
||||
}
|
||||
|
||||
// Re-add "last subsample" flag if this is the last subsample.
|
||||
if (chunk_size == remaining_input_data) {
|
||||
subsample_flags |= OEMCrypto_LastSubsample;
|
||||
@@ -3385,6 +3409,11 @@ OEMCryptoResult CryptoSession::LegacyDecryptInChunks(
|
||||
// Calculate the size of the next chunk.
|
||||
const size_t chunk_size = std::min(remaining_input_data, max_chunk_size);
|
||||
fake_sample.buffers.input_data_length = chunk_size;
|
||||
if (fake_sample.buffers.output_descriptor.type ==
|
||||
OEMCrypto_BufferType_Clear) {
|
||||
fake_sample.buffers.output_descriptor.buffer.clear.clear_buffer_length =
|
||||
chunk_size;
|
||||
}
|
||||
if (is_protected) {
|
||||
fake_subsample.num_bytes_encrypted = chunk_size;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user