Commit Graph

2671 Commits

Author SHA1 Message Date
Rahul Frias
612f8bc0a9 Merge "Disallow restoring an offline license multiple times" into sc-dev am: d1d0fa431a
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14731758

Change-Id: Iabf693abbe60ec39b7b0a67939961d507b45a9a6
2021-06-09 00:30:49 +00:00
Rahul Frias
d1d0fa431a Merge "Disallow restoring an offline license multiple times" into sc-dev 2021-06-08 23:57:23 +00:00
Robert Shih
a81ace2ea4 Use drm@1.4 vintf fragments for drm@1.3
This avoids widevine crashloops in case partners updated
vendor/widevine without updating device makefiles.

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

Bug: 178110290
Bug: 186502089
Test: GtsMediaTestCases
Change-Id: Iafd9e62beadf5a099a76ab6a987ffd9598e5ef25
2021-06-04 19:45:16 +00:00
Rahul Frias
999fbeb666 Disallow restoring an offline license multiple times
[ Merge of http://go/wvgerrit/126063 ]

As a side-effect of fixing b/161865160 CDM checks to flag reloading
of an offline license were removed. This left it to the OEMCrypto
which varied by device implementation. Checks are being reintroduced
to the CDM and will help MediaDrm return the expected error
ERROR_LICENSE_STATE.

In addition restoring an offline liense to a session where a license
is already loaded will be rejected.

Bug: 184608310
Bug: 182208685
Test: WV unit/integration tests
      MediaDrmTest.testMultipleLoadKeys
Change-Id: Id8ee069d22819f7823aa6af11a41f35f0a04ce0a
2021-06-04 03:20:15 -07:00
Alex Dale
ad0d66c7e6 [DO NOT MERGE] Revert "Restructed reference root of trust (1/3 Keybox)"
This reverts commit e4ee4eb404.

Reason for revert: Feature missed deadline

Bug: 135283522
Change-Id: I4ee2caac2dadfcc3e145b9c9b977d216d4edd929
2021-06-02 20:00:16 +00:00
Alex Dale
06b637ed95 [DO NOT MERGE] Revert "Restructed reference root of trust (2/3 DRM Cert)"
This reverts commit f6f5099604.

Reason for revert: Feature missed deadline

Bug: 135283522
Change-Id: Ic86930ee3444c5a6aa1d78ae3a12a9030c29ef92
2021-06-02 17:41:53 +00:00
Alex Dale
dda99b0adf Merge "New usage entries are moved lower after creation." into sc-dev am: 9c47be6aa8 am: 7291bb5fc5 am: a48adbebee
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14354899

Change-Id: I6a65a4a0b913e4e53abe103a5daf12d29bea2239
2021-05-26 23:08:44 +00:00
Alex Dale
9c47be6aa8 Merge "New usage entries are moved lower after creation." into sc-dev 2021-05-26 22:31:03 +00:00
TreeHugger Robot
ab13d34235 Merge "Sync L3 headers in sc-dev" into sc-dev am: 5af95f48ed am: c03abd803e am: 1015e07fa6
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14669194

Change-Id: Ia49ab3f12f62a874466a0e3b0ed81052754e2321
2021-05-26 00:51:13 +00:00
TreeHugger Robot
5af95f48ed Merge "Sync L3 headers in sc-dev" into sc-dev 2021-05-26 00:02:54 +00:00
Fred Gylys-Colwell
ad8edfb449 Add fudge to duration tests am: 20833734e1 am: fd451af75b am: 05ae982332
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14664668

Change-Id: I3f8b63f93cd015ab30d75619b6a6c14821366310
2021-05-25 23:00:11 +00:00
Cong Lin
8cb1e102db L3 Load RSA private key from two parts [sc-dev]
This is a cherry-pick of
https://widevine-internal-review.googlesource.com/c/cdm/+/121763

Original commit message from master branch:
This is a security improvement against an L3 exploit b/182584472.
The change is to store RSA private key in two parts instead of one,
and load it separately when the key is needed. This will make it
more difficult to find the entire RSA key.

OEM private key is split into two parts and stored in Haystack in CL:
cl/367515385. Loading RSA key is to be changed to loading part one first
and then part two. Bytes in each part are parsed in sequence.

Only OEM private key has two non-empty parts. For DRM private key the
first part contains the entire key, and second part is empty. For more
details, please find the comments in the head of rsa_load.cpp.

This change slightly increased the size of LoadRSAKey from 6KB to 7KB
due to the macros introduced. It's unlikely to have overall performance
impact.

Bug: 183416973
Bug: 182584472
Test: jenkins/run_level3_static_tests
Test: GTS test
https: //android-build.googleplex.com/builds/forrest/run/L93800000881790143
Change-Id: I34b3b795e6ac2ce9b41e915c1adf8fcdc489d94a
2021-05-25 22:33:26 +00:00
Fred Gylys-Colwell
4964c79d93 Merge "LUCI: Add build fuzz tests script to presubmits" into sc-dev am: eaa1e6d4a0 am: c6cfc6a296 am: 9a13a70164
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14486069

Change-Id: I11964ae28e3da961a07c77a88e9a9c0f0bce695b
2021-05-25 21:09:17 +00:00
Fred Gylys-Colwell
20833734e1 Add fudge to duration tests
Merge from Widevine repo of http://go/wvgerrit/125046

Add some extra fudge to the termination time. This assumes that flaky
tests were caused by roundoff error.

Bug: 175741647
Change-Id: I9bcc86f9b9540e5985df647dd1b5c5d439556e2b
2021-05-25 20:26:43 +00:00
Fred Gylys-Colwell
eaa1e6d4a0 Merge "LUCI: Add build fuzz tests script to presubmits" into sc-dev 2021-05-25 20:19:49 +00:00
Alex Dale
6805c0e267 Check for open session when initializing usage table. am: 023b06eded am: 51ec04bd43 am: f423cc7a4e
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14296026

Change-Id: Ice3bdbb35d67403ae5af9bc005f798ec0a2de567
2021-05-24 22:01:22 +00:00
Alex Dale
884550333d New usage entries are moved lower after creation.
[ Merge of http://go/wvgerrit/124004 ]

When the CDM creates a new usage entry for an offline or streaming
license, the new entry is immediately moved to the lowest available
entry index that has been marked as vacant (kStorageTypeUnknown).

When a license is released, its meta data that is managed by the CDM
is cleared; however, the usage entry's index is marked vacant, but it
is not released.  This creates wasted entry space in the usage table.
Unfortunately, defragging the table is computationally expensive and
may not be able to actually free up much space depending on when it
is performed.

For a typical user, this will likely not be an issue as the table
can get quite large compared to the number of licenses an app uses
and the table is partially cleaned on each boot.

GTS tests, however, have reached a point where they fill the usage
table before all tests are complete.  This is causing many unexpected
failures for devices.  Most of these tests release their license, but
the CDM never reaches a state where it can clean up the table.

By moving newly created entries to the lowest available index directly
after creating the entries, the table never needs to grow unless all
entries are in use.  Clean up is now almost never required.

Bug: 180639135
Bug: 180638990
Bug: 180638530
Test: MediaDrmTest#testWidevineApi28
Change-Id: I1a68d90d51384094298b27037778747ce7435374
2021-05-24 12:51:44 -07:00
Cong Lin
d542cb91b5 Sync L3 headers in sc-dev
Merge of these CLs from Widevine sc-dev:

modified:   libwvdrmengine/level3/include/clear_cache_function.h
  Add cache flush assembly for arm64 L3 to Android header | http://go/wvgerrit/124828
  Address compilation errors | http://go/wvgerrit/113083

modified:   libwvdrmengine/level3/include/level3_file_system_android.h
  Update Widevine Copyright header for android | http://go/wvgerrit/108084

Bug: 184866351
Test: Header changes for clearing cache is verified by one of the partners on their arm64 target;
https: //b.corp.google.com/issues/175432203#comment13

Change-Id: I0ac8f339f65d02abb3080020fbc715b9c0db85b2
2021-05-20 14:56:20 -07:00
Alex Dale
023b06eded Check for open session when initializing usage table.
[ Merge of http://go/wvgerrit/122984 ]

There was an issue encountered by some vendors with how the usage
table was initialized on some devices.  Previously, the CDM would
open an OEMCrypto session first, then initialize the usage table
(loading existing or creating a new one).  On these devices,
OEMCrypto_CreateUsageTableHeader() and OEMCrypto_LoadUsageTableHeader()
would fail if there were any open sessions.

This CL changes the initialization process to create/load the usage
table before opening an OEMCrypto session.

This change also lays the ground work for another usage table fix
to address GTS tests failure.

In the process, several of the functions for the usage table have been
split up into smaller chunks of code.  This required additional changes
to the usage table unittest to keep them up to date.

Bug: 169195093
Bug: 180639135
Test: Linux unittests and MediaDrmTest
Change-Id: Ifbf35f5d8cff5b89fea9b16edb998c84803f4fbe
2021-05-19 10:39:51 -07:00
Cong Lin
563a79bd8b [RESTRICT AUTOMERGE] L3 Load RSA key from two parts and re-generate
build

This is a merge of CL from widevine repo (obfuscated code only):
https://widevine-internal-review.googlesource.com/c/cdm/+/124965

The source code change that produced the obfucated code is here:
https://widevine-internal-review.googlesource.com/c/cdm/+/121763

Original commit message from the fix above:
"This is a security improvement against an L3 exploit b/182584472.
The change is to store RSA private key in two parts instead of one,
and load it separately when the key is needed. This will make it
more difficult to find the entire RSA key.

This CL does the key loading part only. Key splitting is done
in Haystack in CL: cl/367515385"

New L3 system IDs included in the obfuscated code:
ID     Description
22593  Android S ARM L3 Field Provisioning 3.0
22594  Android S ARM 64 L3 Field Provisioning 3.0
22595  Android S x86 L3 Field Provisioning 3.0
22596  Android S x86 64 L3 Field Provisioning 3.0

Bug: 182584472
Test: L3 unit tests
Test: GTS tests
https://android-build.googleplex.com/builds/forrest/run/L16300000887061939
The only failed case is a test issue due to the new IDs not being added
to the allow list of the test yet. This test passed on local run with
the updated allow list.

Change-Id: If8b8b2cb9291ede0cb2dcc892f5557c3a68c4b96
2021-05-19 10:20:02 -07:00
Cong Lin
77f9be1d01 [RESTRICT AUTOMERGE] L3 Load RSA key from two parts and re-generate
build

This is a merge of CL from widevine repo (obfuscated code only):
https://widevine-internal-review.googlesource.com/c/cdm/+/124963

The source code change that produced the obfucated code is here:
https://widevine-internal-review.googlesource.com/c/cdm/+/121763

Original commit message from the fix above:
"This is a security improvement against an L3 exploit b/182584472.
The change is to store RSA private key in two parts instead of one,
and load it separately when the key is needed. This will make it
more difficult to find the entire RSA key.

This CL does the key loading part only. Key splitting is done
in Haystack in CL: cl/367515385"

New L3 system IDs included in the obfuscated code:
ID     Description
22593  Android S ARM L3 Field Provisioning 3.0
22594  Android S ARM 64 L3 Field Provisioning 3.0
22595  Android S x86 L3 Field Provisioning 3.0
22596  Android S x86 64 L3 Field Provisioning 3.0

Bug: 182584472
Test: L3 unit tests
Test: GTS tests
https://android-build.googleplex.com/builds/forrest/run/L16300000887061939
The only failed case is a test issue due to the new IDs not being added
to the allow list of the test yet. This test passed on local run with
the updated allow list.

Change-Id: I50730b80e27d7ba78d5b28341cfe0f2085b03b2c
2021-05-18 11:20:24 -07:00
TreeHugger Robot
e0344b8efb Merge "Validate decryption with entitled keys in OEC tests" into sc-dev am: e233e68de1
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14506727

Change-Id: Ifd10be34ef0ac4ca02c5f5781db013436c1c6c85
2021-05-17 22:10:23 +00:00
TreeHugger Robot
ac87531b36 Merge "Remove asserts from GenerateSimpleSampleDescription()" into sc-dev am: 418d322961
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14506726

Change-Id: Ia4c41e3fe92fe8a5514e3253db930ec95b3eaec6
2021-05-17 22:10:18 +00:00
TreeHugger Robot
e233e68de1 Merge "Validate decryption with entitled keys in OEC tests" into sc-dev 2021-05-17 22:09:52 +00:00
TreeHugger Robot
418d322961 Merge "Remove asserts from GenerateSimpleSampleDescription()" into sc-dev 2021-05-17 22:09:21 +00:00
TreeHugger Robot
4948331656 Merge "[DO NOT MERGE] Revert "Restructed reference root of trust (3/3 OEM Cert)"" into sc-dev 2021-05-17 21:50:36 +00:00
Alex Dale
fe28d4cafc [DO NOT MERGE] Revert "Restructed reference root of trust (3/3 OEM Cert)"
This reverts commit 9f7e2c4413.

Reason for revert: Feature missed deadline

Bug: 135283522
Change-Id: I63eb0431762fd13c64bef926fb1e64b6edacb156
2021-05-17 19:08:53 +00:00
John W. Bruce
d742daf9c7 Validate decryption with entitled keys in OEC tests
(This change is merged from http://go/wvgerrit/124825)

The OEMCrypto tests have tests that verify that entitled keys can be
loaded but not that they can be successfully used for decrypt. This
patch adds a decrypt portion to the existing tests.

As part of this, the existing Session::EncryptCTR() method and portions
of Session::TestDecryptCTR() are lifted to be static functions so they
can be shared across unrelated classes in oec_session_util.cpp.
EncryptCTR() had no dependence on its enclosing class and is unchanged
other than being moved outside the class.

To reduce ambiguity with the new decrypt verification, this patch also
renames EntitledMessage::VerifyEntitlementTestKeys() to the
more-specific EntitledMessage::VerifyKCBs(). Its behavior is unchanged.

Bug: 186782279
Test: x86-64 platform
Test: opk_ta platform
Test: build_and_run_all_unit_tests
Change-Id: I15156882907b0987215087aaf43b4666fedc171a
2021-05-11 12:52:24 -07:00
John W. Bruce
ed17d09c1b Remove asserts from GenerateSimpleSampleDescription()
(This change is merged from http://go/wvgerrit/124824)

GenerateSimpleSampleDescription() only had asserts to check parameters
that only came from other test code, so they weren't testing anything of
use. With the asserts removed, it's no longer necessary to wrap calls to
GenerateSimpleSampleDescription() with ASSERT_NO_FATAL_FAILURE(), which
a lot of callers were already forgetting to do anyway. This also
simplifies a future patch that will generalize the decryption test code
to work with entitlement licenses.

Bug: 186782279
Test: x86-64 platform
Test: build_and_run_all_unit_tests
Change-Id: I987427fdfee4826d77ab95344f9aca8c374b2001
2021-05-11 12:49:22 -07:00
Cong Lin
4dd5b67ab0 [RESTRICT AUTOMERGE] Refresh L3 libraries after buffer overflow fix sc-dev am: 22f8ee9498
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14235494

Change-Id: I9f6af72472a903d0cfe4c6bc7bd882f66448e0e4
2021-05-10 22:20:57 +00:00
TreeHugger Robot
ddaae9a17b Merge "[RESTRICT AUTOMERGE] Refresh L3 libraries after buffer overflow fix sc-dev" into sc-dev 2021-05-10 22:02:06 +00:00
Fred Gylys-Colwell
d3942b242c LUCI: Add build fuzz tests script to presubmits
Merge from Widevine repo of http://go/wvgerrit/123803

Update fuzz build script to use gyp from third_party folder.

Test: ran fuzz tests on luci
bug: 186271314
bug: 184866351
Change-Id: If530872aa1e60d2108932610415aa5315979390c
2021-05-10 17:44:50 +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
Alex Dale
0579fe805e Clean up other core CDM logs.
[ Merge of http://go/wvgerrit/122613 ]

Further log clean up in the core CDM code.
- Changed several INFO logs to DEBUG and VERBOSE
- Added more identifiers to the DEBUG logs to help match resource
  associations
- Added more enum-to-string functions
- Unknown enum values will be formatted to contain their numeric
  value

Key areas improved are the UsageTableHeader and CdmSession.

Bug: 183576879
Test: CE CDM unittests
Change-Id: I2d11e714d419e0736d3e2f7a7668e8d36d7ef449
2021-04-28 20:39:21 -07:00
Robert Shih
ca6153e7d8 Merge "metrics: set OEMCrypto initialization errors correctly" into sc-dev am: 85afe8c0b0
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14238887

Change-Id: I085c56c3af4748b0bb156d34d4bb25b795a3d57c
2021-04-28 21:51:02 +00:00
Robert Shih
85afe8c0b0 Merge "metrics: set OEMCrypto initialization errors correctly" into sc-dev 2021-04-28 21:31:23 +00:00
Ulyana Trafimovich
d7fe1ff2cf Merge "Disable dexpreopt and <uses-library> check for tests." into sc-dev am: 4b9ec9eab6
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14326926

Change-Id: I16ff9f6df17577231bd50252bd7b4dce585bbdb9
2021-04-28 09:57:02 +00:00
Ulyana Trafimovich
4b9ec9eab6 Merge "Disable dexpreopt and <uses-library> check for tests." into sc-dev 2021-04-28 09:38:17 +00:00
Robert Shih
f88f5e1d8b Merge "Update Android WVCdm version to 16.1.0" into sc-dev am: 7a061b503f
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14313686

Change-Id: Ibc8e863e46662264ba775359ab4b240d9c706e35
2021-04-27 21:40:09 +00:00
Robert Shih
7a061b503f Merge "Update Android WVCdm version to 16.1.0" into sc-dev 2021-04-27 20:59:28 +00:00
Rahul Frias
78099431a8 Merge "Address CE CDM code review comments" into sc-dev am: 9b3e37b038
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14253246

Change-Id: Icac8e27e2b15ae1298e3ed75b66c8593525f02b8
2021-04-27 20:50:34 +00:00
Rahul Frias
9b3e37b038 Merge "Address CE CDM code review comments" into sc-dev 2021-04-27 20:27:35 +00:00
TreeHugger Robot
15bf2eec0b Merge changes I6dd829f4,Id8384c58,I9228b9cc,I744a1e89 into sc-dev am: 03dff71bd8
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/14212412

Change-Id: I1837921fb595a45514ce17befccc0fc82cd20193
2021-04-27 19:33:36 +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
Cong Lin
22f8ee9498 [RESTRICT AUTOMERGE] Refresh L3 libraries after buffer overflow fix sc-dev
Merge of [http://go/wvgerrit/118363]. Fixes included:

http://go/wvgerrit/111603
Fix L3 block offset test and re-enable buffer overflow tests

http://go/wvgerrit/111784
Fix heap overflow test in L3 and OEMCrypto ref

http://go/wvgerrit/113644
Check for buffer overflow when computing subsample size

http://go/wvgerrit/113946
Fix test failures caused by huge key length in L3

Test: Ran L3 unit tests
Test:
https://android-build.googleplex.com/builds/forrest/run/L81800000863169076
Bug: 182584472

Change-Id: Iae051ac2c06eb263b3b3be76d56b42917340af1d
2021-04-27 09:35:03 -07:00
Ulya Trafimovich
07440a83bf Disable dexpreopt and <uses-library> check for tests.
Bug: 132357300
Test: treehugger
Change-Id: Ia2c6cba7a4a91f6d3b0b343a44c4257817c3a4cf
2021-04-27 14:27:37 +01:00