CCF
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
ccf::crypto::KeyPair_OpenSSL Class Reference

#include <key_pair.h>

Inherits ccf::crypto::PublicKey_OpenSSL, and ccf::crypto::KeyPair.

Public Member Functions

 KeyPair_OpenSSL (CurveID curve_id)
 
 KeyPair_OpenSSL (const KeyPair_OpenSSL &)=delete
 
 KeyPair_OpenSSL (const Pem &pem)
 
 KeyPair_OpenSSL (const JsonWebKeyECPrivate &jwk)
 
virtual ~KeyPair_OpenSSL ()=default
 
virtual Pem private_key_pem () const override
 
virtual Pem public_key_pem () const override
 
virtual std::vector< uint8_t > public_key_der () const override
 
virtual std::vector< uint8_t > private_key_der () const override
 
virtual bool verify (const std::vector< uint8_t > &contents, const std::vector< uint8_t > &signature) override
 
virtual bool verify (const uint8_t *contents, size_t contents_size, const uint8_t *signature, size_t signature_size) override
 
virtual std::vector< uint8_t > sign (std::span< const uint8_t > d, MDType md_type={}) const override
 
int sign (std::span< const uint8_t > d, size_t *sig_size, uint8_t *sig, MDType md_type={}) const
 
std::vector< uint8_t > sign_hash (const uint8_t *hash, size_t hash_size) const override
 
virtual int sign_hash (const uint8_t *hash, size_t hash_size, size_t *sig_size, uint8_t *sig) const override
 
virtual Pem create_csr (const std::string &subject_name, const std::vector< SubjectAltName > &subject_alt_names, const std::optional< Pem > &public_key=std::nullopt) const override
 
virtual std::vector< uint8_t > create_csr_der (const std::string &subject_name, const std::vector< SubjectAltName > &subject_alt_names, const std::optional< Pem > &public_key=std::nullopt) const override
 
virtual Pem sign_csr_impl (const std::optional< Pem > &issuer_cert, const Pem &signing_request, const std::string &valid_from, const std::string &valid_to, bool ca=false, Signer signer=Signer::SUBJECT) const override
 
virtual std::vector< uint8_t > derive_shared_secret (const PublicKey &peer_key) override
 
virtual CurveID get_curve_id () const override
 
virtual std::vector< uint8_t > public_key_raw () const override
 
virtual PublicKey::Coordinates coordinates () const override
 
virtual JsonWebKeyECPrivate private_key_jwk (const std::optional< std::string > &kid=std::nullopt) const override
 
virtual bool verify (const uint8_t *contents, size_t contents_size, const uint8_t *sig, size_t sig_size, MDType md_type, HashBytes &bytes) override
 
- Public Member Functions inherited from ccf::crypto::PublicKey_OpenSSL
 PublicKey_OpenSSL (PublicKey_OpenSSL &&key)=default
 
 PublicKey_OpenSSL (EVP_PKEY *key)
 
 PublicKey_OpenSSL (const Pem &pem)
 
 PublicKey_OpenSSL (std::span< const uint8_t > der)
 
 PublicKey_OpenSSL (const JsonWebKeyECPublic &jwk)
 
virtual ~PublicKey_OpenSSL ()
 
virtual bool verify_hash (const uint8_t *hash, size_t hash_size, const uint8_t *sig, size_t sig_size, MDType md_type) override
 
int get_openssl_group_id () const
 
 operator EVP_PKEY * () const
 
virtual JsonWebKeyECPublic public_key_jwk (const std::optional< std::string > &kid=std::nullopt) const override
 
virtual bool verify (const uint8_t *contents, size_t contents_size, const uint8_t *sig, size_t sig_size, MDType md_type, HashBytes &bytes)=0
 
bool verify (const uint8_t *contents, size_t contents_size, const uint8_t *sig, size_t sig_size, MDType md_type=MDType::NONE)
 
virtual bool verify (const std::vector< uint8_t > &contents, const std::vector< uint8_t > &signature)
 
virtual bool verify_hash (const std::vector< uint8_t > &hash, const std::vector< uint8_t > &signature, MDType md_type)
 
virtual bool verify_hash (const uint8_t *hash, size_t hash_size, const uint8_t *sig, size_t sig_size, MDType md_type)=0
 
