Commit Graph

7944 Commits

Author SHA1 Message Date
Vicky Min
e5aa80df88 Use GTEST_SKIP for non prov 4.0 tests
Bug: 251240681
Merged from https://widevine-internal-review.googlesource.com/179570

Change-Id: Ieb3e2dc0de3ad33c6407ee4cbcfbd39641b6df4c
2024-02-01 13:40:50 -08:00
Cong Lin
9d97c2bf60 Implement OEMCrypto_LoadCasECMKeys() with TODO WTPIs
Add function body of OEMCrypto_LoadCasECMKeys() with a few TODOs. At the
end, Cas content keys and IVs shall be installed to key slot by WTPIs,
which will be declared in the next CL.

Test: opk_ta
Bug: 241146324
Merged from https://widevine-internal-review.googlesource.com/169378

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

Change-Id: Idf3930ec916e95012067741e46254018fc6e4381
2024-02-01 13:40:50 -08:00
Cong Lin
695b204545 Add test for zero subsample size
Decrypting zero subsample size should return success.

Test: opk_ta, run_fake_l1_tests, run_dynamic_level3
Bug: 279999069
Merged from https://widevine-internal-review.googlesource.com/178138

Change-Id: I3bbad9c63ee72bd6e8ea3b796d231116e59afdc7
2024-02-01 13:40:50 -08:00
Fred Gylys-Colwell
5c05e8a387 Lock OEMCrypto v18.3 API
Bug: 290252845
Merged from https://widevine-internal-review.googlesource.com/178093

Change-Id: I5067df6724b43e9e7d9e67b1a60e0e209f51adbd
2024-02-01 13:40:50 -08:00
Vicky Min
3ee5d69a91 Disable Android Keybox tests for prov 4.0
Bug: 288404945
Merged from https://widevine-internal-review.googlesource.com/178053

Change-Id: I339e7089efaa5082aae348f26ee853d7993fe1d3
2024-02-01 13:40:50 -08:00
Matt Feddersen
2bdea1767f Let OPK call MoveUsageEntry after creation
Changes the OPK session state machine to allow API_MOVEENTRY in
the same circumstances as API_CREATENEWUSAGEENTRY. Adds a test
to trigger the same situation as the linked bug.

The test cases in the bug fail because OEMCrypto_MoveEntry() is
called immediately after OEMCrypto_CreateNewUsageEntry(), but the
session state machine has different filters for the two calls.
Furthermore, OEMCrypto_CreateNewUsageEntry() doesn't change the
state machine, so we should align the two filters to allow
OEMCrypto_MoveEntry() to be called immediately after
OEMCrypto_CreateNewUsageEntry() in all situations where
OEMCrypto_CreateNewUsageEntry() is allowed.

The existing OEMCrypto defrag tests did not catch this edge case
because the test helper functions always do something to modify the
state machine after calling OEMCrypto_CreateNewUsageEntry().

Test: OEMCryptoUsageTableDefragTest.MakeAndMoveEntry
Bug: 286938572

Merged from https://widevine-internal-review.googlesource.com/178013
(cherry picked from commit a87d66ccb7b2fc5f549142e64a7e45531dd95db6)

Change-Id: I8a8465b2b7479effe4055a014bc94b166178a693
2024-02-01 13:40:50 -08:00
Vicky Min
001ede83fd Skip OEMCryptoMemoryLoadUsageTableHeaderForHugeHeader when usage tables
are not supported

Bug: 284922725
Merged from https://widevine-internal-review.googlesource.com/176890

Change-Id: I7d15a85b8a9a25e1261f341b0a583369f84c1fb1
2024-02-01 13:40:50 -08:00
Vicky Min
f47c5bf05a Refactor cast oemcrypto unit tests
Refactor the cast related oemcrypto unit tests into a separate file.

Bug: 253779846
Merged from https://widevine-internal-review.googlesource.com/176930

Change-Id: I937042f786d1cc973e186d76bd276cbc792dfc19
2024-02-01 13:40:50 -08:00
Vicky Min
5317ce1c63 Refactor generic crypto unit tests
Refactor the generic crypto oemcrypto unit tests into a separate file.

Bug: 253779846
Merged from https://widevine-internal-review.googlesource.com/176730

Change-Id: I343ee19ef979a9bedbc528a4533711a137ffb5e9
2024-02-01 13:40:50 -08:00
Vicky Min
51c57c9e11 Small refactoring changes
1) Move some provisioning unit tests into
   oemcrypto_provisioning_test.cpp
2) Remove some test group comments

Bug: 253779846
Merged from https://widevine-internal-review.googlesource.com/176735

