Commit Graph

264 Commits

Author SHA1 Message Date
John "Juce" Bruce
c400a37d19 Validate Service Certificates Before Accepting Them
(This is a merge of http://go/wvgerrit/14630)

To create a better flow when an application sets a service certificate
manually, we will now validate the certificate when it is given to us,
and if it is invalid, we will not allow the property to be set.

Bug: 21307186
Change-Id: If980ad075604223fc962a859fae93e98d86a7f4f
2015-06-12 11:46:32 -07:00
John "Juce" Bruce
a8328dd2f9 Delete Singleton on Library Unload
(This is a merge of http://go/wvgerrit/14531)

As an optimization, the Media Server now unloads our library when not
in use. This has exposed a bug by which we were never deleting the CDM
singleton. Fix is to make WvContentDecryptionModule an Android smart
pointer ref base and then make sure all the plugins store a strong
pointer to it. The singleton is a weak pointer, so when the last
plugin is cleaned up, the CDM will be as well. And on the off chance
that the library isn't immediately unloaded, the singleton code will
generate a new CDM next time one is needed.

Bug: 21153732
Change-Id: Ifaf02fa9afe0a70a8b53e8b92ee0a3d1359ca001
2015-06-09 14:58:01 -07:00
Rahul Frias
93d326129a Enable tests that cover renewals/releases with client IDs
[ Merge of http://go/wvgerrit/14480 ]

Server upgrades have been completed and allow these tests to run successfully
against UAT. They were earlier tested against staging.

b/21479112

Change-Id: Ifc5e5780fa5305c6ddfd662ada204db599cb5c6e
2015-05-28 00:33:00 -07:00
Rahul Frias
997ea4f447 Accept signed service certificates
[ Merge of http://go/wvgerrit/14410 ]

When specifying a service certificate though mediaDrm, the CDM earlier expected
serialized service certificates rather than signed ones.

b/21334970

Change-Id: I39af2aa25e8dc2a651cbdce84eb32f266b5b3382
2015-05-26 10:34:18 -07:00
Kongqun Yang
3cdc43caeb Use 0 to represent unexpired license in OnExpirationUpdate
Also fix a missing change for
"playback duration should override license duration".

Merged from Widevine CDM repo:
https://widevine-internal-review.googlesource.com/#/c/14435/

Bug: 21393975
Change-Id: Ibfcf3ae4c13db8944ea285bcc79b6312ea621e1b
2015-05-22 15:47:42 -07:00
Kongqun Yang
ce68b8ee88 Fix expiry time overflow if it is unlimited
Bug: 21324836

Merged from Widevine CDM repo:
https://widevine-internal-review.googlesource.com/#/c/14392

Change-Id: I2a8da14c98f8ae0fece3667b6f6b8517577f8a98
2015-05-20 18:31:06 -07:00
Kyle Alexander
b513c016ed Merge "Updating expected Android version to M" into mnc-dev 2015-05-15 18:24:15 +00:00
Rahul Frias
6e7339f40f Merge "Playback duration should override license duration" into mnc-dev 2015-05-15 17:40:07 +00:00
Kyle Alexander
fdefa86e6e Updating expected Android version to M
Change-Id: Ie8f066658377e58af8c132125c815ef847c2938b
2015-05-15 09:08:00 -07:00
Rahul Frias
d4900bc9a2 Playback duration should override license duration
[ Merge of go/wvgerrit/14360 ]

If within playback window, do not expire license on expiry of rental or
license duration. In this case playback duration will extend the license.

b/17791094

Change-Id: I26d255aa8f0287bd583ebdeec991c613d49d8f22
2015-05-14 15:51:01 -07:00
Rahul Frias
d2e91faf8e Respect Client Properties when reporting CDM Status
[ Merge from go/wvgerrit/14286 ]

CDM now reports status information associated with the specified security level.
Earlier information would be reported from the default security level.

b/18709693

Change-Id: I7a01e8ea9773b56951c207437ce85e567fd32b09
2015-05-07 16:35:51 -07:00
Chih-Hung Hsieh
1c6b675f0c Use gcc to build unit tests until vendor code is fixed.
BUG: 20893039
Change-Id: I649dae16bbc748defc8eb92c879140fe950fe936
2015-05-06 16:44:47 -07:00
Rahul Frias
20fc54e384 Add client information to release and renewal messages
[ Merge of go/wvgerrit/14240 ]

Client information is reported in release and renewal messages based on
flag in the license. License proto has been updated to match server updates.

There are two caveats
* Client IDs will be reported unencrypted when usage reports are requested.
* Release requests that enable privacy mode (encrypted client IDs) but do not
  specify a service certificate are not supported.

b/19247020

Change-Id: I95e709922122370f310936fbad3d312262128e49
2015-05-04 18:24:00 -07:00
Fred Gylys-Colwell
c4d9c1036e Merge "Update unit test make files to use BoringSSL" 2015-04-22 17:35:25 +00:00
Fred Gylys-Colwell
f75fddcdf1 Update unit test make files to use BoringSSL
Merge from widevine of go://wvgerrit/14173

This CL updates the android makefiles to use the libcrypto_static.

Change-Id: I74567ff880ebdce366766a9ab44c92cc9540b8db
2015-04-22 07:47:51 -07:00
Fred Gylys-Colwell
a745387c20 Annotate logcat with current running test (oemcrypto)
Merge from widevine repo of http://go/wvgerrit/14125

This copies code from http://go/wvgerrit/13847 to the oemcrypto unit
tests.  It puts the test name in the log file.

I also commented out some unused function parameters to avoid compiler
warnings.

Change-Id: I3ba259de2f408ec60e90db7f0ea1524d5aa8f8a4
2015-04-17 12:51:20 -07:00
Rahul Frias
dfe9a55a15 Merge "Fix offline key restoration failures" 2015-04-16 00:38:42 +00:00
Edwin Wong
2eb013691c Add more CdmResponseType to help with debugging in the field.
The errors in the range ERROR_DRM_VENDOR_MIN to ERROR_DRM_VENDOR_MAX are
reflected in the message that is reported to the app, which is
MediaDrmStateException.getDiagnosticInfo().

Many errors map to kErrorCDMGeneric, especially KEY_ERROR is used as a
generic error in CDM. This fix defines more specific error codes in the
CDM for places where KEY_ERROR is returned.

Merge from http://go/wvgerrit/14071

bug: 19244061
Change-Id: I688bf32828f997000fea041dd29567dde18ac677
2015-04-15 11:44:06 -07:00
Rahul Frias
a48331a747 Fix offline key restoration failures
[Merge of https://widevine-internal-review.googlesource.com/#/c/14110/ from
 widevine cdm repo]

Backward compatibility handling was causing L3 usage and clock information
to be moved. This caused nonce and other failures when attempting to restore
offline keys.

b/20025990

Change-Id: I6e0fa1030bcce1a5bdd811a9064989d3b6ce2f04
2015-04-15 11:01:39 -07:00
John "Juce" Bruce
c5f576585b Allow Setting of Session ID
Implements the optional setMediaDrmSession() method. To enble this,
support was added to the core to report if a session ID is valid.

As a consequence of this, in the tests for the CryptoPlugin,
construction of the plugin must be deferred until all gMock
expectations are set, as construction now calls into the CDM core.

This is a merge of two changes from the Widevine CDM repo:
http://go/wvgerrit/14083
  Allow Setting of Session ID
http://go/wvgerrit/14085
  Check If Session ID Is Valid When Changing CryptoPlugin IDs

Bug: 19570317
Change-Id: I7dbd777ce6efebd71fdb5e602663a0e35a48a9c4
2015-04-10 16:00:33 -07:00
John "Juce" Bruce
bf5515faa1 Merge "Support Per-Origin Provisioning" 2015-04-10 18:20:55 +00:00
John "Juce" Bruce
13afc71658 Merge "Update Protobufs to Include Per-Origin Provisioning ID" 2015-04-10 18:18:58 +00:00
John "Juce" Bruce
59811eed57 Support Per-Origin Provisioning
This is a merge of several Widevine-side commits that, cumulatively,
allow callers to specify an origin to be used to isolate data storage
as specified in the W3C Encrypted Media Extension specification.
Separate origins have separate certificates, and consequently cannot
share device identifiers with each other.

The changes included in this are:

Add Ability to Check for Existing Certificates
    http://go/wvgerrit/13974
Add Ability to Remove the Certificate
    http://go/wvgerrit/13975
Make CDM Origin-Aware
    http://go/wvgerrit/13977
Add Per-Origin Storage to Widevine CDM on Android
    http://go/wvgerrit/14026
Remove Automatic Origin Generation
    http://go/wvgerrit/14031

Bug: 19771858
Change-Id: I6a01c705d9b6b4887a9c7e6ff4399a125f781569
2015-04-09 19:02:31 -07:00
John "Juce" Bruce
786bbba499 Update Protobufs to Include Per-Origin Provisioning ID
(This is a merge of http://go/wvgerrit/13976)

Updates the certificate provisioning protobuf to include the stable_id
field.

Bug: 19771858
Change-Id: I6c1ed8c8c219a8cacc9798d189458d9861aa46d0
2015-04-09 19:00:16 -07:00
John "Juce" Bruce
b0b11bc534 Replace OS Version with Widevine Version
(This is a merge of http://go/wvgerrit/13813)

Removes the OS Version property which was only ever implemented on
Android to appease Netflix and never actually used by them. Adds,
instead, a Widevine library version property. Also adds
implementations of this function for both Android and CE Devices.

For Android, the version number is starting at 3.0.0-android, to
reflect that this is the third major revision of the Widevine CDM in
Android.

For CE Devices, the version number is not changing from its current
value (2.2.0) but is gaining a "-ce" on the end in order to
differentiate it from the Android version number.

Bug: 18376638
Change-Id: Ifb3fa0d62631b45d9e91a6a53bcab3be38763d3a
2015-04-09 18:53:49 -07:00
Fred Gylys-Colwell
3ff106f86a Merge "OEMCrypto Unit Tests" 2015-04-10 00:06:39 +00:00
Jeff Tinker
453eb29b57 Merge "Integrate OnExpirationUpdate and OnSessionKeysChange with Android" 2015-04-10 00:01:32 +00:00
Fred Gylys-Colwell
2527f77201 OEMCrypto Unit Tests
This is a merge from the Widevine repository of
http://go/wvgerrit/14024
Add Level 3 Oemcrypto Unit Tests To Run All Tests Script

This CL adds the ability to restrict the oemcrypto unit tests to only
use the fall back level 3.  This restriction is per-process, and is
only used while running the unit tests.  This allows us to automate
running the unit tests on an android device as both level 1 and level
3 without modifying files in /system/lib.  To turn on the restriction,
set the environment variable: FORCE_LEVEL3_OEMCRYPTO=yes.

New level 3 library versions are:
level3/arm/libwvlevel3.a  Level3 Library Apr  8 2015 13:09:05
level3/x86/libwvlevel3.a  Level3 Library Apr  8 2015 13:15:42

http://go/wvgerrit/14055
Remove Redundant Tests

This CL modifies the UsageTableTests in oemcrypto_test.cpp so that
they are not all parameterized by new_mac_keys_.  This parameter is
used when testing signatures.  In particular, we do not need to verify
timing twice.

Also, I modified the run_all_unit_tests.sh script so that the
environment variable GTEST_FILTER is passed down to the android
process.  This allows us to use the script to run a limited list of
tests while debugging.

http://go/wvgerrit/14054
Filter Out API Version 10 Tests

This CL updates the OEMCrypto tests so that all but one test will pass
for a device that implements the version 9 API.

Android LMP devices should pass tests with
        GTEST_FILTER="*-*MNC*:*CanLoadTestKeys*"

http://go/wvgerrit/13886
Update Documentation about Optional Features

The intergration guide has been updated to include reference to
OEMCrypto_LoadTestRSAKey.  It also now discusses optional features.

The Delta 10 document now mentions OEMCrypto_LoadTestRSAKey.
The android supplement warns that most optional features are required.

This also adds clarification about which functions should save the
usage table, in answer to:

b/16799904 OEMCrypto v9 ambiguous about saving usage table information

Change-Id: Ifb517d58952c9b332b2958ca99af64bc293b985f
2015-04-09 16:19:17 -07:00
John "Juce" Bruce
7bfda6ec82 Merge "Use Idiomatic Generators for DeviceFiles Unit Tests" 2015-04-09 21:49:31 +00:00
Fred Gylys-Colwell
4d6ec2ac4c Merge "Enable OEMCrypto Unit Tests" 2015-04-08 18:27:18 +00:00
John "Juce" Bruce
e0727b8af6 Use Idiomatic Generators for DeviceFiles Unit Tests
(This is a merge of http://go/wvgerrit/13971)

gTest provides generators for ranges of numbers and booleans so that
we don't have to roll our own.

Change-Id: Id7d9310c5d5c1314f680200da4457c0e529ac107
2015-04-07 16:33:27 -07:00
Fred Gylys-Colwell
6d5be4fddf Enable OEMCrypto Unit Tests
This is a merge from the widevine repository of
http://go/wvgerrit/13923 Switch openssl to use the EVP interface for aes-ctr-128
http://go/wvgerrit/13979 Add Test Certificate to OEMCrypto Mock
http://go/wvgerrit/13978 Add Test Keybox to Level 3 OEMCrypto
http://go/wvgerrit/13873 Enable OEMCrypto Unit Tests

This CL adds a main program to oemcrypto_test.cpp, which filters out
tests that are not supported on the specified platform. It also adds
LoadTestKeybox to the mock. This allows oemcrypto unit tests to be run
on devices that have production keybox.  It also allows the same set
of unit tests to work on Android and on non-Android platforms.

b/18962381 Use test certificate (partial fix)
b/19867990 Separate cast receiver tests

Change-Id: If89c31530103ed85aa37d7379bd5b4dc2a927f38
2015-04-07 15:24:10 -07:00
Ying Wang
0c850a4cb3 Remove setup of proto generated include/header dependency.
They are now set up automatically by the build system.

Bug: 20093047
Change-Id: I3ab1256952915e402adf6510c0f6fdb158feb802
2015-04-07 12:51:20 -07:00
John Bruce
71ccb7f032 Merge "widevine: update to work with BoringSSL." 2015-04-07 19:14:34 +00:00
Fred Gylys-Colwell
88d9472cfb Merge "Fix Memory Leak In OEMCrypto Level 3 Haystack" 2015-04-06 01:52:20 +00:00
Kongqun Yang
7c003cdb0e Merge "Report key status change" 2015-04-02 17:18:20 +00:00
Kongqun Yang
d9b274cb4a Merge "Report change in session expiration" 2015-04-02 17:18:06 +00:00
Kongqun Yang
f7c449e93a Integrate OnExpirationUpdate and OnSessionKeysChange with Android
Also removes OnSessionExpiration which is no longer needed with
OnSessionKeysChange.

Bug: 19771612
Bug: 19771431

Merged from Widevine CDM repo:
https://widevine-internal-review.googlesource.com/#/c/13951/

Change-Id: I0603e808e8d50ff7bb1fb1d5e44fabd8d268ee8a
2015-04-01 19:28:35 -07:00
Kongqun Yang
4621028434 Report key status change
Also modified PolicyEngine::CanDecrypt to use the new Keys_status_.

Bug: 19771431

Merged from Widevine CDM repo:
https://widevine-internal-review.googlesource.com/#/c/13904/

Change-Id: If7fb7fa45ecf9ff4e65278cda00ad7230b57f50b
2015-04-01 19:25:39 -07:00
Adam Langley
4f01ef23d1 widevine: update to work with BoringSSL.
This change:

1) Switches the Makefiles over to using LOCAL_STATIC_LIBRARIES, which I
understand is the new hotness, rather than setting a -I flag directly.

2) Switches to the non-deprecated _ex versions for EVP_EncryptFinal.

3) Uses the EVP_PKEY interface for checking PSS signatures. This is the
only supported interface in OpenSSL: the PSS padding check functions are
only exported in upstream OpenSSL because it's a library from the 90s
and they don't have a concept of "unexported". Also, by using the EVP
functions, OpenSSL/BoringSSL can do a better job of being constant-time.

Since there aren't any obvious tests for checking that the signtaure
verification still works, I tested with the code in the referenced
paste, which includes both the old and new verification functions and
checks that they both work on a sample signature. (And I also checked
that they both fail when a bit in the signature is changed.)

https://paste.googleplex.com/5747976139964416

Change-Id: Iae7409c53eeea9c3892a32c180d7181d72467dcb
2015-04-01 15:46:54 -07:00
John "Juce" Bruce
74afe9dd4e Remove Unused Member from CDM Session
This is a merge of http://go/wvgerrit/13929 from the Widevine repo.

Change-Id: Ic0dea9a0a263fe68bea5ca6c87f5d8e8356ed77c
2015-04-01 13:28:39 -07:00
Fred Gylys-Colwell
42f7458cfc Fix Memory Leak In OEMCrypto Level 3 Haystack
Merge from Widevine repo of http://go/wvgerrit/10308

There was a memory leak in the oemcrypto RSA code.

Also, when saving the usage table, some session variables were
allocated twice.  This results in session data  being lost.

There were also some leaks and uninitialized values in oemcrypto_test.

I added some checks and profiling to the debug runtime for the
haystack.  It will warn if a variable is left unencrypted or is
unencrypted twice.  I also added the profile code.

Versions of L3 library:
android/level3/arm/libwvlevel3.a  Level3 Library Apr  1 2015 11:40:06
android/level3/x86/libwvlevel3.a  Level3 Library Apr  1 2015 12:44:32

b/19950814

Change-Id: Ic752e36c09fce121dcaf92f9209591e74f3eb070
2015-04-01 12:52:29 -07:00
Fred Gylys-Colwell
5f70024388 Merge "Add backward compatibility to OEMCrypto_CopyBuffer" 2015-04-01 05:16:44 +00:00
Fred Gylys-Colwell
ae1711acc0 Add backward compatibility to OEMCrypto_CopyBuffer
Merge from Widevine repository of http://go/wvgerrit/13912

This CL falls back to OEMCrypto_DecryptCTR if the oemcrypto library
does not implement OEMCrypto_CopyBuffer.  This allows devices with
oem crypto version 9 to function as they previously did.

Change-Id: Id3a4a94b1fd559f426ee260cfbf7077fa9101d8b
2015-03-31 20:33:11 -07:00
John "Juce" Bruce
69a9f8edb2 Change DeviceFiles Helpers to Accept std::string
(This is a merge of http://go/wvgerrit/13922 from the Widevine CDM
repository.)

I'm not sure why we chose to pass char* instead of std::string to the
helper functions in DeviceFiles, but it seems to require a lot of
gymnastics of the calling code for minimal gain.

Change-Id: Ie0cdec80ab77c94370648dd74249124aed6e8be1
2015-03-31 17:29:44 -07:00
John "Juce" Bruce
c66badec60 Add More Base Path Helpers to DeviceFiles
(This is a merge of http://go/wvgerrit/13910/ from the Widevine CDM
repository.)

DeviceFiles has a lot of repeated code whenever it needs to check for
file existence or remove a file. When reading and writing files, it
has wrappers that handle this repeated burden. This change adds
wrappers for the other functionality used by DeviceFiles as well, to
reduce duplication.

Change-Id: If959b504672c1b907346d28f31648d8028de8bdf
2015-03-31 15:40:27 -07:00
John "Juce" Bruce
54f3b6d376 Fix Headers in file_store.h
(This is a merge of http://go/wvgerrit/13911/ from the Widevine CDM
repository.)

This wasn't causing problems anywhere yet, but the headers included by
file_store.h were not the headers it actually needed.

Change-Id: I89e6fd30efc8837ba44ce6cfd6d7a7b77db7197a
2015-03-31 15:38:19 -07:00
Kongqun Yang
bdb82e04f8 Report change in session expiration
Bug: 19771612

Merged from Widevine CDM repo:
https://widevine-internal-review.googlesource.com/#/c/13885/

Change-Id: I754f06a7ed9476554f9e1da3fe23f4563f9fc07e
2015-03-31 14:33:53 -07:00
Fred Gylys-Colwell
a7d2f57bfb Clear Content Copy
Copy from Widevine repository of http://go/wvgerrit/13841

This CL adds a nonblocking CopyBuffer to OEMCrypto, its unit tests,
and plumbs it up to the cdm CryptoSession and CdmEngine.

b/19543782

Change-Id: I4c88bd2f8d7f67ecccb549c1934b7c0da15a8429
2015-03-31 09:15:38 -07:00
Fred Gylys-Colwell
582eb32661 OEMCrypto Query Key Control Block
Merge from Widevine repo http://go/wvgerrit/13818

This CL adds the ability to query OEMCrypto about the key control
block and duration of a key that has been loaded.  There are unit
tests and implementation in the level 3 and reference implementation.

b/18503541

Change-Id: I8e40d90a3c64c1ce030af6fef9e98c8eac0df1a5
2015-03-30 15:38:52 -07:00