Commit Graph

727 Commits

Author SHA1 Message Date
Fred Gylys-Colwell
7d5b88a06a Avoid calling DeleteUsageEntry for OEMCrypto v13
Merge from Widevine repo of http://go/wvgerrit/27182

This function is not defined for v13, and should not be called by the
adapter.

b/38203780
Test: Ran unit tests specified in bug, on sailfish.

Change-Id: I38b1cc8493dd22da724f415f28d94f47d6d9c942
2017-05-12 17:26:24 -07:00
Edwin Wong
d751e81790 Fix GTS testL3PlayHDCPV* tests.
These tests verify whether a L3 device respects the HDCP policy set in the
license request. L3 device should only play the clear lead, and stop at
encrypted content. MeidaDrm should throw an ERROR_INSUFFICIENT_OUTPUT_PROTECTION
exception. This is because L3 device always returns current HDCP connection
status as HDCP_NONE.

This CL modifies the policy engine CanDecryptContent method to return
CdmResponseType instead of a boolean, so the app can generate the correct
error response if HDCP constriants are not met.

Test: GTS tests
  ANDROID_BUILD_TOP= ./android-gts/tooadefed run gts -m GtsMediaTestCases --test
  com.google.android.media.gts.WidevineDashPolicyTests#testL3PlayHDCPV*Required

Test: unit tests
  adb shell /data/app/policy_engine_unittest
  adb shell /data/app/policy_engine_constraints_unittest

Test: Play Movies

bug: 34258607
Change-Id: I11fc9da1e077e18e38f34159daae9d8ebcd948b6
2017-05-12 16:55:26 -07:00
Rahul Frias
adce58d758 Fix deadlock when pending key release sessions are deallocated am: 02fe2ef693
am: 54876569de

