This is a merge from the Widevine repo of http://go/wvgerrit/117311 Update backwards compatibility builds http://go/wvgerrit/117423 Restrict maximum size of key id To protect from out-of-memory found by fuzz testing. http://go/wvgerrit/117683 Generation number should wrap The master generation number should wrap around on overflow. This means that we cannot use less than to check for a skew of 1. http://go/wvgerrit/119232 Replace 0 with nullptr Bug: 176234903 Bug: 184866351 Bug: 161243686 Test: ran unit tests (CL affects test code only) Merged-In: Ie787bcf9c66a7605700c3dc29a8aa16406926ce3 Change-Id: I2b02a36a70a0920f31ffc00de102a23516d4b20e
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
|
// source code may only be used and distributed under the Widevine
|
|
// License Agreement.
|
|
//
|
|
// Reference 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_ref {
|
|
|
|
// 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_(nullptr), 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_ref
|
|
|
|
#endif // OEMCRYPTO_RSA_KEY_SHARED_H_
|