Commit Graph

1672 Commits

Author SHA1 Message Date
Alex Dale
d874fffaec Support 32 bytes session key
[ Merge of http://go/wvgerrit/149849 ]

With ECC based DRM cert, the session key is expected to be 32, as
compared to 16 bytes in RSA case. This CL adds supports for 32 bytes
session key.

Bug: 236317198
Test: oemcrypto_test
Change-Id: I657fdd92d17736a23375ddcd457f83efa6ca6d1f
2022-06-23 14:48:19 -07:00
Alex Dale
02c7062349 Fix crypto session metrics test for provision 4.0
[ Merge of http://go/wvgerrit/151311 ]

Missing a check for provision 4.0.

Note: This CL is merged out of sequence with the CDM repo, resulting
in a slightly different CL.

[ Conflicting CL http://ag/18244016 ]

Test: Native test crypto_session_unittest
Bug: 180530495
Bug: 236317198
Change-Id: I79f753ba43098e1a3422c39b9903f57e5df03af2
2022-06-23 14:47:03 -07:00
Alex Dale
1c96d290bd Update cdm provision tests to work with prov 4
[ Merge of http://go/wvgerrit/150810 ]

This CL changes the call "Provision()" in some tests to use
"EnsureProvisioned()". The latter can actually call "Provision()" twice
in case of Prov 4 being used: first call to get oemcert.bin and second
call to get drm cert.bin.

Also added a file clean up during test tear-down.

Test: opk_ta with prov2 and prov4
Bug: 180530495
Bug: 236317198
Change-Id: I37c8708ead7f18e8b4d619bf6a080424e45406ee
2022-06-21 15:34:12 -07:00
Alex Dale
577ce88cbc Fix close entited key session in oemcrypto adaptor
[ Merge of http://go/wvgerrit/153290 ]

Currently OEMCrypto_Close will be called for entitled key sessions as
well upon destroying, while only OEMCrypto sessions should be called.
This CL adds a session type to the oemcrypto adaptor.

Bug: 232225911
Bug: 236317198
Test: request_license_test
Change-Id: I323fff80139ce949f801cf0df5aa2bd3171dfb51
2022-06-21 15:16:26 -07:00
Alex Dale
4fbc410346 Merge "Clang-formatted properties_android.cpp with new CDM properties." 2022-06-21 20:54:44 +00:00
Alex Dale
9b04109b60 Merge "Updated OEMCrypto tests to use DRM key objects." 2022-06-21 20:52:08 +00:00
TreeHugger Robot
a2cd76506f Merge "Downgrade benign error logs in device_files.cpp to warnings" 2022-06-21 19:16:44 +00:00
TreeHugger Robot
bb9a167038 Merge "Sync OEM_ENTITLEMENT in license_protocol.proto" 2022-06-21 19:16:40 +00:00
John Bruce
44aa794a68 Merge "Defer creation of default_config_" 2022-06-21 17:47:42 +00:00
Alex Dale
6c35b9e67a Clang-formatted properties_android.cpp with new CDM properties.
The CL http://ag/16988980 introduced new Adnroid property queries to
the CDM; however, the file was not of the correct format for the CDM
repo.  This CL simply ran clang-format on the file.

Bug: 197771575
Bug: 236317198
Test: none
Change-Id: I5293864f84d1297efb7aef2a96a71794217c5203
2022-06-17 19:57:43 -07:00
Alex Dale
68b5146a06 Downgrade benign error logs in device_files.cpp to warnings
[ Merge of http://go/wvgerrit/152650 ]

There are two LOGEs in device_files.cpp that would frequently trigger
during testing despite the condition they were logging being totally
normal. The files were not present because the device had never had to
write them yet. This patch downgrades these bengin errors to warnings
to reduce log spam.

Test: build_and_run_all_unit_tests.sh
Bug: 236317198
Change-Id: I56f9d477f8a6b26635f0eb4a6b7c636e866381d3
2022-06-17 19:47:26 -07:00
Alex Dale
729f2f6fb5 Sync OEM_ENTITLEMENT in license_protocol.proto
[ Merge of http://go/wvgerrit/148729 ]

A recent merge from google3 of the ODK code broke builds on the
oemcrypto-v17 branch because it depended on a license_protocol.proto
change that had not been brought over yet. This patch brings over the
missing line to fix the build.

Test: build_and_run_all_unit_tests.sh
Bug: 236317198
Change-Id: Ia8133696f3156c16ef4bd1382358be5da6159820
2022-06-17 19:43:49 -07:00
Alex Dale
b9ad36763a Add flag to disable CDM logging
[ Merge of http://go/wvgerrit/151570 ]

Bug: 215590138
Bug: 236317198
Change-Id: I5e90d2813252ca5ff5d9ba62316e2ee5545c71bf
2022-06-17 19:10:34 -07:00
John "Juce" Bruce
6b19df3268 Defer creation of default_config_
(This is a merge of http://go/wvgerrit/152969.)

C++ makes absolutely no guarantees about the order of initialization of
global variables in different compilation units. The class-scope static
WvCdmTestBase::default_config_ in test_base.cpp invokes the
ConfigTestEnv constructor on creation, which depends on the prior
initialization of several file-scope static variables in
config_test_env.cpp. Since those are different compilation units, there
is no guarantee that they will initialize in the correct order to avoid
referencing uninitialized memory. This is one of the reasons Google
Style really encourages people not to have global-scope variables with
complex types.

As it happens, on all our internal platforms, these files get linked in
such a way that the variables get initialized in the right order and
there is no crash. But that's not guaranteed, and some partners have
reported crashes here. In at least one case, the "right" linker order
was platform-dependent, and the partner ended up having to maintain
separate linker orders for separate platforms.

This patch defers default_config_ initialization until
WvCdmTestBase::Initialize() is called. By that time, all static
variables will be initialized, so it will be safe to reference them.

Bug: 173252165
Test: x86-64
Test: build_and_run_all_unit_tests.sh
Change-Id: If31128a999c7d6945f47293ca57f08e43d8274de
2022-06-17 15:55:44 -07:00
Alex Dale
bfa2d782bd Updated OEMCrypto tests to use DRM key objects.
[ Merge of http://go/wvgerrit/147275 ]

Swapped out use of OpenSSL/BoringSSL RSA and EC_KEY to use OEMCrypto
reference utility classes RsaPublicKey/EccPublicKey.  This enables
further test development with ECC keys, and removes duplicate OpenSSL/
BoringSSL code.

For Android makefiles, only the minimally required files have been
added.

Bug: 205902021
Bug: 236317198
Test: run_prov30_test run_prov40_test oemcrypto_test
Change-Id: I64491018e8ffb69bf986083e3aae446eb9e5cf39
2022-06-16 21:13:22 -07:00
Alex Dale
6024987733 Return null system ID for built-in DRM cert devices.
[ Merge of http://go/wvgerrit/153489 ]

OEMCrypto does not provide an API for retrieving the system ID when
the TEE uses a built-in DRM certificate (provisioning 1.0).  New OEMs
and Android devices do not use prov 1.0; however, the Zimperium CDM
(at least the tests) use a built-in certificate and are failing
certain tests because of the missing system ID.  To address this
failure; the CDM SystemIdExtractor has been updated to return a null
system ID.

Bug: 235879962
Test: system_id_extractor_unittest
Change-Id: Ib4c2bd75a7825967b0aa9e31e144184ae18fe8fb
2022-06-15 14:11:50 -07:00
John "Juce" Bruce
bcb04e050e Clean up constexprs with extra consts
(This is a merge of http://go/wvgerrit/151930.)

While grepping the code to respond to some CR feedback, I noticed a few
places where we had sprinkled some unnecessary "const" specifiers
amongst constexpr declarations. This patch cleans them up. There should
be little semantic difference in the code after this patch, as it only
removes specifiers that were redundant. The only exception is where
"constexpr const char* X" was converted to "constexpr char X[]", which
has slightly different semantics in edge cases we don't use.

Test: x86-64
Bug: 231439638
Change-Id: I0b33777f8d3b718a3410f6d802c51b1220508d34
2022-05-16 18:37:45 -07:00
John "Juce" Bruce
59b0e81963 Convert wv_cdm_constants.h to use constexpr
(This is a merge of http://go/wvgerrit/151929.)

Bug: 231439638
Test: x86-64
Change-Id: I2f62bf1e258ba260384c80838d322352d7ba1e5d
2022-05-16 18:33:52 -07:00
John "Juce" Bruce
a7cded376e Skip padding for content keys differently
(This is a merge of http://go/wvgerrit/151891.)

A previous patch changed how we skip padding when extracting keys from
key containers in license.cpp. Unfortunately, this broke generic
signing when an ODK core message is not in use:

1) "Content" keys for signing are 32 bytes long, but content keys were
   assumed to be 16 bytes long.
2) When an ODK core message IS in use, the result of the extraction in
   license.cpp is ignored.

The only way to know the correct length of a content key container in
License Protocol 2.1 is to leverage the knowledge that it will always be
padded by exactly 16 bytes. This will have to change if we ever
implement support for License Protocol 2.2, as all key containers are
unpadded in that version.

Bug: 231439638
Bug: 114159862
Test: oemcrypto_dynamic_v15
Change-Id: I1d6c24b3a922247b970fd1517c6f23aded570adf
2022-05-16 18:32:00 -07:00
Alex Dale
97638781d6 Move system ID extraction outside of CryptoSession. am: 9d169a00bb am: 3c82ad605d
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18244016

Change-Id: I461ae5b896396aff9949242d897d743fef3609ce
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-13 18:39:19 +00:00
Alex Dale
9d169a00bb Move system ID extraction outside of CryptoSession.
[ Merge of http://go/wvgerrit/151391 ]

This CL moves the logic for extracting the system ID from keybox or
OEM certificate (from OEMCrypto or device files) to a dedicated
SystemIdExtractor.

Before Provisioning 4.0, the system ID could only be found from data
returned by OEMCrypto.  However, with provisioning 4.0, the system ID
can now be found in the OEM certificate that is stored on the device
files.

Bug: 232020319
Test: system_id_extractor_unittest
Test: Forest L37800000954493485
Change-Id: Ie1b7987906e2e4fef015cd659a947b6dbb7594b1
2022-05-12 19:22:03 -07:00
Alex Dale
9ffe02116a Merge "Added metrics for production readiness." into tm-dev am: 8ac7ca3f46 am: b3bc24aaf1
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18304422

Change-Id: I1598e1e56e4ace0d19c82cd6fa5edf0d21d28a1a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 23:49:21 +00:00
Alex Dale
88a7ff7685 Added metrics for production readiness.
[ Merge of http://go/wvgerrit/151749 ]

Extended CryptoSession for recording the result of
OEMCrypto_ProductionReady().

Only OEMCrypto_SUCCESS is considered "production ready".  With the
exception of OEMCrypto_ERROR_NOT_IMPLEMENTED, any other result is
vendor-specific and indicates not being production ready.

Bug: 231655151
Test: metrics_collections_unittest
Change-Id: Ia0e5603d7ee1290238cce63d0194ae1aced424c1
2022-05-10 18:04:11 -07:00
Alex Dale
866cd26693 Added CDM support for production readiness reporting. am: cd5afa88a6 am: cce550d006
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18195696

Change-Id: Ib68038545cfc302f34eabe52264188b3e7ff356b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-10 22:04:13 +00:00
Alex Dale
cd5afa88a6 Added CDM support for production readiness reporting.
[ Merge of http://go/wvgerrit/151518 ]

Extended the CDM layer to report OEMCrypto's production readiness
via string property query.

If OEMCrypto implementents OEMCrypto_ProductionReady(), then the
reported readiness by the CDM will report "True" or "False".

If OEMCrypto does not implement OEMCrypto_ProductionReady() then no
level of readiness is assumed, and the CDM will report "Unknown".

Bug: 231655151
Test: run_prov30_tests and request_license_test
Change-Id: I6afe481ef00ac129d02b004eca89a65810bfbff8
2022-05-10 13:35:43 -07:00
Rahul Frias
efa8877be2 Merge "Check L3 for secure stops" into tm-dev am: f4e2e9833d am: ba5c28e363
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18192750

Change-Id: I31b8373c502246676275f39f98d5ea6af8d6924c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-06 22:44:30 +00:00
Rahul Frias
9544ebb04b Merge "Update version change canary test" into tm-dev am: e26370f0b6 am: 6966dd7b20
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18194076

Change-Id: I219bc46b77f2f795a48ff02ab44c7f71d1377ad7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-06 22:44:01 +00:00
Rahul Frias
f4e2e9833d Merge "Check L3 for secure stops" into tm-dev 2022-05-06 22:08:52 +00:00
Rahul Frias
e26370f0b6 Merge "Update version change canary test" into tm-dev 2022-05-06 22:06:05 +00:00
Rahul Frias
13daf6d3ed Check L3 for secure stops
[ Merge of http://go/wvgerrit/151512 ]

Parameterizing GtsMediaDrm tests exposed a few issues. If secure stops
were stored at L3 security level, retrieval would fail. This CL
checks L3 if the secure stop was not found at the default security
level.

Bug: 221249079
Test: GtsMediaTestCases
Change-Id: Ie88197f8e29457981d782199a76d38774f6faa67
2022-05-06 01:39:24 +00:00
Rahul Frias
81e5fc3dc4 Update version change canary test
[ Merge of http://go/wvgerrit/151571 ]

The android OS version has been updated to 13. Updating WV tests as well.
CDM version has been updated previously, so no additional changes are needed.

Bug: 231646284
Test: WV unit/integration tests
Change-Id: Ifaf2fe1f04627654725b1b221d8c3dc30029ac6c
2022-05-05 18:29:25 -07:00
Alex Dale
f0b6a1bcca Merge "Resize OEMCrypto buffer-based results on success." into tm-dev am: f980049ef0 am: 3adda51fc2
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18126088

Change-Id: Ie65372e74a6b8b5f73dfeaaef33f3a67d4e4e58a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-05 21:28:16 +00:00
Alex Dale
f980049ef0 Merge "Resize OEMCrypto buffer-based results on success." into tm-dev 2022-05-05 20:38:05 +00:00
Edwin Wong
2b41c881f2 Merge "Only use libbinder_ndk for aidl service." into tm-dev am: f607802265 am: 421e7d99d9
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18092491

Change-Id: I3874c09e4652c0222a342855199ac343837a91ef
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-05 19:21:03 +00:00
Edwin Wong
f607802265 Merge "Only use libbinder_ndk for aidl service." into tm-dev 2022-05-05 17:53:05 +00:00
Cong Lin
51b9001218 Merge "Include SPOID in provisioning 4 request" into tm-dev am: e06c526d3b am: fa90d3da1f
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18014492

Change-Id: I7839f22385c0d6cf25338dc6649b5eafbfdbfed2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-05 16:26:26 +00:00
Edwin Wong
af5f57a46c Only use libbinder_ndk for aidl service.
[ Merged from http://go/wvgerrit/151169 ]

Test: Netflix and Google TV streaming and downloaded playback
Test: unit tests
Test: atest VtsAidlHalDrmTargetTest
Test: adb shell readelf -d /vendor/bin/hw/android.hardware.drm-service.widevine
Test: adb shell readelf -d /vendor/lib64/libwvaidl.so

Bug: 230791937
Change-Id: Ia60d9fc838bf228b40d99b076a837ae789fa2d03
2022-05-05 15:12:55 +00:00
Alex Dale
1069ae39cc Resize OEMCrypto buffer-based results on success.
[ Merge of http://go/wvgerrit/151191 ]

Within the CDM and OEMCrypto tests, there were a few OEMCrypto function
calls where the final size of the output buffers were not being
resized.  For several of these functions, an initial call is made with
zero-length output buffers, expecting OEMCrypto to return
ERROR_SHORT_BUFFER; followed by a call with buffers at least as large
as specified by OEMCrypto.  However, for some operations, OEMCrypto
makes an estimate on the final size on the first call, specifying the
exact size only after performing the operations.

This is the case for the wrapped key returned by
OEMCrypto_LoadProvisioning().  The provisioning response contains a
padded + encrypted DRM key.  OEMCrypto does not know the actual size
of the key until decrypted, and the actual DRM key might be smaller.

There was a OEMCrypto test for OEMCrypto_BuildInformation() which
was enforcing the wrong behaviour.  This has been updated.

Bug: 230661565
Test: oemcrypto_test
Change-Id: Iad297d56ffbb085894641fdf8698ce5fd18edbf2
2022-05-04 21:32:08 -07:00
TreeHugger Robot
b6cb5024cc Merge "Skip key padding better" 2022-05-04 00:19:06 +00:00
Lu Chen
534589fd2e Include SPOID in provisioning 4 request
Merged from https://widevine-internal-review.googlesource.com/148554

This change was merged to master but missed in tm-dev when we stopped
the auto merging to tm-dev. Manually cherry picked it.

Test: ran OPK unit tests
Bug: 230820162
Bug: 180530495

Change-Id: Ib23f07f84096650beb4dd1950105db01e004d484
2022-04-29 21:36:51 -07:00
TreeHugger Robot
48de2dd5ec Merge "Added mutex for reserved_license_ids_." into tm-dev am: da1e3c5de2 am: 15dbcab918
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/17919183

Change-Id: I5dfdd7d88526420dd3ada802c6b9181bc4d20675
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-29 20:11:42 +00:00
TreeHugger Robot
da1e3c5de2 Merge "Added mutex for reserved_license_ids_." into tm-dev 2022-04-29 19:36:30 +00:00
John Bruce
3d4df9b5d4 Merge "First-stage Provisioning 4.0 client ID encryption" into tm-dev am: 7d78ce9ac8 am: 9063559c43
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/17949160

Change-Id: I044eff2022cbb905409f5f0ca1d49b4dcf549ac5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-29 19:12:11 +00:00
Alex Dale
654e6208f6 Merge "Specify DRM certificate duration in tests." into tm-dev am: 38b639f920 am: beddef3475
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/17779678

Change-Id: I31e1ba2f4e5d9a96b457b6aa5c2d6dcc69ff7b57
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-29 18:42:17 +00:00
John "Juce" Bruce
30a3da1b83 Skip key padding better
(This is a merge of http://go/wvgerrit/151112.)

The Widevine CDMs have never validated the padding on AES keys. However,
the code to ignore the padding was unusual and based on the assumption
the keys would always have either 0 or 16 bytes of padding and did not
handle other cases correctly. This patch updates the padding-ignoring
code to just do the obvious thing: Reject keys that are too small and
ignore all extra bytes regardless of count.

Bug: 114159862
Test: x86-64
Change-Id: Ic48010477e4cb5f7d2afbde25cf2f098e3470089
2022-04-29 18:20:31 +00:00
John Bruce
7d78ce9ac8 Merge "First-stage Provisioning 4.0 client ID encryption" into tm-dev 2022-04-29 17:38:39 +00:00
Alex Dale
38b639f920 Merge "Specify DRM certificate duration in tests." into tm-dev 2022-04-29 17:34:59 +00:00
Robert Shih
aeef8cc0e7 Merge "WVCdm: no destroy global log buffer on exit" into tm-dev am: 5c38b38514 am: 5c15da7afc
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/17570520

Change-Id: I393967ede53cf655dfb7966be610a6dcbceca5e7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-27 22:08:46 +00:00
Alex Dale
f696a48318 Logging CDM session ID on Decrypt() failures.
[ Merge of http://go/wvgerrit/149690 ]

This changes extends the CryptoSession logging to include the OEMCrypto
session ID in its decrypt failure logs, and adds a new CdmSession
decrypt failure log which includes the CDM session ID.  The CDM session
directly maps to the MediaDRM session ID, making app debugging easier.

The Decrypt() code pathway is one of the most frequently called
portions of the CDM code, and the pathway attempts to make as few
logging calls as possible in order to keep latency low and log
verbosity to a minimum.  It is anticiapted that when a call to
Decrypt() fails, there will be a burst of failures as the app may
make several calls to Decrypt() before handling the first decrypt
error.

To keep logging low, the following rules are followed:
- CryptoSession: decrypt errors are only logged when the decrypt error
  changes.
- CdmSession: decrypt errors are only logged when the last call to
  decrypt had succeeded.

Bug: 183984396
Test: MediaGTS with decrypt failures
Change-Id: Ic6124646d129efbc8a690b5bfd4dc422e04e677b
2022-04-26 21:23:12 +00:00
Robert Shih
5a1d5e8837 WVCdm: no destroy global log buffer on exit
[ Merge of go/wvgerrit/149989 ]

Bug: 227848537
Change-Id: I9407b133654c20ddcd3c15404dd19b3719064e6e
Test: Irdeto monkey test
2022-04-26 16:57:13 +00:00