Commit Graph

2744 Commits

Author SHA1 Message Date
Fred Gylys-Colwell
947531a6a9 Refactor oemcrypto mock into stand alone reference code
Merge from Widevine repo of http://go/wvgerrit/46204
Refactor utility code - split the mock, step 1

Merge from Widevine repo of http://go/wvgerrit/46205
Move some OEMCrypto types to common header - split the mock, step 2

Merge from Widevine repo of http://go/wvgerrit/46206
Split mock into two -- step 3

Merge from Widevine repo of http://go/wvgerrit/47460
Split the mock into two -- step 3.5

The CL moves several files used by oemcrypto and cdm into a common
subdirectory, so that it may more easily be shared with partners.

The CORE_DISALLOW_COPY_AND_ASSIGN macro was moved to its own header in
the util/include directory.

This CL removes some references to the mock from other code, and puts
some constants and types, such as the definition of the keybox, into a
header in oemcrypto.

Test: tested as part of http://go/ag/4674759
bug: 76393338
Change-Id: I75b4bde7062ed8ee572c97ebc2f4da018f4be0c9
2018-09-02 11:45:16 -07:00
Rahul Frias
b8091eaa7d Merge "Delete usage information on insufficient resources" into pi-dev am: b4b02e7762
am: 4540d4eba3

Change-Id: I617db9b5b8ee69681036456d8e2a7b4711b2d926
2018-08-29 20:45:55 -07:00
Rahul Frias
4540d4eba3 Merge "Delete usage information on insufficient resources" into pi-dev
am: b4b02e7762

Change-Id: I902ddd96e3bfabc4fc17f0f329d31060106452a3
2018-08-29 20:41:55 -07:00
TreeHugger Robot
b4b02e7762 Merge "Delete usage information on insufficient resources" into pi-dev 2018-08-30 03:31:52 +00:00
Fred Gylys-Colwell
15ecbe09bd Refine TwoHundredEntries tests am: a963e90bb8
am: 5b74e3186a

Change-Id: Ifbdc769685d3e6f96222ca180696dc18022d84d1
2018-08-29 18:29:35 -07:00
Fred Gylys-Colwell
5b74e3186a Refine TwoHundredEntries tests
am: a963e90bb8

