69 Commits

Author SHA1 Message Date
Googler
c56808c463 Automated update of OPK code
Included changes:

  - 92a0538dc60ad0c48866b5736fcec125f6493d8d Remove unused function by John "Juce" Bruce <juce@google.com>
  - 7235e2c89a94d6b6ed086aa83cd4b22b56bd8d65 Various static function fixes by John "Juce" Bruce <juce@google.com>
  - 908055030aa283ce74915fb68571b0ce3854e12e Fix duplicate & missing headers identified by clang-tidy by John "Juce" Bruce <juce@google.com>
  - 502b8b8caeb4654f294398039fff98ec641bda24 Updated `core_message_features.cpp` to use `odk_versions.h` by Alex Dale <sigquit@google.com>
  - 3163312183f5e0b8a08b97cfe171221861743cc5 Bump ODK max supported minor versions by Matt Feddersen <mattfedd@google.com>
  - c461df67a9003e738042716ae644dd96a66d2446 Updated ODK minor versions for 2025Q2 release. by Alex Dale <sigquit@google.com>
  - 56a43e881c31e4e2d3a2a7732bef00705a252a65 Added ODK_InitializeSessionValuesEx by Alex Dale <sigquit@google.com>

GitOrigin-RevId: 92a0538dc60ad0c48866b5736fcec125f6493d8d
2025-06-06 16:09:23 -07:00
Googler
5387878a5b Automated update of OPK code
Included changes:

  - 676ac7be8548d80c420591fc0b4fb9a11723ef34 Backwards compatibility script for CDM v18 and OPK v19 by Vicky Min <vickymin@google.com>
  - 3cd4f71fda91245ac0b61c4c847950952f3021c0 Change BuildInformation ree fields to optional by Matt Feddersen <mattfedd@google.com>
  - a2259e95dea40c27a4be02ad479aec8f1fc84737 Created a DICE CBOR Cert parser/serializer. by Alex Dale <sigquit@google.com>
  - b8f2c364afeb6279e5aee6488d4527e189ac42ff Don't create invalid enum value by John "Juce" Bruce <juce@google.com>
  - b0aed212a3b2dd8f752d8fc43982848c1aa6c152 Created an HLS Key type. by Alex Dale <sigquit@google.com>
  - f8cfc54b41f124ba849596dbe6438b7f271a72b7 Specify C/C++ standard when running clang-tidy on OPK by John "Juce" Bruce <juce@google.com>

GitOrigin-RevId: 676ac7be8548d80c420591fc0b4fb9a11723ef34
2025-05-30 09:58:39 -07:00
Matt Feddersen
a2b9e085e9 OEMCrypto and OPK v20 prerelease initial commit 2025-05-22 16:33:29 -07:00
Cong Lin
98dfef4389 OEMCrypto and OPK 19.5 2025-04-02 09:49:07 -07:00
Vicky Min
b4e12724af OEMCrypto and OPK 19.4 2024-11-26 20:50:11 +00:00
John W. Bruce
365ea19c9a OEMCrypto and OPK v19.3 2024-09-05 07:21:15 +00:00
Matt Feddersen
482b0923ca Add v16.3 unwrap compatibility 2024-07-25 14:15:55 -07:00
Alex Dale
9fe69a896c Corrected README and CHANGELOG for OPK v19.2. 2024-06-27 18:20:56 -07:00
Alex Dale
a084ab5489 OPK v19.2 2024-06-21 21:41:11 -07:00
Matt Feddersen
b8d32f0d6e OPK v19.1 2024-03-28 18:04:59 -07:00
Matt Feddersen
3f5e2d789e OEMCrypto and OPK v19.0
See the file CHANGELOG.md for details.
2023-12-14 17:14:56 -08:00
Matt Feddersen
6cd8677952 Bug fix ECC and persistent storage in OPTEE
Fixes two bugs in the OP-TEE port

1. WTPI_GetBootCertificateChain() did not correctly zero pad ECC keys
   that are smaller than 32 bytes.
2. wtpi_persistent_storage_layer2.c:write_raw_object() would overwrite
   objects if an initial read failed.
