Commit Graph

2813 Commits

Author SHA1 Message Date
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
3c42b91471 Merge "Update WV build and android version number change canary" 2018-11-13 18:12:07 +00: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
TreeHugger Robot
e89c9b969c Merge "Parameterize "forbid analog" in mod mock" 2018-11-10 16:05:37 +00: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
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
Colin Cross
c0144ac97f Add SetValue for unsigned long for uint64_t
am: b0f80eb4a7

Change-Id: Ia95df0946a40f0383c32f94006576220205e613d
2018-10-30 14:11:46 -07:00
Colin Cross
b0f80eb4a7 Add SetValue for unsigned long for uint64_t
google::protobuf::uint64 is changing from unsigned long long to
uint64_t, which is sometimes unsigned long long and sometimes
unsigned long.  Add a SetValue specialization for unsigned long.
Mark both the unsigned long and unsigned long long specializations
as sometimes unused, they will be unused if uint64_t is the other.

Bug: 117607748
Test: m checkbuild
Change-Id: I8bec0be6cd7e13354cf96a7e510fe2b920aec561
2018-10-27 23:35:51 -07:00
Rahul Frias
d44294b663 Address VTS test failures
[ 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
2018-10-22 12:09:06 -07:00
Rahul Frias
e2a1682b99 Suppress implicit-fallthrough warnings.
[ Merge of http://go/wvgerrit/63782 ]

Add FALLTHROUGH_INTENDED for clang compiler.

Bug: 117675755
Test: build with global -Wimplicit-fallthrough.
Change-Id: I603042152ae8fb7e6518ca24e404df1d63097337
2018-10-15 19:04:26 -07:00
John Bruce
de66ef118d Merge "Allow Reloading Partially-Released Licenses" 2018-10-12 03:10:31 +00:00
Srujan Gaddam
1cc16a83c8 Merge "Move AES tables to clear buffers for decryption" 2018-10-11 18:35:08 +00: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
Srujan Gaddam
c2a3cf767d Move AES tables to clear buffers for decryption
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.
2018-09-25 17:10:45 -07:00
TreeHugger Robot
fcb428fc26 Merge "Multiple RSA keys unit test" 2018-09-24 21:54:35 +00:00
TreeHugger Robot
071836c43f Merge "Unit test with small buffer" 2018-09-20 19:25:17 +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
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
TreeHugger Robot
0c072a628c Merge "Change keys_ to key_statuses_" 2018-09-19 01:16:49 +00:00
Fred Gylys-Colwell
edb7de2923 Avoid dlclose
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
2018-09-18 16:52:03 -07:00
Fred Gylys-Colwell
20e85635a2 Multiple RSA keys unit test
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
2018-09-18 23:49:47 +00:00
Fred Gylys-Colwell
e288d10026 Unit test with small buffer
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
2018-09-18 16:48:13 -07:00
Fred Gylys-Colwell
f97624e477 Change keys_ to key_statuses_
Merge from Widevine repo of http://go/wvgerrit/59980

This CL addresses review comments from http://go/ag/4454369.

Change-Id: I5fafafef9a2e9ccbeac3f8d18c3d6335e2de61e8
2018-09-18 16:47:08 -07:00
Fred Gylys-Colwell
48b8fa860e Parameterize "forbid analog" in mod mock
Merge from Widevine repo of http://go/wvgerrit/43660

This CL adds parameters to the mod mock to control various analog
output behaviour.

bug: 38005556

Change-Id: I308b300a2dd73f6bb7fb798d56c2c631a09f3765
2018-09-18 16:41:36 -07:00
Fred Gylys-Colwell
f4258cc628 Send test name to server
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
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
f572d60633 Restrict usage table size in mod mock
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
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
562c14b5f1 Use InstallRootKeyCertificate for keybox and cert
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
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
3a2d291dc5 Testbed classes inherit from oemcrypto reference code
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
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
a0961a8834 Merge common code
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
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
41917224f5 Remove dangerous logging from OEMCrypto Reference code
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
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
e37509dcb2 Remove keybox from OEMCrypto ref
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
2018-09-18 16:33:11 -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
5095bb746e Handle KEY_NOT_LOADED error
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
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
790799ceaa Refactor provisioning tests
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
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
c06b55b42f Refactor Android L3s
Merge from Widevine repo of http://go/wvgerrit/57082
Merge from Widevine repo of http://go/wvgerrit/55420
Merge from Widevine repo of http://go/wvgerrit/52620

Refactor Android Level 3 libraries.

x86/libl3oemcrypto.cpp    Level3 Library 8162 Jul 31 2018 13:01:54
arm/libl3oemcrypto.cpp    Level3 Library 8158 Jul 31 2018 13:02:18
mips64/libl3oemcrypto.cpp Level3 Library 8161 Jul 31 2018 13:02:12
arm64/libl3oemcrypto.cpp  Level3 Library 8159 Jul 31 2018 13:02:17
mips/libl3oemcrypto.cpp   Level3 Library 8160 Jul 31 2018 13:02:22
x86_64/libl3oemcrypto.cpp Level3 Library 8163 Jul 31 2018 13:02:04

b/110952756
b/79203567

Test: unit tests on taimen and arm and x86 emulator.
Test: GTS tests on taimen.
Change-Id: I8a3af773983f84c73ac23851f4e6bf59690bf62b
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
d9c5e59e00 Rename OpenSSL to BoringSSL
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
2018-09-18 16:33:09 -07:00
Fred Gylys-Colwell
2c940856fd Allow clear lead to play before key policy loaded
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
2018-09-18 16:33:07 -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
7bd1d0ea51 Update OEMCrypto L3 to v14
This CL updates the level 3 library to v14. It includes the following CLs:

http://go/wvgerrit/52941 Change initialization of TimeInfo object in L3
http://go/wvgerrit/50820 Use memmove instead of relocs memcpy
http://go/wvgerrit/49845 Use memmove or the relocs memcpy in entry_points
http://go/wvgerrit/48884 Merge back rollback changes from pi-dev
http://go/wvgerrit/47985 Deprecate all_obfuscated_symbols.h
http://go/wvgerrit/47720 Invalidate current key index when loading keys
http://go/wvgerrit/46206 Split mock into two -- step 3
http://go/wvgerrit/46205 Move some OEMCrypto types to common header - split the mock, step 2
http://go/wvgerrit/46204 Refactor utility code - split the mock, step 1
http://go/wvgerrit/44981 Fix pointer addresses of generation number
http://go/wvgerrit/47460 Address offline playback with rollbacked time
http://go/wvgerrit/46442 Convert union type-punning to memcpy in Level 3
http://go/wvgerrit/46441 Remove usage of strlen from Level 3
http://go/wvgerrit/41900 Increase size of RSA key for Level3
http://go/wvgerrit/41832 Remove LoadTestKeybox and test keybox code
http://go/wvgerrit/41826 Add prov 3.0 and remove prov 2.0 code
http://go/wvgerrit/44262 Fixed loading mac keys in mock and Level3
http://go/wvgerrit/43402 Add AES256 to Level 3
http://go/wvgerrit/43045 Add entitlement keys and V14 for Level3
http://go/wvgerrit/38800 Update LoadTestKeybox to take test keybox parameter
http://go/wvgerrit/42064 Test Carmicahel RSA Keys
http://go/wvgerrit/41701 Update print-version-strings

New version numbers:
level3/x86/libl3oemcrypto.cpp  Level3 Library 8162 May 21 2018 13:50:29
level3/arm/libl3oemcrypto.cpp  Level3 Library 8158 May 21 2018 13:52:17
level3/mips64/libl3oemcrypto.cpp Level3 Library 8161 May 21 2018 13:51:47
level3/arm64/libl3oemcrypto.cpp Level3 Library 8159 May 21 2018 13:50:47
level3/mips/libl3oemcrypto.cpp Level3 Library 8160 May 21 2018 13:51:51
level3/x86_64/libl3oemcrypto.cpp Level3 Library 8163 May 21 2018 13:51:19

Test: tested as part of http://go/ag/4674759
Change-Id: Ib2c09e4549e58ad57213168dac27b35543bd64c3
2018-09-09 11:37:50 -07:00
Fred Gylys-Colwell
60d010d18d Address review comments
Merge from Widevine repo of http://go/wvgerrit/54540

Addressing comments in http://go/ag/4448747

Test: tested as part of http://go/ag/4674759
Change-Id: I29005397efcc2e982e635581cc68c8293cea6243
2018-09-09 11:37:48 -07:00
Fred Gylys-Colwell
72e260da48 Clean merge of Client ID code
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
2018-09-09 11:37:48 -07:00
Fred Gylys-Colwell
bbb89c2d7f Fix whitespace and copyrights
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
2018-09-09 11:37:48 -07:00
Fred Gylys-Colwell
0099f8d08b Remove Remaining OPENSSL_VERSION_NUMBER Conditional Compiles
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
2018-09-09 11:37:48 -07:00