37 #include <openssl/asn1.h> 38 #include <openssl/buffer.h> 39 #include <openssl/cmac.h> 40 #include <openssl/ec.h> 41 #include <openssl/evp.h> 103 BUF_MEM * (*generate_key)(EVP_PKEY *
key, BN_CTX *bn_ctx);
113 BUF_MEM * (*compute_key)(EVP_PKEY *
key,
const BUF_MEM *in, BN_CTX *bn_ctx);
162 BUF_MEM * (*map_generate_key)(
const struct pace_ctx *ctx, BN_CTX *bn_ctx);
167 const BUF_MEM * in, BN_CTX *bn_ctx);
210 BUF_MEM * (*generate_key)(EVP_PKEY *
key, BN_CTX *bn_ctx);
220 BUF_MEM * (*compute_key)(EVP_PKEY *
key,
const BUF_MEM *in, BN_CTX *bn_ctx);
226 typedef CVC_CERT * (*CVC_lookup_cvca_cert) (
const unsigned char *chr,
size_t car_len);
283 typedef X509_STORE * (*X509_lookup_csca_cert) (
unsigned long issuer_name_hash);
344 STACK_OF(
RI_CTX *) ri_ctxs;
352 STACK_OF(
CA_CTX *) ca_ctxs;
360 #define EAC_AES_MAC_LENGTH 8 423 const unsigned char *privkey,
size_t privkey_len,
424 const unsigned char *cvca,
size_t cvca_len);
479 const unsigned char *ef_cardsecurity,
size_t ef_cardsecurity_len,
687 size_t cert_desc_len);
690 #define EAC_ID_PACE 0 int EAC_CTX_init_ri(EAC_CTX *ctx, int protocol, int stnd_dp)
Initialize an EAC context for Restricted Identification.
KA_CTX * ka_ctx
Key agreement object used with the ephemeral domain parameters.
void EAC_set_cvc_default_dir(const char *default_dir)
Set directory for EAC_get_default_cvca_lookup()
BN_CTX * bn_ctx
Context for various operations with BIGNUM objects.
EVP_MD_CTX * md_ctx
Context for various hashing operations.
BUF_MEM * EAC_authenticate(const EAC_CTX *ctx, const BUF_MEM *data)
Authenticate data according to TR-03110 F.2.
EVP_PKEY * key
Container for the key pair used for key agreement.
int BUF_MEM_print(BIO *out, const BUF_MEM *buf, int indent)
Prints buffer.
PACE_CTX * pace_ctx
Context for the currently selected Password Authenticated Connection Establishment protocol...
int EAC_CTX_print_private(BIO *out, const EAC_CTX *ctx, int indent)
Print EAC context including private data.
EVP_PKEY * priv_key
TA private key used for signing the challenge.
BUF_MEM * k_mac
Symmetric key used for integrity protection. Derived from KA_CTX.shared_secret.
void EAC_set_x509_default_dir(const char *default_dir)
Set directory for EAC_get_default_csca_lookup()
int id
identifier of this PACE context
X509_STORE *(* X509_lookup_csca_cert)(unsigned long issuer_name_hash)
callback for finding the X.509 trust anchor
int EAC_increment_ssc(const EAC_CTX *ctx)
Increment the Send Sequence Counter.
const EVP_MD * md
Digest to use for derivation of I^{sector}_{ID}.
BUF_MEM * nonce
PICC's challenge.
BUF_MEM * EAC_Comp(const EAC_CTX *ctx, int id, const BUF_MEM *pub)
Compresse a public key according to TR-03110 Table A.2.
int protocol
Identifier of the protocol's OID specifying the exact PACE parameters to use.
int EAC_CTX_set_csca_lookup_cert(EAC_CTX *ctx, X509_lookup_csca_cert lookup_cvca_cert)
Set the CSCA lookup callback.
unsigned char version
(currently unused) Version of the CA protocol, MUST be 1 or 2
X509_lookup_csca_cert EAC_get_default_csca_lookup(void)
Return the default lookup of the country signing CA.
int EAC_CTX_get_csca_lookup_cert(const EAC_CTX *ctx, X509_lookup_csca_cert *lookup_cvca_cert)
Get the CSCA lookup callback.
ENGINE * key_engine
(currently unused) engine for signing and signature verification
const EVP_MD * md
Digest to use for key derivation.
int flags
Flags to control some of the behaviour of the CA.
CA_CTX * ca_ctx
Context for the currently selected Chip Authentication protocol.
unsigned char * iv
Initialisation vector for encryption/decryption.
BUF_MEM * EAC_add_iso_pad(const EAC_CTX *ctx, const BUF_MEM *unpadded)
Pad a buffer using ISO/IEC 9797-1 padding method 2.
CVC_CERT * new_trust_anchor
When a complete CV certificate chain has been verified, this will be the new trust anchor...
unsigned char version
(currently unused) Version of the TA protocol, MUST be 1 or 2
BIGNUM * ssc
Send sequence counter.
struct ka_ctx KA_CTX
Context for a key agreement and subsequent derivation of session keys.
struct eac_ctx EAC_CTX
Context for the Extended Access Control protocol.
int EAC_CTX_init_ta(const EAC_CTX *ctx, const unsigned char *privkey, size_t privkey_len, const unsigned char *cvca, size_t cvca_len)
Initialize an EAC context for TA with the terminal's PKI data. Use either a CV certificate or a known...
EVP_PKEY * pub_key
TA public key used for signing the challenge.
Context for the Terminal Authentication protocol.
struct pace_ctx PACE_CTX
Context for the Password Authenticated Connection Establishment protocol.
void EAC_init(void)
Initializes OpenSSL and the EAC identifier.
int EAC_set_ssc(const EAC_CTX *ctx, unsigned long ssc)
Set the Send Sequence Counter.
int EAC_CTX_init_ef_cardsecurity(const unsigned char *ef_cardsecurity, size_t ef_cardsecurity_len, EAC_CTX *ctx)
Initialize an EAC context for PACE, TA and CA from the data given in an EF.CardSecurity.
EVP_PKEY * static_key
PICC's static domain parameters.
unsigned char version
(currently unused) Version of the PACE protocol, MUST be 1 or 2
CMAC_CTX * cmac_ctx
Context for CMAC.
eac_tr_version
Identification of the specifications to use.
Interface for Card Verifiable Certificates.
BUF_MEM * my_eph_pubkey
The own ephemeral public key generated in PACe step 3b.
EAC_CTX * EAC_CTX_new(void)
Create a new EAC context.
CVC_lookup_cvca_cert EAC_get_default_cvca_lookup(void)
Return the default lookup of the country verifying CA.
int flags
Flags to control some of the behaviour of the CA.
CVC_CERT *(* CVC_lookup_cvca_cert)(const unsigned char *chr, size_t car_len)
callback for finding the CVCA trust anchor
int id
identifier of this RI context
BUF_MEM * EAC_hash_certificate_description(const unsigned char *cert_desc, size_t cert_desc_len)
Compute the hash of a CV certificate description.
struct ca_ctx CA_CTX
Context for the Chip Authentication protocol.
BUF_MEM * EAC_encrypt(const EAC_CTX *ctx, const BUF_MEM *data)
Encrypts data according to TR-03110 F.2.
const EVP_CIPHER * cipher
Cipher to use for encryption/decryption.
CVC_CERT * trust_anchor
Trust anchor for CV certificate validation.
Context for the Restricted Identification protocol.
RI_CTX * ri_ctx
Context for the currently selected Restricted Identification protocol.
void EAC_CTX_clear_free(EAC_CTX *ctx)
Free an EAC context.
struct ri_ctx RI_CTX
Context for the Restricted Identification protocol.
int EAC_CTX_get_cvca_lookup(const EAC_CTX *ctx, CVC_lookup_cvca_cert *lookup_cvca_cert)
Return the EAC context's CVCA lookup callback.
ENGINE * cipher_engine
Cipher's engine.
int protocol
Identifier of the protocol's OID specifying the exact TA parameters to use.
void BUF_MEM_clear_free(BUF_MEM *b)
Frees and wipes a buffer.
Perform EAC according to TR-03110 v2.02 and later.
BUF_MEM * EAC_decrypt(const EAC_CTX *ctx, const BUF_MEM *data)
Decrypt data according to TR-03110 F.2.
Context for the Chip Authentication protocol.
int id
identifier of this CA context
The actual certifcate, consisting of the body and a signature.
CVC_lookup_cvca_cert lookup_cvca_cert
Lookup the CVCA trust anchor.
Context for the Extended Access Control protocol.
TA_CTX * ta_ctx
Context for the currently selected Terminal Authentication protocol.
int protocol
Identifier of the hash function to use.
int EAC_CTX_init_ca(EAC_CTX *ctx, int protocol, int curve)
Initialize an EAC context for Chip Authentication.
struct ta_ctx TA_CTX
Context for the Terminal Authentication protocol.
int protocol
Identifier of the protocol's OID specifying the exact CA parameters to use.
CVC_CERT * current_cert
Most recent verified CV certificate in a certificate chain.
KA_CTX * key_ctx
Context for currently selected secure messaging established with PACE or CA.
int EAC_reset_ssc(const EAC_CTX *ctx)
Reset the Send Sequence Counter.
Definitions of object identifiers.
Context for the Password Authenticated Connection Establishment protocol.
int EAC_verify_authentication(const EAC_CTX *ctx, const BUF_MEM *data, const BUF_MEM *mac)
Verify authenticated data according to TR-03110 F.2.
int EAC_CTX_init_ef_cardaccess(unsigned const char *in, size_t in_len, EAC_CTX *ctx)
Initialize an EAC context for PACE, TA and CA from the data given in an EF.CardAccess.
int EAC_CTX_init_pace(EAC_CTX *ctx, int protocol, int curve)
Initialize an EAC context for PACE.
Perform EAC according to TR-03110 v2.01.
KA_CTX * ka_ctx
Key agreement object used with the PICC's private key.
Undefined type, if nothing else matches.
int(* map_compute_key)(struct pace_ctx *ctx, const BUF_MEM *s, const BUF_MEM *in, BN_CTX *bn_ctx)
Points to the implementation of a specific mapping.
Context for a key agreement and subsequent derivation of session keys.
void EAC_cleanup(void)
Wrapper to EVP_cleanup()
int enc_keylen
Length of the computed key for the encryption/decryption.
BUF_MEM * EAC_remove_iso_pad(const BUF_MEM *padded)
Remove ISO/IEC 9797-1 padding method 2 from a message.
int EAC_CTX_set_cvca_lookup(EAC_CTX *ctx, CVC_lookup_cvca_cert lookup_cvca_cert)
Set the CVCA lookup callback.
BUF_MEM * k_enc
Symmetric key used for encryption/decryption. Derived from KA_CTX.shared_secret.
EVP_CIPHER_CTX * cipher_ctx
Context for various cipher operations.
int EAC_CTX_set_encryption_ctx(EAC_CTX *ctx, int id)
Set the SM context for encryption, decryption and authentication.
X509_lookup_csca_cert lookup_csca_cert
callback for finding the X.509 trust anchor
BUF_MEM * pk_pcd
PCD's public key extracted from it's CV certificate.
int mac_keylen
Length of the computed key for the message authentication code.
ENGINE * md_engine
Digest's engine.
BUF_MEM * nonce
PICC's decrypted challenge generated in PACE step 1.
EVP_PKEY * static_key
PICC's static domain parameters.
BUF_MEM * shared_secret
Shared secret computed during the key agreement protocol.