Commit Graph

534 Commits

Author SHA1 Message Date
Alex Dale
2a6154617f Change build info short-length to be based on real length.
[ Cherry-pick of v19 http://go/wvgerrit/219592 ]
[ Merge of http://go/wvgerrit/219554 ]

The original CheckBuildInformation_OutputLengthAPI17 test was
written with the assumption that the estimated length would not
be too much larger than the real length of the build info; however
this is not true for some vendors.

This CL changes the short-buffer length to be based on a real
build info length from a successful call to OEMCrypto.

Bug: 411308060
Change-Id: I6504288ca59d7d41facaadc45adc76a5236826d9
2025-04-21 15:58:05 -07:00
Alex Dale
25380c8832 Updated OEMCrypto JSON build information validation test.
[ Merge of http://go/wvgerrit/219213 ]

Updates CheckJsonBuildInformationAPI18 to better check the contents
of the JSON build information introduced in V18.

Bug: 348498112
Bug: 348497732
Change-Id: I567700eb2ba451a9b10c52159d5fd30d5ae94841
2025-04-18 12:38:18 -07:00
Alex Dale
53b1b0ebc0 Added OEMCrypto build information validation test.
[ Merge of http://go/wvgerrit/219212 ]

This CL adds a new OEMCrypto test CheckBuildInformation*API17 which
ensures that OEMCrypto_BuildInformation() is generating valid build
information.

Bug: 348498112
Bug: 348497732
Change-Id: I22f9878d8ffa05b2b1b1b6ec28718e231438d4a7
Merged-In: I22f9878d8ffa05b2b1b1b6ec28718e231438d4a7
2025-04-18 12:37:53 -07:00
Treehugger Robot
e63b07e850 Merge "Fix key type used in InstallOemPrivateKeyCanBeUsed test" into vic-widevine-dev 2024-11-19 19:05:06 +00:00
Kyle Zhang
d73997bc0b Revert "Limit output buffer size during decrypt fallback"
Revert submission 28914157

Reason for revert: b/372348308

Reverted changes: /q/submissionid:28914157

Change-Id: Ib77156ffe6abed0f8feee5d9f60f24a90e749ff8
2024-10-14 22:28:42 +00:00
Cong Lin
8dc895664a Fix key type used in InstallOemPrivateKeyCanBeUsed test
Merge of https://widevine-internal-review.git.corp.google.com/c/cdm/+/208111

Signature is generated from public_key1, so we should use key_type1 for
signature verification.

Test: opk_ta_p40
Bug: 355011375
Change-Id: If532f3814c7a4b7899d574fc09d3d09b9bb18976
2024-10-08 18:09:22 +00:00
Cong Lin
0ea1b8f8fd Fix test message format for cast receiver
Merge of https://widevine-internal-review.git.corp.google.com/c/cdm/+/206431

Message to be signed by CAST funciton is supposed to be in a certain
format: "constant prefix + SHA1(message)".

Some of our current CAST tests uses random message which break this
specification. This fixes the input message.

Test: Cast tests with run_fake_l1_tests
Bug: 359893908
Change-Id: I6b318d749971d837f13daa7b147313e8e0b1d3d0
2024-09-12 18:07:37 +00:00
John W. Bruce
0b47bd6a50 Increase size of BCC buffer in OEC tests
We are receiving reports from partners in the field that they are
failing the OEMCrypto tests only because the tests assume the BCC will
fit into 5k of memory but their BCC is nearly 8k in size.

This patch increases the buffer to 10k.

Bug: 354834629
Test: x86-64
Merged from https://widevine-internal-review.googlesource.com/204773

Change-Id: I360196518b7651139c003505253d1aed6a0c3907
2024-08-21 05:12:51 +00:00
John W. Bruce
a5bce8122e Limit output buffer size during decrypt fallback
This is based on a patch submitted by Amlogic.

When we're doing decrypt fallback, either in the CDM or the OEMCrypto
tests, we sometimes fall back to a point where we're synthesizing new
samples and/or subsamples for the content being decrypted. When this
happens and the output buffer is clear, we should limit the size of the
output buffer to only the space needed to hold the output.

Previously, we've been passing the entire output buffer to every call.
This can create a problem if the reason for the fallback is a lack of
enough memory to communicate the buffers to the TA, since the output
buffer will remain the same size as the total output. Restricting the
buffer passed to each call to only the space needed by that call will
reduce the memory requirement.

Bug: 354834629
Test: x86-64
Merged from https://widevine-internal-review.googlesource.com/204810

Merged from https://widevine-internal-review.googlesource.com/204953

Change-Id: I412f43d8f88c72072ef1dd5293436bdb58e500b3
2024-08-21 05:11:49 +00:00
John W. Bruce
5a4a8fdede Remove OEMCryptoLicenseTest.RejectCbc1API16
This test should have been removed in v17, when we allowed this pattern
to be used with cbcs. Although we can't start enforcing the correct
behavior until v20 now, we can remove enforcement of the incorrect
behavior.

Bug: 356173926
Merged from https://widevine-internal-review.googlesource.com/204832

Merged from https://widevine-internal-review.googlesource.com/204870

Change-Id: Idc6e3109286daabb83874d52ad3abaff5e14badb
2024-08-21 05:10:09 +00:00
Cong Lin
27bc52e3f4 Filter increment counter tests for L3
Since L3 doesn't support license/prov counters yet.

Test: run_level3_static_tests
Bug: 354822652
Merged from https://widevine-internal-review.googlesource.com/204153

Change-Id: I8d8cff20cb27d38d2b6169ec76f3a20ffda18461
2024-08-07 19:24:32 +00:00
Rahul Frias
5a1b5e2b37 Haystack: Forbid DeriveKeysFromSessionKey after a license is loaded
[ Merge of http://go/wvgerrit/199050 ]

Fix to L3 renewal policy bypass attack:
OEMCrypto_DeriveKeysFromSessionKey cannot be called after a license is
loaded.

Re-generated L3 from oemcrypto-v19 branch.
Also needed to update a few tests because it now returns a different
error code.

Test: tested with
https: //widevine-internal-review.git.corp.google.com/c/cdm/+/196392
Bug: 334154045

Merged from https://widevine-internal-review.googlesource.com/197957

Change-Id: Id0e81123b140085654106e99a05ae2405091f101
2024-06-02 00:17:36 -07:00
Rahul Frias
d926fb31ec Address missing dependencies or executables
[ Merge of http://go/wvgerrit/195850 ]

Since Widevine device builds now include APEX prebuilts,
shared library dependencies for the prebuilts are in
are in /apex/com.google.android.widevine/lib[64] rather
than /system/lib[64] or /vendor/lib[64]. When tests are
run not all the dependencies are present.

These changes include
* Statically linking missing dependencies
* Adding /apex/com.google.android.widevine/lib[64] to
  the shared library path
* Searching for some of the test executables in
  /data/nativetest[64]/vendor/

Bug: 329888778
Bug: 329891889
Bug: 329891175
Bug: 329891049

Test: ./build_and_run_all_unit_tests.sh
Change-Id: I067685cedc7701c4e6502bdac98b53e22b61ad1e
2024-05-10 18:17:10 -07:00
Vicky Min
d53caaade2 Skip entitlement session test that is only supported on CAS devices
Bug: 335398236
Merged from https://widevine-internal-review.googlesource.com/197432
(cherry picked from commit a35129440254c91a261903e499e3f2417425cfb0)
(cherry picked from commit 87d58f48d62dbc4cdbb6c2af1c5a7bda2e209efa)

Change-Id: I7f67dfbc8725cbe0a67d8eda082fa184286d2e84
2024-05-10 18:15:16 -07:00
Vicky Min
1c6ec56725 Update DecryptZeroSizeSubSample test to accept success or error
Bug: 338010108
Merged from https://widevine-internal-review.googlesource.com/198002

Change-Id: I52c72a5c1a287e8556a243b6072faf23ce4bbdad
(cherry picked from commit 8b806d128e450ab0bf9cba17e21b5ed5ff97c277)
2024-05-10 17:24:37 +00:00
Cong Lin
c33960cb7c Fix default cipher mode for CAS unit test
[ Merge of http://go/wvgerrit/194571 ]

Default to OEMCrypto_CipherMode_CBC instead of OEMCrypto_CipherMode_CENC
which is not used by CAS.

Test: CAS unit tests
Bug: 325639114
Bug: 322928572
Merged from https://widevine-internal-review.googlesource.com/193650

Change-Id: I8876d5262643015fb6a322eae6444ef4001d146d
2024-04-16 10:25:38 -07:00
Shawn Willden
688a572357 Remove unnecessary "_external" suffix from libcppbor
Test: Build
Change-Id: I8e4d65bafe9d4b4bbc576c8c9c995bddf0a957a2
2024-04-01 10:24:45 -06:00
Treehugger Robot
c482048f00 Merge "Bump version to 19.1.0 and update OPK changelog" into main 2024-03-28 23:50:08 +00:00
Kyle Zhang
85223cf29a Merge "Lock v19.1 API" into main 2024-03-28 23:26:55 +00:00
Treehugger Robot
2b80494f57 Merge "Add BCC extract tool for BCC uploading test" into main 2024-03-28 23:04:05 +00:00
Matt Feddersen
daa6f5f738 Bump version to 19.1.0 and update OPK changelog
Merged from https://widevine-internal-review.googlesource.com/194911

Change-Id: I366df6f46622d6333e7f77cbef3cb5dc9b1d2710
2024-03-28 14:26:50 -07:00
Matt Feddersen
fb1554a10b Lock v19.1 API
Merged from https://widevine-internal-review.googlesource.com/195130

Change-Id: I44760c19bc1457017ffacdda5f3c40f4a66edccb
2024-03-28 14:04:35 -07:00
Cong Lin
1fd5a8bf37 Add BCC extract tool for BCC uploading test
Extract BCC and build info from oemcrypto, construct BCC uploading
record and dumps it out a JSON file.

The BCC uploader will pick up the output file later.

Bug: 312787974
Change-Id: Ie8ef6a75408e8ef8355b1c0de14532de0ae83732
2024-03-21 13:35:46 -07:00
Rahul Frias
a798692e4e Unit tests for forbidden RSA key usage
[ Partial merge of http://go/wvgerrit/188279 ]

This CL adds unit tests to verify that the following
forbidden uses of an RSA private key do not work:

- ForbidPrepAndSign -- A cast cert key cannot sign a license
  request.
- ForbidUseAsDRMCert -- A cast cert cannot be used with the
  DRM cert's padding scheme and it cannot be used to derive
  keys from a session key.
- *ForbidRSASignatureForDRMKey* -- A DRM cert key cannot be
  used with GenerateRSASignature.
- *OEMCertForbidGenerateRSASignature* -- An OEM cert key
  cannot be used with GenerateRSASignature.

Bug: 251875110
Test: WVTS
Change-Id: I55b1eb04465023352edea55ba4ef532d1cd07231
2024-03-20 23:59:55 -07:00
Rahul Frias
b3157f2328 Add DRM reprovisioning request generation
[ Merge of http://go/wvgerrit/192010 ]

Adding files not merged in ag/26501922

Updates the CDM to add support for DRM reprovisioning request creation.
- Load the baked-in certificate for use as the client token.
- Add functions to build and sign a drm reprovisioning request.
- Update the Rikers L3 OEMCrypto implementation to support signing
  provisioning requests and getting embedded certificate.
- Update client id token to handle DRM reprovisioning.
- Add OEMCrypto function to load the baked-in device certificate in
  Rikers CDMs and stubs for non-Rikers CDMs.
- Add dynamic adapter support for getting embedded device certificate
  only on L3.

Bug: 305093063
Test: WVTS
Change-Id: I839db69a48c1add196f9b56e6ee3812f549f814d
2024-03-20 23:30:26 -07:00
Cong Lin
13dab7dd61 Fix oemcrypto v19 android test and cppbor dependency
OEMCrypto_LoadProvisioning() has changed signature in v19.
Added lipcppbor library and utils to Android tests.

Test: build_all_unit_tests.sh
Bug: 324147162
Change-Id: Id890f97602f684e38d6e42cace9d5dc225958bec
2024-02-22 17:14:19 -08:00
Cong Lin
08fb9ce43b Replace binary cbor object with cppbor builders in oemcrypto tests
Now that the Cppbor library is in place.

Test: opk_ta_p40
Change-Id: I0641e1598d30b178ea2b1feeaf8d4f328be0b23a
2024-02-22 15:16:59 -08:00
Matt Feddersen
4fdeaf41b0 Update lock file for v19.0
Change-Id: I342bcc70f013e421f1a6351612a776f09fb75cc7
2024-02-22 15:16:48 -08:00
Matt Feddersen
fc361dd566 Update "tests last updated" date
Change-Id: Ibe9edd6f66137c8d414b24aedf366e1d0f61bc7e
2024-02-22 15:16:46 -08:00
Fred Gylys-Colwell
34ac11b187 Document OEMCrypto_LoadProvisioningCast
Bug: 314222872
Change-Id: I05031d1eacefceb73931b979ef69e69fdba871a7
2024-02-22 15:16:09 -08:00
Cong Lin
ce2af4e96a Use SignedCsrPayload validator in omecypto provisioning tests
To ensure the ref impl of OEMCrypto_GetDeviceSignedCsrPayload() in OPK
and testbed returns the correct sample format.

Test: opk_ta_p40, run_fake_l1_tests
Bug: 300304834
Change-Id: I6d399774fbaac2e12096cf878d582cd3c1320318
2024-02-22 15:16:00 -08:00
Cong Lin
6c5b9aa271 Device info ref impl to return all required properties
Let the sample device info built by ref implementation include all
required fields to pass device info validation tests.

Test: opk_ta_p40, run_fake_l1_tests
Bug: 307968622
Change-Id: Ib6b7645a1d26347f6992dd3c3bc2f39d4a92b283
2024-02-22 15:13:52 -08:00
Vicky Min
d5157c536d OEMCrypto unit tests for license release
Bug: 295956275
Change-Id: I3c8fc5fcadeae051cc734a64378e473492437c34
2024-02-22 15:10:08 -08:00
Fred Gylys-Colwell
1dc4377cde Move CAS unit tests to the doxygen group cas
This groups the tests together on the devsite.

staged at
https://developers.devsite.corp.google.com/widevine/drm/client/oemcrypto/v19/oemcrypto-test/group/cas

Bug: 298719677
Change-Id: I9d4303ee6397917c0f8ce53c3d591860ac29ad3d
2024-02-22 14:56:29 -08:00
Fred Gylys-Colwell
d4dae79a0e Clean up some test docs
Some tests were not in a doxygen group, so they were not
showing up on the dev site.

Bug: 298719677
Change-Id: Ic86b7999ac7ab324eb40a30023b74897f87d97e5
2024-02-22 14:56:27 -08:00
Cong Lin
64124a7832 Add BCC validation to oemcrypto unit tests
The returned BCC from OEMCrypto_GetBootCertificateChain() can be
validated by unit tests with BccValidator.

Test: run_fake_l1_tests, opk_ta_p40
Bug: 300304834
Bug: 307968622
Change-Id: I6312cb45548f5d8a711c13ea0356d6ec8db51082
2024-02-22 14:46:30 -08:00
Fred Gylys-Colwell
e85a6b9616 Allow entitlement and entitled session to be the same
For DRM, but not for CAS, we allow the entitlement session
and the entitled session to be the same.

Bug: 301462149
Change-Id: Ib830484be8437b1c4ce34500ae912e6c119dcfc3
(cherry picked from commit c1ec1c248d3ca1d3bc414c71cc9222c77d56f043)
2024-02-22 14:31:56 -08:00
Jacob Trimble
4b32cb4b10 Implement license protocol 2.2 for OEMCrypto v19
This updates the code and tests to allow for using license protocol 2.2
when using OEMCrypto v19.

Issue: 80428549
Issue: 121031064
Issue: 232464183
Change-Id: Ib6bb61f86dd310b566227462658530bca5940b88
2024-02-22 14:31:54 -08:00
Vicky Min
5f3bc77c52 Remove RestrictFilter() function and RSAPerformance test
Since we want to migrate to using GTEST_SKIP to skip unit tests instead
of GTEST_FILTER, we can remove the RestrictFilter() function which
filters the tests out using GTEST_FILTER. To do this, the RSAPerformance
test needs to be removed, which is acceptable since no one uses this
test anymore. However, b/299135804 is being used to track a new way to
either execute/track permance.

Bug: 251240681, 299135804
Change-Id: Ife59c468ee127f4c39d3be91707ca38a061b7895
2024-02-22 14:31:29 -08:00
Jacob Trimble
488a4647db Merge OEMCrypto KDF and usage functions
Since KDF functions are only used right before specific functions, this
merges them to simplify internal state within OEMCrypto.

Fixes: 299527712
Change-Id: I426cfcdc102bd73cf65cd809b213da2474f44b34
2024-02-22 14:24:35 -08:00
Vicky Min
b04fda2908 Skip API and time rollback tests with GTEST_SKIP
Bug: 251240681
Change-Id: Ie1cee828f239ddca03ad18aac4139e2e42038df3
2024-02-22 13:54:52 -08:00
Vicky Min
18369730b9 Refactor OEMCrypto_SetDecryptHash
The current implementation of OEMCrypto_SetDecryptHash gives developers
flexibility to use different types of hashes. However, all the
implementations we have seen thus far use crc32. Because of this, crc32
should be sufficient and we can refactor OEMCrypto_SetDecryptHash to
only use the crc32 hash.

Bug: 287706586
Change-Id: I4aaa253b2656dfd9c984f77dfb08fe160b23b47c
2024-02-22 13:52:26 -08:00
Vicky Min
5c718ecb0d Update OEMCrypto to match ODK version updates
Bug: 293154424
Change-Id: Ie22bc48e043f2a88090a2601d5d5c96953e73015
2024-02-22 13:49:25 -08:00
Matt Feddersen
6c7988f8c9 Don't force decrypt count to increase for bypass
Bug: 324261677

Merged from https://widevine-internal-review.googlesource.com/191631

Change-Id: I371fc22ad330402aed0e10cb3cba8641abe00bea
2024-02-19 14:58:49 -08:00
Junfeng Yang
65abd1deb7 Remove the extra call to OEMCrypto_GenerateNonce
The extra call to OEMCrypto_GenerateNonce is not needed. And it would
also lead to failure when the fuzzers are linked with the OPK
serialization layer.

Bug: 324666282
Change-Id: I43941fd5ee1f15f7106e6f0be2b65dce206225cf
2024-02-19 01:15:57 -08:00
Ian Benz
858d66a12c Fix code health issues in OEMCrypto testbed identified by Coverity
Change-Id: I518f753d9d716415d2fe62d3bf54fc9f816f044c
2024-02-19 01:01:48 -08:00
Matt Feddersen
8ac74f2d68 Skip some cast tests if not supported
Merged from https://widevine-internal-review.googlesource.com/190072

Change-Id: I4134b3f090e3f47c80601ae30262d0587808e88a
2024-02-19 01:00:47 -08:00
Robert Shih
7abdd4d0ae Misc formatting fix
Bug: 323289757
Test: TreeHugger
Change-Id: I26ec60855bf19a3ef87ca7bc86f3cb024e393c2b
2024-02-01 13:40:52 -08:00
Fred Gylys-Colwell
c53047bd1b Document huge buffer tests in separate group
Explain how the huge buffer tests work. In particular, state
that we expect that OEMCrypto returns an error on huge
buffers.

Staged here:
https://developers.devsite.corp.google.com/widevine/drm/client/oemcrypto/v18/oemcrypto-test/group/security

Bug: 300645748
Merged from https://widevine-internal-review.googlesource.com/188034

Change-Id: Iba9d652dfe57df6786b0ab60931f02f8ce9b8180
2024-02-01 13:40:52 -08:00
Ian Benz
8e48e36554 Fix uninitialized variable in Provisioning40CastRoundTrip
- Initialize allowed_schemes_ since it is used by CreateDefaultResponse.
- Issue was detected by Coverity.

Change-Id: I368c4773f6316b65196aaa39e23e70717299c570
2024-02-01 13:40:51 -08:00