Commit Graph

612 Commits

Author SHA1 Message Date
Alex Dale
774c4667fc Allow ProvisioningHolder to return load status.
[ Merge of http://go/wvgerrit/219452 ]

Allow ProvisioningHolder to load the a provisioning response
without triggering test failure if the CDM rejects the response.
This is to allow testing cases where we expect the CDM to
reject the response.

VIC-specific: No specialized provisioning dump call.

Bug: 391469176
Change-Id: Ief1791f23035fe9b554f8e82e049343aa7e97362
2025-04-18 12:44:07 -07:00
Alex Dale
ca7be366df Refactored ProvisioningHolder to separate operations.
[ Merge of http://go/wvgerrit/219451 ]

An upcoming provisioning test requires the ability to perform
generate, fetch and load operations separately (similar to the
current behavior of LicenseHolder).

This CL separates the 3 operations into different methods and
documents the pre/post conditions of each.  The original API
is maintained for backwards compatibility.

VIC-specific: Excludes Golden-data refactoring and merges main
change (216510) and typo fix (216570).

Bug: 391469176
Test: run_x86_64_tests
Change-Id: Iec83dfce9d235eedf04ed32d98f7700de4bade12
2025-04-18 12:43:28 -07:00
Alex Dale
3d5bdaeb77 Retry provisioning and license requests on 502 errors
[ Merge of http://go/wvgerrit/219370 ]

Work around the server problem.

Bug: 345333545
Change-Id: Ie1b0021f545c77d61bb2363494239f4fe000f3d5
2025-04-18 12:39:24 -07:00
Rahul Frias
b06655fc59 Merge changes I34aab2b5,I0874b965 into vic-widevine-dev
* changes:
  Skip ProvisioningStableSpoidTest if L3
  Correct CertificateProvisioningTests failures
2024-11-05 18:05:14 +00:00
Alex Dale
380148e3e6 Fixed HLS parsing of bad content IDs.
[ Merge of http://go/wvgerrit/207457 ]

When parsing Widevine's HLS key data, the key details are contained
in a data URI in the HLS X-KEY URI field.  The data of the URI is a
base64 encoded JSON object, containing the information required to
generate the license request.  The "content_id" field of the JSON
object is expected to be a base64 encoded; however, the HLS parser
did not verify that the decoding was successful.  In the event that
was not successful, the decoder would return an empty string, which
the parser would attempt to access the first element by reference
which may be a null reference.

In C++, creating a reference from a null point (without actually
accessing the value) is undefined; however most C++ implemenations
will not cause a segment fault; but it is not guarenteed by the
standard.

This change checks if the decoding was successful before attempting
to store the decoded "content_id" value.

A unit test is added to ensure that a parser fails gracefully.

Bug: 356210640
Test: HlsParseTest.BadHlsData_InvalidContentId
Change-Id: Ie2ad42d69953258659178dd1464d830b2723c6c7
2024-10-01 21:14:19 -07:00
Rahul Frias
a5a02ac1fb Skip ProvisioningStableSpoidTest if L3
[ Merge of http://go/wvgerrit/207790 ]

SPOID is only expected to be stable for L1

Bug: 339917270
Test: CoreIntegrationTest.ProvisioningStableSpoidTest
Change-Id: I34aab2b5f873b643e2cfb3c7ad8c996f2134a48b
2024-09-30 12:54:41 -07:00
Rahul Frias
92d0e81143 Correct CertificateProvisioningTests failures
[ Merge of http://go/wvgerrit/207720 ]

CertificateProvisioningTests were failing because the expected
filename "cert.bin" was not met. The file path being passed in
on android was "/data/vendor/mediadrm/IDM0/L[1|3]/cert.bin"

Bug: 339917270
Test: CertificateProvisioningTests/CertificateProvisioningTests.ProvisioningResponseSuccess/Keybox
Test: CertificateProvisioningTests/CertificateProvisioningTests.ProvisioningResponseSuccess/OemCert
Test: CertificateProvisioningTests/CertificateProvisioningTests.ProvisioningResponseSuccess/DrmCertificateReprovisioning
Change-Id: I0874b9652d54848d58c202fe197af0da0616e8cd
2024-09-30 09:41:56 -07:00
Rahul Frias
d27b58202e Merge changes I58806276,Ic112b459 into vic-widevine-dev
* changes:
  Clang format long line
  Update test data for entitled license test
2024-09-09 17:12:40 +00:00
Vicky Min
e642847b81 Update license holder to handle Android license releases
Since the CDM engine handles license releases for CE CDM and Android
differently, this changes the license release test to accomodate for
that.

Bug: 348712053
Change-Id: Ibc768e5d5c31ef8c2226b63dc622ffabfc0591fe
2024-09-04 19:33:16 +00:00
Fred Gylys-Colwell
135d6c608d Update test data for entitled license test
A new set of license data was created on UAT so that we
could have keys that match those in the license returned by
a License SDK and by those generated by UAT.

It should be more clear now which data is just made up, and
which data has to match some golden values based on the made
up data.

Bug: 338323091
Test: WVTS
Change-Id: Ic112b4594afb99c6f43e011f59ee7592d4809189
2024-08-23 23:26:28 -07:00
Alex Dale
b282ec92b6 Improved SystemIdExtractor's opened/closed session behavior.
[ Merge of http://go/wvgerrit/201577 ]
[ Cherry-pick of http://ag/28133919 ]

VIC specific: No DRM reprovisioning support

The SystemIdExtractor did not properly define behavior when working
with opened/closed CryptoSessions.  Due to the CryptoSession's class
dual role of being both a session and a general handle into the
crypto engine, small bugs relying on undefined behavior which happened
to return expected output allowed tests to pass.

This CL makes the following changes:
1) Have SystemIdExtractor verify caller expectations when session is
   open.
2) Improved SystemIdExtractor to operate when CryptoSession is opened
   or closed.
3) Updates several SystemIdExtractorTest cases to better test defined
   behavior without relying on undefined behavior.
4) Better code comments; hopefully some which will help prevent future
   misuse of the internal APIs.

Test: system_id_extractor_unittest on Oriole
Test: WVTS on oriole
Bug: 329713288
Change-Id: I65518fe62f43e8060ea752852eb08a3d7132e2a0
2024-07-02 14:24:37 -07:00
Vicky Min
df171c9d94 Fix clear lead integration tests
The original clear lead integration tests weren't following the flow of
the original bug because there was only one sample, so
DecryptMultipleSamples wasn't being called in the same way. This should
fix this.

Bug: 320785945
Merged from https://widevine-internal-review.googlesource.com/198137
(cherry picked from commit 4141e271d44c32da88dc0f02a0173fae0b45ead9)

Change-Id: Ia70e3fd78381d8d34261b95931fdb303f77f73fd
2024-06-02 07:06:03 +00:00
Rahul Frias
0500d27ce5 Fix LicenseRenewalSpecifiedServer for SDK servers
[ Merge of http://go/wvgerrit/197972 ]

The test only needs to verify that the license has a renewal
server url. It does not need to fetch a renewal from that url.

bug: 338103523
Change-Id: I1513f8692089c3f51a53ffd6ecb62348702b8fb8
2024-05-30 10:48:53 -07:00
Fred Gylys-Colwell
1f3c38d6a3 Update request url
The test server for UAT and for the SDKs now accept the same
url format for renewals.

Bug: 328763985
Change-Id: I1a58412047735efa26da7986bf19fa9a7fbaf374
2024-05-10 15:03:17 -07:00
Vicky Min
d05d3738b4 Integration tests to verify clear lead content plays successfully
Also added a unit test to verify that decryption without a license fails
with the correct error code. Also changed comment types for policy
integration tests and core integration tests to be picked up by Doxygen.

Bug: 320785945
Merged from https://widevine-internal-review.googlesource.com/194910

Change-Id: Ibdb70683003bb430dde9b4a1bd9fc9839bace342
2024-03-28 14:09:01 -07:00
Treehugger Robot
24027c5ebf Merge "Quit test setup when test is skipped" into main 2024-03-26 23:00:40 +00:00
Rahul Frias
ee77a96d74 Merge changes I55b1eb04,I839db69a,I43e845b8,I56b6d301,Ia59bfacf, ... into main
* changes:
  Unit tests for forbidden RSA key usage
  Add DRM reprovisioning request generation
  Correct copyright header
  Fix bcc length for printing
  Update ODK version to 18.4
  Adjust skipping tests when provisioning skipped
  Change test storage to use protobuf
  Remove WvCdmEnginePreProvTestStaging
  Rename and clarify Drm Reprovisioning token types
2024-03-26 06:09:26 +00:00
Fred Gylys-Colwell
202350959d Quit test setup when test is skipped
The SetUp for child classes do not automatically quit when
the parent SetUp is skipped.

Bug: 305093063
Change-Id: I606a949ef0e94fa87a97268856b7f2d8b9135ebe
2024-03-21 16:58:05 -07:00
Vicky Min
c001e2f5a4 Skip License Release tests when there is no usage table
Bug: 330364107
Merged from https://widevine-internal-review.googlesource.com/194574

Change-Id: I25db60e239b157d736d89506280c3d218215fb6f
2024-03-21 11:46:42 -07:00
Cong Lin
5e186dcfa6 Fix bcc length for printing
[ Merge of http://go/wvgerrit/194310 ]

Resize bcc to the correct length to eliminate the trailing zeros.

Bug: 330645490
Test: core unit tests

Change-Id: I56b6d30120735a4d7a0f39f29a9f255bd2d2d18c
2024-03-20 21:41:15 -07:00
Fred Gylys-Colwell
38243aca4c Adjust skipping tests when provisioning skipped
[ Merge of http://go/wvgerrit/194254 ]

For some platforms, we cannot provision. In this case, any
test that needs provisioning is skipped. However, when a
test is skipped in a subroutine, the rest of SetUp is still
run. Any failures in SetUp will cause the test to be marked
as a failure.

This CL duplicates the check for skipping the test in SetUp
and in TearDown.

Bug: 329467151
Test: WV and unit/integration tests

Change-Id: I0087b12a3f26b52ecf62bf7b0e7bcf4fa2c6c763
2024-03-20 14:55:42 -07:00
Jacob Trimble
428586b0eb Change test storage to use protobuf
[ Merge of http://go/wvgerrit/193190 ]

This changes the persistent test storage to use protobufs instead of
manual parsing.  This simplifies the code but makes the files less
"human readable".  Files can be read using 'gqui' if needed.

Bug: 312529037
Test: unit/integration tests
Change-Id: I1b025eac96458c0061e0883e1e4fd05484842ff2
2024-03-20 13:59:14 -07:00
Fred Gylys-Colwell
d3b869c0ab Remove WvCdmEnginePreProvTestStaging
[ Merge of http://go/wvgerrit/194370 ]

This test explicitly provisions against the staging server,
which we do not require from partners.

Bug: 329293570
Test: WV unit/integration tests

Change-Id: Id88840f188ec99b386837d83f69844b0990594a9
2024-03-20 13:30:23 -07:00
Geoffrey Alexander
e9e4b76817 Rename and clarify Drm Reprovisioning token types
[ Merge of http://go/wvgerrit/194374 ]

Renames and adds clarifying comments to Drm Reprovisioning token types.
All provisioning methods can be forced to reprovision by apps which can
cause reprovisioning to be an overloaded term. Renaming token types
used by the Drm Reprovisioning method to more clearly state they are
used for Drm Certificate Reprovisioning should help to avoid confusion.
This change also adds comments to help clarify when and where Drm
Reprovisioning is used as a provisioning type.

Bug: b/305093063
Test: WVTS

* Added dependency to dynamic perf tests to fix missing header build
  error.

Change-Id: I158eb5672ad9e655a60bc68e0f4f2f7a0d464b4e
2024-03-20 11:15:58 -07:00
Rahul Frias
7cc19077ca Merge "Add DRM reprovisioning request generation" into main 2024-03-20 17:24:36 +00:00
Rahul Frias
af2ffca5fa Add DRM reprovisioning request generation
[ Merge of http://go/wvgerrit/192010 ]

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: I9a0ecf95e27213b046f03baa0781fb164179323b
2024-03-15 10:22:35 -07:00
Alex Dale
b1fad7f4cb Reset crypto session pointers on RemoveKeys.
[ Merge of http://go/wvgerrit/189590 ]
[ Cherry-pick of http://ag/26541307 ]

The CDM session shares its CryptoSession instance with a few additional
member objects (CdmLicense and PolicyEngine).  When the CDM session's
crypto session is reset, it must also reset the CdmLicense and
PolicyEngine otherwise, a potential stale pointer reference may occur.

Test: request_license_test on Oriole
Test: run_x86_64_tests
Bug: 311239278
Change-Id: Ie175513ae652dcd96e12e5e1def574a8a56d5863
2024-03-14 00:19:25 -07:00
Robert Shih
fc8d793682 Fix certificate_provisioning_unittest after KDF change
KDF change: ag/26339839

Bug: 299527712
Change-Id: Ibfff3c13b10615e71f60fc69a811a3119881ea80
2024-02-23 10:41:49 -08:00
Ian Benz
6d56eed754 Fix oemcrypto-v19 issues identified by Coverity
Change-Id: Idd79f02337640047979f5a41dd922d14c78c3b2e
2024-02-22 17:13:42 -08:00
Matt Feddersen
c36826607e Add CDM integration test for MoveUsageEntry bug
Test: GTEST_FILTER="*PIG*Defrag*" ./jenkins/opk_ta
Bug: 307750348

Change-Id: I5cc1ffb32311d6e46a956e11fc400b6f9510e6d6
2024-02-22 14:34:00 -08:00
Vicky Min
159aeeecf4 Add integration test for license release
Bug: 258816489
Change-Id: I315eefeb479146de2563aefa75303633341d86f0
2024-02-22 14:33:25 -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
Fred Gylys-Colwell
52b7965226 Skip RenewOnLicenseLoad test when not viable
The feature RenewOnLicenseLoad is not expected to work for an offline
license when the device has no usage table.

Bug: 310498829
Merged from https://widevine-internal-review.googlesource.com/190789

Change-Id: I601c332ed6cd17f9682082ea6acda7e67492b381
2024-02-19 01:03:30 -08:00
Geoffrey Alexander
62ba0133cf Create general certificate provisioning tests
Creates parameterized certificate provisioning tests to prepare for DRM
reprovisioning implementation.
- Create parameterized certificate provisioning test suite.
- Change RETURN_IF_NOT_OPEN macro to call IsOpen instead of checking
  the |open_| variable to make mocking of CryptoSession methods easier.

Bug: b/305093063
Merged from https://widevine-internal-review.googlesource.com/188051

Change-Id: Ic1c344af64073a8ff5626530a0864bfeea90fc6e
2024-02-19 01:01:31 -08:00
Ian Benz
2fabef5bc9 Fix code health issues in the CDM identified by Coverity
Bug: 323331064
Change-Id: Ic87b32c1f7996bd5bb31e99a5fc117c59e94a42c
2024-02-19 01:01:31 -08:00
Ronish Kalia
d0f454d91c [DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
<add g3 doc link>

Bug: 304529413
Test: N/A
Change-Id: I204c137da43a021bcebe316759d1aadaec99fe2a
2024-02-14 14:19:08 +00:00
Fred Gylys-Colwell
f8e8efe1d6 Log more license information
This CL logs some extra policy information from a license.

Bug: 305794515
Bug: 311529487

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

Change-Id: I707afbb01b5467d2551c68a9152ca078815544eb
2024-02-01 13:40:52 -08:00
Alex Dale
95917053f3 Added test printer for std::future_status.
Bug: 297082009
Test: run_zimperium_dev
Change-Id: I65904821de45a7d5bd515388dcaf9cace53a4893
(cherry picked from commit 61dd2b7951ace38a0710909928028144462db165)
2024-02-01 13:40:52 -08:00
Robert Shih
f3e9794a00 Use updated ProvisioningHolder ctor in test
Bug: 323289757
Test: core_integration_test
Change-Id: I1403b4779c434ce23f98fae3e1c061b06fdd4008
2024-02-01 13:40:52 -08:00
Vicky Min
e7017475b7 Use GTEST_SKIP for generic crypto tests
Bug: 251240681
Merged from https://widevine-internal-review.googlesource.com/180050

Change-Id: I5aebcf10f9c8bad5ff21c22bc882040ecd0b390a
2024-02-01 13:40:51 -08:00
Vicky Min
afbbad9aa5 Use GTEST_SKIP for session tests
Bug: 251240681
Merged from https://widevine-internal-review.googlesource.com/180010

Change-Id: I39e5c0365a5e0c2ddf62e6f68426f6baa3ddd1a1
2024-02-01 13:40:50 -08:00
Ian Benz
44e21cb9c2 Remove extra copy operations identified by Coverity
Change-Id: I5e900082d3b17300f3a4ef95561d04c0228aba4f
2024-02-01 13:40:49 -08:00
Alex Dale
8429693866 Added skip test flags to test_base
Flags are to be used in new tests when creating tests that potentially
take a long time to run.  Certain test suites are intended to be quick
and may skip certain long running tests.

New slow tests should check these flags and skip using GTEST_SKIP().

Bug: 311273599
Test: ./build.py x86-64 --debug
Change-Id: I4fc5a026f23f489bf2ad8b8a11dc467f550f0c5e
2024-02-01 13:40:49 -08:00
Alex Dale
151a0e1a76 Include client_version in license requests.
"client_version" is an optional, information field in the protocol for
license requests.  It was requested that the CE CDM includes this
information in the license request.  It does not hurt to include this
information in the Android license requests too.

If, for some reason, the client cannot provide this information, the
request is still sent out as normal.  No reason to prevent an otherwise
valid license request due to a missing optional field.

Note: This field is directly in the LicenseRequest message and not the
ClientIdentification message.

Bug: 253013596
Test: license_unittest
Change-Id: I9dc342301fffdc174122088af39406150b34562e
2024-02-01 13:40:49 -08:00
nihardamar
a4158f16ad Refactor common code in generic_crypto_unittest.cpp
Bug: 220056143

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

Change-Id: I767c57eaa6e24990b83805490cf8b1ec51903324
2024-02-01 13:40:49 -08:00
Fred Gylys-Colwell
1548fe5c98 Fix url parsing in test code
Bug: 300696974
Change-Id: Ic9a158ed0c2e7434d3a4b669a7d301999f29449e
2024-02-01 13:40:49 -08:00
Vicky Min
269d1527cb Filter keybox tests with GTEST_SKIP
Bug: 288404945, 251240681
Merged from https://widevine-internal-review.googlesource.com/183630

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

Change-Id: I9f6a4045f9b554589e25338accecb0d338fad5ce
2024-02-01 13:40:49 -08:00
Vicky Min
a012466156 Use GTEST_SKIP for non keybox devices
Bug: 251240681
Merged from https://widevine-internal-review.googlesource.com/179090

Change-Id: I8c539bfbccde7f22fb732951a95715935935858f
2024-01-30 16:09:41 -08:00