Merge changes from topic "oemcrypto-v16"

* changes:
  OEMCrypto v16.2
  OEMCrypto v16.1
This commit is contained in:
Fred Gylys-Colwell
2020-02-05 16:10:47 +00:00
committed by Android (Google) Code Review
147 changed files with 14748 additions and 11097 deletions

View File

@@ -181,14 +181,6 @@ bool StringToInt64(const std::string& input, int64_t* output) {
} // namespace
// GTest requires PrintTo to be in the same namespace as the thing it prints,
// which is std::vector in this case.
namespace std {
void PrintTo(const vector<uint8_t>& value, ostream* os) {
*os << wvcdm::b2a_hex(value);
}
} // namespace std
using ::testing::Contains;
using ::testing::Pair;
using ::testing::StrNe;

View File

@@ -85,7 +85,7 @@ write_options_txt_file()
fi
echo "security_patch_level 1" >> $HOST_OPTIONS_PATH
echo "max_buffer_size 0" >> $HOST_OPTIONS_PATH
echo "max_subsample_size 0" >> $HOST_OPTIONS_PATH
if [ "$use_keybox" == "$NO" ]; then
echo "use_keybox 0" >> $HOST_OPTIONS_PATH

View File

@@ -12,13 +12,17 @@ LOCAL_MODULE_TAGS := tests
LOCAL_SRC_FILES := \
$(test_main) \
$(test_src_dir)/$(test_name).cpp \
../../oemcrypto/test//oec_device_features.cpp \
../core/test/config_test_env.cpp \
../core/test/fake_provisioning_server.cpp \
../core/test/http_socket.cpp \
../core/test/license_request.cpp \
../core/test/test_base.cpp \
../core/test/test_printers.cpp \
../core/test/url_request.cpp
../core/test/url_request.cpp \
../../oemcrypto/test/oec_device_features.cpp \
../../oemcrypto/test/oec_key_deriver.cpp \
../../oemcrypto/test/oec_session_util.cpp \
../util/test/test_sleep.cpp \
LOCAL_C_INCLUDES := \
vendor/widevine/libwvdrmengine/android/cdm/test \
@@ -27,8 +31,11 @@ LOCAL_C_INCLUDES := \
vendor/widevine/libwvdrmengine/cdm/include \
vendor/widevine/libwvdrmengine/cdm/metrics/include \
vendor/widevine/libwvdrmengine/cdm/util/include \
vendor/widevine/libwvdrmengine/cdm/util/test \
vendor/widevine/libwvdrmengine/oemcrypto/include \
vendor/widevine/libwvdrmengine/oemcrypto/test \
vendor/widevine/libwvdrmengine/oemcrypto/odk/include \
vendor/widevine/libwvdrmengine/oemcrypto/odk/kdo/include \
LOCAL_C_INCLUDES += external/protobuf/src
@@ -40,6 +47,8 @@ LOCAL_STATIC_LIBRARIES := \
libgmock \
libgtest \
libwvlevel3 \
libwv_kdo \
libwv_odk \
LOCAL_SHARED_LIBRARIES := \
libbase \

View File

