Commit Graph

151 Commits

Author SHA1 Message Date
John "Juce" Bruce
3398b1f8e7 Fix Repository Inconsistencies from LMP
Back when we were being proactive about merging LMP changes to master
in the Widevine repository, there were a few changes that got merged
in a different form than what got checked into the Android repository.
Mostly, this happened due to several large core changes that were
brought over to the master branch in multiple parts so as not to break
other teams using the Widevine repository. This patch brings the two
trees in sync.

Change-Id: I4e56a742686d73d1c6ace209684ce0e8542fd93f
2015-03-11 13:26:23 -07:00
John "Juce" Bruce
85daefb89d Restore Lost Formatting Fixes
Due to merges happening out-of-order, some formatting fixes that had
previously been merged from the Widevine repository were subsequently
wiped out by later merges.

Change-Id: I9f02d281d276b0f5b5f93b02a699144400db7520
2015-03-11 11:47:05 -07:00
John "Juce" Bruce
1bd405fc40 Merge Tweaks Originating in Merge Review Comments
This merges several small changes that were made in response to
comments that arose when LMP changes were merged into the Widevine
repository's master branch.

Change-Id: Ifec968af54dbc3288f24654ec0c6ca9b5962e1aa
2015-03-10 16:08:20 -07:00
Jeff Tinker
fb6d83398c Merge "Specify OEMCrypto API version in client capabilities"
Merges missing bits from the Widevine CDM repo for
https://widevine-internal-review.googlesource.com/#/c/10653

Most of this change was submitted into lmp-dev, but some tests
were ommitted.  This CL completes the missing changes from the
original widevine repo commit.

It also fixes some missing test installation commands.

b/15388863

Change-Id: Id59d885780134c6c6863477f8c49fb9d8ffe509d
2015-03-10 23:03:20 +00:00
John "Juce" Bruce
f17ef05ebf Fix Build
A nonexistant member field was being initialized.

Change-Id: I12b0917e70e163e71f09d5d4c03fd0bd59ad6002
2015-03-10 14:55:41 -07:00
Fred Gylys-Colwell
4e6fd5d2d8 Merge "Lock session list in CdmEngine OnTimerEvent (master)" 2015-03-10 20:48:13 +00:00
KongQun Yang
0a564039ca Cleanup namespace ending comment
(This is a merge of http://go/wvgerrit/13400 from the Widevine CDM
repository.)

Replace "};  // namespace" with "}  // namespace":
ag -l --ignore-dir third_party "};  //" | \
while read f; do sed -r -i 's/\};  \/\//}  \/\//' $f ; done

Replace "// unnamed namespace" with "// namespace":
ag -l --ignore-dir third_party "unnamed namespace" | \
while read f; do sed -r -i 's/unnamed namespace/namespace/' $f ; done

Change-Id: I50ece9a127ce669f15cd532dfae1dd741338a075
2015-03-09 13:05:25 -07:00
KongQun Yang
23c95a1251 Merge MaxNumberOfSessions changes from CDM
Bug: 18377675

Implement new OEMCrypto function to get max number of sessions
https://widevine-internal-review.googlesource.com/#/c/12980/

Add oemcrypto static adapter for v9
https://widevine-internal-review.googlesource.com/#/c/13022/

Support new property to query MaxNumberOfSessions in CDM
https://widevine-internal-review.googlesource.com/#/c/13020/

Fix GetHdcpCapabilities incorrect return if not initialized
https://widevine-internal-review.googlesource.com/#/c/13210/

Change-Id: I02738c543cedd6e38d8826f845fec6cb2b1ede3c
2015-03-09 13:05:21 -07:00
Fred Gylys-Colwell
6444332cd7 Lock session list in CdmEngine OnTimerEvent (master)
Cherry pick of
https://widevine-internal-review.googlesource.com/#/c/12935/

Change-Id: I029d36b2b6d092ae938fca2a7f6d893814c25a8a
2015-03-06 16:00:37 -08:00
John "Juce" Bruce
2c809b62ca Replace Uses of .compare() in Device Files
(This is a merge of http://go/wvgerrit/13390 from the Widevine CDM
repository.)

Change-Id: I5b3595d5ef52b670e5ba5019746f03d934ae9625
2015-03-06 12:06:47 -08:00
John "Juce" Bruce
a3b0d83d19 Run clang-format on Core
This copies over formatting changes from the Widevine CDM repository
that resulted from running clang-format with Google style on the
shared core/ directory. It also copies over some rewordings of log
messages that were made at the same time.

