Changed Prov4.0 handler to accept only recent requests.

[ Cherry-pick of v19 http://go/wvgerrit/219291 ]
[ Merge of http://go/wvgerrit/219432 ]

If the same app/origin generates multiple provisioning 4.0
requests it is possible that a mismatch between the OEM/DRM
certificate and the wrapped OEM/DRM private key occurs.  The CDM
would use the OEM/DRM certificate of the first response one
received, and the wrapped private key of the last request generated.

To avoid this issue, the public key from the most recent request
is cached and checked against the responses received.  If the
keys match, that response is accepted; if the keys don't match
than the response is assumed "stale" and the response is dropped.

In an attempt to maintain existing behavior of the CDM, "stale"
responses will return NO_ERROR to the app.

Note: This was tested using both RSA and ECC cert key types.

VIC-specific: Needed to add implementation of StringContains() and
StringEndsWith().

Bug: 391469176
Test: run_prov40_tests
Change-Id: Id45d40d9af355c46a61c3cc2c19c252cf17c7489
This commit is contained in:
Alex Dale
2025-04-21 17:04:07 -07:00
parent daf291955f
commit a2cdce4296
7 changed files with 795 additions and 29 deletions

View File

@@ -151,18 +151,24 @@ class CertificateProvisioning {
CdmCertificateType cert_type_;
std::unique_ptr<ServiceCertificate> service_certificate_;
std::string request_;
// == Provisioning 4.0 Variables ==
// The wrapped private key in provisioning 4 generated by calling
// GenerateCertificateKeyPair. It will be saved to file system if a valid
// response is received.
std::string provisioning_40_wrapped_private_key_;
// Key type of the generated key pair in provisioning 4.
CryptoWrappedKey::Type provisioning_40_key_type_;
// Store the last provisioning request message
std::string provisioning_request_message_;
CryptoWrappedKey prov40_wrapped_private_key_;
// Cache of the most recently sent OEM/DRM public key sent. Used
// to match the response with the request.
// This MUST be matched with the current |prov40_wrapped_private_key_|.
std::string prov40_public_key_;
// Store the last provisioning request message.
// This is the serialized ProvisioningRequest.
// Used for X.509 responses which require the original
// request to verify the signature of the response.
std::string prov40_request_;
CORE_DISALLOW_COPY_AND_ASSIGN(CertificateProvisioning);
};
}; // class CertificateProvisioning
} // namespace wvcdm
#endif // WVCDM_CORE_CERTIFICATE_PROVISIONING_H_