Commit Graph

6366 Commits

Author SHA1 Message Date
Cong Lin
0ad587ca20 Substring out of range test needs non-zero length value
Merge from Widevine repo of http://go/wvgerrit/154651

Some substring out of range tests uses non-zero offset but
with zero length. This zero length later will be ignored by
v15 oemcrypto, so the tests actually didn't test
anything. These tests are failing on v15 oemcrypto because
the test expect an out of range error but it actually
succeeded since nothing was tested.

Assign the offset to be out of range and then also assign
length to be not zero.

Test: run_fake_l1_tests; run_level3_static_tests;
Bug: 229299394
Test: tested with http://go/ag/20420224

Change-Id: Ic50b6323312e0ecb253dbeb925d9291db6eec075
2022-11-22 03:01:26 +00:00
Fred Gylys-Colwell
6161f812dc Fix cherry pick of unpacking enum
Merge from Widevine repo of http://go/wvgerrit/158251

The cherry pick of http://go/wvgerrit/157958 was not complete.

Bug: 251827716
Test: tested with http://go/ag/20420224

Change-Id: Icd4d2f23003ab621bf690ca3dcf1de2f0c5afc45
2022-11-22 03:01:19 +00:00
Ian Benz
7671db226a Prevent oemcrypto_opk_deactivate_usage_entry_fuzz abort
Merge from Widevine repo of http://go/wvgerrit/158203

Prevent abort, interpreted as a crash by libFuzzer, when
OEMCrypto_CreateUsageTableHeader fails session state checks due to being
called after OEMCrypto_GenerateNonce.

Bug: 251215411
Test: tested with http://go/ag/20420224

Change-Id: I71ad1186ff2cb9ced81f9950d2fa235878aeb54d
2022-11-22 03:01:03 +00:00
Ian Benz
d04af0042e Prevent oemcrypto_opk_report_usage_fuzz abort
Merge from Widevine repo of http://go/wvgerrit/158204

Prevent abort, interpreted as a crash by libFuzzer, when
OEMCrypto_CreateUsageTableHeader fails session state checks due to being
called after OEMCrypto_GenerateNonce.

Bug: 250682470
Test: tested with http://go/ag/20420224

Change-Id: Ia15b8c26fb391a190c32115e398a78ff9f8a7e16
2022-11-22 03:00:51 +00:00
Fred Gylys-Colwell
e0294995d8 Lock OEMCrypto API for v17.1
Merge from Widevine repo of http://go/wvgerrit/158077

I ran the script ./oemcrypto/lock-api-for-release

Bug: 235858362
Test: tested with http://go/ag/20420224

Change-Id: I59b808898cdec60bffe36059f75ac413b0f55356
2022-11-22 03:00:41 +00:00
Fred Gylys-Colwell
b10a4459f8 Verify OEMCrypto API has not changed
Merge from Widevine repo of http://go/wvgerrit/157923

This adds a C file to be built by Luci to verify that nobody
has made a change to OEMCryptoCENC.h that changes the
signature of any _oecc function. See the new comment in the
header for an explanation why we don't want to chage the
function signature of an oecc function.

We also update the OEMCrypto release script to verify that
all of the functions have been locked. There is a script to
update the lock file that should be run before each release.

Bug: 235858362
Test: tested with http://go/ag/20420224

Change-Id: Id890054e82cf8cc4c75e83c8347a776bda2d8a3b
2022-11-22 03:00:29 +00:00
Fred Gylys-Colwell
f862f2a378 Prevent unpacking invalid enum values from ODK_Message
Merge from Widevine repo of http://go/wvgerrit/158102
Test: tested with http://go/ag/20420224
Bug: 247376339