Aside from the changed log messages, this should not affect behavior
or functionality.

Change-Id: I69c57c188f7a79f30fa3517afeed17365929b6b6
2015-03-05 16:46:01 -08:00
John "Juce" Bruce
dff91b48c1 Merge "Generate Key Set IDs at Key Request Generation Time" 2015-03-05 20:05:13 +00:00
John "Juce" Bruce
f66fd68caa Merge "Make PSSH parser more robust." 2015-03-05 20:04:53 +00:00
John "Juce" Bruce
614abba6c2 Merge "Remove OEMCrypto v8 adapter" 2015-03-05 20:04:43 +00:00
John "Juce" Bruce
cba04ecddf Merge "Merge Widevine CDM-Side Core Changes" 2015-03-05 20:04:14 +00:00
John "Juce" Bruce
9340b3e869 Merge "Merge Widevine CDM-Side Test Changes" 2015-03-05 20:04:05 +00:00
John "Juce" Bruce
6d1ceb2e18 Merge "Rename CancelKeyRequest" 2015-03-05 20:03:40 +00:00
KongQun Yang
dc0ecfea7c Merge "Update usage table when session is closed" 2015-03-05 02:11:04 +00:00
John "Juce" Bruce
620b05dba0 Generate Key Set IDs at Key Request Generation Time
(This is a merge of http://go/wvgerrit/11285 from the Widevine CDM
repository.)

The key set ID is now available earlier, in order to support the CE
CDM 4.5 interface, which needs it at key request generation time, not
later at key response receipt time. It is still possible to receive
the key set ID at key response time, for Android's purposes. Either
API may now be passed a pointer to store the ID in, which may also be
left NULL if this is not needed.

Change-Id: I47e80ea4005c80282e36cfae92cb91142208f624
2015-03-04 15:02:01 -08:00
John "Juce" Bruce
4252a4b790 Make PSSH parser more robust.
(This is a merge of http://go/wvgerrit/12700 from the Widevine CDM
repository.)

Adds unit tests which cover several cases, including five which are
fixed in this patch:

* Find a Widevine PSSH after a PSSH with non-zero flags.
  (We have no control over another provider's abuse of the flags field,
   so we should not give up if such a PSSH appears before ours.)
* Find a Widevine PSSH after a v1 PSSH.
  (CENC now specifies a general v1 format.  We don't have to support it
   directly in the CDM, but we do have to skip it gracefully.)
* Find a Widevine PSSH after a non-PSSH box.
  (This would be unusual input, but we can easily recover from it.)
* Parse a PSSH box with a size field of 0, which means "the rest of the
  buffer."
  (This would be unusual input, too, but is technically allowed for any
   MP4 box.)
* Parse a v1 Widevine PSSH box, ignoring the new fields we don't need.

Bug: 19288007
Change-Id: I355df9e34ba4d53cc02e8501de965a0d193ee554
2015-03-04 15:00:57 -08:00
John "Juce" Bruce
d5fdd89071 Remove OEMCrypto v8 adapter
Android has never used the static adapters. This code is and has
always been dead in the Android codebase.

Change-Id: Ia6bb12a3fafb2c9b08349b0aca31fde45a58dada
2015-03-04 15:00:57 -08:00
John "Juce" Bruce
7639e0297f Merge Widevine CDM-Side Core Changes
This is a combined merge of several small changes to the core in the
Widevine CDM repository:

http://go/wvgerrit/10941
  Rename privacy_crypto to allow more variants.

http://go/wvgerrit/11530
  Add Missing Header to properties.h

http://go/wvgerrit/11531
  More Loosely Couple CdmEngine and CdmSession

Change-Id: I5b3f738ae495ab267da1440421dd7aa6f7860194
2015-03-04 13:25:54 -08:00
John "Juce" Bruce
33ddce2298 Merge Widevine CDM-Side Test Changes
This is a combined merge of several small test changes in the
Widevine CDM repository:

http://go/wvgerrit/11252
  Chain CreateSession() Helpers in CDM Session Unit Test

http://go/wvgerrit/10931
  Increase URLRequest timeouts and tolerate 502's.

http://go/wvgerrit/10695
  Remove dead CHROMIUM_BUILD code in engine test.

