[ Merge of http://go/wvgerrit/64402 ]
Changes to support PSSHs for single content and entitlement licenses in the
same PSSH tightened up validation of PSSHs. Some of the test PSSH had
incorrect length fields which led to VTS test failures.
b/117265150
b/117616791
b/117616861
Test: VtsHalDrmV1_0Target
Change-Id: I86354817eb9060a7bcea774583c4d4155a400fff
[ Merge of http://go/wvgerrit/63782 ]
Add FALLTHROUGH_INTENDED for clang compiler.
Bug: 117675755
Test: build with global -Wimplicit-fallthrough.
Change-Id: I603042152ae8fb7e6518ca24e404df1d63097337
(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
(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
This log message was printed if initialization data was
not provided, which is actually not an error condition.
bug:116045153
Change-Id: I5597286ddf33d5b6c17f69f9a6a7cdba469b46b6
b/111246860
Merge of http://go/wvgerrit/60040
The libraries were built with the following optimization flags:
arm: -02
arm64: -02
x86: -01
x86_64: -01 (-02 was giving segfaults)
mips: -01
mips64: -01
linux: -02
AES tables are currently obfuscated as part of Haystack, and
deobfuscated everytime they're being used as part of decryption. This
adds a considerable performance hit in constantly loading and unloading
these buffers. Since they're open source code (see:
https://github.com/openssl/openssl/blob/master/crypto/aes/aes_core.c),
obfuscating them doesn't provide much benefit.
[ 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
[ 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
Merge from Widevine repo of http://go/wvgerrit/55462
Instead of calling dlclose on liboemcrypto.so after each terminate,
this CL keeps the library loaded. Although the original bug
b/72831885 has been fixed, there is still some lingering worry about
possible hard-to-find resource leaks in dlclose.
For more context, see the discussion around the original bug
b/72831885. The fix that closed this bug has more discussion:
https://boringssl-review.googlesource.com/c/boringssl/+/25784 In
particular, we only fixed a known resource leak in boringssl, not in
any other libraries, and we added a patch that the borringssl team was
not very happy to include because it was not very thread safe.
bug: http://b/72831885 d2i_PKCS8_PRIV_KEY_INFO_bio returns null
test: unit tests on taimen.
Change-Id: I73b5e69bf300e03fe567b8e7e1d8e0e08b6bca37
Merge from Widevine repo of http://go/wvgerrit/55460
This test ensures that different oemcrypto sessions can use different RSA keys.
bug: 110319198 Test concurrent sessions can use different DRM certificates
test: unit tests on taimen
Change-Id: Id75eedea347d453987dfe42894a8a7301e345674
Merge from Widevine repo of http://go/wvgerrit/57640
Add a unit test for OEMCrypto to handle a small buffer.
Test: unit tests
bug: 78233951
Change-Id: I5efe088705e2d248ab9ea45d8576daf69ad8bcdb
Merge from Widevine repo of http://go/wvgerrit/59700
This CL sets the environment variable MODEL_NAME to be the current
unit test. When running on a test platform, this environment variable
is used in the license request as model_name.
test: unit tests.
bug: 38004627
Change-Id: I347c5cec35942d68285cc01615b976097f37d214
Merge from Widevine repo of http://go/wvgerrit/58820
This adds an option to the oemcrypto mod mock so that it will limit
the usage table to the specified size. It returns the resource limit
error code when the maximum size is reached.
bug: 111260263
test: unit tests
Change-Id: I166b06855fba77ae8ddd13a922fe05be93f2c8f6
Merge from Widevine repo of http://go/wvgerrit/55461
This CL allows provisioning 3.0 devices to install their OEM certs
from an initialization partition. This method is already used for
keyboxes on Android -- we are just adding the ability to use it for
OEM certs, also.
Also, for v15, we require OEMCrypto to report a valid certificate in
the unit tests.
bug: 111725154
test: unit tests
Change-Id: I142c84a1a67bdb4cee943cfd12a632421901eb24
Merge from Widevine repo of http://go/wvgerrit/58200
This CL removes code from the testbed that is duplicated in the
reference code using inheritance.
bug: 76393338 Split mock into reference code and testbed code
test: unit tests
Change-Id: I7b5f5330a595fa1756e6dfdf75bc07addb6107a8
Merge from Widevine repo of http://go/wvgerrit/57720
Now that we have oemcrypto mock split into reference and testbed code, it is
time to remove the part of testbed that is an exact copy of the reference code
and just use the reference code.
Test: unit tests
Bug: 76393338
Change-Id: I3831a3f0118221c21ff1c28e6b6101b27b889012
Merge from Widevine repo of http://go/wvgerrit/57584
This CL is part of the long slog to split the mock into safer
reference code and dangerous test code.
bug: 76393338 (Step 4) Split mock into reference code and testbed
bug: 36515266 OEMCrypto Logging Cleanup
test: unit tests
Change-Id: Idbbf704a5947e2f161af7b71c328423f02982378
Merge from Widevine repo of http://go/wvgerrit/56526
This CL removes the test keybox from OEMCrypto reference code.
Test: unit tests
Bug: 76393338 split mock into ref and testbed
Change-Id: I4bf0eb777c6851191d0ac9ccf8e2b42c55c8f6b9
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
Merge from Widevine repo of http://go/wvgerrit/56522
This CL moves provisioning from core/test/cdm_engine_test.cpp to
test_base.cpp because other tests should also only be run when the
device has been provisioned.
It also adds a fake license server. The license holder helps a test
create a license request and then generates a bare-bones license,
without actually sending anything to a real license server.
Test: more unit tests pass than before.
Bug: 72354901 Fix Generic Crypto tests.
Change-Id: Iec067a6a1fb91fa8fd7b904fdf36e90981e293a3
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
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
Merge from Widevine repo of http://go/wvgerrit/55620
There were two places that explicitly referenced BoringSSL instead of
OpenSSL. (Not counting, of course, all the BoringSSL functions and
headers that still have "OpenSSL" in their names.) This change fixes one
to mention either library and the other to specifically mention
BoringSSL.
Bug: 70636815
Test: CE CDM Unit Tests
Change-Id: I8703e1c427c66953fcc565a4f8f85093c7180f46
Merge from Widevine repo of http://go/wvgerrit/56760
This CL backs out one restriction added in http://go/wvgerrit/42941.
In that CL, a sample would not be processed if the policy engine says
the key cannot be used for a given security level. The change relaxes
the check and does not run the verification if the sample is clear.
Bug: 112113797
Bug: 115758660
Test: GTS tests. Unit tests. Verified Play movies and Netflix.
Test: version number unit tests fail as expected.
Change-Id: I5238745c3d3d7f0eb7fae203f4579e8df4d0681b
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
This CL cleans up some bad merges of client ID code, entitlement keys,
and concurrent session access. After this CL, core cdm code on
android should match that on widevine at the commit 2f916720 on branch
master.
CLs merged here are based on:
http://go/wvgerrit/50483 Protect sessions from concurrent access
http://go/wvgerrit/48860 Remove duplicate information from client identification
http://go/wvgerrit/49040 Revert revertion of Client ID Expansion
http://go/wvgerrit/46448 Test Entitlement Licenses
Test: tested as part of http://go/ag/4674759
Change-Id: I45854d6b034c247b16073a96d6ff3ea953ded3ae
There were some mistakes in previous merges from pi-dev to master in
whitespace and copyright notices. This fixes them.
Test: tested as part of http://go/ag/4674759
Change-Id: Iae46c121de59233b62925a4d8c97f2b370e3e7f1
Some of http://go/wvgerrit/46251 from Widevine repo.
The rest was merged in the oemcrypto refactor.
When we standardized on BoringSSL, these conditional compilations that
had been added as a stopgap for OpenSSL became unneeded. However, they
were not noticed and removed at the time.
Bug: 72459799
Test: CE CDM Unit Tests
Test: tested as part of http://go/ag/4674759
Change-Id: I693f691ffcb255e03660edaa6743cd0fb9ef12c6
Merge from Widevine repo of http://go/wvgerrit/45940
Since the Level 3 OEMCrypto is being updated to Provisioning 3.0, its
SPOID would be derived from its OEM Certificate, breaking backwards
compatibility. This CL changes how we determine what unique id to use
for SPOIDs by checking to see if OEMCrypto_GetDeviceID is implemented,
and if so, using the id returned from that call. If not and the root
of trust is an OEM Cert, we continue to use that OEM Cert.
This allows Level 3 devices to keep the same SPOID when they undergo a
field update to Provisioning 3.0.
Also, the Level 3 OEMCrypto will share a single OEM certificate across
all devices with the same architecture. Since the OEM Cert is not
unique, it cannot be used to derive a unique id. By using the unique
id returned by OEMCrypto_GetDeviceID, we can generate a unique SPOID.
The id from OEMCrypto_GetDeviceID has always been required to be
unique for devices with keyboxes. The functionality and use of this
function for Provisioning 3.0 devices was introduced in OEMCrypto API
version 14.1.
Test: tested as part of http://go/ag/4674759
Change-Id: I65af8246c9312c75c570a2d518caa3de633007c4
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
Merge from Widevine repo of http://go/wvgerrit/50560
There were some compiler warnings about converting true and false to
integers in EXPECT_EQ which were solved by using EXPECT_TRUE and
EXPECT_FALSE.
Test: tested as part of http://go/ag/4674759
Change-Id: Ie55b53ce48301af64ee2dff04642cbda02c1c41e
Merge from Widevine repo of http://go/wvgerrit/43202
Sync the definition of WidevinePssh data with the latest in support of
entitlement keys.
bug: 73297961 Fix or remove sublicense support.
Test: tested as part of http://go/ag/4674759
Change-Id: Ia9faf82732854a705b4b14430169ce4c8ecbcfcd
Merge from Widevine repo of http://go/wvgerrit/53883
Note: this CL does not modify license_key_status.cpp because the
previous CL already included those changes.
OEMCrypto v14 only supports one entitled key per entitlement key at a
time. Unfortunately, some partners have use cases that require using
old entitlement keys after the new keys have been loaded. Most
notably, when a key rotation occurs, the new PSSH will often be loaded
before the playback position catches up to the PSSH in the stream,
meaning that decryption will need to continue using the old keys for a
bit.
To fix this, EntitlementKeySession now caches the entitled keys when
they are loaded and only loads them under their matching entitlement
key when SelectKey() is called. This ensures that the right entitled
key is loaded for a given entitlement key before decryption.
The entitlement key integration tests have been updated to verify that
the old entitled keys still work even after loading new entitled keys.
Also, several places in the code that assumed loading new entitled
keys would wipe out the old keys have had to be modified.
Bug: 78652567
Test: CE CDM Unit Tests
Test: tested as part of http://go/ag/4674759
Change-Id: I6fac9dfe2b170ad68fb7cdb5bc8d6a2f35a20c2c
Merge from Widevine repo of http://go/wvgerrit/49003
CopyOldUsageEntry currently needs the old usage table to be loaded via
CreateOldUsageEntry. The CDM uses a workaround by creating a dummy old
entry, but the OEMCrypto code should be responsible for this. However,
since there have been several versions released with the current
OEMCrypto spec, the CDM code would have to still exist to support
implementations of that spec. Therefore, in order to avoid having to
support both a CDM with this workaround removed (as well as updating
the spec) and a CDM with it still in place, this workaround should be
canonicalized.
b/65730828
Test: tested as part of http://go/ag/4674759
Change-Id: I4619c551b79a53746683519d284663bf513ec38d
Merge from Widevine repo of http://go/wvgerrit/53465
It may not be clear that Properties::Init is called multiple
times. This CL adds an explanation in the header file. The function
itself is platform specific.
Test: tested as part of http://go/ag/4674759
Change-Id: I68010c594ec146e36161ae0f4f44d53caefa1896
Merge from Widevine repo of http://go/wvgerrit/53640
While HttpSocket supports both secure and insecure requests, the
error-handling code in HttpSocket::Read() was written assuming that
the insecure code path was previously taken. This resulted in spurious
and misleading error messages being printed when an SSL error
occurred, and it also meant that retryable SSL responses were not
being retried. Also, the code for detecting a closed connection was
technically incorrect, although a quirk of BoringSSL meant that it
happened to work well enough to go unnoticed.
This patch adds separate SSL error handling from the non-secure error
handling. It correctly checks for a closed connection. It will retry
retryable errors after a delay. And it prints the correct BoringSSL
error when an unrecoverable error occurs. There should be no change in
behavior for insecure connections.
Bug: 77338045
Test: CE CDM Unit Tests
Test: tested as part of http://go/ag/4674759
Change-Id: I8c45ca5771f22c11716d2e3649de91ab1acc1954
Merge from Widevine repo of http://go/wvgerrit/50481
Original CL http://go/wvgerrit/47520
The original CL was not completely merged to master on Android, so
this CL only reverts the left-over bits.
The original fix was not sufficient to address all race conditions. A
subsequent CL will address them.
Bug: 73781703
Bug: 79158083
Bug: 79262108
Test: tested as part of http://go/ag/4674759
Change-Id: Ib6c55ab5434e08fe61e0f65623ac8c7b2dc5aaa1
Merge from Widevine repo of http://go/wvgerrit/53625
Passing the third parameter to std::string::insert() as an integer
technically makes for an ambiguous method call, as there are two
overloads that could accept these arguments. While baseline GCC and
Clang discern our intent here correctly, seawardt@ discovered that
XCode is more pedantic and requires that we pass the third parameter
as a char to disambiguate.
Test: WvCdmEnginePreProvTestUat.ProvisioningServiceCertificateInvalidTest
Test: tested as part of http://go/ag/4674759
Change-Id: I65a2506209215cd081c685faac26e08bae486d5e