Commit Graph

2056 Commits

Author SHA1 Message Date
John W. Bruce
bfe6046199 Build Android Unit Tests 32-bit Only
(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
2017-03-23 17:09:15 -07:00
TreeHugger Robot
99566d48e9 Merge "Clean Up Warnings in Android Glue Code" 2017-03-23 19:52:49 +00:00
Fred Gylys-Colwell
85365a1497 Fix or ignore compiler warnings
Merge from Widevine repo of http://go/wvgerrit/24688

b/35466719

Change-Id: If89f0cad0c61f37536a84f8dadaf08072356343a
2017-03-22 14:07:08 -07:00
John W. Bruce
92d26ff87e Clean Up Warnings in Android Glue Code
(This is a merge of go/wvgerrit/24739)

This cleans up some warnings in the Android glue code:

1) Checking if unsigned values are >= 0.
2) Using {0} initializer syntax instead of fully expanding to {0,0}.

Bug: 34394125
Test: Verified compilation passes
Change-Id: Id59730b97da7fce320f634451a44a4df4bf0b494
2017-03-22 11:08:32 -07:00
Edwin Wong
c4aad89fd0 Rename libhidl_utils to libwidevinehidl_utils.
This library is local to vendor/widevine HAL service, rename to
indicate this is used only by widevine HAL.

Test: Play Movies & TV (streaming and pinned)

Test: Netflix

bug: 36430909
Change-Id: Iacaf78f4223bf305569e7f1d04dd4e4ad0a87727
2017-03-20 11:14:36 -07:00
Edwin Wong
266898a352 Fix CTS post submit failures
MediaCodecTest.android.media.cts.MediaCodecTest.testCryptoError
was failing due to incorrect error code translation introduced
by the drm hidl hal.

Test: ANDROID_BUILD_TOP= ./android-cts/tools/cts-tradefed run cts
  --module CtsMediaTestCases --test
  android.media.cts.MediaCodecTest#testCryptoError