Change-Id: I75a6c9509880a20c85e54cbd2fcbf34b101ce70e
2015-03-04 12:39:06 -08:00
John "Juce" Bruce
2ae1f717f3 Rename CancelKeyRequest
(This is a merge of http://go/wvgerrit/10674 from the Widevine CDM
repository.)

Now that the CE CDM has CloseSession to handle closing sessions, we
can rename CancelKeyRequest on the CDM Engine & CDM Session to better
resemble its purpose and the name it is known by on Android.

Change-Id: I68d55b3be733579e5875ab33d8e94a62fe1f651d
2015-03-04 12:24:57 -08:00
KongQun Yang
a0b016ecf6 Update usage table when session is closed
Merge from the widevine CDM repo:
https://widevine-internal-review.googlesource.com/#/c/13310/

Bug: 19003762
Change-Id: Icaa1978c16437d36c99b0b0dabbbfa15fe469bc3
2015-03-03 17:43:52 +00:00
Fred Gylys-Colwell
7416795401 am 802fe3b3: Lock session list in CdmEngine OnTimerEvent
* commit '802fe3b35c42975cad30b947903e002500f2a6c7':
  Lock session list in CdmEngine OnTimerEvent
2015-02-11 20:04:44 +00:00
Fred Gylys-Colwell
802fe3b35c Lock session list in CdmEngine OnTimerEvent
This is a copy of the widevine CL:
https://widevine-internal-review.googlesource.com/#/c/12742/

If a session is closed at the same time as an OnTimerEvent is
processing an event, there could be a race condition between the two
threads.  This CL adds a lock that prevents a session from being
removed from the list while the timer is currently processing an
event.

If CloseSession is called while the OnTimerEvent method is active, the
session will be added to a dead list, and deleted when the timer event
has finished.

This CL does not address the main problem in bug 19252886, but
one bugreport, netflix_log_3.txt, indicates there may have been
a problem with the CDM timer.
bug: 19252886

Change-Id: I17190edaeb3eef1295d4d204232cc4262cb5fa9b
2015-02-10 20:11:57 -08:00
Jeff Tinker
173e6031f3 am 8961cd24: Fix for zero-sized corrupted license files
* commit '8961cd2404b7064d69288b5572ffd0d454004280':
  Fix for zero-sized corrupted license files
2015-01-23 08:45:27 +00:00
Jeff Tinker
8961cd2404 Fix for zero-sized corrupted license files
Netflix reported that after pulling power while their app is active,
the app isn't able to restart.  This is because the license file for
session keys isn't getting synched to disk, so the data is still in
the buffer cache when the device shuts down.  Calling fflush and fsync
on the file ensures the data is persisted to disk.  fclose alone
doesn't do fsync.

In testing, I also noticed that the license file was being rewritten
every second which is hard on the flash filesystem.  The timer thread
was modified to avoid these frequent writes.

Merge of https://widevine-internal-review.googlesource.com/#/c/12431/
from the widevine cdm repo.

bug: 19108207
Change-Id: Ibe81e40a3c1f5d25563523da43fefdccdaa6ddcf
2015-01-22 16:20:31 -08:00
Rahul Frias
ab3ffa9a55 am 6e4896e8: Merge "Corrections to license policy handling and reporting" into lmp-mr1-dev
* commit '6e4896e8ba52192a731eab19f454a1f51544dbab':
  Corrections to license policy handling and reporting
2015-01-17 11:46:40 +00:00
Rahul Frias
db1382e0a3 Corrections to license policy handling and reporting
If a key query occurred before a license was received an UNKNOWN_ERROR was
returned. This now succeeds but returns no information (an empty container).

Also licenses that were already expired when received were not marked as such.
This did not cause violations in playback rules but caused an exception when
they were queried.

[ Merge of https://widevine-internal-review.googlesource.com/#/c/12300
  from wv git repo ]

b/18843625

Change-Id: I6990765c15e519ddf203a2fd8f0a130306f090a6
2015-01-16 14:48:57 -08:00
Fred Gylys-Colwell
f9add54545 am 62a9cf3c: Terminate Level 1 OEMCrypto on Initialization Error
* commit '62a9cf3cbea34f2d04c50809703d31efd78514d9':
  Terminate Level 1 OEMCrypto on Initialization Error