Change-Id: I5b3ef3cfdee6870f6d58e5551fd6a74507ae1e81
2022-11-18 17:08:14 +00:00
Vicky Min
78e4c4ba8a Fix out of bounds buffer error in CreateCoreLicenseResponse()
Merge from Widevine repo of http://go/wvgerrit/157777
(partially merged in http://go/ag/20031768)

In CreateCoreLicenseResponse(), there seems to be an out of bounds
potential error due to a missing check that the index used for
license_response.parsed_license->key_array is valid. Adding a check
for this here.

Bug: 217677571
Test: tested with http://go/ag/20420224
PiperOrigin-RevId: 452114761
Change-Id: Id35ec48bebb564596b8e67c737bc13be9377891b
2022-11-15 22:46:20 +00:00
Cong Lin
0f32f41bd1 [RESTRICT AUTOMERGE] Sync OEMCrypto, ODK files and unit tests
run android/copy_files from cdm repo to sync files in Android
tm-widevine-release.

Changes include:
1. Update ODK to 17.1
2. update in license_protocol.proto
3. updates in oemcrypto unit tests
4. A few cdm and util test updates
5. Prov4 unit test fixes

Originating CLs:
https://widevine-internal-review.googlesource.com/c/cdm/+/155289/
https://widevine-internal-review.googlesource.com/c/cdm/+/155429/
https://widevine-internal-review.googlesource.com/c/cdm/+/155430/
https://widevine-internal-review.googlesource.com/c/cdm/+/154415/
https://widevine-internal-review.googlesource.com/c/cdm/+/156457/
https://widevine-internal-review.googlesource.com/c/cdm/+/156878/
https://widevine-internal-review.googlesource.com/c/cdm/+/156879/
https://widevine-internal-review.googlesource.com/c/cdm/+/156425/
https://widevine-internal-review.googlesource.com/c/cdm/+/156486/
https://widevine-internal-review.googlesource.com/c/cdm/+/156539/
https://widevine-internal-review.googlesource.com/c/cdm/+/156542/

Test: ran oemcrypto unit tests and ODK tests
Test: ran gts media test cases
Bug: 239201888

Change-Id: Iad9aff72aec5ba42296582837f34dd704bc11810
2022-09-22 17:13:02 -07:00
Alex Dale
fa8c0a9a62 Create custom gtest matcher for similar URLs.
[ Merge of http://go/wvgerrit/156997 ]

Several of the Android integration tests perform direct URL comparisons
between fixed URLs and the server URL returned by the CDM.  With
provisioning 4.0, the CDM will append additional query parameters to
the server URL.  This updated URL still contains all of the original
expected information, but with additional parameters.  So long as the
URL contains the required fields, any additional parameter should be
considered valid.

The gtest framework used by the integration tests allow for the
creation of custom "matchers", rules that can be used to validate data
and create informative failure logs.  The CL creates a new matcher for
checking that a tested URL is a superset of content of the expected
URL.

Bug: 244319313
Test: request_license_test on prov 4 device
Change-Id: Ie721058fa628b3a4a74dc56f4172a3dfcb1f1ef3
2022-09-07 20:20:57 -07:00
TreeHugger Robot
4a4b4405e9 Merge "Update clear KCB test name" into tm-widevine-release 2022-08-03 16:47:26 +00:00
Alex Dale
6109ec6d66 Added mutex protection for session_property_set_.
[ Merge of http://go/wvgerrit/154575 ]
[ Cherry-pick of http://go/wvgerrit/19216679 ]

There is a rare race condition experienced by some Android devices
where the a new client property set is being added while another is
being removed.  The C++ stl library does not provided thread
protection by default.

This CL adds a new mutex for the client property set map which prevents
multiple threads accessing the property sets concurrently.

Bug: 235238226
Test: GtsMediaTestCases on redfin
Change-Id: I32cf11bfb1332295ba1245071102ff0adc35259d
(cherry picked from commit aaa97a5d60)
2022-08-02 16:35:13 +00:00
Cong Lin
0ce898be87 Update clear KCB test name
This is to bring cdm tm-widevine-release in sync with Android
tm-widevine-release.

Originating CL: https://widevine-internal-review.googlesource.com/c/cdm/+/154509
The only difference is in the test name.

Test: run diff against CDM tm-widevine-release
Bug: 239059097
Change-Id: I1279bf780c8faef393b32d73a163756a016d80fc
2022-07-26 21:19:32 +00:00
Android Build Coastguard Worker
85b470e1ca Snap for 8742898 from 8c4c238324 to tm-release am: 50ecea3526
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18983484

Change-Id: I00f832231698a5949d7cca2b46b9343e0902a488
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 22:24:38 +00:00
Android Build Coastguard Worker
50ecea3526 Snap for 8742898 from 8c4c238324 to tm-release
Change-Id: Ieb00135247a13e8249efc85b18b1a9fd61023262
2022-06-18 21:57:37 +00:00
Cong Lin
8c4c238324 Add unit test for clear KCB in LS SDK 16.4 response
This is a merge from:
https://widevine-internal-review.googlesource.com/c/cdm/+/152897
and http://go/wvgerrit/153709

Adding a new OEMCrypto unit test will allow partners to correct a
problem earlier in their integration.

Verifies current oemcrypto implementation handles clear KCB in a
mocked 16.4 license response.

Unit test release date updated to 2022-06-17.

Test: run_x86_64_tests; opk_ta
Bug: 235870170
Bug: 234645065
Change-Id: I59fef2c25f5c007624447d4f46147d96adeddad9
2022-06-17 15:02:09 -07:00
Android Build Coastguard Worker
32e1e8e7c7 Snap for 8656240 from cd593979e9 to tm-release
Change-Id: I5e8bdd3004549143addbc100b2432a4aed6bf0c2
2022-05-28 01:58:37 +00:00
Rahul Frias
cd593979e9 Allow provisioning model to be queried
[ Merge of http://go/wvgerrit/152674 ]

This allows an app to query the provisioning model. Possible
values are { "DrmCertificate", "Keybox", "OEMCertificate",
"BootCertificateChain" }

An app can use these to disntinguish between provisioning models.
Provisioning 4.0 (boot certificate chain) requires a double provisioning
step.

Bug: 234057551
Test: WV unit/integration tests, libwvdrmdrmplugin_hal_test
Change-Id: I1611488ec632a0e5a9e1d106b7475e8f5a2a5a13
2022-05-26 16:22:16 -07:00
Android Build Coastguard Worker
90227da99c Snap for 8627648 from 9935fae50d to tm-release
Change-Id: If460e31096902e522161af2b0979b792ec40adb3
2022-05-22 21:20:30 +00:00
Cong Lin
9935fae50d Loosen KCB encryption checks in L3
This is a merge from:
https://widevine-internal-review.googlesource.com/c/cdm/+/152372

The L3 source change which produced these libraries is:
https://widevine-internal-review.googlesource.com/c/cdm/+/152371/

Original commit message:
To address the bug with certain 16.4.x SDK versions returning a
clear key control block (KCB) for clients newer than 16.5, the
exact version check to determine whether key control blocks are
clear or not has been loosened.

Original behavior:
- ODK version >= 16.5.x --> Assume clear
- ODK version <= 16.4.x --> Assume encrypted
New behavior:
- No KCB IV --> Assume clear
- Otherwise --> Assume encrypted

This CL also includes a change to oemcrypto/include/OEMCryptoCENC.h
The changes to OEMCryptoCENC.h in the CL are comments or variable name
change. So it should be safe.
This change was merged to wv tm-dev here:
https://widevine-internal-review.googlesource.com/c/cdm/+/148411
So, adding it to Android tm-dev.

Test: run_level3_static_tests, CdmDecryptTest/CdmTestWithDecryptParam.* against LS SDK 16.4.2 & 17.0
Bug: 232557453
Change-Id: I2bbb5ab3ea33a16bd6c198077e5aefe960737ea0
2022-05-22 06:35:22 +00:00
Android Build Coastguard Worker
dd8bd6c169 Snap for 8598607 from 186e489562 to tm-release
Change-Id: I6575dd1b8cb4d1a24442d297a684415ac8d74467
2022-05-16 23:21:28 +00:00
Robert Shih
186e489562 Merge "dumpsys widevine: print hex IDs to avoid garbled text" into tm-dev 2022-05-16 06:17:33 +00:00
Android Build Coastguard Worker
6569359fb8 Snap for 8590907 from 9d169a00bb to tm-release
Change-Id: I560ab9de4ada467154cec87425aa719ae6818c91
2022-05-14 01:20:22 +00:00
Alex Dale
9d169a00bb Move system ID extraction outside of CryptoSession.
[ Merge of http://go/wvgerrit/151391 ]

This CL moves the logic for extracting the system ID from keybox or
OEM certificate (from OEMCrypto or device files) to a dedicated
SystemIdExtractor.

Before Provisioning 4.0, the system ID could only be found from data
returned by OEMCrypto.  However, with provisioning 4.0, the system ID
can now be found in the OEM certificate that is stored on the device
files.

Bug: 232020319
Test: system_id_extractor_unittest
Test: Forest L37800000954493485
Change-Id: Ie1b7987906e2e4fef015cd659a947b6dbb7594b1
2022-05-12 19:22:03 -07:00
Android Build Coastguard Worker
6e98c38fbb Snap for 8581162 from cf3771e54a to tm-release
Change-Id: I4829192ab84646c1c207e9886c3f1218533283fb
2022-05-12 23:20:10 +00:00
Alex Dale
8ac7ca3f46 Merge "Added metrics for production readiness." into tm-dev 2022-05-12 22:10:24 +00:00
Android Build Coastguard Worker
60ee9521df Snap for 8572535 from f8146ee716 to tm-release
Change-Id: Ifa4d22190fadf94fafdd8705c7e31fbaa4d174af
2022-05-11 23:20:21 +00:00
Edwin Wong
cf3771e54a Add hal_metrics_adapter_unittest for AIDL service.
[ Merged from http://go/wvgerrit/151750 ]

Test: m hal_metrics_adapter_unittest -j128
Test: m hal_metrics_adapter_unittest  WV_UNITTESTS_BUILD_TARGET=hidl -j128
Test: adb push $(OUT)/data/nativetest/hal_metrics_adapter_unittest  /data/nativetest/.
Test: adb shell  LD_LIBRARY_PATH=/vendor/lib64 /data/nativetest/hal_metrics_adapter_unittest

Bug: 217247987
Change-Id: I0c890d2fab754bf993632659293a0272c863b11f
2022-05-11 22:01:35 +00:00
Edwin
5202862e9a Add libwvdrmdrmplugin_hal_test for AIDL service
[ Merged from http://go/wvgerrit/150769 ]

- remove OpenSessions_1_1, only applies to hidl
- move plugin and mCdm creation in SetUp() test fixture
- reset plugin and mCdm smart pointers in TearDown
- reduce code duplication
- remove MockDrmPluginListener, send*Event has gone private

Test: m libwvdrmdrmplugin_hal_test -j128
Test: m libwvdrmdrmplugin_hal_test WV_UNITTESTS_BUILD_TARGET=hidl -j128
Test: adb push $(OUT)/data/nativetest/libwvdrmdrmplugin_hal_test /data/nativetest/.
Test: adb shell LD_LIBRARY_PATH=/vendor/lib64 /data/nativetest/libwvdrmdrmplugin_hal_test

Bug: 217247987
Change-Id: I8bc0a390a88facbc890cf26872fd089afe87850a
2022-05-11 05:36:40 +00:00
Alex Dale
88a7ff7685 Added metrics for production readiness.
[ Merge of http://go/wvgerrit/151749 ]

Extended CryptoSession for recording the result of
OEMCrypto_ProductionReady().

Only OEMCrypto_SUCCESS is considered "production ready".  With the
exception of OEMCrypto_ERROR_NOT_IMPLEMENTED, any other result is
vendor-specific and indicates not being production ready.

Bug: 231655151
Test: metrics_collections_unittest
Change-Id: Ia0e5603d7ee1290238cce63d0194ae1aced424c1
2022-05-10 18:04:11 -07:00
Robert Shih
ca2440f556 dumpsys widevine: print hex IDs to avoid garbled text
Includes minor format change for easier ingestion by other tools.

Bug: 231677822
Test: adb shell dumpsys android.hardware.drm.IDrmFactory/widevine
Change-Id: Ibd13c84bd8f93ea0fc6cbd38b56ef39541ecc867
2022-05-11 00:50:11 +00:00
Edwin Wong
f8146ee716 Merge "Add libwvdrmmediacrypto_hal_test for AIDL service." into tm-dev 2022-05-10 23:12:05 +00:00
Alex Dale
cd5afa88a6 Added CDM support for production readiness reporting.
[ Merge of http://go/wvgerrit/151518 ]

Extended the CDM layer to report OEMCrypto's production readiness
via string property query.

If OEMCrypto implementents OEMCrypto_ProductionReady(), then the
reported readiness by the CDM will report "True" or "False".

If OEMCrypto does not implement OEMCrypto_ProductionReady() then no
level of readiness is assumed, and the CDM will report "Unknown".

Bug: 231655151
Test: run_prov30_tests and request_license_test
Change-Id: I6afe481ef00ac129d02b004eca89a65810bfbff8
2022-05-10 13:35:43 -07:00
Android Build Coastguard Worker
65e2b8f644 Snap for 8561975 from c4a2a08ee6 to tm-release
Change-Id: Ib06cd02934355fbc4a2ea878f983662ed8c513ea
2022-05-09 23:20:23 +00:00
TreeHugger Robot
c4a2a08ee6 Merge "Update TestMaxDRMKeys to use 2048 bit keys only" into tm-dev 2022-05-09 09:34:58 +00:00
TreeHugger Robot
6e4cf1f1a9 Merge "Restrict CAS unit tests to devices that support CAS" into tm-dev 2022-05-09 09:34:55 +00:00
Android Build Coastguard Worker
f7607aa016 Snap for 8554681 from f4e2e9833d to tm-release
Change-Id: Id382b5ca192a85be4d6819f2bff9573520332167
2022-05-07 01:20:03 +00:00
Rahul Frias
f4e2e9833d Merge "Check L3 for secure stops" into tm-dev 2022-05-06 22:08:52 +00:00
Rahul Frias
e26370f0b6 Merge "Update version change canary test" into tm-dev 2022-05-06 22:06:05 +00:00
Edwin Wong
19407fdc10 Add libwvdrmmediacrypto_hal_test for AIDL service.
[ Merge from http://go/wvgerrit/151349 ]

- move plugin and mCdm creation in SetUp() test fixture
- replace StrictMock<MockCD<> with NiceMock; otherwise,
  "uninteresting mock for isOpenSession" will return fail by default
- replace .WillOnce() for isOpenSession() with .WillRepeatedly

Test: m libwvdrmmediacrypto_hal_test -j128
Test: m libwvdrmmediacrypto_hal_test  WV_UNITTESTS_BUILD_TARGET=hidl -j128
Test: adb push $(OUT)/data/nativetest/libwvdrmmediacrypto_hal_test  /data/nativetest/.
Test: adb shell  LD_LIBRARY_PATH=/vendor/lib64
/data/nativetest/libwvdrmmediacrypto_hal_test

Bug: 217247987
Change-Id: I8d7189473d52738645c73c6665f4f3f6a13042f0
2022-05-06 18:21:57 +00:00
Rahul Frias
13daf6d3ed Check L3 for secure stops
[ Merge of http://go/wvgerrit/151512 ]

Parameterizing GtsMediaDrm tests exposed a few issues. If secure stops
were stored at L3 security level, retrieval would fail. This CL
checks L3 if the secure stop was not found at the default security
level.

Bug: 221249079
Test: GtsMediaTestCases
Change-Id: Ie88197f8e29457981d782199a76d38774f6faa67
2022-05-06 01:39:24 +00:00
Rahul Frias
81e5fc3dc4 Update version change canary test
[ Merge of http://go/wvgerrit/151571 ]

The android OS version has been updated to 13. Updating WV tests as well.
CDM version has been updated previously, so no additional changes are needed.

Bug: 231646284
Test: WV unit/integration tests
Change-Id: Ifaf2fe1f04627654725b1b221d8c3dc30029ac6c
2022-05-05 18:29:25 -07:00
Android Build Coastguard Worker
31231866b7 Snap for 8547970 from f980049ef0 to tm-release
Change-Id: Icaae29f48101c7555707d3db7804afb9d9a535f1
2022-05-05 23:20:20 +00:00
Alex Dale
f980049ef0 Merge "Resize OEMCrypto buffer-based results on success." into tm-dev 2022-05-05 20:38:05 +00:00
Edwin Wong
f607802265 Merge "Only use libbinder_ndk for aidl service." into tm-dev 2022-05-05 17:53:05 +00:00
Edwin Wong
af5f57a46c Only use libbinder_ndk for aidl service.
[ Merged from http://go/wvgerrit/151169 ]

Test: Netflix and Google TV streaming and downloaded playback
Test: unit tests
Test: atest VtsAidlHalDrmTargetTest
Test: adb shell readelf -d /vendor/bin/hw/android.hardware.drm-service.widevine
Test: adb shell readelf -d /vendor/lib64/libwvaidl.so

Bug: 230791937
Change-Id: Ia60d9fc838bf228b40d99b076a837ae789fa2d03
2022-05-05 15:12:55 +00:00
Cong Lin
e06c526d3b Merge "Include SPOID in provisioning 4 request" into tm-dev 2022-05-05 14:56:01 +00:00
Alex Dale
1069ae39cc Resize OEMCrypto buffer-based results on success.
[ Merge of http://go/wvgerrit/151191 ]

Within the CDM and OEMCrypto tests, there were a few OEMCrypto function
calls where the final size of the output buffers were not being
resized.  For several of these functions, an initial call is made with
zero-length output buffers, expecting OEMCrypto to return
ERROR_SHORT_BUFFER; followed by a call with buffers at least as large
as specified by OEMCrypto.  However, for some operations, OEMCrypto
makes an estimate on the final size on the first call, specifying the
exact size only after performing the operations.

This is the case for the wrapped key returned by
OEMCrypto_LoadProvisioning().  The provisioning response contains a
padded + encrypted DRM key.  OEMCrypto does not know the actual size
of the key until decrypted, and the actual DRM key might be smaller.

There was a OEMCrypto test for OEMCrypto_BuildInformation() which
was enforcing the wrong behaviour.  This has been updated.

Bug: 230661565
Test: oemcrypto_test
Change-Id: Iad297d56ffbb085894641fdf8698ce5fd18edbf2
2022-05-04 21:32:08 -07:00
Android Build Coastguard Worker
5652ff5fe7 Snap for 8540474 from 1563fb2a27 to tm-release
Change-Id: Iddfed089fb846977d58d7bb2dabc9937e83015db
2022-05-04 23:23:06 +00:00
Vicky Min
1563fb2a27 Fix TestLoadLicenseForOutOfRangeSubStringOffSetAndLengths()
In TestLoadLicenseForOutOfRangeSubStringOffSetAndLengths(),
LoadResponse() should be called after EncryptAndSignResponse() so this
is moved in this CL.

Bug: 231368221
Test: OEMCryptoMemoryLoadLicense tests
Change-Id: I7a0224afb21c3ab1d896ce3cfb64e1ad544a581a
2022-05-03 23:36:05 +00:00