2023-12-08 18:35:51 -08:00
Fred Gylys-Colwell
c259630b75 OEMCrypto v18.4
Updates to OEMCrypto API, OPK, and unit tests to support
MediaCAS.
2023-09-07 13:57:34 -07:00
Fred Gylys-Colwell
3c628c8f27 OEMCrypto v18.3
Updates to OEMCrypto API, OPK, ODK, and unit tests.

See the file CHANGELOG.md for details.
2023-07-11 16:57:57 -07:00
Fred Gylys-Colwell
562f64f292 Version 18.1
Updates to OEMCrypto API, OPK, ODK, and unit tests.

See the file CHANGELOG.md for details.
2023-03-09 18:06:07 -08:00
Fred Gylys-Colwell
5232c51e33 OEMCrypto v17.1
The previous commit had a v17.2 change in it that is not needed
for v17.1
2022-06-27 07:16:03 -07:00
Fred Gylys-Colwell
1ec4f64360 Version 17.1
Updates to OEMCrypto API and OPK reference implementation.
2022-06-26 20:46:35 -07:00
Fred Gylys-Colwell
5e1f940c81 Version 17 plus test updates and OPK v17 and Makefiles
Add makefiles to external repo, and update the gitignore so
that they are included.
2022-04-17 11:24:52 -07:00
Fred Gylys-Colwell
0a16cb2594 Version 17 plus test updates and OPK v17
This is the first public release of OPK v17.
See the file CHANGELOG.md for details.
2022-04-13 19:36:27 -07:00
Fred Gylys-Colwell
044a89ef55 Initial v17 Release
Headers and Unit tests have been updated to match the v17 spec.

Documentation can be found here:
https://developers.devsite.corp.google.com/widevine/drm/client/oemcrypto/v17
2021-12-04 01:13:15 +00:00
Fred Gylys-Colwell
8e55868e8a Missing images 2021-12-04 01:10:46 +00:00
Fred Gylys-Colwell
ef80dcf790 Update documentation and update some tests
Some changes were made to align the source code with the new devsite,
https://developers.devsite.corp.google.com/widevine.

Updates to documentation:
6cd6438a5 Update doc string for return values
8705af128 Move documentation of Resource Rating to devsite
f0394da46 Documentation: specify usage entry may not be reloaded
f7e1dd729 Documentation: clarify buffers sizes for DeriveKeys
305d98f4a Documentation: Entitled content keys are not wrapped
11174fd01 Documentation: Add figures to OEMCrypto API
e1fdbbfc2 Document buffer size for OEMCrypto_CopyBuffer
06dd39c46 Update return code docs for OEMCrypto_ReportUsage
b67a0c688 Documentation: Add parentheses so Doxygen creates links
369fcde53 Documentation: Add links from OEMCrypto API
a7489aa25 Remove extra blank line

Some unit tests were not compiling on some platforms. Some platforms
were not passing usage table duration tests even though they correctly
implemented the spec.

Update to tests:
0268104c1 Add curly braces in oemcrypto_test.cpp
8dce14f2d Update usage entry before sleeping
0c164a2c4 Use size_t for length in wvcrc32
2021-12-04 00:50:57 +00:00
Fred Gylys-Colwell
d361835c19 Always generate nonce before signing license
The v16 state diagram says that a nonce should be included in all
license requests. The unit tests were not honoring this
requirement. This CL updates the unit tests to match the spec.

Bug: 186565384
2021-09-08 21:30:20 +00:00
Vicky Min
8c158b00cf Sync fake clock for nonce tests
Because the fake clock is getting out of sync with the real clock for
the nonce flood tests, add a call to TestSleep::SyncFakeClock() in
Clock::GetCurrentTime() to force a sync.

Bug: 198329759
2021-09-08 21:18:08 +00:00
Fred Gylys-Colwell
3def45f33d Update date in oemcrypto tests
Update the date in the log string so we know when the tests were
published.
2021-08-05 03:16:45 +00:00
Fred Gylys-Colwell
8aeb9e81a0 Add extra RSA private keys to unit tests
There have been some failures with various RSA private keys. We add
them to the unit tests to make sure that OEMCrypto is able to load
these types of keys:
* Shorter than normal private exponents. This seems to occur
  occasionally even with Euler totients. But it occurs more with
  Carmichael totients.
* 0-leading-byte private exponents. This also occurs naturally for both
  Euler and Carmichael totients.
* Carmichael vs Euler totients. I think we may already have tests for
  this. But just in case.

