Commit Graph

8015 Commits

Author SHA1 Message Date
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
Ian Benz
35cf9c2f99 Fix OEMCrypto test issues identified by Coverity
Change-Id: Ic9f4982bf022292d10a0a88f10648a46077ec0cf
2024-02-01 13:40:51 -08:00
Cong Lin
28c2345413 Fix error check in ForbidPrepAndSign test
OEMCrypto_ERROR_INVALID_RSA_KEY is deprecated in v17. But
v16 oemcrypto can still return it. Unit test should allow
this error for now.

Test: run_dynamic_oemcrypto_v16.4, run_dynamic_oemcrypto_v16.3
Bug: 307668988

Change-Id: I950b62c8b3e02ea09d4795839a3d69573ab718aa
2024-02-01 13:40:51 -08:00
Fred Gylys-Colwell
8f3ee84c1b Unit tests for forbidden RSA key usage
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
Change-Id: Ic2b23e3fd279e878c190a8294078a8d092126a29
2024-02-01 13:40:51 -08:00
Ian Benz
343324e97c Add missing #include to fix the OPK Linux build
Merged from https://widevine-internal-review.googlesource.com/185856
Merged from https://widevine-internal-review.googlesource.com/185910

Change-Id: I51d7a0fed2475333f459030005e796c2055fecc7
2024-02-01 13:40:51 -08:00
Fred Gylys-Colwell
36d4c4c4b7 Pretty print BuildInformation in unit tests
Change-Id: I1f702edc731454c84667c79e05c94b4360a40111
2024-02-01 13:40:51 -08:00
Alex Dale
ac5f0135d5 Cleanup install_keybox_tool
This tool will soon be used in LUCI tests.  It seemed necessary to
clean it up to make the build cop's job easier if there is a problem.

The following was completed:
* Removed stub for install XML based keyboxes
  * This is handled externally
* Improved error checking
* Replace C-style prints with C++ styled prints
  * Keybox information is still printed to stdout
  * Major erros are printed to stderr
* Updated to follow Google style guide
* Fixed header includes
  * Removed unused headers
  * Added headers that are used, but were included indirectly
* Ensures OEMCrypto_Terminate() is called
  * Particularly if there is an error encountered.

Bug: 299108238
Test: Tested in later CL
Change-Id: Ie6dafc44d050d0c6ae288f88cd5d6f3737d4a88c
2024-02-01 13:40:51 -08:00
Fred Gylys-Colwell
e0d30c5fc0 Rename LoadWithAllowedSchemes to LoadCastCertificateKey
The unit test helper function LoadWithAllowedSchemes should
only be used to load a Cast Certificate. So it has been
renamed to make that clear.

The only unit test that used the old function with the
non-cast padding scheme has been removed. A replacement will
be added in the next CL of the chain.

Change-Id: Id4aa2f420435baff664324ee4b3dcb74ab9ffe8a
2024-02-01 13:40:51 -08:00
Fred Gylys-Colwell
c89ca732f0 Clean up OEMCrypto unit tests for Android
Remove some stale tests.

Bug: 175122314
Change-Id: Ie110ffc28353fcdafaf7774d81a625f5d99f4213
2024-02-01 13:40:51 -08:00
Fred Gylys-Colwell
fd28f10559 Update OEMCrypto unit test date
This corresponds to the release date of v18.4

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

Change-Id: I5e2714822932c52a82bd1f287111c11a4001f985
2024-02-01 13:40:51 -08:00
Fred Gylys-Colwell
b99d1213df Clean up logging of device id
It helps in debugging and scanning logs if the device id is
human readable.

Bug: 299108238
Change-Id: Ib358b71514b2ddcc61bc6239ff802d87dad7d3ef
2024-02-01 13:40:51 -08:00
Fred Gylys-Colwell
7bb0b06c03 Refactor provisioning unit tests
There was some confusion about which tests loaded a cert and
which ones just used a cert. This distinction is important
when testing devices with a baked-in-cert.

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

Change-Id: I3c2b119c3355b3a9190799637ff0860b6153b35b
2024-02-01 13:40:51 -08:00
Vicky Min
5b831fc4f1 Skip entitlement session tests that are only supported on CAS devices
Bug: 297497167, 297244784
Merged from https://widevine-internal-review.googlesource.com/183690

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

Change-Id: I09e5a961550467ceacd043b22c4d21085df82571
2024-02-01 13:40:51 -08:00
Fred Gylys-Colwell
05f3d0c524 Add install keybox tool and test
This adds an install keybox tool to the OEMCrypto unit test
directory. It is built when we build the OPK w/linux IPC.

This CL also adds some scripts to use this tool when running
the OPK Linux TA, and then runs the standard tests.

Bug: 295371549
Change-Id: I11e59faa3b24d906f573bcd3f4855e73a4aa5fdf
2024-02-01 13:40:51 -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
68eb8ee824 Skip Android tests after initialization
Bug: 297123471
Merged from https://widevine-internal-review.googlesource.com/183551

Change-Id: I742ad6115bb3d4dd3490eb7b18e4f62bfcc1447b
2024-02-01 13:40:51 -08:00
Ian Benz
ab6944dc59 Fix uninitialized field identified by clang-tidy
Merged from https://widevine-internal-review.googlesource.com/181950
Merged from https://widevine-internal-review.googlesource.com/182050

Change-Id: I87f1401a02c6e475b7c728c625fbe5fc7c71dea6
2024-02-01 13:40:51 -08:00
Matt Feddersen
0dbc42f10e CAS demo app
Adds a new `cas` directory to the ports/linux project. This contains
an end-to-end demo of OEMCrypto CAS functionality, using the Linux
tee_simulator as a base.

Test: from ports/linux/cas dir: `CDM_DIR=~/work/cdm-dupe ./scripts/build.sh && CDM_DIR=~/work/cdm-dupe ./scripts/run.sh`

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

Change-Id: I781b403100ad2e069d99650d9ddae8e7acbc309a
2024-02-01 13:40:50 -08:00
Vicky Min
7d989e3448 Filter RSA 3072 tests
We want to transition to using GTEST_SKIP to skip unit tests instead of
modifying the GTEST_FILTER variable. This does so for tests that require
RSA 3072 support.

Bug: 251240681
Change-Id: I048d31e25316d621771efb5d472f651bff40bf75
2024-02-01 13:40:50 -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
Vicky Min
678b3332db Allow ODKs to be tested against older versions for Qualcomm
Bug: 276889732
Merged from https://widevine-internal-review.googlesource.com/179801
(cherry picked from commit af81eefde596cf1644e5451b03230c77cfde410b)

Change-Id: I7a99d3c3104f16898258785d17a9b9b7a2f53ad1
2024-02-01 13:40:50 -08:00
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