Commit Graph

820 Commits

Author SHA1 Message Date
Rahul Frias
e22d0ab48c Only export public symbols.
[ Merge of http://go/wvgerrit/67923 ]

Before, all symbols were being exported in the dynamic library.  Now
only the public symbols are.  This no longer has the unit tests load
the dynamic library, so we lose testing the dynamic integration; but
the unit tests use a lot of internals, even the top-level CDM ones.

Bug: 69271232
Bug: 69548115
Test: WV unit/integration tests
Change-Id: I62919937277ec785aca1f8b36b28caa2f9d8f3ea
2018-12-13 11:56:02 -08:00
Rahul Frias
0e28104cff Change from custom Lock to std::mutex.
[ Merge of http://go/wvgerrit/67884 ]

Now that we can use C++11, we should use the cross-platform std::mutex
type, not the custom pthread version.

Bug: 111850982
Test: WV unit/integration tests
Change-Id: If2fde2836826c5184609e6b1f3a6511206bd4594
2018-12-13 11:55:54 -08:00
Rahul Frias
65c64292b7 Merge "Enforce OEMCrypto insufficient resources error reporting" 2018-12-12 16:47:11 +00:00
Srujan Gaddam
b10d5c2a8f Merge changes from topic "level_3_oecv15"
* changes:
  Changes to adapter + gyp to support v15
  Add full decrypt path testing functionality to Level 3
  Update pointers to substrings in Level 3
  Update level 3 reference API for v15
2018-12-11 19:54:39 +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
e01b559bb7 Update ClientIdentification in proto
[ Merge of http://go/wvgerrit/67323 ]

This allows the client to report resource rating tier in
ClientIdentification.

Bug: 117112392
Test: WV unit/integration test
Change-Id: I5bcbd5217c376cb52be2548ee63e0b0232b411d3
2018-12-11 01:40:11 -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
John Bruce
dbef7f34ac Merge changes Ic23e2e48,I5d25844b
* changes:
  Google-style override & virtual
  Remove Sub-Licenses and Sub-Sessions
2018-12-07 00:35:51 +00:00
Srujan Gaddam
732c077f79 Changes to adapter + gyp to support v15
Bug: b/117558570
Test: Android, CE CDM, and Linux tests
Merge of http://go/wvgerrit/67566

This CL adds changes to support the Level 3 upgrade to v15 with both the
dynamic and static adapters. It also rearranges the wvcrc.cpp files so
that the tests have their own copy and Level 3 can just use the one in
ref/src.

Change-Id: Ieee2859601881aa1800622454e6ce0345eb94aa7
2018-12-06 23:04:12 +00:00
John W. Bruce
92cf993cf5 Add Missing Includes Netflix Pointed Out
(This is a merge of http://go/wvgerrit/66810)

Netflix discovered that several files were only compiling because of
transitive includes via the Metrics code. This patch adds the missing
headers they noted.

Bug: 118676365
Test: CE CDM Build
Change-Id: Ifbc4e5d4276d1c3fb9bbd677230cd431e34e5c76
2018-12-06 09:31:42 -08:00
John W. Bruce
b771d93514 Google-style override & virtual
(This is a merge of http://go/wvgerrit/66625)

Google C++ Style dictates that methods which override base class or
interface methods should be declared "override" but not "virtual". Since
our codebase has not had access to "override" until now, many of our
classes do not follow this rule. I've updated as many places as I could
find to follow Google C++ Style, which should hopefully help us catch
errors better in the future.

Bug: 111851141
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: Ic23e2e482e967256da306791532b5fec7b81b2f2
2018-12-06 09:01:18 -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
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
Fred Gylys-Colwell
e59b976625 Update comments and unit tests for InstallKeyboxOrCert
Merge from Widevine repo of http://go/wvgerrit/66865

This CL updates the comments for the code that uses
InstallKeyboxOrCert to install a keybox or oem cert at runtime.  There
is also a new unit test for the device id.  There are not many unit
tests because we don't want to accidentally overwrite the production
keybox or cert on a device when running tests.

bug: 111725154
test: unit tests
Change-Id: Ide9b3d4732f3f96a723a128907babe7e59c02ffc
2018-11-26 14:08:17 -08:00
Rahul Frias
7beac0352e Merge "Address NTS TCs AUDIO-026-* failures" 2018-11-26 18:28:43 +00:00
TreeHugger Robot
f76387d1fc Merge "Fix for off by one error and correct comments" 2018-11-26 06:11:21 +00:00
Rahul Frias
14978a0832 Address NTS TCs AUDIO-026-* failures
[ Merge of http://go/wvgerrit/66083 and http://go/ag/5445191 ]

Fix proposed by amlogic. Release usage session early in the CdmEngine
destructor to avoid SIGBUS.

Bug: 118646062
Test: WV unit/integration tests.

Change-Id: I8b419c57814dc32e9873173ab6c24d209bdcc3a0
2018-11-21 13:43:15 -08:00
Fred Gylys-Colwell
3a3307242d Fix for off by one error and correct comments
Merge from Widevine repo of http://go/wvgerrit/66711

This addresses review comments for the OEMCrypto v15 CLs, as documented in
b/119685652.

Test: unit tests
Bug: 119685652
Change-Id: I0e7ce13dd80335eb1a12240df5c1df2c34ba4298
2018-11-18 14:00:28 -08:00
Rahul Frias
f0e855a8d4 Merge "Always use configured client authentication" 2018-11-17 23:18:20 +00:00
Rahul Frias
dd55fefe87 Add support for HDCP 2.3
[ Merge of http://go/wvgerrit/66283 ]

Bug: 78773763
Test: WV unit/integration tests

Change-Id: I5050295a7aa6d829a66adce5d5de86b725a82738
2018-11-16 23:46:27 -08:00
Rahul Frias
d8cc5481e3 Update license_protocol and client_identification protos
[ Merge of http://go/wvgerrit/65442 ]

This also requires the removal of sub session related code as references
were removed from the proto.

Bug: 119077124
Test: WV unit/integration tests
Change-Id: Ida1a591afc267ec97344e5bba00bbf401887a202
2018-11-16 23:44:43 -08:00
Fred Gylys-Colwell
246621c5ce Full decrypt path testing
Merge from master branch of Widevine repo of http://go/wvgerrit/66080
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64002

This CL updates OEMCrypto reference code and unit tests to support full decrypt
path testing.

Test: unit tests
Test: tested as part of http://go/ag/5501993
Bug: 34078913
Change-Id: Ia67374599d6619698a336f41513068ad04294e7f
2018-11-16 17:14:00 -08:00
Fred Gylys-Colwell
4fa255ea51 Add Sandbox ID support
Merge from master branch of Widevine repo of http://go/wvgerrit/66078
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64022

This CL updates OEMCrypto ref code, unit tests, and core code for
setting the sandbox id before initializing OEMCrypto.

Test: unit tests only
Test: tested as part of http://go/ag/5501993
Bug: 115834255
Change-Id: Id9831680fe4db1c69413815931cae4bc80df0c01
2018-11-16 17:14:00 -08:00
Srujan Gaddam
926a780397 Resize mac_key string to 2 * MAC_KEY_SIZE
Merge from master branch of Widevine repo of http://go/wvgerrit/66074
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/65102

Currently, the string only contains the mac_key_server, which isn't an
issue currently because we just get the offset into the message for the
enc_mac_keys pointer when calling LoadKeys, and rely on OEMCrypto to
read the 64 bytes. However, v15 will need the length of the enc_mac_keys
to reflect the true size.

Test: tested as part of http://go/ag/5501993
Bug: 115874964

Change-Id: Id76e91feb176755467c0433e6b0e87d2bb221033
2018-11-16 17:14:00 -08:00
Srujan Gaddam
e6439255ba Update OEMCrypto calls to use substrings
Merge from master branch of Widevine repo of http://go/wvgerrit/66073
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64083

As part of the update to v15, LoadKeys, RefreshKeys, and
LoadEntitledContentKeys should all use offsets and lengths into the
message rather than a pointer for its parameters. The CDM, tests,
adapters, and OEMCrypto implementations are changed to reflect this.

Test: tested as part of http://go/ag/5501993
Bug: 115874964

Change-Id: I981fa322dec7c565066fd163ca5775dbff71fccf
2018-11-16 17:14:00 -08:00
Fred Gylys-Colwell
4550979f22 OEMCrypto Resource Rating
Merge from master branch of Widevine repo of http://go/wvgerrit/66072
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63764

This adds the function OEMCrypto_ResourceRatingTier to the oemcrypto referenece
code, dynamic adapter, and unit tests.

Bug: 117110800
Test: tested as part of http://go/ag/5501993

Change-Id: Idf47af405f0c69601108b75c788a97b30abdb39d
2018-11-16 17:14:00 -08:00
Fred Gylys-Colwell
43a47a60c0 Add session parameter to OEMCrypto_CopyBuffer
Merge from master branch of Widevine repo of http://go/wvgerrit/66070
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63662

To make the threading model more clear, CopyBuffer is now a session function.
This means we need to pass in which session the current thread locks.

Test: unit tests.
Test: tested as part of http://go/ag/5501993
Bug: 113680369
Change-Id: I2fdd2cfcaab99f3793950b3845941463675f5e4c
2018-11-16 17:14:00 -08:00
Fred Gylys-Colwell
ef067572bc Remove error OEMCrypto_KEY_NOT_LOADED
Merge from master branch of Widevine repo of http://go/wvgerrit/66066
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63628

The error code OEMCrypto_KEY_NOT_LOADED is redundant with
OEMCrypto_ERROR_NO_CONTENT_KEY and OEMCrypto_KEY_NOT_ENTITLED.  The
function LoadEntitledContentKey should return KEY_NOT_ENTITLED if it
does not find the corresponding entitlement key in its key table.  All
other functions that do not find a key id in the key table should
return OEMCrypto_ERROR_NO_CONTENT_KEY.  This includes QueryKeyControl,
SelectKey, and RefreshKeys.

Test: unit tests
Test: tested as part of http://go/ag/5501993
Bug: 115574797
Change-Id: Ida2111f32e331b99f3f0c77fa404a42654d0870c
2018-11-16 17:09:32 -08:00
Fred Gylys-Colwell
f3e9d84484 Add build info API to OEMCrypto
Merge from master branch of Widevine repo of http://go/wvgerrit/66065
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63080

This is for the reference code, the unit tests, and the oemcrypto adapter.

Bug: 116414218
Test: unit tests
Test: tested as part of http://go/ag/5501993

Change-Id: I05a631f6cfcf1584a748b3a0c9ae48633893589f
2018-11-16 15:38:45 -08:00
Fred Gylys-Colwell
f2edb8f2dd Update API version to 15
Merge from master branch of Widevine repo of http://go/wvgerrit/66064
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63063

This is in the reference code for OEMCrypto, and in the unit tetss.

Bug: 111939411
Test: unit tests
Test: tested as part of http://go/ag/5501993

Change-Id: I2cc2e7028f62d1c375eb632452eef94566fa9ae3
2018-11-16 15:38:45 -08:00
Fred Gylys-Colwell
05fc8b5e97 Temporarily use old test keybox
Merge from Widevine repo of http://go/wvgerrit/65922

This CL puts the old 4121 test keybox back into the unit and android
integration tests so that we can run tests on a device with OEMCrypto v13.

This change should not be released, and should not be included in CE CDM.  It
should be removed once we have more test devices with v14 or v15.

Bug: 119313532
Bug: 119316243
Test: unit tests
Test: tested as part of http://go/ag/5501993

Change-Id: If6a459e11176e07c66fbe6fc45c63d87595a20dc
2018-11-16 15:38:45 -08:00
John Bruce
218aa76560 Merge changes I37d6d7aa,I9e8624dd,I96c2015a,I0b755962
* changes:
  Replace scoped_ptr With std::unique_ptr
  Replace shared_ptr With std::shared_ptr
  Replace UniquePtr with std::unique_ptr
  override, Don't OVERRIDE
2018-11-16 18:08:02 +00:00
Srujan Gaddam
49906026b7 Merge "Setup test ROT + log empty root key in ref" 2018-11-14 21:01:47 +00:00
John W. Bruce
b182a7445e Replace scoped_ptr With std::unique_ptr
(This is a merge of http://go/wvgerrit/65782)

We have had our own scoped_ptr implementation that is used throughout
the codebase. Now that we support C++11, we can replace these with
std::unique_ptr.

Doing this replacement exposed a few places where the two were not
interchangeable. OEMCrypto Ref was doing some unsafe things with passing
scoped_ptrs to functions and has been updated to use move semantics. And
a few constructors were explicitly constructing a scoped_ptr with NULL,
which is ambiguous with std::unique_ptr. These have been replaced with
default constructor calls.

Bug: 111851141
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I37d6d7aad4906709381c74f0c5439f826d2be768
2018-11-14 10:50:34 -08: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
John W. Bruce
39cfe6037f Replace UniquePtr with std::unique_ptr
(This is a merge of http://go/wvgerrit/65264)

Now that we have C++11, we can remove Android's hand-rolled UniquePtr in
favor of std::unique_ptr.

Bug: 111851141
Test: Android Unit Tests
Change-Id: I96c2015aa2422da66a4bcbefb927dacc5f6e782f
2018-11-14 10:50:34 -08:00
John W. Bruce
d902366ac8 override, Don't OVERRIDE
(This is a merge of http://go/wvgerrit/65263)

Now that C++11 is mandatory, we can drop the OVERRIDE macro which was
inconsistently used in the codebase in favor of using the override
keyword directly.

Bug: 111851141
Test: CE CDM Unit Tests
Test: Android Build
Change-Id: I0b7559624b84feb19740afd63463dadd243412b0
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
9fc06b07a3 Merge "Fix invalid iterator in CloseCdm" 2018-11-07 17:16:38 +00:00
Rahul Frias
39fd24b8d8 Merge "Avoid double release of crypto_lock_" 2018-11-07 17:14:56 +00:00
Srujan Gaddam
5c2f991973 Setup test ROT + log empty root key in ref
Bug: b/117897682
Test: unit tests

Merge of http://go/wvgerrit/65223

Gtest setup does not call the base class' setup if it's defined in the
derived class. As a result, the WvCdmEngineTests were not installing the
test root of trusts in the OEMCrypto, which leads to segfaults when
using a key derived from the root of trust when a real root of trust
doesn't exist. The test class' setup is changed to use its base class'
methods, and logging is added to handle empty derived keys.

Change-Id: Ia574c4ade48206d771d6079fb3b67ccd7653428c
2018-11-01 16:02:37 -07:00
Rahul Frias
19c582aac7 Avoid double release of crypto_lock_
[ Merge of http://go/wvgerrit/65162 ]

Bug: 118645525
Test: WV unit/integration tests
Change-Id: Ia8c8e156cf5a5a795d2a502dcb021936b99d0367
2018-10-31 18:41:28 -07: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
058b80f906 Partner (Amazon) reported a memory leak
[ Merge of http://go/wvgerrit/64682 ]

Looks like we do not delete control_block_

Bug: 117126556
Test: WV unit/integration tests
Change-Id: If0b4db163276bbf016bb81ed7e8ef56fa66ea30e
2018-10-31 10:22:14 -07:00
John W. Bruce
5d4932264f Allow Reloading Partially-Released Licenses
(This is a merge of http://go/wvgerrit/62780)

The EME spec requires that it be possible to do the following flow:

  1) Generate a release request for a persistent session.
  2) Close the session.
  3) Load the persistent session.
  4) Update the session with the release response.

This flow is used by Netflix in their API as well. However, our code did
not support this flow, as it rejected attempts to reload
partially-released sessions.

This patch changes attempts to load sessions that have already had
release messages generated into release-retry reloads, allowing them to
be released.

Bug: 113167010
Test: CE CDM Unit Tests
Test: Android CDM Unit Tests
Change-Id: I75bb7c75911e0fad1584bd8dd27f83c17f73bf45
2018-10-09 14:08:28 -07: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
Jeff Tinker
44fe62b0a6 Remove spurious "No Widevine PSSH" error log message
This log message was printed if initialization data was
not provided, which is actually not an error condition.

bug:116045153
Change-Id: I5597286ddf33d5b6c17f69f9a6a7cdba469b46b6
2018-10-05 20:51:11 +00:00
Rahul Frias
adfc0093f5 Rename method CanUseKey for clarity
[ Merge of http://go/wvgerrit/60240 ]

Since the method is not a general purpose check and only verifies that
the key can be used for a given security level the method
has been renamed PolicyEngine::CanUseKeyForSecurityLevel.

Bug: 115701771
Test: WV unit/integration tests
Change-Id: Icd6789538bb709d2a48c67bbd7bc810f4b000e14
2018-09-19 09:46:08 -07:00