Commit Graph

121 Commits

Author SHA1 Message Date
Kyle Zhang
5070a7b949 Exposing the Cast Signing Algorithm
1. Exposing the Cast Signing Algorithm in cdm core.
2. Update core Cast tests to use new core CDM Cast signing API.

Bug: 279671867
Bug: 279672538
Change-Id: Ia73c4b5e6dd61edf790bca97a321881d310e7a99
2024-01-26 17:05:58 -08:00
Kyle Zhang
81a63e05ae Add dumping provision request functionality
[ Merge of http://go/wvgerrit/179590 ]

Bug: 277788529
Test: dumpsys android.hardware.drm.IDrmFactory/widevine -prov
Change-Id: Ife88d1323bf5ee423eb8827ca324b73db3cc984a
(cherry picked from commit afbfe173a8)
2023-07-31 19:32:08 +00:00
Alex Dale
37f125a491 Piped CdmEngine's generic crypto operations to Android CDM.
[ Merge of http://go/wvgerrit/172010 ]

The CdmEngine provides an API for generic crypto operations that are
already used for the CE CDM.  This API is being exposed in the Android
CDM.  The parameter order of the Android CDM is modified to match the
existing generic crypto parameters used in the media DRM plugin.

Bug: 274984456
Bug: 29400687
Test: build x86-64 and Android
Change-Id: I3b286ebb011bd58754b7b8ea814ed46daf1f62f9
2023-05-01 15:50:39 -07:00
Alex Dale
1e1f11f5b1 Fixed WV metrics YAML formating.
[ Merge of http://go/wvgerrit/171270 ]

The metrics dump tool for the Widevine DRM factory was producing
malformed YAML output.  This is compounded by the formatting using
fixed indentation for its output.

Bug: 239462891
Test: adb shell dumpsys android.hardware.drm.IDrmFactory/widevine -m
Test: atest GtsMediaTestCases
Change-Id: I784d107085721ad0dabe94bdab33e9cc073f98e4
2023-04-21 13:32:52 -07:00
Alex Dale
52bd76e0e2 Fixed test and log formatting for CdmResponseType.
[ Merge of http://go/wvgerrit/168397 ]

When CdmResponseType (enum) was transformed to CdmResponseType
(struct), the test printers where not updated to print the result
of failed comparisons.  In addition, several logs statements were
updated haphazardly, leaving inconsistencies and potential
compiler-specific behavior.

This CL replaces CdmResponseType std::string operator with a ToString()
method.  This is to make it consistent with Google's C++ style guide
on conversion operators vs methods.  The string conversion function is
now defined in wv_cdm_types.cpp instead of inline in the header file.

The PrintTo function has been implemented along with the other CDM
test printers in test_printers.cpp.

Bug: 273989359
Test: run_x86_64_tests
Test: MediaDrmParameterizedTests on redfin
Test: Forrest drm_compliance
Change-Id: Ibfaa17029046b75b1c8c278f7bd7e04a24379848
2023-03-27 11:21:45 -07:00
Fred Gylys-Colwell
ab8c06906a Fix logging error type
Merge from Widevine repo of http://go/wvgerrit/166942

The error type is no longer an enumeration.

Bug: 271146682

Change-Id: I64f60fde94d1e8a586128a59f1455041622444b6
2023-03-23 16:23:43 +00:00
Rahul Frias
f63a0b287d Remove comment.
Merged from https://widevine-internal-review.googlesource.com/164120

Based on review comment in PS10 of http://go/ag/20608670

Bug: 262797186
Test: GtsMediaTestCases
Change-Id: Ia54117ffd0882de161e772fc1ca180a8d3f27480
2023-02-22 15:53:42 -08:00
Rahul Frias
233bac3a6f Add error codes to support ATSC license installation
[ Merge of http://go/wvgerrit/163899 ]

Bug: 176871821
Test: WV Unit/integration/Luci tests
Test: libwvdrmdrmplugin_hal_test
Change-Id: I0153093433715b1357d3854043cc6362f9261c57
2022-12-21 11:55:08 -08:00
Kyle Zhang
11255b7426 Pick widevine oemcrypto-v18 change
No-Typo-Check: From a third party header file
Bug: 260918793
Test: unit tests
Test: atp v2/widevine-eng/drm_compliance
Change-Id: I36effd6a10a99bdb2399ab1f4a0fad026d607c70
2022-12-21 00:03:50 +00:00
Edwin Wong
4586522c07 Remove comment.
Merged from http://go/wvgerrit/163817

Based on review comment in PS10 of http://go/ag/ag/20608670

Test: Google TV
Test: atest MediaDrmParameterizedTests
Test: atest DrmSessionManagerTest

Bug: 262797186
Change-Id: I28ed90255df1a16fb252000f8a8a0f89246563c3
2022-12-16 19:16:33 +00:00
Robert Shih
1fdbd3cd2c aidl plugin: add error details to return status
Merged from http://go/wvgerrit/163639

Bug: 253271674
Test: Google TV
Test: atest MediaDrmParameterizedTests
Test: atest DrmSessionManagerTest
Change-Id: I9f0e83774d405466a389d2fd90d693830682dde4
2022-12-15 14:50:56 +00:00
Edwin Wong
b1fd332cc5 Fix mapCdmResponseType template.
Merged from http://go/wvgerrit/163457

mapCdmResponseType is called either with an enum or
a CdmResponseType struct.

Test: build android.hardware.drm-service.widevine
Test: Netflix and Play Movies & TV
Test: build_and_run_all_unit_tests.sh
Test: atest MediaDrmParameterizedTests
Test: atest DrmSessionManagerTest

Bug: 253271674
Bug: 262210157
Change-Id: Ieb9fccf33f54a98c67ddf7655d2a5ada7a946114
2022-12-12 20:48:46 +00:00
Robert Shih
096b0eda5a Squashed merge 3 CLs.
1. "Change CdmResponseType from enum into a struct"
Merged from http://go/wvgerrit/163199
Bug: 253271674

2. "Log request information when server returns 401"
Bug: 260760387
Bug: 186031735
Merged from http://go/wvgerrit/162798

3. "Specify server version on the command line"
Bug: 251599048
Merged from http://go/wvgerrit/158897

Test: build android.hardware.drm-service.widevine
Test: Netflix and Play Movies & TV
Test: build_and_run_all_unit_tests.sh

Bug: 253271674
Change-Id: I70c950acce070609ee0343920ec68e66b058bc23
2022-12-08 21:08:14 +00:00
Edwin Wong
e176b20509 Rename aidl_ include and src directories.
Test: unit tests
Test: Google TV and Netflix
Test: atest GtsMediaTestCases

Bug: 216527109
Change-Id: I3fd02c2c60da588dba3db27cea3593de25a7180f
2022-09-05 21:08:25 +00:00
TreeHugger Robot
0b02296014 Removing Non-HIDL Widevine DRM Plugin for Android
[ Merge of http://go/wvgerrit/138089 ]

Non-hidl code is no longer needed in the widevine android plugin. By
doing work this cleanup will save the team from having to keep
maintaining code that isn't needed anymore.
Clean up steps taken as follows:
    1. Remove non-hidl code but keep commonly used code
    2. Remove legacy test code
    3. Remove legacy test build and test entry

Bug: 69573078
Bug: 172285246
Test: unit tests, GtsMediaTestCases, CtsMediaDrmTestCases
Change-Id: I75938d69413c631ef6be82da3d885ba173efc581
2021-11-11 02:06:15 +00: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
Rahul Frias
c882bd8230 Correct an error reported when a license is restored and then released
[ Merge of http://go/wvgerrit/128143 ]

Now reports LICENSE_STATE_ERROR rather than ERROR_DRM_GENERIC_PLUGIN
to make the cause of failure and suggested action more clear for app
developers. Also added an additional error log.

Bug: 190645000
Test: WV unit/integration tests
Change-Id: Ib23ca628c590316f90f497d8fdfbab24fd644d6f
2021-06-29 20:21:06 -07: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
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
Rahul Frias
30ebbefb40 Add CLIENT_TOKEN_NOT_SET error code
[ Merge of http://go/wvgerrit/120511 ]

Bug: 169740403
Test: WV unit/integration test
Change-Id: Iba77c0b7e7f1bee1e96b0d08f0ab8e8591292012
2021-03-22 17:08:34 -07: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
Robert Shih
e0a1e459a2 libwvhidl: implement setPlaybackId
Bug: 159337195
Bug: 168341163
Test: GtsMediaTestCases MediaDrmTest#testSetPlaybackId
Change-Id: I4fc687892c9dd3b8077b3ecdfd9bbc355b298571
2021-01-20 15:26:01 +00:00
Rahul Frias
ec8bed38f4 Update Widevine Copyright header for android
[ Merge of http://go/wvgerrit/108084 ]

The Widevine License Agreement has been renamed to use inclusive
language. This covers files in the android directory.

Bug: 168562298
Test: verified compilation (comment only change)
Change-Id: I0f9e6445e0168ebe85425baeb81371e182e5a39c
2020-10-21 02:49:05 -07:00
Alex Dale
b96b58628c Correctly handle local display only for SRM version.
[ Merge of http://go/wvgerrit/105343 ]

If a device only supports local display (eliminating the need for an
SRM version), then the CDM should treat this as no SRM version.

Bug: 166009716
Test: License request integration test
Change-Id: I2d9c3f98735563df6d7c7a287abab41bf0a8c513
2020-09-02 21:36:37 -07:00
Rahul Frias
c8cff5274c Allow offline licenses to be loaded and restored in the same session am: 3709a4f419 am: 693d58e17d am: e37249c1de
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/12209028

Change-Id: I53f56740230c5e085f6210d5149cc4a77d475a8d
2020-07-26 18:48:36 +00:00
Rahul Frias
3709a4f419 Allow offline licenses to be loaded and restored in the same session
[ Merge of http://go/wvgerrit/103243 ]

In v16, OEMCrypto specifications required that an error be returned if
multiple attempts are made to load an offline license into a session.
This caused the GTS test testConcurrentDrmCertificates to fail. It was
introduced to verify that a license could retrieved and loaded into a
session and then restored. This was based on an app use case.

Ideally we would like to disallow a this behavior but need to make sure
it is not being used by apps.

For now this will be allowed. If detected, the CDM will reintialize the
OEMCrypto session and allow the license to be restored.

Bug: 161551490
Test: WV unit integration tests, GtsMediaTestCases and
      WidevineConcurrentDrmCertificatesTest#testConcurrentDrmCertificates,
      MediaDrmTest#testMultipleLoadKeys on a redfin
Change-Id: I0834e4419c3a6dccfd77aaea3afa3d65c2c0c742
2020-07-24 07:27:19 -07:00
Alex Dale
6a247ab924 INSUFFICIENT_RESOURCE errors are mapped consistently.
[ Merge of http://go/wvgerrit/102109 ]

The CDM was using unique CDM error codes for the various cases
where OEMCrypto would return INSUFFICIENT_RESOURCE.  However, these
error codes were being incorrectly mapped at the Android level,
resulting in incorrect errors in the MediaDRM layer.

At no point does the CDM handle different INSUFFICIENT_RESOURCE_x
within the same case, as such the use of unique codes are limited.
This CL removes the unique codes, and unifies them under the same
CDM error code.

This CL also extends SelectKey to handle error codes returned by
LoadEntitledContentKeys.

Bug: 154682842
Test: Unit tests
Change-Id: I319fabf6cac60b0dc19ea891609689daeeaeb435
2020-06-22 16:27:25 -07:00
Rahul Frias
bbe9f6afc4 Add ATSC support - part 1
[ Merge of http://go/wvgerrit/100864 and http://go/ag/10704773 ]

ATSC 3.0 allows for licenses to be downloaded OTA and are tied to
a DRM certificate that may be shared across apps. The provisioning
process for ATSC may happen at the factory or during an OS update.

This contrasts from the regular OTT model, which requires that
provisioning and license download have an uplink as well as a
downlink connection.

This adds support for the ATSC mode property. ATSC mode can only be
set (or unset) before sessions are opened. Once the CDM identifier is
set/sealed, requests to modify the ATSC mode will be rejected.

If one needs to open sessions with both ATSC mode and regular (non-ATSC)
mode, separate MediaDrm objects will need to be created. The default
mode is to not use ATSC.

Enable ATSC mode by calling
  mediaDrm.setPropertyString("atscMode", "enable")

Disable ATSC mode by calling
  mediaDrm.setPropertyString("atscMode", "disable")

Provisioning and unprovisioning requests for ATSC will be rejected as
certificates will be retrieved by the ATSC service.

Bug: 139730600
Test: WV unit/integration test, GtsMediaTestCases
Change-Id: I142f286c711fe007ff42125c3c8cdc6450b6ea36
2020-06-08 14:56:48 -07:00
Alex Dale
2a16d70a06 Suppress error for removing lingering offline licenses.
[ Merge of http://go/wvgerrit/97963 ]

There are situations where an offline license file will remain on the
system after it's usage entry has been deleted.  This would result in
its key set ID being reported as present by the CDM, but any
operations acting upon it will result in an error.

The app should be able to remove the license without error, so long
as the license file exists and no other OEMCrypto operations fail.

This change introduces a new error code LICENSE_USAGE_ENTRY_MISSING,
which indicates that a license's usage entry cannot be found.

A new integration test checks that the CDM can handle the calls to
removeOfflineLicense().

Bug: 137034719
Test: Android unit and integration tests
Change-Id: Ibdbe963b7f7e3ac97b446300d8e3896cdee7abc5
2020-04-29 17:48:26 -07:00
Alex Dale
c9e4dd2495 New CDM error codes for usage table errors.
[ Merge of http://go/wvgerrit/95404 ]

There are three situtations where error codes from a usage table
operations were not being mapped to unique CDM response types.  These
particular errors provide useful information for the CDM during table
defragging.

Also fixed misspelled error code.

Bug: 150890014
Bug: 150891685
Test: Linux unit tests and Android build
Change-Id: I683abdd5fc0871317eede960ea36cfafac7e7f49
2020-03-23 12:54:27 -07:00
John W. Bruce
a62886b925 Combined Decrypt Calls
(This is a merge of http://go/wvgerrit/93829,
http://go/wvgerrit/93830, http://go/wvgerrit/93832,
http://go/wvgerrit/93833, and http://go/wvgerrit/93834 from the
Widevine repo.)

This implements the CDM code changes necessary to take advantage of
Combined Decrypt Calls on OEMCrypto v16. The result of this is that
WVCryptoPlugin is much lighter now because it can pass the full sample
down to the core in one call, but CryptoSession is heavier, as it now
has to handle more complex fallback logic when devices can't handle
multiple subsamples at once.

This patch also removes support for the 'cens' and 'cbc1' schema, which
are being dropped in OEMCrypto v16. This fixes an overflow in the code
for handling those schemas by removing it entirely.

This patch also fixes the "in chunks" legacy decrypt path to use larger
chunk sizes on devices with higher resource rating tiers.

Bug: 135285640
Bug: 123435824
Bug: 138584971
Bug: 139257871
Bug: 78289910
Bug: 149361893
Test: no new CE CDM Unit Test failures
Test: Google Play plays
Test: Netflix plays
Test: no new GTS failures
Change-Id: Ic4952c9fa3bc7fd5ed08698e88254380a7a18514
2020-02-19 11:44:35 -08:00
Fred Gylys-Colwell
7665614b2e OEMCrypto v16.1
Merge of http://go/wvgerrit/93404

This CL updates the Widevine CDM to support OEMCrypto v16.1

Test: Tested in 16.2 CL
Bug: 141247171
Change-Id: I69bd993500f6fb63bf6010c8b0250dc7acc3d71b
2020-02-03 14:45:32 -08:00
Robert Shih
8fce3e316b wv hidl: upgrade Drm/Crypto factories to v1.3
Bug: 139134043
Test: MediaDrmTest
Change-Id: I94d1cc8a323c144805d74d5568944dd48ae80e60
2019-12-16 01:19:49 -08:00
Alex Dale
061b0e7caf Merge CDM LRU change to Android.
[ Merge of http://go/wvgerrit/81903 ]
[ Merge of http://go/wvgerrit/87473 ]
[ Merge of http://go/wvgerrit/82568 ]
[ Merge of http://go/wvgerrit/87266 ]
[ Merge of http://go/wvgerrit/87474 ]
[ Merge of http://go/wvgerrit/87475 ]

Bug: 135046978
Test: GTS and Android unit tests
Change-Id: Iff2ff62cea21eeb36d7b56c8bb852fce8447ff89
2019-12-06 13:23:26 -08:00
Rahul Frias
10eb4da035 Simplify parameter validation
[ Merge of http://go/wvgerrit/89888 ]

A macro validates parameters in CryptoSession and return a
specified error code. Some error codes have been retired and replaced with
the error code PARAMETER_NULL.

Bug: 136123217
Test: Android unit/integration tests
Change-Id: I6ecbad53e87cce04dfd9ea27861400e83044cf5e
2019-11-22 12:05:52 -08:00
Alex Dale
0f25034907 Reordering Android WV error codes in mapper.
[ Merge of http://go/wvgerrit/86243 ]

Sorted the case-return blocks in the error map function.  Used two iterations
of a bucket sort algorithm.  First by the case label, then a binary sort on
whether the return value is in the `android` namespace or not.  There are some
exception (such as the first and last block).

The majority of the sorting was done using a script:
  https://paste.googleplex.com/6390453727395840

Bug: 34648626
Test: Linux unit tests and compiled on Android
Change-Id: I524e0d0d93df8b0a3dc1155980eec22cf43156b6
2019-10-01 10:54:46 -07:00
John W. Bruce
63b2ea86d9 Allow CE CDM to Create Sessions Without a Service Certificate
(This is a merge of http://go/wvgerrit/84510)

When the CE CDM 3.5 behavior around service certificates was originally
implemented, it allowed sessions to be created if a service certificate
had not yet been installed, in keeping with the EME spec. However, the
service certificate in use at session creation time was cached, and so
there was a bug where any sessions open before a service certificate was
installed would never be updated with any future service certificates.
The code also caused problems for Android. When it was merged to master,
it was fixed to simply not allow session creation on CE CDM without a
service certificate. However, this created an impedance mismatch between
the CE CDM and EME that has caused pain for Shaka Player Embedded,
Chrome, Chromecast, Fuchsia, and likely every partner that is trying to
implement a fully-compliant EME stack on top of CE CDM.

Removing the code that blocks session creation without a service
certificate is easy. Fixing the bug that motivated it is not. Removing
the caching is not possible because Android needs it for certain
behavior on its end. So instead, the CE CDM will have to iterate over
all open sessions and update their service certificates if the installed
service certificate changes.

Test: CE CDM Unit Tests
Test: Android Unit Tests
Bug: 111766009
Change-Id: I1bd70553e2209b823a6acdc221c0497a5f3181b2
2019-09-09 16:17:26 -07:00
Rahul Frias
1aed4dc670 hidl: return BAD_VALUE from RemoveOfflineLicense when keyset is not found
[ Merge from http://go/wvgerrit/75623 ]

This addresses code-review comments during the merge to the wv repo.

Bug: 127828539
Test: WV unit/integration tests
Change-Id: I12abe3eb0767bb9ccb76940dcca12c17d32e8e53
2019-04-01 20:10:25 -07:00
Rahul Frias
272e60db27 Add recoverable errors
[ Merge of http://go/wvgerrit/71326 ]

Nonce flood, frame size, session and system invalidation errors
will now bubble up to the app. OEMCrypto v15 returns
OEMCrypto_ERROR_BUFFER_TOO_LARGE, OEMCrypto_ERROR_SESSION_LOST_STATE,
OEMCrypto_ERROR_SYSTEM_INVALIDATED and a variety of nonce errors.
These will be reported to HIDL as OUTPUT_TOO_LARGE_ERROR,
ERROR_DRM_SESSION_LOST_STATE, ERROR_DRM_INVALID_STATE and
ERROR_DRM_RESOURCE_CONTENTION.

Bug: 120572706
Test: Unit/Integration tests
Change-Id: Ida177300046327ce81592a273028ef6c3a0d9fd9
2019-01-31 00:44:02 -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
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
Rahul Frias
589a3cf27e Add decrypt hash support
[ Merge of http://go/wvgerrit/68083 ]

Add ability to query decrypt hash support, set a hash computed over a frame
and retrieve the last error at a later point.

Bug: 34080802
Test: WV unit/integration tests. New tests added to cdm_engine_test,
      libwvdrmdrmplugin_hidl_test and request_license_test.

Change-Id: I7548c8798c873a6af3e1cfc0df57c117e1e474a6
2019-01-07 10:14:25 -08:00
John W. Bruce
5629a646d8 Remove Sub-Licenses and Sub-Sessions
(This is a merge of http://go/wvgerrit/66643)

The sub-license feature has been removed from the server and packager.
So that we do not have to continue maintaining the code that supports
this feature that never shipped, I am removing it from the CDM as well.

Bug: 113165466
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I5d25844b161e74aa19adf19a29c56e4881aa7304
2018-12-06 09:00:51 -08:00
John W. Bruce
3d603eb12d Reject Embedded Keys Under 16 Bytes
(This is a merge of http://go/wvgerrit/60620)

The license code handles keys larger than 16 bytes correctly, but it
does not properly reject keys smaller than 16 bytes.

This patch adds unit tests not only for the new error case but also
the existing success cases which were not previously being tested. As
part of this, license_unittest was changed to use a Test Peer instead
of making the test fixture a friend class.

Bug: 111069024
Test: CE CDM unit tests
Test: Android unit tests
Change-Id: Idb2deb6fbe0aeb19b530f9818bebff480541f5c8
2018-10-08 10:05:34 -07:00
Fred Gylys-Colwell
5095bb746e Handle KEY_NOT_LOADED error
Merge from Widevine repo of http://go/wvgerrit/56523

In OEMCrypto v14, SelectKey can also return KEY_NOT_LOADED if the key
id is not found.  This was added to help with entitlement licenses.
However, SelectKey in crypto session converts this to an unknown
error.

In this CL we change that to a NO_CONTENT_KEY_3 error.  This is
probably only important because the generic crypto tests expect
NO_CONTENT_KEY_3 when we try to use an undefined key.

Test: existing unit tests pass, and some future unit tests pass.
Bug: 72354901 Turn on generic crypto tests
Change-Id: I3c0b7e6306cafd3feabc8aac7e47983c89194a26
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
a242a32bba Implement Method to Release Licenses Without a Server Roundtrip
Merge from Widevine repo of http://go/wvgerrit/52480

Partners have asked for a way to release offline licenses without
using a release message. This is typically used by cable partners who
are caching licenses ahead of time and do not care about usage
statistics.

As part of implementing this request, CdmSession::DeleteLicense() was
renamed to reflect that it only deletes the *files* associated with a
license, and a new CdmSession::DeleteLicense() has been written that
also cleans up other related data.

Bug: 77955334
Test: CE CDM Unit Tests
Test: tested as part of http://go/ag/4674759
Change-Id: I00d6e20935c5fecb3ac9be6757c0f191d85c6bd6
2018-09-02 11:45:16 -07:00
Fred Gylys-Colwell
240652afcf Do Not Unprovision Baked-In DRM Certs
Merge from Widevine repo of http://go/wvgerrit/49820

Devices with baked-in DRM certs cannot be reprovisioned. As such, we
must protect them against being unprovisioned. Currently, our unit
tests break such devices by attempting to unprovision them. This patch
adds code to block the Unprovision() call on these devices.

Bug: 69264798
Test: CE CDM Unit Tests
Test: tested as part of http://go/ag/4674759
Change-Id: I49322dcb2d3d5c7953e870eb91a9e0b978d4dabe
2018-09-02 11:45:16 -07:00
Rahul Frias
0163607fa3 Revert of "Prevent race conditions between decrypt and close session"
[ Original CL http://ag/3890635,
  Merge of http://go/wvgerrit/50340 ]

The original fix was not sufficient to address all race conditions.
A subsequent CL will address them.

Bug: 73781703
Bug: 79158083
Bug: 79262108
Test: WV unit/integration tests, GTS GtsMediaTestCases tests and
      24 hours of continuous Netflix playback.

Change-Id: I869c22a250e2467b3d49935815e4157dc012fff5
2018-05-14 15:45:54 -07:00
Rahul Frias
07bb4de042 Prevent race conditions between decrypt and close session
[ Merge of http://go/wvgerrit/47520 ]

Bug: 73781703
Test: WV unit/integration tests, GTS GtsMediaTestCases tests and AUPT tests.
Change-Id: I618ed8ca38855aecdb31e829a7f4041cbd505a02
2018-04-19 23:41:27 -07:00