Commit Graph

3017 Commits

Author SHA1 Message Date
Peter Kalauskas
1afc15fba3 Add lazy service target to widevine
Test: Run widevine media GTS tests
Bug: 112386116
Change-Id: Id0a735def8d3bf4e71df1952c3d4d8034f3aabda
2019-01-30 09:26:09 -08:00
Jeff Tinker
8084bd5375 Implement isCryptoSchemeSupported in the Widevine drm plugin
Support overloaded isCryptoSchemeSupported method that
accepts a security level parameter

bug:110701831
test: cts media test cases, widevine integration tests, gts media tests

Change-Id: Ia84e40ff8d4f13fc06478e338e3238061e283dac
2019-01-30 07:10:10 +00:00
John W. Bruce
a1b5b42d55 Add a Reader-Writer Lock
(This is a merge of http://go/wvgerrit/70666)

We need a reader-writer lock implementation in order to make use of the
new threading guarantees in OEMCrypto v15. However, we do not have
access to an STL reader-writer lock due to only being on C++11. This
patch adds a home-grown reader-writer lock, as well as tests to verify
that its behavior is sound.

Bug: 70889998
Bug: 118584039
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: Iaddcefb50e72452fbd27d04879eacf775484e675
2019-01-29 13:41:38 -08:00
Edwin Wong
54104c7a22 Implement MediaDrm offline license support in Widevine hidl service.
Merged from http://go/wvgerrit/69723.

The new APIs are getOfflineLicenseIds, getOfflineLicenseState and
removeOfflineLicense. These methods are currently stubbed out in
Widevine hidl service. This CL completes the implementation.

Test: unit tests - libwvdrmdrmplugin_hidl_test

Test: GTS
  --test com.google.android.media.gts.MediaDrmTest#testWidevineApi29

bug: 117570686
Change-Id: I96ffb75f453e36e931effefd3664b5faa8d69d30
2019-01-29 13:41:08 -08:00
Rahul Frias
19c4996b3c Merge "Modified return values for Restore operations" 2019-01-28 21:31:54 +00:00
Rahul Frias
7eb408e181 Merge "Support both PEM format and DER format intermediate certs" 2019-01-28 21:08:43 +00:00
Rahul Frias
61ef6b691a Merge "Add CDM integration test for offline renewal and release" 2019-01-28 21:06:48 +00:00
Rahul Frias
f60d2b87fa Merge "Add logging to Usage Table Header" 2019-01-28 20:03:09 +00:00
John Bruce
d21695d395 Merge "Add a cross-platform argument parser." 2019-01-28 18:29:10 +00:00
Srujan Gaddam
5e883463da Merge "Add relocs param to TerminateRuntime" 2019-01-28 18:28:48 +00:00
John Bruce
fcfa61c71f Merge "Misc Windows fixes." 2019-01-28 17:49:28 +00:00
Rahul Frias
980b15fd7e Support both PEM format and DER format intermediate certs
[ Merge of http://go/wvgerrit/71204 ]

- Also renames oem_certificate_generator_help to
oem_certificate_generator_test_helper to better reflect what it is.
- Use PKCS7_DETACHED instead of PKCS7_PARTIAL.

Bug: 122610083.
Test: WV unit/integration tests
Change-Id: Iee84598512cafb6092a857da1582c741c6ee7693
2019-01-28 09:38:53 -08:00
Rahul Frias
4b54d8a7a4 Merge "Report provider client token" 2019-01-28 17:30:52 +00:00
John Bruce
9372b9fb54 Merge "Segfault When Running Jenkins Tests... Sometimes" 2019-01-26 17:31:32 +00:00
Fred Gylys-Colwell
1e9c85c00d Merge changes Ibd8951c7,I9a13dbae
* changes:
  Add mutex lock around InstallTestRootOfTrust
  Remove Test Keybox Again
2019-01-26 01:09:28 +00:00
Fred Gylys-Colwell
03c10789f9 Add mutex lock around InstallTestRootOfTrust
Merge from Widevine repo of http://go/wvgerrit/71323

When running multithreaded tests, we need to make sure there are no other
OEMCrypto calls between OEMCrypto_Initialize and the installation of the test
keybox.

bug: 123319961
test: ran juce's threading test
Change-Id: Ibd8951c764f6538da4afa9ad146a6a72064eb13a
2019-01-26 01:05:38 +00:00
Jacob Trimble
9a66a6f590 Add a cross-platform argument parser.
(This is a merge of http://go/wvgerrit/70343)

Instead of using the POSIX-specific getopt(), this uses a manual
string comparison so it works on Windows.

Test: Android Unit Tests
Bug: 122953649
Change-Id: If009f8b3bfc8581d252da0f5ed55293c46d70bc6
2019-01-25 15:44:28 -08:00
Jacob Trimble
b3dd9c3711 Misc Windows fixes.
(This is a merge of http://go/wvgerrit/70324)

- Add build settings for Windows.
- Conditionally add pthread.
- Add dummy DLLMain method.
- Fix #if checks for Windows.
- Remove designated initializers which aren't supported in MSVC.
- Remove variable length array.

Test: Android Unit Tests
Bug: 122953649
Change-Id: I14f16e7ce4b3ff17ee0139ea6c2f7243ae999aa1
2019-01-25 15:05:00 -08:00
John W. Bruce
dfc5909d0c Segfault When Running Jenkins Tests... Sometimes
(This is a merge of http://go/wvgerrit/71330)

The Service Certificate unit tests actually relied on the ability to
call Properties::Init() multiple times to clear previous mutable state.
Unfortunately, they didn't check the return code that could have told
them their mutable state wasn't being cleared and instead proceeded to
use a pointer which — depending on compiler — could be totally valid and
allow the test to pass or could be invalid and cause a segfault. You can
read the bug for a fuller explanation of the mechanics.

The fix is twofold. First, the tests will now assert out if insertion
into the property set map fails, preventing segfaults. Second, a helper
has been added to Properties that allows tests interested in
re-initializing Properties to do so. The default behavior for most tests
remains the same: Properties can only be initialized once and subsequent
calls to Properties::Init() are ignored.

This patch also fixed a few formatting issues I noticed.

Bug: 123099779
Test: Jenkins Unit Tests w/ GCC
Test: CE CDM Unit Tests w/ GCC & Clang
Change-Id: Ifd29f3ddf5cff934933cf47b92ecd12ab0a4a938
2019-01-25 14:48:00 -08:00
Srujan Gaddam
d203bea228 Fix entry range for INSUFFICIENT_RESOURCES tests
Bug: b/121214641
Merge of http://go/wvgerrit/70768
Tests: usage_table_header_unittests (with and without hardcoded values)

DeleteEntry fails if the last entry is in use, since it cannot shrink
the table any further via swapping. The LoadEntry_LoadUsageEntry...
tests test to see that after deleting an entry x amount of times, the
usage table can load an entry. If the entry we want to load is within x
positions of the last entry of the usage table, the method cannot
succeed for the aforementioned reason.

Change-Id: Iccdaf538cb4bcbd34855f36c71aceaeb93b4a770
2019-01-25 11:32:13 -08:00
Rahul Frias
7982f0848d Report provider client token
[ Merge of http://go/wvgerrit/71103 ]

A content provider may specify a provider client token in a license.
This is a client token generated by a provider. If present in a license,
they will now be included in a license renewal request.

Bug: 34386290
Test: WV unit/integration tests
Change-Id: I3db303ea4d8b4ff4495393be4015b49e13db2ffc
2019-01-24 21:59:19 -08:00
Srujan Gaddam
ee45468c22 Add relocs param to TerminateRuntime
Bugs: b/112824791, b/120287622 (partially)
Merge of http://go/wvgerrit/70772
Tests: GTS tests, Android + Linux unit/integration tests

The Level 3 added functionality to reuse mmap'd pages, and as part of
it, the signature for TerminateRuntime changed so the relocs object can
be used to free all the pages at OEMCrypto_Terminate.

Change-Id: If3253926d948dcf69c178b9843cdf40aa7856d50
2019-01-24 15:33:47 -08:00
Fred Gylys-Colwell
408509efdc Remove Test Keybox Again
Merge from Widevine repo of http://go/wvgerrit/69563

This CL also disables unit tests that depend on the old test keybox when run
against OEMCrypto v13 or earlier.

Unit tests that require a particular API level have been
removed.  This requirement for Android is tested in GTS tests.

Bug: 119316243
Test: unit tests
Change-Id: I9a13dbaee1693ecea906fd0184a8e2590dc5beed
2019-01-24 11:59:02 -08:00
John Bruce
85e2c6a026 Merge "Simplify How Request ID Indices are Generated" 2019-01-24 05:27:18 +00:00
John Bruce
dfeaa49cb7 Merge "Implement HttpSocket for Windows." 2019-01-24 05:24:49 +00:00
Rahul Frias
33885289ae Add CDM integration test for offline renewal and release
[ Merge of http://go/wvgerrit/70865 ]

Bug: 116643233
Test: WV unit/integration tests
Change-Id: I13aba71d120dc25950b8ccba4091800835aaaaf4
2019-01-23 15:51:37 -08:00
Rahul Frias
869fd8b0d6 Merge "Return error codes when storing or retrieving licenses" 2019-01-23 19:12:25 +00:00
Rahul Frias
8b61a03b5f Return error codes when storing or retrieving licenses
[ Merge of http://go/wvgerrit/70386 ]

This allows error codes from device files to be added as sub-errors when
errors such as GET_LICENSE_ERROR are encountered.

Bug: 112357085
Bug: 115382201
Test: WV unit/integration tests

Change-Id: I505a87086ce584efc7e482984c0f132ac5329e16
2019-01-23 18:16:53 +00:00
John W. Bruce
ca00dc7ae4 Simplify How Request ID Indices are Generated
(This is a merge of http://go/wvgerrit/70667)

Request ID Index generation has historically worked by incrementing a
shared variable in one place and reading it in another place and
trusting the fact that CdmLicense calls these operations in a certain
order and only once per session to give each session a unique value.
This patch cleans this up a bit, having each session store the current
Request ID Index at the same time as it stores its Request ID Base. This
guarantees that each CryptoSession will receive a unique but stable
combination of Base and ID rather than relying on the calling pattern.

Since all this generation happens during the same function, the full
Request ID can be generated up-front and stored, making
GenerateRequestId() no longer necessary.

This patch also simplifies the threading story around this shared state
by using a std::atomic<uint64_t>. Bringing the code that interacts with
the shared state together into one place and replacing it with atomic
operations will simplify locking around this code when CryptoSession
locking is revamped in a future patch.

Bug: 70889998
Bug: 118584039
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I12d2f6501f872f1973e5a9af5125ca03f23e5a56
2019-01-23 09:52:46 -08:00
Jeff Tinker
bf6245967e Add securityLevel to MediaDrm isCryptoSchemeSupported API
bug:110701831
test: cts media test cases, widevine integration tests

Change-Id: I4a8973537b4b90740cdaf79a36e73943bcf074fb
2019-01-22 23:27:48 +00:00
Rahul Frias
45b3f5761e Add a static method to query security level
[ Merge of http://go/wvgerrit/70665 ]

This allows one to be able to query for security level, from
Crypto factory methods before the plugins and CdmEngine objects
have been created.

Bug: 117104043
Test: WV Unit/integration tests
Change-Id: Id07f420c3cfb92166cd3bb3cf82148d52e10eb03
2019-01-22 12:17:51 -08:00
Jeff Tinker
81e77bda58 Merge "Add support for HDCP 2.3" 2019-01-19 05:48:02 +00:00
Adam Stone
700ee5160a Add session metric pruning.
[ Merge of http://go/wvgerrit/65983 ]

Add support to drop closed metrics in order to save space for
long-running applications (and CdmEngine instances). The code now keeps
only a limited number of metrics collections after the session is closed.
As a session (and its metrics session) is closed, the oldest, closed metrics
session is dropped. This means those metrics will not be reported nor
accessible in the client.

Bug: http://b/118664842

Test: CDM Unit tests. Android Unit Test. Ran GPLay Manually.
Change-Id: I27d6e61a8fe4148ad1ef2a433c8e5f4cdd84cc72
2019-01-17 13:30:11 -08:00
Rahul Frias
675b934406 Modified return values for Restore operations
[ Merge of http://go/wvgerrit/70543 ]

RestoreOfflineLicense and RestoreLicenseForRelease now return
CdmResponseType errors rather than a boolean. These error codes
can now be used when gathering metrics.

Bug: 115517916
Test: WV unit/integration tests
Change-Id: If4784d2cdd9825948c5dec31d3e60058ea06b61d
2019-01-17 00:09:38 -08:00
Jacob Trimble
39028534fa Implement HttpSocket for Windows.
(This is a merge of http://go/wvgerrit/70304)

Test: build_and_run_all_unit_tests
Bug: 122953649
Change-Id: I6f201f460a0779a23e72db2bbc5d22e3f47cdd42
2019-01-16 20:06:37 -08:00
Srujan Gaddam
92e123d8ea Merge "Fix handling of INSUFFICIENT_RESOURCES in LoadEntry" 2019-01-17 03:33:49 +00:00
John Bruce
cfe7221d9e Merge "Fix IV handling for pattern encryption." 2019-01-17 03:07:56 +00:00
John W. Bruce
ff7f8c00bf Fix IV handling for pattern encryption.
(This is a merge of modmaker@'s change from the Widevine repo,
http://go/wvgerrit/48880)

When using pattern encryption, WVCryptoPlugin needs to increment the
IV after each subsample.  It should increment it based on the number
of actually encrypted samples (i.e. ignore clear data caused by
subsamples or pattern encryption).

In the common encryption spec, section 9.6.1 states:

  If the last Block pattern in a Subsample is incomplete, the partial
  pattern SHALL be followed until truncated by the BytesOfProtectedData
  size and any partial crypt_byte_block SHALL remain unencrypted.

This fixes the counting of encrypted blocks to account for partial
patterns.  This also makes it more efficient by removing the loop.

Bug: 111001481
Test: build_and_run_all_unit_tests
Test: Widevine GTS Tests
Change-Id: Ibd2bf10f64461b9bce10ef07453096fe4a4f6376
2019-01-16 16:34:52 -08:00
John Bruce
0c194ff115 Merge "Re-enable Binary Provisioning Test Again" 2019-01-17 00:30:42 +00:00
John Bruce
3b328bb896 Merge "Make Properties::Init() Take Action Only Once" 2019-01-17 00:30:07 +00:00
John W. Bruce
0a365da715 Add platform.cpp to Additional Build Files
(This is a merge of http://go/wvgerrit/70303)

The new platform.cpp file was not added to every build file that needs
to reference it. This was not detected as all of these platforms are
non-Windows, and platform.cpp is only required on Windows builds right
now. To avoid future problems should it ever provide non-Windows
functionality, though, I am adding it to the build files now.

Bug: 122953649
Test: Android Build
Change-Id: I57b983ad078dfef198b7c3e97fb93336b09704b6
2019-01-16 11:07:38 -08:00
John W. Bruce
777abaef01 Add some platform abstractions.
(This is a merge of http://go/wvgerrit/70303)

This adds a platform.h file to abstract some of the differences
between Windows and POSIX platforms.  This includes ntohl, setenv,
and ssize_t.

Bug: 122953649
Test: Android Unit Tests
Change-Id: I3235f3f284b53d24d7365ff3f4a06dcd9b403697
2019-01-16 11:06:55 -08:00
John W. Bruce
1cd093795e Resolve Merge Disparity
The same merge conflict happened in the Widevine and Android repos, but
it was resolved differently. This patch brings the resolutions back in
sync.

Bug: 111504510
Bug: 111505796
Bug: 115358798
Test: Android Build
Change-Id: I5161ae3e1aad41ee034dc5fec59dad1c7699d65c
2019-01-15 16:46:14 -08:00
John W. Bruce
e12a837e14 Re-enable Binary Provisioning Test Again
(This is a merge of http://go/wvgerrit/70384)

It turns out the reason the binary provisioning unit test was failing is
because the test base class was setting the property to turn on binary
provisioning before calling Init(), however all current Init()
implementations overwrite the value of that field. As such, the tests
weren't actually using binary provisioning. With that fixed, everything
passes; the binary provisioning flow doesn't appear to actually be
broken.

This is the exact same commit as was previously reverted,
cf5464d7a2fbecd1938ae0700199145b7b61c3c3. However, a pending patch fixes
the multiple runs of Properties::Init() that lead to the inconsistent
failures of the previous patch. (See http://go/wvgerrit/70383)

Bug: 112046733
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I79fc2c8d4d24505b46cab0e21eef85a37d66748d
2019-01-15 16:28:01 -08:00
John W. Bruce
86efc7534a Make Properties::Init() Take Action Only Once
(This is a merge of http://go/wvgerrit/70383)

Up until now, implementations of Properties::Init() have had to handle
potentially being called multiple times, at any point during runtime. In
practice, this has meant little for the actual implementations, and all
of them have committed the error of blowing away mutated property state
if the method is re-run at the wrong time.

This patch makes the platform implementations a private function,
Properties::InitOnce(), which Properties::Init() ensures will never be
called more than once per run.

Bug: 112046733
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: If33f5e37abfad5d26da8380b4bc25fc018450970
2019-01-15 16:27:57 -08:00
Jeff Tinker
7c0cd2582b Add support for HDCP 2.3
bug:120040804
Change-Id: I51e0d173edc36d518e12b821ccb3a7b1e7e8d217
2019-01-15 10:12:55 -08:00
Rahul Frias
ef00d6ffa5 Update property retrival method
[ Merge of http://go/wvgerrit/70203 ]

The earlier property_get() method had a limitation on property length.
Properties of some new devices exceed that length. An error message
is returned rather than a truncated string. Replace its use with
android::base::GetProperty() which does not have a length limitation.

Bug: 115358798
Test: WV unit/integration tests
Change-Id: I46ce9a7e77bcd031225d0082f83c57d484fe5405
2019-01-15 00:24:52 -08:00
Jeff Tinker
a4e66ac673 Merge "Add additional error conditions to MediaDrm" 2019-01-15 01:22:14 +00:00
Rahul Frias
9df3421eea Add logging to Usage Table Header
[ Merge of http://go/wvgerrit/70227 ]

This logs additional information especially usage table entry numbers

Bug: 122829543
Test: WV unit/integration tests
Change-Id: I7ff5a0697f9c10daa30a13e5fa9c1641f0740b6e
2019-01-14 12:13:12 -08:00
Rahul Frias
5d6c12ff5d Add additional logging to Cdm Engine
[ Merge of http://go/wvgerrit/69965 ]

Bug: 120786527
Test: WV unit/integration tests
Change-Id: I8fea89b25435c3a3b632155fe6a2b07349b63a19
2019-01-11 14:01:49 -08:00