43 lines
1.4 KiB
C++
43 lines
1.4 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright 2019 Google LLC.
|
|
//
|
|
// This software is licensed under the terms defined in the Widevine Master
|
|
// License Agreement. For a copy of this agreement, please contact
|
|
// widevine-licensing@google.com.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Description:
|
|
// Class to generate EC keys locally.
|
|
|
|
#ifndef COMMON_LOCAL_EC_KEY_SOURCE_H_
|
|
#define COMMON_LOCAL_EC_KEY_SOURCE_H_
|
|
|
|
#include "common/ec_key.h"
|
|
#include "common/ec_key_source.h"
|
|
|
|
namespace widevine {
|
|
|
|
// Class which generates new EC keys.
|
|
class LocalECKeySource : public ECKeySource {
|
|
public:
|
|
LocalECKeySource() = default;
|
|
|
|
// Creates an EC key pair using openssl and |curve|.
|
|
// Parameter |curve| is a standard curve which defines the parameters of the
|
|
// key generation.
|
|
// Parameter |private_key| is the serialized EC private key.
|
|
// Parameter |public_key| is the serialized EC public key.
|
|
// Caller retains ownership of all pointers and they cannot be nullptr.
|
|
// Returns true if successful, false otherwise.
|
|
bool GetECKey(ECPrivateKey::EllipticCurve curve, std::string* private_key,
|
|
std::string* public_key) override;
|
|
|
|
private:
|
|
LocalECKeySource(const LocalECKeySource&) = delete;
|
|
LocalECKeySource& operator=(const LocalECKeySource&) = delete;
|
|
};
|
|
|
|
} // namespace widevine
|
|
|
|
#endif // COMMON_LOCAL_EC_KEY_SOURCE_H_
|