- Public Member Functions inherited from ccf::crypto::PublicKey
bool verify (const uint8_t *contents, size_t contents_size, const uint8_t *sig, size_t sig_size, MDType md_type=MDType::NONE)
 
- Public Member Functions inherited from ccf::crypto::KeyPair
virtual ~KeyPair ()=default
 
Pem create_csr (const std::string &subject_name) const
 
virtual Pem sign_csr (const Pem &issuer_cert, const Pem &signing_request, const std::string &valid_from, const std::string &valid_to, bool ca=false, Signer signer=Signer::SUBJECT) const
 
Pem self_sign (const std::string &name, const std::string &valid_from, const std::string &valid_to, const std::optional< SubjectAltName > subject_alt_name=std::nullopt, bool ca=true) const
 
Pem self_sign (const std::string &subject_name, const std::string &valid_from, const std::string &valid_to, const std::vector< SubjectAltName > &subject_alt_names, bool ca=true) const
 

Protected Member Functions

OpenSSL::Unique_X509_REQ create_req (const std::string &subject_name, const std::vector< SubjectAltName > &subject_alt_names, const std::optional< Pem > &public_key) const
 
- Protected Member Functions inherited from ccf::crypto::PublicKey_OpenSSL
 PublicKey_OpenSSL ()
 

Additional Inherited Members

- Public Types inherited from ccf::crypto::KeyPair
enum class  Signer { SUBJECT = 0 , ISSUER = 1 }
 
- Static Public Member Functions inherited from ccf::crypto::PublicKey_OpenSSL
static int get_openssl_group_id (CurveID gid)
 
- Static Protected Member Functions inherited from ccf::crypto::PublicKey_OpenSSL
static std::vector< uint8_t > ec_point_public_from_jwk (const JsonWebKeyECPublic &jwk)
 
- Protected Attributes inherited from ccf::crypto::PublicKey_OpenSSL
EVP_PKEY * key = nullptr
 

Constructor & Destructor Documentation

◆ KeyPair_OpenSSL() [1/4]

ccf::crypto::KeyPair_OpenSSL::KeyPair_OpenSSL ( CurveID  curve_id)

◆ KeyPair_OpenSSL() [2/4]

ccf::crypto::KeyPair_OpenSSL::KeyPair_OpenSSL ( const KeyPair_OpenSSL )
delete

◆ KeyPair_OpenSSL() [3/4]

ccf::crypto::KeyPair_OpenSSL::KeyPair_OpenSSL ( const Pem pem)

◆ KeyPair_OpenSSL() [4/4]

ccf::crypto::KeyPair_OpenSSL::KeyPair_OpenSSL ( const JsonWebKeyECPrivate jwk)

◆ ~KeyPair_OpenSSL()

virtual ccf::crypto::KeyPair_OpenSSL::~KeyPair_OpenSSL ( )
virtualdefault

Member Function Documentation

◆ coordinates()

PublicKey::Coordinates ccf::crypto::KeyPair_OpenSSL::coordinates ( ) const
overridevirtual

The x/y coordinates of the public key

Reimplemented from ccf::crypto::PublicKey_OpenSSL.

◆ create_csr()

Pem ccf::crypto::KeyPair_OpenSSL::create_csr ( const std::string &  subject_name,
const std::vector< SubjectAltName > &  subject_alt_names,
const std::optional< Pem > &  public_key = std::nullopt 
) const
overridevirtual

Implements ccf::crypto::KeyPair.

◆ create_csr_der()

std::vector< uint8_t > ccf::crypto::KeyPair_OpenSSL::create_csr_der ( const std::string &  subject_name,
const std::vector< SubjectAltName > &  subject_alt_names,
const std::optional< Pem > &  public_key = std::nullopt 
) const
overridevirtual

Implements ccf::crypto::KeyPair.

◆ create_req()

Unique_X509_REQ ccf::crypto::KeyPair_OpenSSL::create_req ( const std::string &  subject_name,
const std::vector< SubjectAltName > &  subject_alt_names,
const std::optional< Pem > &  public_key 
) const
protected

◆ derive_shared_secret()

std::vector< uint8_t > ccf::crypto::KeyPair_OpenSSL::derive_shared_secret ( const PublicKey peer_key)
overridevirtual

Implements ccf::crypto::KeyPair.

◆ get_curve_id()

CurveID ccf::crypto::KeyPair_OpenSSL::get_curve_id ( ) const
overridevirtual

The curve ID