bug: 35137940
Change-Id: I5177367df7b57fe23a4b17c38462886786537140
2017-03-15 13:21:37 -07:00
Rahul Frias
2ec7ec27bb Address warnings in CDM unittests
[ Merge of http://go/wvgerrit/24600 ]

Test: Unit test only change. Verified by rerunning unittests.

b/36221430

Change-Id: I36a8a0a5df400673689280cbf53ba9394f827c90
2017-03-14 12:13:12 -07:00
Adam Stone
dd88c13fb1 Trim unnecessary CDM metrics.
Bug: 35269103
Test: Removing unnecessary code. Existing tests pass.
Change-Id: I1ba8572a8b3fabbf707e77b366717c9ba3069ace
2017-03-13 19:10:39 -07:00
John Bruce
5cd6622a75 Merge "Enable SPOIDs in Treble Widevine Glue Layer" 2017-03-10 03:17:52 +00:00
John Bruce
f37e37c37b Merge "Implement Widevine drm HIDL HAL service." 2017-03-10 03:13:01 +00:00
Fred Gylys-Colwell
ca2f1641c3 Merge changes I2f7052b6,Ifbfaf97c
* changes:
  Test Cleanup
  Report error OEMCrypto_ERROR_ENTRY_IN_USE
2017-03-08 20:44:36 +00:00
Fred Gylys-Colwell
2dbc81318a Merge "Give Nonce Error Explicit Name" 2017-03-08 20:44:00 +00:00
TreeHugger Robot
1322df2d28 Merge "Clean up how metrics were disabled" 2017-03-07 03:55:47 +00:00
Fred Gylys-Colwell
9bd9bcd61a Test Cleanup
Some tests code was not correctly merged from the widevine side.

An initializer in generic_crypto_unittest.cpp was missed in
http://go/wvgerrit/23767

bug: 35951647

Change-Id: I2f7052b621989a032179346edf43dcaf6cb7d921
2017-03-03 21:30:02 +00:00
Fred Gylys-Colwell
14c3a3865a Give Nonce Error Explicit Name
Merge from widevine repo of http://go/wvgerrit/24421

A nonce generation error for a certificate provisioning request had a
generic name Error2.  However, this is an actionable error by the
application: the application should wait 1 second and try again.
Therefore it deserves a more descriptive name.

bug: 35926133
bug: 35879493

Change-Id: I6c87a5a762cb970c9530a55c993d7acbed773a00
2017-03-03 21:25:20 +00:00
John W. Bruce
d9b90be205 Enable SPOIDs in Treble Widevine Glue Layer
Adds code to the Widevine Glue Layer that drives the generation and use
of SPOIDs on platforms that support SPOIDs. (All devices whose first
release is Android O or later.) Note that this only applies to the new,
Treble-ized API. If the Widevine DRM Plugin is accessed through the old
API, it will not use SPOIDs. This is by design because the old API does
not provide an application package name, so SPOID generation is no
better than the existing, origin-based solution.

Bug: 27101531
Test: Unit tests
Test: GTS tests
Test: Google Play
Change-Id: I80f79fca84065105e218e9070a1d5299c8e33500
2017-03-02 13:46:16 -08:00
Edwin Wong
2dc53442e7 Implement Widevine drm HIDL HAL service.
Modify Android mediadrm and mediacrypto glue layer to use
HIDL interface.

Test: Play Movies (streaming and offline playback)

Test: ANDROID_BUILD_TOP= ./android-gts/tools/gts-tradefed
run gts -m GtsMediaTestCases

Test:
adb shell /system/bin/libwvdrmengine_hidl_test

Test:
adb shell /system/bin/libwvdrmmediacrypto_hidl_test

Test:
adb shell /system/bin/libwvdrmdrmplugin_hidl_test

bug: 34628973
Change-Id: Icd5f2dd556acb9874697963b4d7d62cb7c943e74
2017-03-02 13:46:11 -08:00
Fred Gylys-Colwell
ce535ad21e Report error OEMCrypto_ERROR_ENTRY_IN_USE
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
2017-03-02 10:55:05 -08:00
Fred Gylys-Colwell
70ffdb1c6a Backwards Compatibility Tests
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
2017-03-02 10:15:10 -08:00
Fred Gylys-Colwell
a4506542df Merge "Source and destination buffers may point to same buffer" 2017-03-02 04:44:11 +00:00
John Bruce
1178b10992 Merge "Enable 64-bit Android Builds" 2017-03-02 04:33:31 +00:00
Fred Gylys-Colwell
872fd1077e Merge "Avoid Nonce Flood in core/test/cdm_engine_test.cpp" 2017-03-02 03:46:58 +00:00
Fred Gylys-Colwell
5fa587bd0b Merge "Widevine L1 Provisioning Models" 2017-03-02 03:46:36 +00:00
John W. Bruce
df0dad5311 Enable 64-bit Android Builds
(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
2017-03-02 02:58:56 +00:00
Fred Gylys-Colwell
848d851441 Merge "Clean up oemcrypto dynamic adapter and add level 3 libraries" 2017-03-02 02:48:43 +00:00
Fred Gylys-Colwell
4025322185 Source and destination buffers may point to same buffer
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
2017-03-01 18:27:38 -08:00
Fred Gylys-Colwell
27c01e82b5 Clean up oemcrypto dynamic adapter and add level 3 libraries
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
2017-03-02 01:49:52 +00:00
Fred Gylys-Colwell
55db447738 Widevine L1 Provisioning Models
Merge from Widevine repo of http://go/wvgerrit/24305

This CL adds a pdf of the document "Widevine L1 Provisiong Models"
to the source directory so we can share with partners.

bug: 35880276

Change-Id: I60ea958b2e4cefc783c692ad78784b7071f59e2e
2017-03-01 13:44:16 -08:00
Fred Gylys-Colwell
e2f9028c57 Avoid Nonce Flood in core/test/cdm_engine_test.cpp
Merge from Widevine repo of http://go/wvgerrit/24205

This adds a single retry to each call into cdm_engine that uses a
nonce. This should prevent spurious tests failing because they
accidentally generated a nonce flood.

bug: 35879493
Change-Id: I99a5f2063f04befb74361ff44c4ce8e34f41e89d
2017-03-01 13:39:56 -08:00
Fred Gylys-Colwell
3b7b2c91c1 Merge "Clean Up OEMCrypto Header" 2017-03-01 18:40:51 +00:00
Fred Gylys-Colwell
7112a5eec3 Add more slack to timing tests
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
2017-03-01 06:30:43 +00:00
Fred Gylys-Colwell
3a9c9ce498 Clean Up OEMCrypto Header
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
2017-02-28 22:26:05 -08:00
Fred Gylys-Colwell
eade07c7a9 Minor build updates
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
2017-03-01 01:48:56 +00:00
Fred Gylys-Colwell
1aac150100 Merge "More Usage Table Tests" 2017-02-22 20:27:40 +00:00
Fred Gylys-Colwell
8274b77019 Include Metric Unit Tests
Merge from Widevine repo of http://go/wvgerrit/23842

This CL updates the android make files and test scripts to include the
two new unit test suites in metrics/test.

Change-Id: Ie31bdc3ae3709ab116d2a340ee5b55c7c12d1d33
2017-02-17 16:22:06 -08:00
Fred Gylys-Colwell
582d3237c9 More Usage Table Tests
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
2017-02-18 00:19:08 +00:00
Rahul Frias
db5c3dfb6d Enable usage header table and entries
[ Merge of http://go/wvgerrit/24022 ]

b/34327459

Test: Verified by unit, integration tests on angler

Change-Id: Idb17dc472dddbdad217c35bdaa3fb20ae8152371
2017-02-17 09:54:33 +00:00
Rahul Frias
826e390ad6 Consolidate update usage table calls
[ Merge of http://go/wvgerrit/23980 ]

In OEMCrypto version 13, usage information is updated by calls to
OEMCrypto_UpdateUsageEntry. In previous versions calls were made to
OEMCrypto_UpdateUsageTable instead. Both need to be supported as the
OEMCrypto version may vary by device.

This consolidates calls to OEMCrypto_UpdateUsageTable so that they
can be disabled if OEMCrypto version >= 13. No functional changes other
than disabling by OEMCrypto version were introduced in this section.

Helper routines have been added to device files as well.

b/34327459

Test: Verified by unit, integration tests on angler

Change-Id: If5d4bbbe7589e7cc1094999ba21f727eb6c92c3b
2017-02-17 01:50:20 -08:00
Rahul Frias
0db3a137e9 Introduce UsageTableHeader class
[ Merge of http://go/wvgerrit/23820 ]

The UsageTableHeader class is a singleton that CDM sessions will share.
A separate object will be created for each security level. The class
synchronizes access to usage table header and associated data-structures
and controls when they are read in or written out to non-secure persistent
storage. Upgrades from a fixed size usage table (supported by previous
versions of the OEMCrypto API v9-12) are handled by this class.

b/34327459

Test: Verified by unit/integration tests on angler

Change-Id: Ifc5996985e76bc260c01e55bc12aab1248389a80
2017-02-17 04:14:09 +00:00
Jeff Tinker
f39c002618 Clean up how metrics were disabled
Initially both metrics collection and publishing were
going to be disabled to work around P0:b/35093325.
But disabling collection was not completed since it proved
to be unnecessary. However, remnants were left in the header
file. This change just cleans up the remnants.

Change-Id: Ibdceafd2add31c93de995a558a675b8ba8a055bc
related-to-bug:35093325
2017-02-16 18:04:27 -08:00
Rahul Frias
e75d3a6512 Revise usage entry metadata
[ Merge of http://go/wvgerrit/23742 ]

In OEMCrypto V13, usage table header and usage entries are stored in
persistent non-secure storage and loaded and unloaded from the TEE.
Information needs to be maintained to assist finding the associated license
or usage information. This information has been revised for usage information
to use key set id and usage info file name rather than provider session
token and app id.

The app id is stored in a hashed form (usage info file name) and was not
extractable during the upgrade process to OEMCrypto V13. Due to this
DeviceFiles UsageInfo routines have switched to use usage info file name
rather than app id as a key.

b/34327459

Test: Verified by unit/integration tests on angler
Change-Id: I95aa0435d0955c61fc45b951f5b5d44de2ba5cfc
2017-02-16 14:58:34 -08:00
Rahul Frias
b384408dd2 Persist usage entry number
[ Merge of http://go/wvgerrit/23741 ]

Usage entries and usage entry numbers need to be stored with license
and usage information, to facilitate loading usage entries when offline
licenses/usage information are restored or prepared for release.

b/34327459

Test: Validated by running unit/integration tests on angler.

Change-Id: I0949fc4cec8a50be0a7700b659dc12bb82ac6f73
2017-02-16 07:12:21 +00:00
Rahul Frias
e85e27d596 Merge changes I634d3b7b,I988556b2
* changes:
  Add usage support query method
  Implement Cdm::listStoredLicenses()
2017-02-08 10:34:22 +00:00
Jeff Tinker
c934152265 Merge "Disable widevine metrics" 2017-02-08 02:00:25 +00:00
Jeff Tinker
3c22ce40cd Disable widevine metrics
Workaround for mediadrmserver spinning/battery
drain problems.

b/35093325

Change-Id: I71b32435c43d9e467c74d8c18e5a91af903f6b66
2017-02-07 17:53:58 -08:00
Rahul Frias
db6df99db1 Add usage support query method
[ Merge of http://go/wvgerrit/23522 ]

A helper method has been added to CryptoSession to determine whether the
TEE supports usage tables, usage table headers+entries or does not
provide any support for persistent licenses.

In addition
* CryptoSession now supports deletion of multiple
  usage entries rather than a single one.
* Typedefs have been added for usage table headers and entries

b/34327459

Test: Verified by unit/integration tests on angler.

Change-Id: I634d3b7b81ce94d1deccd2a7aaf26b9efde414a8
2017-02-07 13:50:22 -08:00
Rahul Frias
6d617e2be4 Implement Cdm::listStoredLicenses()
[ Merge of http://go/wvgerrit/23600 ]

This adds a new entry to IStorage:: -

  bool list(std::vector<std::string> file_names)

It returns the name of each file in the (origin-specific) file system.

b/34628115

Uses the current file system (origin-specific) bound to the CDM. Returns
the list of stored licenses (key_set_ids) in vector output parameter.

Test: verified by unittests on angler.

Change-Id: I988556b27c2a4b75f52b59bcd78cfeaddd649acd
2017-02-07 13:28:05 -08:00
Rahul Frias
1be8354553 Merge "Include libcdm_protos archive as LOCAL_STATIC_LIBRARIES" 2017-02-04 07:04:20 +00:00
Jeff Tinker
d31c7e6673 Merge "Disable AmiAdapter info logging" 2017-02-04 01:07:33 +00:00
Rahul Frias
6e9eb297b2 Include libcdm_protos archive as LOCAL_STATIC_LIBRARIES
[ Merge of http://go/wvgerrit/23533 ]

Prior to this CL libcdm_protos was included as LOCAL_WHOLE_STATIC_LIBRARIES

b/34393411

Test: Ran unittests and streaming/offline playback using playmovies.

Change-Id: I4cdea8620693ee7660c71e44d08122acd07843a2
2017-02-02 14:05:29 -08:00