Files
ce_cdm/oemcrypto/test/oemcrypto_session_tests_helper.h
2024-06-25 14:03:53 -07:00

64 lines
2.1 KiB
C++

#ifndef CDM_OEMCRYPTO_SESSION_TESTS_HELPER_
#define CDM_OEMCRYPTO_SESSION_TESTS_HELPER_
#include <assert.h>
#include <openssl/aes.h>
#include <openssl/rand.h>
#include <algorithm>
#include <iostream>
#include "OEMCryptoCENC.h"
#include "oec_session_util.h"
#include "oec_test_data.h"
namespace wvoec {
class SessionUtil {
public:
SessionUtil()
: encoded_rsa_key_(kTestRSAPKCS8PrivateKeyInfo2_2048,
kTestRSAPKCS8PrivateKeyInfo2_2048 +
sizeof(kTestRSAPKCS8PrivateKeyInfo2_2048)) {}
// Create a new wrapped DRM Certificate. This creates a new one, even if one
// already exists. For provisioning 2 or 3, it uses encoded_rsa_key_ to
// specify the key. For Prov 4.0, the key is generated by OEMCrypto.
void CreateWrappedDRMKey();
// This is used to force installation of a keybox. This overwrites the
// production keybox -- it does NOT use OEMCrypto_LoadTestKeybox.
void InstallKeybox(const wvoec::WidevineKeybox& keybox, bool good);
// This loads the test keybox or the test RSA key, using LoadTestKeybox or
// LoadTestRSAKey as needed.
void EnsureTestROT();
// Install a DRM private key in to the session. If a key has not been created,
// tehn CreateWrappedDRMKey is used to create one first. Works with Prov 2-4.
void InstallTestDrmKey(Session* s);
// Create and install an OEM Cert private key. After creation, the key is
// saved to oem_public_key_. Only for provisioning 4.0
void CreateProv4OEMKey(Session* s);
// Create a new DRM Cert. Only for provisioning 4.0
void CreateProv4DRMKey();
void CreateProv4CastKey(Session* s, bool load_drm_before_prov_req);
// Used by prov2.0, prov3.0, and prov 4.0
std::vector<uint8_t> encoded_rsa_key_;
std::vector<uint8_t> wrapped_drm_key_;
OEMCrypto_PrivateKeyType drm_key_type_;
std::vector<uint8_t> drm_public_key_;
wvoec::WidevineKeybox keybox_;
// Used by prov4.0
std::vector<uint8_t> wrapped_oem_key_;
std::vector<uint8_t> oem_public_key_;
OEMCrypto_PrivateKeyType oem_key_type_;
};
} // namespace wvoec
#endif // CDM_OEMCRYPTO_SESSION_TESTS_HELPER_