Commit Graph

6683 Commits

Author SHA1 Message Date
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
e3697c6595 Fix oemcrypto_decrypt_cenc_fuzz null reference
[ Merge of http://go/wvgerrit/153669 ]

The oemcrypto_decrypt_cenc_fuzz fuzz test found a null reference error.
This adds a check to ensure that the input_buffer vector used for the
sample descriptions is not empty before attempting to access it.

Bug: 192310854
Bug: 236317198
Change-Id: If3909b01d3bc19434bbd5b6b77e7cd76182b2bdf
2022-08-19 14:38:33 -07:00
Alex Dale
490696322f Added mutex protection for session_property_set_. am: 381f879ff7 am: 5b5c0fd770
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/19561012

Change-Id: If29bd2021c3d451822a0cd483da15140f622d723
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-16 22:56:32 +00:00
Alex Dale
5b5c0fd770 Added mutex protection for session_property_set_. am: 381f879ff7
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/19561012

Change-Id: Iec56b526fd95cafbd09aae9894796c959924f48a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-16 21:45:05 +00: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
6a0d1ce668 Merge "Added mutex protection for session_property_set_." 2022-08-02 16:33:45 +00:00
Alex Dale
cc29f745f9 Re-enabled OEMCrypto fuzz tests
[ Merge of http://go/wvgerrit/153121 ]

`run_oemcrypto_fuzz_tests` script was disabled while OPK was
transitioning between v16 and v17.  Now that OPK is v17, the
fuzz tests can be re-enabled.

Some targets could not be built due to a missing header file.
`oemcrypto/ref/src/cppbor.cpp` was updated to include the missing
header.

Bug: 235414753
Bug: 229160033
Bug: 236317198
Test: run_oemcrypto_fuzz_tests
Change-Id: Ieeebae1f6d84c5735a669d44ea45875675fdb5a3
2022-08-01 15:20:05 -07: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
Cong Lin
2dfc3171f7 Fix the length of the extracted BCC
After a successful extraction, the vector of BCC should be resized to
the correct value.

This CL picks the change from http://ag/19196496, which fixes the bcc
size for our internal extraction tool.

Test: build and run extraction tool
Bug: 237029566
Change-Id: I0c73861e363215486a93abebac84da2ce49d43a8
2022-08-01 10:30:39 -07:00
Edwin Wong
ab5fd42968 Fix printUsage() typo in Widevine dumpsys hook.
Merged from http://go/wvgerrit/155149

Test:  adb shell dumpsys android.hardware.drm.IDrmFactory/widevine -o
  fail: verify correct usage is printed

Test: adb shell dumpsys android.hardware.drm::IDrmFactory/widevine
  fail: "Can't find service: android.hardware.drm::IDrmFactory/widevine"

Test: adb shell dumpsys android.hardware.drm.IDrmFactory/widevine
  success

Bug: 240289274
Change-Id: I609ac5b049614c53a4d21e75a7b9b22a61603be6
2022-07-26 22:26:40 +00:00
Alex Dale
2999e4588e Fix 31 ClangTidyBuild findings:
[ Merge of http://go/wvgerrit/151597 ]

* missing #include <string> for 'std::string' For more info see go/clang_tidy/checks/google3-build-missing-std-includes (25 times)
* missing #include <utility> for 'std::move' For more info see go/clang_tidy/checks/google3-build-missing-std-includes (3 times)
* missing #include <algorithm> for 'std::find_if' For more info see go/clang_tidy/checks/google3-build-missing-std-includes (2 times)
* missing #include <algorithm> for 'std::sort' For more info see go/clang_tidy/checks/google3-build-missing-std-includes

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/clang-tidy-bug for category ClangTidyBuild if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

Bug: 236317198
Change-Id: I28f7899b5cf0637be15833659f8ba0dd6ff3ab90
2022-07-20 14:47:43 -07:00
Alex Dale
4c36fb469b Fix 2 ClangTidyBuild findings:
[ Merge of http://go/wvgerrit/150489 ]

* missing #include <string> for 'std::string' For more info see go/clang_tidy/checks/google3-build-missing-std-includes (2 times)

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/clang-tidy-bug for category ClangTidyBuild if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/METADATA.
Anything wrong with the signup? File a bug at go/clrobot-bug.

Bug: 236317198
Change-Id: I9ccf0ce00ee3f6f7b3a2b6ec9dedeff578535217
2022-07-20 14:47:43 -07:00
Alex Dale
1a405a11a6 adding OEM_ENTITLEMENT key container type.
[ Merge of http://go/wvgerrit/148691 ]

This is a followup to OEM_CONTENT,
a custom key container that was added to Widevine server.

Bug: 193006094
Bug: 236317198
Change-Id: I82285e4e50f981e0cedf2adac5910643f34f8e46
2022-07-20 14:47:42 -07:00
Alex Dale
41d307ed9e Misc fixes for Windows
[ Merge of http://go/wvgerrit/152510 ]

Bug: 236317198
Change-Id: I67ac7d7c903ecfbb659595699c5bfe38f4d781df
2022-07-20 14:47:42 -07: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
Cong Lin
b08a8feeb3 Merge "Fix the length of the extracted BCC" 2022-07-20 17:23:30 +00:00
Lu Chen
22e1e8b3d4 Merge "Widvine remote provisioning HAL implementation" 2022-07-14 17:37:43 +00: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
Cong Lin
1f4385424e Fix the length of the extracted BCC
After a successful extraction, the vector of BCC should be resized to
the correct value.

Test: build and run extraction tool
Bug: 237029566
Change-Id: I41f39cb72bb1dc27d6d40f3c5ace5265271aab0e
2022-07-06 09:50:04 -07: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
4455aeceed Fix InstallTestRSAKey() for provision 4 tests
[ Merge of http://go/wvgerrit/153589 ]

Some unit tests call InstallTestRSAKey() a few times. In current
provision 2 with Keybox, the test RSA DRM key is hard coded. But for
provision 4, it will be generated by OEMCrypto.

When a test calls multiple times of InstallTestRSAKey(), we don't want
the key to be generated during each call, and we want to use the same
key in order for the decrytion to work.

The fix to cache the drm key once it is created for prov 4 tests.

Bug: 180530495
Bug: 236317198
Test: oemcrypto_test
Change-Id: I1b2d96a89e0619861492e6d9bc56862e2c440c86
2022-06-23 14:48:19 -07:00
Alex Dale
073f478239 Implement GetDeviceId for prov4
[ Merge of http://go/wvgerrit/150349 ]

The device id for prov4 is hash of the encoded device public key
(COSE_key).

Also replaced a few bug numbers if it is prov3 specific (not related to prov4).

Bug: 225216277
Bug: 236317198
Test: oemcrypto_test
Change-Id: Ica1c8579c0a3ef83c70f331283c9cce629c6bb3f
2022-06-23 14:48:19 -07: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
TreeHugger Robot
6ba729940f Merge "Add flag to disable CDM logging" 2022-06-18 23:32:27 +00:00
Cong Lin
decb9d32f4 Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324 am: b363f54f9e am: e483932fb0 am: 6d2b371b65
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: I1bd377bf8cefe7a760251267e42bde1b8dc5bf98
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 09:08:43 +00:00
Cong Lin
a4174f78da Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324 am: 7588d0baa1 am: 395251bd90 am: a3ad7f2719
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: If4fe2c8fd3275272067a6444a1db0ea620588f10
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 09:07:58 +00:00
Cong Lin
87198e8f1e Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324 am: b363f54f9e am: 0698bcdefe am: 7b52695632
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: I92875386804868c45cda907cb420656387290c96
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 09:07:21 +00:00
Cong Lin
6d2b371b65 Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324 am: b363f54f9e am: e483932fb0
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: I0fcf8b89af94d6db4b69bdf7db4bb65b5c21d45d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 08:50:16 +00:00
Cong Lin
a3ad7f2719 Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324 am: 7588d0baa1 am: 395251bd90
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: I5111003ccd9181e601bcdff1abcb3761cd3d6ef3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 08:49:44 +00:00
Cong Lin
7b52695632 Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324 am: b363f54f9e am: 0698bcdefe
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: I60680a436ee8133ebef3c57f37afaa2b55851162
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 08:49:10 +00:00
Cong Lin
0698bcdefe Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324 am: b363f54f9e
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: Id78fb4d41f4d7a9b7e090dec2a1d00952e65ebb5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 08:26:41 +00:00
Cong Lin
e483932fb0 Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324 am: b363f54f9e
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: Ib560ed98055a97ccaed658097b12c12577a9449f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 08:26:39 +00:00
Cong Lin
395251bd90 Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324 am: 7588d0baa1
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: If6f3ef93b5e626ebac886ea9606e3e90967da02e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 08:26:34 +00:00
Cong Lin
f529e0d563 Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324 am: 154a1db776
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: I0224f6540925ad4b16988afd8e2bd76a12771c49
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 08:26:02 +00:00
Cong Lin
b363f54f9e Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: Ibcdf7c29ad2392a2ee49873aacd5a8f831dbc251
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 08:10:52 +00:00
Cong Lin
154a1db776 Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: I59e227877aee30a0f0d1e755234f1913cf1903c6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 08:09:35 +00:00
Cong Lin
7588d0baa1 Add unit test for clear KCB in LS SDK 16.4 response am: 8c4c238324
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18973819

Change-Id: I85897585bd72d28afbd11edfcdf4854e758560bd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-18 08:08:58 +00:00