Reimplemented from ccf::crypto::PublicKey_OpenSSL.

◆ private_key_der()

std::vector< uint8_t > ccf::crypto::KeyPair_OpenSSL::private_key_der ( ) const
overridevirtual

Implements ccf::crypto::KeyPair.

◆ private_key_jwk()

JsonWebKeyECPrivate ccf::crypto::KeyPair_OpenSSL::private_key_jwk ( const std::optional< std::string > &  kid = std::nullopt) const
overridevirtual

Implements ccf::crypto::KeyPair.

◆ private_key_pem()

Pem ccf::crypto::KeyPair_OpenSSL::private_key_pem ( ) const
overridevirtual

Implements ccf::crypto::KeyPair.

◆ public_key_der()

std::vector< uint8_t > ccf::crypto::KeyPair_OpenSSL::public_key_der ( ) const
overridevirtual

Get the public key in DER format

Reimplemented from ccf::crypto::PublicKey_OpenSSL.

◆ public_key_pem()

Pem ccf::crypto::KeyPair_OpenSSL::public_key_pem ( ) const
overridevirtual

Get the public key in PEM format

Reimplemented from ccf::crypto::PublicKey_OpenSSL.

◆ public_key_raw()

std::vector< uint8_t > ccf::crypto::KeyPair_OpenSSL::public_key_raw ( ) const
overridevirtual

Get the raw bytes of the public key

Reimplemented from ccf::crypto::PublicKey_OpenSSL.

◆ sign() [1/2]

std::vector< uint8_t > ccf::crypto::KeyPair_OpenSSL::sign ( std::span< const uint8_t >  d,
MDType  md_type = {} 
) const
overridevirtual

Implements ccf::crypto::KeyPair.

◆ sign() [2/2]

int ccf::crypto::KeyPair_OpenSSL::sign ( std::span< const uint8_t >  d,
size_t *  sig_size,
uint8_t *  sig,
MDType  md_type = {} 
) const

◆ sign_csr_impl()

Pem ccf::crypto::KeyPair_OpenSSL::sign_csr_impl ( const std::optional< Pem > &  issuer_cert,
const Pem signing_request,
const std::string &  valid_from,
const std::string &  valid_to,
bool  ca = false,
Signer  signer = Signer::SUBJECT 
) const
overridevirtual

Implements ccf::crypto::KeyPair.

◆ sign_hash() [1/2]

std::vector< uint8_t > ccf::crypto::KeyPair_OpenSSL::sign_hash ( const uint8_t *  hash,
size_t  hash_size 
) const
overridevirtual

Implements ccf::crypto::KeyPair.

◆ sign_hash() [2/2]

int ccf::crypto::KeyPair_OpenSSL::sign_hash ( const uint8_t *  hash,
size_t  hash_size,
size_t *  sig_size,
uint8_t *  sig 
) const
overridevirtual

Implements ccf::crypto::KeyPair.

◆ verify() [1/3]

bool ccf::crypto::KeyPair_OpenSSL::verify ( const std::vector< uint8_t > &  contents,
const std::vector< uint8_t > &  signature 
)
overridevirtual

Verify that a signature was produced on contents with the private key associated with the public key held by the object.

Parameters
contentsSequence of bytes that was signed
signatureSignature as a sequence of bytes
Returns
Whether the signature matches the contents and the key

Reimplemented from ccf::crypto::PublicKey.

◆ verify() [2/3]

bool ccf::crypto::PublicKey_OpenSSL::verify ( const uint8_t *  contents,
size_t  contents_size,
const uint8_t *  sig,
size_t  sig_size,
MDType  md_type,
HashBytes bytes 
)
overridevirtual

Verify that a signature was produced on contents with the private key associated with the public key held by the object.

Parameters
contentsaddress of contents
contents_sizesize of contents
sigaddress of signature
sig_sizesize of signature
md_typeDigest algorithm to use
bytesBuffer to write the hash to
Returns
Whether the signature matches the contents and the key

Reimplemented from ccf::crypto::PublicKey_OpenSSL.

◆ verify() [3/3]

bool ccf::crypto::KeyPair_OpenSSL::verify ( const uint8_t *  contents,
size_t  contents_size,
const uint8_t *  signature,
size_t  signature_size 
)
overridevirtual

Implements ccf::crypto::KeyPair.


The documentation for this class was generated from the following files: