Commit Graph

422 Commits

Author SHA1 Message Date
John "Juce" Bruce
5606e7dae3 Upgrade MOCK_METHOD to googletest 1.10
(This is a merge of http://go/wvgerrit/139989.)

Googletest added a new, more powerful MOCK_METHOD() macro in 1.10. This
patch updates all our usage of the old MOCK_METHOD family to the new
macro. Full details can be found at
https://github.com/google/googletest/blob/release-1.10.0/googlemock/docs/cook_book.md#creating-mock-classes
but in brief, the new MOCK_METHOD() replaces the entire old MOCK_METHOD
family and has the following advantages:

1) No need to count parameters or update the macro name when changing
   parameters.
2) No need for a different macro for const methods.
3) The ability to specify override, noexcept, and other function
   qualifiers.
4) The macro order is now the same as C++ method definition order:
   Return Type -> Name -> Arguments -> Qualifiers

In addition to upgrading all our usage sites to the new macro, the
addition of the override qualifier to our MOCK_METHODs helped uncover
several cases where we were using MOCK_METHOD to override methods that
didn't exist. This is a great example of why the override qualifier is
so useful. These places have been updated, by removing the invalid and
unused mock method.

Bug: 207693687
Test: build_and_run_all_unit_tests
Change-Id: Iaad4a22c7f72bb48b1356fe01a41eb0a2f555244
2022-01-21 01:49:28 +00:00
Rahul Frias
693874b9a1 Update Version number am: 0aa9b47b03 am: d44e6b2ff3
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/16221418