2014-12-18 22:03:47 +00:00
Fred Gylys-Colwell
62a9cf3cbe Terminate Level 1 OEMCrypto on Initialization Error
Cherry pick of the widevine change
https://widevine-internal-review.googlesource.com/#/c/12082/

If the level 1 oemcrypto library loads and initializes, but has the
wrong version or does not have a valid keybox, then the level 3
fallback is used.   However, in those cases, the level 1 was not
terminated properly.  This caused a resource leak on some platforms.

With this CL, in OEMCrypto_Initialize, the level 1 library Terminate
is called if its Initialize was called and the level 1 library will
not be used.

bug: 18755226
Change-Id: I56e7d3349eeebd94f3fa8c4a1f4b21781cc7428b
2014-12-17 11:29:14 -08:00
Rong Xu
31aa16fbab Fix gcc-4_9 warning
Fix a warning in gcc-4.9:
In file included from
vendor/widevine/libwvdrmengine/cdm/core/src/max_res_engine.cpp:3:0:
vendor/widevine/libwvdrmengine/cdm/core/include/max_res_engine.h:56:9:
error: 'class wvcdm::MaxResEngine::KeyStatus' is private
   class KeyStatus {
         ^
vendor/widevine/libwvdrmengine/cdm/core/src/max_res_engine.cpp:10:53:
error: within this context
 typedef std::map<wvcdm::KeyId,
wvcdm::MaxResEngine::KeyStatus*>::const_iterator

(cherry picked from commit 944d085a79)

Change-Id: I4984bd52c52c36e59c4d09db5e4f4d581e577b07
2014-12-09 11:20:24 +01:00
Rahul Frias
3a586ab27b Report HDCP status of no HDCP device attached
OEMCrypto may report an HDCP status of "No HDCP device attached/using
local display with secure path". This is not propagated upto
the server as an appropriate HDCP value did not exist in the
license protocol. This has now been added. Netflix has requested that
this be reported.

[ Merge of https://widevine-internal-review.googlesource.com/#/c/11806/
  from Widevine cdm repo ]

b/18377309

Change-Id: I3db88c7ab5e79a3c12dbc8a398c4770e14e5ee5c
2014-11-22 01:46:13 -08:00
Rahul Frias
aa7ad630d7 MediaDrm throws an exception when Secure Stops are requested
Our recommendation to OEMs is that they support a table of at least 50
usage entries in OEMCrypto. If more usage entries are stored, the PSTs get
added to the CDM but are LRU'ed out of the OEMCrypto usage table. When the
CDM queries those usage entries, OEMCrypto will return a
OEMCrypto_ERROR_INVALID_CONTEXT. Rather than return an error and have
MediaDrm throw an exception, CDM should delete this PST and return the
next usage entry, when queried.

[ Merge of https://widevine-internal-review.googlesource.com/#/c/11457/
  from Widevine cdm repo ]

b/17994711

Change-Id: I00e3f93000096fb434d94333e22958de795a4bb5
2014-11-13 12:56:26 -08:00
Fred Gylys-Colwell
3b1a3e47d8 Merge "Adjust CDM engine and request license unit tests" into lmp-mr1-dev 2014-11-13 01:12:22 +00:00
Fred Gylys-Colwell
9ff5125867 Adjust CDM engine and request license unit tests
Merge of the widevine change:
https://widevine-internal-review.googlesource.com/#/c/11632

Several unit tests in cdm_engine_test.cpp and request_license_test.cpp
were failing regularly. These were caused by either:
1) The device was not provisioned.
  This has been fixed by adding a certificate provisioning step in the
  test setup for the cdm engine tests and changing the existing
  provision steop in the request license tests to provision for both
  security levels.
2) The device was hitting a flaky server.
  This has been fixed by switching from the GooglePlayServer to the
  Widevine server.
3) A null pointer introduced when testing secure stops with an app
  id.  This has been fixed by directly injecting the app id in the unit
  tests.
4) Flaky network connections.  The unit tests were requesting data
  from the server and were timing out after 3 seconds.  I changed that
  to 12 seconds.
5) The tests were searching for an end-of-line marker to find the GLS
  header in the license response message.  The end-of-line marker was
  present in a valid DRM message for almost 1% of the test cases.  This
  code  has been replaced by searching for the string "GLS/1" at the
  begining of the HTML body.

