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

#include <ec_key_pair.h>

Inherits ccf::crypto::ECPublicKey_OpenSSL, and ccf::crypto::ECKeyPair.

Public Member Functions

 ECKeyPair_OpenSSL (CurveID curve_id)
 
 ECKeyPair_OpenSSL (const ECKeyPair_OpenSSL &)=delete
 
 ECKeyPair_OpenSSL (const Pem &pem)
 
 ECKeyPair_OpenSSL (const JsonWebKeyECPrivate &jwk)
 
 ~ECKeyPair_OpenSSL () override=default
 
Pem private_key_pem () const override
 
Pem public_key_pem () const override
 
std::vector< uint8_t > public_key_der () const override
 
std::vector< uint8_t > private_key_der () const override
 
bool verify (const std::vector< uint8_t > &contents, const std::vector< uint8_t > &signature) override
 
bool verify (const uint8_t *contents, size_t contents_size, const uint8_t *signature, size_t signature_size) override
 
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
 
int sign_hash (const uint8_t *hash, size_t hash_size, size_t *sig_size, uint8_t *sig) const override
 
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
 
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
 
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
 
std::vector< uint8_t > derive_shared_secret (const ECPublicKey &peer_key) override
 
CurveID get_curve_id () const override
 
std::vector< uint8_t > public_key_raw () const override
 
ECPublicKey::Coordinates coordinates () const override
 
JsonWebKeyECPrivate private_key_jwk (const std::optional< std::string > &kid=std::nullopt) const override
 
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::ECPublicKey_OpenSSL
 ECPublicKey_OpenSSL (EVP_PKEY *key)
 
 ECPublicKey_OpenSSL (const Pem &pem)
 
 ECPublicKey_OpenSSL (ECPublicKey_OpenSSL &&key)=default
 
 ECPublicKey_OpenSSL (std::span< const uint8_t > der)
 
 ECPublicKey_OpenSSL (const JsonWebKeyECPublic &jwk)
 
 ~ECPublicKey_OpenSSL () override
 
bool verify (const uint8_t *contents, size_t contents_size, const uint8_t *sig, size_t sig_size, MDType md_type, HashBytes &bytes) override
 
bool verify_hash (const uint8_t *hash, size_t hash_size, const uint8_t *sig, size_t sig_size, MDType md_type) override
 
Pem public_key_pem () const override
 
std::vector< uint8_t > public_key_der () const override
 
std::vector< uint8_t > public_key_raw () const override
 
CurveID get_curve_id () const override
 
int get_openssl_group_id () const
 
Coordinates coordinates () const override
 
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::ECPublicKey
virtual ~ECPublicKey ()=default
 
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::PublicKey_OpenSSL
 PublicKey_OpenSSL ()=default
 
 PublicKey_OpenSSL (EVP_PKEY *key)
 
 PublicKey_OpenSSL (const Pem &pem)
 
void check_is_cose_compatible (int cose_alg)
 
 operator EVP_PKEY * () const
 
virtual ~PublicKey_OpenSSL ()
 
- Public Member Functions inherited from ccf::crypto::ECKeyPair
virtual ~ECKeyPair ()=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::ECPublicKey_OpenSSL
 ECPublicKey_OpenSSL ()
 

Additional Inherited Members

- Public Types inherited from ccf::crypto::ECKeyPair
enum class  Signer : std::uint8_t { SUBJECT = 0 , ISSUER = 1 }
 
- Static Public Member Functions inherited from ccf::crypto::ECPublicKey_OpenSSL
static int get_openssl_group_id (CurveID gid)
 
- Static Protected Member Functions inherited from ccf::crypto::ECPublicKey_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

◆ ECKeyPair_OpenSSL() [1/4]

ccf::crypto::ECKeyPair_OpenSSL::ECKeyPair_OpenSSL ( CurveID  curve_id)

◆ ECKeyPair_OpenSSL() [2/4]

ccf::crypto::ECKeyPair_OpenSSL::ECKeyPair_OpenSSL ( const ECKeyPair_OpenSSL )
delete

◆ ECKeyPair_OpenSSL() [3/4]

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

◆ ECKeyPair_OpenSSL() [4/4]

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

◆ ~ECKeyPair_OpenSSL()

ccf::crypto::ECKeyPair_OpenSSL::~ECKeyPair_OpenSSL ( )
overridedefault

Member Function Documentation

◆ coordinates()

ECPublicKey::Coordinates ccf::crypto::ECKeyPair_OpenSSL::coordinates ( ) const
overridevirtual

The x/y coordinates of the public key

Implements ccf::crypto::ECPublicKey.

◆ create_csr()

Pem ccf::crypto::ECKeyPair_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

◆ create_csr_der()

std::vector< uint8_t > ccf::crypto::ECKeyPair_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

◆ create_req()

Unique_X509_REQ ccf::crypto::ECKeyPair_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::ECKeyPair_OpenSSL::derive_shared_secret ( const ECPublicKey peer_key)
overridevirtual

◆ get_curve_id()

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

The curve ID

Implements ccf::crypto::ECPublicKey.

◆ private_key_der()

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

◆ private_key_jwk()

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

◆ private_key_pem()

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

◆ public_key_der()

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

Get the public key in DER format

Implements ccf::crypto::ECPublicKey.

◆ public_key_pem()

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

Get the public key in PEM format

Implements ccf::crypto::ECPublicKey.

◆ public_key_raw()

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

Get the raw bytes of the public key

Implements ccf::crypto::ECPublicKey.

◆ sign() [1/2]

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

◆ sign() [2/2]

int ccf::crypto::ECKeyPair_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::ECKeyPair_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

◆ sign_hash() [1/2]

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

◆ sign_hash() [2/2]

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

◆ verify() [1/3]

bool ccf::crypto::ECKeyPair_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::ECPublicKey.

◆ verify() [2/3]

bool ccf::crypto::ECPublicKey_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

Implements ccf::crypto::ECPublicKey.

◆ verify() [3/3]

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

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