Commit Graph

478 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Vicky Min
ff80927f90 Allow server to send license with larger ODK_MAX_NUM_KEYS
PiperOrigin-RevId: 538676411
Merged from https://widevine-internal-review.googlesource.com/175915

Change-Id: Iadef2115fe3f9001034223e647cbfa6228484281
2024-01-29 12:31:03 -08:00
Rahul Frias
0cd3d185c7 Cleanup vendor projects are proprietary.
[ Merge of http://go/ag/21276850 ]

Test: m droid dist
Merged from https://widevine-internal-review.googlesource.com/166674

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

Change-Id: I0bdec38c4d12710fa97b91665d211ba6c0d4b24d
2024-01-26 17:39:30 -08:00
Ian Benz
14c5d6ee5f Move internal fuzz target naming scheme to g3doc
Change-Id: I400b0a34c670673aba9dd347ec41060b4b23897a
2024-01-26 16:26:25 -08:00
Ian Benz
e19927f4bf Update OEMCrypto fuzzing documentation
- Add details for triaging crashes and writing fuzz tests.
- Move internal documentation not needed by partners to g3doc.
- Remove infrastructure details covered in the design document.

Change-Id: Ib60b2bea954f4371595b0f891434e2274366fdd2
2024-01-26 16:26:23 -08:00
Ian Benz
9a24732f5b Replace entitled key session fuzzer
Enable multiple OEMCrypto calls in arbitrary order, multiple OEMCrypto
sessions, and OEMCrypto_ReassociateEntitledKeySession fuzzing.

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

Change-Id: Ic1ac754c74bf0299c8c9f04ffdbfe82cf9f7569d
2024-01-26 16:25:06 -08:00
Ian Benz
79c809840e Add OEMCrypto_QueryKeyControl fuzzer
Merged from https://widevine-internal-review.googlesource.com/177111
Merged from https://widevine-internal-review.googlesource.com/177117

Change-Id: Iea28155a369f71557a32cc34da7bd328f78e2413
2024-01-26 16:21:38 -08:00
Ian Benz
078682a897 Simplify fuzz tests using LicenseWithUsageEntryFuzz
Merged from https://widevine-internal-review.googlesource.com/175060

Change-Id: I2f245ac998883e2a31cde361e30b36f00681262c
2024-01-26 16:21:25 -08:00
Ian Benz
5c5433a8d8 Update OEMCrypto_LoadLicense corpus for ODK_Packing_ParsedLicense
- Regenerate corpus files.
- Change nonce endianness.

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

Change-Id: I5f288a054325097d6ea696cd755fc0557d0eadd1
2024-01-26 16:20:39 -08:00
Vicky Min
28e68a866b Fix crash in wvoec::LicenseRoundTrip::InjectFuzzedResponseData
After the ODK_MAX_NUM_KEYS change, the core response is a pointer to an
array instead of an array. This check should ensure the index of the key
array can always be accessed.

Bug: 286531859
Change-Id: I44604eb977be722ef692de2b61e1f626266a42a7
2024-01-26 16:18:40 -08:00
Ian Benz
ed55c511a3 Add OEMCrypto_GenerateCertificateKeyPair second stage fuzzer
Merged from https://widevine-internal-review.googlesource.com/176771

Change-Id: I8afee6636a44f46a573be5a94f6c12161b57eace
2024-01-26 15:27:29 -08:00
Ian Benz
4aa2bcde49 Fix OEMCrypto_LoadEntitledContentKeys fuzzer
- Pass entitled key session to OEMCrypto_LoadEntitledContentKeys.
- Refresh corpus files.

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

Change-Id: I7edb081933d37897e3b9d83dd00a627b5de64bc9
2024-01-26 15:26:46 -08:00
Ian Benz
3a05989920 Add OEMCrypto_GetDeviceSignedCsrPayload fuzzer
Merged from https://widevine-internal-review.googlesource.com/175050

Change-Id: I28e4b1bc1f82deaf5644d0b2e31d916bf65365d3
2024-01-26 15:23:50 -08:00
Ian Benz
ea43147a08 Add OEMCrypto_GetDeviceInformation fuzzer
Merged from https://widevine-internal-review.googlesource.com/174936

Change-Id: I79bbb8506a13d3142a8b323a7c67d0155973a3f4
2024-01-26 15:22:49 -08:00