CCF
|
Namespaces | |
namespace | OpenSSL |
namespace | sharing |
Typedefs | |
using | COSEVerifierUniquePtr = std::unique_ptr< COSEVerifier > |
using | EdDSAPublicKeyPtr = std::shared_ptr< EdDSAPublicKey > |
using | EdDSAKeyPairPtr = std::shared_ptr< EdDSAKeyPair > |
using | EntropyPtr = std::shared_ptr< Entropy > |
using | HashBytes = std::vector< uint8_t > |
using | PublicKeyPtr = std::shared_ptr< PublicKey > |
using | KeyPairPtr = std::shared_ptr< KeyPair > |
using | RSAPublicKeyPtr = std::shared_ptr< RSAPublicKey > |
using | RSAKeyPairPtr = std::shared_ptr< RSAKeyPair > |
using | StandardGcmHeader = FixedSizeGcmHeader< 12 > |
using | VerifierPtr = std::shared_ptr< Verifier > |
using | VerifierUniquePtr = std::unique_ptr< Verifier > |
using | Base64Impl = Base64_openssl |
using | PublicKeyImpl = EdDSAPublicKey_OpenSSL |
using | KeyPairImpl = EdDSAKeyPair_OpenSSL |
using | COSEHeadersArray = std::vector< std::shared_ptr< ccf::crypto::COSEParametersFactory > > |
using | RSAPublicKeyImpl = RSAPublicKey_OpenSSL |
using | RSAKeyPairImpl = RSAKeyPair_OpenSSL |
Enumerations | |
enum class | CurveID { NONE = 0 , SECP384R1 , SECP256R1 , CURVE25519 , X25519 } |
enum class | JsonWebKeyType { EC = 0 , RSA = 1 , OKP = 2 } |
enum class | JsonWebKeyECCurve { P256 = 0 , P384 = 1 , P521 = 2 } |
enum class | JsonWebKeyEdDSACurve { ED25519 = 0 , X25519 = 1 } |
enum class | MDType { NONE = 0 , SHA1 , SHA256 , SHA384 , SHA512 } |
Functions | |
std::vector< uint8_t > | raw_from_b64 (const std::string_view &b64_string) |
std::vector< uint8_t > | raw_from_b64url (const std::string_view &b64url_string) |
std::string | b64_from_raw (const uint8_t *data, size_t size) |
std::string | b64_from_raw (const std::vector< uint8_t > &data) |
std::string | b64url_from_raw (const uint8_t *data, size_t size, bool with_padding=true) |
std::string | b64url_from_raw (const std::vector< uint8_t > &data, bool with_padding=true) |
COSEVerifierUniquePtr | make_cose_verifier_from_cert (const std::vector< uint8_t > &cert) |
COSEVerifierUniquePtr | make_cose_verifier_from_key (const Pem &public_key) |
COSEEndorsementValidity | extract_cose_endorsement_validity (std::span< const uint8_t > cose_msg) |
DECLARE_JSON_ENUM (CurveID, {{CurveID::NONE, "None"}, {CurveID::SECP384R1, "Secp384R1"}, {CurveID::SECP256R1, "Secp256R1"}, {CurveID::CURVE25519, "Curve25519"}, {CurveID::X25519, "X25519"}}) | |
MDType | get_md_for_ec (CurveID ec) |
std::vector< uint8_t > | ecdsa_sig_from_r_s (const uint8_t *r, size_t r_size, const uint8_t *s, size_t s_size, bool big_endian=true) |
std::vector< uint8_t > | ecdsa_sig_p1363_to_der (std::span< const uint8_t > signature) |
std::vector< uint8_t > | ecdsa_sig_der_to_p1363 (const std::vector< uint8_t > &signature, CurveID curveId) |
EdDSAPublicKeyPtr | make_eddsa_public_key (const Pem &pem) |
EdDSAPublicKeyPtr | make_eddsa_public_key (const JsonWebKeyEdDSAPublic &jwk) |
EdDSAKeyPairPtr | make_eddsa_key_pair (CurveID curve_id=CurveID::CURVE25519) |
EdDSAKeyPairPtr | make_eddsa_key_pair (const Pem &pem) |
EdDSAKeyPairPtr | make_eddsa_key_pair (const JsonWebKeyEdDSAPrivate &jwk) |
EntropyPtr | get_entropy () |
std::shared_ptr< HashProvider > | make_hash_provider () |
std::shared_ptr< ISha256Hash > | make_incremental_sha256 () |
std::vector< uint8_t > | hkdf (MDType md_type, size_t length, const std::span< const uint8_t > &ikm, const std::span< const uint8_t > &salt={}, const std::span< const uint8_t > &info={}) |
HashBytes | hmac (MDType type, const std::vector< uint8_t > &key, const std::vector< uint8_t > &data) |
DECLARE_JSON_ENUM (JsonWebKeyType, {{JsonWebKeyType::EC, "EC"}, {JsonWebKeyType::RSA, "RSA"}, {JsonWebKeyType::OKP, "OKP"}}) | |
DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS (JsonWebKey) | |
DECLARE_JSON_REQUIRED_FIELDS (JsonWebKey, kty) | |
DECLARE_JSON_OPTIONAL_FIELDS (JsonWebKey, kid, x5c) | |
DECLARE_JSON_ENUM (JsonWebKeyECCurve, {{JsonWebKeyECCurve::P256, "P-256"}, {JsonWebKeyECCurve::P384, "P-384"}, {JsonWebKeyECCurve::P521, "P-521"}}) | |
DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS (JsonWebKeyData) | |
DECLARE_JSON_REQUIRED_FIELDS (JsonWebKeyData, kty) | |
DECLARE_JSON_OPTIONAL_FIELDS (JsonWebKeyData, kid, x5c, n, e, x, y, crv, issuer) | |
DECLARE_JSON_ENUM (JsonWebKeyEdDSACurve, {{JsonWebKeyEdDSACurve::ED25519, "Ed25519"}, {JsonWebKeyEdDSACurve::X25519, "X25519"}}) | |
DECLARE_JSON_TYPE_WITH_BASE (JsonWebKeyECPublic, JsonWebKey) | |
DECLARE_JSON_REQUIRED_FIELDS (JsonWebKeyECPublic, crv, x, y) | |
DECLARE_JSON_TYPE_WITH_BASE (JsonWebKeyECPrivate, JsonWebKeyECPublic) | |
DECLARE_JSON_REQUIRED_FIELDS (JsonWebKeyECPrivate, d) | |
DECLARE_JSON_TYPE_WITH_BASE (JsonWebKeyRSAPublic, JsonWebKey) | |
DECLARE_JSON_REQUIRED_FIELDS (JsonWebKeyRSAPublic, n, e) | |
DECLARE_JSON_TYPE_WITH_BASE (JsonWebKeyRSAPrivate, JsonWebKeyRSAPublic) | |
DECLARE_JSON_REQUIRED_FIELDS (JsonWebKeyRSAPrivate, d, p, q, dp, dq, qi) | |
DECLARE_JSON_TYPE_WITH_BASE (JsonWebKeyEdDSAPublic, JsonWebKey) | |
DECLARE_JSON_REQUIRED_FIELDS (JsonWebKeyEdDSAPublic, crv, x) | |
DECLARE_JSON_TYPE_WITH_BASE (JsonWebKeyEdDSAPrivate, JsonWebKeyEdDSAPublic) | |
DECLARE_JSON_REQUIRED_FIELDS (JsonWebKeyEdDSAPrivate, d) | |
PublicKeyPtr | make_public_key (const Pem &pem) |
PublicKeyPtr | make_public_key (const std::vector< uint8_t > &der) |
PublicKeyPtr | make_public_key (const JsonWebKeyECPublic &jwk) |
KeyPairPtr | make_key_pair (CurveID curve_id=service_identity_curve_choice) |
KeyPairPtr | make_key_pair (const Pem &pem) |
KeyPairPtr | make_key_pair (const JsonWebKeyECPrivate &jwk) |
std::vector< uint8_t > | ckm_rsa_pkcs_oaep_wrap (RSAPublicKeyPtr wrapping_key, const std::vector< uint8_t > &unwrapped, const std::optional< std::vector< uint8_t > > &label={}) |
std::vector< uint8_t > | ckm_rsa_pkcs_oaep_wrap (const Pem &wrapping_key, const std::vector< uint8_t > &unwrapped, const std::optional< std::vector< uint8_t > > &label={}) |
std::vector< uint8_t > | ckm_rsa_pkcs_oaep_unwrap (RSAKeyPairPtr wrapping_key, const std::vector< uint8_t > &wrapped, const std::optional< std::vector< uint8_t > > &label={}) |
std::vector< uint8_t > | ckm_rsa_pkcs_oaep_unwrap (const Pem &wrapping_key, const std::vector< uint8_t > &wrapped, const std::optional< std::vector< uint8_t > > &label={}) |
std::vector< uint8_t > | ckm_aes_key_wrap_pad (const std::vector< uint8_t > &wrapping_key, const std::vector< uint8_t > &unwrapped) |
std::vector< uint8_t > | ckm_aes_key_unwrap_pad (const std::vector< uint8_t > &wrapping_key, const std::vector< uint8_t > &wrapped) |
std::vector< uint8_t > | ckm_rsa_aes_key_wrap (size_t aes_key_size, RSAPublicKeyPtr wrapping_key, const std::vector< uint8_t > &unwrapped, const std::optional< std::vector< uint8_t > > &label={}) |
std::vector< uint8_t > | ckm_rsa_aes_key_wrap (size_t aes_key_size, const Pem &wrapping_key, const std::vector< uint8_t > &unwrapped, const std::optional< std::vector< uint8_t > > &label={}) |
std::vector< uint8_t > | ckm_rsa_aes_key_unwrap (RSAKeyPairPtr wrapping_key, const std::vector< uint8_t > &wrapped, const std::optional< std::vector< uint8_t > > &label={}) |
std::vector< uint8_t > | ckm_rsa_aes_key_unwrap (const Pem &wrapping_key, const std::vector< uint8_t > &wrapped, const std::optional< std::vector< uint8_t > > &label={}) |
DECLARE_JSON_ENUM (MDType, {{MDType::NONE, "NONE"}, {MDType::SHA1, "SHA1"}, {MDType::SHA256, "SHA256"}, {MDType::SHA384, "SHA384"}, {MDType::SHA512, "SHA512"}}) | |
void | openssl_sha256_init () |
void | openssl_sha256_shutdown () |
void | to_json (nlohmann::json &j, const Pem &p) |
void | from_json (const nlohmann::json &j, Pem &p) |
std::string | schema_name (const Pem *) |
std::vector< ccf::crypto::Pem > | split_x509_cert_bundle (const std::string_view &pem) |
void | fill_json_schema (nlohmann::json &schema, const Pem *) |
RSAPublicKeyPtr | make_rsa_public_key (const Pem &pem) |
RSAPublicKeyPtr | make_rsa_public_key (const std::vector< uint8_t > &der) |
RSAPublicKeyPtr | make_rsa_public_key (const JsonWebKeyRSAPublic &jwk) |
RSAPublicKeyPtr | make_rsa_public_key (const uint8_t *data, size_t size) |
RSAKeyPairPtr | make_rsa_key_pair (size_t public_key_size=RSAKeyPair::default_public_key_size, size_t public_exponent=RSAKeyPair::default_public_exponent) |
RSAKeyPairPtr | make_rsa_key_pair (const Pem &pem) |
RSAKeyPairPtr | make_rsa_key_pair (const JsonWebKeyRSAPrivate &jwk) |
DECLARE_JSON_TYPE (SubjectAltName) | |
DECLARE_JSON_REQUIRED_FIELDS (SubjectAltName, san, is_ip) | |
HashBytes | sha256 (const std::span< uint8_t const > &data) |
HashBytes | sha256 (const uint8_t *data, size_t len) |
void | to_json (nlohmann::json &j, const Sha256Hash &hash) |
void | from_json (const nlohmann::json &j, Sha256Hash &hash) |
std::string | schema_name (const Sha256Hash *) |
void | fill_json_schema (nlohmann::json &schema, const Sha256Hash *) |
bool | operator== (const Sha256Hash &lhs, const Sha256Hash &rhs) |
bool | operator!= (const Sha256Hash &lhs, const Sha256Hash &rhs) |
std::unique_ptr< KeyAesGcm > | make_key_aes_gcm (std::span< const uint8_t > rawKey) |
Free function implementation. | |
void | check_supported_aes_key_size (size_t num_bits) |
std::vector< uint8_t > | aes_gcm_encrypt (std::span< const uint8_t > key, std::span< const uint8_t > plaintext, const std::vector< uint8_t > &iv=default_iv, const std::vector< uint8_t > &aad={}) |
std::vector< uint8_t > | aes_gcm_decrypt (std::span< const uint8_t > key, std::span< const uint8_t > ciphertext, const std::vector< uint8_t > &iv=default_iv, const std::vector< uint8_t > &aad={}) |
VerifierUniquePtr | make_unique_verifier (const std::vector< uint8_t > &cert) |
VerifierPtr | make_verifier (const std::vector< uint8_t > &cert) |
VerifierUniquePtr | make_unique_verifier (const Pem &pem) |
VerifierPtr | make_verifier (const Pem &pem) |
ccf::crypto::Pem | cert_der_to_pem (const std::vector< uint8_t > &der) |
std::vector< uint8_t > | cert_pem_to_der (const Pem &pem) |
std::vector< uint8_t > | public_key_der_from_cert (const std::vector< uint8_t > &der) |
ccf::crypto::Pem | public_key_pem_from_cert (const std::vector< uint8_t > &der) |
std::string | get_subject_name (const Pem &cert) |
Pem | public_key_pem_from_csr (const Pem &signing_request) |
void | default_sha256 (const std::span< const uint8_t > &data, uint8_t *h) |
std::vector< uint8_t > | sha256 (const std::vector< uint8_t > &data) |
std::optional< int > | key_to_cose_alg_id (const ccf::crypto::PublicKey_OpenSSL &key) |
std::shared_ptr< COSEParametersFactory > | cose_params_int_int (int64_t key, int64_t value) |
std::shared_ptr< COSEParametersFactory > | cose_params_int_string (int64_t key, const std::string &value) |
std::shared_ptr< COSEParametersFactory > | cose_params_string_int (const std::string &key, int64_t value) |
std::shared_ptr< COSEParametersFactory > | cose_params_string_string (const std::string &key, const std::string &value) |
std::shared_ptr< COSEParametersFactory > | cose_params_int_bytes (int64_t key, std::span< const uint8_t > value) |
std::shared_ptr< COSEParametersFactory > | cose_params_string_bytes (const std::string &key, std::span< const uint8_t > value) |
std::vector< uint8_t > | cose_sign1 (const KeyPair_OpenSSL &key, const std::vector< std::shared_ptr< COSEParametersFactory > > &protected_headers, std::span< const uint8_t > payload, bool detached_payload) |
void | openssl_sha256 (const std::span< const uint8_t > &data, uint8_t *h) |
std::pair< Unique_BIGNUM, Unique_BIGNUM > | get_components (const JsonWebKeyECPublic &jwk) |
Unique_PKEY | key_from_raw_ec_point (const std::vector< uint8_t > &raw, int nid) |
std::pair< Unique_BIGNUM, Unique_BIGNUM > | get_modulus_and_exponent (const JsonWebKeyRSAPublic &jwk) |
std::ostream & | operator<< (std::ostream &os, const ccf::crypto::Sha256Hash &h) |
Variables | |
constexpr size_t | GCM_DEFAULT_KEY_SIZE = 32 |
constexpr size_t | GCM_SIZE_TAG = 16 |
using ccf::crypto::Base64Impl = typedef Base64_openssl |
using ccf::crypto::COSEHeadersArray = typedef std::vector<std::shared_ptr<ccf::crypto::COSEParametersFactory> > |
using ccf::crypto::COSEVerifierUniquePtr = typedef std::unique_ptr<COSEVerifier> |
using ccf::crypto::EdDSAKeyPairPtr = typedef std::shared_ptr<EdDSAKeyPair> |
using ccf::crypto::EdDSAPublicKeyPtr = typedef std::shared_ptr<EdDSAPublicKey> |
using ccf::crypto::EntropyPtr = typedef std::shared_ptr<Entropy> |
using ccf::crypto::HashBytes = typedef std::vector<uint8_t> |
using ccf::crypto::KeyPairPtr = typedef std::shared_ptr<KeyPair> |
using ccf::crypto::PublicKeyPtr = typedef std::shared_ptr<PublicKey> |
using ccf::crypto::RSAKeyPairImpl = typedef RSAKeyPair_OpenSSL |
using ccf::crypto::RSAKeyPairPtr = typedef std::shared_ptr<RSAKeyPair> |
using ccf::crypto::RSAPublicKeyImpl = typedef RSAPublicKey_OpenSSL |
using ccf::crypto::RSAPublicKeyPtr = typedef std::shared_ptr<RSAPublicKey> |
using ccf::crypto::StandardGcmHeader = typedef FixedSizeGcmHeader<12> |
typedef std::shared_ptr< Verifier > ccf::crypto::VerifierPtr |
typedef std::unique_ptr< Verifier > ccf::crypto::VerifierUniquePtr |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
std::vector< uint8_t > ccf::crypto::aes_gcm_decrypt | ( | std::span< const uint8_t > | key, |
std::span< const uint8_t > | ciphertext, | ||
const std::vector< uint8_t > & | iv = default_iv , |
||
const std::vector< uint8_t > & | aad = {} |
||
) |
AES-GCM Decryption with key
of data
key | The key |
ciphertext | The (encrypted) data |
iv | Initialization vector |
aad | Additional authenticated data |
std::vector< uint8_t > ccf::crypto::aes_gcm_encrypt | ( | std::span< const uint8_t > | key, |
std::span< const uint8_t > | plaintext, | ||
const std::vector< uint8_t > & | iv = default_iv , |
||
const std::vector< uint8_t > & | aad = {} |
||
) |
AES-GCM Encryption with key
of data
key | The key |
plaintext | The data |
iv | Intialization vector |
aad | Additional authenticated data |
std::string ccf::crypto::b64_from_raw | ( | const std::vector< uint8_t > & | data | ) |
std::string ccf::crypto::b64_from_raw | ( | const uint8_t * | data, |
size_t | size | ||
) |
std::string ccf::crypto::b64url_from_raw | ( | const std::vector< uint8_t > & | data, |
bool | with_padding = true |
||
) |
std::string ccf::crypto::b64url_from_raw | ( | const uint8_t * | data, |
size_t | size, | ||
bool | with_padding = true |
||
) |
ccf::crypto::Pem ccf::crypto::cert_der_to_pem | ( | const std::vector< uint8_t > & | der | ) |
std::vector< uint8_t > ccf::crypto::cert_pem_to_der | ( | const Pem & | pem | ) |
|
inline |
Check for unsupported AES key sizes num_bits
Key size in bits
std::vector< uint8_t > ccf::crypto::ckm_aes_key_unwrap_pad | ( | const std::vector< uint8_t > & | wrapping_key, |
const std::vector< uint8_t > & | wrapped | ||
) |
PKCS11 2.14.3 CKM_AES_KEY_WRAP_PAD unwrap
wrapping_key | The wrapping (encryption) key |
wrapped | The wrapped key to unwrap |
std::vector< uint8_t > ccf::crypto::ckm_aes_key_wrap_pad | ( | const std::vector< uint8_t > & | wrapping_key, |
const std::vector< uint8_t > & | unwrapped | ||
) |
PKCS11 2.14.3 CKM_AES_KEY_WRAP_PAD wrap
wrapping_key | The wrapping (encryption) key |
unwrapped | The unwrapped key to be wrapped |
std::vector< uint8_t > ccf::crypto::ckm_rsa_aes_key_unwrap | ( | const Pem & | wrapping_key, |
const std::vector< uint8_t > & | wrapped, | ||
const std::optional< std::vector< uint8_t > > & | label = {} |
||
) |
PKCS11 2.1.21 CKM_RSA_AES_KEY_WRAP unwrap
wrapping_key | The wrapping (encryption) key |
wrapped | The wrapped key to unwrap |
label | Optional label |
std::vector< uint8_t > ccf::crypto::ckm_rsa_aes_key_unwrap | ( | RSAKeyPairPtr | wrapping_key, |
const std::vector< uint8_t > & | wrapped, | ||
const std::optional< std::vector< uint8_t > > & | label = {} |
||
) |
PKCS11 2.1.21 CKM_RSA_AES_KEY_WRAP unwrap
wrapping_key | The wrapping (encryption) key |
wrapped | The wrapped key to unwrap |
label | Optional label |
std::vector< uint8_t > ccf::crypto::ckm_rsa_aes_key_wrap | ( | size_t | aes_key_size, |
const Pem & | wrapping_key, | ||
const std::vector< uint8_t > & | unwrapped, | ||
const std::optional< std::vector< uint8_t > > & | label = {} |
||
) |
PKCS11 2.1.21 CKM_RSA_AES_KEY_WRAP wrap
aes_key_size | Key size 128, 192 or 256. |
wrapping_key | The wrapping (encryption) key |
unwrapped | The key to wrap |
label | Optional label |
std::vector< uint8_t > ccf::crypto::ckm_rsa_aes_key_wrap | ( | size_t | aes_key_size, |
RSAPublicKeyPtr | wrapping_key, | ||
const std::vector< uint8_t > & | unwrapped, | ||
const std::optional< std::vector< uint8_t > > & | label = {} |
||
) |
PKCS11 2.1.21 CKM_RSA_AES_KEY_WRAP wrap
aes_key_size | Key size 128, 192 or 256. |
wrapping_key | The wrapping (encryption) key |
unwrapped | The key to wrap |
label | Optional label |
std::vector< uint8_t > ccf::crypto::ckm_rsa_pkcs_oaep_unwrap | ( | const Pem & | wrapping_key, |
const std::vector< uint8_t > & | wrapped, | ||
const std::optional< std::vector< uint8_t > > & | label = {} |
||
) |
PKCS11 2.1.8 CKM_RSA_PKCS_OAEP
wrapping_key | The wrapping (encryption) key |
wrapped | The wrapped key to unwrap |
label | Optional label |
std::vector< uint8_t > ccf::crypto::ckm_rsa_pkcs_oaep_unwrap | ( | RSAKeyPairPtr | wrapping_key, |
const std::vector< uint8_t > & | wrapped, | ||
const std::optional< std::vector< uint8_t > > & | label = {} |
||
) |
PKCS11 2.1.8 CKM_RSA_PKCS_OAEP unwrap
wrapping_key | The wrapping (encryption) key |
wrapped | The wrapped key to unwrap |
label | Optional label |
std::vector< uint8_t > ccf::crypto::ckm_rsa_pkcs_oaep_wrap | ( | const Pem & | wrapping_key, |
const std::vector< uint8_t > & | unwrapped, | ||
const std::optional< std::vector< uint8_t > > & | label = {} |
||
) |
PKCS11 2.1.8 CKM_RSA_PKCS_OAEP
wrapping_key | The wrapping (encryption) key |
unwrapped | The unwrapped key to be wrapped |
label | Optional label |
std::vector< uint8_t > ccf::crypto::ckm_rsa_pkcs_oaep_wrap | ( | RSAPublicKeyPtr | wrapping_key, |
const std::vector< uint8_t > & | unwrapped, | ||
const std::optional< std::vector< uint8_t > > & | label = {} |
||
) |
PKCS11 2.1.8 CKM_RSA_PKCS_OAEP wrap
wrapping_key | The wrapping (encryption) key |
unwrapped | The unwrapped key to be wrapped |
label | Optional label |
std::shared_ptr< COSEParametersFactory > ccf::crypto::cose_params_int_bytes | ( | int64_t | key, |
std::span< const uint8_t > | value | ||
) |
std::shared_ptr< COSEParametersFactory > ccf::crypto::cose_params_int_int | ( | int64_t | key, |
int64_t | value | ||
) |
std::shared_ptr< COSEParametersFactory > ccf::crypto::cose_params_int_string | ( | int64_t | key, |
const std::string & | value | ||
) |
std::shared_ptr< COSEParametersFactory > ccf::crypto::cose_params_string_bytes | ( | const std::string & | key, |
std::span< const uint8_t > | value | ||
) |
std::shared_ptr< COSEParametersFactory > ccf::crypto::cose_params_string_int | ( | const std::string & | key, |
int64_t | value | ||
) |
std::shared_ptr< COSEParametersFactory > ccf::crypto::cose_params_string_string | ( | const std::string & | key, |
const std::string & | value | ||
) |
std::vector< uint8_t > ccf::crypto::cose_sign1 | ( | const KeyPair_OpenSSL & | key, |
const std::vector< std::shared_ptr< COSEParametersFactory > > & | protected_headers, | ||
std::span< const uint8_t > | payload, | ||
bool | detached_payload | ||
) |
ccf::crypto::DECLARE_JSON_ENUM | ( | CurveID | , |
{{CurveID::NONE, "None"}, {CurveID::SECP384R1, "Secp384R1"}, {CurveID::SECP256R1, "Secp256R1"}, {CurveID::CURVE25519, "Curve25519"}, {CurveID::X25519, "X25519"}} | |||
) |
ccf::crypto::DECLARE_JSON_ENUM | ( | JsonWebKeyECCurve | , |
{{JsonWebKeyECCurve::P256, "P-256"}, {JsonWebKeyECCurve::P384, "P-384"}, {JsonWebKeyECCurve::P521, "P-521"}} | |||
) |
ccf::crypto::DECLARE_JSON_ENUM | ( | JsonWebKeyEdDSACurve | , |
{{JsonWebKeyEdDSACurve::ED25519, "Ed25519"}, {JsonWebKeyEdDSACurve::X25519, "X25519"}} | |||
) |
ccf::crypto::DECLARE_JSON_ENUM | ( | JsonWebKeyType | , |
{{JsonWebKeyType::EC, "EC"}, {JsonWebKeyType::RSA, "RSA"}, {JsonWebKeyType::OKP, "OKP"}} | |||
) |
ccf::crypto::DECLARE_JSON_ENUM | ( | MDType | , |
{{MDType::NONE, "NONE"}, {MDType::SHA1, "SHA1"}, {MDType::SHA256, "SHA256"}, {MDType::SHA384, "SHA384"}, {MDType::SHA512, "SHA512"}} | |||
) |
ccf::crypto::DECLARE_JSON_OPTIONAL_FIELDS | ( | JsonWebKey | , |
kid | , | ||
x5c | |||
) |
ccf::crypto::DECLARE_JSON_OPTIONAL_FIELDS | ( | JsonWebKeyData | , |
kid | , | ||
x5c | , | ||
n | , | ||
e | , | ||
x | , | ||
y | , | ||
crv | , | ||
issuer | |||
) |
ccf::crypto::DECLARE_JSON_REQUIRED_FIELDS | ( | JsonWebKey | , |
kty | |||
) |
ccf::crypto::DECLARE_JSON_REQUIRED_FIELDS | ( | JsonWebKeyData | , |
kty | |||
) |
ccf::crypto::DECLARE_JSON_REQUIRED_FIELDS | ( | JsonWebKeyECPrivate | , |
d | |||
) |
ccf::crypto::DECLARE_JSON_REQUIRED_FIELDS | ( | JsonWebKeyECPublic | , |
crv | , | ||
x | , | ||
y | |||
) |
ccf::crypto::DECLARE_JSON_REQUIRED_FIELDS | ( | JsonWebKeyEdDSAPrivate | , |
d | |||
) |
ccf::crypto::DECLARE_JSON_REQUIRED_FIELDS | ( | JsonWebKeyEdDSAPublic | , |
crv | , | ||
x | |||
) |
ccf::crypto::DECLARE_JSON_REQUIRED_FIELDS | ( | JsonWebKeyRSAPrivate | , |
d | , | ||
p | , | ||
q | , | ||
dp | , | ||
dq | , | ||
qi | |||
) |
ccf::crypto::DECLARE_JSON_REQUIRED_FIELDS | ( | JsonWebKeyRSAPublic | , |
n | , | ||
e | |||
) |
ccf::crypto::DECLARE_JSON_REQUIRED_FIELDS | ( | SubjectAltName | , |
san | , | ||
is_ip | |||
) |
ccf::crypto::DECLARE_JSON_TYPE | ( | SubjectAltName | ) |
ccf::crypto::DECLARE_JSON_TYPE_WITH_BASE | ( | JsonWebKeyECPrivate | , |
JsonWebKeyECPublic | |||
) |
ccf::crypto::DECLARE_JSON_TYPE_WITH_BASE | ( | JsonWebKeyECPublic | , |
JsonWebKey | |||
) |
ccf::crypto::DECLARE_JSON_TYPE_WITH_BASE | ( | JsonWebKeyEdDSAPrivate | , |
JsonWebKeyEdDSAPublic | |||
) |
ccf::crypto::DECLARE_JSON_TYPE_WITH_BASE | ( | JsonWebKeyEdDSAPublic | , |
JsonWebKey | |||
) |
ccf::crypto::DECLARE_JSON_TYPE_WITH_BASE | ( | JsonWebKeyRSAPrivate | , |
JsonWebKeyRSAPublic | |||
) |
ccf::crypto::DECLARE_JSON_TYPE_WITH_BASE | ( | JsonWebKeyRSAPublic | , |
JsonWebKey | |||
) |
ccf::crypto::DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS | ( | JsonWebKey | ) |
ccf::crypto::DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS | ( | JsonWebKeyData | ) |
void ccf::crypto::default_sha256 | ( | const std::span< const uint8_t > & | data, |
uint8_t * | h | ||
) |
std::vector< uint8_t > ccf::crypto::ecdsa_sig_der_to_p1363 | ( | const std::vector< uint8_t > & | signature, |
CurveID | curveId | ||
) |
std::vector< uint8_t > ccf::crypto::ecdsa_sig_from_r_s | ( | const uint8_t * | r, |
size_t | r_size, | ||
const uint8_t * | s, | ||
size_t | s_size, | ||
bool | big_endian = true |
||
) |
Converts R and S signature parameters to RFC 3279 DER encoding.
r | The raw r signature parameter |
r_size | The size of the r signature parameter |
s | The raw s signature parameter |
s_size | The size of the s signature parameter |
big_endian | True if the parameters are big endian, else False |
std::vector< uint8_t > ccf::crypto::ecdsa_sig_p1363_to_der | ( | std::span< const uint8_t > | signature | ) |
Converts an ECDSA signature in IEEE P1363 encoding to RFC 3279 DER encoding.
signature | The signature in IEEE P1363 encoding |
COSEEndorsementValidity ccf::crypto::extract_cose_endorsement_validity | ( | std::span< const uint8_t > | cose_msg | ) |
|
inline |
void ccf::crypto::fill_json_schema | ( | nlohmann::json & | schema, |
const Sha256Hash * | hash | ||
) |
|
inline |
void ccf::crypto::from_json | ( | const nlohmann::json & | j, |
Sha256Hash & | hash | ||
) |
std::pair< Unique_BIGNUM, Unique_BIGNUM > ccf::crypto::get_components | ( | const JsonWebKeyECPublic & | jwk | ) |
EntropyPtr ccf::crypto::get_entropy | ( | ) |
std::pair< Unique_BIGNUM, Unique_BIGNUM > ccf::crypto::get_modulus_and_exponent | ( | const JsonWebKeyRSAPublic & | jwk | ) |
std::string ccf::crypto::get_subject_name | ( | const Pem & | cert | ) |
std::vector< uint8_t > ccf::crypto::hkdf | ( | MDType | md_type, |
size_t | length, | ||
const std::span< const uint8_t > & | ikm, | ||
const std::span< const uint8_t > & | salt = {} , |
||
const std::span< const uint8_t > & | info = {} |
||
) |
Perform HKDF key derivation
HashBytes ccf::crypto::hmac | ( | MDType | type, |
const std::vector< uint8_t > & | key, | ||
const std::vector< uint8_t > & | data | ||
) |
Compute the HMAC of key
and data
OpenSSL::Unique_PKEY ccf::crypto::key_from_raw_ec_point | ( | const std::vector< uint8_t > & | raw, |
int | nid | ||
) |
std::optional< int > ccf::crypto::key_to_cose_alg_id | ( | const ccf::crypto::PublicKey_OpenSSL & | key | ) |
COSEVerifierUniquePtr ccf::crypto::make_cose_verifier_from_cert | ( | const std::vector< uint8_t > & | cert | ) |
COSEVerifierUniquePtr ccf::crypto::make_cose_verifier_from_key | ( | const Pem & | public_key | ) |
EdDSAKeyPairPtr ccf::crypto::make_eddsa_key_pair | ( | const JsonWebKeyEdDSAPrivate & | jwk | ) |
Create a public / private EdDSA key pair from existing JsonWebKeyEdDSAPrivate object
Currently only Curve25519 is supported.
EdDSAKeyPairPtr ccf::crypto::make_eddsa_key_pair | ( | const Pem & | pem | ) |
Create a public / private EdDSA key pair from existing private key data
Currently only Curve25519 is supported.
EdDSAKeyPairPtr ccf::crypto::make_eddsa_key_pair | ( | CurveID | curve_id = CurveID::CURVE25519 | ) |
Create a new public / private EdDSA key pair on specified curve and implementation
curve_id | Elliptic curve to use. Currently only CURVE25519 is supported. |
EdDSAPublicKeyPtr ccf::crypto::make_eddsa_public_key | ( | const JsonWebKeyEdDSAPublic & | jwk | ) |
Create a public / private EdDSA public key from existing JsonWebKeyEdDSAPublic object
Currently only Curve25519 is supported.
EdDSAPublicKeyPtr ccf::crypto::make_eddsa_public_key | ( | const Pem & | pem | ) |
Create a public / private EdDSA public key from existing public key data
Currently only Curve25519 is supported.
std::shared_ptr< HashProvider > ccf::crypto::make_hash_provider | ( | ) |
Create a default hash provider
std::shared_ptr< ISha256Hash > ccf::crypto::make_incremental_sha256 | ( | ) |
Create a default incremental SHA256 hash provider
std::unique_ptr< KeyAesGcm > ccf::crypto::make_key_aes_gcm | ( | std::span< const uint8_t > | rawKey | ) |
Free function implementation.
KeyPairPtr ccf::crypto::make_key_pair | ( | const JsonWebKeyECPrivate & | jwk | ) |
Construct a new public / private ECDSA key pair from a JsonWebKeyECPrivate object
jwk | JsonWebKeyECPrivate object |
KeyPairPtr ccf::crypto::make_key_pair | ( | const Pem & | pem | ) |
Create a public / private ECDSA key pair from existing private key data
pem | PEM key to load |
KeyPairPtr ccf::crypto::make_key_pair | ( | CurveID | curve_id = service_identity_curve_choice | ) |
Create a new public / private ECDSA key pair on specified curve and implementation
curve_id | Elliptic curve to use |
PublicKeyPtr ccf::crypto::make_public_key | ( | const JsonWebKeyECPublic & | jwk | ) |
Construct PublicKey from a JsonWebKeyECPublic object
jwk | JsonWebKeyECPublic object |
PublicKeyPtr ccf::crypto::make_public_key | ( | const Pem & | pem | ) |
Construct PublicKey from a raw public key in PEM format
pem | Sequence of bytes containing the key in PEM format |
PublicKeyPtr ccf::crypto::make_public_key | ( | const std::vector< uint8_t > & | der | ) |
Construct PublicKey from a raw public key in DER format
der | Sequence of bytes containing the key in DER format |
RSAKeyPairPtr ccf::crypto::make_rsa_key_pair | ( | const JsonWebKeyRSAPrivate & | jwk | ) |
Create a public / private RSA key pair from existing JsonWebKeyRSAPrivate object
RSAKeyPairPtr ccf::crypto::make_rsa_key_pair | ( | const Pem & | pem | ) |
Create a public / private RSA key pair from existing private key data
RSAKeyPairPtr ccf::crypto::make_rsa_key_pair | ( | size_t | public_key_size = RSAKeyPair::default_public_key_size , |
size_t | public_exponent = RSAKeyPair::default_public_exponent |
||
) |
Create a new public / private RSA key pair with specified size and exponent
RSAPublicKeyPtr ccf::crypto::make_rsa_public_key | ( | const JsonWebKeyRSAPublic & | jwk | ) |
RSAPublicKeyPtr ccf::crypto::make_rsa_public_key | ( | const Pem & | pem | ) |
RSAPublicKeyPtr ccf::crypto::make_rsa_public_key | ( | const std::vector< uint8_t > & | der | ) |
RSAPublicKeyPtr ccf::crypto::make_rsa_public_key | ( | const uint8_t * | data, |
size_t | size | ||
) |
VerifierUniquePtr ccf::crypto::make_unique_verifier | ( | const Pem & | pem | ) |
Construct Verifier from a certificate in PEM format
pem | The certificate containing a public key |
VerifierUniquePtr ccf::crypto::make_unique_verifier | ( | const std::vector< uint8_t > & | cert | ) |
Construct Verifier from a certificate in DER or PEM format
cert | The certificate containing a public key |
VerifierPtr ccf::crypto::make_verifier | ( | const Pem & | pem | ) |
Construct Verifier from a certificate in PEM format
pem | The certificate containing a public key |
VerifierPtr ccf::crypto::make_verifier | ( | const std::vector< uint8_t > & | cert | ) |
Construct a certificate verifier
cert | The certificate containing a public key |
void ccf::crypto::openssl_sha256 | ( | const std::span< const uint8_t > & | data, |
uint8_t * | h | ||
) |
void ccf::crypto::openssl_sha256_init | ( | ) |
To be called once per thread, before calling the ccf::crypto::sha256 functions (sha256.h) or calling internal CCF code making use of them.
Typical CCF application code does NOT need to make these calls, they are exposed for unit tests that use ccfcrypto.a directly and skip typical initialization and shutdown.
These calls exist to create and cache an EVP_MD_CTX per thread and amortise creation costs that can be substantial fraction of the total hashing time for small messages.
void ccf::crypto::openssl_sha256_shutdown | ( | ) |
bool ccf::crypto::operator!= | ( | const Sha256Hash & | lhs, |
const Sha256Hash & | rhs | ||
) |
std::ostream & ccf::crypto::operator<< | ( | std::ostream & | os, |
const ccf::crypto::Sha256Hash & | h | ||
) |
bool ccf::crypto::operator== | ( | const Sha256Hash & | lhs, |
const Sha256Hash & | rhs | ||
) |
std::vector< uint8_t > ccf::crypto::public_key_der_from_cert | ( | const std::vector< uint8_t > & | der | ) |
ccf::crypto::Pem ccf::crypto::public_key_pem_from_cert | ( | const std::vector< uint8_t > & | der | ) |
Extracts the public key from a certificate signing request (CSR).
signing_request | CSR to extract the public key from |
std::vector< uint8_t > ccf::crypto::raw_from_b64 | ( | const std::string_view & | b64_string | ) |
std::vector< uint8_t > ccf::crypto::raw_from_b64url | ( | const std::string_view & | b64url_string | ) |
|
inline |
std::string ccf::crypto::schema_name | ( | const Sha256Hash * | hash | ) |
std::vector< uint8_t > ccf::crypto::sha256 | ( | const std::span< uint8_t const > & | data | ) |
Compute the SHA256 hash of data
data | The data to compute the hash of |
std::vector< uint8_t > ccf::crypto::sha256 | ( | const std::vector< uint8_t > & | data | ) |
std::vector< uint8_t > ccf::crypto::sha256 | ( | const uint8_t * | data, |
size_t | len | ||
) |
Compute the SHA256 hash of data
data | The data to compute the hash of |
len | Length of the data |
std::vector< ccf::crypto::Pem > ccf::crypto::split_x509_cert_bundle | ( | const std::string_view & | pem | ) |
|
inline |
void ccf::crypto::to_json | ( | nlohmann::json & | j, |
const Sha256Hash & | hash | ||
) |
|
constexpr |
|
constexpr |