Go to the documentation of this file.
55 #include <openssl/asn1.h>
56 #include <openssl/buffer.h>
57 #include <openssl/cmac.h>
58 #include <openssl/ec.h>
59 #include <openssl/evp.h>
121 BUF_MEM * (*generate_key)(EVP_PKEY *
key, BN_CTX *bn_ctx);
131 BUF_MEM * (*compute_key)(EVP_PKEY *
key,
const BUF_MEM *in, BN_CTX *bn_ctx);
180 BUF_MEM * (*map_generate_key)(
const struct pace_ctx *ctx, BN_CTX *bn_ctx);
185 const BUF_MEM * in, BN_CTX *bn_ctx);
228 BUF_MEM * (*generate_key)(EVP_PKEY *key, BN_CTX *bn_ctx);
238 BUF_MEM * (*compute_key)(EVP_PKEY *key,
const BUF_MEM *in, BN_CTX *bn_ctx);
244 typedef CVC_CERT * (*CVC_lookup_cvca_cert) (
const unsigned char *chr,
size_t car_len);
301 typedef X509_STORE * (*X509_lookup_csca_cert) (
unsigned long issuer_name_hash);
378 #define EAC_AES_MAC_LENGTH 8
441 const unsigned char *privkey,
size_t privkey_len,
442 const unsigned char *cvca,
size_t cvca_len);
497 const unsigned char *ef_cardsecurity,
size_t ef_cardsecurity_len,
705 size_t cert_desc_len);
708 #define EAC_ID_PACE 0
ENGINE * cipher_engine
Cipher's engine.
int EAC_CTX_set_cvca_lookup(EAC_CTX *ctx, CVC_lookup_cvca_cert lookup_cvca_cert)
Set the CVCA lookup callback.
int EAC_CTX_init_ri(EAC_CTX *ctx, int protocol, int stnd_dp)
Initialize an EAC context for Restricted Identification.
int EAC_CTX_set_csca_lookup_cert(EAC_CTX *ctx, X509_lookup_csca_cert lookup_cvca_cert)
Set the CSCA lookup callback.
TA_CTX * ta_ctx
Context for the currently selected Terminal Authentication protocol.
ENGINE * md_engine
Digest's engine.
int BUF_MEM_print(BIO *out, const BUF_MEM *buf, int indent)
Prints buffer.
int EAC_CTX_print_private(BIO *out, const EAC_CTX *ctx, int indent)
Print EAC context including private data.
void EAC_cleanup(void)
Wrapper to EVP_cleanup()
void EAC_set_cvc_default_dir(const char *default_dir)
Set directory for EAC_get_default_cvca_lookup()
int id
identifier of this PACE context
CA_CTX * ca_ctx
Context for the currently selected Chip Authentication protocol.
int EAC_CTX_init_pace(EAC_CTX *ctx, int protocol, int curve)
Initialize an EAC context for PACE.
BN_CTX * bn_ctx
Context for various operations with BIGNUM objects.
void EAC_set_x509_default_dir(const char *default_dir)
Set directory for EAC_get_default_csca_lookup()
CVC_CERT * trust_anchor
Trust anchor for CV certificate validation.
struct ta_ctx TA_CTX
Context for the Terminal Authentication protocol.
eac_tr_version
Identification of the specifications to use.
BUF_MEM * k_mac
Symmetric key used for integrity protection. Derived from KA_CTX.shared_secret.
Context for the Restricted Identification protocol.
BUF_MEM * EAC_authenticate(const EAC_CTX *ctx, const BUF_MEM *data)
Authenticate data according to TR-03110 F.2.
struct ca_ctx CA_CTX
Context for the Chip Authentication protocol.
Definitions of object identifiers.
RI_CTX * ri_ctx
Context for the currently selected Restricted Identification protocol.
int EAC_increment_ssc(const EAC_CTX *ctx)
Increment the Send Sequence Counter.
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.
BUF_MEM * pk_pcd
PCD's public key extracted from it's CV certificate.
struct pace_ctx PACE_CTX
Context for the Password Authenticated Connection Establishment protocol.
The actual certifcate, consisting of the body and a signature.
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.
Context for the Chip Authentication protocol.
CVC_lookup_cvca_cert EAC_get_default_cvca_lookup(void)
Return the default lookup of the country verifying CA.
unsigned char version
(currently unused) Version of the CA protocol, MUST be 1 or 2
Interface for Card Verifiable Certificates.
KA_CTX * key_ctx
Context for currently selected secure messaging established with PACE or CA.
BIGNUM * ssc
Send sequence counter.
struct ri_ctx RI_CTX
Context for the Restricted Identification protocol.
int EAC_set_ssc(const EAC_CTX *ctx, unsigned long ssc)
Set the Send Sequence Counter.
unsigned char version
(currently unused) Version of the PACE protocol, MUST be 1 or 2
struct eac_ctx EAC_CTX
Context for the Extended Access Control protocol.
CVC_CERT * new_trust_anchor
When a complete CV certificate chain has been verified, this will be the new trust anchor.
const EVP_MD * md
Digest to use for derivation of I^{sector}_{ID}.
int protocol
Identifier of the protocol's OID specifying the exact TA parameters to use.
STACK_OF(PACE_CTX *) pace_ctxs
stack of available Password Authenticated Connection Establishment configurations
X509_lookup_csca_cert EAC_get_default_csca_lookup(void)
Return the default lookup of the country signing CA.
@ EAC_TR_VERSION_2_02
Perform EAC according to TR-03110 v2.02 and later.
CVC_CERT * current_cert
Most recent verified CV certificate in a certificate chain.
int flags
Flags to control some of the behaviour of the CA.
void EAC_init(void)
Initializes OpenSSL and the EAC identifier.
Context for the Password Authenticated Connection Establishment protocol.
Context for a key agreement and subsequent derivation of session keys.
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...
EAC_CTX * EAC_CTX_new(void)
Create a new EAC context.
BUF_MEM * k_enc
Symmetric key used for encryption/decryption. Derived from KA_CTX.shared_secret.
EVP_MD_CTX * md_ctx
Context for various hashing operations.
BUF_MEM * nonce
PICC's challenge.
@ EAC_TR_VERSION_2_01
Perform EAC according to TR-03110 v2.01.
BUF_MEM * EAC_encrypt(const EAC_CTX *ctx, const BUF_MEM *data)
Encrypts data according to TR-03110 F.2.
PACE_CTX * pace_ctx
Context for the currently selected Password Authenticated Connection Establishment protocol.
struct ka_ctx KA_CTX
Context for a key agreement and subsequent derivation of session keys.
@ EAC_TR_VERSION
Undefined type, if nothing else matches.
int EAC_CTX_get_csca_lookup_cert(const EAC_CTX *ctx, X509_lookup_csca_cert *lookup_cvca_cert)
Get the CSCA lookup callback.
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.
void BUF_MEM_clear_free(BUF_MEM *b)
Frees and wipes a buffer.
BUF_MEM * EAC_decrypt(const EAC_CTX *ctx, const BUF_MEM *data)
Decrypt data according to TR-03110 F.2.
BUF_MEM * EAC_hash_certificate_description(const unsigned char *cert_desc, size_t cert_desc_len)
Compute the hash of a CV certificate description.
Context for the Extended Access Control protocol.
int protocol
Identifier of the protocol's OID specifying the exact CA parameters to use.
BUF_MEM * my_eph_pubkey
The own ephemeral public key generated in PACe step 3b.
unsigned char * iv
Initialisation vector for encryption/decryption.
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.
EVP_PKEY * static_key
PICC's static domain parameters.
void EAC_CTX_clear_free(EAC_CTX *ctx)
Free an EAC context.
int id
identifier of this RI context
X509_STORE *(* X509_lookup_csca_cert)(unsigned long issuer_name_hash)
callback for finding the X.509 trust anchor
KA_CTX * ka_ctx
Key agreement object used with the PICC's private key.
unsigned char version
(currently unused) Version of the TA protocol, MUST be 1 or 2
int enc_keylen
Length of the computed key for the encryption/decryption.
int EAC_CTX_init_ca(EAC_CTX *ctx, int protocol, int curve)
Initialize an EAC context for Chip Authentication.
int protocol
Identifier of the hash function to use.
enum eac_tr_version tr_version
Perform EAC conforming to this version of TR-03110.
int id
identifier of this CA context
BUF_MEM * shared_secret
Shared secret computed during the key agreement protocol.
const EVP_CIPHER * cipher
Cipher to use for encryption/decryption.
X509_lookup_csca_cert lookup_csca_cert
callback for finding the X.509 trust anchor
int flags
Flags to control some of the behaviour of the CA.
EVP_PKEY * key
Container for the key pair used for key agreement.
int mac_keylen
Length of the computed key for the message authentication code.
BUF_MEM * EAC_remove_iso_pad(const BUF_MEM *padded)
Remove ISO/IEC 9797-1 padding method 2 from a message.
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_reset_ssc(const EAC_CTX *ctx)
Reset the Send Sequence Counter.
ENGINE * key_engine
(currently unused) engine for signing and signature verification
const EVP_MD * md
Digest to use for key derivation.
KA_CTX * ka_ctx
Key agreement object used with the ephemeral domain parameters.
EVP_PKEY * static_key
PICC's static domain parameters.
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 * priv_key
TA private key used for signing the challenge.
CMAC_CTX * cmac_ctx
Context for CMAC.
CVC_lookup_cvca_cert lookup_cvca_cert
Lookup the CVCA trust anchor.
EVP_CIPHER_CTX * cipher_ctx
Context for various cipher operations.
Context for the Terminal Authentication protocol.
EVP_PKEY * pub_key
TA public key used for signing the challenge.
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.
int EAC_CTX_set_encryption_ctx(EAC_CTX *ctx, int id)
Set the SM context for encryption, decryption and authentication.
CVC_CERT *(* CVC_lookup_cvca_cert)(const unsigned char *chr, size_t car_len)
callback for finding the CVCA trust anchor
BUF_MEM * nonce
PICC's decrypted challenge generated in PACE step 1.