Change-Id: I5af4bd2baf8af8a0702f8a13c6750f1d87120cf3
2021-11-12 05:03:29 +00:00
Rahul Frias
0aa9b47b03 Update Version number
[ Merge of http://go/wvgerrit/138289 and http://go/ag/16210935 ]

Update the android version number test to accept "12" or "12L"

Bug: 205491167
Test: wv unit/integration tests
Change-Id: If11e7c6f3a89263ab78d274aa8d776991d3942e9
2021-11-09 16:41:40 -08:00
Fred Gylys-Colwell
a3166eb2ba Updates to OTA Keybox Reprovisioning
Adjust OTA code to account for some design changes and
add integration tests.

Merge from Widevine repo of http://go/wvgerrit/133775
Change use_test_key to uint32_t type

Merge from Widevine repo of http://go/wvgerrit/133774
Cleanup CDM OKP info before tests.

Merge from Widevine repo of http://go/wvgerrit/133773
Change context for derivation in OTA keybox solution

Merge from Widevine repo of http://go/wvgerrit/133772
Updated OTA keybox key derivation.

Merge from Widevine repo of http://go/wvgerrit/133771
Use double provisioning step in integration tests

Merge from Widevine repo of http://go/wvgerrit/133770
Erase keybox on initialization for OEMCrypto testbed

Merge from Widevine repo of http://go/wvgerrit/133769
Add session id to OEMCrypto OTA functions

Merge from Widevine repo of http://go/wvgerrit/133768
Integration test for OTA Keybox reprovisioning

Merge from Widevine repo of http://go/wvgerrit/133767
Add test x509 cert for testing

Merge from Widevine repo of http://go/wvgerrit/133766
OTA Keybox basic functionality in testbed

Merge from Widevine repo of http://go/wvgerrit/133765
Update OTA test script to use newer build scripts

Merge from Widevine repo of http://go/wvgerrit/133764
Adjust comment stype for doxygen

Test: Test: unit/integration/GtsMediaTestCases

Bug: 190505461
Bug: 190505461
Bug: 190505461
bug: 187646550
Bug: 187646550
Bug: 187646550
Bug: 187646550
Bug: 190505461
Bug: 187646550
Bug: 188228998
Bug: 190505461
Bug: 187646550
Merged-In: I41ff819a1fd8aca2e20adb25127fa0d9c4879b01
Change-Id: I41ff819a1fd8aca2e20adb25127fa0d9c4879b01
2021-10-20 17:50:18 -07:00
Rahul Frias
39558526f6 Wrapped OKP info into several classes.
[ Merge of http://go/wvgerrit/133744 ]

This changes adds several small classes which contain and manage
system and engine information related to OTA keybox provisioning.
These classes closely map to the OKP device file messages.

Bug: 189232882
Test: Linux unit tests
Change-Id: Ia9334c38f9d7ea89b30d9ad05f0595570bb38658

Storing and loading OKP info.

[ Merge of http://go/wvgerrit/133763 and http://go/ag/15645333 ]

This change extends the DeviceFiles module to be able to store and
load OKP info.  Mild data validation is performed when storing and
loading the information.

Bug: 189232882
Test: Android unit tests
Change-Id: I077de3234157252f2255a4389bf82a8d5344a355

System OKP fallback policy.

[ Merge of http://go/wvgerrit/133783 and http://go/ag/15645334 ]

SystemFallbackPolicy provides a thread-safe interface for accessing
and modifying OKP info.

Bug: 189232882
Test: Android unit tests
Change-Id: I4e43e3bc047ed5fb6cb517b53e4094e812b70e1e

Engine OKP provisioner.

[ Merge of http://go/wvgerrit/133803 and http://go/ag/15645335 ]

The OtaKeyboxProvisioner provides a CdmEngine-specific context for
performing OTA keybox provisioning.  Utilizes the system-wide
SystemFallbackPolicy to relay provisioning status between engines.
The provisioner will handle message wrapping and unwrapping of the
raw OTA keybox request / response into the SignedProvisioningMessage
which is sent to/received from the provisioning server.

[ Partial merge of http://go/wvgerrit/125844 ]

Note: Includes partial CryptoSession changes from various CLs.
CryptoSession functionality has been stripped to reduce impact of
this CL.

Bug: 189232882
Test: Android unit tests
Change-Id: I282bf7d1887daefb2250af1bd595c4dc3dfcfb29

Integrated OKP into CDM Engine

[ Merge of http://go/wvgerrit/133804 and http://go/ag/15646376 ]

Extended the functionality of the CdmEngine to check if the device
requires OKP and to initialize OKP resources if required.  The
functionality of OpenSession() and GetProvisioningRequest() have been
the most affected.  If OKP is required, these methods will signal to
the app that provisioning is required and will return an OKP request.

Once a device is provisioned, the OKP data is cleared away and the
CdmEngine will resume normal operation.  Engines created after a
device is provisioned will immediately enter normal operations.
The exception is for CdmEngines which failed to perform OKP for some
reason and are still running.  Those apps will need to restart before
gaining access to L1 operations.

Bug: 187646550
Test: Android integration tests
Merged-In: Ia572a66a7b73479355758aa3d0c682691eaca0fc
Change-Id: Ia572a66a7b73479355758aa3d0c682691eaca0fc
2021-10-20 17:50:08 -07:00
Fred Gylys-Colwell
44ba42f5cc Use local provisioning server
Merge from Widevine repo of http://go/wvgerrit/133703 and
http://ag/14707867

In order to use a local provisioning server, we need to use a
different test keybox system id that is in the dev device database
instead of the production database. We also need to use a local
license server that uses the dev license server.

Bug: 187646550
Test: GtsMediaTestCases

Change-Id: Ice89143dd26de22757375a770c6bac716fcbc057

Add Keybox OTA Provisioning functions to OEMCrypto header

Merge from Widevine repo of http://go/wvgerrit/133704 and
http://go/ag/14707868

Bug: 188228998
Change-Id: Iff54bc2870e87bf7239e179e1d02fbcc8df6198f

Stub build changes to support OTA Keybox

Merge from Widevine repo of http://go/wvgerrit/133725 and
http://go/ag/14781459

This CL adds a new unit test file for testing OTA keybox
reprovisioning functionality. This new test is built when running the
dynamic adapter in the linux build, and in the Android build.

Bug: 187646550
Change-Id: I625513840188f95e74831ef2ea399e827e837439

Add OTA Keybox functions to dynamic adapter

Merge from Widevine repo of http://go/wvgerrit/125843
and http://go/ag/14781460

Bug: 187646550
Change-Id: Ief78ed10599c091690e0d7dc488ea71674c763b5

Refactor dynamic adapter keybox verification

Merge from Widevine repo of http://go/wvgerrit/133727
http://go/ag/14812524

The keybox validation needs to be done separately from initializing
the library so that we can support Keybox OTA Reprovisioning.

If L1 loads, but the keybox is missing, the initialization should
succeed. When the keybox is validated, the adapter should try to look
for a keybox on the filesystem. if none is found, it should either
return NEEDS PROVISIONING or an error.

Bug: 187646550
Change-Id: I34a8c365a5a5ca35c379bea827c85c749964744c

Update crypto session to use new OTA keybox functionality

Merge from Widevine repo of http://go/wvgerrit/133728 and
http://go/ag/14812525

This CL stubs out two new CryptoSession functions that call the new
OEMCrypto functions for OTA Keybox Provisioning. It builds!  Yay!

It also adds a boolean needs_keybox_provisioning that is set to true
when OEMCrypto reports that it needs a keybox. This should only happen
if there is no keybox installed and oemcrypto supports provisioning.

Bug: 187646550
Merged-In: Ide9533943125aa13b8899b652b118a0b410c882c
Change-Id: Ide9533943125aa13b8899b652b118a0b410c882c
2021-10-20 17:49:43 -07:00
Fred Gylys-Colwell
9cab445e2c Add initial reboot test infrastructure
Merge from Widevine repo of http://go/wvgerrit/130469
Parse and decode persistent data for reboot tests

Merge from Widevine repo of http://go/wvgerrit/130468
Save and restore persistent test data

Merge from Widevine repo of http://go/wvgerrit/130467
Saving and restore the test host's file system

Merge from Widevine repo of http://go/wvgerrit/130466
Add reboot test class

Test: android/run_reboot_test.sh and jenkins/run_fake_l1_tests
Bug: 194342751
Bug: 194342800
Change-Id: Id2f3d9850cb75cb286f7863738aa8fd38a1a5301
2021-10-14 17:50:14 +00:00
Fred Gylys-Colwell
7397f77343 Updates to OTA Keybox Reprovisioning
[ Cherry pick of http://ag/15847758 ]

Adjust OTA code to account for some design changes and
add integration tests.

Merge from Widevine repo of http://go/wvgerrit/133775
Change use_test_key to uint32_t type

Merge from Widevine repo of http://go/wvgerrit/133774
Cleanup CDM OKP info before tests.

Merge from Widevine repo of http://go/wvgerrit/133773
Change context for derivation in OTA keybox solution

Merge from Widevine repo of http://go/wvgerrit/133772
Updated OTA keybox key derivation.

Merge from Widevine repo of http://go/wvgerrit/133771
Use double provisioning step in integration tests

Merge from Widevine repo of http://go/wvgerrit/133770
Erase keybox on initialization for OEMCrypto testbed

Merge from Widevine repo of http://go/wvgerrit/133769
Add session id to OEMCrypto OTA functions

Merge from Widevine repo of http://go/wvgerrit/133768
Integration test for OTA Keybox reprovisioning

Merge from Widevine repo of http://go/wvgerrit/133767
Add test x509 cert for testing

Merge from Widevine repo of http://go/wvgerrit/133766
OTA Keybox basic functionality in testbed

Merge from Widevine repo of http://go/wvgerrit/133765
Update OTA test script to use newer build scripts

Merge from Widevine repo of http://go/wvgerrit/133764
Adjust comment stype for doxygen

Test: MediaDrmTest and Android unittests

Bug: 190505461
Bug: 190505461
Bug: 190505461
bug: 187646550
Bug: 187646550
Bug: 187646550
Bug: 187646550
Bug: 190505461
Bug: 187646550
Bug: 188228998
Bug: 190505461
Bug: 187646550
Change-Id: I41ff819a1fd8aca2e20adb25127fa0d9c4879b01
2021-10-01 15:00:33 -07:00
Rahul Frias
6afcbab5cf Wrapped OKP info into several classes.
[ Cherry pick of http://ag/15836995 ]
[ Merge of http://go/wvgerrit/133744 ]

This changes adds several small classes which contain and manage
system and engine information related to OTA keybox provisioning.
These classes closely map to the OKP device file messages.

Bug: 189232882
Test: Linux unit tests
Change-Id: Ia9334c38f9d7ea89b30d9ad05f0595570bb38658

Storing and loading OKP info.

[ Merge of http://go/wvgerrit/133763 and http://go/ag/15645333 ]

This change extends the DeviceFiles module to be able to store and
load OKP info.  Mild data validation is performed when storing and
loading the information.

Bug: 189232882
Test: Android unit tests
Change-Id: I077de3234157252f2255a4389bf82a8d5344a355

System OKP fallback policy.

[ Merge of http://go/wvgerrit/133783 and http://go/ag/15645334 ]

SystemFallbackPolicy provides a thread-safe interface for accessing
and modifying OKP info.

Bug: 189232882
Test: Android unit tests
Change-Id: I4e43e3bc047ed5fb6cb517b53e4094e812b70e1e

Engine OKP provisioner.

[ Merge of http://go/wvgerrit/133803 and http://go/ag/15645335 ]

The OtaKeyboxProvisioner provides a CdmEngine-specific context for
performing OTA keybox provisioning.  Utilizes the system-wide
SystemFallbackPolicy to relay provisioning status between engines.
The provisioner will handle message wrapping and unwrapping of the
raw OTA keybox request / response into the SignedProvisioningMessage
which is sent to/received from the provisioning server.

[ Partial merge of http://go/wvgerrit/125844 ]

Note: Includes partial CryptoSession changes from various CLs.
CryptoSession functionality has been stripped to reduce impact of
this CL.

Bug: 189232882
Test: Android unit tests
Change-Id: I282bf7d1887daefb2250af1bd595c4dc3dfcfb29

Integrated OKP into CDM Engine

[ Merge of http://go/wvgerrit/133804 and http://go/ag/15646376 ]

Extended the functionality of the CdmEngine to check if the device
requires OKP and to initialize OKP resources if required.  The
functionality of OpenSession() and GetProvisioningRequest() have been
the most affected.  If OKP is required, these methods will signal to
the app that provisioning is required and will return an OKP request.

Once a device is provisioned, the OKP data is cleared away and the
CdmEngine will resume normal operation.  Engines created after a
device is provisioned will immediately enter normal operations.
The exception is for CdmEngines which failed to perform OKP for some
reason and are still running.  Those apps will need to restart before
gaining access to L1 operations.

Bug: 187646550
Test: Android integration tests
Change-Id: Ia572a66a7b73479355758aa3d0c682691eaca0fc
2021-09-29 14:00:37 -07:00
Fred Gylys-Colwell
bac33dbc6e Use local provisioning server
Merge from Widevine repo of http://go/wvgerrit/133703 and
http://ag/14707867

[ Cherry-pick of http://ag/15835345 ]

In order to use a local provisioning server, we need to use a
different test keybox system id that is in the dev device database
instead of the production database. We also need to use a local
license server that uses the dev license server.

Bug: 187646550
Test: GtsMediaTestCases

Change-Id: Ice89143dd26de22757375a770c6bac716fcbc057

Add Keybox OTA Provisioning functions to OEMCrypto header

Merge from Widevine repo of http://go/wvgerrit/133704 and
http://go/ag/14707868

Bug: 188228998
Change-Id: Iff54bc2870e87bf7239e179e1d02fbcc8df6198f

Stub build changes to support OTA Keybox

Merge from Widevine repo of http://go/wvgerrit/133725 and
http://go/ag/14781459

This CL adds a new unit test file for testing OTA keybox
reprovisioning functionality. This new test is built when running the
dynamic adapter in the linux build, and in the Android build.

Bug: 187646550
Change-Id: I625513840188f95e74831ef2ea399e827e837439

Add OTA Keybox functions to dynamic adapter

Merge from Widevine repo of http://go/wvgerrit/125843
and http://go/ag/14781460

Bug: 187646550
Change-Id: Ief78ed10599c091690e0d7dc488ea71674c763b5

Refactor dynamic adapter keybox verification

Merge from Widevine repo of http://go/wvgerrit/133727
http://go/ag/14812524

The keybox validation needs to be done separately from initializing
the library so that we can support Keybox OTA Reprovisioning.

If L1 loads, but the keybox is missing, the initialization should
succeed. When the keybox is validated, the adapter should try to look
for a keybox on the filesystem. if none is found, it should either
return NEEDS PROVISIONING or an error.

Bug: 187646550
Change-Id: I34a8c365a5a5ca35c379bea827c85c749964744c

Update crypto session to use new OTA keybox functionality

Merge from Widevine repo of http://go/wvgerrit/133728 and
http://go/ag/14812525

This CL stubs out two new CryptoSession functions that call the new
OEMCrypto functions for OTA Keybox Provisioning. It builds!  Yay!

It also adds a boolean needs_keybox_provisioning that is set to true
when OEMCrypto reports that it needs a keybox. This should only happen
if there is no keybox installed and oemcrypto supports provisioning.

Bug: 187646550
Change-Id: Ide9533943125aa13b8899b652b118a0b410c882c
2021-09-29 14:00:36 -07:00
Alex Dale
1229aedcea Merge "PST and non PST can handle unlimited license durations." into sc-dev 2021-07-01 06:45:07 +00:00
Alex Dale
16a0ab2309 Merge "Updated integration test to handle unlimited license durations." into sc-dev 2021-07-01 05:35:29 +00:00
Rahul Frias
5271d95ce4 Merge "Address unit test failures" into sc-dev 2021-06-30 19:30:22 +00:00
Alex Dale
14bd15a08c PST and non PST can handle unlimited license durations.
[ Merge of http://go/wvgerrit/128183  ]

As was the case with WvCdmStreamingUsageReportTest.ReportTest, the
following tests were also updated to handle the case where "license
duration" is unlimited:
- WvCdmStreamingNoPstTest.UsageTest
- WvCdmStreamingPstTest.UsageTest
- WvCdmOfflineUsageReportTest.UsageTest

This is due to the new license duration model used for V16 licenses.

Bug: 163542905
Test: cdm_extended_duration_test
Change-Id: I24d3fc17fcf19129a19ed39a5c6c1ddd59ed073d
2021-06-30 10:41:07 -07:00
Alex Dale
a9e26bdc2b Updated integration test to handle unlimited license durations.
[ Merge of http://go/wvgerrit/128046 ]

Test case WvCdmStreamingUsageReportTest.WvCdmStreamingUsageReportTest
was failing comparing "license duration" values returned when querying
for key information for licenses with unlimited "rental duration".

This is due to the new license duration model used for V16 licenses.

From the Widevine MediaDrm doc for "LicenseDurationRemaining":

  For OEMCrypto v16+ (Android 11 and later), license duration is no
  longer being enforced. If rental duration is set to never expire,
  ”9223372036854775807” (LLONG_MAX) will be returned.

Similarly, the test has been updated for "playback duration" queries
of the same case.

Bug: 163542905
Test: cdm_extended_duration_test

Change-Id: I57e0e435631a151fac45c963d865de256a773644
2021-06-28 22:35:52 -07:00
Rahul Frias
52d3c9f7c1 Update VersionNumberTest.VersionNumberChangeCanary
[ Merge of http://go/wvgerrit/126463 ]

The Version Number in the test is being updated to 12 to reflect
android OS version (Test only change)

Bug: 190467766
Test: WV request_license_test:
      requestVersionNumberTest.VersionNumberChangeCanary
Change-Id: Iad4bb3f178fb2dcb454027c1323e51fe34dfdfff
2021-06-15 03:01:55 -07:00
Rahul Frias
8e92fef410 Address unit test failures
[ Merge of http://go/wvgerrit/126744 ]

* EngineMetrics previous_oemcrypto_initialization_failure is set only
  on a previous failure. Removing it from the list of expectations
  as we cannot be certain that it will or will not be set unless we
  know the previous state of the device.

* Corrected client_capabililties expectations in
  CdmLicenseTest.PrepareKeyRequestValidation

* Correct error expected in
  - WVDrmPluginTest.RejectsAtscProvisioningRequests
  - WVDrmPluginTest.RejectsAtscUnprovisionDeviceRequests

* Correct expectations
  - CdmSessionTest.InitWithBuiltInCertificate,
  - CdmSessionTest.InitWithCertificate
  - CdmSessionTest.ReInitFail,
  - CdmSessionTest.InitFailCryptoError

Bug: 181693982
Test: WV unit/integration tests
Change-Id: I2f1e1c38604d768e0532b30d8551c77ea45e63f4
2021-06-14 08:04:40 +00:00
Rahul Frias
bb0b6b4ba5 Merge "Disallow the ability to load offline licenses more than once" into sc-dev 2021-05-07 22:21:03 +00:00
TreeHugger Robot
4057559ae5 Merge "Report Rental duration remaining" into sc-dev 2021-05-01 00:50:13 +00:00
TreeHugger Robot
b7662fcbf2 Merge "Use Usage information from OEMCrypto on clock rollback" into sc-dev 2021-04-30 19:18:35 +00:00
Rahul Frias
2404500ceb Report Rental duration remaining
[ Merge of http://go/wvgerrit/124063 ]

LicenseDurationRemaining used to indicate the minimum of rental or
license duration till OEMCrypto v16. OEMCrypto v16 onwards it began
reporting rental duration alone.

This is confusing for app developers and content partners. Keeping
LicenseDurationRemaining as apps may depend on it but adding
RentalDurationRemaining for clarity.

Bug: 186838303
Test: WV unit/integration tests, WvCdmRequestLicenseTest.QueryKeyStatus
Change-Id: I6c507150a0945ee36716b4da189f5741b092c0ec
2021-04-30 04:52:39 -07:00
Rahul Frias
0921b04e41 Disallow the ability to load offline licenses more than once
[ Merge of http://go/wvgerrit/123263 ]

In b/65839890 we discovered that an android app loaded an offline
license more than once in a session. We did not intend to allow
this behavior but did not prohibit it. OEMCrypto v16 disallowed
this behavior at the OEMCrypto level but we worked around it
within the CDM to maintain the bad behavior. Now that we have confirmed
that the app no longer relies on that behavior, we are reverting
the CDM workaround.

Bug: 161865160
Test: WV unit/integration test, GtsMediaTestCases
      Amazon, Netflix, Google TV streaming and offline playback.
Change-Id: I31254e4c13b81587f88c6c684d08d5aa5c18e39d
2021-04-29 16:20:30 -07:00
Robert Shih
7a061b503f Merge "Update Android WVCdm version to 16.1.0" into sc-dev 2021-04-27 20:59:28 +00:00
TreeHugger Robot
03dff71bd8 Merge changes I6dd829f4,Id8384c58,I9228b9cc,I744a1e89 into sc-dev
* changes:
  Fix CDM Builds w/ OEMCrypto_ERROR_INVALID_ENTITLED_KEY_SESSION
  Fix unused param warnings in oemcrypto fuzz test
  Add http socket tests to other tests
  Turn on ODK tests in CE CDM test and fix test helper
2021-04-27 19:20:34 +00:00
Robert Shih
3a503278e6 Update Android WVCdm version to 16.1.0
TODO: update VersionNumberTest.VersionNumberChangeCanary

[ Merge of http://go/wvgerrit/123403 ]

Bug: 183073374
Test: GtsMediaTestCases
Change-Id: I1773416b6f3f212bead5e6b7749da52883041d07
2021-04-26 12:00:16 -07:00
Fred Gylys-Colwell
5a58b6d8d2 Add http socket tests to other tests
Merge from Widevine repo of http://go/wvgerrit/122224

This CL removes the separate main() in http_socket_test that
allowed the user to set the server on the command line.  I
don't think anybody was using this, and it conflicted with
our desire to include this suite of tests with the other CE
CDM tests running on Luci.

test: ran http_socket_test
bug: 118657876
Change-Id: I9228b9cc97a0af2afd1bb4a99bc40b88ce956d67
2021-04-23 10:11:48 -07:00
Rahul Frias
87e84d5498 Use Usage information from OEMCrypto on clock rollback
[ Merge of http://go/wvgerrit/123103 ]

This corrects setting of first and last playback times stored by the
CDM on rollback. Earlier usage information from the usage entry in
OEMCrypto would be ignored on rollback even when available.
Information stored along with the license in persistent storage would
be used instead.

A new test with longer duration expiry has been added as well as some
additional verification.

Bug: 186199213
Test: WV unit/integration test
Change-Id: I601f9584a8a0c5137ce68546f8ec833bf2e70cc5
2021-04-23 03:58:31 -07:00
Rahul Frias
2a316f65fe Correct request_license_test failures
[ Merge of http://go/wvgerrit/122885 ]

A recent change to the license service resulted in PSTs being inserted
into persistent renewable licenses even when not specified by the
content provider. This caused ReleaseOfflineKeySessionUsageDisabledTest
to fail. The asset was changed to use a policy for a persistent
license without renewal.

Offline_RollbackBeforeRestoreKey failed because the duration of the
license is short. It has expired when the clock is restored after a
rollback.

Bug: 181693982
Test: request_license_test
Change-Id: I0a2c2a09e563c81c134fba1f310deb1eb4de26a3
2021-04-23 01:52:18 -07:00
Rahul Frias
c997497aa6 Merge "Remove CBC1 and CENS test" into sc-dev 2021-04-17 00:12:17 +00:00
Rahul Frias
d59b009495 Merge "Address CE CDM test failures and code review comments" into sc-dev 2021-04-16 08:25:45 +00:00
Rahul Frias
69f29bbcb2 Remove CBC1 and CENS test
[ Merge of http://go/wvgerrit/122183 ]

Support for CBC1 and CENS encryption modes is no longer required with
OEMCrypto v16. Removing tests to enforce them. The tests will validate
CENC and CBCS mode.

Bug: 181693982
Test: request_license_test
Change-Id: I350d315528c753b70dbf1b1cc46f2897002333fb
2021-04-14 13:33:41 -07:00
Rahul Frias
a674c7cdd0 Correct request_license_test failures
[ Merge of http://go/wvgerrit/122103 ]

When in CTR mode an encryption pattern should no longer be specified.
This will address failures in Cdm/WvCenc30Test.DecryptionTest/* and
Cdm/WvCenc30SwitchCipherModeTest.DecryptionTest/*

Bug: 181693982
Test: WV unit/integration tests
Change-Id: Iecbf28b51115501439aebf057056657c796896ae
2021-04-14 02:57:50 -07:00
Rahul Frias
d802baa4d4 Address CE CDM test failures and code review comments
The android CL ag/13947818 was submitted before some CE CDM test
failures were noticed and code review comments were received.

Bug: 184813991
Test: WV unit/integration test
Change-Id: Ic31ca5bc5e46994e01eca56248e6bdffedd779f3
2021-04-13 11:23:18 -07:00
Rahul Frias
a40af9d1ef Reword "blacklisted" to "forbidden"
[ Merge of http://go/wvgerrit/113563 ]

Bug: 159847851
Test: WV unit/integration tests
Change-Id: I138b3e3291cb9e75841d092ca1bfa9a652ad9f9a
2021-04-08 11:54:06 -07:00
Bob Badour
ea0bd6030c Merge "[LSC] Add LOCAL_LICENSE_KINDS to vendor/widevine" into sc-dev 2021-03-26 06:45:39 +00:00
Alex Dale
50757c84ec Merge "Use new Base64 encode functions." into sc-dev 2021-03-26 05:19:31 +00:00
Bob Badour
376f47047c [LSC] Add LOCAL_LICENSE_KINDS to vendor/widevine
Added SPDX-license-identifier-Apache-2.0 legacy_by_exception_only to:
  Android.bp
  libwvdrmengine/Android.bp
  libwvdrmengine/vts/vendor_module/Android.bp

Added legacy_by_exception_only to:
  libwvdrmengine/cdm/Android.bp
  libwvdrmengine/cdm/core/src/Android.bp
  libwvdrmengine/cdm/core/test/Android.bp
  libwvdrmengine/cdm/metrics/src/Android.bp
  libwvdrmengine/cdm/test/integration-test.mk
  libwvdrmengine/cdm/test/unit-test.mk
  libwvdrmengine/level3/Android.bp
  libwvdrmengine/mediacrypto/Android.bp
  libwvdrmengine/mediacrypto/test/Android.mk
  libwvdrmengine/mediadrm/Android.bp
  libwvdrmengine/mediadrm/test/Android.mk
  libwvdrmengine/oemcrypto/odk/Android.bp
  libwvdrmengine/oemcrypto/odk/test/fuzzing/Android.bp
  libwvdrmengine/oemcrypto/odk/test/fuzzing/corpus_generator/Android.bp
  libwvdrmengine/oemcrypto/test/Android.mk
  libwvdrmengine/test/unit/Android.mk
  libwvdrmengine/tools/metrics_dump/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I41ef520b6e394a7708f453a706e6ef1a5f46c36a
2021-03-25 09:52:52 -07:00
Alex Dale
d859c1ab17 Use new Base64 encode functions.
[ Merge of http://go/wvgerrit/119806 ]

This change replaces all calls for base64 encoding which first converts
a string to a vector.  The new base64 encoding function allow for
encoding binary data contained within strings.

Bug: 181732604
Test: Android unittests
Change-Id: Ibfe79dba99e6a2ee2f2a96e85b62fbd22519aea7
2021-03-23 14:49:58 -07:00
Rahul Frias
e538c96131 Save and retrieve key information from licenses and usage records
[ Merge of http://go/wvgerrit/120512 ]

Wrapped DRM private keys are loaded when a key request is made or when
offline/usage sessions are restored. They were earlier loaded when a
session was opened.

For streaming sessions, key material will be fetched from the default
or legacy certificates and loaded when a key request is made.

For offline and usage sessions, key material may be retrieved from
license or usage records if available. If not available, information
associated with the legacy certificate will be loaded.

Certificate and wrapped keys are also written out when an offline
license or usage record is saved.

Bug: 169740403
Test: WV unit/integration tests
      WvCdmRequestLicenseTest.ProvisioningWithExpiringCertTest
      WvCdmRequestLicenseTest.StreamingWithExpiringCertTest
      WvCdmRequestLicenseTest.RestoreOfflineKeysWithExpiringCertTest
Change-Id: Ice0154c632170c46da171cbbb23a97380c610a98
2021-03-23 13:06:55 -07:00
Rahul Frias
b21be96b1b Verify DRM certificate validity
[ Merge of http://go/wvgerrit/120123 ]

DRM certificate creation and expiration times are now validated.

* New DRM (default) certificates will have an expiration time specified
by the provisioning service.

When stored, the client will include the time the certificate was
received. This allows for expiration calculation to occur when client
and provisioning service clocks are out of sync.

When read out, creation, expiration and acquisition times are
validated. The certificate is checked for expiry by making sure
that the time at the client since the license was acquired is not
greater than the expiration period. The time information stored at the
client may be tampered with. The license service will perform an
expiration check and reject the license request if tampered with.
The expiration time may be set to never expires/unlimited. This is not
a valid value for creation or acquisition time.

* Pre-existing (legacy) certificates from upgrading devices will not
have an expiration time set by the provisioning service. Instead
the client will calculate an expiration time 6 months with + or -
a random two month period in the future. This is stored along with the
certificate.

When read out, if no expiration time has been set by the client, one
will be calculated and written out. The certificate will be declared as
valid. If a client calculated expiration time is present, the
certificate will be validated. In case of tampering, the license service
can reject license requests and force reprovisioning when appropriate.

* ATSC certificates will continue to not have an expiration time.
No additional validation is required.

Other changes for non-ATSC licenses involve managing both default and
legacy certificate co-existance. When checking for DRM certificates,
the default certificate is attempted first. This is followed by a check
for the legacy certificate, if the default certificate is not present.

Bug: 169740403
Test: WV unit/integration tests
      DeviceFilesTest.StoreCertificateInvalidParams
      DeviceFilesTest.RetrieveAtscCertificate
      DeviceFilesTest.RetrieveAtscCertificateNotFound
      DeviceFilesTest.RetrieveCertificateInvalidParams
      DeviceFilesTest.RetrieveLegacyCertificateWithoutExpirationTime
      DeviceFilesTest.RetrieveLegacyCertificateWithClientExpirationTime
      DeviceFilesTest.RetrieveLegacyExpiredCertificateByClientExpirationTime
      DeviceFilesTest.RetrieveLegacyCertificateInvalidClientExpirationTime
      DeviceFilesTest.RetrieveCertificateWithoutKeyType
      DeviceFilesTest.RetrieveDefaultCertificate
      DeviceFilesTest.RetrieveDefaultCertificateNeverExpires
      DeviceFilesTest.HasCertificateAtsc
      DeviceFilesTest.HasCertificateDefault
      DeviceFilesTest.HasCertificateLegacy
      DeviceFilesTest.HasCertificateNone
      CertificateTest.StoreCertificateTest.DefaultAndLegacy/*
      CertificateTest.RetrieveLegacyCertificateTest.ErrorScenarios/*
      CertificateTest.RetrieveDefaultCertificateTest.ErrorScenarios/*

Change-Id: I7dbec7555fbd493c1ec61c6bb5d9428a2405b1fd
2021-03-19 02:49:20 -07:00
Rahul Frias
9a350eddbd Extract creation and expiration times from DRM cert
[ Merge of http://go/wvgerrit/119843 ]

Creation and expiration times are extracted from the device DRM
certificate. They are reported as
 * -1 if not set in the proto
 * 0 if unlimited
 * positive number otherwise

Bug: 169740403
Test: WV unit, integraiton tests
Change-Id: I9463954dfeb82b6a88ff5d608ed74d20f2424e83
2021-03-18 23:59:21 -07:00
TreeHugger Robot
6ee9f49e5c Merge "Address compilation warnings" into sc-dev 2021-03-13 02:43:45 +00:00
Alex Dale
16c704fa09 Android tests call exit() when complete.
[ Merge of http://go/wvgerrit/119804 ]

The coverage framework used by Android requires the process to call
exit() for coverage information to be dumped after the tests.

Android unit tests have been adapted to use the a new main module.
The core test_main.cpp used by integration tests has been updated to
call exit().

Bug: 138941105
Test: Linux and Android unittests
Change-Id: Ifffc7b8290c50dffe527738a36547c1d2fb90bd3
2021-03-12 16:22:20 -08:00
Rahul Frias
094fabed5a Address compilation warnings
[ Merge of http://go/wvgerrit/119523 ]

Bug: 182299187
Test: compile vendor/widevine/libwvdrmengine
Change-Id: I39d1b62a3237bfb9163a7e157b871f22e3fec394
2021-03-10 18:49:57 -08:00
Robert Shih
7cb52c1ccf wvcdm: filter logs by app uid
This commit is a combination of the following:
* http://go/wvgerrit/117003
* http://go/wvgerrit/118303

Bug: 162255728
Test: MediaDrmTest#testGetLogMessages
Change-Id: I5699b64d5c4bab463e5b587595fa7d324dc1d93f
2021-03-01 11:56:37 -08:00
Rahul Frias
64d5b38ff5 Throw DeniedByServerException when provisioning detects a revoked device
[ Merge of http://go/wvgerrit/117267 ]

The client will now advertise the ability to handle provisioning errors
by a minor version updated to the provisioning protocol version.
The provisioning service may indicate that the individual device
is revoked or all devices with the same make/model have been revoked.

If the provisoning service has not been upgraded, the protocol version
field in the request will be ignored. The provisioning service/SDK
will respond with an HTTP 400 error to a provisioning request from
a revoked device.

Bug: 174174765
Test: WvCdmRequestLicenseTest.ProvisioningRevocationTest,
      WV unit/integration tests
Change-Id: I5ff61496685f310de6704a90452b8b76b3505cbb
2021-02-23 14:36:21 -08:00
Alex Dale
e15c0607c7 Enable the CDM to track the DRM private key type.
[ Merge of http://go/wvgerrit/110923 ]

The CDM is responsible for telling OEMCrypto the underlying DRM
private key type when loading it into a session.  To do this, the
CDM must determine and store the key type of a successfully loaded
provisioning response.  The type of key is available from the
DRM certificate proto that is provided in the reponse.

This change introduces a class to contain the wrapped key and
type together.  To store the type, the CDM device files have been
updated to include a key type with the DRM certificate and to
store from and load to the new class.

Unittests have been updated for using the new class where the
wrapped key was used before.

Test: Linux unit tests
Bug: 140813486
Change-Id: I09249afe9c291632fb651ecd00eac697d6939ec7
(cherry picked from commit 6c457402e944079271cef488aa4699f986da6a2e)
Merged-In: I09249afe9c291632fb651ecd00eac697d6939ec7
2021-02-18 23:10:39 +00:00
Rahul Frias
b1f54bbba8 Add Duration Use Case integration tests
Cherry pick from http://go/wvgerrit/102986, rvc-dev branch of
http://go/wvgerrit/105825, rvc-widevine-release of http://go/ag/12561661

This CL adds several integration tests that match the duration use
cases. The test classes are designed for the core cdm, but the test
cases match those found in oemcrypto/odk/test/odk_timer_test.cpp.

See this document for a list of use cases:
libwvdrmengine/docs/License_Duration_and_Renewal.pdf

Test: Ran the tests against v16 OEMCrypto. Some fail against v15.
Bug: 161463952
Change-Id: I7cd424ae241d3897fbd06956e87dd9da0752cb6d
2020-11-02 23:10:41 +00:00
Rahul Frias
d1dff772d3 Add some policy integration tests
Cherry-pick from branch rvc-dev of http://go/wvgerrit/105824 and
rvc-widevine-release http://go/ag/12561660

This adds two policy integration tests to verify that we are handling offline
licenses correctly.

Bug: 161023174
Bug: 129301787
Test: WV unit/integration tests
Change-Id: I20f5d6a9fbfd2ff8cff361e1005e45b46c700704
2020-11-02 00:44:02 -08:00
Rahul Frias
1381746ecb Merge changes I9a4977fd,I8ae5a10c,I0f9e6445
* changes:
  Update Widevine Copyright header
  Update Widevine Copyright header for core CDM
  Update Widevine Copyright header for android
2020-10-22 10:24:45 +00:00