Commit Graph

2134 Commits

Author SHA1 Message Date
Rahul Frias
5da8da58f6 Corrections for big usage table support in L3
[ Merge of http://go/wvgerrit/26421 ]

* Corrects usage_table_header lifetime management. Earlier the
  UsageTableHeader class was a singleton tied to the CdmEngine lifetime.
  With SPOIDs there might be multiple concurrent CdmEngine objects.
  The UsageTableHeader class is now associated with OEMCrypto
  lifetime. There are two UsageTableHeader objects one for each L1 and L3.
  These get allocated/deallocated on OEMCrypto Initialization/Termination
  respectively.
* UsageTableHeader requires OEMCrypto, file read/writes and
  metric gathering to perform its required functionality. Because of the
  lifetime changes, CryptoSession, DeviceFiles and MetricsGroup objects
  need to passed to the methods rather than at Creation time.
* Miscellaneous fixes, when moving or deleteing entries.
* Adds usage_table_header_unittests.
* Addresses failures with request_license_test with secure stop in L3.

b/36858906
b/36855557
b/36048120
b/38341136
b/37100505
b/35946047

Test: Verified by unit and integration tests. Added new
      usage_table_header_unittests

Change-Id: I20e396ab2c0afbd14372dd93b969e5b0f1ccd291
2017-05-31 00:37:58 -07:00
TreeHugger Robot
45c98e47f2 Merge "Revert "Fix widevine drm hal resource leaks"" into oc-dev 2017-05-17 23:47:19 +00:00
Jeff Tinker
d2080a8b9f Revert "Fix widevine drm hal resource leaks"
This reverts commit 006506278a.

It needs to be reverted to fix b/38343960 on marlin.

This change is not needed since the root cause of the
resource leak was addressed in ag/2226738. 

Change-Id: I93b64d39103d574b7dcde6b1477839a50b64aefd
2017-05-16 22:20:20 +00:00
TreeHugger Robot
27deb32b79 Merge "Fix widevine drm hal resource leaks" into oc-dev 2017-05-15 19:53:54 +00:00
Fred Gylys-Colwell
0a02017009 Merge "Avoid calling DeleteUsageEntry for OEMCrypto v13" into oc-dev 2017-05-13 05:39:10 +00:00
Edwin Wong
dcf78b1062 Merge "Fix GTS testL3PlayHDCPV* tests." into oc-dev 2017-05-13 04:15:55 +00:00
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
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
Jeff Tinker
006506278a Fix widevine drm hal resource leaks
A strong pointer cycle was preventing the drm plugin
from being released.  This change converts the listener
to a weak pointer to break the cycle.

bug:36408047
test: manual testing to verify leaks are fixed
Change-Id: I2e2af392c2b263b7b0943d61dcaee5e94089ce27
2017-05-09 14:31:07 -07: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
Fred Gylys-Colwell
35fc4edc11 Remove unused variables from mips build
Merge from Widevine repo of http://go/wvgerrit/26940

b/38014227
b/38016711
Test: built sdk_phone_mips

Change-Id: Ibcdbf49f96e976f51c38db25a944268a86a1671e
2017-05-05 07:55:36 -07:00
Fred Gylys-Colwell
38b5e8c71c Refresh Current Key in Level 3
Merge from Widevine repo of http://go/wvgerrit/26780
and http://go/wvgerrit/26740

Previously, in oemcrypto level 3, a session's current key's duration
was not updated until the next call to SelectKey.  This caused
problems with license that only used one key.  This CL fixes that.

arm64/libwvlevel3.a            Level3 Library 7283 May  2 2017 13:16:21
arm/libwvlevel3.a              Level3 Library 4445 May  2 2017 11:49:34
x86_64/libwvlevel3.a           Level3 Library 7284 May  2 2017 12:09:21
x86/libwvlevel3.a              Level3 Library 4464 May  2 2017 11:53:46

Test: unit tests run on emulator.
b/37481239
b/37523523

Change-Id: Ife90a3358b6620c8fb81324ec2331d3775a38191
2017-05-03 11:53:49 -07: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
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
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
John Bruce
9574bc849a Merge "Move SPOID Enable/Disable Logic Out of WVDrmPlugin" into oc-dev 2017-04-20 17:19:50 +00:00
Rahul Frias
518ce632f7 Merge "Prevent segfaults when a session is deallocated" into oc-dev 2017-04-20 17:19:45 +00:00
Fred Gylys-Colwell
45bf89ff8b Replace mips library with stubs file
Merge from Widevine repo of http://go/wvgerrit/26202

This is a workaround to fix a broken mips build.

Test: Built for sdk_phone_mips.
b/37523523

Change-Id: I56ce65919303113f712d422d33e335b594292d42
2017-04-19 21:16:57 -07: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
John W. Bruce
68d26ef98b Remove API Version TODO Comments
(This is a merge of http://go/wvgerrit/26221)

We have agreed on API 26 for O, so these comments can be removed without
making any further changes.

Bug: 34548395
Test: This is a comment-only change. But I verified it builds.
Change-Id: I490befba4f47902a84b60e562a7a5eb162a9f3be
2017-04-19 16:48:14 -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
John W. Bruce
c0a7655834 Maxing Out Sessions Can Cause SPOID Failures
(This is a merge of http://go/wvgerrit/25581)

To prevent dead DRM Plugins from being instantiated when there are no
sessions available, the time at which the device ID is queried has been
moved from instantiation-time to SPOID-calculation-time.

SPOIDs can now fail to be generated. Which means anything that depends
on a SPOID may fail because of this. However, this is a more actionable
problem for apps than having them receive a dead or unusable DRM Plugin
object.

Bug: 36660726
Test: libwvdrmdrmplugin_hidl_test
Change-Id: Ice6a8eabfee8d48bf2af02e2e7169aa95af9f2e4
2017-04-18 10:25:39 -07:00
John W. Bruce
19947dfe6f Move SPOID Enable/Disable Logic Out of WVDrmPlugin
(This is a merge of http://go/wvgerrit/25580)

While writing fixes for b/36660726, b/34716264, and b/36065223, it
became clear that having the logic that checks whether the device
supports SPOIDs embedded inside WVDrmPlugin was complicating its code
and inhibiting testing of the class. By moving this check into the code
that instantiates WVDrmPlugin, the result of the calculation can be
independently tested while the tests for WVDrmPlugin can put it in
whatever state they need for the sake of unit testing.

As a consequence of this, the check on retrieving the "deviceUniqueId"
byte array property, which was removed when SPOIDs were implemented, can
be reinstated.

Bug: 36660726
Bug: 34716264
Bug: 36065223
Test: libwvdrmdrmplugin_hidl_test & libwvdrmengine_hidl_test
Change-Id: I961d2ee42bbdc42f0c324e36d9a74ac92205a437
2017-04-18 09:56:58 -07: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
TreeHugger Robot
6116fdb97a Merge "Translate CDM session not opened errors" into oc-dev 2017-04-14 21:38:30 +00:00
TreeHugger Robot
45910edd19 Merge "Add an offline test asset for the drm vts test" into oc-dev 2017-04-14 21:38:30 +00: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
Iliyan Malchev
28b89a9b4f Route drm@1.0-service.widevine libbinder to /dev/vndbinder
b/37309712: [Marlin/Sailfish] Fatal signal 6 (SIGABRT) when playing Exo
	    Player L1 encrypted content
Test: marlin

Change-Id: I05b12ea334138498be13bca92c9b1db6ed1b9870
Signed-off-by: Iliyan Malchev <malchev@google.com>
2017-04-14 01:22:04 -07:00
Jeff Tinker
3914953bff Add an offline test asset for the drm vts test
To test restoreKeys, a content configuration with a
license policy allowing offline playaback was needed.

Test: drm vts test

bug:34178477
Change-Id: Ib90d7a878c0f310569abb09f21138c7a6ac9daae
2017-04-14 00:30:07 -07:00
Jeff Tinker
f5240b69e4 Translate CDM session not opened errors
The drm hidl hal specifies that operations on sessions that
are not opened return ERROR_DRM_SESSION_NOT_OPENED.  This
change adds that translation, previously they were mapped
to unknown error.

Test: drm vts test

bug:34178477
Change-Id: I3777dd90eea7061f3fa5413a5732d7d58b85b49b
2017-04-14 00:28:47 -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
ce62e1d7e7 Correct error returned when license is for the future
[ Merge of http://go/wvgerrit/25721 ]

Return CryptoException with errorCode ERROR_NO_KEY when an attempt is made
to make use of a license whose start time is in the future.

Test: Verified by WidevineDashPolicyTests#testL1LicenseStart2030

b/31914841

Change-Id: I2a157c227550a2391b6536365f34f1dfec3dea0c
2017-04-12 13:20:44 -07:00
John Bruce
1b0d67f368 Merge "Always Report OEMCrypto_ERROR_KEY_EXPIRED as NEED_KEY" into oc-dev 2017-04-12 17:48:58 +00:00
TreeHugger Robot
cc28abea0b Merge "Disable MinVersionNumber13 Test *DO NOT MERGE*" into oc-dev 2017-04-12 01:37:18 +00:00
TreeHugger Robot
dbaacf9232 Merge "Address merge comments" into oc-dev 2017-04-11 23:57:19 +00: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