I also added test_printers.cpp that defines functions used by GTest to
print error codes by name instead of numeric value.

This CL changes unit tests only. It does not change any production
code.

bug: 18316036

Change-Id: I3398580059a03114e782ac7ac59e6b0944012df4
2014-11-12 13:57:03 -08:00
John "Juce" Bruce
abbef3d002 Merge "Fix Typos in License.cpp" into lmp-mr1-dev 2014-11-07 21:33:24 +00:00
John "Juce" Bruce
4d695de2b0 Fix Typos in License.cpp
(This is a merge of http://go/wvgerrit/11626 in the Widevine CDM
repo.)

Change-Id: Iad48e76a77c285c0e0738b22436dc60cb3704740
2014-11-07 13:21:40 -08:00
John "Juce" Bruce
039b984a75 Merge "Add OS Version to Properties" into lmp-mr1-dev 2014-11-07 20:04:55 +00:00
John "Juce" Bruce
31f87bc19e Add OS Version to Properties
(This is a merge of http://go/wvgerrit/11613 from the Widevine CDM
repo.)

Adds a property for the OS version, implements it on Android, and
adds it to the license request property bag so that Netflix may
use it to discern the supported capabilities of the CDM.

Bug: 18230738
Change-Id: If5174a108093855314f3e0102b83691e20bb247b
2014-11-07 11:47:51 -08:00
Edwin Wong
59da418883 Remove corrupted license file from storage.
(This is a port of http://go/wvgerrit/11614 from the
 Widevine repo.)

CDM does not recover if a license file has invalid size
or the hash is incorrect. Remove the corrupted license
file in such cases.

bug: 18002606

Change-Id: I46dec853ce6b2e7c7430297d50df5d30488cde3b
2014-11-06 17:07:48 -08:00
Jeff Tinker
960718a673 Merge "Wire Up Max-Res Plumbing" into lmp-mr1-dev 2014-11-06 02:36:01 +00:00
Jeff Tinker
418887a5e7 Merge "Add Max-Res Decode Engine to CDM Core" into lmp-mr1-dev 2014-11-06 02:35:56 +00:00
Fred Gylys-Colwell
20191d996c Allow Secure Stops to be queried and deleted by application ID
This CL changes the WVDrmPlugin so that an application can segregate
its secure stops from those of other applications by setting an
application ID.

This CL is a merge of the following Widevine CLs:
https://widevine-internal-review.googlesource.com/#/c/11565/
Add getSecureStop by ssid

https://widevine-internal-review.googlesource.com/#/c/11572
Add getSecureStop by SSID and releaseAllSecureStops by app id.

https://widevine-internal-review.googlesource.com/#/c/11564/
Store Usage Info by App Id (device_file stubs)

https://widevine-internal-review.googlesource.com/#/c/11563/
Add application id to StoreUsageInfo.

https://widevine-internal-review.googlesource.com/#/c/11561/
Added Application ID to PropertySet for secure stop.

bug: 18053197
bug: 18076411
Change-Id: I5444baf67ba1b960dee2dc958bced8de82ab70a3
2014-11-05 17:39:44 -08:00
John "Juce" Bruce
e4252f3861 Wire Up Max-Res Plumbing
(This is a port of http://go/wvgerrit/11556 from the Widevine CDM
repo.)

This wires up the new method on the crypto interface with the core
code that handles the max-res decode.

Bug: 16034599
Change-Id: Id2ea5635bf732eabf1fd33712ff8bab6cf1a1745
2014-11-04 11:55:27 -08:00
John "Juce" Bruce
12821d5968 Add Max-Res Decode Engine to CDM Core
(This is a port of http://go/wvgerrit/11555 from the Widevine CDM
repo.)

Bug: 16034599
Change-Id: Ie69afac7d89e27623adbc84d2baebccf1d1ba6e6
2014-11-04 11:55:23 -08:00
Edwin Wong
138160ddea Update license request url to new signed Widevine UAT proxy.
Bug: 16631113
Change-Id: I442f9c9decd03213912c8c2befcbeccc2a332c53
2014-09-13 01:32:29 +00:00
Jeff Tinker
887dcfef6b Revert workaround for WVv9 netflix license issue on fugu and molly
related-to-bug: 17212907

Change-Id: I9a6eed207f8fbdbd621b9ecde2cb99112f02e9fa
2014-09-08 19:32:04 +00:00