@@ -63,9 +63,6 @@ const wvcdm::CdmIdentifier kAlternateCdmIdentifier2 = {
const std::string kEmptyServiceCertificate;
const std::string kComma = ",";
// From OEMCrypto v15.2 onwards, we require the nonce table to be size 4.
const size_t kNonceTableSize = 4;
// Protobuf generated classes
using video_widevine::LicenseIdentification;
using video_widevine::LicenseRequest_ContentIdentification;
@@ -2356,22 +2353,14 @@ TEST_F(WvCdmRequestLicenseTest, ProvisioningInterspersedRetryTest) {
// test this for API versions before that if they use OEM certificates.
std::vector<std::string> key_msgs;
// TODO(b/135288420): There can be only one request per OEMCrypto session.
// This code must change.
wvcdm::CdmResponseType first_request_error;
if (provisioning_model == wvcdm::QUERY_VALUE_KEYBOX) {
// For keyboxes we use derived keys as part of the provisioning request.
// These get updated each request, therefore any request before the latest
// fails, so we only need 2 requests.
key_msgs.resize(2);
first_request_error = wvcdm::REWRAP_DEVICE_RSA_KEY_ERROR;
} else {
// For OEM certificates, we don't use derived keys, so any request is
// valid as long as its corresponding nonce is contained in the nonce
// table. This is why we need the size to be fixed.
// We need kNonceTableSize + 1 requests here to check that the first
// of these fails and the one after that succeeds.
key_msgs.resize(kNonceTableSize + 1);
first_request_error = wvcdm::REWRAP_DEVICE_RSA_KEY_30_ERROR;
}
// For keyboxes we use derived keys as part of the provisioning request.
// These get updated each request, therefore any request before the latest
// fails, so we only need 2 requests.
key_msgs.resize(2);
first_request_error = wvcdm::REWRAP_DEVICE_RSA_KEY_ERROR;
for (size_t i = 0; i < key_msgs.size(); i++) {
EXPECT_EQ(
@@ -4941,6 +4930,32 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
// These are the only valid values for Android devices.
EXPECT_TRUE(value == wvcdm::QUERY_VALUE_KEYBOX ||
value == wvcdm::QUERY_VALUE_OEM_CERTIFICATE);
EXPECT_EQ(
wvcdm::NO_ERROR,
decryptor_->QueryStatus(
kLevelDefault, wvcdm::QUERY_KEY_MAX_USAGE_TABLE_ENTRIES, &value));
ss.clear();
ss.str(value);
uint32_t max_usage_table_entries;
ss >> max_usage_table_entries;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
EXPECT_LE(200u, max_usage_table_entries);
EXPECT_EQ(
wvcdm::NO_ERROR,
decryptor_->QueryStatus(
kLevelDefault, wvcdm::QUERY_KEY_OEMCRYPTO_API_MINOR_VERSION, &value));
ss.clear();
ss.str(value);
uint32_t api_minor_version;
ss >> api_minor_version;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
EXPECT_LE(0u, api_minor_version);
}
TEST_F(WvCdmRequestLicenseTest, QueryStatusL3) {
@@ -5048,6 +5063,28 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatusL3) {
// These are the only valid values for Android devices.
EXPECT_TRUE(value == wvcdm::QUERY_VALUE_KEYBOX ||
value == wvcdm::QUERY_VALUE_OEM_CERTIFICATE);
EXPECT_EQ(wvcdm::NO_ERROR,
decryptor_->QueryStatus(
kLevel3, wvcdm::QUERY_KEY_OEMCRYPTO_API_MINOR_VERSION, &value));
ss.clear();
ss.str(value);
uint32_t api_minor_version;
ss >> api_minor_version;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
EXPECT_LE(0u, api_minor_version);
EXPECT_EQ(wvcdm::NO_ERROR,
decryptor_->QueryStatus(
kLevel3, wvcdm::QUERY_KEY_MAX_USAGE_TABLE_ENTRIES, &value));
ss.clear();
ss.str(value);
uint32_t max_usage_table_entries;
ss >> max_usage_table_entries;
ASSERT_FALSE(ss.fail());
EXPECT_TRUE(ss.eof());
EXPECT_LE(200u, max_usage_table_entries);
}
TEST_F(WvCdmRequestLicenseTest, QueryOemCryptoSessionId) {

View File

@@ -11,13 +11,15 @@ LOCAL_MODULE_TAGS := tests
LOCAL_SRC_FILES := \
$(test_src_dir)/$(test_name).cpp \
../../oemcrypto/test/oec_device_features.cpp \
../core/test/config_test_env.cpp \
../core/test/fake_provisioning_server.cpp \
../core/test/http_socket.cpp \
../core/test/license_request.cpp \
../core/test/test_base.cpp \
../core/test/test_printers.cpp \
../core/test/url_request.cpp
../core/test/url_request.cpp \
../../oemcrypto/test/oec_device_features.cpp \
../util/test/test_sleep.cpp \
LOCAL_C_INCLUDES := \
vendor/widevine/libwvdrmengine/android/cdm/test \
@@ -26,8 +28,11 @@ LOCAL_C_INCLUDES := \
vendor/widevine/libwvdrmengine/cdm/include \
vendor/widevine/libwvdrmengine/cdm/metrics/include \
vendor/widevine/libwvdrmengine/cdm/util/include \
vendor/widevine/libwvdrmengine/cdm/util/test \
vendor/widevine/libwvdrmengine/oemcrypto/include \
vendor/widevine/libwvdrmengine/oemcrypto/test \
vendor/widevine/libwvdrmengine/oemcrypto/odk/include \
vendor/widevine/libwvdrmengine/oemcrypto/odk/kdo/include \
LOCAL_C_INCLUDES += external/protobuf/src