Bug: 190450051
2021-08-05 03:13:50 +00:00
Fred Gylys-Colwell
9ed08c10b8 Update OEMCrypto buffer offset tests
Some unit tests used the response buffer size before the size had been
computed. This CL updates the tests.

Bug: 183440999
2021-08-05 03:12:12 +00:00
Fred Gylys-Colwell
dff9898485 Remove non-ASCII curly quotes from OEMCryptoCENC.h
Bug: 192275441
2021-08-05 03:07:55 +00:00
Fred Gylys-Colwell
d0445f09e1 Update OEMCrypto test comments and logs
This CL merges some changes from branch rvc-dev to sc-dev that
prepared it for merge.

One change is that the unit tests now say they are part of Android S
instead of R.

Bug: 180546871
2021-08-04 22:00:23 +00:00
Fred Gylys-Colwell
1dc1ff7e7c Validate decryption with entitled keys in OEC tests
The OEMCrypto tests have tests that verify that entitled keys can be
loaded but not that they can be successfully used for decrypt. This
patch adds a decrypt portion to the existing tests.

As part of this, the existing Session::EncryptCTR() method and
portions of Session::TestDecryptCTR() are lifted to be static
functions so they can be shared across unrelated classes in
oec_session_util.cpp.  EncryptCTR() had no dependence on its enclosing
class and is unchanged other than being moved outside the class.

To reduce ambiguity with the new decrypt verification, this patch also
renames EntitledMessage::VerifyEntitlementTestKeys() to the
more-specific EntitledMessage::VerifyKCBs(). Its behavior is
unchanged.

Bug: 186782279
2021-08-04 21:59:18 +00:00
Fred Gylys-Colwell
18f9284d88 Remove asserts from GenerateSimpleSampleDescription()
GenerateSimpleSampleDescription() only had asserts to check parameters
that only came from other test code, so they weren't testing anything
of use. With the asserts removed, it's no longer necessary to wrap
calls to GenerateSimpleSampleDescription() with
ASSERT_NO_FATAL_FAILURE(), which a lot of callers were already
forgetting to do anyway. This also simplifies a future patch that will
generalize the decryption test code to work with entitlement licenses.

Bug: 186782279
2021-08-04 21:58:08 +00:00
Fred Gylys-Colwell
55c4dfc25a Modify OEMCrypto unit tests to allow 16.3 or 16.4
Some unit tests expected OEMCrypto to be the latest ODK version,
but we do not require this for v16.

Bug: 184905579
2021-08-04 20:27:06 +00:00
Fred Gylys-Colwell
1ffc1ca575 Update licenes comment
Remove the term "Master" from "Widevine Master License Agreement".
2021-08-04 20:25:53 +00:00
Fred Gylys-Colwell
732599673e Updates to fuzz tests
This CL updates the fuzz tests as well as some changes to
documentation. A few OEMCrypto enumerations were updated to include
"test only" values to help the automated fuzz tools.

This should make it easier for partners to run fuzz testing on their
own implementations.

Bug: 186785830
2021-08-04 20:23:21 +00:00
Fred Gylys-Colwell
b4b0da045a Update version number in reference OEMCrypto 2021-08-04 20:21:22 +00:00
Fred Gylys-Colwell
7caea8d5c9 Update to ClearCopyTestAPI10
Older versions of OEMCrypto spec did not require
OEMCrypto_ERROR_SHORT_BUFFER, and it is difficult for an OEMCrypto to
pass both this test and the unit tests shipped with CE CDM.

Bug: 166529517
2021-08-04 20:20:08 +00:00
Fred Gylys-Colwell
bb16924e69 Update Unit tests and reference code
This patch adds a suite of tests for OEMCrypto that verifying buffer
overflow and off-by-one errors. The reference code has also been
updated to pass these tests.

The ODK library and the OEMCrypto API have not changed since the
release of version 16.4.
2021-01-25 19:51:10 -08:00
Fred Gylys-Colwell
7e3c282944 Disable dangerous test
The test OEMCryptoMemoryInstallKeyboxForHugeKeyboxBuffer is dangerous
because it attempts to pass garbage data to InstallKeybox. On a
production device this might erase the keybox.
2021-01-08 14:50:52 -08:00
Fred Gylys-Colwell
2980612cb5 Update version compatibility document
- This updates the version compatibility document to clarify how the
Android hidl interface works.
- Testing of analog output was removed because the unit tests cannot
verify correct behaviour.
- Some buffer overflow tests have been added.
2020-12-15 14:29:34 -08:00
Fred Gylys-Colwell
ad3791e23f OEMCrypto and ODK v16.4
This update is not required for all devices. It is necessary for
supporting some use cases for offline licenses on devices that do not
support usage tables. Most devices are expected to support usage
tables.

