This CL undoes the merge cc28abea0b by
TreeHugger that should not have gone to master. We re-enable a unit
tests that is required for OC MR1, but is not required for OC.
It also includes a minor change that allows the oemcrypto mock to be
built by an Android NDK:
Merge from Widevine repo of http://go/wvgerrit/24681
b/31458046
b/35141278
Change-Id: I8edc51504a16f1825ef765aeaff6f77f034f0362
74 lines
1.8 KiB
C++
74 lines
1.8 KiB
C++
// 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_
|