(This is a merge of wvgerrit/24922)
This contains several fixes and improvements to the
build_and_run_all_unit_tests.sh and run_all_unit_tests.sh scripts:
* All tests are now identified as vendor binaries and thus are stored in
the /vendor/bin/ directory instead of /system/bin/. Previously, some
tests had moved to /vendor/bin/ but the scripts had not been updated,
causing these tests to fail to run.
* The -j parameter can now be passed to build_and_run_all_unit_tests.sh,
for those who want to speed up their build by using multiple cores.
* The 64-bit library directories are now added to the library search
path, in anticipation of devices with 64-bit DRM Plugins.
* Checking for Verity protection is now done in
build_and_run_all_unit_tests.sh (which is the script that actually
modifies the file system) instead of just in run_all_unit_tests.sh.
* The library search path is no longer set unnecessarily for
libwvdrmengine_hidl_test.
* The Treble-only tests and non-Treble-only tests now only run on
devices that meet their respective criteria.
Bug: 36071236
Test: Ran build_and_run_all_unit_tests.sh
Change-Id: Iea236880c4445858111c801dfa278a528bca0f6c
Merge from Widevine repo of http://go/wvgerrit/24863
The oemcrypto unit tests GenericKeyDecryptSameBuffer and
GenericKeyDecryptSameBuffer require features in oemcrypto v12, so they
should not be run on devices that report oemcrypto v11 or earlier.
b/36071236
Test: Unit tests run on Ryu and Bullhead.
Change-Id: Ia6645559ed98cae8d9807a14d6f0e514c5c4c615
(This is a merge of http://go/wvgerrit/24738)
The change to enable 64-bit as a possible target for Widevine Android
made all the unit tests build as 64-bit on compatible platforms. Since
none of these devices support 64-bit properly yet, this is a mistake.
This patch restores unit test builds to being 32-bit only for now.
In the future, when the switch for 64-bit-supporting devices is added,
it will also switch the unit tests to 64-bit mode.
Bug: 36071236
Test: Verified unit test format with "file" command.
Change-Id: Ib4d3678181f3221b85fe6409f1d842dd15af3daa
Merge from Widevine repo of http://go/wvgerrit/24311
This CL adds the error OEMCrypto_ERROR_ENTRY_IN_USE to unit tests, the
reference oemcrypto, and the level 3 haystack.
bug: 35879590
Change-Id: Ifbfaf97c0045147aed4498ec0b57d90b26f100d0
Merge from Widevine repo of http://go/wvgerrit/24241
The CL also only modifies existing tests so that they will pass
with an old version of OEMCrypto, or it filters out the tests so
that they do not run. This positions us so that we can more
easily verify how much backwards compatibility we expect to work.
bug: 35877886
Change-Id: Iadc06672d7f9cef75800662ff83389c504a3fd04
(This is a merge of go/wvgerrit/23686)
This patch removes the makefile lines that previously prevented the
Widevine DRM Plugin from being built as 64-bit on Android. 64-bit
builds are now fully supported.
Only one piece of CDM code has had to change. Due to a bug in
libprotobuf before v3.0, int64 values from protobufs are technically a
different type from int64_t values in code on some 64-bit
architectures. Both have the same in-memory representation at runtime
but are seen as distinct types by the compiler. The compiler will
automatically convert in most places, but template instantiation is
not one of them, so a few places that passed a Protobuf int64 directly
into a template had to be modified.
Please note that tweaks to the mediadrmserver (not covered by this
patch) are needed in order for it to run as 64-bit and load 64-bit DRM
Plugins. Please also note that, as we have no 64-bit L1 OEMCrypto on
any devices, using the 64-bit mediadrmserver and Widevine library will
make your device fall back to L3 for the time being.
Bug: 18949752
Test: OEMCrypto unit tests
Test: Widevine unit tests
Test: Google Play (on Marlin)
Test: Widevine GTS Tests (on Marlin)
Change-Id: Ib6cdf2dd1ff75a1c473cacdc5e22397caa0a656c
Merge from Widevine repo of http://go/wvgerrit/23581
This CL adds some unit tests to oemcrypto to verify that DecryptCENC
and the generic encrypt and decrypt functions behave correctly when
the input and output buffer is the same. i.e. decrypt in place.
The mock and haystack are also updated to pass the tests.
b/34080119
Change-Id: Ie295bdaddbb8058bebb36f6dab092d307f249ecd
Merge from Widevine repo of http://go/wvgerrit/24043
This CL simplifies the way the oemcrypto dynamic adapter handles
backwards compatibility while looking up old function pointers.
It also puts in guards for functions that do not have pointers.
Current Level 3 libraries merged from http://go/wvgerrit/23686/
level3/arm64/libwvlevel3.a Level3 Library 7283 Feb 15 2017 13:39:10
level3/mips64/libwvlevel3.a Level3 Library 7285 Feb 15 2017 13:51:12
level3/arm/libwvlevel3.a Level3 Library 4445 Feb 15 2017 14:20:04
level3/x86_64/libwvlevel3.a Level3 Library 7284 Feb 15 2017 13:43:04
level3/x86/libwvlevel3.a Level3 Library 4464 Feb 15 2017 14:14:55
level3/mips/libwvlevel3.a Level3 Library 4465 Feb 15 2017 14:10:04
Test: OEMCrypto Unit tests pass on bullhead, fugu, and all
six emulators. A bullhead was crippled to use L3 only, and
Play Movies worked OK. ExoPlayer tests were also run on the
bullhead. L1 was re-installed on the bullhead, and Play Movies and
ExoPlayer tests were repeated with no problems.
Bug: 18949752
Bug: 31458046
Change-Id: I8668fde1ce8a045c71bf33c566f3ff86e11821c5
Merge from Widevine repo of http://go/wvgerrit/24042
This CL adjusts the tolerance in tests that check the license_received
time. This was periodically failing because a nonce flood might delay
the test by 1 second, which was being rounded up to 2. The tolerance
is now 3. The time is explicily used when it is available. Some
extra logging is also added to the mock.
bug:31458046
Change-Id: I450880cb3cd8bd5ef66cba13b94dd963d2663d9a
Merge from Widevine repo of http://go/wvgerrit/23482
Now that the documentation has been approved, it's time to
copy text from http://go/oemcrypto to OEMCryptoCENC.h
This also has all the little tweaks to the documents that have been
requested over the past couple of weeks.
b/31458046
Change-Id: I5b865031eb7945005c06bf1b00ecfaaedcad15f4
This CL removes some unused variables, and changes some integers to
unsigned integers. On some platforms, we were getting compiler errors
and unit test failures.
Merge from Widevine repo of http://go/wvgerrit/23840
Use unsigned integer literals
Merge from Widevine repo of http://go/wvgerrit/23767
Fix Gyp Files
Merge from Widevine repo of http://go/wvgerrit/23500
Remove unused variables
bug: 31458046
Change-Id: I4dfec95ae49187262552fbbf322f3310ab777826
Merge from Widevine repo of http://go/wvgerrit/23865
This adds the following tests to the oemcrypto usage tables suite:
Forbid shrinking the usage table over open sessions.
Shrinking usage table must make it smaller, not larger.
Forbid creation of new usage table while open sessions using old.
Change-Id: Ia97a3f4d3ef53417c4f8c98f8ed6ef9ea06d7fad
Merge from Widevine repo of http://go/wvgerrit/23436
This change is just comment changes: minor rewording and grammar
fixes.
Change-Id: I4cb2ef77715623fdb2567f5b504ffaceb937a480
Merge from widevine repo of http://go/wvgerrit/23421
This CL adds some more unit tests for big usage tables, and corrects a
problem found in the reference code.
Change-Id: Iae9a4406d79a13362223c2b4da7365b845d92382
Merge from widevine of http://go/wvgerrit/23283
This CL adds the backwards compatiblity functions to the new usage
tables in the oemcrypto mock reference code.
b/31458046
b/32554171
Change-Id: I04901d95aceb8910406f7c514c26c29c2c575322
This change is the complete Widevine metrics system. It will
measure and record runtime information about what is happening
in the CDM - such as errors and throughput.
Bug: 33745339
Bug: 26027857
Change-Id: Ic9a82074f1e2b72c72d751b235f8ae361232787d
Merge from widevine repo of http://go/wvgerrit/23280
This CL moves some of the oemcrypto mock classes into their own
files. There are no real code changes.
Change-Id: I4e4a6a01d8e75051bc0eb2a5d58361c438c7f41b
Merge from widevine of http://go/wvgerrit/23184
This adds the shared license bit to the key control block for the
reference code and the unit tests.
b/31458046
Change-Id: I4e360ea5dd2e6cee145663d4ab4f384b65cac427
Merge from widevine of http://go/wvgerrit/23283
This CL adds some big usage table functionality to the oemcrypto
mock and unit tests.
Still missing are: backwards compatibility, defragging the table,
haystack code, and lots of new unit tests.
The haystack now reports it doesn't support usage tables, so that
the unit tests will pass. This will be fixed in a future CL.
b/31458046
b/32554171
b/34173776
b/34174907
Change-Id: I6e08e76f7612ffb77e413151e00f830339298c62
Merge from widevine of http://go/wvgerrit/22958/
This adds unit tests for OEMCrypto to check 3072 bit RSA keys. It
also adds indicates that the mock supports them.
b/32776334
Change-Id: I68a3ff56969a860602e6c230558478dc3577c8f5
Merge from Widevine repo of http://go/wvgerrit/23240
This CL runs clang format on some OEMCrypto test and mock files,
so it is easier to see what really changed in the next CL.
Change-Id: I0abf98fc8d312d5b94ad51c3ef2caae820b931de
Merge from Widevine repo of http://go/wvgerrit/23166
This changes OEMCrypto_CreateUsageTableHeader so that the new header
is passed back in a buffer to the cdm layer.
I hacked out the haystack call and just stubbed out the mock call.
This should still build and run with previous liblevel3.a builds.
I also removed from the header some function names that are no longer
part of OEMCrypto v13.
bug:31458046
Change-Id: Ie490c482fe2457076f9026369f4b4b9491a4eb81
Merge from widevine of http://go/wvgerrit/23042
This updates unit tests to account for key control block changes for
OEMCrypto v13. There are two new bits, restricting SRM version and
restricting analog output. The verification string is also updated.
Part of this is to include some simple unit tests for the SRM
functions.
b/33815454
b/28955520
Change-Id: I7cc2ce508688fded2b67fc2a4379c7a8d59d8d22
Merge from Widevine repo of http://go/wvgerrit/23044
On some platforms, the compiler will not pack structures. This CL
replaces the OECrypto_PST_Report packed structure with a simple buffer
of uint8_t. This changes the signature of OEMCrypto_ReportUsage as
part of OEMCrypto v13.
There is also a new wrapper class that test code, the mock, and debug
code can use to access data in the report.
The old packed structure definition is moved to the level 3, where we
use a compiler that packs sructs when asked nicely.
arm/libwvlevel3.a Level3 Library 4445 Jan 20 2017 11:29:15
x86/libwvlevel3.a Level3 Library 4464 Jan 20 2017 11:10:49
mips/libwvlevel3.a Level3 Library 4465 Jan 20 2017 10:56:08
b/32180083
Change-Id: Ie138f034cb12780a2f8636888cebf022c52169e5
Merge from Widevine repo of http://go/wvgerrit/22963
This change kInactive to kInactiveUsed and adds kInactiveUnused to the
possible values for the status field in the Usage Report. This CL
updates the header, the unit tests, and haystack and reference code.
b/32714323
Change-Id: If8d8e32ea1e3dc18da34e5fae35f578b027de9c7
Merge from Widevine repo of http://go/wvgerrit/22899
This is most of the header changes for OEMCrypto v13. This updates
just enough of the code that existing unit tests build and pass.
The documentation will be reviewed in http://go/wvgerrit/22887. When
that CL has been approved, comments in the code will be updated to
match.
Real code will be broken into several other CLs.
bug:31458046
arm/libwvlevel3.a Level3 Library 4445 Jan 17 2017 20:01:26
x86/libwvlevel3.a Level3 Library 4464 Jan 17 2017 19:00:37
mips/libwvlevel3.a Level3 Library 4465 Jan 17 2017 19:24:35
Change-Id: I0318c53235c0b33afb623cba933365e09dec4e61
Merge from Widevine repo of http://go/wvgerrit/22797
CryptoEngine has a number of functions that return constants that
control the configuration of mock OEMCrypto. Give all the functions
a common prefix (config_) so their intent is more clear.
Change-Id: Idf9d3e9e8941fa0e793b0eb17a3f89bf634d9ed5
Merge from Widevine repo of http://go/wvgerrit/22804
Create a class, AuthenticationRoot, to encapsulate the objects and
logic for managing either keyboxes or certificates as the device's
root of trust.
Currently the class provides the existing keybox-related functions
needed by oemcrypto's CryptoEngine. It will be extended to provide
both keybox and certificate related functions, and the logic to
determine whether keybox or certificate based authentication should
be performed.
Change-Id: I792d1bfc8e9a81bbfd2baec20e3b3d182f0392f7
Merge from Widevine repo of http://go/wvgerrit/22571
This adds unit tests to verify that OEMCrypto accepts all key control
block verification strings kctl, kc09, kc10, .... This is needed now
that the unit tests use the current API for all other unit tests.
b/33253872
Change-Id: Ie6b556fc91cd6cb6e07141bd50da3dbfa1681fec
(This is a merge of go/wvgerrit/22949)
Starting with OEMCrypto v12, we are guaranteeing to integration partners
that the buffers passed to OEMCrypto_DecryptCENC and
OEMCrypto_CopyBuffer will not be more than 100KiB (102400 bytes) in
size. For requests larger than this, we will first try to send the
buffer to OEMCrypto anyway. (in case the integration supports buffers
larger than the minimum) In the event that the buffer is rejected, we
will break it up into 100KiB chunks and send them down individually for
decryption.
Breaking a subsample into smaller subsamples necessitates knowledge of
how to update other decryption parameters (like the offsets and the IV)
that previously the CDM Core has not needed to know about. Until now,
this knowledge lived in the glue layer on the Android CDM and nowhere
on the CE CDM. Now, the CryptoSession has a subset of this knowledge, in
order to break up buffers successfully.
For testing purposes, the Mock OEMCrypto has been modified to only
support the smallest buffer size. In order to make sure the chunking
code was being exercised by them, the CE CDM tests had to have the
amount of data they decrypt increased by several orders of magnitude. To
contain this growth, I have moved the test data to its own file.
Bug: 31381719
Test: Ran the updated CE CDM integration tests
Test: Modified the OEMCrypto dynamic adapter to pretend both L3 and L1
only support 100KiB buffers on a Marlin and a Ryu. Confirmed that the
GTS H.264 tests (which have subsamples over 100KiB) passed still. A
similar test was attempted on Fugu but Fugu cannot pass these tests even
without this change present.
Change-Id: Iabe7db3d87554cd1352f10a7524cd55352818397
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
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
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
Merge from widevine repo of http://go/wvgerrit/21684
This CL adds provisioning 3.0 functionality to the OEMCrypto reference
implementation.
Change-Id: I60c1fd88f246d443e0ae59ad56862c2ea9d95445
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
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
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
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
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
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
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
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
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