Commit Graph

1564 Commits

Author SHA1 Message Date
Alex Dale
023b06eded Check for open session when initializing usage table.
[ Merge of http://go/wvgerrit/122984 ]

There was an issue encountered by some vendors with how the usage
table was initialized on some devices.  Previously, the CDM would
open an OEMCrypto session first, then initialize the usage table
(loading existing or creating a new one).  On these devices,
OEMCrypto_CreateUsageTableHeader() and OEMCrypto_LoadUsageTableHeader()
would fail if there were any open sessions.

This CL changes the initialization process to create/load the usage
table before opening an OEMCrypto session.

This change also lays the ground work for another usage table fix
to address GTS tests failure.

In the process, several of the functions for the usage table have been
split up into smaller chunks of code.  This required additional changes
to the usage table unittest to keep them up to date.

Bug: 169195093
Bug: 180639135
Test: Linux unittests and MediaDrmTest
Change-Id: Ifbf35f5d8cff5b89fea9b16edb998c84803f4fbe
2021-05-19 10:39:51 -07:00
Rahul Frias
bb0b6b4ba5 Merge "Disallow the ability to load offline licenses more than once" into sc-dev 2021-05-07 22:21:03 +00:00
TreeHugger Robot
4057559ae5 Merge "Report Rental duration remaining" into sc-dev 2021-05-01 00:50:13 +00:00
TreeHugger Robot
b7662fcbf2 Merge "Use Usage information from OEMCrypto on clock rollback" into sc-dev 2021-04-30 19:18:35 +00:00
Rahul Frias
2404500ceb Report Rental duration remaining
[ Merge of http://go/wvgerrit/124063 ]

LicenseDurationRemaining used to indicate the minimum of rental or
license duration till OEMCrypto v16. OEMCrypto v16 onwards it began
reporting rental duration alone.

This is confusing for app developers and content partners. Keeping
LicenseDurationRemaining as apps may depend on it but adding
RentalDurationRemaining for clarity.

Bug: 186838303
Test: WV unit/integration tests, WvCdmRequestLicenseTest.QueryKeyStatus
Change-Id: I6c507150a0945ee36716b4da189f5741b092c0ec
2021-04-30 04:52:39 -07:00
Rahul Frias
0921b04e41 Disallow the ability to load offline licenses more than once
[ Merge of http://go/wvgerrit/123263 ]

In b/65839890 we discovered that an android app loaded an offline
license more than once in a session. We did not intend to allow
this behavior but did not prohibit it. OEMCrypto v16 disallowed
this behavior at the OEMCrypto level but we worked around it
within the CDM to maintain the bad behavior. Now that we have confirmed
that the app no longer relies on that behavior, we are reverting
the CDM workaround.

Bug: 161865160
Test: WV unit/integration test, GtsMediaTestCases
      Amazon, Netflix, Google TV streaming and offline playback.
Change-Id: I31254e4c13b81587f88c6c684d08d5aa5c18e39d
2021-04-29 16:20:30 -07:00
Alex Dale
0579fe805e Clean up other core CDM logs.
[ Merge of http://go/wvgerrit/122613 ]

Further log clean up in the core CDM code.
- Changed several INFO logs to DEBUG and VERBOSE
- Added more identifiers to the DEBUG logs to help match resource
  associations
- Added more enum-to-string functions
- Unknown enum values will be formatted to contain their numeric
  value

Key areas improved are the UsageTableHeader and CdmSession.

Bug: 183576879
Test: CE CDM unittests
Change-Id: I2d11e714d419e0736d3e2f7a7668e8d36d7ef449
2021-04-28 20:39:21 -07:00
Robert Shih
85afe8c0b0 Merge "metrics: set OEMCrypto initialization errors correctly" into sc-dev 2021-04-28 21:31:23 +00:00
Robert Shih
7a061b503f Merge "Update Android WVCdm version to 16.1.0" into sc-dev 2021-04-27 20:59:28 +00:00
Rahul Frias
9b3e37b038 Merge "Address CE CDM code review comments" into sc-dev 2021-04-27 20:27:35 +00:00
TreeHugger Robot
03dff71bd8 Merge changes I6dd829f4,Id8384c58,I9228b9cc,I744a1e89 into sc-dev
* changes:
  Fix CDM Builds w/ OEMCrypto_ERROR_INVALID_ENTITLED_KEY_SESSION
  Fix unused param warnings in oemcrypto fuzz test
  Add http socket tests to other tests
  Turn on ODK tests in CE CDM test and fix test helper
2021-04-27 19:20:34 +00:00
Robert Shih
3a503278e6 Update Android WVCdm version to 16.1.0
TODO: update VersionNumberTest.VersionNumberChangeCanary

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

Bug: 183073374
Test: GtsMediaTestCases
Change-Id: I1773416b6f3f212bead5e6b7749da52883041d07
2021-04-26 12:00:16 -07:00
Rahul Frias
4c4e746e57 Replace DeviceFiles::LicenseState with CdmOfflineLicenseState
[ Merge of http://go/wvgerrit/123003 ]

Bug: 160006474
Test: WV unit/integration tests
Change-Id: Ied813f58405fcac44f0543f715ab2175129bbf9c
2021-04-24 00:30:20 -07:00
Rahul Frias
46a3f6c608 Merge "Correct request_license_test failures" into sc-dev 2021-04-24 01:03:49 +00:00
Rahul Frias
c21d40c68f Address CE CDM code review comments
Undoes a change to the buffer size from http://ag/13865723

Bug: 184813991
Test: WV unit/integration tests
Change-Id: I40cf786f149626ff65a3362020b3da859bb86159
2021-04-23 12:26:34 -07:00
Fred Gylys-Colwell
ebb7d45a25 Fix CDM Builds w/ OEMCrypto_ERROR_INVALID_ENTITLED_KEY_SESSION
Merge from Widevine repo of http://go/wvgerrit/108224

A recent Copybara merge to master broke CDM builds by introducing a
new OEMCrypto error code. This patch adds it to the test printers so
that the build can pass again.

Bug: 185597829
Test: CE CDM Build
Change-Id: I6dd829f4c618c9ebec937cf711ff57b7f1678994
2021-04-23 10:11:48 -07:00
Fred Gylys-Colwell
5a58b6d8d2 Add http socket tests to other tests
Merge from Widevine repo of http://go/wvgerrit/122224

This CL removes the separate main() in http_socket_test that
allowed the user to set the server on the command line.  I
don't think anybody was using this, and it conflicted with
our desire to include this suite of tests with the other CE
CDM tests running on Luci.

test: ran http_socket_test
bug: 118657876
Change-Id: I9228b9cc97a0af2afd1bb4a99bc40b88ce956d67
2021-04-23 10:11:48 -07:00
Rahul Frias
87e84d5498 Use Usage information from OEMCrypto on clock rollback
[ Merge of http://go/wvgerrit/123103 ]

This corrects setting of first and last playback times stored by the
CDM on rollback. Earlier usage information from the usage entry in
OEMCrypto would be ignored on rollback even when available.
Information stored along with the license in persistent storage would
be used instead.

A new test with longer duration expiry has been added as well as some
additional verification.

Bug: 186199213
Test: WV unit/integration test
Change-Id: I601f9584a8a0c5137ce68546f8ec833bf2e70cc5
2021-04-23 03:58:31 -07:00
Rahul Frias
2a316f65fe Correct request_license_test failures
[ Merge of http://go/wvgerrit/122885 ]

A recent change to the license service resulted in PSTs being inserted
into persistent renewable licenses even when not specified by the
content provider. This caused ReleaseOfflineKeySessionUsageDisabledTest
to fail. The asset was changed to use a policy for a persistent
license without renewal.

Offline_RollbackBeforeRestoreKey failed because the duration of the
license is short. It has expired when the clock is restored after a
rollback.

Bug: 181693982
Test: request_license_test
Change-Id: I0a2c2a09e563c81c134fba1f310deb1eb4de26a3
2021-04-23 01:52:18 -07:00
Alex Dale
5eed0446da Clean up CdmEngine logs.
[ Merge of http://go/wvgerrit/121568 ]

The CdmEngine logs had both too much and too little information.

Since our logging has been enabled to print function names natively,
many of the log information has become superfluous.  Needless
information has been removed, and many of the important INFO logs have
been reduced to only the information not present in the function name.

Some of the INFO and ERROR logs were missing identifiers to match
failures with the same session request should the failures take more
than a few milliseconds to occur.  CDM session IDs and key set IDs
have been included in all the logs that _appeared_ to have a slow
operation between the top of the method and log.

To help make enum values more readable, several enums-to-string
functions have been implemented.  These converters are intended for
INFO logging and as such, do not log any addition information should
the enum be out of range.

To help make empty and null identifiers more readable in the logs,
empty strings will be logged as <empty> and null strings will be
logged as <null>.

While working through the "cdm_engine.cpp" file, a few minor changes
have been made:
- Adjust if statements to match with Google C++ style guidelines
  - Skipped anything that was not obvious
- Added a const qualifier to variables where appropriate
- Moved some null checks to the top of the method
  - Only where sequence is non-critical to normal operation
- Removed unnecessary string to vector to string conversions
- Reject empty |force_session_id|
  - Already enforced on CE CDM code and not uesd on Android

Bug: 183576879
Test: CE CDM unittests
Change-Id: Id165373055f7ce6097c93c48f84af74bd353c8cb
2021-04-21 21:05:10 -07:00
Robert Shih
9776979f75 metrics: set OEMCrypto initialization errors correctly
[ Merge of http://go/wvgerrit/122663 ]

Bug: 162763203
Test: adb shell dumpsys media.metrics
Change-Id: I4e34d2ca924e271d31952ca4258287f0c9c96f38
2021-04-19 22:18:16 +00:00
TreeHugger Robot
9c3c076cac Merge "Address review comments" into sc-dev 2021-04-17 03:49:56 +00:00
Rahul Frias
c997497aa6 Merge "Remove CBC1 and CENS test" into sc-dev 2021-04-17 00:12:17 +00:00
Alex Dale
d4b24490f2 Merge "Only one function for reporting usage support." into sc-dev 2021-04-16 19:47:10 +00:00
Rahul Frias
d59b009495 Merge "Address CE CDM test failures and code review comments" into sc-dev 2021-04-16 08:25:45 +00:00
Rahul Frias
5343a90f1f Merge "Correct request_license_test failures" into sc-dev 2021-04-16 07:52:43 +00:00
Fred Gylys-Colwell
bcc1db9b69 Address review comments
Merge from Widevine repo of http://go/wvgerrit/122383

Fix a few grammar errors found in http://go/ag/14154405 and
http://go/ag/14150103.

Bug: 185536454
Test: comments changed only
Change-Id: Ied2af940d705fbfc4af60c1d76a051c8c163097f
2021-04-15 22:07:18 -07:00
TreeHugger Robot
c1d423487f Merge changes Ic7459870,I655babf1,I463642fb,Iccdbcc0b,I2ebbd8f7, ... into sc-dev
* changes:
  Fix another typo
  Update license comment
  Update Version Compatibility Document
  Modify OEMCrypto unit tests to allow 16.3 or 16.4
  Update OEMCrypto test comments and logs
  Update OEMCryptoCENC.h header to obfuscate missing functions
  Clean up duration tests
  Use either spelling of AllocateSecureBuffer in dynamic adapter
  Update ODK library for OPK compatibility
2021-04-16 03:10:10 +00:00
Alex Dale
93cfe22910 Merge "Extended Android file store error logs." into sc-dev 2021-04-14 23:05:55 +00:00
Rahul Frias
69f29bbcb2 Remove CBC1 and CENS test
[ Merge of http://go/wvgerrit/122183 ]

Support for CBC1 and CENS encryption modes is no longer required with
OEMCrypto v16. Removing tests to enforce them. The tests will validate
CENC and CBCS mode.

Bug: 181693982
Test: request_license_test
Change-Id: I350d315528c753b70dbf1b1cc46f2897002333fb
2021-04-14 13:33:41 -07:00
Rahul Frias
a674c7cdd0 Correct request_license_test failures
[ Merge of http://go/wvgerrit/122103 ]

When in CTR mode an encryption pattern should no longer be specified.
This will address failures in Cdm/WvCenc30Test.DecryptionTest/* and
Cdm/WvCenc30SwitchCipherModeTest.DecryptionTest/*

Bug: 181693982
Test: WV unit/integration tests
Change-Id: Iecbf28b51115501439aebf057056657c796896ae
2021-04-14 02:57:50 -07:00
Rahul Frias
d802baa4d4 Address CE CDM test failures and code review comments
The android CL ag/13947818 was submitted before some CE CDM test
failures were noticed and code review comments were received.

Bug: 184813991
Test: WV unit/integration test
Change-Id: Ic31ca5bc5e46994e01eca56248e6bdffedd779f3
2021-04-13 11:23:18 -07:00
Fred Gylys-Colwell
e998b08de7 Clean up duration tests
Merge from Widevine repo of http://go/wvgerrit/120903

Some comments in the duration tests had stale numbers in them. This
was fixed.

Also, the tests CdmUseCase_LicenseDuration were failing with a v16 CDM
and a v15 OEMCrypto because the exact cutoff time is different in
those two cases. That is exactly why specifying the license duration
is not recommended. The tests have been modified to handle both
acceptable behaviors.

Bug: 182237739
Change-Id: I05765beacfe69d02e7366bb3f651f0d5888ab3e5
2021-04-12 14:00:53 -07:00
Fred Gylys-Colwell
504b05492b Use either spelling of AllocateSecureBuffer in dynamic adapter
Merge from Widevine repo of http://go/wvgerrit/121883

There was a problem in the v16.3 header that did not rename
OEMCrypto_AllocateSecureBuffer to _oecc109 or
OEMCrypto_FreeSecureBuffer to _oecc110. These functions are only used
in testing.

This changes the dynamic adapter to accept either name for those
functions.

Bug: 171121061
Change-Id: I30121c7524e8db580ba85f3e686a7a7c429d80a9
2021-04-12 14:00:53 -07:00
Alex Dale
36dc9bb97b Extended Android file store error logs.
[ Merge of http://go/wvgerrit/120763 ]

This change introduces additional logging information for files and
file system operations on Android.

File reading and writing will attempt to make sense of |errno| and
log useful information.   In the event that the file must be closed,
the file stat will be printed.

Failures in determining the file size will print potential reasons for
the encountered error.

This partly restructures the File interface implementation to use file
descriptors instead of the C standard libraries FILE handle.  This is
done to ensure that |errno| is set to an expected value.

This change also introduces the utility functions SafeWrite() and
SafeRead() to handle common, retriable errors.

Bug: 178232354
Test: Android MediaDrm GTS and Android file-based unittests
Change-Id: I15a3c47a271098c9edb4bd9f619ed1a12dca6143
2021-04-09 14:23:24 -07:00
Alex Dale
ca335b2c11 Only one function for reporting usage support.
[ Merge of http://go/wvgerrit/121567 ]

Replaced the two usage support functions GetUsageSupportType() and
UsageInformationSupport() into a single function HasUsageInfoSupport().

Since moving to only supporting a single usage info system (usage table
header + usage entries), the different usage support functions have
lost their purpose.

One version of the method works on an open session and will use a
cached value of the property if previously set.  The other can be
called without opening the session (as used for query calls).

This is part of larger fix for the usage table initialization process.

Bug: 169195093
Test: CE CDM unit tests
Change-Id: I637c24dd143e995dbb0f8848850e3c71ff1018eb
2021-04-09 01:34:57 -07:00
Alex Dale
ccda4faf7b Cleaned up OEMCrypto security level getter.
[ Merge of http://go/wvgerrit/121566 ]

This clean up is part of a larger usage table initialization fix.

Bug: 169195093
Change-Id: I3ee818d1e5621f1f2fa64b189da4e66503d5e680
2021-04-09 01:34:56 -07:00
Rahul Frias
574dc28df5 Merge "Reword "blacklisted" to "forbidden"" into sc-dev 2021-04-09 07:38:26 +00:00
Rahul Frias
a40af9d1ef Reword "blacklisted" to "forbidden"
[ Merge of http://go/wvgerrit/113563 ]

Bug: 159847851
Test: WV unit/integration tests
Change-Id: I138b3e3291cb9e75841d092ca1bfa9a652ad9f9a
2021-04-08 11:54:06 -07:00
Rahul Frias
7c8d3e287e Correction to addition of LOCAL_LICENSE_KINDS to vendor/widevine
Remove incorrectly identified license files in http://go/ag/13998816

Bug: 68860345
Bug: 151177513
Bug: 151953481
Test: mm
Change-Id: I676a63598c8a7df11a1cef6d8bebcc9940c961dc
2021-04-08 07:56:48 +00:00
Bob Badour
ea0bd6030c Merge "[LSC] Add LOCAL_LICENSE_KINDS to vendor/widevine" into sc-dev 2021-03-26 06:45:39 +00:00
Alex Dale
50757c84ec Merge "Use new Base64 encode functions." into sc-dev 2021-03-26 05:19:31 +00:00
Alex Dale
e189968a16 Merge "Base64 encoding for string input." into sc-dev 2021-03-26 05:18:43 +00:00
Bob Badour
376f47047c [LSC] Add LOCAL_LICENSE_KINDS to vendor/widevine
Added SPDX-license-identifier-Apache-2.0 legacy_by_exception_only to:
  Android.bp
  libwvdrmengine/Android.bp
  libwvdrmengine/vts/vendor_module/Android.bp

Added legacy_by_exception_only to:
  libwvdrmengine/cdm/Android.bp
  libwvdrmengine/cdm/core/src/Android.bp
  libwvdrmengine/cdm/core/test/Android.bp
  libwvdrmengine/cdm/metrics/src/Android.bp
  libwvdrmengine/cdm/test/integration-test.mk
  libwvdrmengine/cdm/test/unit-test.mk
  libwvdrmengine/level3/Android.bp
  libwvdrmengine/mediacrypto/Android.bp
  libwvdrmengine/mediacrypto/test/Android.mk
  libwvdrmengine/mediadrm/Android.bp
  libwvdrmengine/mediadrm/test/Android.mk
  libwvdrmengine/oemcrypto/odk/Android.bp
  libwvdrmengine/oemcrypto/odk/test/fuzzing/Android.bp
  libwvdrmengine/oemcrypto/odk/test/fuzzing/corpus_generator/Android.bp
  libwvdrmengine/oemcrypto/test/Android.mk
  libwvdrmengine/test/unit/Android.mk
  libwvdrmengine/tools/metrics_dump/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I41ef520b6e394a7708f453a706e6ef1a5f46c36a
2021-03-25 09:52:52 -07:00
Rahul Frias
8c6ce2e4c9 Merge "Have system clocks return wall time" into sc-dev 2021-03-24 01:23:19 +00:00
Alex Dale
d859c1ab17 Use new Base64 encode functions.
[ Merge of http://go/wvgerrit/119806 ]

This change replaces all calls for base64 encoding which first converts
a string to a vector.  The new base64 encoding function allow for
encoding binary data contained within strings.

Bug: 181732604
Test: Android unittests
Change-Id: Ibfe79dba99e6a2ee2f2a96e85b62fbd22519aea7
2021-03-23 14:49:58 -07:00
Alex Dale
e51f869190 Base64 encoding for string input.
[ Merge of http://go/wvgerrit/119805 ]

This change adds 3 new functions for encoding binary data from a C++
string to a base64 encoded ASCII string.

The CDM and protobuf generated code use C++ strings to store binary
data.  These binary strings are commonly converted into a base64
encoded ASCII string for logging and for returning to the app.

This change also cleans up some of the internal components of the
string_conversions library to use several standard library C++11
method.

Bug: 181732604
Test: CE CDM unittests
Change-Id: I547568c6402e011344260f2df2a06e972122ab8a
2021-03-23 14:49:46 -07:00
Rahul Frias
e538c96131 Save and retrieve key information from licenses and usage records
[ Merge of http://go/wvgerrit/120512 ]

Wrapped DRM private keys are loaded when a key request is made or when
offline/usage sessions are restored. They were earlier loaded when a
session was opened.

For streaming sessions, key material will be fetched from the default
or legacy certificates and loaded when a key request is made.

For offline and usage sessions, key material may be retrieved from
license or usage records if available. If not available, information
associated with the legacy certificate will be loaded.

Certificate and wrapped keys are also written out when an offline
license or usage record is saved.

Bug: 169740403
Test: WV unit/integration tests
      WvCdmRequestLicenseTest.ProvisioningWithExpiringCertTest
      WvCdmRequestLicenseTest.StreamingWithExpiringCertTest
      WvCdmRequestLicenseTest.RestoreOfflineKeysWithExpiringCertTest
Change-Id: Ice0154c632170c46da171cbbb23a97380c610a98
2021-03-23 13:06:55 -07:00
Rahul Frias
30ebbefb40 Add CLIENT_TOKEN_NOT_SET error code
[ Merge of http://go/wvgerrit/120511 ]

Bug: 169740403
Test: WV unit/integration test
Change-Id: Iba77c0b7e7f1bee1e96b0d08f0ab8e8591292012
2021-03-22 17:08:34 -07:00
Rahul Frias
1aa197ce4a Add certificate information to Usage Information
[ Merge of http://go/wvgerrit/120509 ]

Certificates and wrapped key material are stored in the usage information
file but apart from usage information records. Usage info records include
an identifier which indicates the associated certificate. Routines to
help with finding, inserting or removal of associated certificates have
been included. After a usage entry is deleted, a garbage collection
routine is run to remove any certificates not used by usage infomation
records.

Bug: 169740403
Test: WV unit/integration tests
Change-Id: I49075a7704a58c2488b73eb7c38b007958af566d
2021-03-22 17:07:25 -07:00