Change-Id: I3d02c23b63eb7949fbc6abf60a7dbe32086ef2c9
2024-02-01 13:40:50 -08:00
Matt Feddersen
4fa979b43d Fix CastReceiver unit tests
Test: opk_ta, opk_ta_p40
Bug: 259454969

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

Change-Id: I6cefe7fb85db539ecb066498b51525a04b8bbd51
2024-02-01 13:40:50 -08:00
Matt Feddersen
27421a9161 Add OEMCrypto tests for Cast prov 4 flow
Expected flow, which begins with a device that has already been
provisioned with Prov 4 stage 1:
1. OEMCrypto_InstallOEMPrivateKey()
2. OEMCrypto_GenerateCertificateKeyPair() -> wrapped_csr_priv
3. OEMCrypto_LoadDRMPrivateKey(wrapped_csr_priv)
4. OEMCrypto_PrepAndSignProvisioningRequest() to create a Prov 4
   provisioning request message type with a CAST request in the
   message body
5. Server sends a Prov 2 response. Server side derivation uses CSR keys
   to derive session key, mac keys, and encryption keys.
6. OEMCrypto_DeriveKeysFromSessionKey(), same derivation as server side
7. OEMCrypto_LoadProvisioning(), use derived keys to verify + decrypt

The OEMCrypto_LoadDRMPrivateKey() step can happen before or after the
PrepAndSignProvisioningRequest() call.

Test: tests fail
Bug: 259452440

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

Change-Id: Id5e6737b187339ec93e3d0d03c28e2b379d60747
2024-02-01 13:40:50 -08:00
Cong Lin
5a17d8ebd9 OEMCrypto_ReassociateEntitledKeySession() to check key policy
OEMCrypto_ReassociateEntitledKeySession() should prevent an entitled key
session from being associated to an arbitrary entitlement session.
Validations added/updated in this CL:
1. at least one entitled key is supposed to have matching entitlement
key in the new session;
2. the key control block in the new entitlement key should remain
   unchanged compared to the existing entitlement key.

Updated OPK and ref/testbed implementations.

Test: jenkins/opk_ta, jenkins/run_fake_l1_tests
Bug: 262795590
Merged from https://widevine-internal-review.googlesource.com/171192

Change-Id: I3868aa0d3c5ffb818ed83b9c49313125803939e0
2024-02-01 13:40:49 -08:00
Cong Lin
ab7c39a450 OEMCrypto_ReassociateEntitledKeySession() to verify entitlement key IDs
OEMCrypto_ReassociateEntitledKeySession() should prevent an entitled key
session from being associated to an arbitrary entitlement session. The
target entitlement session is supposed to have all the entitlement keys
that the entitled key session uses.

Updated OPK and ref/testbed implementations.

Test: jenkins/opk_ta entitlement tests
Bug: 262795590
Merged from https://widevine-internal-review.googlesource.com/169774

Change-Id: I4322422f01f7094c3862f33ef3199ff3a44995b0
2024-02-01 13:40:49 -08:00
Ian Benz
b9d857649e Add clang-tidy support for the OPK Linux port
Bug: 256230932
Change-Id: I4f46e285376101ff129c1fca5c80a259c70cc0c7
2024-02-01 13:40:49 -08:00
Ian Benz
44e21cb9c2 Remove extra copy operations identified by Coverity
Change-Id: I5e900082d3b17300f3a4ef95561d04c0228aba4f
2024-02-01 13:40:49 -08:00
Jacob Trimble
a457c2a14d Make IV const in privacy_crypto
Merged from https://widevine-internal-review.googlesource.com/188677

Change-Id: I17346b54259ca1929ef40a8d61aef38969800159
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
Ian Benz
b1ac15d021 Remove unnecessary copies identified by clang-tidy
Change-Id: Iee57c8dfbefdfce6f785f4ae936084f62fc32836
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
Alex Dale
386ca20974 New CE CDM error for device revocation.
Devices may be revoked by the provisioning server resulting in an
error message contained within the provisioning response.  The CDM
core currently returns an error, but the CE CDM would map this to
an kUnexpectedError, which does not provide the information to the
CE client to react.  This situation is not immediately recoverable,
but may provide certain apps to use a different DRM plugin if they
support such a thing.

Documentation and tests are needed.

Bug: 179650038
Test: None
Change-Id: I892a23839758264ddd7b29fb739cb00d41d953f8
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
Fred Gylys-Colwell
981c7e97d9 Replace reference to SelectKey with GetKeyHandle in docs
Bug: 300514029
Merged from https://widevine-internal-review.googlesource.com/187930