There were no new changes to the OEMCrypto code. However, the ODK
library has been updated so the minior version has been updated to 4.

There were also some changes to the unit tests.
1. We added more tests for pattern decryption.
2. We added more tests for buffer overflow handling.
4. We added some support for fuzz testing. These tests are not quite
   ready for wide use.
2020-10-07 19:37:40 -07:00
Fred Gylys-Colwell
6433bf285f One more version string change. 2020-06-03 06:16:50 -07:00
Fred Gylys-Colwell
b5637c89cb OEMCrypto v16.3
There were no new changes to the OEMCrypto code. However, the ODK
library changed, so we rolled the minor version number to 3.  The ODK
library was updated to support a nonce-free offline license. An
offline license would not require a nonce if, for example, it is
preloaded onto the device and does not have an entry in the usage
table.

Also, the following unit tests have been updated:
1. Various tests: Keys are not derived if they are not used. This is more
   in line with the “OEMCrypto state” diagram below.
2. The decrypt hash is not verified when there are multiple samples or no
   key is selected.
3. LoadKeyWithNoRequest. A nonce-free license is loaded in a session that
   did not sign the request. (Requires 16.3 ODK library)
4. RefreshLargeBuffer. The renewal message was set to the large
   size. Previously, only the license request was set to the larger size.
5. OEMCryptoGenericCryptoTest.*LargeBuffer. The correct buffer size is
   now being used.
6. ShrinkOverOpenSessions: The correct error code
   OEMCrypto_ERROR_ENTRY_IN_USE is now verified.
7. TimeRollbackPrevention: The test was refactored and fixed. Comments
   were added.
2020-06-02 10:14:16 -07:00
Fred Gylys-Colwell
e000b9de99 Update OEMCrypto documents (v16.2)
There were no function signature changes, so the API version number
did not change from 16.2. There were several grammar and spelling
errors. There were also the following corrections:

1. The description of OEMCrypto_LoadProvisioning now says that devices
with a keybox use keys derived from the keybox device key, and devices
using Provisioning 3.0 use keys derived from the session key. The
description was previously reversed.

2. The function OEMCrypto_SupportedPatterns is no longer
discussed. This function was never fully defined.

3. The function OEMCrypto_LoadRenewal no longer says that keys and key
control blocks should be verified. This is because the function
OEMCrypto_LoadRenewal processes a message with no key control
block. It should update timers for the entire license.
2020-04-14 10:10:56 -07:00
Fred Gylys-Colwell
016c2970ac Update unit tests to 2020-03-27 version
This CL updates the following:
- Some robustness improvements to the ODK library.
- Unit tests assume that license release does not have a core message.
- Added version string to unit tests.

The version string of the unit tests is now:
OEMCrypto unit tests for API 16.2. Tests last updated 2020-03-27
2020-03-30 18:51:33 -07:00
Fred Gylys-Colwell
1a9765171b OEMCrypto v16.2 unit tests and reference code 2020-02-10 16:34:45 -08:00
Fred Gylys-Colwell
d597f863e9 Update OEMCrypto docs to v16.2
This updates the documentation for the v16.2 release.
2020-02-01 12:00:52 -08:00
Fred Gylys-Colwell
9fa2cbdb67 OEMCrypto v16.1 -- update ODK
This CL updates the ODK library to address review comments.
2020-02-01 11:56:34 -08:00
Fred Gylys-Colwell
858fa33cd7 Updates for 16.1 unit tests and code
This patch has the full v16.1 reference code and unit tests.
2020-01-13 21:28:54 -08:00
Fred Gylys-Colwell
dc346cf70a RenewLicense test updates. 2019-12-15 17:01:22 -08:00
Fred Gylys-Colwell
f328c85fc3 Combine Decrypt Unit Tests. 2019-12-15 16:09:03 -08:00