Commit Graph

416 Commits

Author SHA1 Message Date
Rahul Frias
3c9175fec5 Return key request type none after key rotation
[ Merge of http://go/wvgerrit/80084 ]

Corrected the key type being returned after entitled keys from
init data are loaded. Made test changes to validate.

Bug: 133903028
Test: WV unit/integration tests
Change-Id: Icb44587f5c3aba3b0facae6d83dc9344d6b60833
2019-05-29 19:03:43 -07:00
Rahul Frias
80b8e29c3f WvCdmExtendedDurationTest#VerifyLicenseRequestTest fixes
[ Merge of http://go/wvgerrit/79724 ]

Bug: 122982573
Test: WV unit/integration tests
Change-Id: Icb7b192311dc6bbe630d96f993ccca774160774b
2019-05-22 18:12:06 -07:00
Rahul Frias
776996d6d2 Ref count WvCdmDecryptionModule
[ Merge of http://go/wvgerrit/78803 ]

WvCdmDecryptionModule needs to be refcounted since it inherits
from RefBase. The test code instantiates it as a member variable.

Bug: 133188706
Test: WV unit/integration tests
Change-Id: Ib41f3477a55923fb4cc26472e42d3e18eb2b84d4
2019-05-21 11:41:52 -07:00
Rahul Frias
4f273991b9 Correct android version number in test
[ Merge of http://go/wvgerrit/79144 ]

Bug: 132908020
Test: WV unit/integration tests
Change-Id: Idf5cf3e1e886af3bfed157320fa09d66dfa55c0d
2019-05-16 14:44:40 -07:00
Rahul Frias
19c6e57269 Merge "Single PSSH entitlement handling" into qt-dev 2019-05-13 16:26:16 +00:00
Adam Stone
3a27d2d649 Correctly sets provisioning state for test.
[ Merge from http://go/wvgerrit/78383 ]

Bug: http://b/121049662

Test: Re-ran the unit test.
Change-Id: I62c00f425c93b588e123ddd8b1093177f2e9b241
2019-05-08 14:13:28 -07:00
Rahul Frias
da25bce428 Single PSSH entitlement handling
[ Merge of http://go/wvgerrit/78425 ]

This CL refactors code, corrects comments and adds additional
integration tests.

Bug: 128462397
Test: WV unit/integration tests, GPlay playback tests and GtsMediaDrmTests
Change-Id: I679960d44c45cf4ff13c27eb960e66ec63f491b5
2019-05-07 23:07:05 -07:00
Rahul Frias
2e2e92280e Handle key rotation
[ Merge of http://go/wvgerrit/77049 ]

Entitlement PSSHs can now be provided in follow on key generation
requests to cause keys to be rotated without needing a license
exchange.

Bug: 128462397
Test: WV unit/integration tests, Netflix and GPlay tests,
      GtsMediaDrmTests

Change-Id: I6ed0901a35c498240f42e405a522d82ea8dce2f7
2019-04-23 13:54:51 -07:00
Rahul Frias
dcfe0f3690 Merge "Remove references to internal documents" 2019-03-28 23:29:43 +00:00
Rahul Frias
4e745ff203 Remove references to internal documents
[ Merge of http://go/wvgerrit/75303 ]

Bug: 117181780
Test: WV unit/integration tests
Change-Id: Ica12e270a9ac5fbcff069aace807bb4651814ad7
2019-03-28 09:32:30 -07:00
Rahul Frias
43efc6d84a Corrections for limited duration licenses
[ Merge of http://go/wvgerrit/74627 ]

Limited duration licenses (where license duration is unlimited and
playback window is set to a small value) did not work correctly when
the initial decrypt call occured before the license was received.

Bug: 109653883
Test: WV unit/integration tests
Change-Id: I0738e97db525b239455e2ac93ab0bedd6611b311
2019-03-23 00:53:26 -07:00
Rahul Frias
8942f7682a Add unit tests to remove usage entries
[ Merge of http://go/wvgerrit/74343 ]

This replicates a Netflix test that adds secure stops and removes them
one at a time, while some of the sessions are still open. Usage
enties will be deleted at the time, but the usage header table
will not be shrunk if the last entry is in use. This happens later when
sessions are closed and the last usage entry is no longer in use.

Bug: 120894148
Test: WV unit/integration tests, CE CDM tests
Change-Id: Ib572950afc61754fe5f3c417e650d5d08503425a
2019-03-18 15:47:12 -07:00
Adam Stone
77edbbe219 Merge changes I095f893b,I14d40676
* changes:
  Adds a VersionInfo message to SignedMessage
  Add UsageTableHeader metrics
2019-03-06 00:19:24 +00:00
Rahul Frias
e67d87bec1 Merge "Correction to logging when SRM version is queried" 2019-02-27 21:48:06 +00:00
Adam Stone
741645a4be Add UsageTableHeader metrics
[ Merge from http://go/wvgerrit/72183 ]

Adds basic metrics for the usage table header.

Bug: http://b/112919252
Test: Unit tests. Manual GPlay
Change-Id: I14d406766d8b2aba3b6e4f1a02c75eedc674b011
2019-02-25 17:09:31 -08:00
Rahul Frias
088c5afa02 Move WV unit/integration tests to /data/nativetest
[ Merge of http://go/wvgerrit/73044 ]

The tests currently get copied to /data/bin. Changes in location
of system libraries causes test failures when tests are unable to
find dependent dynamic libraries.

Bug: 123879070
Test: WV unit/integration tests
Change-Id: I86edbe33b4753238fcf8b84243ac6e6c058ea145
2019-02-21 09:53:06 -08:00
Rahul Frias
4916cb1e9c Correction to logging when SRM version is queried
[ Merge of http://go/wvgerrit/72703 ]

SRM is an optional feature and whether it is implemented is upto the
discretion of OEMs. If it is not, avoid logging this information.

Bug: 124391178
Test: WV unit/integration tests
Change-Id: If8d2b1e0b59fb11825f832a5d4259b03c482fd6b
2019-02-20 18:13:07 -08:00
Srujan Gaddam
6bd5c564d8 Test to ensure rollback doesn't affect key duration
Bug: b/78359032
Merge of http://go/wvgerrit/70544
Test: Android unit + integration tests/manual checking of system time to
make sure it's restored correctly

Integration tests are added to make sure that clock rollback of the
device system time does not affect key duration for both streaming and
offline licenses. These tests require root access as they modify system
time and restore them.

Change-Id: I3e1802205e2fc2056093c1e39b0ff6e0a8816abc
2019-02-07 17:26:32 -08:00
Adam Stone
9f31068de6 Merge "Add a metric decorator around cdm engine" 2019-02-04 17:55:35 +00:00
Rahul Frias
c9f7085f92 Merge "Enable provider client token test" 2019-02-01 21:44:02 +00:00
John Bruce
f8e46ebb34 Merge "Add a Reader-Writer Lock" 2019-02-01 19:32:43 +00:00
Rahul Frias
f83e813ea8 Enable provider client token test
[ Merge of http://go/wvgerrit/71907 ]

The client token needed to be enabled in the license request.

Bug: 123369846
Bug: 123370099
Test: WV unit/integration tests
Change-Id: I4d3e944b1d79010977c119291594878c406b00c5
2019-02-01 11:17:45 -08:00
Adam Stone
46eecb6b80 Add a metric decorator around cdm engine
[ Merge from http://go/wvgerrit/69105 ]

This adds a metric collecting decorator class around cdm engine. This
implementation uses a templated decorator. The decorator enables:

1) Wrapping the CDM Engine methods to capture timing and error
information.
2) Allows use of a mock CDM Engine for testing.

Test: Unit tests. GPlay manual testing and GTS tests.
BUG: http://b/64724336
Change-Id: I5e4a0f552974fab1939bc7ab02719a1f5849cf3f
2019-02-01 10:32:44 -08: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
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
Rahul Frias
61ef6b691a Merge "Add CDM integration test for offline renewal and release" 2019-01-28 21:06:48 +00: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
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
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
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
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
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
Srujan Gaddam
4c5c4caf66 Add detail about L3 initialization
Bug: b/70299597
Merge of http://go/wvgerrit/67304
Test: Android, CE CDM, and Linux tests

There's a few different things that can go wrong in the L3
initialization, with seeding and device key failures among others. They
should be recorded in metrics to track. Along the same lines, since
multiple errors can happen in conjunction, metrics needs to change to
add more fields for errors. This CL also adds the
hidl_metrics_adapter_unittest to the Android test scripts.

Change-Id: Ie5bcf81bbe294a1136c58410f90087a13b3d911d
2018-12-14 11:32:19 -08:00
Rahul Frias
65c64292b7 Merge "Enforce OEMCrypto insufficient resources error reporting" 2018-12-12 16:47:11 +00:00
Rahul Frias
afd11c0da5 Add support for Resource Rating Tiers
[ Merge of http://go/wvgerrit/67324 ]

This introduces the ability to query resource rating tier information
through the plugin and CDM. Resource rating tiers are also
sent in the client identification portion of the license request.

Bug: 117112392
Test: WV unit/integration tests
Change-Id: I68ac6dfc4362f61150af822bd526e346b5cc4bf7
2018-12-11 01:43:58 -08:00
Rahul Frias
5f96a20d99 Allow querying of OEMCrypto build information
[ Merge of http://go/wvgerrit/67503 ]

Bug: 117118184
Test: WV unit/integration tests
Change-Id: I8db90c1617e068a4711eb41a5852d15b5e228f2f
2018-12-10 21:48:13 -08:00
Rahul Frias
f98fbbb187 Enforce OEMCrypto insufficient resources error reporting
[ Merge of http://go/wvgerrit/63682 and http://go/wvgerrit/4977904 ]

Enforce OEMCrypto insufficient resources error reporting in CDM tests.
In addition, when CreateNew/LoadUsageEntry fails with OEMCrypto
insufficient resources error, delete a random usage entry
and retry. The current behavior evicts low index entries
from the usage table, which was a crude attempt to emulate a LRU.
This was deficient as, on occasion, it will result in the deletion
of a recently added usage entry.

Bug: 111260263
Bug: 113828866
Bug: 120433165

Test: Widevine OEMCrypto tests, integration tests. GtsMediaTestCases.
      Play movies and Netflix playback tests.
      GtsMediaTestCases MediaDrmTest#testUsageTableCapacity

Change-Id: I63340f76d1e2af3c6834b98ad816e11eea18fc7f
2018-12-10 00:09:56 -08:00
Srujan Gaddam
896ce2b5aa Refactor file_store to use smart pointers
Bug: b/119276649
Merge from: http://go/wvgerrit/66367
Test: Android, CE CDM, Linux unit tests

The FileSystem interface as it exists expects an Open for a file and
then a Close when finished. However, the Close doesn't delete the file
itself and depending on the platform, the underlying impl_ as well,
leading to a memory leak. To fix this leak as well as harden against
future memory issues, this change refactors the interface to shift away
from raw pointers and towards smart pointers.

Change-Id: I7a7132ea95cd3775796a540f510b698f4f27dd24
2018-11-30 16:25:58 -08:00
Rahul Frias
f0e855a8d4 Merge "Always use configured client authentication" 2018-11-17 23:18:20 +00:00
John W. Bruce
fb4d53bae6 Replace shared_ptr With std::shared_ptr
(This is a merge of http://go/wvgerrit/65783)

Straightforward patch to replace our shared_ptr implementation with
std::shared_ptr, which works identically for all our use cases.

Bug: 111851141
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I9e8624dd3cab70a45941a45eb553c1ea0c077d2f
2018-11-14 10:50:34 -08:00
Rahul Frias
9b7e2013d4 Update WV build and android version number change canary
[ Merge of http://go/wvgerrit/66145 ]

Bug: 119431010
Test: WV unit/integration tests
Change-Id: Ib869ee0df03dda6124ebcdb6ed8e502915ba9896
2018-11-12 23:54:16 -08:00
Rahul Frias
49f518a911 Always use configured client authentication
[ Merge of http://go/wvgerrit/66002 ]

Client authentication was needed when licenses were requested from
the Play movies license service. For UAT/staging client authentication
is set to the empty string.

The play movies license service has not been used recently for testing.
Also, client authentication has not been supported as one of the
command line arguments. This was even before the command line parameters
were consolidated in TestBase.

Since it is not possible to specify client authentication on the
command line, the configured(default) value is always used.
This CL will remove code in the test to check if it has
been specified on the command line. It can be added back later,
if we decide to support client authentication as an option.

b/119221644
Test: WV unit/integration tests

Change-Id: I4a7fab5ec27b4897c9a73bd3ff34615d8ae11c28
2018-11-11 13:01:07 -08:00
Rahul Frias
d374b17b7c Fix invalid iterator in CloseCdm
[ Merge of http://go/ag/5334065 and http://go/wvgerrit/65122 ]

Sessions were not being correctly released when CloseCdm() was called.
Broadcom noticed this issue and proposed the fix.

Bug: 117876077
Test: WV unit/integration tests, GtsMediaTestCases and playback tests
Change-Id: I8800744f2396f0955c76d5f3e187a69fe04330f6
2018-10-31 16:19:33 -07:00
Rahul Frias
ba3e8933c8 Avoid sending clear subsamples to the decoder before keys are loaded
[ Merge of http://go/wvgerrit/54880 ]

Sending clear subsamples but filtering out encrypted ones,
before the keys have been loaded, causes problems during decode.
This is because subsamples that contain the first and last
subsample flags may be filtered out.

Clear subsamples that have first and last subsample flags set
will still be allowed to be passed to the decoder.

Bug: 110251447
Bug: 73447733
Test: WV Unit/integration tests.
Change-Id: I8c91c88f6313ad7b7b21c1c95e4c5787381949c1
2018-09-19 09:37:32 -07:00
Fred Gylys-Colwell
b849630a6f Fix generic crypto tests
Merge from Widevine repo of http://go/wvgerrit/56524

Test: unit tests, including generic crypto tests, pass.
Bug: 72354901 Fix Generic Crypto tests.
Change-Id: I39404424acb2d896afe06c461a02e3664c0f45de
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
e635d4d384 Common test main
Merge from Widevine repo of http://go/wvgerrit/56521

This CL adds a common main routine for integration tests.  It sets a
default test configuration for the provisioning and license server
urls and certificates, and allows the user to set them on the command
line.

Test: current unit tests still pass.
Bug: 72354901 Fix Generic Crypto tests.
Change-Id: I604a3d9e15d50da5041794624c4571c0dcb091f5
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
4af5aaf18a Add test base that catches nonce flood
Merge from Widevine repo of http://go/wvgerrit/56520

This CL adds a test base that installs a test keybox and catches nonce
flood errors for all CDM tests.

In order to do this, a new class is added called a
CryptoSessionFactory.  The default factory just creates a new
CryptoSession.  All places in the code that create a new CryptoSession
now call the static method MakeCryptoSession, which uses the current
factory to create a CryptoSession.  If MakeCryptoSession is called and
there is no current factory, a default factory is created.

The CryptoSession constructor is now private, so that we do not
accidentally try to create one without using the factory.

For the new test base, we first create a special test
CryptoSessionFactory that creates a TestCryptoSession.  The test
factory catches the first call to MakeCryptoSession and injects an
installation of the test keybox after OEMCrypto_Initialize is called.

The TestCryptoSession injects a sleep statement and a retry whenever
it detects a nonce flood.

Test: current unit tests still pass.
bug: 72354901 Fix Generic Crypto tests.
bug: 111361440 Remove #ifdef from unit tests
Change-Id: I248e7f3c53721c04d2af412ef835e19bb4d15d9a
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
01ce294226 Correct pssh
Merge from Widevine repo of http://go/wvgerrit/56540

The pssh in request_license_test had the wrong size field.

Test: tested as part of http://go/ag/4674759
Change-Id: I6fed0fc8d11aec0a360d300e500a4ef62b658dad
2018-09-09 11:37:50 -07:00
Fred Gylys-Colwell
de8d11b8de Remove WrongMessageTest
Merge from Widevine repo of http://go/wvgerrit/48841

This test is not providing value to the CDM, as it seems to exist
primarily to validate server behavior. However, it is not doing what
it says it is (the request is rejected because it is using unparseable
garbage data, not because its key ID is unknown) and according to
tinskip@, the behavior it claims to be testing is not valid. (The
licensing service will not fail just because the key ID is unknown.
Indeed, if the test data is fixed to use a valid payload with an
unknown key ID, the test fails because the server does not.)

Bug: 78640287
Test: CE CDM Unit Tests
Test: Android Unit Tests
Test: tested as part of http://go/ag/4674759

Change-Id: Idfcff15ab3d15fdfb6eb111b5dff68aa5a23fb37
2018-09-09 11:37:48 -07:00
Fred Gylys-Colwell
947531a6a9 Refactor oemcrypto mock into stand alone reference code
Merge from Widevine repo of http://go/wvgerrit/46204
Refactor utility code - split the mock, step 1

Merge from Widevine repo of http://go/wvgerrit/46205
Move some OEMCrypto types to common header - split the mock, step 2

Merge from Widevine repo of http://go/wvgerrit/46206
Split mock into two -- step 3

Merge from Widevine repo of http://go/wvgerrit/47460
Split the mock into two -- step 3.5

The CL moves several files used by oemcrypto and cdm into a common
subdirectory, so that it may more easily be shared with partners.

The CORE_DISALLOW_COPY_AND_ASSIGN macro was moved to its own header in
the util/include directory.

This CL removes some references to the mock from other code, and puts
some constants and types, such as the definition of the keybox, into a
header in oemcrypto.

Test: tested as part of http://go/ag/4674759
bug: 76393338
Change-Id: I75b4bde7062ed8ee572c97ebc2f4da018f4be0c9
2018-09-02 11:45:16 -07:00