Change-Id: I3134f9d12692dbd2916c576a872c79c87ad192fe
2024-01-30 16:09:41 -08:00
Fred Gylys-Colwell
797ab111ca Update OEMCrypto version to 18.4 in header
Merged from https://widevine-internal-review.googlesource.com/183806

Change-Id: I0d56b6a1f3056de5985a4acfa24dc2e03a6ac193
2024-01-30 16:09:41 -08:00
Cong Lin
dafd837420 Update documentation of OEMCrypto_GetDeviceSignedCsrPayload()
Clearify usage and paremeters of OEMCrypto_GetDeviceSignedCsrPayload()
and OEMCrypto_GetDeviceInformation().

Bug: 291625901
Merged from https://widevine-internal-review.googlesource.com/179470

Change-Id: I0c69bd6fadded6d749fd6f33553bb4a51d69e719
2024-01-30 16:09:41 -08:00
Fred Gylys-Colwell
dad5b3efb6 Update link in entitlement documentation
Relative links are different for the first sentence of a
group description and the rest of the group
description. That is because the first sentence also appears
in the group overview table. To fix this, I'm taking the
link out of the first sentence.

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

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

Change-Id: I697e1aacd5df683790ec486cc7e429d4981e4140
2024-01-30 16:09:41 -08:00
Matt Feddersen
40becdc349 Add is_factory_build to BuildInformation
Test: GTEST_FILTER="*CheckJsonBuildInformationAPI18*" ./jenkins/opk_ta
Bug: 259595106

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

Change-Id: I51994521fe0b692c1948f98058ef442556a28656
2024-01-30 16:09:41 -08:00
Jacob Trimble
91c7a8cffe Misc Fixes
- Code protection fixes for v18
- Fix MSVC error with static_assert
- Fix RSA with Cobalt
- Workaround SCP errors with string concatenation
    - Use snprintf instead

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

Change-Id: If2e9ee3403e313fd8c7dffccca6f8d3f7b0b0afb
2024-01-30 16:09:41 -08:00
Fred Gylys-Colwell
0a39e71bfb Specify encoding restrictsion for BCC
If the BCC has an RSA key, then it needs to be parsed by
BoringSSL, which expects rsaEncryption as the encoding type.

Bug: 272102162

Change-Id: I9b7dc374d8db80efda062b47f6b17720d9bc2ba2
2024-01-30 16:09:41 -08:00
Fred Gylys-Colwell
0a9bc6534c Document key usage for GenerateCertificateKeyPair
bug: 277124807
Merged from https://widevine-internal-review.googlesource.com/177958

Change-Id: I867d664a73ceba7391b5054365c4352a7c6aa301
2024-01-30 16:09:41 -08:00
Fred Gylys-Colwell
bf5804a103 Format code block in header
Adding some triple tildes makes doxygen format code blocks
correctly.

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

Change-Id: Ie4cce625fbd5f77a2f65191716bd4a2a8cf8b76e
2024-01-30 16:09:41 -08:00
Junfeng Yang
e0dac6f403 Remove a mistaken comment line
It appears there is a mistaken line in the comment for
OEMCrypto_LoadLicense.

Change-Id: I6a265e606052913a1adac317fa8557663897994c
2024-01-30 16:09:41 -08:00
Matt Feddersen
aaa1ce865f Improve documentation for OEMCrypto_GenerateCertificateKeyPair
Bug: 279194702

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

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

Change-Id: I59dfe4c5053c24c011c9222fe516b446df6524e0
2024-01-30 16:09:41 -08:00
Matt Feddersen
89ba99f16d Add new optional fields to OEMCrypto_BuildInformation output
Bug: 273347757

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

Change-Id: I0f878cab8456fa277a453d76e4deb4a2a846ede9
2024-01-30 16:09:41 -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
Cong Lin
30669a7b67 Cdm to expose GetDeviceInformation() and GetDeviceSignedCsrPayload()
GetDeviceInformation() and GetDeviceSignedCsrPayload() are added to
cdm_engine and crypto_session, so that they can be queried by DRM
plugin. This is to allow the wv drm HAL to be able to extract BCC and
CSR payload to build CSR for prov 4 device registration, such that we
don't need a separate RKP HAL to do this job.

Changes to the DRM plugin to use the exposed methods will be in the
coming CL.

Bug: 286556950
Test: request_license_test
Merged from https://widevine-internal-review.googlesource.com/178890

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

