Commit Graph

788 Commits

Author SHA1 Message Date
Aaron Vaage
af71f66aa4 Removing Widevine OEMCrypto Profiler
This is a merge of go/wvgerrit/22806

This change removed the oemcrypto profiler to allow
the new metrics system free-reign over how to collect
and store measurements.

Bug: 33745339
Bug: 26027857
Change-Id: I6b9051faa6835f13860258c94f8bcfd3a59f1be6
2017-01-17 17:53:40 -08:00
Rahul Frias
b413037733 Merge "Don't read from closed sockets" 2017-01-13 09:14:07 +00:00
Rahul Frias
41ba5aa745 Don't read from closed sockets
[ Merge of http://go/wvgerrit/17958 ]

This CL might help diagnose the build bot problem.

b/34261498

Test: All unittests other than some oemcrypto, request_license_test
passed. Those tests failed with or without this CL.

Change-Id: I71e48284b52a1177c6e3b4c9a8bdd12b77cc9f2d
2017-01-12 17:56:59 -08:00
Rahul Frias
0ee9d95a03 Rename PolicyEngine::CanDecrypt to CanDecryptContent.
[ Merge of http://go/wvgerrit/22517 ]

b/34211676

Test: All unittests other than some oemcrypto, request_license_test
passed. Those tests failed with or without this CL.

Change-Id: I86a2ff041aae57ac46e9f9f7bac38ec4599a0fa7
2017-01-11 15:44:52 -08:00
Rahul Frias
516718727e Rename "Is*Expired" to "Has*Expired" in PolicyEngine
[ Merge of http://go/wvgerrit/22516 ]

b/34211676

Test: All unittests other than some oemcrypto, request_license_test
passed. Those tests failed with or without this CL.

Change-Id: Ie973f468f9efd05bdafcf90164dae185a6ce11dc
2017-01-11 15:44:38 -08:00
Rahul Frias
8e3206c1be Update duration semantics for PolicyEngine.
[ Merge of http://go/wvgerrit/22237 ]

This only changes the existing fields of the policy.

License::Policy::license_duration_seconds represents the end time
(relative to the license start time) that the license can be used.
This overriding other times if this is earlier.

License::Policy::rental_duration_seconds represents the end time
(relative to the license start time) that the license can be used
before playback starts. Once playback starts, this no longer applies.

License::Policy::playback_duration_seconds represents the end time
(relative to the playback start time) that the license can be used after
playback has started.

b/34211676

Test: Ran new unittests and reran old tests. All tests other than some
oemcrypto, request_license_test passed. Those tests failed with or
without this CL.

Change-Id: I34e7e39a7ab864300806c557b480f093aec8e545
2017-01-11 15:44:23 -08:00
Rahul Frias
a83a9ae540 Merge "Add Cdm::setVideoResolution()" 2017-01-11 09:19:47 +00:00
Rahul Frias
40159825e8 Add Cdm::setVideoResolution()
[ Merge of http://go/wvgerrit/22744 ]

Pass resolution information into policy engine for constraint
checking.

b/33380824

Test: Reran unittests. All tests other than some oemcrypto,
request_license_test passed. Those tests failed with or without this CL.

Change-Id: I405099b1f66a47fa0c2579e2ae248dd78fa4e98a
2017-01-09 21:42:42 -08:00
Rahul Frias
079ee03869 Offline playback for fastball
[ Merge of http://go/wvgerrit/18560 ]

This adds support for offline playback. If the content contains
mutiple playlists which contain differing EXT-X-KEY attribute lists,
each of those keys will need to be saved and restored into separate
sessions.

b/30041089

Test: Added unit tests to cover new functionality. Some oem_crypto,
request_license_test failures but the same as without this CL.

Change-Id: Ia1b877e12a67e8a720d29897ac7e2da236090123
2017-01-09 19:07:42 -08:00
Rahul Frias
182f3c8058 Avoid race condition on closing CDM session.
[ Merge from go/wvgerrit/22920 ]

Automated tests reveal a race condition between closing
a session and the periodic policy timer event. If a close
session was in progress (WVDrmPlugin::closeSession) and
CdmEngine::CloseSession caused the CdmEngine::session_list_lock_
to be held, a call into CdmEngine::OnTimerEvent would pend on the
release of the lock.

The close session would continue to deallocate the session
and disable (stop) the policy timer leaving the CdmEngine::OnTimerEvent
call in an undefined state. This would result in an ANR.

This subtle race-condition was introduced when changes were made
to add in per-origin storage [ http://go/wvgerrit/17971 ]. This seems
to happen at a low frequency (~ < 0.5%).

To address a lock has been introduced to protect the map
WvContentDecryptionModule::cdms_.

Test: Unit tests + 200 aupt test iterations

b/33343891

Change-Id: I9788db8a7d1df84f0df82cdbadb9d0f0fbe21e4e
2017-01-06 16:43:48 -08:00
John W. Bruce
5f4397fdc4 NYC-MR2 Widevine Version Number Bump am: 1b298c6ec7
am: 8309a406b3

Change-Id: I10117c8fd120a64489b0094a231c9b3e63ba3b2c
2017-01-06 02:03:24 +00:00
John W. Bruce
1b298c6ec7 NYC-MR2 Widevine Version Number Bump
(This is a merge of go/wvgerrit/22897)

Bumps the Widevine version to 4.2.0 for NYC-MR2 and also updates the
test to expect the NYC-MR2 OS version number.

Bug: 32955300
Test: request_license_test
Change-Id: I2f186928f20e0848cbeef5fef2182045ad27140a
2017-01-05 15:50:31 -08:00
Fred Gylys-Colwell
cc8d6942d6 Merge "Level 3: Throw out keybox with wrong system id *DO NOT MERGE*" into nyc-mr2-dev 2017-01-05 00:55:39 +00:00
Fred Gylys-Colwell
2d0bf3e813 Merge "OEMCrypto v12 Documentation" 2016-12-28 20:12:38 +00:00
Aaron Vaage
9d464cff5d [ OEMCrypto Profiler ] Removed Call Table am: 4ad500d878
am: 9ae9de59d4

Change-Id: Ic34ac456ba79b8fcdf215eb7174bfc40181d1974
2016-12-13 18:16:58 +00:00
Aaron Vaage
9ae9de59d4 [ OEMCrypto Profiler ] Removed Call Table
am: 4ad500d878

Change-Id: I52bc32fef3a70681c3443f6f862e1bee83bf17f2
2016-12-13 18:03:32 +00:00
Aaron Vaage
37fc42c5b8 Merge "[ OEMCrypto Profiler ] Removed Call Table" into nyc-mr2-dev 2016-12-13 17:41:19 +00:00
Rahul Frias
91f0894685 Address test network issues am: 3380679886
am: 939401861e

Change-Id: I3ff1b57f1978053394db042265a5de20e389424a
2016-12-13 09:30:21 +00:00
Rahul Frias
939401861e Address test network issues
am: 3380679886

Change-Id: I0cadd9a2713f1614b3f4a97b234a1d065cb42425
2016-12-13 09:23:21 +00:00
Rahul Frias
f77df16bd5 Merge "Address test network issues" into nyc-mr2-dev 2016-12-13 09:18:10 +00:00
Fred Gylys-Colwell
7e7ef2bb58 Level 3: Throw out keybox with wrong system id *DO NOT MERGE*
This CL modifies the haystack code to throw out the keybox if the
system id is wrong.  This should help prevent b/33344450 from
persisting.

Part of this code change was to backport some updates to the haystack
tools on master.

arm/libwvlevel3.a  Level3 Library 4445 Dec  6 2016 16:58:47
x86/libwvlevel3.a  Level3 Library 4464 Dec  6 2016 17:06:21
mips/libwvlevel3.a  Level3 Library 4465 Dec  7 2016 13:36:32

b/33556871

Change-Id: I8dadf4bc7981af6afb970533df61d34b80d133a7
2016-12-12 16:11:08 -08:00
Aaron Vaage
4ad500d878 [ OEMCrypto Profiler ] Removed Call Table
This is a merge of go/wvgerrit/22627

The call table was meant to be a long-term way to track
the performance of all OEMCrypto function calls.

This feature does not get used. Apps that call into the
profiler can generate this from the history.

This change was designed to go into Android O
(go/wvgerrit/22503) but since the Call Table is causing problems
on specific chip sets its being removed in NYC MR2.

Bug: 33550032
Bug: 33459261
Change-Id: I2af417a32452e7d0d0a1ada8794efd849c497dc8
2016-12-12 15:05:07 -08:00
Fred Gylys-Colwell
c268ce1da2 Merge "OEMCrypto_GetDeviceID should return Not Implemented for Prov 3.0" 2016-12-12 22:52:30 +00:00
Fred Gylys-Colwell
264c75cde9 Merge "OEMCrypto Refresh License Tests with PST" 2016-12-12 22:52:17 +00:00
Fred Gylys-Colwell
14d70e666f OEMCrypto v12 Documentation
Merge from Widevine repo of http://go/wvgerrit/18603

This is the documentation changes for OEMCrypto v12.  This
includes Provisioning 3.0 changes.

Comments can be put in the original Google docs:
http://go/oemcrypto WV Modular DRM Security Integration Guide for
Common Encryption (CENC)

http://go/wvdelta12
WV Modular DRM Version 12 Delta

The following features and changes are documented, but not
implemented:
b/28887904 Buffer Size Unit Tests
b/28294273 All OEMCrypto functions should return same error code
           when key expires
b/24469550 Enforce Maximum 16 Byte Key ID Length
b/30140448 Minimum 16 keys per OEMCrypto_Session
b/28316108 Feature Request Key Control Block "No Digital Output"
b/8608578 OEMCrypto_RefreshKeys should not alter key control
          setting except duration
b/30120064 Add OEMCrypto Unit Test for non-paired subsamples
           (for VP9)
b/30141311 Sample OEM Certificate Needed
b/31381719 Divide Samples into Subsamples of at most 100k bytes

Change-Id: Ibf03b55cda822a676cd174ddc292bb35177cddbe
2016-12-06 14:53:19 -08:00
Rahul Frias
4c89e58f9b Correct subsample flags in request_license_test am: e7782c1e27
am: 541c9e632a

Change-Id: Ib97b8d7a9bfe57f68275e9193943df84afa729e5
2016-12-05 23:06:59 +00:00
Rahul Frias
541c9e632a Correct subsample flags in request_license_test
am: e7782c1e27

Change-Id: I7667fe5cd3ae42b72b5c65686bc9ae8f78fb61af
2016-12-05 23:03:12 +00:00
Rahul Frias
dab8aab4a8 Merge "Correct subsample flags in request_license_test" into nyc-mr2-dev 2016-12-05 22:58:51 +00:00
Rahul Frias
e6f668ca16 Release offline release sessions
[ Merge of http://go/wvgerrit/21960 ]

When an offline release message is generated, a session is created
internally to generate the release and handle the release response.
If the response is never provided (network, server errors),
or there is an error when the response is being processed, the
session may not be closed. This change introduces a time to live for
release sessions of 60 seconds and will be reclaimed after this period.

Test: verified by unittests on angler

b/32223945

Change-Id: I3bd4637733ddf6c343956ed9f97c68d84dc7d4e4
2016-12-04 01:51:09 -08:00
Rahul Frias
9a55ca3249 Release offline release sessions -- DO NOT MERGE
[ Merge of http://go/wvgerrit/21960 ]

When an offline release message is generated, a session is created
internally to generate the release and handle the release response.
If the response is never provided (network, server errors),
or there is an error when the response is being processed, the
session may not be closed. This change introduces a time to live for
release sessions of 60 seconds and will be reclaimed after this period.

b/32223945

Change-Id: I3bd4637733ddf6c343956ed9f97c68d84dc7d4e4
2016-12-02 14:43:53 -08:00
Fred Gylys-Colwell
e363c649ee Merge changes I6c215b40,I60c1fd88,Ib1a5566d,Ib7065ce8,Ib579a322, ...
* changes:
  Update Key Control Verification String
  Implement provisioning 3.0 functionality in oemcrypto mock
  OEMCrypto rewrap rsa key 3.0 unit tests
  OEMCrypto Tests Provisioning Method
  Refactor OEMCrypto Unit Tests
  OEMCrypto v12 Haystack and Adapter
2016-12-02 18:59:24 +00:00
Rahul Frias
e7782c1e27 Correct subsample flags in request_license_test
[ Merge of  http://go/wvgerrit/21980 ]

b/32487750

Change-Id: I5a3c3a768f3d1a81af4e8d897f68cfdbeb3526da
2016-12-01 11:17:59 -08:00
Fred Gylys-Colwell
50fe997cf2 OEMCrypto_GetDeviceID should return Not Implemented for Prov 3.0
Merge from Widevine repo of http://go/wvgerrit/22402

This CL updates the oemcrypto reference implementation (mock) to
return OEMCrypto_ERROR_NOT_IMPLEMENTED from OEMCrypto_GetDeviceID when
the device is configured to use provisioning 3.0.

This CL also moves unit test for OEMCrypto_GetDeviceID to the section
that is run only for keybox using devices.

b/33178932

Change-Id: Ie4f9346132ce305bdbd47474dc4c0f6268f3d444
2016-11-30 15:54:00 -08:00
Fred Gylys-Colwell
1d5a03cb40 OEMCrypto Refresh License Tests with PST
Merge from widevine repo of http://go/wvgerrit/22409

This CL adds unit tests for refreshing online and offline licenses
that have usage table entries.

b/32609464

Change-Id: I5166a43525ebb324bc2f253cee6b6f34da697cec
2016-11-30 15:52:29 -08:00
John Bruce
e990c82466 Merge "Simplify IV Incrementation" 2016-11-30 23:39:42 +00:00
John W. Bruce
3847adb78e Simplify IV Incrementation
(This is a merge of go/wvgerrit/22441)

The IV incrementation code in Widevine DRM Plugin includes complexity
for handling partial crypto blocks in "cens" mode, a situation that
cannot actually happen. This commit changes the code to no longer handle
this case specially.

Bug: 28696811
Test: No tests for this code path due to bug 28295739
Change-Id: I77f8434a9785bf028509387c06db217a5de2b91b
2016-11-30 11:17:17 -08:00
Fred Gylys-Colwell
7fc037f1a9 Update Key Control Verification String
Merge from widevine repo of http://go/wvgerrit/22382

This updates the key control verification string in the haystack, in
the reference oemcrypto (mock), and in the oemcrypto unit tests.

The unit tests now set the key control block to be kc12 for all
licenses if the API is set to version 12.  Previously, we only used
the more recent verification codes if the key control block used
recent features.

This should help prevent future incidents like b/32830469.

Change-Id: I6c215b4058445a6d807610af94457598f26d591a
2016-11-29 16:10:13 -08:00
Fred Gylys-Colwell
08ad98cad9 Implement provisioning 3.0 functionality in oemcrypto mock
Merge from widevine repo of http://go/wvgerrit/21684

This CL adds provisioning 3.0 functionality to the OEMCrypto reference
implementation.

Change-Id: I60c1fd88f246d443e0ae59ad56862c2ea9d95445
2016-11-29 16:07:00 -08:00
Fred Gylys-Colwell
3e525dfdd3 OEMCrypto rewrap rsa key 3.0 unit tests
Merge from widevine repo of http://go/wvgerrit/21683

This CL adds unit tests for OEMCrypto_RewrapDeviceRSAKey30 for devices
that use provisioning 3.0.

Change-Id: Ib1a5566de343365b2ae3531f375ac2cc6d86ee53
2016-11-29 15:18:19 -08:00
Fred Gylys-Colwell
053ff5bd3c OEMCrypto Tests Provisioning Method
Merge from widevine repo of http://go/wvgerrit/21682

This CL updates oemcrypto/test/oec_device_features.cpp to figure out
the provisioning method and filter out tests that are not relevant to
the device's method.

This CL also introduces unit tests for GetOEMPublicCertificate.

Unit tests for RewrapDeviceRSAKey30 will be in a future CL.

Change-Id: Ib7065ce866d1171ca61b9aa08188fa2ac8d90fc2
2016-11-29 15:15:08 -08:00
Fred Gylys-Colwell
0fb76d5c1b Refactor OEMCrypto Unit Tests
Merge from widevine repo of http://go/wvgerrit/21681

This CL refactors some oemcrypto unit tests in preparation for adding
Provisioning 3.0 tests.

- The signature GenerateNonce has changed.  Instead of the caller
  passing in a pointer for the nonce, we store the nonce in a member
  variable of Session.

- GenerateDerivedKeys is being replaced by InstallTestSessionKeys.
  This sets up and calls the appropriate derive keys method.  This
  function is in the test class, instead of the session class so that
  multiple sessions in a class can share the same wrapped rsa key.
  This will be modified for provisioning 3.0 in a future CL.

- Rename tests that require a keybox.  Some tests are specific for
  using a keybox to request a DRM cert. These tests are renamed so we
  can filter them out on devices that use an OEM Cert.  Corresponding
  tests for devices using provisioning 3.0 will be in a future CL.

- Some member variables and methods in the class Session were not
  used.  They are removed.

- Added openssl smart pointer.

- Comments.  I added comments.

- clang format.

Change-Id: Ib579a322858e0ef92652a42167241b35cf85a041
2016-11-29 15:05:23 -08:00
Fred Gylys-Colwell
4cac936b10 OEMCrypto v12 Haystack and Adapter
Merge of several CLs from the widevine repo.

Merge from widevine repo of http://go/wvgerrit/22440
Build OEMCrypto v12 Haystacks with cache flush

level3/mips/libwvlevel3.a  Level3 Library 4465 Nov 29 2016 13:34:45
level3/arm/libwvlevel3.a  Level3 Library 4445 Nov 29 2016 14:02:08
level3/x86/libwvlevel3.a  Level3 Library 4464 Nov 29 2016 14:22:21

Merge from widevine repo of http://go/wvgerrit/22403
Pull cache flush out of Haystack

Merge from widevine repo of http://go/wvgerrit/21145
OEMCrypto v12 stubs -- just the header file changes.

Merge from widevine repo of http://go/wvgerrit/21146
Add OEMCrypto v12 functions to profiler

This CL adds the new oemcrypto v12 functions for provision 3.0 to the
list of profiler functions.

Merge from widevine repo of http://go/wvgerrit/21143
OEMCrypto v12 adapter

This CL updates the oemcrypto dynamic and static adpaters to include
oemcrypto v12 funtionality.  It adds the three new Provisioning 3.0
functions.

It also adds code in the initialization routine to null out all of
the function pointers if any of them fail to load.  It is better to
fall back to level 3 than to use an inconsistent level 1.

b/31528025

Change-Id: I3579dc93e00ad7e7c743beecdd8291eac557d4e4
2016-11-29 14:56:36 -08:00
Fred Gylys-Colwell
6d000b5295 OEMCrypto v12 Header
Merge from widevine repo of http://go/wvgerrit/21710

This is the header changes for OEMCrypto v12.  This includes
Provisioning 3.0 changes.

This CL was split off from http://go/wvgerrit//18603 because that
review is now concentrating on clarification and wording issues.

This CL is just for the header, and API changes.

Change-Id: I7cc423726433dcac9fb907246b6b6dd64f5c3367
2016-11-28 21:56:00 -08:00
Fred Gylys-Colwell
a200710d53 Add unit test to verify signature
Merge from widevine repo of http://go/wvgerrit/21521

On devices that use provisioning 3.0, the function
OEMCrypto_GenerateSignature will only be used for a license renewal.
This CL adds a call to OEMCrypto_GenerateSignature to the refresh key
tests.  Otherwise, there would be no coverage at all for that
function.

Change-Id: Icbd568eea3f9f256cc9b0b441f7907b316bb5b69
2016-11-28 21:54:03 -08:00
Fred Gylys-Colwell
47f454839e Unit Test for OEMCrypto_ERROR_KEY_EXPIRED
Merge from widevine repo of http://go/wvgerrit/21141

All of the decrypt calls and the SelectKey call should return
OEMCrypto_ERROR_KEY_EXPIRED on error.  This CL updates the oemcrypto
unit tests, reference mock, and level 3 code.

b/28294273

Change-Id: I7ac6a3652e0b2fe5a46071e1c2eda00daeed7a33
2016-11-28 21:52:11 -08:00
Fred Gylys-Colwell
7214064635 Use fast random for unit tests
Merge from widevine repo of http://go/wvgerrit/21560

For OEMCrypto v12 we explicitly require OEMCrypto_GetRandom to handle
buffers up to 32 bytes long.  This CL relaces the use of GetRandom
with openssl's RAND_psuedo_bytes to fill test vectors.

b/31464102

Change-Id: Ia0006b92bb12b98e9c130068dbb31b5f67281de2
2016-11-28 21:47:44 -08:00
Fred Gylys-Colwell
67b06a70e4 Buffer Size Unit Tests
Merge from widevine repo of http://go/wvgerrit/21260

This CL adds some oemcrypto unit tests for various buffer sizes, as
described in b/28887904 and the OEMCrypto v12 specification.

Encryption and Decryption buffers can be 100k large.  License request
and response messages can be 8k. A provider session token (pst) can be
at most 255 bytes long.

I also passed the code through clang-format.

b/28887904

Change-Id: Ia3e317c0f6466e663461e66b610c9a98a90efb0a
2016-11-28 21:44:36 -08:00
Fred Gylys-Colwell
5228b538f0 Specify units for time based property fields.
Merge from widevine of http://go/wvgerrit/21381

Change-Id: I8b209e1403e94adc7843ff1009c8cd1d5761b917
2016-11-28 21:40:19 -08:00
Fred Gylys-Colwell
f0cee3ad20 Require 20 keys per session and 10 sessions
Merge from widevine repo of http://go/wvgerrit/20981

OMECrypto v12 requires at least 20 keys per session and at least 10
sessions.  This CL updates the unit tests to verify this, and updates
level 3 and mock code to conform.

This CL also updates the level 3 oemcrypto to support 16 sessions and
320 keys total.

b/30140448 Minimum 20 keys per OEMCrypto_Session

Change-Id: Idd38d8f2cdfd6acde6fa7622b5912372bee9e488
2016-11-28 21:36:03 -08:00
Rahul Frias
3380679886 Address test network issues
[ Merge of http://go/wvgerrit/22140 ]

There are occasional issues when trying to connect to
http://widevine-proxy.appspot.com/proxy . This changes introduces upto
3 retry attempts. The UAT server on appspot is being replaced by UAT on borg
and so it is not worth our while to debug these issues furthur.

b/30022298

Change-Id: I76c1421e93c7c14b5d2bcd7ad07119a705245922
2016-11-10 18:40:10 -08:00