Commit Graph

541 Commits

Author SHA1 Message Date
Rahul Frias
7b7d5edd7c Use new play license service URI
[ Merge of http://go/wvgerrit/54802 ]

BUG: 110954967
BUG: 110960064

Test: WV unit/integration tests.

Change-Id: I3c5263f304ec9c9734a6761cbd7db46ccb476e9e
2018-08-01 13:41:54 -07:00
John W. Bruce
c28cea3637 Add Missing Parameter to License Keys Unit-Test
(This is a merge of http://go/wvgerrit/55265)

Compiling with GCC 7 revealed that a function call in this test was
missing an argument. It meant to be passing the output protection level
to the function, but because of optional arguments, it was instead
passing it as the fourth argument.

Fixing this revealed that the test cases for the test were incorrect in
one case, which has been fixed to expect the correct results.
Thankfully, this part of the code does not appear to have been broken
while the tests had this hole.

Bug: 111648438
Test: build_and_run_all_unit_tests.sh
Change-Id: I6c13d5fecdccc4185ca5e8698fc845929ff16cb1
2018-07-19 12:49:40 -07:00
Rahul Frias
a20034e3a2 Recover when stored information is corrupted
[ Merge of http://go/wvgerrit/52040 ]

Information stored in files are serialized and protected by an MD5 hash.
When files cannot be read because the MD5 hash computed over it
fails verification, the file is deleted. This allows for recovery.

However if the protobuf deserialization fails we return an error
but do not delete the file. When errors of this sort occur
with usage information files, the CDM cannot recover.
removeAllSecureStops() will fail as well and new licenses
with PSTs cannot be processed. In order to recover the file will
be deleted when a protobuf deserialization error occurs.

Bug: 109765590
Test: WV unit, integration tests. GTS tests. Netflix and Play Movies playback
Change-Id: I408914924e644d5c22b2ba7865d3a7d598788ee6
2018-06-06 00:57:31 -07:00
Rahul Frias
d401baa236 Address deadlock
[ Merge of http://go/wvgerrit/51322 ]

This avoids taking the session_map_lock_ twice.

Bug: 80248149
Test: WV unit/integration tests, GtsMediaTestCases,
      2 days of netflix playback.

Change-Id: Iea1c7b7ba08d7d40c227d21c5abfce13c0a8b395
2018-05-28 12:41:19 -07:00
John W. Bruce
b305d99d3b Make Defensive Copies in CopyBufferInChunks
(This is a merge of http://go/wvgerrit/51084)

Nominally, OEMCrypto probably shouldn't modify the buffer descriptor we
pass into OEMCrypto_DecryptCENC(), but in practice, we know some
platforms do this, so we make defensive copies in
CryptoSession::DecryptInChunks() just in case. Turns out, some devices
also behave like this in OEMCrypto_CopyBuffer(), so we should also be
doing defensive copies in CryptoSession::CopyBufferInChunks().

Bug: 79779554
Test: ExoPlayer Demo App, played "Secure Subsample UHD (WebM, VP9)"
Test: build_and_run_all_unit_tests.sh
Change-Id: Ib46043a6cc0aa42d1d1cc85f5adb477c566363e9
2018-05-23 18:04:01 -07:00
Rahul Frias
e8c3a4afac Protect sessions from concurrent access.
Locks in earlier releases controlled access to sessions and the list
of sessions for each CdmEngine instance. This guarded against
concurrent access between session management (OpenSession,
CloseSession, etc), periodic timer calls and calls to Decrypt.

The list of sessions and locking was moved to a separate class
CdmSessionMap. This left open the possibility that a session
might be destructed, while being called to decrypt or invoked through the
timer. An attempt was made to add per-session locks in b/73781703
but this was found insufficient.

Per-session locks will be introduced in a future changelist, but for
now the coarser locks will be reintroduced.

Bug: 73781703
Bug: 79158083
Bug: 79262108
Bug: 79436509

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

Change-Id: I30a3ede340192370dfe5c92c01b1c76df16b7123
2018-05-15 11:51:17 -07:00
Rahul Frias
dcab2b1355 Address concurrency failures between calls to decrypt and periodic timer
[ http://go/wvgerrit/50341 ]

The shared_ptr implementation was taken from a google3 implementation.
Updates to the reference counter needed to be atomic and were
platform dependent in the original code. These were not carried
over to this codebase. Race conditions between calls to decrypt and
the periodic timer, led to incorrect reference count values.
CdmSession objects were then destructed while references to
them still existed. Segfaults occurred when they were referenced.

Bug: 79431096

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

Change-Id: I6008ddba869efcc58972e5ea8644a204f91410ab
2018-05-14 16:38:38 -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
184e0d0559 Address Cdm Extended Duration Test failures
[ Merge of http://go/wvgerrit/49980 ]

This CL
* corrects some of the test expectations
* switches test content used to test streaming with provider session tokens.
  The policy of the earlier test content had changed.
* adds some more information to log messages

Bug: 63819720
Test: WV unit, integration tests, WvCdmExtendedDuraionTest,
      GtsMediaDrmTest

Change-Id: I8fdbc9c38d6018cc6e884e1b95b2e9d26e7aa536
2018-05-11 14:27:45 -07:00
Rahul Frias
734b6b819e Merge "Allow a service certificate to be specified for provisioning" into pi-dev 2018-05-02 21:51:54 +00:00
Rahul Frias
9ba6493e1b Save usage information before closing a session
[ Merge of http://go/wvgerrit/48640 ]

Usage information is saved periodically, in order to avoid excessive
flash writes. This limits our session usage accuracy to
within a usage save period. Saving usage information when
closing a session is an improvement and addresses some failures
seen with Netflix compliance tests.

Bug: 74015553
Test: WV unit/integration tests
Change-Id: I680aad05922f334df0611ff3933082a512f7c002
2018-04-26 14:14:51 -07:00
Rahul Frias
d7e0a3562c Remove duplicate information from client identification
[ Merge of http://go/wvgerrit/48720 ]

The device ID does not need to be sent in the client identification
information as it is either present in other fields or ignored
by the license service.

This also allows for build information to be reported during
provisioning for devices with OEM certificates.

Bug: 78578351
Test: WV unit/integration tests. GtsMediaTestCases.
Change-Id: I708c63d34f0e2df7e465154d12096a394a1b23d7
2018-04-25 17:21:40 -07:00
Rahul Frias
816f00e533 Allow a service certificate to be specified for provisioning
[ Merge of http://go/wvgerrit/48400 ]

Client identification information has recently been enabled in
provisioning messages. For privacy concerns this information
is being encrypted with a default service certificate.
Apps need to be able to override the default one to allow
for provisioning with third party provisioning services.

Bug: 78420508
Test: WV unit, integration tests
      New WvCdmRequestLicenseTest.ProvisioningTestWithServiceCertificate test
      GTS MediaDrmTestCases

Change-Id: Iee61ad47d33ce011efbea4eb90f7e4b1f032d15f
2018-04-24 11:14:35 -07:00
Rahul Frias
d873f40d80 Merge "Enable encryption of client ID for provisioning" into pi-dev 2018-04-23 22:03:53 +00:00
Rahul Frias
c171d024d9 Enable encryption of client ID for provisioning
[ Merge of http://go/wvgerrit/46760 ]

This enables encryption of client ID for provisioning requests for
devices with keyboxes as root of trust. Client ID will not be
provided for those devices with OEM device certificates as root of
trust. That will be addressed in b/78303730.

Bug: 77607585
Test: WV unit/integration tests. Tests with L3 using OEM certs
Change-Id: Id9bd697aa049bd5659ab80714e141dbc50408f6a
2018-04-22 10:52:51 -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
Fred Gylys-Colwell
1a25cbdad6 Update Copyright
Merge from Widevine repo of http://go/wvgerrit/47860

This CL updates the copyright notice to indicate that files
shared with partners are shared under the Widevine Master
License Agreement.

bug: 77926774
test: comment change only
Change-Id: I0423668111578b80fb39a932d763df2827e2dfc3
2018-04-16 16:38:05 -07:00
Rahul Frias
d102f8a4d2 Correct exception returned after RemoveKeys is called.
[ Merge of http://go/wvgerrit/47065 ]

RemoveKeys now resets associated crypto and policy resources,
rather than just closing the crypto session. This results in a
MediaCodec.CryptoException with error code ERROR_NO_KEY
rather than ERROR_SESSION_NOT_OPENED, if decrypt is called
afterwards.

Error SESSION_NOT_FOUND_FOR_DECRYPT is made unique. Error codes
were also synchonized between various branches in the widevine repo.

Bug: 77304819
Test: WV unit/integration tests, VtsHalDrmV1_0Target tests
Change-Id: I6cba2a3e1ce466d58c7727cde2d8f81d9503d655
2018-04-11 00:11:11 -07:00
Rahul Frias
f0cd22d4f4 Address failures when provisioning methods differ
[ Merge of http://go/wvgerrit/46907 ]

The WV client supports root of trusts as keyboxes or OEM certificates.
Devices with keyboxes use provisioning 2.0 protocol to provision
while those with OEM certificates use 3.0. L3 provisioning failures
occur if the L1 and L3 root of trusts differ.

The provisioning method is now retrieved and cached when the
security level is known, when the session is opened.
Earlier it was retrieved and cached at initialization time and
always set to the value of L1 OEMCrypto (if present). This led
to provisioning failures.

A case of acquiring a lock while one was held in GetProvisioningId()
has also fixed.

Bug: 77606913
Test: WV unit/integration tests
Change-Id: I2d66ee2cf64f846cec4a37fbccb554447c8a0e1d
2018-04-09 13:47:29 -07:00
John W. Bruce
9d384305b7 Add widevine.com Default Provisioning Service Certificate
(This is a merge from http://go/wvgerrit/46447)

The Production Provisioning Service is moving to the "widevine.com"
certificate from the "license.widevine.com" certificate it was using.
This replaces the two places this certificate appears in the source
code. This is expected to be the last such update.

Also, the Staging Provisioning Service was already using this
certificate, but our code had it listed as using the old certificate. It
has also been updated.

Bug: 77244492
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I2ce14ea8e672c453ce0f74fbd3345f7e40f2f297
2018-04-09 13:47:15 -07:00
Rahul Frias
92e6a1bb66 Merge changes Ie4a63ac2,I8523ef28 into pi-dev
* changes:
  Recovery from usage info corruption
  Correct segfault in WvCdmRequestLicenseTest.UsageRemoveSecureStopTest
2018-04-03 18:12:34 +00:00
Rahul Frias
d7d8940174 Recovery from usage info corruption
[ Merge of http://go/wvgerrit/46623 ]

If corruption of the usage information file is detected while saving a
streaming license with a PST, usage information file is deleted, so that
a subsequent load keys may succeed.

Also when calling the MediaDrm API releaseAllSecureStops(), an error would
be returned if usage info file was corrupted. Since this file is
deleted successfully, errors have been replaced with warnings.

Bug: 73447733
Test: wv unit/integration tests
Change-Id: Ie4a63ac202fd6009609105f38ffa8a3b23ed334e
2018-04-02 19:04:09 -07:00
Rahul Frias
4e201c2700 Correct segfault in WvCdmRequestLicenseTest.UsageRemoveSecureStopTest
[ Merge of http://go/wvgerrit/46622 ]

Secure stop API related changes introduced in b/69674645 caused
segfaults on taimen/walleye but not other devices due to a difference
in OEMCrypto version.

Bug: 77294890
Test: WV unit/integration tests on sailfish and walleye
Change-Id: I8523ef283334d7d32d180e902072fe1dd6e665c1
2018-04-02 19:03:26 -07:00
Rahul Frias
142e80f750 Correct unit test compile error
[ Merge of http://go/wvgerrit/46640 ]

Bug: 72994956
Test: WV unit/integration tests on walleye, sailfish and linux.
Change-Id: I7319a4b79ab9a02e0ca9a50fb48c6107f8c3a762
2018-04-02 11:02:31 -07:00
Adam Stone
084c370db6 Merge changes If99c1873,I3a3aa4fb into pi-dev
* changes:
  Creates a new license request latency metric
  Fixes missing or broken metrics in Widevine CDM
2018-03-31 00:50:34 +00:00
Adam Stone
09c45c4440 Creates a new license request latency metric
Previously, we did not have a license request latency metric. This is a
notable limitation in our metrics. This adds a metric that captures the
timing between a GenerateKeyRequest and an AddKey operation.

Bug: 72994956
Test: New unit tests. Google Play
Change-Id: If99c187399c02f9b5d4c355732af7588bbbefb11
2018-03-30 21:43:48 +00:00
Adam Stone
e1fe90372f Fixes missing or broken metrics in Widevine CDM
A few metrics were missing or not properly collected in the CDM metrics.
This CL addresses them.

Bug: 64570194
Bug: 72866232

Test: Unit tests and Google Play manual test.
Change-Id: I3a3aa4fb3eb8422c9c8c398016f02409307beb33
2018-03-30 14:07:04 -07:00
Srujan Gaddam
5064731d02 Remove call to DeriveKeys for release
Merge of http://go/wvgerrit/45520/

Bug: b/70650789

Test: request_license_tests and GTS tests on sailfish and taimen

This is related to b/70650789. An extra call to DeriveKeysFromSessionKey
in the case where there is a provider session token results in the
OEMCrypto mock incorrectly using the derived mac keys to sign the release
message, since a future call to LoadKeys is never called.
2018-03-29 10:37:09 -07:00
John W. Bruce
db0911df54 Load Certificate to Confirm Provisioning
(This is a merge of http://go/wvgerrit/46203)

Previously, IsProvisioned() only confirmed the existence of a
certificate file, not whether the contents of that file were actually
valid. This patch changes its behavior so that it actually validates the
loadability of the file before returning.

This is sufficient to resolve Netflix's use case in b/65835227, but it
is only part of the solution for Android's use case in b/72353451. A
second patch will be required to cover cases where the certificate can
be loaded but cannot be used with the current OEMCrypto or with the
server.

Bug: 65835227
Bug: 72353451
Test: Android and CE CDM unit tests
Change-Id: Id3987a6f3c4097d7d356dfa631b023287354439a
2018-03-28 03:33:02 -07:00
Adam Stone
b19f0d106f Fixes widevine metrics proto serialization
Changes to a much more efficient and more reusable protobuf format for
metrics.

Test: Widevine tests, Google Play and MediaDrm CTS test.
Bug: 73724218

Change-Id: I3299051d7a16bcd7758c8f272415ca40e10c1313
2018-03-22 16:36:18 -07:00
Rahul Frias
4ba82e4585 Secure stop API related changes
[ Merge of http://go/wvgerrit/44921 ]

* Added the ability to remove a single usage information record.
* Added a method to retrieve all secure stop Ids.

Bug: 69674645
Test: WV unit, integration tests
Change-Id: I04ac8224b4bdda69541e61ff1103af3836138228
2018-03-14 15:24:10 -07:00
Rahul Frias
1d9a16c3b9 Rename ReleaseAllUsageInfo to RemoveAllUsageInfo
[ Merge of http://go/wvgerrit/44920 ]

Bug: 69674645
Test: WV unit and integration tests
Change-Id: Iee6e60b9dd20a8ed087c5e44924aa1c05f640920
2018-03-14 11:34:05 -07:00
Jeff Tinker
6a4abc15fe Remove error code INVALID_QUERY_STATUS
CdmEngine::QueryStatus was mapping all error codes
returned from crypto_session.Open to INVALID_QUERY_STATUS
which caused important failure information to be lost.
The GTS DrmSessionManagerTest test was failing as a
result, because session reclaiming no longer worked.

merge of http://go/wvgerrit/44800

bug:72705384
test:gts DrmSessionManagerTest

Change-Id: Id404a18b8f66cf6137b69f6b4e1bdd7004706a0c
(cherry picked from commit 6aad0f77cb)
2018-03-12 23:38:04 +00:00
Fred Gylys-Colwell
5bd4dbb502 Use license.widevine.com cert for provisioning server
Merge from Widevine repo of http://go/wvgerrit/44505

This CL changes the certificate provisioning code to verify the
provisioning message using a cert from license.widevine.com instead of
the staging certificate.

It also adjusts the certificates in config_test_env.cpp because the
license and provisioning servers are different and may probably have
different certs.

bug: 73031756
test: unit tests with mock oemcrypto, and read oemcrypto on sailfish
Change-Id: I4b457a369a49ef07bda9e5632ab59e5f621ec966
2018-03-02 14:36:42 -08:00
Fred Gylys-Colwell
d2c384f619 Adjust cdm engine test response to nonce flood
Merge from Widevine repo of http://go/wvgerrit/43720

This CL changes the cdm engine test's Provision method so that it
keeps OEMCrypto alive during the provisioning.  This is only needed
when testing with the oemcrypto mock and the nonce flood rate has been
throttled to 1.  In that case, if OEMCrypto is allowed to terminate
between each request, all nonce requests will be an error.

Keeping OEMCrypto alive does not modify the desired test results when
oemcrypto is not throttled.

This CL changes test code only.

bug: 73607610
test: unit tests
Change-Id: I71b27b1bb8200188a0a821afc977d7a9cc7fd968
2018-02-21 13:35:57 -08:00
Rahul Frias
3480900b1a Correct format specifier
[ Merged from http://go/wvgerrit/43640 ]

Bug: 62266605
Test: WV unit/integration test
Change-Id: I9944805f0dd7f5b33e3a0b2eb40f2a3a6e26489e
2018-02-16 15:07:14 -08:00
Fred Gylys-Colwell
10275f508a Merge "Fix compiler warnings" 2018-02-16 02:15:09 +00:00
Fred Gylys-Colwell
ef0ec145d3 Fix compiler warnings
Merge from Widevine repo of http://go/wvgerrit/43420

Remove or mark unused variables.  Fix unsigned/signed comparisons.

bug: 73390805
test: unit tests
Change-Id: Ic523400a5decf82fae733042b260e0c39a087cd3
2018-02-15 11:18:54 -08:00
Rahul Frias
fe2c777a8e Disambiguate INSUFFICIENT_CRYPTO_RESOURCES errors
[ Merge of http://go/wvgerrit/43281 ]

Bug: 73164325
Test: WV unit/integration test, playback tests using Netflix and
      Play Movies.

Change-Id: Ifc3dd8863da1616eb4a7df35ad010f53b6d5e3d2
2018-02-14 15:45:27 -08:00
Rahul Frias
5053a887dd Enforce security level checks only on encrypted content
[ Merged of http://go/wvgerrit/43260 ]

Bug: 73250635
Bug: 73251811
Bug: 70278160
Bug: 73159523

Test: WV unit/integration tests, GtsMediaTestCases, playback using
      Play Movies and Netflix.

Change-Id: I677aeab80fc90e5c8b9c71a185ca626c75013938
2018-02-13 18:57:42 -08:00
Rahul Frias
e0cc4f61b2 Correct HDCP values returned in query command
[ Merge of http://go/wvgerrit/43240 ]

HDCP related changes were made in http://go/wvgerrit/42602. This
also changed the string values returned in the HDCP query command.
This CL reverts changes to the string values as were specified in
the Widevine Modular DRM Plugin vendor extensions document. Changing
them at this point will impact applications.

Bug: 70278160

Test: WV unit/integration tests, GtsMediaTestCases, playback using
      Play Movies and Netflix.

Change-Id: I20171a8272aeeff5007cf90c9939b2ce1ce0fb13
2018-02-13 16:54:37 -08:00
Srujan Gaddam
a4e7e3fd80 Merge "Fix dead code in dynamic adapter" 2018-02-13 03:47:18 +00:00
Srujan Gaddam
c616bfcd51 Fix dead code in dynamic adapter
b/73254535

Test: unit/integration tests

Merge of http://go/wvgerrit/43100
2018-02-12 17:06:53 -08:00
Rahul Frias
928ae5639e Merge "Changes to support new MediaDrm methods" 2018-02-09 03:36:39 +00:00
Rahul Frias
8d27f791e6 Merge "Detect when unable to meet policy requirements" 2018-02-09 03:36:12 +00:00
Rahul Frias
dc25029fc4 Changes to support new MediaDrm methods
[ Merge from http://go/wvgerrit/42602 ]

Renamed HDCP related query names to better reflect their purpose.

Bug: 69674645
Test: wv unit/integration tests
Change-Id: If4da45ff676da0e812852bf34f209d99e59c059b
2018-02-08 16:29:34 -08:00
Srujan Gaddam
3bbd0584a8 Fix cipher mode assignment in adapter
b/73127061

Merge of http://go/wvgerrit/42923

Test: Unit tests/playback
2018-02-08 15:08:09 -08:00
Rahul Frias
c78ce178d4 Detect when unable to meet policy requirements
[ Merged of http://go/wvgerrit/39766 ]

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.

Bug: 31913737
Bug: 31913439

Test: WV unit/integration tests
Test: Playback using playmovies and netflix. Cast playback using
      playmovies.

Change-Id: If25735ab0f789108431115623cb236687c5ef818
2018-02-07 21:47:52 -08:00
Rahul Frias
91efb844a1 Merge "Correct request_license_test failures" 2018-02-07 17:06:57 +00:00
Rahul Frias
d9d53dee3b Correct request_license_test failures
[ Merge of http://go/wvgerrit/42103 ]

* While deprecating keyboxes as identification, some code to
  restore a license was mistakenly removed in http:://go/wvgerrit/36740,
  http://ag/3442777

* Corrections to keep track of cipher mode, call SelectKeys when cipher
  mode changes and to use the backward compatible LoadKeys call in case
  OEMCrypto is v13.

Bug: 70160032

Test: Ran WV unit/integration tests. Request license test failures
      have been addressed.

Change-Id: Id03c50874085af6d9985d10c19a74a02efb7a1f5
2018-02-06 09:46:36 -08:00