Change-Id: Ibafa3a58c99fbb8f1f25f8951d3749110bd32176
2024-01-30 16:09:41 -08:00
Kyle Zhang
c600ccb741 Add Cdm support for Cast provision 4.0 flow
Bug: 259455235
Test: CorePIGTest.CastReceiverProvisioning*
Merged from https://widevine-internal-review.googlesource.com/174150

Change-Id: I8d546a73a64a71a4d61225d9c6d14d893decce22
2024-01-30 16:09:41 -08:00
Fred Gylys-Colwell
f6c1879b4c Add OEMCrypto_FactoryInstallBCCSignature API
This was requested by OEM and SOCs to support Prov 4 signing
model in the factory.

Bug: 275567037
Merged from https://widevine-internal-review.googlesource.com/176310

Change-Id: I2907841c4a16f37ae9a2241a6c9eaad73ff616af
2024-01-30 16:09:41 -08:00
Robert Shih
dd1c01c9dd Merge cdm core changes into Android main
Merged commit:
- short link: go/wvgerrit/177661
  hash: a3cd4bd
  subject: Fix policy engine unittest issues from clang-tidy
  submitted: 2023-07-06

Change-Id: I7f079fccdd2f296d51b08b0a7005a0bb7c930ccb
2024-01-30 16:04:12 -08:00
Robert Shih
cc8f885e2b Merge oemcrypto fuzz tests into Android main
Change-Id: If7fb815fa6193ddfe9a94e925356cc177ae3bacc
2024-01-30 16:03:00 -08:00
Vicky Min
e123e25a9e Add comments referencing both places that need to be updated with new minor version releases.
PiperOrigin-RevId: 552584184
Change-Id: I3eaba4e9b4cf83e70c5dfc2edcfbbeace789d49a
(cherry picked from commit 589feafd7b572319ddbae97eb1778d760a739dd3)
2024-01-29 12:40:18 -08:00
Cong Lin
7277331f92 Update ODK version to 18.4 and unit tests
Test: odk tests, opk_ta, fake_l1_tests
Bug: 294440012
Merged from https://widevine-internal-review.googlesource.com/181150

Change-Id: Ia33962f9d244333b1ca17c9a64efc29de35db093
2024-01-29 12:40:11 -08:00
Fred Gylys-Colwell
10d9bc272f Mark some ODK types as undocumented, and document others
Bug: 293188660
PiperOrigin-RevId: 551019650
Merged from https://widevine-internal-review.googlesource.com/180470

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

Change-Id: I28aa1d82437128ac2862cf0d6de325644e4af067
2024-01-29 12:39:48 -08:00
Vicky Min
e765453b35 Update ODK minor version to match when major version is updated
PiperOrigin-RevId: 551930047
Merged from https://widevine-internal-review.googlesource.com/180430
(cherry picked from commit d85aa8107dbe292490f9897b1e76f72bc0144bff)

Change-Id: If973113886a19cb720ad635e68830b9afbcf22b5
2024-01-29 12:39:48 -08:00
Fred Gylys-Colwell
06ad24bce0 Update ODK and test version to 18.3
PiperOrigin-RevId: 546349606

Merged from
https://widevine-internal-review.googlesource.com/178000
and
https://widevine-internal-review.googlesource.com/178061

Bug: 290252863
Change-Id: I0d6d9a0214d556ae39efe8a720df8ac60c1e67fb
2024-01-29 12:39:46 -08:00
Matt Feddersen
2e7c68440b Bump OEMCrypto API to 18.2 to match ODK
Merged from https://widevine-internal-review.googlesource.com/170295

Change-Id: I9e9cc0c7c3296db71ac31518cf2d3d8608066686
2024-01-29 12:38:34 -08:00
Fred Gylys-Colwell
84e27c660d Initialize renewal request time
The `time_of_renewal_request` field in the clock_values struct was not being initialized. With this CL, we use a value of 0 to indicate a renewal has not been requested yet.

We also modify the check in `ODK_ParseRenewal` to use a value of 0 for the `time_of_renewal_request` to skip the check for a stale renewal. This is done because now that a "renew on license load" license starts the playback clock immediately, we need a different way to decide if a renewal from a previous session can be loaded.

PiperOrigin-RevId: 546129556
Merged from https://widevine-internal-review.googlesource.com/177998

Change-Id: I17282cf918d0cdb4d9b5108a41914ecd7d87cc8f
2024-01-29 12:31:37 -08:00
Fred Gylys-Colwell
d0752047fc Document b/290249855 in ODK
PiperOrigin-RevId: 546118816
Merged from https://widevine-internal-review.googlesource.com/177992

Change-Id: I6ab0b599a2d858f9451a5fbd3e3612275b729ee6
2024-01-29 12:31:36 -08:00