Commit Graph

763 Commits

Author SHA1 Message Date
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
065d4d151e Update C function/field documentation to match behavior in ODK
PiperOrigin-RevId: 560780563
Change-Id: Ibd88398b06cca7a51d152fb6da95afd40cdd5a8b
2024-02-22 13:52:28 -08:00
Vicky Min
3933be3650 Update OEMCrypto_PrepAndSignLicenseRequest() documentation
OEMCrypto_PrepAndSignLicenseRequest() documentation needs to be updated
to match the current behavior.

Bug: 296608852
Change-Id: Ib76dc2f1afa705b5f71e654afa2889b2dcca36ce
2024-02-22 13:52:28 -08:00
Jacob Trimble
660a20ed5c Always use static_assert on MSVC
MSVC supports static_assert but won't always set __STDC_VERSION__ correctly.  So we just assume it is supported.

PiperOrigin-RevId: 559166904
Change-Id: I9a62094686405c58fe9be202bce0f4fefb764d48
2024-02-22 13:52:28 -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
c26d6d3c97 Update core_message_util_test LicenseResponse18 unit test for variable max num keys change
PiperOrigin-RevId: 557685272
Change-Id: Ib9e1b6c38d1f135c757e734c1c9f36d3913a21ca
2024-02-22 13:52:11 -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
Vicky Min
41942e1014 Roll ODK version number to 19.0
PiperOrigin-RevId: 551966786
Change-Id: Ib3eb3423112a340abb25cddfdc2d6d43ad2ce6f1
2024-02-22 13:44:51 -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
Junfeng Yang
93c19cd8de Fix the parameter direction
The output_descriptor parameter of OEMCrypto_FreeSecureBuffer should be
marked as [in,out].

Bug: 321346771
Change-Id: I4ba1a7f0b0f12a068d655a0d0b8b43a0818980dc
2024-02-19 01:01:26 -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
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
Matt Feddersen
c02de3f0e6 Update CHANGELOG link for v17.2
Merged from https://widevine-internal-review.googlesource.com/183778

In addition to the merge from oemcrypto-v17, this CL fixes a few header
indents and v18 tag links.

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

Change-Id: I781aa69314acdeb48bff1af3c291c847f6a664ea
2024-02-01 13:40:53 -08:00
Cong Lin
5d72262eda Update OEMCrypto CHANGELOG for v18.4
Bug: 294440012
Merged from https://widevine-internal-review.googlesource.com/181191

Change-Id: I4d0726058b938a7d9767bbecd8553c92e81841da
2024-02-01 13:40:52 -08:00
Cong Lin
2db837bce4 Update OEMCrypto CHANGELOG.md for v17.2
Bug: 241146324
Merged from https://widevine-internal-review.googlesource.com/178978

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

Change-Id: I385cab041e795d9ef2a5cb01e7ee71fe3290c84d
2024-02-01 13:40:52 -08:00
Matt Feddersen
5715fb527a Update changelog for 18.3
Merged from https://widevine-internal-review.googlesource.com/178050

Change-Id: Id4417754bdb9acabbbdbebbf913e4de87c933054
2024-02-01 13:40:52 -08:00
Matt Feddersen
6243410069 Remove WTPI_MaxBufferSizeForDecrypt and WTPI_ApplyCGMS
Bug: 277115746

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

Change-Id: I744f4fe1837b776b50693a40535484e8fae092c4
2024-02-01 13:40:52 -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
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