Change-Id: I38d4ccb9c7e517e72a2b4555557db0de01f01302
2018-08-29 18:10:22 -07:00
Rahul Frias
299b100fc8 Delete usage information on insufficient resources
[ Merge of http://go/wvgerrit/58460 ]

If OEMCrypto runs out of space in the usage table header+entries adding
a new license or loading/using an existing one might fail. This CL makes
two modifications to handle this scenario.

* OEMCrypto_ERROR_INSUFFICIENT_RESOURCES will be returned from
  OEMCrypto_CreateNewUsageEntry or OEMCrypto_LoadUsageEntry. An attempt
  will be made to release a LRU entry from the usage table and retry
  the operation. This may be retried 3 times unless success
  occurs earlier.

* On initialization, the usage table header is loaded. If there are more than
  the minimum number of usage entries (200), an attempt is made to
  add a usage entry. If this fails, we are likely in an unrecoverable
  state. We then delete all offline licenses, usage information and
  recreate the usage table header. This will allow future playback
  attempts to succeed and offline licenses to be able to be downloaded
  but will lose all current offline licenses and secure stops.

Bug: 112486006
Test: WV unit/integration tests, GtsMediaDrmTest
      Playback tests using Netflix and Play movies.

Change-Id: I41a18d69a329f8a96c7b607d299ce73af3d56177
2018-08-29 17:38:43 -07:00
Fred Gylys-Colwell
a963e90bb8 Refine TwoHundredEntries tests
Merge from Widevine repo of http://go/wvgerrit/58440

This CL modifies the oemcrypto test TwoHundredEntries so that it
attempts to create more than 200 entries.  A device is allowed to fail
when such an attempt is made, but it must return an insufficient
resources error.

The test then verifies that each of the entries that were succesfully
created can be used to reload its license and the keys can be used for
decryption.

It then shrinks the usage table header, and verifies that the
remaining licenses can still be used for decryption.

bug: 112486006
test: unit tests (test code only)
Change-Id: I6e6edfb00f0553724e0f99fb4e5ea5c817450937
2018-08-29 14:54:25 -07:00
Rahul Frias
760e938384 Merge "Use new play license service URI" 2018-08-14 17:06:33 +00:00
Haibo Huang
e7703c90e3 [automerger skipped] Remove std::tr1::
am: 3513db8f73  -s ours

Change-Id: Ie7249e936ea64b13ee9ec5322e64cd2be6372a2e
2018-08-10 17:23:49 -07:00
Haibo Huang
3513db8f73 Remove std::tr1::
To be compatible with latest googletest.

Test: compile
Change-Id: I15d857ce7b9b28ba5f75c84c61f1c6a970012ca7
Merged-In: I15d857ce7b9b28ba5f75c84c61f1c6a970012ca7
2018-08-10 21:37:50 +00:00
Rahul Frias
7b7d5edd7c Use new play license service URI
[ Merge of http://go/wvgerrit/54802 ]

BUG: 110954967
BUG: 110960064

Test: WV unit/integration tests.

Change-Id: I3c5263f304ec9c9734a6761cbd7db46ccb476e9e
2018-08-01 13:41:54 -07:00
Haibo Huang
531b6d3d10 Remove std::tr1::
To be compatible with latest googletest.

Test: compile
Change-Id: I15d857ce7b9b28ba5f75c84c61f1c6a970012ca7
2018-07-23 18:24:15 +00:00
John W. Bruce
c28cea3637 Add Missing Parameter to License Keys Unit-Test
(This is a merge of http://go/wvgerrit/55265)

Compiling with GCC 7 revealed that a function call in this test was
missing an argument. It meant to be passing the output protection level
to the function, but because of optional arguments, it was instead
passing it as the fourth argument.

Fixing this revealed that the test cases for the test were incorrect in
one case, which has been fixed to expect the correct results.
Thankfully, this part of the code does not appear to have been broken
while the tests had this hole.

Bug: 111648438
Test: build_and_run_all_unit_tests.sh
Change-Id: I6c13d5fecdccc4185ca5e8698fc845929ff16cb1
2018-07-19 12:49:40 -07:00
Fred Gylys-Colwell
44d2d2653e Delete old provisioning doc
Merge from Widevine repo of http://go/wvgerrit/53980

The provisioning doc changed names, and I accidentally added the new one
without deleting the old one.

I also added a watermark to the newer one.

Change-Id: Ib6e553aa5222c0c59dc03a897229645d37e4189e
2018-06-29 13:59:42 -07:00
Rahul Frias
52a1d1681c Recover when stored information is corrupted am: a20034e3a2
am: 0dc79e547f

Change-Id: I68795d284dfcde4ccd8484bdccf3ddf3a9ee0882
2018-06-06 20:56:39 -07:00
Rahul Frias
0dc79e547f Recover when stored information is corrupted
am: a20034e3a2

Change-Id: I064f71dc63da3771e5ce70f7656eb7a45a9843c1
2018-06-06 14:10:20 -07:00
Rahul Frias
a20034e3a2 Recover when stored information is corrupted
[ Merge of http://go/wvgerrit/52040 ]

Information stored in files are serialized and protected by an MD5 hash.
When files cannot be read because the MD5 hash computed over it
fails verification, the file is deleted. This allows for recovery.

However if the protobuf deserialization fails we return an error
but do not delete the file. When errors of this sort occur
with usage information files, the CDM cannot recover.
removeAllSecureStops() will fail as well and new licenses
with PSTs cannot be processed. In order to recover the file will
be deleted when a protobuf deserialization error occurs.

Bug: 109765590
Test: WV unit, integration tests. GTS tests. Netflix and Play Movies playback
Change-Id: I408914924e644d5c22b2ba7865d3a7d598788ee6
2018-06-06 00:57:31 -07:00
Rahul Frias
9af88e1c59 Address deadlock am: d401baa236
am: 2d7e47508b

Change-Id: Iffe367f44be7049b013ce1fda7394de924dd83ae
2018-05-30 00:06:13 -07:00
Rahul Frias
2d7e47508b Address deadlock
am: d401baa236

Change-Id: Idfa0ee7dc493cc40a0c2500e8377257ce6dcbc80
2018-05-30 00:01:12 -07:00
Rahul Frias
d401baa236 Address deadlock
[ Merge of http://go/wvgerrit/51322 ]

This avoids taking the session_map_lock_ twice.

Bug: 80248149
Test: WV unit/integration tests, GtsMediaTestCases,
      2 days of netflix playback.

Change-Id: Iea1c7b7ba08d7d40c227d21c5abfce13c0a8b395
2018-05-28 12:41:19 -07:00
Fred Gylys-Colwell
a5b89dc5eb Merge "Update Docs for OEMCrypto v14.1" into pi-dev am: 7d90a07c08
am: b94b13107d

Change-Id: I4bb3ba3a6e176d026725e097f3bae0bd234723bc
2018-05-26 11:09:30 -07:00
Fred Gylys-Colwell
b94b13107d Merge "Update Docs for OEMCrypto v14.1" into pi-dev
am: 7d90a07c08

Change-Id: I5010de40e77e0325262d7182340abc744ac2015a
2018-05-26 11:02:51 -07:00
TreeHugger Robot
7d90a07c08 Merge "Update Docs for OEMCrypto v14.1" into pi-dev 2018-05-26 17:54:12 +00:00
Fred Gylys-Colwell
23efd73969 Merge "Update Android Integration Guide" into pi-dev am: d19f86c153
am: 8ac6b598dd

Change-Id: Ic9a7c9e4d9ea8a7fc70042289f73387ba4eb8b9e
2018-05-26 10:13:57 -07:00
Fred Gylys-Colwell
8ac6b598dd Merge "Update Android Integration Guide" into pi-dev
am: d19f86c153

Change-Id: Ica63db685b8564fe0785fed262b5f49e44348223
2018-05-26 10:07:56 -07:00
Fred Gylys-Colwell
d19f86c153 Merge "Update Android Integration Guide" into pi-dev 2018-05-26 16:56:57 +00:00
Fred Gylys-Colwell
36be81af8b Merge "Document Version Compatibility" into pi-dev am: 67c140641e
am: b83fe36a09

Change-Id: I932e569de9006108944526a8888e8d68ba8aa8d6
2018-05-25 05:16:56 -07:00
John W. Bruce
ee74b98530 Make Defensive Copies in CopyBufferInChunks am: b305d99d3b
am: f3b5d0408b

Change-Id: I02471e84c5b9ee4339daccdc3df1a38038f5949e
2018-05-25 05:12:22 -07:00
Fred Gylys-Colwell
b83fe36a09 Merge "Document Version Compatibility" into pi-dev
am: 67c140641e

Change-Id: Ic25046c30a641f4b21832b1f425b9ce813197184
2018-05-24 18:06:29 -07:00
John W. Bruce
f3b5d0408b Make Defensive Copies in CopyBufferInChunks
am: b305d99d3b

Change-Id: I6657bd3174202f061a003f0e8132075b807af2e9
2018-05-24 17:04:27 -07:00
TreeHugger Robot
67c140641e Merge "Document Version Compatibility" into pi-dev 2018-05-24 20:58:54 +00:00
Fred Gylys-Colwell
4192c3d04c Document Version Compatibility
Merge from Widevine repo of http://go/wvgerrit/49580

This document explains which version of OEMCrypto is compatible with
which version of CE CDM or Android.  The intent is to share this on
all Widevine partner repos.

bug: 77637828
Change-Id: Id7db8f9cb5f2a5c6bf35dfecd2ae3b3fabd09c56
testing: documentation only
2018-05-24 17:20:22 +00:00
Fred Gylys-Colwell
d3638335ec Update Android Integration Guide
Merge from Widevine repo of http://go/wvgerrit/51081

Clarifies the Level 3 OEMCrypto library, talks about build files, and data
migration.

test: documentation only
bug: 74242000
Change-Id: Id1c9f9cb44f0b3e5bc084458b1d934b9fea18ac8
2018-05-24 17:20:07 +00:00
Fred Gylys-Colwell
13e08cd7b8 Update Docs for OEMCrypto v14.1
Some documentation updates.

Merge from Widevine repo of http://go/wvgerrit/50941

bug: 79940606 OEMCrypto_PST_Report are network byte order
bug: 79874942 [Documentation] PST_Report struct layout differs from documentation
bug: 74010869 CGMS Best Effort

test: documentation change only
Change-Id: I1e9149efcfa5d91c503b74e6776ebb8f25cda15c
2018-05-24 17:19:54 +00:00
John W. Bruce
b305d99d3b Make Defensive Copies in CopyBufferInChunks
(This is a merge of http://go/wvgerrit/51084)

Nominally, OEMCrypto probably shouldn't modify the buffer descriptor we
pass into OEMCrypto_DecryptCENC(), but in practice, we know some
platforms do this, so we make defensive copies in
CryptoSession::DecryptInChunks() just in case. Turns out, some devices
also behave like this in OEMCrypto_CopyBuffer(), so we should also be
doing defensive copies in CryptoSession::CopyBufferInChunks().

Bug: 79779554
Test: ExoPlayer Demo App, played "Secure Subsample UHD (WebM, VP9)"
Test: build_and_run_all_unit_tests.sh
Change-Id: Ib46043a6cc0aa42d1d1cc85f5adb477c566363e9
2018-05-23 18:04:01 -07:00
Fred Gylys-Colwell
0ed9c3150a Fix entry count in TwoHundredEntries am: b396f9a870
am: 7132c09585

Change-Id: Iab80e32b17311344b930ad1bfc8785dc4647eaf2
2018-05-17 14:08:25 -07:00
Fred Gylys-Colwell
7132c09585 Fix entry count in TwoHundredEntries
am: b396f9a870

Change-Id: Ib137096153be59111461e78886764d407ebbe352
2018-05-17 13:47:13 -07:00
Fred Gylys-Colwell
b396f9a870 Fix entry count in TwoHundredEntries
Merge from Widevine repo of http://go/wvgerrit/50600

The entry count was really 201 -- it should be 200.

test: This code is unit tests only -- no production code.
bug: 79875327
Change-Id: Ib81253ce9d51a7157ea0a64cddeb6cc266b3e25e
2018-05-16 15:08:35 -07:00
Rahul Frias
f9f46408c5 Merge changes I30a3ede3,I6008ddba,I869c22a2 into pi-dev am: d615d66cca
am: b9c3a6b81a

Change-Id: I1088358f88836dbd77543a532ef45bb907ed51a6
2018-05-15 17:23:34 -07:00
Fred Gylys-Colwell
01b7c91992 Unit test for kInactiveUnused usage reports am: bd6bbce86f
am: f3d8e21bff

Change-Id: Ib48a323581ce121e3c502d6379b58d3afcc59b4c
2018-05-15 17:17:38 -07:00
Rahul Frias
b9c3a6b81a Merge changes I30a3ede3,I6008ddba,I869c22a2 into pi-dev
am: d615d66cca

Change-Id: I0d991231a7a4b15d1f8f822e6f9ad136b7135a31
2018-05-15 17:04:35 -07:00
Rahul Frias
d615d66cca Merge changes I30a3ede3,I6008ddba,I869c22a2 into pi-dev
* changes:
  Protect sessions from concurrent access.
  Address concurrency failures between calls to decrypt and periodic timer
  Revert of "Prevent race conditions between decrypt and close session"
2018-05-15 23:21:04 +00:00
Fred Gylys-Colwell
f3d8e21bff Unit test for kInactiveUnused usage reports
am: bd6bbce86f

Change-Id: Ib669b04260a7298b4e223e7873e1603123e14125
2018-05-15 15:45:23 -07:00
Fred Gylys-Colwell
bd6bbce86f Unit test for kInactiveUnused usage reports
Merge from Widevine repo of http://go/wvgerrit/50422

This CL adds unit tests to verify that a usage report can have the status
kInactiveUnused.

bug: 79556142
test: unit test code only
Change-Id: I10f71ac2e585ef33727aa8f80d867d80fe156ab8
2018-05-15 13:23:30 -07:00
Rahul Frias
e8c3a4afac Protect sessions from concurrent access.
Locks in earlier releases controlled access to sessions and the list
of sessions for each CdmEngine instance. This guarded against
concurrent access between session management (OpenSession,
CloseSession, etc), periodic timer calls and calls to Decrypt.

The list of sessions and locking was moved to a separate class
CdmSessionMap. This left open the possibility that a session
might be destructed, while being called to decrypt or invoked through the
timer. An attempt was made to add per-session locks in b/73781703
but this was found insufficient.

Per-session locks will be introduced in a future changelist, but for
now the coarser locks will be reintroduced.

Bug: 73781703
Bug: 79158083
Bug: 79262108
Bug: 79436509

Test: WV unit/integration tests, GTS GtsMediaTestCases tests and
      24 hours of continuous Netflix playback.

Change-Id: I30a3ede340192370dfe5c92c01b1c76df16b7123
2018-05-15 11:51:17 -07:00
Rahul Frias
dcab2b1355 Address concurrency failures between calls to decrypt and periodic timer
[ http://go/wvgerrit/50341 ]

The shared_ptr implementation was taken from a google3 implementation.
Updates to the reference counter needed to be atomic and were
platform dependent in the original code. These were not carried
over to this codebase. Race conditions between calls to decrypt and
the periodic timer, led to incorrect reference count values.
CdmSession objects were then destructed while references to
them still existed. Segfaults occurred when they were referenced.

Bug: 79431096

Test: WV unit/integration tests, GTS GtsMediaTestCases tests and
      24 hours of continuous Netflix playback.

Change-Id: I6008ddba869efcc58972e5ea8644a204f91410ab
2018-05-14 16:38:38 -07:00
Rahul Frias
0163607fa3 Revert of "Prevent race conditions between decrypt and close session"
[ Original CL http://ag/3890635,
  Merge of http://go/wvgerrit/50340 ]

The original fix was not sufficient to address all race conditions.
A subsequent CL will address them.

Bug: 73781703
Bug: 79158083
Bug: 79262108
Test: WV unit/integration tests, GTS GtsMediaTestCases tests and
      24 hours of continuous Netflix playback.

Change-Id: I869c22a250e2467b3d49935815e4157dc012fff5
2018-05-14 15:45:54 -07:00
Rahul Frias
0747894a52 Merge "Address Cdm Extended Duration Test failures" into pi-dev am: aa536ec97f
am: 410f28186b

Change-Id: Iab78f1b96044629b73ee71278707dd4e5097fcab
2018-05-14 15:43:49 -07:00
Rahul Frias
410f28186b Merge "Address Cdm Extended Duration Test failures" into pi-dev
am: aa536ec97f

Change-Id: Iafc7887aa52174cd21d4fa7d4e80e24dd8211a21
2018-05-14 15:39:22 -07:00