diff --git a/Android.bp b/Android.bp new file mode 100644 index 00000000..292b5255 --- /dev/null +++ b/Android.bp @@ -0,0 +1,45 @@ +// +// Copyright (C) 2021 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + default_applicable_licenses: ["vendor_widevine_license"], +} + +// Added automatically by a large-scale-change that took the approach of +// 'apply every license found to every target'. While this makes sure we respect +// every license restriction, it may not be entirely correct. +// +// e.g. GPL in an MIT project might only apply to the contrib/ directory. +// +// Please consider splitting the single license below into multiple licenses, +// taking care not to lose any license_kind information, and overriding the +// default license using the 'licenses: [...]' property on targets as needed. +// +// For unused files, consider creating a 'fileGroup' with "//visibility:private" +// to attach the license to, and including a comment whether the files may be +// used in the current project. +// See: http://go/android-license-faq +license { + name: "vendor_widevine_license", + visibility: [":__subpackages__"], + license_kinds: [ + "SPDX-license-identifier-Apache-2.0", + "legacy_by_exception_only", // by exception only + ], + // large-scale-change unable to identify any license_text files +} diff --git a/libwvdrmengine/Android.bp b/libwvdrmengine/Android.bp index 1b40061d..0dde5135 100644 --- a/libwvdrmengine/Android.bp +++ b/libwvdrmengine/Android.bp @@ -41,6 +41,19 @@ // However, restorecon is not implemented for /vendor/bin, so we put // the script in /system/bin. // +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "vendor_widevine_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + // legacy_by_exception_only (by exception only) + default_applicable_licenses: ["vendor_widevine_license"], +} + sh_binary { name: "move_widevine_data", src: "move_widevine_data.sh", diff --git a/libwvdrmengine/cdm/Android.bp b/libwvdrmengine/cdm/Android.bp index 4ad49ab4..8a2ba34a 100644 --- a/libwvdrmengine/cdm/Android.bp +++ b/libwvdrmengine/cdm/Android.bp @@ -2,6 +2,18 @@ // Builds libcdm.a // +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "vendor_widevine_license" + // to get the below license kinds: + // legacy_by_exception_only (by exception only) + default_applicable_licenses: ["vendor_widevine_license"], +} + SRC_DIR = "src" CORE_SRC_DIR = "core/src" METRICS_SRC_DIR = "metrics/src" diff --git a/libwvdrmengine/cdm/core/src/Android.bp b/libwvdrmengine/cdm/core/src/Android.bp index b0bdff09..d6631060 100644 --- a/libwvdrmengine/cdm/core/src/Android.bp +++ b/libwvdrmengine/cdm/core/src/Android.bp @@ -1,3 +1,32 @@ +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + default_applicable_licenses: [ + "vendor_widevine_libwvdrmengine_cdm_core_src_license", + ], +} + +// Added automatically by a large-scale-change +// +// large-scale-change included anything that looked like it might be a license +// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc. +// +// Please consider removing redundant or irrelevant files from 'license_text:'. +// See: http://go/android-license-faq +license { + name: "vendor_widevine_libwvdrmengine_cdm_core_src_license", + visibility: [":__subpackages__"], + license_kinds: [ + "legacy_by_exception_only", // by exception only + ], + license_text: [ + "license.cpp", + "license_key_status.cpp", + "license_protocol.proto", + ], +} + cc_library { name: "libcdm_protos", diff --git a/libwvdrmengine/cdm/core/src/cdm_session.cpp b/libwvdrmengine/cdm/core/src/cdm_session.cpp index 9d4bfb43..07634c2a 100644 --- a/libwvdrmengine/cdm/core/src/cdm_session.cpp +++ b/libwvdrmengine/cdm/core/src/cdm_session.cpp @@ -926,7 +926,7 @@ int64_t CdmSession::GetDurationRemaining() { CdmSessionId CdmSession::GenerateSessionId() { static int session_num = 1; - return SESSION_ID_PREFIX + IntToString(++session_num); + return SESSION_ID_PREFIX + std::to_string(++session_num); } bool CdmSession::GenerateKeySetId(bool atsc_mode_enabled, diff --git a/libwvdrmengine/cdm/core/src/certificate_provisioning.cpp b/libwvdrmengine/cdm/core/src/certificate_provisioning.cpp index 27e01b9f..048da402 100644 --- a/libwvdrmengine/cdm/core/src/certificate_provisioning.cpp +++ b/libwvdrmengine/cdm/core/src/certificate_provisioning.cpp @@ -318,9 +318,7 @@ CdmResponseType CertificateProvisioning::GetProvisioningRequestInternal( if (!wvcdm::Properties::provisioning_messages_are_binary()) { // Return request as web-safe base64 string - std::vector request_vector(serialized_request.begin(), - serialized_request.end()); - *request = Base64SafeEncodeNoPad(request_vector); + *request = Base64SafeEncodeNoPad(serialized_request); } else { *request = std::move(serialized_request); } diff --git a/libwvdrmengine/cdm/core/src/device_files.cpp b/libwvdrmengine/cdm/core/src/device_files.cpp index 2fa06fed..d21943c3 100644 --- a/libwvdrmengine/cdm/core/src/device_files.cpp +++ b/libwvdrmengine/cdm/core/src/device_files.cpp @@ -1771,9 +1771,7 @@ std::string DeviceFiles::GetUsageInfoFileName(const std::string& app_id) { } std::string DeviceFiles::GetFileNameSafeHash(const std::string& input) { - std::string hash = Md5Hash(input); - return wvcdm::Base64SafeEncode( - std::vector(hash.begin(), hash.end())); + return wvcdm::Base64SafeEncode(Md5Hash(input)); } } // namespace wvcdm diff --git a/libwvdrmengine/cdm/core/test/Android.bp b/libwvdrmengine/cdm/core/test/Android.bp index 841d1302..6c868c08 100644 --- a/libwvdrmengine/cdm/core/test/Android.bp +++ b/libwvdrmengine/cdm/core/test/Android.bp @@ -12,6 +12,36 @@ // See the License for the specific language governing permissions and$ // limitations under the License. +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + default_applicable_licenses: [ + "vendor_widevine_libwvdrmengine_cdm_core_test_license", + ], +} + +// Added automatically by a large-scale-change +// +// large-scale-change included anything that looked like it might be a license +// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc. +// +// Please consider removing redundant or irrelevant files from 'license_text:'. +// See: http://go/android-license-faq +license { + name: "vendor_widevine_libwvdrmengine_cdm_core_test_license", + visibility: [":__subpackages__"], + license_kinds: [ + "legacy_by_exception_only", // by exception only + ], + license_text: [ + "license_keys_unittest.cpp", + "license_request.cpp", + "license_request.h", + "license_unittest.cpp", + ], +} + filegroup { name: "vts_cdm_core_test_srcs", srcs: [ diff --git a/libwvdrmengine/cdm/core/test/cdm_engine_test.cpp b/libwvdrmengine/cdm/core/test/cdm_engine_test.cpp index edcd8e8e..28d6dd78 100644 --- a/libwvdrmengine/cdm/core/test/cdm_engine_test.cpp +++ b/libwvdrmengine/cdm/core/test/cdm_engine_test.cpp @@ -107,9 +107,7 @@ class WvCdmEnginePreProvTest : public WvCdmTestBaseWithEngine { license_request.GetDrmMessage(http_response, *response); LOGV("response: size = %zu, string =\n%s\n", response->size(), - Base64SafeEncode( - std::vector(response->begin(), response->end())) - .c_str()); + Base64SafeEncode(*response).c_str()); return true; } diff --git a/libwvdrmengine/cdm/core/test/fake_provisioning_server.cpp b/libwvdrmengine/cdm/core/test/fake_provisioning_server.cpp index 1877f4bb..f6bdca48 100644 --- a/libwvdrmengine/cdm/core/test/fake_provisioning_server.cpp +++ b/libwvdrmengine/cdm/core/test/fake_provisioning_server.cpp @@ -352,11 +352,11 @@ bool FakeProvisioningServer::MakeResponse( // CDM. std::string response_data; signed_response.SerializeToString(&response_data); - std::vector response_data_v(response_data.begin(), - response_data.end()); - static const std::string json_start = "{ \"signedResponse\": \""; - static const std::string json_end = "\" }"; - *json_response = json_start + Base64SafeEncode(response_data_v) + json_end; + static const std::string kJsonStart = "{ \"signedResponse\": \""; + static const std::string kJsonEnd = "\" }"; + *json_response = kJsonStart; + json_response->append(Base64SafeEncode(response_data)); + json_response->append(kJsonEnd); return true; } diff --git a/libwvdrmengine/cdm/core/test/initialization_data_unittest.cpp b/libwvdrmengine/cdm/core/test/initialization_data_unittest.cpp index 717a00bc..692de725 100644 --- a/libwvdrmengine/cdm/core/test/initialization_data_unittest.cpp +++ b/libwvdrmengine/cdm/core/test/initialization_data_unittest.cpp @@ -341,11 +341,8 @@ class VectorOfStrings { std::string GenerateHlsUriData(const std::string& provider, const std::string& content_id, const std::vector& key_ids) { - std::string json = GenerateJsonInitData(provider, content_id, key_ids); - std::vector json_init_data( - reinterpret_cast(json.data()), - reinterpret_cast(json.data() + json.size())); - return kHlsTestUriDataFormat + Base64Encode(json_init_data); + const std::string json = GenerateJsonInitData(provider, content_id, key_ids); + return kHlsTestUriDataFormat + Base64Encode(json); } std::string CreateHlsAttributeList(const std::string& method, @@ -786,19 +783,16 @@ INSTANTIATE_TEST_CASE_P( .AddKeyId(kHlsTestKeyId1))); TEST_F(HlsInitDataConstructionTest, InvalidUriDataFormat) { - std::string json = + const std::string json = GenerateJsonInitData(kHlsTestProvider, kHlsTestContentId, VectorOfStrings(kHlsTestKeyId1).Generate()); - std::vector json_init_data( - reinterpret_cast(json.data()), - reinterpret_cast(json.data() + json.size())); std::string value; EXPECT_FALSE(InitializationData::ConstructWidevineInitData( - kHlsMethodAes128, Base64Encode(json_init_data), &value)); + kHlsMethodAes128, Base64Encode(json), &value)); } TEST_F(HlsInitDataConstructionTest, InvalidUriBase64Encode) { - std::string json = + const std::string json = GenerateJsonInitData(kHlsTestProvider, kHlsTestContentId, VectorOfStrings(kHlsTestKeyId1).Generate()); std::string value; diff --git a/libwvdrmengine/cdm/core/test/test_base.cpp b/libwvdrmengine/cdm/core/test/test_base.cpp index 3f4117f6..83e2d551 100644 --- a/libwvdrmengine/cdm/core/test/test_base.cpp +++ b/libwvdrmengine/cdm/core/test/test_base.cpp @@ -291,7 +291,6 @@ WvCdmTestBase::WvCdmTestBase() void WvCdmTestBase::Provision() { CdmProvisioningRequest prov_request; - CdmProvisioningRequest binary_prov_request; std::string provisioning_server_url; CdmCertificateType cert_type = kCertificateWidevine; std::string cert_authority; @@ -331,9 +330,7 @@ void WvCdmTestBase::Provision() { ASSERT_EQ(NO_ERROR, result); if (binary_provisioning_) { - binary_prov_request = prov_request; - prov_request = std::string(Base64SafeEncodeNoPad(std::vector( - binary_prov_request.begin(), binary_prov_request.end()))); + prov_request = Base64SafeEncodeNoPad(prov_request); } LOGV("Provisioning request: req = %s", prov_request.c_str()); diff --git a/libwvdrmengine/cdm/metrics/src/Android.bp b/libwvdrmengine/cdm/metrics/src/Android.bp index 925a0419..5c01872a 100644 --- a/libwvdrmengine/cdm/metrics/src/Android.bp +++ b/libwvdrmengine/cdm/metrics/src/Android.bp @@ -13,6 +13,18 @@ // limitations under the License. // Build host library for metrics_dump tool. +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "vendor_widevine_license" + // to get the below license kinds: + // legacy_by_exception_only (by exception only) + default_applicable_licenses: ["vendor_widevine_license"], +} + cc_library_host_shared { name: "libcdm_metrics_protos_full_host", diff --git a/libwvdrmengine/cdm/test/integration-test.mk b/libwvdrmengine/cdm/test/integration-test.mk index 86319d93..55673b4a 100644 --- a/libwvdrmengine/cdm/test/integration-test.mk +++ b/libwvdrmengine/cdm/test/integration-test.mk @@ -7,6 +7,8 @@ $(call assert-not-null,test_name) include $(CLEAR_VARS) LOCAL_MODULE := $(test_name) +LOCAL_LICENSE_KINDS := legacy_by_exception_only +LOCAL_LICENSE_CONDITIONS := by_exception_only LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := \ diff --git a/libwvdrmengine/cdm/test/request_license_test.cpp b/libwvdrmengine/cdm/test/request_license_test.cpp index c0198cc6..e8dff3e5 100644 --- a/libwvdrmengine/cdm/test/request_license_test.cpp +++ b/libwvdrmengine/cdm/test/request_license_test.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -2613,9 +2614,9 @@ TEST_F(WvCdmRequestLicenseTest, ProvisioningRevocationTest) { signed_response.SerializeToString(&response); if (!wvcdm::Properties::provisioning_messages_are_binary()) { - std::vector response_vec(response.begin(), response.end()); + const std::string binary_response = std::move(response); response = "\"signedResponse\": \""; - response.append(wvcdm::Base64SafeEncode(response_vec)); + response.append(wvcdm::Base64SafeEncode(binary_response)); response.append("\""); } diff --git a/libwvdrmengine/cdm/test/unit-test.mk b/libwvdrmengine/cdm/test/unit-test.mk index f4919842..70963ac3 100644 --- a/libwvdrmengine/cdm/test/unit-test.mk +++ b/libwvdrmengine/cdm/test/unit-test.mk @@ -7,6 +7,8 @@ $(call assert-not-null,test_name) include $(CLEAR_VARS) LOCAL_MODULE := $(test_name) +LOCAL_LICENSE_KINDS := legacy_by_exception_only +LOCAL_LICENSE_CONDITIONS := by_exception_only LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := \ diff --git a/libwvdrmengine/cdm/util/include/string_conversions.h b/libwvdrmengine/cdm/util/include/string_conversions.h index feff9dca..c1606527 100644 --- a/libwvdrmengine/cdm/util/include/string_conversions.h +++ b/libwvdrmengine/cdm/util/include/string_conversions.h @@ -1,7 +1,6 @@ // Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary // source code may only be used and distributed under the Widevine License // Agreement. - #ifndef WVCDM_UTIL_STRING_CONVERSIONS_H_ #define WVCDM_UTIL_STRING_CONVERSIONS_H_ @@ -15,29 +14,49 @@ namespace wvcdm { +// ASCII hex to Binary conversion. CORE_UTIL_EXPORT std::vector a2b_hex(const std::string& b); CORE_UTIL_EXPORT std::vector a2b_hex(const std::string& label, const std::string& b); CORE_UTIL_EXPORT std::string a2bs_hex(const std::string& b); + +// Binary to ASCII hex conversion. CORE_UTIL_EXPORT std::string b2a_hex(const std::vector& b); CORE_UTIL_EXPORT std::string b2a_hex(const std::string& b); +CORE_UTIL_EXPORT std::string HexEncode(const uint8_t* bytes, size_t size); + +// Base64 encoding/decoding. +// Converts binary data into the ASCII Base64 character set and vice +// versa using the encoding rules defined in RFC4648 section 4. CORE_UTIL_EXPORT std::string Base64Encode( const std::vector& bin_input); +CORE_UTIL_EXPORT std::string Base64Encode(const std::string& bin_input); CORE_UTIL_EXPORT std::vector Base64Decode( const std::string& bin_input); + +// URL-Safe Base64 encoding/decoding. +// Converts binary data into the URL/Filename safe ASCII Base64 +// character set and vice versa using the encoding rules defined in +// RFC4648 section 5. CORE_UTIL_EXPORT std::string Base64SafeEncode( const std::vector& bin_input); -CORE_UTIL_EXPORT std::string Base64SafeEncodeNoPad( - const std::vector& bin_input); +CORE_UTIL_EXPORT std::string Base64SafeEncode(const std::string& bin_input); CORE_UTIL_EXPORT std::vector Base64SafeDecode( const std::string& bin_input); -CORE_UTIL_EXPORT std::string HexEncode(const uint8_t* bytes, unsigned size); -CORE_UTIL_EXPORT std::string IntToString(int value); +// URL-Safe Base64 encoding without padding. +// Similar to Base64SafeEncode(), without any padding character '=' +// at the end. +CORE_UTIL_EXPORT std::string Base64SafeEncodeNoPad( + const std::vector& bin_input); +CORE_UTIL_EXPORT std::string Base64SafeEncodeNoPad( + const std::string& bin_input); + +// Host to Network/Network to Host conversion. CORE_UTIL_EXPORT int64_t htonll64(int64_t x); CORE_UTIL_EXPORT inline int64_t ntohll64(int64_t x) { return htonll64(x); } -CORE_UTIL_EXPORT std::string BytesToString(const uint8_t* bytes, unsigned size); -// Encode unsigned integer into a big endian formatted string -CORE_UTIL_EXPORT std::string EncodeUint32(unsigned int u); + +// Encode unsigned integer into a big endian formatted string. +CORE_UTIL_EXPORT std::string EncodeUint32(uint32_t u); } // namespace wvcdm diff --git a/libwvdrmengine/cdm/util/src/string_conversions.cpp b/libwvdrmengine/cdm/util/src/string_conversions.cpp index 2b0ba5f1..3faa2fe5 100644 --- a/libwvdrmengine/cdm/util/src/string_conversions.cpp +++ b/libwvdrmengine/cdm/util/src/string_conversions.cpp @@ -10,15 +10,18 @@ #include #include -#include #include "log.h" #include "platform.h" namespace wvcdm { - -static const char kBase64Codes[] = +namespace { +// Base64 character set, indexed for their 6-bit mapping, plus '='. +const char kBase64Codes[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; +// URL safe Base64 character set. +const char kBase64SafeCodes[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="; // Gets the low |n| bits of |in|. #define GET_LOW_BITS(in, n) ((in) & ((1 << (n)) - 1)) @@ -27,26 +30,131 @@ static const char kBase64Codes[] = // Calculates a/b using round-up division (only works for positive numbers). #define CEIL_DIVIDE(a, b) ((((a)-1) / (b)) + 1) -int DecodeBase64Char(char c) { - const char* it = strchr(kBase64Codes, c); +// Decodes a single Base64 encoded character into its 6-bit value. +// The provided |codes| must be a Base64 character map. +int DecodeBase64Char(char c, const char* codes) { + const char* it = strchr(codes, c); if (it == nullptr) return -1; - return it - kBase64Codes; + return it - codes; } -bool DecodeHexChar(char ch, unsigned char* digit) { +bool DecodeHexChar(char ch, uint8_t* digit) { if (ch >= '0' && ch <= '9') { *digit = ch - '0'; - } else { - ch = tolower(ch); - if ((ch >= 'a') && (ch <= 'f')) { - *digit = ch - 'a' + 10; - } else { - return false; + return true; + } + ch = tolower(ch); + if ((ch >= 'a') && (ch <= 'f')) { + *digit = ch - 'a' + 10; + return true; + } + return false; +} + +// Encode for standard base64 encoding (RFC4648). +// https://en.wikipedia.org/wiki/Base64 +// Text | M | a | n | +// ASCI | 77 (0x4d) | 97 (0x61) | 110 (0x6e) | +// Bits | 0 1 0 0 1 1 0 1 0 1 1 0 0 0 0 1 0 1 1 0 1 1 1 0 | +// Index | 19 | 22 | 5 | 46 | +// Base64 | T | W | F | u | +// | <----------------- 24-bits -----------------> | + +// The provided |codes| must be a Base64 character map. +std::string Base64EncodeInternal(const uint8_t* data, size_t length, + const char* codes) { + // |temp| stores a 24-bit block that is treated as an array where insertions + // occur from high to low. + uint32_t temp = 0; + size_t out_index = 0; + const size_t out_size = CEIL_DIVIDE(length, 3) * 4; + std::string result(out_size, '\0'); + for (size_t i = 0; i < length; i++) { + // "insert" 8-bits of data + temp |= (data[i] << ((2 - (i % 3)) * 8)); + if (i % 3 == 2) { + result[out_index++] = codes[GET_BITS(temp, 18, 24)]; + result[out_index++] = codes[GET_BITS(temp, 12, 18)]; + result[out_index++] = codes[GET_BITS(temp, 6, 12)]; + result[out_index++] = codes[GET_BITS(temp, 0, 6)]; + temp = 0; } } - return true; + if (length % 3 == 1) { + result[out_index++] = codes[GET_BITS(temp, 18, 24)]; + result[out_index++] = codes[GET_BITS(temp, 12, 18)]; + result[out_index++] = '='; + result[out_index++] = '='; + } else if (length % 3 == 2) { + result[out_index++] = codes[GET_BITS(temp, 18, 24)]; + result[out_index++] = codes[GET_BITS(temp, 12, 18)]; + result[out_index++] = codes[GET_BITS(temp, 6, 12)]; + result[out_index++] = '='; + } + return result; } +std::vector Base64DecodeInternal(const char* encoded, size_t length, + const char* codes) { + const size_t out_size_max = CEIL_DIVIDE(length * 3, 4); + std::vector result(out_size_max, '\0'); + // |temp| stores 24-bits of data that is treated as an array where insertions + // occur from high to low. + uint32_t temp = 0; + size_t out_index = 0; + size_t i; + for (i = 0; i < length; i++) { + if (encoded[i] == '=') { + // Verify an '=' only appears at the end. We want i to remain at the + // first '=', so we need an inner loop. + for (size_t j = i; j < length; j++) { + if (encoded[j] != '=') { + LOGE("base64Decode failed"); + return std::vector(); + } + } + if (length % 4 != 0) { + // If padded, then the length must be a multiple of 4. + // Unpadded messages are OK. + LOGE("base64Decode failed"); + return std::vector(); + } + break; + } + + const int decoded = DecodeBase64Char(encoded[i], codes); + if (decoded < 0) { + LOGE("base64Decode failed"); + return std::vector(); + } + // "insert" 6-bits of data + temp |= (decoded << ((3 - (i % 4)) * 6)); + + if (i % 4 == 3) { + result[out_index++] = GET_BITS(temp, 16, 24); + result[out_index++] = GET_BITS(temp, 8, 16); + result[out_index++] = GET_BITS(temp, 0, 8); + temp = 0; + } + } + + switch (i % 4) { + case 1: + LOGE("base64Decode failed"); + return std::vector(); + case 2: + result[out_index++] = GET_BITS(temp, 16, 24); + break; + case 3: + result[out_index++] = GET_BITS(temp, 16, 24); + result[out_index++] = GET_BITS(temp, 8, 16); + break; + } + result.resize(out_index); + return result; +} +} // namespace + // converts an ascii hex string(2 bytes per digit) into a decimal byte string std::vector a2b_hex(const std::string& byte) { std::vector array; @@ -97,161 +205,7 @@ std::string b2a_hex(const std::string& byte) { byte.length()); } -// Encode for standard base64 encoding (RFC4648). -// https://en.wikipedia.org/wiki/Base64 -// Text | M | a | n | -// ASCI | 77 (0x4d) | 97 (0x61) | 110 (0x6e) | -// Bits | 0 1 0 0 1 1 0 1 0 1 1 0 0 0 0 1 0 1 1 0 1 1 1 0 | -// Index | 19 | 22 | 5 | 46 | -// Base64 | T | W | F | u | -// | <----------------- 24-bits -----------------> | -std::string Base64Encode(const std::vector& bin_input) { - if (bin_input.empty()) { - return std::string(); - } - - // |temp| stores a 24-bit block that is treated as an array where insertions - // occur from high to low. - uint32_t temp = 0; - size_t out_index = 0; - const size_t out_size = CEIL_DIVIDE(bin_input.size(), 3) * 4; - std::string result(out_size, '\0'); - for (size_t i = 0; i < bin_input.size(); i++) { - // "insert" 8-bits of data - temp |= (bin_input[i] << ((2 - (i % 3)) * 8)); - - if (i % 3 == 2) { - result[out_index++] = kBase64Codes[GET_BITS(temp, 18, 24)]; - result[out_index++] = kBase64Codes[GET_BITS(temp, 12, 18)]; - result[out_index++] = kBase64Codes[GET_BITS(temp, 6, 12)]; - result[out_index++] = kBase64Codes[GET_BITS(temp, 0, 6)]; - temp = 0; - } - } - - if (bin_input.size() % 3 == 1) { - result[out_index++] = kBase64Codes[GET_BITS(temp, 18, 24)]; - result[out_index++] = kBase64Codes[GET_BITS(temp, 12, 18)]; - result[out_index++] = '='; - result[out_index++] = '='; - } else if (bin_input.size() % 3 == 2) { - result[out_index++] = kBase64Codes[GET_BITS(temp, 18, 24)]; - result[out_index++] = kBase64Codes[GET_BITS(temp, 12, 18)]; - result[out_index++] = kBase64Codes[GET_BITS(temp, 6, 12)]; - result[out_index++] = '='; - } - - return result; -} - -// Filename-friendly base64 encoding (RFC4648), commonly referred to -// as Base64WebSafeEncode. -// -// This is the encoding required to interface with the provisioning server, as -// well as for certain license server transactions. It is also used for logging -// certain strings. The difference between web safe encoding vs regular encoding -// is that the web safe version replaces '+' with '-' and '/' with '_'. -std::string Base64SafeEncode(const std::vector& bin_input) { - if (bin_input.empty()) { - return std::string(); - } - - std::string ret = Base64Encode(bin_input); - for (size_t i = 0; i < ret.size(); i++) { - if (ret[i] == '+') - ret[i] = '-'; - else if (ret[i] == '/') - ret[i] = '_'; - } - return ret; -} - -std::string Base64SafeEncodeNoPad(const std::vector& bin_input) { - std::string b64_output = Base64SafeEncode(bin_input); - // Output size: ceiling [ bin_input.size() * 4 / 3 ]. - b64_output.resize((bin_input.size() * 4 + 2) / 3); - return b64_output; -} - -// Decode for standard base64 encoding (RFC4648). -std::vector Base64Decode(const std::string& b64_input) { - if (b64_input.empty()) { - return std::vector(); - } - - const size_t out_size_max = CEIL_DIVIDE(b64_input.size() * 3, 4); - std::vector result(out_size_max, '\0'); - - // |temp| stores 24-bits of data that is treated as an array where insertions - // occur from high to low. - uint32_t temp = 0; - size_t out_index = 0; - size_t i; - for (i = 0; i < b64_input.size(); i++) { - if (b64_input[i] == '=') { - // Verify an '=' only appears at the end. We want i to remain at the - // first '=', so we need an inner loop. - for (size_t j = i; j < b64_input.size(); j++) { - if (b64_input[j] != '=') { - LOGE("base64Decode failed"); - return std::vector(); - } - } - break; - } - - const int decoded = DecodeBase64Char(b64_input[i]); - if (decoded < 0) { - LOGE("base64Decode failed"); - return std::vector(); - } - // "insert" 6-bits of data - temp |= (decoded << ((3 - (i % 4)) * 6)); - - if (i % 4 == 3) { - result[out_index++] = GET_BITS(temp, 16, 24); - result[out_index++] = GET_BITS(temp, 8, 16); - result[out_index++] = GET_BITS(temp, 0, 8); - temp = 0; - } - } - - switch (i % 4) { - case 1: - LOGE("base64Decode failed"); - return std::vector(); - case 2: - result[out_index++] = GET_BITS(temp, 16, 24); - break; - case 3: - result[out_index++] = GET_BITS(temp, 16, 24); - result[out_index++] = GET_BITS(temp, 8, 16); - break; - } - result.resize(out_index); - return result; -} - -// Decode for Filename-friendly base64 encoding (RFC4648), commonly referred -// as Base64WebSafeDecode. Add padding if needed. -std::vector Base64SafeDecode(const std::string& b64_input) { - if (b64_input.empty()) { - return std::vector(); - } - - // Make a copy so we can modify it to replace the web-safe special characters - // with the normal ones. - std::string input_copy = b64_input; - for (size_t i = 0; i < input_copy.size(); i++) { - if (input_copy[i] == '-') - input_copy[i] = '+'; - else if (input_copy[i] == '_') - input_copy[i] = '/'; - } - return Base64Decode(input_copy); -} - -std::string HexEncode(const uint8_t* in_buffer, unsigned int size) { +std::string HexEncode(const uint8_t* in_buffer, size_t size) { static const char kHexChars[] = "0123456789ABCDEF"; if (size == 0) return ""; constexpr unsigned int kMaxSafeSize = 3072; @@ -267,19 +221,83 @@ std::string HexEncode(const uint8_t* in_buffer, unsigned int size) { return out_buffer; } -std::string IntToString(int value) { - // log10(2) ~= 0.3 bytes needed per bit or per byte log10(2**8) ~= 2.4. - // So round up to allocate 3 output characters per byte, plus 1 for '-'. - const int kOutputBufSize = 3 * sizeof(int) + 1; - char buffer[kOutputBufSize]; - memset(buffer, 0, kOutputBufSize); - snprintf(buffer, kOutputBufSize, "%d", value); +// Standard Base64 encoding and decoding. - std::string out_string(buffer); - return out_string; +std::string Base64Encode(const std::vector& bin_input) { + if (bin_input.empty()) { + return std::string(); + } + return Base64EncodeInternal(bin_input.data(), bin_input.size(), kBase64Codes); } -int64_t htonll64(int64_t x) { // Convert to big endian (network-byte-order) +std::string Base64Encode(const std::string& bin_input) { + if (bin_input.empty()) { + return std::string(); + } + return Base64EncodeInternal( + reinterpret_cast(bin_input.data()), bin_input.size(), + kBase64Codes); +} + +// Decode for standard base64 encoding (RFC4648). +std::vector Base64Decode(const std::string& b64_input) { + if (b64_input.empty()) { + return std::vector(); + } + return Base64DecodeInternal(b64_input.data(), b64_input.size(), kBase64Codes); +} + +// URL/Filename Safe Base64 encoding and decoding. + +// This is the encoding required to interface with the provisioning server, as +// well as for certain license server transactions. It is also used for logging +// certain strings. The difference between web safe encoding vs regular encoding +// is that the web safe version replaces '+' with '-' and '/' with '_'. +std::string Base64SafeEncode(const std::vector& bin_input) { + if (bin_input.empty()) { + return std::string(); + } + return Base64EncodeInternal(bin_input.data(), bin_input.size(), + kBase64SafeCodes); +} + +std::string Base64SafeEncode(const std::string& bin_input) { + if (bin_input.empty()) { + return std::string(); + } + return Base64EncodeInternal( + reinterpret_cast(bin_input.data()), bin_input.size(), + kBase64SafeCodes); +} + +std::vector Base64SafeDecode(const std::string& b64_input) { + if (b64_input.empty()) { + return std::vector(); + } + return Base64DecodeInternal(b64_input.data(), b64_input.size(), + kBase64SafeCodes); +} + +// URL/Filename Safe Base64 encoding without padding. + +std::string Base64SafeEncodeNoPad(const std::vector& bin_input) { + std::string b64_output = Base64SafeEncode(bin_input); + // Output size: ceiling [ bin_input.size() * 4 / 3 ]. + b64_output.resize((bin_input.size() * 4 + 2) / 3); + return b64_output; +} + +std::string Base64SafeEncodeNoPad(const std::string& bin_input) { + std::string b64_output = Base64SafeEncode(bin_input); + // Output size: ceiling [ bin_input.size() * 4 / 3 ]. + b64_output.resize((bin_input.size() * 4 + 2) / 3); + return b64_output; +} + +// Host to Network/Network to Host conversion. + +// Convert to big endian (network-byte-order) +int64_t htonll64(int64_t x) { union { uint32_t array[2]; int64_t number; @@ -296,19 +314,13 @@ int64_t htonll64(int64_t x) { // Convert to big endian (network-byte-order) } } -std::string BytesToString(const uint8_t* bytes, unsigned size) { - if (!bytes || !size) return ""; - const char* char_bytes = reinterpret_cast(bytes); - return std::string(char_bytes, char_bytes + size); -} - // Encode unsigned integer into a big endian formatted string std::string EncodeUint32(unsigned int u) { std::string s; - s.append(1, (u >> 24) & 0xFF); - s.append(1, (u >> 16) & 0xFF); - s.append(1, (u >> 8) & 0xFF); - s.append(1, (u >> 0) & 0xFF); + s.push_back((u >> 24) & 0xFF); + s.push_back((u >> 16) & 0xFF); + s.push_back((u >> 8) & 0xFF); + s.push_back(u & 0xFF); return s; } diff --git a/libwvdrmengine/cdm/util/test/base64_test.cpp b/libwvdrmengine/cdm/util/test/base64_test.cpp index 81d32a98..684fa447 100644 --- a/libwvdrmengine/cdm/util/test/base64_test.cpp +++ b/libwvdrmengine/cdm/util/test/base64_test.cpp @@ -55,8 +55,14 @@ const std::pair kBase64TestVectors[] = { make_pair(&kTwoBytesOverData, &kTwoBytesOverB64Data), make_pair(&kTestData, &kB64TestData)}; -const std::string kBase64ErrorVectors[] = {"Foo$sa", "Foo\x99\x23\xfa\02", - "Foo==Foo", "FooBa"}; +// Arbitrary invalid base64 test vectors +const std::string kBase64ErrorVectors[] = {"Foo$sa", + "Foo\x99\x23\xfa\02", + "Foo==Foo", + "FooBa", + "SGVsbG8sIFdvcmxkI===", + "SGVsbG8sIFdvcmxkI======", + "SGVsbG8sIFdvcmxkIQp=="}; std::string ConvertToBase64WebSafe(const std::string& std_base64_string) { std::string str(std_base64_string); @@ -77,28 +83,90 @@ class Base64EncodeDecodeTest TEST_P(Base64EncodeDecodeTest, EncodeDecodeTest) { std::pair values = GetParam(); - std::vector decoded_vector = Base64Decode(values.second->data()); - std::string decoded_string(decoded_vector.begin(), decoded_vector.end()); - EXPECT_STREQ(values.first->data(), decoded_string.data()); - std::string b64_string = Base64Encode(decoded_vector); - EXPECT_STREQ(values.second->data(), b64_string.data()); + const std::string& plain_text_string = *(values.first); + const std::string& expected_encoded = *(values.second); + + // Encode from string. + const std::string b64_string_encoded = Base64Encode(plain_text_string); + EXPECT_EQ(b64_string_encoded, expected_encoded); + + // Encode from vector. + const std::vector plain_text_vector(plain_text_string.begin(), + plain_text_string.end()); + const std::string b64_vector_encoded = Base64Encode(plain_text_vector); + EXPECT_EQ(b64_vector_encoded, expected_encoded); + + // Decode from string. + const std::vector decoded_vector = Base64Decode(expected_encoded); + EXPECT_EQ(decoded_vector, plain_text_vector); } TEST_P(Base64EncodeDecodeTest, WebSafeEncodeDecodeTest) { std::pair values = GetParam(); - std::string encoded_string = ConvertToBase64WebSafe(*(values.second)); - std::vector decoded_vector = Base64SafeDecode(encoded_string); - std::string decoded_string(decoded_vector.begin(), decoded_vector.end()); - EXPECT_STREQ(values.first->data(), decoded_string.data()); - std::string b64_string = Base64SafeEncode(decoded_vector); - EXPECT_STREQ(encoded_string.data(), b64_string.data()); + const std::string& plain_text_string = *(values.first); + const std::string& expected_encoded = + ConvertToBase64WebSafe(*(values.second)); + + // Encode from string. + const std::string b64_string_encoded = Base64SafeEncode(plain_text_string); + EXPECT_EQ(b64_string_encoded, expected_encoded); + + // Encode from vector. + const std::vector plain_text_vector(plain_text_string.begin(), + plain_text_string.end()); + const std::string b64_vector_encoded = Base64SafeEncode(plain_text_vector); + EXPECT_EQ(b64_vector_encoded, expected_encoded); + + // Decode from string. + const std::vector decoded_vector = + Base64SafeDecode(expected_encoded); + EXPECT_EQ(decoded_vector, plain_text_vector); +} + +TEST_P(Base64EncodeDecodeTest, WebSafeEncodeNoPad) { + std::pair values = GetParam(); + const std::string& plain_text_string = *(values.first); + const std::string& padded_encoded = ConvertToBase64WebSafe(*(values.second)); + + // Encode from string. + const std::string b64_string_encoded = + Base64SafeEncodeNoPad(plain_text_string); + + // If input is empty, output will be empty. + if (plain_text_string.empty()) { + EXPECT_TRUE(b64_string_encoded.empty()); + return; + } + + if (padded_encoded.back() == '=') { + // If padding is present in the regular encoding, then it should be + // striped from the result. + EXPECT_NE(b64_string_encoded.back(), '='); + const std::string expected_encoded = + padded_encoded.substr(0, b64_string_encoded.size()); + EXPECT_EQ(b64_string_encoded, expected_encoded); + } else { + // If no padding is present, then results should be equal. + EXPECT_EQ(b64_string_encoded, padded_encoded); + } + + // Encode from vector. + const std::vector plain_text_vector(plain_text_string.begin(), + plain_text_string.end()); + const std::string b64_vector_encoded = + Base64SafeEncodeNoPad(plain_text_vector); + // Assuming the above has passed, the results should be the same as + // a result encoded from a string. + EXPECT_EQ(b64_vector_encoded, b64_string_encoded); } class Base64ErrorDecodeTest : public ::testing::TestWithParam {}; TEST_P(Base64ErrorDecodeTest, EncoderErrors) { - std::vector result = Base64Decode(GetParam()); - EXPECT_EQ(0u, result.size()); + const std::vector standard_result = Base64Decode(GetParam()); + EXPECT_TRUE(standard_result.empty()); + const std::vector safe_result = Base64SafeDecode(GetParam()); + EXPECT_TRUE(safe_result.empty()); } INSTANTIATE_TEST_CASE_P(ExecutesBase64Test, Base64EncodeDecodeTest, diff --git a/libwvdrmengine/level3/Android.bp b/libwvdrmengine/level3/Android.bp index d3292183..49a179d1 100644 --- a/libwvdrmengine/level3/Android.bp +++ b/libwvdrmengine/level3/Android.bp @@ -12,6 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "vendor_widevine_license" + // to get the below license kinds: + // legacy_by_exception_only (by exception only) + default_applicable_licenses: ["vendor_widevine_license"], +} + cc_library_static { name: "libwvlevel3", cflags: [ diff --git a/libwvdrmengine/mediacrypto/Android.bp b/libwvdrmengine/mediacrypto/Android.bp index 8f9b9e78..bd06a4a6 100644 --- a/libwvdrmengine/mediacrypto/Android.bp +++ b/libwvdrmengine/mediacrypto/Android.bp @@ -15,6 +15,18 @@ // ---------------------------------------------------------------------------- // Builds libwvdrmcryptoplugin // +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "vendor_widevine_license" + // to get the below license kinds: + // legacy_by_exception_only (by exception only) + default_applicable_licenses: ["vendor_widevine_license"], +} + cc_library_static { name: "libwvdrmcryptoplugin", diff --git a/libwvdrmengine/mediacrypto/test/Android.mk b/libwvdrmengine/mediacrypto/test/Android.mk index 51666840..91169e8a 100644 --- a/libwvdrmengine/mediacrypto/test/Android.mk +++ b/libwvdrmengine/mediacrypto/test/Android.mk @@ -45,6 +45,8 @@ LOCAL_C_INCLUDES += \ external/protobuf/src \ LOCAL_MODULE := libwvdrmmediacrypto_test +LOCAL_LICENSE_KINDS := legacy_by_exception_only +LOCAL_LICENSE_CONDITIONS := by_exception_only LOCAL_MODULE_TAGS := tests @@ -117,6 +119,8 @@ LOCAL_C_INCLUDES += \ external/protobuf/src \ LOCAL_MODULE := libwvdrmmediacrypto_hidl_test +LOCAL_LICENSE_KINDS := legacy_by_exception_only +LOCAL_LICENSE_CONDITIONS := by_exception_only LOCAL_MODULE_TAGS := tests diff --git a/libwvdrmengine/mediadrm/Android.bp b/libwvdrmengine/mediadrm/Android.bp index 95f440da..4ad257d1 100644 --- a/libwvdrmengine/mediadrm/Android.bp +++ b/libwvdrmengine/mediadrm/Android.bp @@ -15,6 +15,18 @@ // ---------------------------------------------------------------------------- // Builds libwvdrmdrmplugin // +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "vendor_widevine_license" + // to get the below license kinds: + // legacy_by_exception_only (by exception only) + default_applicable_licenses: ["vendor_widevine_license"], +} + cc_library_static { name: "libwvdrmdrmplugin", diff --git a/libwvdrmengine/mediadrm/test/Android.mk b/libwvdrmengine/mediadrm/test/Android.mk index 15cbbb78..b6792a33 100644 --- a/libwvdrmengine/mediadrm/test/Android.mk +++ b/libwvdrmengine/mediadrm/test/Android.mk @@ -48,6 +48,8 @@ LOCAL_C_INCLUDES += \ external/protobuf/src \ LOCAL_MODULE := libwvdrmdrmplugin_test +LOCAL_LICENSE_KINDS := legacy_by_exception_only +LOCAL_LICENSE_CONDITIONS := by_exception_only LOCAL_MODULE_TAGS := tests @@ -121,6 +123,8 @@ LOCAL_C_INCLUDES += \ external/protobuf/src \ LOCAL_MODULE := libwvdrmdrmplugin_hidl_test +LOCAL_LICENSE_KINDS := legacy_by_exception_only +LOCAL_LICENSE_CONDITIONS := by_exception_only LOCAL_MODULE_TAGS := tests @@ -182,6 +186,8 @@ LOCAL_C_INCLUDES += \ external/protobuf/src \ LOCAL_MODULE := hidl_metrics_adapter_unittest +LOCAL_LICENSE_KINDS := legacy_by_exception_only +LOCAL_LICENSE_CONDITIONS := by_exception_only LOCAL_MODULE_TAGS := tests @@ -196,4 +202,3 @@ LOCAL_MODULE_TARGET_ARCH := arm x86 mips endif include $(BUILD_EXECUTABLE) - diff --git a/libwvdrmengine/mediadrm/test/WVDrmPlugin_test.cpp b/libwvdrmengine/mediadrm/test/WVDrmPlugin_test.cpp index a4be0776..16779b5a 100644 --- a/libwvdrmengine/mediadrm/test/WVDrmPlugin_test.cpp +++ b/libwvdrmengine/mediadrm/test/WVDrmPlugin_test.cpp @@ -3224,10 +3224,10 @@ TEST_F(WVDrmPluginTest, CanSetDecryptHashProperties) { // ",," static const std::string frameNumber = ",1"; uint32_t hash = 0xbeef; // crc32 hash - std::vector hashVector( + const std::vector hashVector( reinterpret_cast(&hash), reinterpret_cast(&hash) + sizeof(uint32_t)); - std::string base64EncodedHash = Base64Encode(hashVector); + const std::string base64EncodedHash = Base64Encode(hashVector); std::string computedHash(sessionId.begin(), sessionId.end()); computedHash.append(frameNumber.c_str()); computedHash.append(base64EncodedHash.c_str()); diff --git a/libwvdrmengine/oemcrypto/odk/Android.bp b/libwvdrmengine/oemcrypto/odk/Android.bp index 41aa3e3a..01af3332 100644 --- a/libwvdrmengine/oemcrypto/odk/Android.bp +++ b/libwvdrmengine/oemcrypto/odk/Android.bp @@ -5,6 +5,18 @@ // ---------------------------------------------------------------- // Builds libwv_odk.a, The ODK Library (libwv_odk) is used by // the CDM and by oemcrypto implementations. +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "vendor_widevine_license" + // to get the below license kinds: + // legacy_by_exception_only (by exception only) + default_applicable_licenses: ["vendor_widevine_license"], +} + cc_library_static { name: "libwv_odk", include_dirs: [ diff --git a/libwvdrmengine/oemcrypto/odk/test/fuzzing/Android.bp b/libwvdrmengine/oemcrypto/odk/test/fuzzing/Android.bp index f0093f43..28465c39 100644 --- a/libwvdrmengine/oemcrypto/odk/test/fuzzing/Android.bp +++ b/libwvdrmengine/oemcrypto/odk/test/fuzzing/Android.bp @@ -2,6 +2,18 @@ // source code may only be used and distributed under the Widevine Master // License Agreement. +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "vendor_widevine_license" + // to get the below license kinds: + // legacy_by_exception_only (by exception only) + default_applicable_licenses: ["vendor_widevine_license"], +} + cc_defaults { name: "odk_fuzz_library_defaults", srcs: [ @@ -165,4 +177,4 @@ cc_fuzz { ], defaults: ["odk_fuzz_library_defaults"], proprietary: true, -} \ No newline at end of file +} diff --git a/libwvdrmengine/oemcrypto/odk/test/fuzzing/corpus_generator/Android.bp b/libwvdrmengine/oemcrypto/odk/test/fuzzing/corpus_generator/Android.bp index e9939711..bcbbfd3b 100644 --- a/libwvdrmengine/oemcrypto/odk/test/fuzzing/corpus_generator/Android.bp +++ b/libwvdrmengine/oemcrypto/odk/test/fuzzing/corpus_generator/Android.bp @@ -9,6 +9,18 @@ // ---------------------------------------------------------------- // Builds libwv_odk.so, The ODK shared Library (libwv_odk) is used // by the OEMCrypto unit tests to generate corpus for ODK fuzz scrips. +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "vendor_widevine_license" + // to get the below license kinds: + // legacy_by_exception_only (by exception only) + default_applicable_licenses: ["vendor_widevine_license"], +} + cc_library_shared { name: "libwv_odk_corpus_generator", include_dirs: [ diff --git a/libwvdrmengine/oemcrypto/test/Android.mk b/libwvdrmengine/oemcrypto/test/Android.mk index 3b8ed93e..5d86cda5 100644 --- a/libwvdrmengine/oemcrypto/test/Android.mk +++ b/libwvdrmengine/oemcrypto/test/Android.mk @@ -6,6 +6,8 @@ LOCAL_C_INCLUDES := \ vendor/widevine/libwvdrmengine/cdm/util/include \ LOCAL_MODULE:=oemcrypto_test +LOCAL_LICENSE_KINDS:=legacy_by_exception_only +LOCAL_LICENSE_CONDITIONS:=by_exception_only LOCAL_MODULE_TAGS := tests LOCAL_MODULE_OWNER := widevine diff --git a/libwvdrmengine/test/unit/Android.mk b/libwvdrmengine/test/unit/Android.mk index 2086bf67..a9cd618e 100644 --- a/libwvdrmengine/test/unit/Android.mk +++ b/libwvdrmengine/test/unit/Android.mk @@ -33,6 +33,8 @@ LOCAL_HEADER_LIBRARIES := \ libstagefright_foundation_headers \ LOCAL_MODULE := libwvdrmengine_test +LOCAL_LICENSE_KINDS := legacy_by_exception_only +LOCAL_LICENSE_CONDITIONS := by_exception_only LOCAL_MODULE_TAGS := tests @@ -90,6 +92,8 @@ LOCAL_HEADER_LIBRARIES := \ libstagefright_foundation_headers \ LOCAL_MODULE := libwvdrmengine_hidl_test +LOCAL_LICENSE_KINDS := legacy_by_exception_only +LOCAL_LICENSE_CONDITIONS := by_exception_only LOCAL_MODULE_TAGS := tests diff --git a/libwvdrmengine/tools/metrics_dump/Android.bp b/libwvdrmengine/tools/metrics_dump/Android.bp index ae7805ee..9dbdb221 100644 --- a/libwvdrmengine/tools/metrics_dump/Android.bp +++ b/libwvdrmengine/tools/metrics_dump/Android.bp @@ -12,6 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "vendor_widevine_license" + // to get the below license kinds: + // legacy_by_exception_only (by exception only) + default_applicable_licenses: ["vendor_widevine_license"], +} + cc_binary_host { name: "metrics_dump", proprietary: true, diff --git a/libwvdrmengine/vts/vendor_module/Android.bp b/libwvdrmengine/vts/vendor_module/Android.bp index 498a4135..a6d26004 100644 --- a/libwvdrmengine/vts/vendor_module/Android.bp +++ b/libwvdrmengine/vts/vendor_module/Android.bp @@ -16,6 +16,19 @@ // Builds libvtswidevine.so // +// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE +// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE +// DEPENDING ON IT IN YOUR PROJECT. *** +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "vendor_widevine_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + // legacy_by_exception_only (by exception only) + default_applicable_licenses: ["vendor_widevine_license"], +} + cc_library_shared { name: "libvtswidevine",