Commit Graph

1556 Commits

Author SHA1 Message Date
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
John "Juce" Bruce
c823a85e7d First-stage Provisioning 4.0 client ID encryption
(This is a merge of http://go/wvgerrit/150131 to the Android repo.)

This patch changes the code path in the CDM so that the first-stage
provisioning request for Provisioning 4.0 is always encrypted with the
Widevine service certificate instead of the client-set service
certificate, reflecting that the first-stage provisioning is always
handled by Widevine.

This patch also makes several methods on the ServiceCertificate class
const. This has no impact on their behavior.

Bug: 221443151
Test: prov40 tests
Change-Id: Ide4c3927afadcd45ae7fb629b99e2f55cc29d56e
2022-04-25 17:33:53 -07:00
Alex Dale
a80a9fef26 Added mutex for reserved_license_ids_.
[ Merge of http://go/wvgerrit/150630 ]

DeviceFiles uses a static variable for tracking license IDs which
have been reserved by a CDM session before officially storing the
license on the device.  This variable was not protected by a mutex,
and a rare race condition would arise, either crashing the service
or getting it stuck in a loop.

This CL adds a mutex for protecting the set of reserved IDs.

Bug: 226555704
Test: device_files_unittest
Change-Id: Icdea88673c76c267b4b7db79697ec52ae8e2581e
2022-04-22 13:53:11 -07:00
Alex Dale
cc35c64757 Specify DRM certificate duration in tests.
[ Merge of http://go/wvgerrit/150350 ]

Certain integration tests were depending on the provisioning server
only sending short duration (~2 minute) certificates when testing
the CDM's ability to enforce expiration periods.  This behavior of
the server was not reliable, resulting in device test failures from
server behavior changes.

The DRM certificate provisioning server allows the requester to
optionally provide a desired certificate duration in the request
URL.  The tests which test the CDM's ability to enforce certificate
durations will now explicitly specify the certificate duration
required by the test.

Bug: 228547158
Test: request_license_test
Change-Id: Ib9ebfdba1451104be0e59baca0b2f23a94cd51e6
2022-04-15 20:14:51 -07:00
Alex Dale
c3125d8320 Merge "Added CDM support for Watermarking reporting." into tm-dev am: b3a5117b82 am: f0de58c431
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/17364417

Change-Id: Ic8673e2b3ae269b71612f6bb6beed7d0e7a67579
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-02 01:35:11 +00:00
Alex Dale
b3a5117b82 Merge "Added CDM support for Watermarking reporting." into tm-dev 2022-04-02 01:07:07 +00:00
Alex Dale
46ce5b68b7 Merge "Reset UsageTableHeader when re-init for tests." into tm-dev am: b3a5a656af am: 06cddd75a3
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/17511529

Change-Id: Id08746db95b09f977f61bdab79a5e43214ebf118
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-01 21:42:02 +00:00
Alex Dale
97f3544866 Added CDM support for Watermarking reporting.
[ Merge of http://go/wvgerrit/148552 ]

Extended the CDM layer to report OEMCrypto's watermarking support.
The reporting of watermarking comes in three (3) mechanisms:
1) ClientCapabilities in license requests
2) CryptoSession metrics when queried to OEMCrypto
3) String property query by apps

If OEMCrypto implementents OEMCrypto_GetWatermarkingSupport(), then
the reported watermarking support by the CDM will match that of
OEMCrypto.

If OEMCrypto does not implement OEMCrypto_GetWatermarkingSupport()
or an error occurs, it is assumed that OEMCrypto does not support
watermarking, and the CDM will report "Not Supported".

Bug: 226443788
Test: run_x86_64_tests request_license_test and license_unittest
Change-Id: Id929a356c395e6bcf45d371ee6887eec40d35329
2022-04-01 14:24:44 -07:00
Alex Dale
b3a5a656af Merge "Reset UsageTableHeader when re-init for tests." into tm-dev 2022-04-01 21:13:32 +00:00
Alex Dale
8091ed239e Reset UsageTableHeader when re-init for tests.
[ Merge of http://go/wvgerrit/149130 ]

When re-initializing OEMCrypto for testing purposes, the
UsageTableHeader must be reset as well.  This is to inform future
sessions to load or create a new header before creating new entries.

Bug: 219075437
Test: request_license_test and MediaDrmTests GTS
Change-Id: Ie8bc72bc7ea079d21587e114223fcb67547c756a
2022-04-01 03:20:24 +00:00
TreeHugger Robot
b18b3e20d3 Merge "Rename conditional flag and remove log spam." into tm-dev am: 0a65e3ba32
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/17500167

Change-Id: I8e2943b97b5f3e8d5910ef2f00d93bfde30eebd9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-30 19:01:51 +00:00
Edwin Wong
2a91e85b91 Rename conditional flag and remove log spam.
[ Merged from http://go/wvgerrit/149029 ]

Address comment in http://ag/17158449 for
b/217247987, rename BUILD_TARGET with a
unique name. Also remove $(info ...) log spam.

Test: ./build_all_unit_tests -t hidl
Test: ./build_and_run_all_unit_tests -t hidl
Test: ./build_all_unit_tests
Test: ./build_and_run_all_unit_tests
Test: ./build_and_run_all_unit_tests -t invalid (default to AIDL)
Bug: 226976702
Change-Id: I1529dfbbbd1b112668ccac22bc684817dcb9ed35
2022-03-30 16:38:01 +00:00
Rahul Frias
04e403cc64 Merge "Sync license_protocol.proto" into tm-dev am: d3c653bd11 am: 7ce3d819d9
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/17345666

Change-Id: I1d8471440b1e7459f5ce23b5f4020a6a29258ce9
2022-03-24 04:23:46 +00:00
TreeHugger Robot
9378f74171 Merge "Correct when OEMCrypto_GetOEMPublicCertificate is called" into tm-dev am: 27d2826d03 am: 6905de19f9
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/17365196

Change-Id: Ic9ef9f131d6ee1d7d6138294ed9a3c62e6ff0220
2022-03-24 04:23:40 +00:00
Rahul Frias
d3c653bd11 Merge "Sync license_protocol.proto" into tm-dev 2022-03-24 03:58:21 +00:00
Rahul Frias
c014da7da3 Correct when OEMCrypto_GetOEMPublicCertificate is called
[ Merge of http://go/wvgerrit/148469 ]

OEMCrypto_GetOEMPublicCertificate needed to be called
before the OEM private key was loaded due to a bug in OEMCrypto.
The bug has been addressed and the call can now be removed.

OEMCrypto_GetOEMPublicCertificate is only applicable to
devices with OEM certs as their root of trust. Devices with
keyboxes (or BCC) as their RoT would return a spurious
error OEMCrypto_ERROR_NOT_IMPLEMENTED. Removing the call
addresses this as well.

Bug: 190231658
Test: WV unit/integration test
Change-Id: I8216ca5a78b8c2acb5681c7f599cdc41efdf9fc7
2022-03-23 17:18:36 -07:00
Rahul Frias
3912635502 Sync license_protocol.proto
[ Merge of http://go/wvgerrit/148470 ]

Bug: 226298543
Test: WV unit/integration tests
Change-Id: Id3300772182a089230e23a277775334f6731d45a
2022-03-23 16:59:13 -07:00