Merge from Widevine repo of http://go/wvgerrit/42281 This cleans up some of the oemcrypto mock code. This code is only used for testing. bug: 72831885 bug: 69271232 Change-Id: I8add162839d6febe56a89df84e8ae0cf0b97a2d9
41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
// Copyright 2016 Google Inc. All Rights Reserved.
|
|
//
|
|
// Mock implementation of OEMCrypto APIs
|
|
//
|
|
#ifndef OEMCRYPTO_RSA_KEY_SHARED_H_
|
|
#define OEMCRYPTO_RSA_KEY_SHARED_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <openssl/rsa.h>
|
|
|
|
namespace wvoec_mock {
|
|
|
|
// Shared pointer with specialized destructor. This pointer is only shared
|
|
// from a CryptoEngine to a Session -- so we don't have to use full reference
|
|
// counting.
|
|
class RSA_shared_ptr {
|
|
public:
|
|
RSA_shared_ptr() : rsa_key_(NULL), key_owned_(false) {}
|
|
~RSA_shared_ptr() { reset(); };
|
|
// Explicitly allow copy as share.
|
|
explicit RSA_shared_ptr(const RSA_shared_ptr& other) :
|
|
rsa_key_(other.rsa_key_), key_owned_(false) {}
|
|
RSA* get() { return rsa_key_; }
|
|
void reset();
|
|
bool LoadPkcs8RsaKey(const uint8_t* buffer, size_t length);
|
|
|
|
private:
|
|
void operator=(const RSA_shared_ptr); // disallow assign.
|
|
|
|
RSA* rsa_key_;
|
|
bool key_owned_;
|
|
};
|
|
|
|
// Log errors from BoringSSL.
|
|
void dump_boringssl_error();
|
|
|
|
} // namespace wvoec_mock
|
|
|
|
#endif // OEMCRYPTO_RSA_KEY_SHARED_H_
|