Change-Id: I86596123026ea88bb95178fbd48182101cc4ea1c
2017-05-12 22:29:26 +00:00
Rahul Frias
02fe2ef693 Fix deadlock when pending key release sessions are deallocated
[ Merge from http://go/wvgerrit/27261/ ]

Sessions created to release keys are periodically cleaned up if the
key release operation does not complete within a specific
amount of time. If other sessions are open, they will be released
through the timer thread. This would result in deadlock as a mutex
was taken twice.

Test: Verified by cdm_extended_duration_test
(AutomatedOfflineSessionReleaseOnOpenSession and
AutomatedOfflineSessionReleaseOnTimerEvent tests)

b/37546078

Change-Id: I7d45f939bdce77e5db461a401364da4f42c1c034
2017-05-11 20:12:33 -07:00
Tomasz Wasilczyk
33f9979b2b Convert libwvdrmengine to soong.
Bug: 37512442
Test: mmm -j50 vendor/widevine/libwvdrmengine/
Change-Id: I45b06b7f14ca4f65031bbc3806808a191156ee7b
2017-05-11 11:10:37 -07:00
Fred Gylys-Colwell
751d4b0d71 Remove TODO logs from dynamic adapter am: ee283ec61c
am: e76930cf14

Change-Id: Id4f6c9cd0dc8f303e11609b2530ec288764ac0e6
2017-05-06 01:39:17 +00:00
Fred Gylys-Colwell
ee283ec61c Remove TODO logs from dynamic adapter
Merge from Widevine repo of http://go/wvgerrit/26943

b/37987506

Test: built and run unit tests on sailfish -- no new failures.  Ran
Netflix on sailfish.

Change-Id: I96f8bb7a5c060fefd116b165406ce6bfad29f59d
2017-05-05 17:00:08 -07:00
John W. Bruce
a5310bcf0c Prefix ENABLE_MEDIADRM_64 with TARGET_ am: 6262f3721f
am: 2e337abdfb

Change-Id: Iae43cc735930b4d04f7990e7b7c28fd3dd74d7e5
2017-04-29 00:02:00 +00:00
John W. Bruce
6262f3721f Prefix ENABLE_MEDIADRM_64 with TARGET_
This build-time flag should be prefixed.

Bug: 37039525
Test: Built OS
Change-Id: Ie1db1f05bdaf43e4066d26a41391af0d7c729128
2017-04-27 18:50:05 -07:00
John Bruce
f76986d707 Merge changes I490befba,I32512a3e into oc-dev am: e434bb3975
am: 64cbdf8204

Change-Id: I88e8d382c6057f23973656a4cbf767bf00dc0ba1
2017-04-21 05:49:37 +00:00
John Bruce
e434bb3975 Merge changes I490befba,I32512a3e into oc-dev
* changes:
  Remove API Version TODO Comments
  Define Provisioning-Unique ID for New Device IDs
2017-04-21 05:38:38 +00:00
Fred Gylys-Colwell
426e53bbbf OEMCrypto Mock SRM functionality
Merge from Widevine repo of http://go/wvgerrit/24730

This CL adds SRM functionality to the modable version of oemcrypto
mock.  This can be used for end-to-end testing.

b/28955873
b/37353534

Change-Id: I2c6f513495ccfd42f7a3d7a3449db6f810563c04
2017-04-20 14:50:43 -07:00
John Bruce
3c37343e5c Merge changes Ib82cf7a1,Ice6a8eab into oc-dev
* changes:
  Hash OEM Certificate
  Maxing Out Sessions Can Cause SPOID Failures
2017-04-20 17:21:46 +00:00
Rahul Frias
f2fccc20cd Prevent segfaults when a session is deallocated
[ Merge of http://go/wvgerrit/26201 ]

Race conditions arose when a session was closed while data was
still queued for decryption in MediaCodec buffers. If a session
is closed while data is still queued for decryption, subsequent
decryption requests will be rejected with a CryptoException
ERROR_SESSION_NOT_OPENED.

Test: Verified by wv unit/integration test and
      WvCdmExtendedDurationTest.DecryptionCloseSessionConcurrencyTest

b/36747801

Change-Id: I044d1d6b9fc886a1c353d20b9c6365319aa71e80
2017-04-19 19:24:04 -07:00
Rahul Frias
c2969ef0f4 Merge changes I9039bc1f,I43758cd2 into oc-dev
* changes:
  Allow decryption of unencrypted data before key has been retrieved
  Correct CryptoException error returned before keys have been loaded
2017-04-19 23:40:51 +00:00
John W. Bruce
ce6bd41627 Define Provisioning-Unique ID for New Device IDs
(This is a merge of wvgerrit/25583)

Devices that use Provisioning 3.0 did not have a Provisioning-Unique ID
defined. Attempting to retrieve it would result in an error.

Devices that use SPOIDs with keyboxes would expose the keybox's real
Provisioning-Unique ID when asked. This is a security flaw.

To solve both cases, an alternative Provisioning-Unique ID is used,
consisting of the Device-Unique ID bitwise-inverted.

Bug: 36065223
Test: run_all_unit_tests.sh
Change-Id: I32512a3e11403e679939187e156904a57a9e24ef
2017-04-19 16:35:29 -07:00
John W. Bruce
8513b71499 Hash OEM Certificate
(This is a merge of wvgerrit/25582)

Provisioning 3.0 devices that do not use SPOIDs have been returning
their full OEM Public Certificate as their device ID. While this is not
a security concern, (it is a PUBLIC cert) the cert is many times larger
than applications are likely expecting. (several kilobytes vs. just a
few bytes) This patch hashes the OEM Public Certificate to produce a
smaller value, but only when it is being provided out of the CDM to a
caller.

Bug: 34716264
Test: run_all_unit_tests.sh
Change-Id: Ib82cf7a174a8bf02ff606edd0394ada13842224c
2017-04-19 16:03:22 -07:00
John W. Bruce
76d3ca9091 Rebuild Haystack and Store L3 Keybox in /data/vendor
(This is a merge of http://go/wvgerrit/25900 and http://go/wvgerrit/25920)

This commit contains the latest Haystack prebuilt binaries based on
the latest OEMCrypto code in the Widevine tree. This is to pick up the
change "Report error OEMCrypto_ERROR_ENTRY_IN_USE", which fixes
several failing unit tests. This CL also adjusts the L3 library so
that it stores its data in the directory specified by the layer above.

level3/x86_64/libwvlevel3.a    Level3 Library 7284 Apr 13 2017 16:58:07
level3/arm/libwvlevel3.a       Level3 Library 4445 Apr 13 2017 16:48:19
level3/mips64/libwvlevel3.a    Level3 Library 7285 Apr 13 2017 23:52:51
level3/mips/libwvlevel3.a      Level3 Library 4465 Apr 13 2017 23:16:02
level3/arm64/libwvlevel3.a     Level3 Library 7283 Apr 13 2017 17:05:12
level3/x86/libwvlevel3.a       Level3 Library 4464 Apr 13 2017 16:36:25

Bug: 36656178
Bug: 37210088
Test: build_and_run_all_unit_tests.sh and GTS tests
Change-Id: Ia5b272cd945f0c9f2fe37ecd0f3ccd2f2ff398bc
2017-04-19 11:23:06 -07:00
Rahul Frias
6260d4d628 Merge "Allow OfflineLicenseRenewal test to be repeatedly invoked" into oc-dev 2017-04-19 18:11:48 +00:00
Rahul Frias
3b68424d1f Merge "Add usage information tests to device files unit tests" into oc-dev 2017-04-19 18:09:40 +00:00
Rahul Frias
0f374af4ab Allow decryption of unencrypted data before key has been retrieved
[ Merge of http://go/wvgerrit/25987 ]

Test: Added Cdm/WvCdmSessionSharingNoKeyTest to request_license_test.
      Verified by wv unit and integration tests.

b/28182987

Change-Id: I9039bc1fca83e2c1044c3af2f47f31dc4fb5c910
2017-04-19 00:47:40 -07:00
Rahul Frias
3d599197be Correct CryptoException error returned before keys have been loaded
[ Merge of http://go/wvgerrit/25983 ]

Earlier versions of android returned CryptoException with
error code ERROR_NO_KEY, when a decrypt call was received before keys were
loaded. Changes to O resulted in ERROR_SESSION_NOT_OPENED being returned
instead. This CL reverts the behaviour.

Also a change to correct CDM error code numbering in comments.

Test: Verified by unit and integration tests

b/37219830

Change-Id: I43758cd29cf9d1945f878ac352a5f26538b48cdb
2017-04-19 00:40:48 -07:00
Rahul Frias
80798ae11c Merge "Revert "Detect when unable to meet policy requirements"" into oc-dev 2017-04-18 20:37:22 +00:00
Rahul Frias
e733943729 Revert "Detect when unable to meet policy requirements"
This reverts commit 1223330ccc.

b/37460568

Change-Id: I936c06f679126ac50fb2d4753b4270b4ba42def5
2017-04-18 20:03:56 +00:00
Rahul Frias
551f4cb474 Merge "Detect when unable to meet policy requirements" into oc-dev 2017-04-15 06:50:05 +00:00
Rahul Frias
f655f329e2 Merge "Correct KeySetId value when returned by AddKey" into oc-dev 2017-04-15 06:37:06 +00:00
Rahul Frias
57bb6c29ca Add usage information tests to device files unit tests
[ Merge of http://go/wvgerrit/24445 ]

Test: Verified by wv unit and integration tests

b/36048120

Change-Id: I9d067e79654331e8e58df5dce5411fbadc73e575
2017-04-14 15:12:25 -07:00
Rahul Frias
5321b96623 Correct KeySetId value when returned by AddKey
[ Merge of http://go/wvgerrit/25643 ]

The MediaDrm#provideKeyResponse API states that an empty byte array is
returned when the license type is streaming or release but a non-empty
value was being returned in some cases.

The KeySetId is now returned when the license type is offline or when
the license is streaming and has a secure stop associated with it.

Test: Verified by request_license_test integration tests. Tests have been
      modified to validate the returned Key Set Id values.

b/36093612

Change-Id: I82dba537c77ddd1d1876cbce58729f3db901ee51
2017-04-14 07:54:01 -07:00
TreeHugger Robot
c3ea64aa89 Merge "Corrections to widevine plugin for vts tests" into oc-dev 2017-04-14 00:05:42 +00:00
Rahul Frias
1223330ccc Detect when unable to meet policy requirements
[ Merge of http://go/wvgerrit/25781 ]

The security level (software/hardware, decryption/decode)
in the policy that specified how the key was to be used was
not being respected for L3. Playback would either continue or
a vendor specific error would be thrown.

If the device cannot use the key as permitted by the policy
CryptoException#ERROR_INSUFFICIENT_OUTPUT_PROTECTION will be thrown.

Test: Verified by WV unit+integration tests.
      Verified by WidevineDashPolicyTests
      Verified by WidevineDashPolicyTests#testL3SoftwareSecureDecoderRequired,
      testL3HardwareSecureCryptoRequired, testL3HardwareSecureDecodeRequired,
      testL3SecureVideoPathRequired.

b/31913737
b/31913439

Change-Id: Ibfc7f3dd6fc7264e8cf9b0d33f6f8d619eed6c00
2017-04-13 16:50:10 -07:00
Jeff Tinker
6c15ea673d Corrections to widevine plugin for vts tests
Add a check for invalid session size in restoreKeys
and correct the return code when attempting to create a
plugin with an invalid uuid. Also correct the return code
when attempting to decrypt after keys have been removed.

bug:37172151
Change-Id: I7e832ffe04081471a0cdb3a9329808f47f12cfc3
2017-04-13 14:53:12 -07:00
Rahul Frias
b474ba042e Allow OfflineLicenseRenewal test to be repeatedly invoked
[ Merge of http://go/wvgerrit/25720 ]

Test: Repeatedly invoke WvCdmRequestLicenseTest.OfflineLicenseRenewal

b/28915200

Change-Id: I5be6be02d09ced1a7ba8bac2c8706f199d063db8
2017-04-11 16:40:16 -07:00
John W. Bruce
7f27e5a266 Always Report OEMCrypto_ERROR_KEY_EXPIRED as NEED_KEY
(This is a merge of wvgerrit/25422)

OEMCrypto_ERROR_KEY_EXPIRED was not always being reported to the higher
layers as a NEED_KEY error, which could cause inconsistent error
handling.

Bug: 28294273
Test: Unit tests
Change-Id: Idf5642ea0f0ba915bc1f53025a1f14691d142aed
2017-04-10 16:49:44 -07:00
John W. Bruce
b99a4c736f Turn on 64-bit Executables on Supported Platforms
This commit changes the unit tests and HAL Service to run as 64-bit on
devices that have enabled 64-bit DRM Plugins.

Bug: 36076017
Test: Turned on the flag for a device and used the file command to
      verify that all binaries were built as 64-bit.
Test: Turned the flag back off and verified that all binaries were built
      as 32-bit. This should affect no current devices.
Change-Id: Ieb7218f15b9359f2038a6f60b8c994b16d2b5b53
2017-04-01 19:05:30 -07:00
John Bruce
0fba3719e7 Merge "Fix & Improve Test-Building and -Running Scripts" into oc-dev 2017-03-31 00:56:55 +00:00
John W. Bruce
f2463075ac Fix & Improve Test-Building and -Running Scripts
(This is a merge of wvgerrit/24922)

This contains several fixes and improvements to the
build_and_run_all_unit_tests.sh and run_all_unit_tests.sh scripts:

* All tests are now identified as vendor binaries and thus are stored in
  the /vendor/bin/ directory instead of /system/bin/. Previously, some
  tests had moved to /vendor/bin/ but the scripts had not been updated,
  causing these tests to fail to run.
* The -j parameter can now be passed to build_and_run_all_unit_tests.sh,
  for those who want to speed up their build by using multiple cores.
* The 64-bit library directories are now added to the library search
  path, in anticipation of devices with 64-bit DRM Plugins.
* Checking for Verity protection is now done in
  build_and_run_all_unit_tests.sh (which is the script that actually
  modifies the file system) instead of just in run_all_unit_tests.sh.
* The library search path is no longer set unnecessarily for
  libwvdrmengine_hidl_test.
* The Treble-only tests and non-Treble-only tests now only run on
  devices that meet their respective criteria.

Bug: 36071236
Test: Ran build_and_run_all_unit_tests.sh
Change-Id: Iea236880c4445858111c801dfa278a528bca0f6c
2017-03-29 19:01:04 -07:00
Edwin Wong
957d4a30dd Fix testOEMCryptoVersion
Merge from go/wvgerrit/24882:

The result of crypto_session.GetApiVersion is misinterpreted.

Test: ANDROID_BUILD_TOP= -gts/tools/gts-tradefed run gts
 -m GtsMediaTestCases --test com.google.android.media.gts.
 MediaDrmTest#testOemCryptoVersion

Test: ANDROID_BUILD_TOP= -gts/tools/gts-tradefed run gts
 -m GtsMediaTestCases --test com.google.android.media.gts.
 MediaDrmTest

bug: 36728950
Change-Id: I72a05608f778fa81689013d3b231010b71329ea1
2017-03-29 15:49:59 -07:00
Edwin Wong
54061a8bb8 Widevine HAL must not access mediametrics binder service.
Widevine HAL is not part of framework/system image and thus it is not
permitted to use Binder. Binder-like mechanisms which are permitted are
HwBinder  or VendorBinder (for communications only with vendor image
components).

Remove references to MediaAnalyticsItems used by ami_adapter.*.

Test: Play Movies & TV (streaming and pinned content)
Test: Netflix
Test: Widevine unit tests

bug: 36576915
Change-Id: I786f206c01d7c5ebfce719f3f51f5f7927f0359e
2017-03-28 14:24:02 -07:00
John W. Bruce
bfe6046199 Build Android Unit Tests 32-bit Only
(This is a merge of http://go/wvgerrit/24738)

The change to enable 64-bit as a possible target for Widevine Android
made all the unit tests build as 64-bit on compatible platforms. Since
none of these devices support 64-bit properly yet, this is a mistake.
This patch restores unit test builds to being 32-bit only for now.

In the future, when the switch for 64-bit-supporting devices is added,
it will also switch the unit tests to 64-bit mode.

Bug: 36071236
Test: Verified unit test format with "file" command.
Change-Id: Ib4d3678181f3221b85fe6409f1d842dd15af3daa
2017-03-23 17:09:15 -07:00
Fred Gylys-Colwell
85365a1497 Fix or ignore compiler warnings
Merge from Widevine repo of http://go/wvgerrit/24688

b/35466719

Change-Id: If89f0cad0c61f37536a84f8dadaf08072356343a
2017-03-22 14:07:08 -07:00
Rahul Frias
2ec7ec27bb Address warnings in CDM unittests
[ Merge of http://go/wvgerrit/24600 ]

Test: Unit test only change. Verified by rerunning unittests.

b/36221430

Change-Id: I36a8a0a5df400673689280cbf53ba9394f827c90
2017-03-14 12:13:12 -07:00
Adam Stone
dd88c13fb1 Trim unnecessary CDM metrics.
Bug: 35269103
Test: Removing unnecessary code. Existing tests pass.
Change-Id: I1ba8572a8b3fabbf707e77b366717c9ba3069ace
2017-03-13 19:10:39 -07:00
Fred Gylys-Colwell
ca2f1641c3 Merge changes I2f7052b6,Ifbfaf97c
* changes:
  Test Cleanup
  Report error OEMCrypto_ERROR_ENTRY_IN_USE
2017-03-08 20:44:36 +00:00
Fred Gylys-Colwell
2dbc81318a Merge "Give Nonce Error Explicit Name" 2017-03-08 20:44:00 +00:00
TreeHugger Robot
1322df2d28 Merge "Clean up how metrics were disabled" 2017-03-07 03:55:47 +00:00
Fred Gylys-Colwell
9bd9bcd61a Test Cleanup
Some tests code was not correctly merged from the widevine side.

An initializer in generic_crypto_unittest.cpp was missed in
http://go/wvgerrit/23767

bug: 35951647

Change-Id: I2f7052b621989a032179346edf43dcaf6cb7d921
2017-03-03 21:30:02 +00:00
Fred Gylys-Colwell
14c3a3865a Give Nonce Error Explicit Name
Merge from widevine repo of http://go/wvgerrit/24421

A nonce generation error for a certificate provisioning request had a
generic name Error2.  However, this is an actionable error by the
application: the application should wait 1 second and try again.
Therefore it deserves a more descriptive name.

bug: 35926133
bug: 35879493

Change-Id: I6c87a5a762cb970c9530a55c993d7acbed773a00
2017-03-03 21:25:20 +00:00
John Bruce
1178b10992 Merge "Enable 64-bit Android Builds" 2017-03-02 04:33:31 +00:00
Fred Gylys-Colwell
872fd1077e Merge "Avoid Nonce Flood in core/test/cdm_engine_test.cpp" 2017-03-02 03:46:58 +00:00
John W. Bruce
df0dad5311 Enable 64-bit Android Builds
(This is a merge of go/wvgerrit/23686)

This patch removes the makefile lines that previously prevented the
Widevine DRM Plugin from being built as 64-bit on Android. 64-bit
builds are now fully supported.

Only one piece of CDM code has had to change. Due to a bug in
libprotobuf before v3.0, int64 values from protobufs are technically a
different type from int64_t values in code on some 64-bit
architectures. Both have the same in-memory representation at runtime
but are seen as distinct types by the compiler. The compiler will
automatically convert in most places, but template instantiation is
not one of them, so a few places that passed a Protobuf int64 directly
into a template had to be modified.

Please note that tweaks to the mediadrmserver (not covered by this
patch) are needed in order for it to run as 64-bit and load 64-bit DRM
Plugins. Please also note that, as we have no 64-bit L1 OEMCrypto on
any devices, using the 64-bit mediadrmserver and Widevine library will
make your device fall back to L3 for the time being.

Bug: 18949752
Test: OEMCrypto unit tests
Test: Widevine unit tests
Test: Google Play (on Marlin)
Test: Widevine GTS Tests (on Marlin)
Change-Id: Ib6cdf2dd1ff75a1c473cacdc5e22397caa0a656c
2017-03-02 02:58:56 +00:00