Commit Graph

87 Commits

Author SHA1 Message Date
Rahul Frias
a6a99c416f Free EC key in test session destructor
[ Merged from http://go/wvgerrit/148030 ]

Bug: 224375138
Test: GtsMediaDrmTests
Change-Id: Ic1d42756cb1a03fa52d90c5fb0bd496e87a43c65
2022-03-21 14:37:58 -07:00
Rahul Frias
139310fd05 Fix key_control_iv in OEMCrypto tests
[ Merge of http://go/wvgerrit/145989 ]

The key_control_iv field is used with an encrypted KCB.  With v17, the
KCB is in the clear and this field should have a length of 0.  This
updates the tests to set the field correctly.

Bug: 224375138
Test: GtsMediaTestCases on sunfish
Change-Id: I2973bc064705557c878bb1fe943e5fde92977dcc
2022-03-16 01:37:32 -07:00
Kyle Zhang
642965c678 Merge latest oemcrypto-v17 change
No-Typo-Check: Not related to this change.

Bug: 161477208
Change-Id: I99e4780f6855b7045aa0cd5a49c13d2d0d51ed64
2022-01-27 20:07:15 -08:00
John "Juce" Bruce
df23c7da03 Fix errors being hidden by Protobuf warning-disabling
(This is a merge of http://go/wvgerrit/140850.)

This patch fixes a number of minor issues in the codebase (mostly
instances of 0-as-nullptr, but also some member shadowing and a missing
override) that were being hidden by the fact that depending on Protobuf
disables these diagnostics. And which will be unhidden when a later
patch removes that behavior from Protobuf.

Bug: 208304830
Test: x86-64
Change-Id: I4b0b1264748880b3726a6388d589868d898f949e
2022-01-21 01:49:40 +00:00
John W. Bruce
f2457565c0 Output BoringSSL errors in OEMCrypto test to stderr
(This is a merge of http://go/wvgerrit/135033 from the Widevine repo.)

Previously, errors from BoringSSL in OEMCrypto were printed to stdout.
This patch moves them to stderr.

Bug: 202752544
Test: OEMCrypto unit tests
Change-Id: Ifad3e4db40e796e0320863e5a58882822e657a31
2021-10-11 12:23:52 -07:00
John W. Bruce
68187b9f02 Fix -Wshorten-64-to-32 errors in BoringSSL interactions
(This is a merge from the Widevine Repo of http://go/wvgerrit/134310.)

This patch fixes code that would trigger -Wshorten-64-to-32 by
implicitly narrowing a variable from 64 to 32 bits. Most of the time, it
does this by making the implicit conversion explicit. The cause of most
of these is that OpenSSL uses "int" for the length of things rather than
size_t. (While BoringSSL sometimes uses int and sometimes uses size_t.)

One exception is LogBoringSSLError(). We have a couple copies of this
function around, and they varied slightly. This patch brings them all
in-line, which conveniently also removes any code in them that would
deal with integer variables.

GetRandBytes() now takes a size_t and downcasts to BoringSSL's native
int internally, so that callers can pass in a size_t value as they would
expect.

There's also an interesting case in oec_session_util.cpp. Because
BoringSSL and OpenSSL disagree about the width of an error code, we have
to use the "auto" type for a temporary variable that holds an error, in
order to retain compatibility with both.

Bug: 194971260
Test: x86-64
Test: x86-64-openssl
Change-Id: I88bc62b4cda396f8a1eabd1a3cb7d1b03f47a33f
2021-09-27 18:17:04 -07:00
John W. Bruce
d742daf9c7 Validate decryption with entitled keys in OEC tests
(This change is merged from http://go/wvgerrit/124825)

The OEMCrypto tests have tests that verify that entitled keys can be
loaded but not that they can be successfully used for decrypt. This
patch adds a decrypt portion to the existing tests.

As part of this, the existing Session::EncryptCTR() method and portions
of Session::TestDecryptCTR() are lifted to be static functions so they
can be shared across unrelated classes in oec_session_util.cpp.
EncryptCTR() had no dependence on its enclosing class and is unchanged
other than being moved outside the class.

To reduce ambiguity with the new decrypt verification, this patch also
renames EntitledMessage::VerifyEntitlementTestKeys() to the
more-specific EntitledMessage::VerifyKCBs(). Its behavior is unchanged.

Bug: 186782279
Test: x86-64 platform
Test: opk_ta platform
Test: build_and_run_all_unit_tests
Change-Id: I15156882907b0987215087aaf43b4666fedc171a
2021-05-11 12:52:24 -07:00
John W. Bruce
ed17d09c1b Remove asserts from GenerateSimpleSampleDescription()
(This change is merged from http://go/wvgerrit/124824)

GenerateSimpleSampleDescription() only had asserts to check parameters
that only came from other test code, so they weren't testing anything of
use. With the asserts removed, it's no longer necessary to wrap calls to
GenerateSimpleSampleDescription() with ASSERT_NO_FATAL_FAILURE(), which
a lot of callers were already forgetting to do anyway. This also
simplifies a future patch that will generalize the decryption test code
to work with entitlement licenses.

Bug: 186782279
Test: x86-64 platform
Test: build_and_run_all_unit_tests
Change-Id: I987427fdfee4826d77ab95344f9aca8c374b2001
2021-05-11 12:49:22 -07:00
Fred Gylys-Colwell
e51c9fbbb8 Update license comment
Merge from Widevine repo of http://go/wvgerrit/121950

Remove term "Master" from "Widevine Master License Agreement".

Bug: 168562298
Change-Id: I655babf1bc447f4872f6a0f849107262be42df7a
2021-04-12 14:10:08 -07:00
Fred Gylys-Colwell
ef65e86ee2 Modify OEMCrypto unit tests to allow 16.3 or 16.4
Merge from Widevine repo of http://go/wvgerrit/121790

Some unit tests expected OEMCrypto to be the latest ODK version,
but we do not require this for v16.

Bug: 184905579
Change-Id: Iccdbcc0b28587aad79a2a63d8c39a564a47fb585
2021-04-12 14:00:53 -07:00
Fred Gylys-Colwell
6628c7f693 Update OEMCrypto test comments and logs
Merge from Widevine repo of http://go/wvgerrit/121886

This CL merges some changes from branch rvc-dev to sc-dev
that prepared it for merge.

One change is that the unit tests now say they are part of
Android S instead of R.

Bug: 180546871
Change-Id: I2ebbd8f7b8586389ebb75f3743a2dc2ad8caa214
2021-04-12 14:00:53 -07:00
Bharath Chandra Elluru
6b548748b2 Merge oemcrypto buffer overflow tests from cdm
Widevine CLs:
http://go/wvgerrit/112243
http://go/wvgerrit/110563
http://go/wvgerrit/95483
http://go/wvgerrit/107047
http://go/wvgerrit/111123
http://go/wvgerrit/106224
http://go/wvgerrit/106263
http://go/wvgerrit/106223
http://go/wvgerrit/104223
http://go/wvgerrit/108583
http://go/wvgerrit/111403
http://go/wvgerrit/111623
http://go/wvgerrit/106264
http://go/wvgerrit/110483
http://go/wvgerrit/111944
http://go/wvgerrit/108684
http://go/wvgerrit/104183
http://go/wvgerrit/111443
http://go/wvgerrit/111869
http://go/wvgerrit/108843
http://go/wvgerrit/104363
http://go/wvgerrit/104423
http://go/wvgerrit/104263
http://go/wvgerrit/106584
http://go/wvgerrit/105924
http://go/wvgerrit/104524
http://go/wvgerrit/113023

Bug:175401639

Test: We would like to run these tests on pixel devices from master
branch using go/wv-and-dash

Change-Id: Ic4188504af64de9ce79941f75ac6feaf29189a4d
2021-01-11 22:13:16 +00:00
Fred Gylys-Colwell
20bb84ffee Merge recent doc changes for OEMCrypto
This is a cherry pick of recent changes to OEMCrypto and ODK. Most of
these are part of the document migration to doxygen.

See http://go/wvgerrit/106005 and its parents for code reviews.

Bug: 144715340
Bug: 148232693
Bug: 167580674
Change-Id: I658f99c8117b974faed97322d61fac0f382283af
2020-09-15 19:10:53 -07:00
Fred Gylys-Colwell
1106e2e913 Unit test for loading nonce-free offline license am: a615671f48 am: ed900f242b am: 32b318e7c4 am: 38d465b042
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/11677947

Change-Id: I63c865fd7574289061ffe929f2ed03a30c56eac0
2020-06-02 22:26:53 +00:00
Fred Gylys-Colwell
a615671f48 Unit test for loading nonce-free offline license
Merge from Widevine repo of http://go/wvgerrit/100964

The previous nonce-free test used the same session to generate the
request as to load the license. However, it is a realistic use case to
have a new session used for loading the license.

The use case relates to a pre-loaded, shared license.

Test: Ran unit tests on taimen and on v16 ref implementation
Bug: 156853321
Change-Id: Ibc07744a16edcd3952d88d73660a75d0c3e8eeb8
2020-06-02 08:30:34 -07:00
John Bruce
265ba61b5c Merge "OEMCrypto Unit Test Fix: Do Not Derive Keys Immediately" into rvc-dev am: 729723b3d2 am: b349680d3f am: 00792ac231 am: 1c7dab441a
Change-Id: I1bada2a5657eb38a8271d2da2199b145a8966d6c
2020-05-30 00:32:39 +00:00
John W. Bruce
b8e13cec2d OEMCrypto Unit Test Fix: Do Not Derive Keys Immediately
(This is a merge of http://go/wvgerrit/100053.)

The OEMCrypto Unit Tests were previously deriving keys from the session
key as part of loading the test RSA key. This creates an invalid
function call order, since the OEMCrypto session will likely next be
used for actions that need to be done *before* deriving these keys. With
ODKiTEE, which is more strict about this order, all OEMCrypto tests were
failing.

Bug: 156655072
Test: OEMCrypto Unit Tests
Change-Id: Ibfede587da30cfff4a44a5e0687e4199b1430372
2020-05-27 01:19:48 +00:00
Fred Gylys-Colwell
cd4d4f564a Update TimeRollbackPrevention unit test am: 75575418d0 am: 7cd14be01d am: 51cf7e4668 am: 40e2e7fa08
Change-Id: I21b29668ed8a9b39e8a7679ed65281d14587bba3
2020-05-21 23:05:32 +00:00
Fred Gylys-Colwell
75575418d0 Update TimeRollbackPrevention unit test
Merge from Widevine repo of http://go/wvgerrit/100110

The unit test TimeRollbackPrevention was broken for several
reasons. This CL reduces the test to its most basic functionality and
updates it to be compatible with a v16 oemcrypto.

This CL also adjusts the fake clock used by the buildbot to fake
sleeping backwards, so that the TimeRollbackPrevention test can also
be run on the buildbot.

Bug: 155773482
Bug: 79422351
Test: unit tests on buildbot, and on flame w/v16 modmock
Change-Id: I3027018b17b738281989e63ae6b0729757217d05
2020-05-20 13:47:28 -07:00
Fred Gylys-Colwell
efb0452042 Replace OEMCrypto_LoadDeviceRSAKey with OEMCrypto_LoadDRMPrivateKey am: 56b836bda3 am: bb42e9bd41 am: 6b56c1c5ec am: b3657d0a6e
Change-Id: I0dc2f37ce34771592cdd0af4ce905a896a88fccd
2020-03-29 20:13:22 +00:00
Fred Gylys-Colwell
56b836bda3 Replace OEMCrypto_LoadDeviceRSAKey with OEMCrypto_LoadDRMPrivateKey
Merge from Widevine repo of http://go/wvgerrit/96783

This CL updates the reference code, unit tests, and adapter to use the
new v16 function OEMCrypto_LoadDRMPrivateKey. This is just an API
change to allow ECC support in the future. The reference code does not
yet support ECC certificates, and the CDM code assumes that all
certificates have an RSA key.

Bug: 152558018
Test: unit tests on taimen and w/v16 mod mock.
Change-Id: I0793b416513b81b3d74849f0b58dbdc91f075ac6
2020-03-29 10:43:54 -07:00
Fred Gylys-Colwell
9265752bce Add unit test for preloaded license am: ca404aae6f am: ab82b4b78f am: d8ea3672c4 am: 3cdcf12c20
Change-Id: I0ed6e8f8d26afa3e7eb9e81fcc06e480ff958803
2020-03-27 20:01:37 +00:00
Fred Gylys-Colwell
ca404aae6f Add unit test for preloaded license
Merge from Widevine repo of http://go/wvgerrit/96508

This adds a unit test for to verify that a preloaded license may be
loaded into OEMCrypto. A preloaded license is a license that does not
have a nonce, and for which there is no license request. This is used
in CAS and ATSC.

I also updated the test version string to
OEMCrypto unit tests for API 16.2. Tests last updated 2020-03-27

Bug: 144105097
Test: ran oemcrypto unit tests on taimen and with v16 modmock.
Change-Id: I6a4926917f36a084d15defa7b908d067612c4dcf
2020-03-26 15:38:38 -07:00
John W. Bruce
d21d70f533 Restore OpenSSL Compatibility
(This is a merge of http://go/wvgerrit/96226.)

This patch does a number of different things in order to re-enable the
CDM to use OpenSSL 1.1.0+ out of the box, instead of just BoringSSL:

* To support https://cryptography.io/, BoringSSL has reimplemented just
  enough of the OpenSSL PKCS7 API that we can fulfill our purposes with
  code that works on either library. This patch replaces code in
  privacy_crypto_boringssl.cpp and oec_session_util.cpp that was only
  compatible with BoringSSL with code that also works in OpenSSL.

* Replaces code in oec_session_util.cpp that used the deprecated OpenSSL
  1.0.0 API with OpenSSL 1.1.0-compatible code. This code previously
  worked on BoringSSL because they have not yet removed the OpenSSL
  1.0.0 functions, even though they also implemented the 1.1.0 API.

* Replaces openssl/mem.h (which does not work in OpenSSL 1.1.0 and
  higher) with openssl/crypto.h. (which works in all OpenSSL and
  BoringSSL releases) This does not require any function code changes.

* The OID-comparison code in privacy_crypto_boringssl.cpp was using
  BoringSSL-exclusive functions to convert OBJ-format OIDs to text.
  Conversion functions that work on either library exist. However, the
  new code uses a different technique instead, pre-converting the
  passed-in OID to OBJ format. This allows it to be compared to the
  certificate directly, avoiding converting every certificate extension
  OID to text.

* Allows the selection of "openssl" as the privacy_crypto_impl and adds
  a variable to configure OpenSSL. More will follow in future patches
  as more configurations of OpenSSL are supported.

Bug: 140053043
Test: CE CDM Unit Tests
Test: CE CDM Unit Tests w/ the x86-64 Platform Reconfigured to OpenSSL
Test: Android Unit Tests
Change-Id: I57cebbbfb59e0bcab85b589b98fb9ffd18885415
2020-03-26 13:20:15 -07:00
Fred Gylys-Colwell
037918aa49 Update tests for license release
Merge from Widevine repo of http://go/wvgerrit/95403

This updates the test code CreateDefaultResponse to make sure that
license releases do not have a core message, and that the key control
block is correctly set for renewals.

Also, the unit test OEMCryptoUsageTableTest.TimingTest is changed to
only a license release when the license is inactive. If the license is
still active, then the license is loaded before generating a usage
report.

Test: Ran full unit tests
Bug: 151092673
Change-Id: I7c01fd17f9b66e88ab3c57aa0f3d40740f13507c
2020-03-09 20:11:23 -07:00
Fred Gylys-Colwell
c5b7a01ab5 Update ODK Library and add license release unit test
Merge from Widevine repo of two CLs.

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

A license release should not have a core message. This CL adjusts the
existing unit tests to verify this. There is also a new unit test called
SecureStop that explicitly tests sending a secure stop in a new
session without first loading the license.

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

This CL has the following changes copied from google3:
http://cr/298871728 Remove odk_static_assert for Message size temporarily
http://cr/298755935 Fix a compiling error during macro expansion
http://cr/298481745 Add missing header for android
http://cr/298448142 Fix odk_test gyp file
http://cr/298419641 Remove header from Android.bp
http://cr/298402053 Separate sizeOf(args) bytes in fuzz tests
http://cr/297730316 No core messages for license release
http://cr/297714346 Add copybara_test and piper_sot_to_gerrit
http://cr/297636713 Adding some comments around boolean conversion code
http://cr/297420679 Autofuzzer when ran with address sanitizer ...
http://cr/296513584 Minor fix with fuzzing odk clock values
http://cr/296322024 Fixing errors in code with how request ...
http://cr/296313159 Fuzzing ODK clock values by setting aside ...
http://cr/295763207 Add more odk tests and move helper functions to test helper
http://cr/294524098 Adding a Build Rule for ODK_KDO_Fuzzer and updating
http://cr/294492213 Address a few review comments of ODK
http://cr/293674368 odk_fuzz: add TODOs & comments
http://cr/293492806 Fix spelling

Bug: 150243585
Bug: 150020278
Bug: 150095506
Bug: 147297226
Bug: 148290294
Bug: 148907684
Bug: 150608451
Test: unit tests
Change-Id: I25fd406f29f4eba40f5cb27e9a1317dce4ffc2f5
2020-03-05 19:06:31 +00:00
Fred Gylys-Colwell
2446b85322 Remove unused parameters
Merge from Widevine repo of http://go/wvgerrit/94043

Remove some unused parameters from test code. These had been
generating compiler warnings.

Bug: 149592532
Test: built and ran unit tests on crosshatch
Change-Id: If1325edc3418f77d620ce3765496ef17156bc624
2020-02-15 12:15:06 -08:00
Fred Gylys-Colwell
db2050dff1 OEMCrypto v16.2
Merge from Widevine repo of http://go/wvgerrit/93404

This is the unit tests, reference code, and documentation for
OEMCrypto v16.2. Backwards compatibility should work for a v15
OEMCrypto.

Some review comments will be addressed in future CLs.

Bug: 141247171
Test: Unit tests
Test: Media GTS tests on bonito
Change-Id: I9d427c07580e180c0a4cfdc4a68f538d351c0ddd
2020-02-04 20:33:16 -08:00
Fred Gylys-Colwell
7665614b2e OEMCrypto v16.1
Merge of http://go/wvgerrit/93404

This CL updates the Widevine CDM to support OEMCrypto v16.1

Test: Tested in 16.2 CL
Bug: 141247171
Change-Id: I69bd993500f6fb63bf6010c8b0250dc7acc3d71b
2020-02-03 14:45:32 -08:00
Fred Gylys-Colwell
843c8ab83a Merge "Fix OEMCrypto UsageTableTest.GenerateReportWrongPST" into qt-dev am: 127f87770c am: e4eef77a01
am: 8a104ddc65

Change-Id: Ifbb57ea1111add3c018a6c115f9337c5594d6b79
2019-05-14 16:56:10 -07:00
TreeHugger Robot
127f87770c Merge "Fix OEMCrypto UsageTableTest.GenerateReportWrongPST" into qt-dev 2019-05-14 22:01:11 +00:00
Fred Gylys-Colwell
cb12eacfc4 Merge "Update unit tests for v15.2" into qt-dev am: 2f79fe2773
am: d0b62c1b8d

Change-Id: I537e6e9c0161084cc0b12a32779fa52c275421cd
2019-05-08 11:38:46 -07:00
Fred Gylys-Colwell
2f79fe2773 Merge "Update unit tests for v15.2" into qt-dev 2019-05-08 17:36:36 +00:00
Fred Gylys-Colwell
a35722f358 Test MAC signature after license reload am: 407d39699b
am: a3d5e7be6a

Change-Id: Ia110288e7d06dcbe7aaebe6c54e42a64402f1a4f
2019-05-08 00:53:00 -07:00
Fred Gylys-Colwell
96431e9c2d Update unit tests for v15.2
Merge from Widevine repo of http://go/wvgerrit/77609

For v15.2 we require that nonces not collide across sessions and there are
restrictions placed on the mac key's IV in LoadKeys.

Test: ran unit tests on reference code

Bug: 131325434
Bug: 131326334

Change-Id: I1bb01c30d8c15d66d762c28b57d7700c44daa835
2019-05-07 22:50:06 -07:00
Fred Gylys-Colwell
407d39699b Test MAC signature after license reload
Merge from Widevine repo of http://go/wvgerrit/78143

This verifies that the correct mac keys are used to sign a message when
generating a usage report or secure stop.

Test: unit tests on ref code and taimen
Bug: 111261264
Change-Id: I7d56a6ff0aae68a5554f7ce84d467697d1f9997b
2019-05-07 19:09:53 +00:00
Fred Gylys-Colwell
d4801531e4 Fix OEMCrypto UsageTableTest.GenerateReportWrongPST
Merge from Widevine repo of http://go/wvgerrit/78063

This test incorrectly asserted a buffer size.

Bug: 131864150
Test: Unit tests ran on taimen.
Change-Id: If53fdd4cce9d6b3dfa85f50a3dbc08c99bceebfb
2019-05-06 11:41:21 -07:00
John W. Bruce
5ea429ee2b Don't Use StringStream When It's Overkill
(This is a merge of http://go/wvgerrit/76063)

Now that we have C++11, many places that do string formatting or parsing
can be replaced with std::to_string() or one of the std::sto*() family
of functions. This patch updates places that do simple stringifying or
parsing to use these functions. Some parts of the code are left
untouched because they were using StringStream to do more complex
actions, such as constructing more complex output or checking the status
of the parsing.

Bug: 120599938
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I482dc234ecd7c6014fa9b6874387ff51e04b772f
2019-04-17 17:46:31 -07:00
Fred Gylys-Colwell
5f7803dedd Add comments to unit tests
Merge from Widevine repo of http://go/wvgerrit/73383

Partners have been requesting more explanation for what each test is
doing.  This is an attempt to clarify some of the tests.

Bug: 119640588
Test: unit tests
Change-Id: I270203b4e8fa7e65abb55297788e4d55856e7dcd
2019-03-03 21:16:55 -08:00
John W. Bruce
777abaef01 Add some platform abstractions.
(This is a merge of http://go/wvgerrit/70303)

This adds a platform.h file to abstract some of the differences
between Windows and POSIX platforms.  This includes ntohl, setenv,
and ssize_t.

Bug: 122953649
Test: Android Unit Tests
Change-Id: I3235f3f284b53d24d7365ff3f4a06dcd9b403697
2019-01-16 11:06:55 -08:00
Rahul Frias
3c350b677f Use vec.data() instead of &vec[0].
[ Merge of http://go/wvgerrit/67984 ]

Getting the address of the first element is invalid when the size is
0.  Calling data() is valid when the size is zero so long as we
don't use the resulting pointer.  This is important when we pass the
pointer to low-level functions like memcpy.

Also, MSVC is stricter about this and doesn't allow indexing the 0-th
element when it is empty.  But GCC/Clang seem to be fine with it so
long as the object isn't used.

Test: WV unit/integration tests

Change-Id: Ic5d11da41dd3a185a63f86a6ea91e9b954fd699a
2018-12-13 12:05:56 -08:00
Srujan Gaddam
b7e4b56934 Update OEMCrypto calls to use substrings (addendum)
Merge from master branch of Widevine repo of http://go/wvgerrit/66076
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64743

http://go/wvgerrit/64083 had some refactorings that weren't completely
accurate or slightly changed the meaning of some tests. This CL is an
addendum to that CL to fix those refactorings.

Test: tested as part of http://go/ag/5501993
Bug: 115874964

Change-Id: I37766a4c34de737eb9ca94ef781805435ee30dfd
2018-11-16 17:14:00 -08:00
Srujan Gaddam
e6439255ba Update OEMCrypto calls to use substrings
Merge from master branch of Widevine repo of http://go/wvgerrit/66073
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64083

As part of the update to v15, LoadKeys, RefreshKeys, and
LoadEntitledContentKeys should all use offsets and lengths into the
message rather than a pointer for its parameters. The CDM, tests,
adapters, and OEMCrypto implementations are changed to reflect this.

Test: tested as part of http://go/ag/5501993
Bug: 115874964

Change-Id: I981fa322dec7c565066fd163ca5775dbff71fccf
2018-11-16 17:14:00 -08:00
Fred Gylys-Colwell
ef067572bc Remove error OEMCrypto_KEY_NOT_LOADED
Merge from master branch of Widevine repo of http://go/wvgerrit/66066
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63628

The error code OEMCrypto_KEY_NOT_LOADED is redundant with
OEMCrypto_ERROR_NO_CONTENT_KEY and OEMCrypto_KEY_NOT_ENTITLED.  The
function LoadEntitledContentKey should return KEY_NOT_ENTITLED if it
does not find the corresponding entitlement key in its key table.  All
other functions that do not find a key id in the key table should
return OEMCrypto_ERROR_NO_CONTENT_KEY.  This includes QueryKeyControl,
SelectKey, and RefreshKeys.

Test: unit tests
Test: tested as part of http://go/ag/5501993
Bug: 115574797
Change-Id: Ida2111f32e331b99f3f0c77fa404a42654d0870c
2018-11-16 17:09:32 -08:00
Fred Gylys-Colwell
f2edb8f2dd Update API version to 15
Merge from master branch of Widevine repo of http://go/wvgerrit/66064
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/63063

This is in the reference code for OEMCrypto, and in the unit tetss.

Bug: 111939411
Test: unit tests
Test: tested as part of http://go/ag/5501993

Change-Id: I2cc2e7028f62d1c375eb632452eef94566fa9ae3
2018-11-16 15:38:45 -08:00
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
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
Fred Gylys-Colwell
98532d313b Use 128 bit AES for key control block
Merge from Widevine repo of http://go/wvgerrit/49805

This aligns the oemcrypto reference code and unit tests to match the
API design doc: http://go/oemcrypto

bug: 79375509
test: unit tests pass
Change-Id: I13761a7384a17e99d88e61aaf80b4a22941fd172
2018-05-08 14:01:45 -07:00
Srujan Gaddam
73c3007c24 Address offline playback with rollbacked time
Merge from http://go/wvgerrit/47640

Test: unit/integration tests

Bug: b/62058202

The usage table keeps track of license duration by using the current
system time. However, if a user were to rollback the time, they can
effectively continue offline playback indefinitely. This changes the way
we compute time by computing offsets by which the user rollbacked the
time and adding it to the current time. This change also includes a test
to verify protection against rollback for usage entries that is only run
when the user is root.

Change-Id: I97c430e1443747b0f9759ae5390b8f5d06bdebf1
2018-04-23 15:44:26 -07:00
Fred Gylys-Colwell
1a25cbdad6 Update Copyright
Merge from Widevine repo of http://go/wvgerrit/47860

This CL updates the copyright notice to indicate that files
shared with partners are shared under the Widevine Master
License Agreement.

bug: 77926774
test: comment change only
Change-Id: I0423668111578b80fb39a932d763df2827e2dfc3
2018-04-16 16:38:05 -07:00