Cherry pick cdm udc-widevine-release changes to udc-widevine-dev to be in sync with 18.3 release

Merged from go/wvgerrit/178231

Bug: 290252845
Test: WVTS tests seem to be running and passing
Change-Id: Ifff9123a73e173e835a6e89ba7c2760e1cd500fd
(cherry picked from commit 6889845d2e7e24f22c00b333335c34259b3fc96e)
This commit is contained in:
Vicky Min
2023-07-12 18:59:13 +00:00
parent 42a5f26c5a
commit bc20b9dac9
460 changed files with 16767 additions and 3215 deletions

View File

@@ -167,4 +167,45 @@ void SessionUtil::CreateProv4DRMKey() {
drm_public_key_ = provisioning_messages.drm_public_key();
}
// Requires stage 1 prov4 to be complete, ie OEM key is available
void SessionUtil::CreateProv4CastKey(Session* s,
bool load_drm_before_prov_req) {
if (global_features.provisioning_method != OEMCrypto_BootCertificateChain) {
FAIL() << "Provisioning 4.0 is required.";
}
Provisioning40CastRoundTrip prov_cast(s, encoded_rsa_key_);
// Calls GenerateCertificateKeyPair(). Generated keys stored in
// prov_cast.drm_public_key_ and prov_cast.wrapped_drm_key_
ASSERT_NO_FATAL_FAILURE(prov_cast.PrepareSession());
// Can choose to load DRM key before preparing the provisioning request, or
// after
if (load_drm_before_prov_req) {
ASSERT_NO_FATAL_FAILURE(prov_cast.LoadDRMPrivateKey());
}
ASSERT_NO_FATAL_FAILURE(s->SetPublicKeyFromSubjectPublicKey(
prov_cast.drm_key_type(), prov_cast.drm_public_key().data(),
prov_cast.drm_public_key().size()));
ASSERT_NO_FATAL_FAILURE(prov_cast.SignAndVerifyRequest());
if (!load_drm_before_prov_req) {
ASSERT_NO_FATAL_FAILURE(prov_cast.LoadDRMPrivateKey());
}
// Generate derived keys in order to verify and decrypt response.
// We are cheating a little bit here since this GenerateDerivedKeys helper
// simulates work on both client side (calls
// OEMCrypto_GenerateDerivedKeysFromSessionKey) and server side (sets
// key_deriver() keys used to create response)
ASSERT_NO_FATAL_FAILURE(s->GenerateDerivedKeysFromSessionKey());
// Response is provisioning 2 with CAST key
ASSERT_NO_FATAL_FAILURE(prov_cast.CreateDefaultResponse());
ASSERT_NO_FATAL_FAILURE(prov_cast.EncryptAndSignResponse());
// Should parse and load successfully
ASSERT_EQ(OEMCrypto_SUCCESS, prov_cast.LoadResponse());
}
} // namespace wvoec