Commit Graph

5020 Commits

Author SHA1 Message Date
Alex Dale
8e090b47b8 Merge "Sync Android reference with CDM reference." into sc-dev 2021-03-22 20:22:42 +00:00
Rahul Frias
57ebb70fe7 Add certificate information to offline licenses
[ Merge of http://go/wvgerrit/120508 ]

Offline licenses will now store the DRM certificate information. This
allows for expired certificates to be deleted and replaced without
losing the ability to use offline licenses.

Bug: 169740403
Test: WV unit/integration tests
      DeviceFilesTest.RetrieveLicenses
      DeviceFilesTest.StoreLicenses
Change-Id: Ic0de6328d32e0000d1b58c81019e6c2227278cc4
2021-03-21 19:11:06 -07:00
Rahul Frias
f6b4d140f4 Add comments to clarify client and service clock times
[ Merge of http://go/wvgerrit/120510 ]

* Added some comments to clarify which clock times are computed at the
  client and at the provisioning service. More detail is present in the
  device_files.proto
* Moved helper methods |SetDeviceCertificate| and
  |ExtractFromDeviceCertificate| from class methods to anonymous
  namespace
* Removed some commented out code

Bug: 169740403
Test: WV unit/integration
Change-Id: Ic263f3dfe296fff6d9b5380b2e7c663d87022cb2
2021-03-21 14:40:12 -07:00
Rahul Frias
615a1e9f64 Have system clocks return wall time
[ Merge of http://go/wvgerrit/120445 ]

Switch TestHost and FakeClock to use chrono::system_clock (wall time)
rather than chrono::steady_clock (ticks since boot time).

Bug: 183160800
Test: CE CDM tests
Change-Id: I6ef4c02c01ff96453847ee8f42e6037c298866b5
2021-03-21 13:34:05 -07:00
Alex Dale
3050d95f6f Merge "Added unittests for WV CRC-32 implementation." into sc-dev 2021-03-19 23:14:00 +00:00
Rahul Frias
c586f7e62b Merge changes from topic "b169740403_2" into sc-dev
* changes:
  Verify DRM certificate validity
  Extract creation and expiration times from DRM cert
  Allow two DRM certificates for each identifier
2021-03-19 21:26:33 +00:00
Rahul Frias
b21be96b1b Verify DRM certificate validity
[ Merge of http://go/wvgerrit/120123 ]

DRM certificate creation and expiration times are now validated.

* New DRM (default) certificates will have an expiration time specified
by the provisioning service.

When stored, the client will include the time the certificate was
received. This allows for expiration calculation to occur when client
and provisioning service clocks are out of sync.

When read out, creation, expiration and acquisition times are
validated. The certificate is checked for expiry by making sure
that the time at the client since the license was acquired is not
greater than the expiration period. The time information stored at the
client may be tampered with. The license service will perform an
expiration check and reject the license request if tampered with.
The expiration time may be set to never expires/unlimited. This is not
a valid value for creation or acquisition time.

* Pre-existing (legacy) certificates from upgrading devices will not
have an expiration time set by the provisioning service. Instead
the client will calculate an expiration time 6 months with + or -
a random two month period in the future. This is stored along with the
certificate.

When read out, if no expiration time has been set by the client, one
will be calculated and written out. The certificate will be declared as
valid. If a client calculated expiration time is present, the
certificate will be validated. In case of tampering, the license service
can reject license requests and force reprovisioning when appropriate.

* ATSC certificates will continue to not have an expiration time.
No additional validation is required.

Other changes for non-ATSC licenses involve managing both default and
legacy certificate co-existance. When checking for DRM certificates,
the default certificate is attempted first. This is followed by a check
for the legacy certificate, if the default certificate is not present.

Bug: 169740403
Test: WV unit/integration tests
      DeviceFilesTest.StoreCertificateInvalidParams
      DeviceFilesTest.RetrieveAtscCertificate
      DeviceFilesTest.RetrieveAtscCertificateNotFound
      DeviceFilesTest.RetrieveCertificateInvalidParams
      DeviceFilesTest.RetrieveLegacyCertificateWithoutExpirationTime
      DeviceFilesTest.RetrieveLegacyCertificateWithClientExpirationTime
      DeviceFilesTest.RetrieveLegacyExpiredCertificateByClientExpirationTime
      DeviceFilesTest.RetrieveLegacyCertificateInvalidClientExpirationTime
      DeviceFilesTest.RetrieveCertificateWithoutKeyType
      DeviceFilesTest.RetrieveDefaultCertificate
      DeviceFilesTest.RetrieveDefaultCertificateNeverExpires
      DeviceFilesTest.HasCertificateAtsc
      DeviceFilesTest.HasCertificateDefault
      DeviceFilesTest.HasCertificateLegacy
      DeviceFilesTest.HasCertificateNone
      CertificateTest.StoreCertificateTest.DefaultAndLegacy/*
      CertificateTest.RetrieveLegacyCertificateTest.ErrorScenarios/*
      CertificateTest.RetrieveDefaultCertificateTest.ErrorScenarios/*

Change-Id: I7dbec7555fbd493c1ec61c6bb5d9428a2405b1fd
2021-03-19 02:49:20 -07:00
TreeHugger Robot
640e8727dc Merge "Annotate fallthrough in OEC Testbed" into sc-dev 2021-03-19 07:41:24 +00:00
Rahul Frias
9a350eddbd Extract creation and expiration times from DRM cert
[ Merge of http://go/wvgerrit/119843 ]

Creation and expiration times are extracted from the device DRM
certificate. They are reported as
 * -1 if not set in the proto
 * 0 if unlimited
 * positive number otherwise

Bug: 169740403
Test: WV unit, integraiton tests
Change-Id: I9463954dfeb82b6a88ff5d608ed74d20f2424e83
2021-03-18 23:59:21 -07:00
Rahul Frias
3b15087627 Allow two DRM certificates for each identifier
[ Merge of http://go/wvgerrit/119684 ]

This allows for a default DRM certificate that includes an expiration
time and a legacy one without for each app+origin specific identifier.
Existing offline licenses/secure stops are not associated with a
certificate, and so we cannot delete legacy certificates even after
fetching a new one. New offline licenses/secure stops will be associated
with certificate information, so we will not have this problem going
forward.

Bug: 169740403
Test: WV unit/integration tests
Change-Id: I0f08f6bf98775fd43927243dc4a9f75f21bfbbcc
2021-03-18 23:58:46 -07:00
Alex Dale
2cf17c34fe Merge "Added unittests for OEM Certificates." into sc-dev 2021-03-19 01:29:23 +00:00
TreeHugger Robot
d1db6df88b Merge "Release crypto resources when provisioning fails" into sc-dev 2021-03-18 23:27:57 +00:00
TreeHugger Robot
9f574be636 Merge "Log license request and response" into sc-dev 2021-03-18 23:27:33 +00:00
Alex Dale
6c58348bb8 Merge "Wrapped OEM Certificate." into sc-dev 2021-03-18 21:15:32 +00:00
Rahul Frias
edf9ad5b90 Correct test data member name
[ Merge of http://go/wvgerrit/119645 ]

Bug: 169740403
Test: WV unit/integration tests
Change-Id: I2a3e82869e3a45112e8b15eea4ac668980c3eb4d
2021-03-16 13:29:30 -07:00
Rahul Frias
dbb1671e39 device_files proto changes for Expiring DRM certificates
[ Merge of http://go/wvgerrit/119644 ]

This change includes additional fields in DeviceCertificate, License and
UsageInfo.

New DRM certificate will include a creation and expiration time.
In addition acquisition_time_seconds will allow the client to calulate
expiration time even when client and provisioning service clocks
are not in sync.

expiration_time_seconds will allow clients to expire DRM certificates
that do include an expiration time. A random value within a window
(4-8 months after update) will be calculated to avoid
a provisioning storm.

Drm certificate will be added to offline licenses. In a future release,
licenses will be removed on expiry and the certification information
that needs to be sent to the license service will be reduced.
This should reduce space overhead.

UsageInfo will use a certificate cache in case multiple usage info
entries use the same DRM certificate.

Bug: 169740403
Test: WV unit/integration tests
Change-Id: I2f34a1df526fa8168162a1b1ea930a2f257b87cd
2021-03-16 13:10:53 -07:00
TreeHugger Robot
6ee9f49e5c Merge "Address compilation warnings" into sc-dev 2021-03-13 02:43:45 +00:00
Alex Dale
16c704fa09 Android tests call exit() when complete.
[ Merge of http://go/wvgerrit/119804 ]

The coverage framework used by Android requires the process to call
exit() for coverage information to be dumped after the tests.

Android unit tests have been adapted to use the a new main module.
The core test_main.cpp used by integration tests has been updated to
call exit().

Bug: 138941105
Test: Linux and Android unittests
Change-Id: Ifffc7b8290c50dffe527738a36547c1d2fb90bd3
2021-03-12 16:22:20 -08:00
Rahul Frias
a828bf5f58 Annotate fallthrough in OEC Testbed
[ Merge of http://go/wvgerrit/119230 ]

This patch adds an annotation to the one place in the codebase where we
intentionally fall through between switch statement cases, in order to
appease stricter compilers.

Bug: 182058081
Test: compile, WV unit/integration tests
Change-Id: I004a6a6e61681fcf22c6bf25d9b0284b8b64e776
2021-03-12 00:58:52 -08:00
Rahul Frias
9f918bc16b Merge "Update drm_certificate.proto" into sc-dev 2021-03-11 18:57:36 +00:00
Rahul Frias
094fabed5a Address compilation warnings
[ Merge of http://go/wvgerrit/119523 ]

Bug: 182299187
Test: compile vendor/widevine/libwvdrmengine
Change-Id: I39d1b62a3237bfb9163a7e157b871f22e3fec394
2021-03-10 18:49:57 -08:00
Rahul Frias
83a85430e3 Release crypto resources when provisioning fails
[ Merge of http://go/wvgerrit/119564 ]

This closes a crypto session when the provisioning request fails. We
cannot be as eager when handling the response as the app may have
multiple simultaneous provisioning attempts in flight. In this case
all provisioning responses except the one associated with the last
request will fail. If we close the session on error, even the one
associated with the last request may fail.

Bug: 180986725
Test: WV unit/integration tests
Change-Id: Ic3d33a374e442b5bf040e345bed829d91c4ef1dc
2021-03-10 18:12:09 -08:00
Rahul Frias
b8049e1f20 Log license request and response
[ Merge of http://go/wvgerrit/119563 ]

This also increases the max log size from 1024 to 5120

Bug: 181642154
Test: WV unit/integration tests
Change-Id: Ifae90354dad1165f4d9fa3c9fe33a4dc14df1270
2021-03-10 17:58:15 -08:00
Edwin Wong
4310a64a48 [automerger skipped] [RESTRICT AUTOMERGE] Fix potential decrypt destPtr overflow. am: f3ad627bcb am: 18065ce373 -s ours am: 49279fb200 am: 45dc1d106a am: d6226efa60 -s ours
am skip reason: subject contains skip directive

Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/13462543

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id7a7aeb5963e74c3a263340bbab089aa42e49a2c
2021-03-10 22:37:39 +00:00
Edwin Wong
08a80add55 [automerger skipped] [RESTRICT AUTOMERGE] Fix potential decrypt destPtr overflow. am: f3ad627bcb am: 18065ce373 -s ours am: 49279fb200 am: 242713098f -s ours
am skip reason: subject contains skip directive

Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/13462543

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I7a37930fc220495957e017e204d95e32ade6d282
2021-03-10 21:57:10 +00:00
Edwin Wong
d6226efa60 [automerger skipped] [RESTRICT AUTOMERGE] Fix potential decrypt destPtr overflow. am: f3ad627bcb am: 18065ce373 -s ours am: 49279fb200 am: 45dc1d106a
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/13462543

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I88ba0b965d2d546ba090e1b138846b997744dece
2021-03-10 21:53:38 +00:00
Edwin Wong
242713098f [automerger skipped] [RESTRICT AUTOMERGE] Fix potential decrypt destPtr overflow. am: f3ad627bcb am: 18065ce373 -s ours am: 49279fb200
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/13462543

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I75d982f8a96803bfdf6ff9bd5807d802d80e04c6
2021-03-10 21:36:27 +00:00
Edwin Wong
45dc1d106a [automerger skipped] [RESTRICT AUTOMERGE] Fix potential decrypt destPtr overflow. am: f3ad627bcb am: 18065ce373 -s ours am: 49279fb200
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/13462543

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I0a8f36599fe984fedf236f6240fd1f08bf99f36d
2021-03-10 21:13:54 +00:00
Edwin Wong
49279fb200 [automerger skipped] [RESTRICT AUTOMERGE] Fix potential decrypt destPtr overflow. am: f3ad627bcb am: 18065ce373 -s ours
am skip reason: subject contains skip directive

Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/13462543

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ia1bce0f38c0ab07f1028e9ecd0f38b78b8de0d77
2021-03-10 20:56:24 +00:00
Edwin Wong
18065ce373 [RESTRICT AUTOMERGE] Fix potential decrypt destPtr overflow. am: f3ad627bcb
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/13462543

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I36fb97d8855ef97a15c7d9d553efa874a2df7c84
2021-03-10 20:12:35 +00:00
Rahul Frias
0cf99f685f Update drm_certificate.proto
[ Merge of http://go/wvgerrit/118563 ]

Sync with the latest version of drm_certificate.proto to add in
certificate expiry time. Add in signed_drm_certificate.proto and remove
messages from device_certificate.proto.

SignedDrmDeviceCertificate and DrmDeviceCertificate are now named
SignedDrmCertificate and DrmCertificate. This necessitated non-proto
changes.

Bug: 169740403
Test: WV unit/integration tests
Change-Id: Ie5969ac7217a25eb075a41df59b77da2becd4545
2021-03-09 14:57:47 -08:00
Alex Dale
d40302f3e3 Merge "Added unittests for reference RSA implementation." into sc-dev 2021-03-09 22:19:51 +00:00
Edwin Wong
76f39ddb08 [RESTRICT AUTOMERGE] Fix WVCryptoPlugin use after free vulnerability.
The shared memory buffer used by srcPtr can be freed by another
thread because it is not protected by a mutex. Subsequently,
a use after free AIGABRT can occur in a race condition.

SafetyNet logging is not added to avoid log spamming. The
mutex lock is called to setup for decryption, which is
called frequently.

The crash was reproduced on the device before the fix.
Verified the test passes after the fix.

Test: sts
  sts-tradefed run sts-engbuild-no-spl-lock -m StsHostTestCases --test android.security.sts.Bug_176495665#testPocBug_176495665

Test: push to device with target_hwasan-userdebug build
  adb shell /data/local/tmp/Bug-176495665_sts64

Bug: 176495665
Bug: 176444161
Change-Id: Ie1aca0ceacb4b7a1b6e473b823541607a36d8cb4
Merged-In: If62b73a9c636048f942a2fc63a13b5bfd1e57b86
2021-03-09 17:10:54 +00:00
Edwin Wong
596d8bf4cc Fix WVCryptoPlugin use after free vulnerability.
The shared memory buffer used by srcPtr can be freed by another
thread because it is not protected by a mutex. Subsequently,
a use after free AIGABRT can occur in a race condition.

SafetyNet logging is not added to avoid log spamming. The
mutex lock is called to setup for decryption, which is
called frequently.

The crash was reproduced on the device before the fix.
Verified the test passes after the fix.

Test: sts
  sts-tradefed run sts-engbuild-no-spl-lock -m StsHostTestCases --test android.security.sts.Bug_176495665#testPocBug_176495665

Test: push to device with target_hwasan-userdebug build
  adb shell /data/local/tmp/Bug-176495665_sts64

Bug: 176495665
Bug: 176444161
Change-Id: If62b73a9c636048f942a2fc63a13b5bfd1e57b86
2021-03-08 21:37:42 -08:00
Alex Dale
23f7cd60a7 Sync Android reference with CDM reference.
The sc-dev branch on Android is out of sync with several important
changes on the CDM master branch.  This changes copies several CLs.

[ Merge of http://go/wvgerrit/104524 ]

OEMCrypto unittest: generic crypto APIs

Add unit tests to verify that generic crypto APIs do not crash for large
input buffer lengths and signature lengths.

[ Merge of http://go/wvgerrit/106583 ]

Fix secure buffer tests in OEMCrypto testbed

The secure buffers were not being used correctly in the testbed, and
were failing OEMCryptoMemoryCopyBufferForHugeBufferLengths.

[ Merge of http://go/wvgerrit/109603 ]

Reject block_offsets of 16 or greater in OEC Ref

This is a potential security hole. We will be enforcing that OEMCrypto
rejects this in an upcoming test, so the Ref must be updated to reject
it.

[ Merge of http://go/wvgerrit/110165 ]

Fix Format String Signedness

See above for full description.

[ Merge of http://go/wvgerrit/111784 ]

Fix heap overflow test in L3 and OEMCrypto ref

Check the length of wrapped_rsa_key_length before casting to
WrappedRSAKey struct.

[ Merge of http://go/wvgerrit/113563 ]

Reword "blacklisted" to "forbidden"

[ Merge of http://go/wvgerrit/113583 ]

Use error code from RAND_bytes

The return code from RAND_bytes was not used correctly.

[ Merge of http://go/wvgerrit/113644 ]

Check for buffer overflow when computing subsample size

The test DecryptCENCForNumBytesClearPlusEncryptedOverflowsSize
cleverly picks num_bytes_clear + num_bytes_encrypted = 1 after integer
overflow. This is in the refernce code, level 3, and odkitee.

[ Merge of http://go/wvgerrit/113683 ]

OEMCrypto reference code: respect analog flags for clear buffers

The reference code should honor the analog_display_active flag for
both clear and secure buffers.

[ Merge of http://go/wvgerrit/114883 ]

Add size check for IV in OEMCrypto APIs

IV is supposed to be 16 bytes but the size is never checked before iv
gets used in LoadProvisioning.

Bug: 145026457
Bug: 147569428
Bug: 159847851
Bug: 162372059
Bug: 169278035
Bug: 169980065
Bug: 173460694
Bug: 173994023
Bug: 174523584
Bug: 175001473
Bug: 175041667
Test: No compiled files changed
Change-Id: If0ccd1cd3a56f72eedd2a6cb202a34bc7b43ca0d
2021-03-08 19:45:05 -08:00
Alex Dale
eb56801fdb Added unittests for WV CRC-32 implementation.
[ Merge of http://go/wvgerrit/115549 ]

Our WV CRC-32 implementation is for CRC-32/MPEG-2 (rather than the
documented CRC-32-IEEE).  The OEMCrypto document has been updated to
reflect the reference implementation.

Test: oemcrypto_partner_tests
Bug: 135283522
Change-Id: Iea8fc4ec500aec96bdb27102c51dfcca77d7bffb
2021-03-08 19:45:05 -08:00
Alex Dale
b3b11ca1ea Added unittests for OEM Certificates.
[ Merge of http://go/wvgerrit/115548 ]

Create a small set of unittests to verify the functionality of OEM
Certificate.

This adds a test OEM Public Certificate and OEM Private Key.

Bug: 135283522
Test: oemcrypto_unittests
Change-Id: Iaa634543d9cb5005d91f1e7c528bf05b2b0c4d68
2021-03-08 19:45:05 -08:00
Alex Dale
10370fb66e Wrapped OEM Certificate.
[ Merge of http://go/wvgerrit/115547 ]

The functionality of OEM Certificates are being abstracted away.  This
is to help with the integration of ECC-based DRM certificates and in
preparation for ECC-based OEM Certificates.

Summary of OEM Certificate functionality:
- Parsing OEM Public Certs (PKCS7 signedData)
- Parsing OEM Private Key (PKCS8 PrivateKey)
- Public cert getter
  - Implements most of OEMCrypto_GetOEMPublicCertificate()
- Certificate validation
  - Implements most of OEMCrypto_IsKeyboxOrOEMCertValid() for OEM
    Certificates
  - Checking public-private key pairing

Bug: 135283522
Test: Future CL
Change-Id: Ib9580bd83641865c53dd829ff09b142bf111768c
2021-03-08 19:44:58 -08:00
Alex Dale
5ad2bd7ba3 Added unittests for reference RSA implementation.
[ Merge of http://go/wvgerrit/115546 ]

Included a set of unittests for RSA keys which ensure client-server
RSA operations work as expected.

Bug: 135283522
Test: oemcrypto_unittests
Change-Id: I8363a82403d0780f3074a05c64c804e700c2b779
2021-03-08 19:24:48 -08:00
Edwin Wong
9c278174c8 [RESTRICT AUTOMERGE] Fix WVCryptoPlugin use after free vulnerability.
The shared memory buffer used by srcPtr can be freed by another
thread because it is not protected by a mutex. Subsequently,
a use after free AIGABRT can occur in a race condition.

SafetyNet logging is not added to avoid log spamming. The
mutex lock is called to setup for decryption, which is
called frequently.

The crash was reproduced on the device before the fix.
Verified the test passes after the fix.

Test: sts
  sts-tradefed run sts-engbuild-no-spl-lock -m StsHostTestCases --test android.security.sts.Bug_176495665#testPocBug_176495665

Test: push to device with target_hwasan-userdebug build
  adb shell /data/local/tmp/Bug-176495665_sts64

Bug: 176495665
Bug: 176444161
Change-Id: Ie1aca0ceacb4b7a1b6e473b823541607a36d8cb4
2021-03-08 15:54:00 -08:00
Rahul Frias
9ab837c78a Integration test for license duration with renewal
This is a squash of several different CLs with chnages only affecting
duration_use_case_test.cpp

* Integration test for license duration with renewal

[ Merge of http://go/wvgerrit/117263 ]

Bug: 180067457

* Add test for infinite renewal

[ Merge of http://go/wvgerrit/107743 ]

This adds a test that verifies an infinite renewal is processed
correctly.

Bug: 162516965
Bug: 170355696
Bug: 169213621
Bug: 166728158

* Add more time to CdmUseCase_Streaming test

[ Merge of http://go/wvgerrit/114146 and http://go/wvgerrit/114147 ]

The duration tests CdmUseCase_Streaming.Case3 was flaky on the
buildbot for platforms with a real clock because there was only room
for 1 second of fudge at the end of playback -- i.e. the rental window
ended at 35s, but the last playback was 34s.

Bug: 175741647

* Set renewal server on command line for tests

[ Merge of http://go/wvgerrit/110903 ]

This CL adds the ability to set the renewal server on the command
line, and adds some comments to the build scripts' README file to
explain how to test a server rollout.

Bug: 173031207

* Change duration test fudge from 1 to 2

[ Merge of http://go/wvgerrit/112143 ]

Some duration tests are flakey. Let's see if this cleans them up
enough.

Bug: 175741647

* Correct some grammar

[ Merged from http://go/wvgerrit/111824 and http://go/wvgerrit/112063 ]

* Add license duration test

[ Merge of http://go/wvgerrit/109143 ]

This adds a license duration test that behaves the same as a rental
duration test. We do not encourage content providers to do this, but
it is reasonable that legacy licenses should work.

Bug: 172099147

* Shorten duration tests

[ Merge of http://go/wvgerrit/108664 ]

This CL tweaks some of the times in the duration use case tests so
that they take less time to run.

These changes the CdmUseCase test time from six and half hours to 3
and a quarter. A 50% savings!

Bug: 170746277

* Improve logging and edge cases in duration tests

[ Merge of http://go/wvgerrit/108663 ]

This cleans up some logging, and handles some edge cases on renewals
when the renewal request round trip overlaps the cutoff time.

Bug: 170746277

* Remove extra cutoff computations

[ Merge of http://go/wvgerrit/106783 ]

The duration tests originally tried to keep track of when the timer
would have gone off if the test was allowed to continue. This proved
impracticle, so the extra parameter has been removed. The tests still
closely match the documented use cases.

Bug: 169453960

* But not too lenient

[ Merge of http://go/wvgerrit/107943 ]

Previously, the duration tests were modified to allow playback to
continue in some cases. See the documentation or code for a list of
these cases. However, the tests had been modified to force playback to
continue in these cases.

This is not desired: in some cases, v15 devices can restrict playback
as requested. This CL changes the tests so that playback restriction
is allowed.  In other words, we no longer force older devices to fail
the test.

Bug: 169255315

* Make some integration tests lenient

[ Merge of http://go/wvgerrit/106843 ]

This allows devices that have OEMCrypto version < v16 or do not
support usage tables to continue playback for an offline license after
the playback window has expired.

Bug: 169582310
Test: duration_use_case_test.cpp

* Add Renewal Use Case tests

[ Merge of http://go/wvgerrit/105826 and http://go/wvgerrit/103784 ]

This CL adds several integration tests that match the duration use
cases with renewals. The test classes are designed for the core cdm,
but the test cases match those found in
oemcrypto/odk/test/odk_timer_test.cpp.

Test: tests pass except for documented bugs.
Bug: 161463952
Change-Id: Ib4775d48490cf150b89aeb2cc64e01a1428f0ab5
2021-03-08 15:36:49 -08:00
Rahul Frias
3176f5f66f An integration test for secure buffers
This is a squash of several different CLs with changes only affecting
policy_integration_test.cpp

* An integration test for secure buffers

[ Merge of http://go/wvgerrit/113905 ]

This extends the previous CL that loads a license that has a key that
requires a secure buffer. It now creates a secure buffer and tries to
decrypt to it.

Bug: 38004627

* Test loading license requiring secure buffer

[ Merge of http://go/wvgerrit/113903 ]

This adds a policy test to verify we can load a license that requires
hardware secure buffers.

Bug: 38004627
Test: WV  unit/integration tests
Change-Id: I1cc0b607ddf5b43fc6b7ba648f3c78d6163e14e9
2021-03-08 15:31:18 -08:00
Rahul Frias
0831e575ba Add Duration Use Case integration tests
Cherry pick from http://go/wvgerrit/102986, rvc-dev branch of
http://go/wvgerrit/105825, rvc-widevine-release of http://go/ag/12561661

Most of this CL was merged in http://go/ag/12967146 except this
correction of ordering in test listing.

Test: Ran the tests against v16 OEMCrypto. Some fail against v15.
Bug: 161463952
Change-Id: I3fa803a645c745dfce42ad15b5ceec9f28aab630
2021-03-08 15:30:08 -08:00
Rahul Frias
a9f051faac Fix test sleep on iOS.
[ Merge of http://go/wvgerrit/117203 ]

clock_settime isn't available on iOS (even though settimeofday is).  But
we can't change the system time on iOS anyway, so this just disallows
iOS.

Bug: 182058081
Test: WV unit/integration tests
Change-Id: I96e5b6634803bd4e6aaf5cc6d64f4441296247d4
2021-03-08 15:28:48 -08:00
Rahul Frias
9a659e31c1 Restrict a2b_hex to 2000 bytes.
[ Merge of http://go/wvgerrit/109144 ]

Because it doesn't help anybody when a buffer overflow test chokes the
logger.

Bug: 182058081
Test: Ran unit tests with verbose logging
Change-Id: Ibcb3379b9eb9bdd94a8959b977e8de32ea116859
2021-03-08 15:27:01 -08:00
Rahul Frias
616a9b38dc Return error when test initialization fails
[ Merge of http://go/wvgerrit/116243 ]

Currently if a command line argument is not understood, all tests are
skipped and the test suite passes.

Bug: 182058081
Test: WV unit/integration tests
Change-Id: I9725a9ed9446f15f08372e68c7a25dffd99c7cef
2021-03-08 15:25:50 -08:00
Rahul Frias
50efa73e34 Set renewal server on command line for tests
[ Merge of http://go/wvgerrit/110903 ]

This CL adds the ability to set the renewal server on the command
line, and adds some comments to the build scripts' README file to
explain how to test a server rollout.

Bug: 173031207
Test: WV unit/integration tests
Change-Id: Ibe71e77469c94601627fb85a1ad4654553d3eb1a

Change-Id: I7e9bfc873c78e26c0cece113dc8a3d08cd9163db
2021-03-08 15:24:27 -08:00
Rahul Frias
24e4c33262 Fix deprecated and printf warnings.
[ Merge of http://go/wvgerrit/118703 ]

Bug: 182058081
Test: WV unit/integration tests
Change-Id: I2d8995b8aab864a2d2f5161d12a473d34e67bad4
2021-03-08 15:22:56 -08:00
Rahul Frias
71cf45fb3f Throw DeniedByServerException when provisioning detects a revoked device
[ Merge of http://go/wvgerrit/117267 ]

This includes some clang-format corrections that were missed in the
original merge from wvgerrit.

Bug: 174174765
Test: WvCdmRequestLicenseTest.ProvisioningRevocationTest,
      WV unit/integration tests
Change-Id: Ifd16ab51eb89530fa5e0b91acc42f30864246d38
2021-03-06 23:53:49 -08:00
Alex Dale
e52086c283 Include DRM key type to SessionMetrics.
[ Merge of http://go/wvgerrit/111903 ]

CDM metrics has been updated to include the DRM key type.  The CDM
session records the key type when the wrapped DRM key is successfully
loaded into an OEMCrypto session.

Now that the API refers to a general DRM key rather than an RSA key,
the timer metric for loading the DRM key has been renamed on the client
to reflect this.

Test: Metric unit tests
Bug: 140813486
Change-Id: I9069f13ac7c979cc8556e08591e1cf8f623d0a84
(cherry picked from commit 47fc031576)
Merged-In: I9069f13ac7c979cc8556e08591e1cf8f623d0a84
2021-03-06 23:47:30 -08:00