Move keybox and root certificate handling into new class.
Merge from Widevine repo of http://go/wvgerrit/22804 Create a class, AuthenticationRoot, to encapsulate the objects and logic for managing either keyboxes or certificates as the device's root of trust. Currently the class provides the existing keybox-related functions needed by oemcrypto's CryptoEngine. It will be extended to provide both keybox and certificate related functions, and the logic to determine whether keybox or certificate based authentication should be performed. Change-Id: I792d1bfc8e9a81bbfd2baec20e3b3d182f0392f7
This commit is contained in:
73
libwvdrmengine/oemcrypto/mock/src/oemcrypto_auth_mock.h
Normal file
73
libwvdrmengine/oemcrypto/mock/src/oemcrypto_auth_mock.h
Normal file
@@ -0,0 +1,73 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Mock implementation of OEMCrypto APIs
|
||||
//
|
||||
#ifndef OEMCRYPTO_AUTH_MOCK_H_
|
||||
#define OEMCRYPTO_AUTH_MOCK_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#include <openssl/rsa.h>
|
||||
|
||||
#include "OEMCryptoCENC.h" // Needed for enums only.
|
||||
#include "oemcrypto_key_mock.h"
|
||||
#include "oemcrypto_keybox_mock.h"
|
||||
#include "oemcrypto_rsa_key_shared.h"
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvoec_mock {
|
||||
|
||||
class AuthenticationRoot {
|
||||
public:
|
||||
explicit AuthenticationRoot(OEMCrypto_ProvisioningMethod method);
|
||||
~AuthenticationRoot() {}
|
||||
|
||||
bool Validate();
|
||||
|
||||
KeyboxError ValidateKeybox();
|
||||
|
||||
bool InstallKeybox(const uint8_t* keybox_data, size_t keybox_length) {
|
||||
return keybox().InstallKeybox(keybox_data, keybox_length);
|
||||
}
|
||||
|
||||
const std::vector<uint8_t>& DeviceKey(bool use_real_keybox = false) {
|
||||
return use_real_keybox ? real_keybox().device_key() :
|
||||
keybox().device_key();
|
||||
}
|
||||
|
||||
const std::vector<uint8_t>& DeviceId() {
|
||||
return keybox().device_id();
|
||||
}
|
||||
|
||||
size_t DeviceTokenLength() {
|
||||
return keybox().key_data_length();
|
||||
}
|
||||
|
||||
const uint8_t* const DeviceToken() {
|
||||
return keybox().key_data();
|
||||
}
|
||||
|
||||
WvKeybox& keybox() { return use_test_keybox_ ? test_keybox_ : keybox_; }
|
||||
void UseTestKeybox() { use_test_keybox_ = true; }
|
||||
|
||||
RSA_shared_ptr& SharedRsaKey() { return rsa_key_; }
|
||||
RSA* rsa_key() { return rsa_key_.get(); }
|
||||
bool LoadTestRsaKey();
|
||||
|
||||
private:
|
||||
OEMCrypto_ProvisioningMethod provisioning_method_;
|
||||
WvKeybox& real_keybox() { return keybox_; }
|
||||
|
||||
WvKeybox keybox_;
|
||||
WvTestKeybox test_keybox_;
|
||||
bool use_test_keybox_;
|
||||
|
||||
RSA_shared_ptr rsa_key_; // If no keybox, this is baked in certificate.
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(AuthenticationRoot);
|
||||
};
|
||||
|
||||
} // namespace wvoec_mock
|
||||
|
||||
#endif // OEMCRYPTO_AUTH_MOCK_H_
|
||||
Reference in New Issue
Block a user