Merge from Widevine repo of http://go/wvgerrit/71323
When running multithreaded tests, we need to make sure there are no other
OEMCrypto calls between OEMCrypto_Initialize and the installation of the test
keybox.
bug: 123319961
test: ran juce's threading test
Change-Id: Ibd8951c764f6538da4afa9ad146a6a72064eb13a
(This is a merge of http://go/wvgerrit/71330)
The Service Certificate unit tests actually relied on the ability to
call Properties::Init() multiple times to clear previous mutable state.
Unfortunately, they didn't check the return code that could have told
them their mutable state wasn't being cleared and instead proceeded to
use a pointer which — depending on compiler — could be totally valid and
allow the test to pass or could be invalid and cause a segfault. You can
read the bug for a fuller explanation of the mechanics.
The fix is twofold. First, the tests will now assert out if insertion
into the property set map fails, preventing segfaults. Second, a helper
has been added to Properties that allows tests interested in
re-initializing Properties to do so. The default behavior for most tests
remains the same: Properties can only be initialized once and subsequent
calls to Properties::Init() are ignored.
This patch also fixed a few formatting issues I noticed.
Bug: 123099779
Test: Jenkins Unit Tests w/ GCC
Test: CE CDM Unit Tests w/ GCC & Clang
Change-Id: Ifd29f3ddf5cff934933cf47b92ecd12ab0a4a938
Bug: b/121214641
Merge of http://go/wvgerrit/70768
Tests: usage_table_header_unittests (with and without hardcoded values)
DeleteEntry fails if the last entry is in use, since it cannot shrink
the table any further via swapping. The LoadEntry_LoadUsageEntry...
tests test to see that after deleting an entry x amount of times, the
usage table can load an entry. If the entry we want to load is within x
positions of the last entry of the usage table, the method cannot
succeed for the aforementioned reason.
Change-Id: Iccdaf538cb4bcbd34855f36c71aceaeb93b4a770
Merge from Widevine repo of http://go/wvgerrit/69563
This CL also disables unit tests that depend on the old test keybox when run
against OEMCrypto v13 or earlier.
Unit tests that require a particular API level have been
removed. This requirement for Android is tested in GTS tests.
Bug: 119316243
Test: unit tests
Change-Id: I9a13dbaee1693ecea906fd0184a8e2590dc5beed
[ Merge of http://go/wvgerrit/70386 ]
This allows error codes from device files to be added as sub-errors when
errors such as GET_LICENSE_ERROR are encountered.
Bug: 112357085
Bug: 115382201
Test: WV unit/integration tests
Change-Id: I505a87086ce584efc7e482984c0f132ac5329e16
(This is a merge of http://go/wvgerrit/70667)
Request ID Index generation has historically worked by incrementing a
shared variable in one place and reading it in another place and
trusting the fact that CdmLicense calls these operations in a certain
order and only once per session to give each session a unique value.
This patch cleans this up a bit, having each session store the current
Request ID Index at the same time as it stores its Request ID Base. This
guarantees that each CryptoSession will receive a unique but stable
combination of Base and ID rather than relying on the calling pattern.
Since all this generation happens during the same function, the full
Request ID can be generated up-front and stored, making
GenerateRequestId() no longer necessary.
This patch also simplifies the threading story around this shared state
by using a std::atomic<uint64_t>. Bringing the code that interacts with
the shared state together into one place and replacing it with atomic
operations will simplify locking around this code when CryptoSession
locking is revamped in a future patch.
Bug: 70889998
Bug: 118584039
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I12d2f6501f872f1973e5a9af5125ca03f23e5a56
[ 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
[ 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
(This is a merge of modmaker@'s change from the Widevine repo,
http://go/wvgerrit/48880)
When using pattern encryption, WVCryptoPlugin needs to increment the
IV after each subsample. It should increment it based on the number
of actually encrypted samples (i.e. ignore clear data caused by
subsamples or pattern encryption).
In the common encryption spec, section 9.6.1 states:
If the last Block pattern in a Subsample is incomplete, the partial
pattern SHALL be followed until truncated by the BytesOfProtectedData
size and any partial crypt_byte_block SHALL remain unencrypted.
This fixes the counting of encrypted blocks to account for partial
patterns. This also makes it more efficient by removing the loop.
Bug: 111001481
Test: build_and_run_all_unit_tests
Test: Widevine GTS Tests
Change-Id: Ibd2bf10f64461b9bce10ef07453096fe4a4f6376
(This is a merge of http://go/wvgerrit/70303)
The new platform.cpp file was not added to every build file that needs
to reference it. This was not detected as all of these platforms are
non-Windows, and platform.cpp is only required on Windows builds right
now. To avoid future problems should it ever provide non-Windows
functionality, though, I am adding it to the build files now.
Bug: 122953649
Test: Android Build
Change-Id: I57b983ad078dfef198b7c3e97fb93336b09704b6
(This is a merge of http://go/wvgerrit/70303)
This adds a platform.h file to abstract some of the differences
between Windows and POSIX platforms. This includes ntohl, setenv,
and ssize_t.
Bug: 122953649
Test: Android Unit Tests
Change-Id: I3235f3f284b53d24d7365ff3f4a06dcd9b403697
The same merge conflict happened in the Widevine and Android repos, but
it was resolved differently. This patch brings the resolutions back in
sync.
Bug: 111504510
Bug: 111505796
Bug: 115358798
Test: Android Build
Change-Id: I5161ae3e1aad41ee034dc5fec59dad1c7699d65c
(This is a merge of http://go/wvgerrit/70384)
It turns out the reason the binary provisioning unit test was failing is
because the test base class was setting the property to turn on binary
provisioning before calling Init(), however all current Init()
implementations overwrite the value of that field. As such, the tests
weren't actually using binary provisioning. With that fixed, everything
passes; the binary provisioning flow doesn't appear to actually be
broken.
This is the exact same commit as was previously reverted,
cf5464d7a2fbecd1938ae0700199145b7b61c3c3. However, a pending patch fixes
the multiple runs of Properties::Init() that lead to the inconsistent
failures of the previous patch. (See http://go/wvgerrit/70383)
Bug: 112046733
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I79fc2c8d4d24505b46cab0e21eef85a37d66748d
(This is a merge of http://go/wvgerrit/70383)
Up until now, implementations of Properties::Init() have had to handle
potentially being called multiple times, at any point during runtime. In
practice, this has meant little for the actual implementations, and all
of them have committed the error of blowing away mutated property state
if the method is re-run at the wrong time.
This patch makes the platform implementations a private function,
Properties::InitOnce(), which Properties::Init() ensures will never be
called more than once per run.
Bug: 112046733
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: If33f5e37abfad5d26da8380b4bc25fc018450970
[ 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
Bug: b/121214641
Merge of http://go/wvgerrit/69703
Test: Android + Linux unit tests
LoadEntry attempts to handle INSUFFICIENT_RESOURCES by deleting an entry
and retrying, but it's possible that the randomly-generated number of
the entry to be deleted might match the entry we want to load. In this
case, we have wasted a retry, since the code just continues on to the
next iteration. This is changed to generate a number different from the
entry to load. Furthermore, if the number of usage entries is 1, we
break since there are no more entries to delete besides the one we want
to load. The code is also changed to call srand in the creation of the
usage_table_header, since without it, rand() would produce the same
values, and similarly, our random generation is changed to use a simple
mod. Tests are modified to reflect these changes.
Change-Id: I95e125b8adbd85d0189f9d40ca15f3fe69e6d6b9
Merge of http://go/wvgerrit/70163
New codes are being added to handle resource
contention, lost session state, frame size too
large and insufficient security level for
decryption. Also cleans up inconsistent use of
tamper detected error where invalid state error
should have been used.
bug:111504510
bug:111505796
test: cts and gts media tests, widevine integration tests
Change-Id: I96ee441717d32ccbcabaa85c8f6a0013055ce16e
[ Merge of http://go/wvgerrit/69724 ]
Some queries no longer require a session to be opened before they
can be answered - security level, current HDCP level, max HDCP level,
usage support, number of open sessions, max sessions,
OEMCrypto API version, current SRM version, SRM update support,
resource rating tier and OEMCrypto build information.
b/117104043
Test: WV unit/integration tests
Change-Id: I92f8249e5599860da8cbf42d3b16f25515a46c55
Bug: b/119881112
Merge of http://go/wvgerrit/68983
Test: Android + Linux tests for ref and L3
This CL removes tests from OEMCrypto that test shared license
functionality and code in the ref and L3 that handle shared licenses.
Change-Id: Ia11510d8db3fa6e471a4ebbdb371fd76b0812984
(The matching reversion in the Widevine Repository is
http://go/wvgerrit/69923)
This reverts commit c207ef8ea6.
Reason for revert: Widevine Buildbot failures
Change-Id: Ied9e36f9eaa94bb7e9cd13b8dff7a2cbdca07a07
(This is a merge of http://go/wvgerrit/69843)
It turns out the reason the binary provisioning unit test was failing is
because the test base class was setting the property to turn on binary
provisioning before calling Init(), however all current Init()
implementations overwrite the value of that field. As such, the tests
weren't actually using binary provisioning. With that fixed, everything
passes; the binary provisioning flow doesn't appear to actually be
broken.
Bug: 112046733
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I7413f7fb2227e596fb610d6ddc5b95cda2f406b8
Merge from http://go/wvgerrit/69603
In getSecureStop, the life of cdmStop will expire when
leaving the if (isCmdResponseTypeSuccess()) scope.
Since setToExternal() which is called by toHidlVec()
only performs a pointer assignment, the content of cdmStop
is lost and secureStop.opaqueData will have all zeros.
Test: netflix streaming and offline playback
Test: Play Movies & TV
Test: GTS test
-m GtsMediaTestCases --test com.google.android.media.gts.MediaDrmTest#testWidevineApi28
Test: GTS test
-m GtsMediaTestCases
bug: 120624463
Change-Id: I8da473d5fd06d091980eade4b7216856ef097e04
[ 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
Merge of http://go/wvgerrit/68986
Bug: b/120797208
Test: Android + Linux unit tests
OEMCrypto v15.1 introduced changes to full decrypt path testing.
This CL reflects those changes for the Level 3 code, including
removing InitializeDecryptHash and changes to error reporting.
Change-Id: I09cec6743524d326cb1a6c3ba4dd1764dbefff5f
Merge from Widevine repo of http://go/wvgerrit/68464
The Full Decrypt Path Testing design has changed to remove
OEMCrypto_InitializeDecryptHash. This CL updates the unit tests and
reference code.
Bug: 120795057
Test: unit tests
Change-Id: Iee28fa9034dc21cee81c5b894c192e260375eeee
Merge from Widevine repo of http://go/wvgerrit/68184
Please add comments to the original documents at http://go/oemcrypto
or http://go/wvdelta15.
Some unit tests will need to be updated. Those will be in a separate CL.
bug: 120795057 Full Decrypt Path Testing - change design
bug: 119688262 Full Decryption Path Test update section in go/wvdelta15
bug: 117898271 Corrections to Documentation
bug: 119881959 Remove shared license from documentation.
bug: 80540710 Document double call to OEMCrypto_DeactivateUsageEntry
Test: documentation and comment change only
Change-Id: I1ef35e15207d3dabea8329a1f05518370ec099e6
(This is a merge of http://go/wvgerrit/69165)
This printf() in the OEMCrypto Unit Tests was causing two log messages
to run together in the log.
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I5a981e201de347fc8fbdc50a94c7227f944f9e8c
Merge from: http://go/wvgerrit/69211
Cleanup unaligned code while working on b/117570686 and remove
a duplicate break statement.
Test: unit tests
./run_all_unit_tests.sh
Bug: 121971420
Change-Id: I0ca1dc0fe54e7fe3a87aa7c8dac7ef9da04e90b2