Commit Graph

1747 Commits

Author SHA1 Message Date
Alex Dale
d027236719 Android CDM: Removed secure stop tests.
[ Merge of http://go/wvgerrit/158720 ]

Support for secure stop licenses have been dropped.  The MediaDRM
APIs have already documented their deprecation.  Before support can
be removed from the plugin and CDM core implementation, the tests
associated with them must be removed.

This CL removes secure stop tests from the Android CDM integration
test `request_license_test` and from the MediaDRM plugin test
`libwvdrmdrmplugin_hal_test` and `libwvdrmdrmplugin_hidl_test`.

Bug: 242289743
Test: libwvdrmdrmplugin_hal_test request_license_test
Change-Id: Idb7ee53ab8115ce9b9a173eaf0a00f54325863a2
2022-10-14 12:57:49 -07:00
Kyle Zhang
af0168dbed Merge cdm changes to android repo
Bug: 251924225
Test: GtsMediaTestCases
Change-Id: I1b4e64c0abf701fe1f5017f14dc72b72c3ea6770
2022-10-11 00:40:42 +00:00
Jeffrey Kardatzke
8f9f25ca35 libwvdrmengine: Change ChromeOS ro.product props to ro.vendor
As of Android T, these need to start with the ro.vendor prefix. We are
doing it now so we can update ChromeOS to be in sync for either version.

Bug: 237492145, 248584954
Test: No properties errors in logcat during playback
Change-Id: Ic6fac64e621be65385d16808dbef52914a66967a
(cherry picked from commit 28a040d407b28d24dd4d5496dd08cfa2f6579d71)
(cherry picked from commit a932781fcc7d2d89d73c546bf244399daf02f5ac)
2022-09-30 18:30:01 +00:00
Jeffrey Kardatzke
ea5825643b Merge "libwvdrmengine: Limit custom property check to ChromeOS" 2022-09-23 21:26:24 +00:00
Alex Dale
84badb3109 Merge "Create custom gtest matcher for similar URLs." 2022-09-21 00:52:32 +00:00
Jeffrey Kardatzke
06c1343153 libwvdrmengine: Limit custom property check to ChromeOS
We added custom properties that are only used on ChromeOS and to avoid
having to bloat the sepolicy for all of Android we are adding a check
here so that we only query the properties on ChromeOS based on the
bertha hardware property.

Bug: b:237492145
Test: Access denied message is gone w/ ExoPlayer
Change-Id: I3a5781ad980dfae2e16501b655386287b5e245b7
(cherry picked from commit 890f71ef367aed683a89892000e40d0e0ca6fbdd)
(cherry picked from commit 4379b0545a2ae866ba9fc315551a5534fa163924)
2022-09-19 16:52:24 +00:00
Kyle Zhang
249404a8df Add widevine vendor apex
Bug: 243699259
Change-Id: Ie1ff0aa9c82f19e0c5412508ac6b67d9083c0cab
2022-09-14 05:31:29 +00:00
TreeHugger Robot
20388e323d Merge "Revert "Add widevine vendor apex"" 2022-09-13 19:35:10 +00:00
Kyle Zhang
eee0d4b88e Revert "Add widevine vendor apex"
Revert submission 19794159-wv-vapex

Reason for revert: Breaking build in branch ndk_translation_all
Reverted Changes:
I48004b8cb:Add widevine apex
Ifa5c1b621:Add widevine vendor apex

Change-Id: I056369265fb341d723b8ff31a0efd7ae3eeec0bb
2022-09-13 18:05:51 +00:00
Kyle Zhang
c68012cd2f Merge "Add widevine vendor apex" 2022-09-13 16:57:54 +00:00
Kyle Zhang
b9c4bfdaf7 Add widevine vendor apex
Bug: 243699259
Change-Id: Ifa5c1b621a9fc0b6d370124fad7de1334c537c65
2022-09-13 01:29:10 +00:00
Alex Dale
66a3ec64d2 Create custom gtest matcher for similar URLs.
[ Cherry-pick of http://ag/19893913 ]
[ Merge of http://go/wvgerrit/157098 ]

Several of the Android integration tests perform direct URL comparisons
between fixed URLs and the server URL returned by the CDM.  With
provisioning 4.0, the CDM will append additional query parameters to
the server URL.  This updated URL still contains all of the original
expected information, but with additional parameters.  So long as the
URL contains the required fields, any additional parameter should be
considered valid.

The gtest framework used by the integration tests allow for the
creation of custom "matchers", rules that can be used to validate data
and create informative failure logs.  The CL creates a new matcher for
checking that a tested URL is a superset of content of the expected
URL.

Bug: 244319313
Test: request_license_test on prov 4 device
Change-Id: Ie721058fa628b3a4a74dc56f4172a3dfcb1f1ef3
(cherry picked from commit fa8c0a9a62)
2022-09-09 22:57:14 +00:00
Edwin Wong
c39a485e35 Merge "Rename aidl_ include and src directories." 2022-09-06 23:59:59 +00:00
Edwin Wong
e176b20509 Rename aidl_ include and src directories.
Test: unit tests
Test: Google TV and Netflix
Test: atest GtsMediaTestCases

Bug: 216527109
Change-Id: I3fd02c2c60da588dba3db27cea3593de25a7180f
2022-09-05 21:08:25 +00:00
Alex Dale
458f4f68c4 Allow running tests without test keybox.
[ CDM CL http://go/wvgerrit/156286 ]

Local test scripts can now run the CDM unit tests without using a test
keybox / test RSA key by setting an environment variable:

  DISABLE_TEST_KEYBOX=yes

The default behavior will continue to be that the unit tests will load
a test keybox / test RSA key.

This is to enable testing different provisioning features when the
device uses keyboxes for its ROT.  Provisioning methods like 3.0 and
4.0 were never forcibly required to load a test ROT.

This is change is required for the ability to test ECC-enabled
keyboxes.

Bug: 135283522
Test: run_x86_64_tests and build_and_run_all_unit_tests.sh
Change-Id: I2a85be541deec3f60ab8fa82452a4d4cafaed339
2022-08-29 17:14:26 -07:00
Alex Dale
6bc69d5005 Remove CORE_UTIL_EXPORT
[ Merge of http://go/wvgerrit/155070 ]

These functions are internal utilities and should not be exported from
our library.  IIRC, this was added to aid in Windows tests, but this is
no longer needed.

Bug: 236317198
Test: build_and_run_all_unit_tests.sh
Change-Id: I19beb35a15f0f87dc8f968e1dd5302aed9463e54
2022-08-19 14:38:55 -07:00
Alex Dale
381f879ff7 Added mutex protection for session_property_set_.
[ Merge of http://go/wvgerrit/154575 ]
[ Cherry-pick of http://ag/19498242 ]

There is a rare race condition experienced by some Android devices
where the a new client property set is being added while another is
being removed.  The C++ stl library does not provided thread
protection by default.

This CL adds a new mutex for the client property set map which prevents
multiple threads accessing the property sets concurrently.

Bug: 235238226
Test: GtsMediaTestCases on redfin
Change-Id: I32cf11bfb1332295ba1245071102ff0adc35259d
(cherry picked from commit aaa97a5d60)
(cherry picked from commit 6109ec6d66)
2022-08-10 21:34:32 +00:00
Alex Dale
dfcab07d14 Added mutex protection for session_property_set_.
[ Cherry-pick of http://ag/19216679 ]
[ Merge of http://go/wvgerrit/155370 ]

There is a rare race condition experienced by some Android devices
where the a new client property set is being added while another is
being removed.  The C++ stl library does not provided thread
protection by default.

This CL adds a new mutex for the client property set map which prevents
multiple threads accessing the property sets concurrently.

Bug: 235238226
Test: GtsMediaTestCases on redfin
Change-Id: I32cf11bfb1332295ba1245071102ff0adc35259d
(cherry picked from commit aaa97a5d60)
2022-08-01 22:12:36 +00:00
Alex Dale
a20ee5bc54 Update system time for OPK reboot tests
[ Merge of http://go/wvgerrit/154593 ]

This CL updates the initial time used for reboot tests to be
within the valid range used by OPK. Also, the fake clock is
now synced with every use of the TestHost's clock function.

Also, the OPK's system clock is no longer initialized to 0
because this caused some tests to set initial playback time
to 0. That broke code that assumed a time of 0 mean "never".

I also removed some log spam in the WTPI code.

Bug: 222353528
Bug: 236317198
Change-Id: Ibdbdb2440454b9cf561cd9ec65ca3e40cf5a8d93
2022-07-20 14:47:25 -07:00
TreeHugger Robot
3ad13cf1e9 Merge "Create test FileSystems in a platform-specific manner" 2022-07-13 23:08:56 +00:00
TreeHugger Robot
f77a06529e Merge "Fuzz Widevine AIDL drmFactory binder interface." 2022-07-13 17:15:03 +00:00
John "Juce" Bruce
0890fae039 Create test FileSystems in a platform-specific manner
(This is a merge of http://go/wvgerrit/153552.)

The correct way to create a FileSystem object for testing CdmEngine
depends on the platform. However, our code has historically just
instantiated a new FileSystem object using the default constructor. This
works fine for Android and has historically worked fine for the CE CDM
tests because they did not implement storage correctly. However, an
upcoming commit will fix the implementation of storage in the CE CDM
TestHost, causing tests that use a default FileSystem constructor to
fail. This patch adds a new platform-defined function that instantiates
per-origin test storage in a platform-correct way. For Android, it
continues to use the default constructor, while for CE CDM, it uses the
TestHost.

Bug: 193060708
Test: x86-64 w/ storage separated
Test: build_and_run_all_unit_tests.sh
Change-Id: I0a9b6a4d3943e053d51d6018e392b7f215f50642
2022-06-29 18:14:26 -07:00
John "Juce" Bruce
f558ae4244 Always store the usage table header in global storage
(This is a merge of http://go/wvgerrit/153551.)

On CE CDM, storage is split between global and per-origin storage, and
one type of storage cannot be used to access the other. (Though, until
an upcoming commit lands, the tests will allow it.) On Android, both
types of storage access the same filesystem. This means that code may
run fine on Android but fail on CE CDM.

The Usage Table Header code normally, explicitly accesses the header
file via global storage. However, a few code paths would try to access
it inconsistently via per-origin storage. This patch updates
StoreTable() to always use the global storage, similar to how
RestoreTable() already functions.

Test: x86-64 w/ storage separated
Test: build_and_run_all_unit_tests.sh
Bug: 236400786
Bug: 192297621
Change-Id: Ie84cef43a7ad169ca8ab701d73c087294ee29705
2022-06-28 19:04:00 -07:00
John "Juce" Bruce
b41eeac78c Always store the Prov 4.0 OEM cert in global storage
(This is a merge of http://go/wvgerrit/153550.)

On CE CDM, storage is split between global and per-origin storage, and
one type of storage cannot be used to access the other. (Though, until
an upcoming commit lands, the tests will allow it.) On Android, both
types of storage access the same filesystem. This means that code may
run fine on Android but fail on CE CDM.

The OEM Cert in Provisioning 4.0 is a global file that should only
exist once, but it was being accessed through the per-origin storage,
which would result in a separate OEM Cert being provisioned for each app
& origin on CE CDM. This patch changes the Prov 4.0 code to access it
through the global storage, using techniques similar to how the Usage
Table Header code does this.

Test: x86-64 w/ storage separated
Test: build_and_run_all_unit_tests.sh
Bug: 236400627
Change-Id: I301d250fc9543e62949a4d9fdcbdd109bd941384
2022-06-28 19:04:00 -07:00
Edwin Wong
a285b363d9 Fuzz Widevine AIDL drmFactory binder interface.
[Merged from http://go/wvgerrit/152150 ]

Test: build and run test

Bug: 226948319
Change-Id: I717d119cbf455fe76e4bb1f818d00141f4e7fa7c
2022-06-26 05:49:03 +00:00
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