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

#include <public_key.h>

Inherits ccf::crypto::PublicKey.

Inherited by ccf::crypto::KeyPair_OpenSSL, and ccf::crypto::RSAPublicKey_OpenSSL.

Public Member Functions

 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 (const uint8_t *contents, size_t contents_size, const uint8_t *sig, size_t sig_size, MDType md_type, HashBytes &bytes) override
 
virtual bool verify_hash (const uint8_t *hash, size_t hash_size, const uint8_t *sig, size_t sig_size, MDType md_type) override
 
virtual Pem public_key_pem () const override
 
virtual std::vector< uint8_t > public_key_der () const override
 
virtual std::vector< uint8_t > public_key_raw () const override
 
virtual CurveID get_curve_id () const override
 
int get_openssl_group_id () const
 
 operator EVP_PKEY * () const
 
virtual Coordinates coordinates () const override
 
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)
 

Static Public Member Functions

static int get_openssl_group_id (CurveID gid)
 

Protected Member Functions

 PublicKey_OpenSSL ()
 

Static Protected Member Functions

static std::vector< uint8_t > ec_point_public_from_jwk (const JsonWebKeyECPublic &jwk)
 

Protected Attributes

EVP_PKEY * key = nullptr
 

Constructor & Destructor Documentation

◆ PublicKey_OpenSSL() [1/6]

ccf::crypto::PublicKey_OpenSSL::PublicKey_OpenSSL ( )
protecteddefault

◆ PublicKey_OpenSSL() [2/6]

ccf::crypto::PublicKey_OpenSSL::PublicKey_OpenSSL ( PublicKey_OpenSSL &&  key)
default

◆ PublicKey_OpenSSL() [3/6]

ccf::crypto::PublicKey_OpenSSL::PublicKey_OpenSSL ( EVP_PKEY *  key)

◆ PublicKey_OpenSSL() [4/6]

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

◆ PublicKey_OpenSSL() [5/6]

ccf::crypto::PublicKey_OpenSSL::PublicKey_OpenSSL ( std::span< const uint8_t >  der)

◆ PublicKey_OpenSSL() [6/6]

ccf::crypto::PublicKey_OpenSSL::PublicKey_OpenSSL ( const JsonWebKeyECPublic jwk)

◆ ~PublicKey_OpenSSL()

ccf::crypto::PublicKey_OpenSSL::~PublicKey_OpenSSL ( )
virtual

Member Function Documentation

◆ coordinates()

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

The x/y coordinates of the public key

Implements ccf::crypto::PublicKey.

Reimplemented in ccf::crypto::KeyPair_OpenSSL.

◆ ec_point_public_from_jwk()

std::vector< uint8_t > ccf::crypto::PublicKey_OpenSSL::ec_point_public_from_jwk ( const JsonWebKeyECPublic jwk)
staticprotected

◆ get_curve_id()

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

The curve ID

Implements ccf::crypto::PublicKey.

Reimplemented in ccf::crypto::KeyPair_OpenSSL.

◆ get_openssl_group_id() [1/2]

int ccf::crypto::PublicKey_OpenSSL::get_openssl_group_id ( ) const

◆ get_openssl_group_id() [2/2]

int ccf::crypto::PublicKey_OpenSSL::get_openssl_group_id ( CurveID  gid)
static

◆ operator EVP_PKEY *()

ccf::crypto::PublicKey_OpenSSL::operator EVP_PKEY * ( ) const
inline

◆ public_key_der()

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

◆ public_key_jwk()

JsonWebKeyECPublic ccf::crypto::PublicKey_OpenSSL::public_key_jwk ( const std::optional< std::string > &  kid = std::nullopt) const
overridevirtual

◆ public_key_pem()

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

◆ public_key_raw()

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

Get the raw bytes of the public key

Implements ccf::crypto::PublicKey.

Reimplemented in ccf::crypto::KeyPair_OpenSSL.

◆ verify() [1/4]

virtual bool ccf::crypto::PublicKey::verify ( const std::vector< uint8_t > &  contents,
const std::vector< uint8_t > &  signature 
)
inlinevirtual

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/4]

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

Implements ccf::crypto::PublicKey.

Reimplemented in ccf::crypto::KeyPair_OpenSSL.

◆ verify() [3/4]

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

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::PublicKey.

◆ verify() [4/4]

bool ccf::crypto::PublicKey::verify ( const uint8_t *  contents,
size_t  contents_size,
const uint8_t *  sig,
size_t  sig_size,
MDType  md_type = MDType::NONE 
)
inline

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 (derived from the public key if md_type == MDType::None).
Returns
Whether the signature matches the contents and the key

◆ verify_hash() [1/3]

virtual bool ccf::crypto::PublicKey::verify_hash ( const std::vector< uint8_t > &  hash,
const std::vector< uint8_t > &  signature,
MDType  md_type 
)
inlinevirtual

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

Parameters
hashHash of some content
signatureSignature as a sequence of bytes
md_typeType of hash
Returns
Whether the signature matches the hash and the key

Reimplemented from ccf::crypto::PublicKey.

◆ verify_hash() [2/3]

bool ccf::crypto::PublicKey_OpenSSL::verify_hash ( const uint8_t *  hash,
size_t  hash_size,
const uint8_t *  sig,
size_t  sig_size,
MDType  md_type 
)
overridevirtual

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

Parameters
hashHash of some content
hash_sizelength of hash
sigSignature as a sequence of bytes
sig_sizeLength of sig
md_typeDigest algorithm
Returns
Whether the signature matches the hash and the key

Implements ccf::crypto::PublicKey.

◆ verify_hash() [3/3]

virtual bool ccf::crypto::PublicKey::verify_hash ( const uint8_t *  hash,
size_t  hash_size,
const uint8_t *  sig,
size_t  sig_size,
MDType  md_type 
)
virtual

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

Parameters
hashHash of some content
hash_sizelength of hash
sigSignature as a sequence of bytes
sig_sizeLength of sig
md_typeDigest algorithm
Returns
Whether the signature matches the hash and the key

Implements ccf::crypto::PublicKey.

Member Data Documentation

◆ key

EVP_PKEY* ccf::crypto::PublicKey_OpenSSL::key = nullptr
protected

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