Cryptographic Wrappers for Secure Messaging

## Macros

#define | EAC_ID_PACE 0
| Identifies the PACE context.
#define | EAC_ID_CA 1
| Identifies the CA context.
#define | EAC_ID_TA 2
| Identifies the TA context.
#define | EAC_ID_EAC 3
| Identifies the currently used channel for encryption/decryption.

## Functions

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 * | EAC_remove_iso_pad (const BUF_MEM *padded)
| Remove ISO/IEC 9797-1 padding method 2 from a message.
int | EAC_increment_ssc (const EAC_CTX *ctx)
| Increment the Send Sequence Counter.
int | EAC_reset_ssc (const EAC_CTX *ctx)
| Reset the Send Sequence Counter.
int | EAC_set_ssc (const EAC_CTX *ctx, unsigned long ssc)
| Set the Send Sequence Counter.
BUF_MEM * | EAC_encrypt (const EAC_CTX *ctx, const BUF_MEM *data)
| Encrypts data according to TR-03110 F.2.
BUF_MEM * | EAC_decrypt (const EAC_CTX *ctx, const BUF_MEM *data)
| Decrypt data according to TR-03110 F.2.
BUF_MEM * | EAC_authenticate (const EAC_CTX *ctx, const BUF_MEM *data)
| Authenticate data according to TR-03110 F.2.
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.
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.
BUF_MEM * | EAC_hash_certificate_description (const unsigned char *cert_desc, size_t cert_desc_len)
| Compute the hash of a CV certificate description.
int | EAC_CTX_set_encryption_ctx (EAC_CTX *ctx, int id)
| Set the SM context for encryption, decryption and authentication.

## Detailed Description

## Macro Definition Documentation

## EAC_ID_CA

#define EAC_ID_CA 1

Identifies the CA context.

Definition at line 710 of file eac.h.

## EAC_ID_EAC

#define EAC_ID_EAC 3

Identifies the currently used channel for encryption/decryption.

Definition at line 714 of file eac.h.

## EAC_ID_PACE

#define EAC_ID_PACE 0

Identifies the PACE context.

Definition at line 708 of file eac.h.

## EAC_ID_TA

#define EAC_ID_TA 2

Identifies the TA context.

Definition at line 712 of file eac.h.

## Function Documentation

## EAC_add_iso_pad()

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.

The block size is calculated from the currently selected SM context.

Parameters

  [in] | ctx | EAC context
  [in] | unpadded | Buffer to pad

Returns
  Padded input or NULL in case of an error

## EAC_authenticate()

BUF_MEM * EAC_authenticate | ( | const EAC_CTX * | ctx,
|  | const BUF_MEM * | data
| ) |  |

Authenticate data according to TR-03110 F.2.

Parameters

  [in] | ctx | EAC context
  [in] | data | Data to authenticate

Returns
  MAC or NULL in case of an error

Note
  data must already be padded to block length

## EAC_Comp()

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.

Parameters

  [in] | ctx | EAC context
  [in] | id | accepts `EAC_ID_PACE`, `EAC_ID_CA`, `EAC_ID_TA`
  [in] | pub | Raw public key

Returns
  Compressed public key or NULL in case of an error

## EAC_CTX_set_encryption_ctx()

int EAC_CTX_set_encryption_ctx | ( | EAC_CTX * | ctx,
|  | int | id
| ) |  |

Set the SM context for encryption, decryption and authentication.

Calls EAC_reset_ssc()

Parameters

  [in,out] | ctx | EAC context
  [in] | id | accepts `EAC_ID_PACE`, `EAC_ID_CA`, `EAC_ID_EAC`

Returns
  1 on success or 0 in case of an error

## EAC_decrypt()

BUF_MEM * EAC_decrypt | ( | const EAC_CTX * | ctx,
|  | const BUF_MEM * | data
| ) |  |

Decrypt data according to TR-03110 F.2.

Parameters

  [in] | ctx | EAC context
  [in] | data | Data to decrypt

Returns
  Decrypted data or NULL in case of an error

Note
  data must already be padded to block length

## EAC_encrypt()

BUF_MEM * EAC_encrypt | ( | const EAC_CTX * | ctx,
|  | const BUF_MEM * | data
| ) |  |

Encrypts data according to TR-03110 F.2.

Parameters

  [in] | ctx | EAC context
  [in] | data | Data to encrypt

Returns
  Encrypted data or NULL in case of an error

Note
  data must already be padded to block length

## EAC_hash_certificate_description()

BUF_MEM * EAC_hash_certificate_description | ( | const unsigned char * | cert_desc,
|  | size_t | cert_desc_len
| ) |  |

Compute the hash of a CV certificate description.

The hash can then be compared to the hash contained in the corresponding CV certificate.

Parameters

  [in] | cert_desc | ASN1 encoded CV certificate description
  [in] | cert_desc_len | Length of cert_desc

Returns
  Hash of cert_desc or NULL in case of an error

## EAC_increment_ssc()

int EAC_increment_ssc | ( | const EAC_CTX * | ctx | ) |

Increment the Send Sequence Counter.

Parameters

  ctx |

Returns
  1 on success or 0 in case of an error

## EAC_remove_iso_pad()

BUF_MEM * EAC_remove_iso_pad | ( | const BUF_MEM * | padded | ) |

Remove ISO/IEC 9797-1 padding method 2 from a message.

Parameters

  [in] | padded | Padded message

Returns
  Unpadded message or NULL in case of an error

## EAC_reset_ssc()

int EAC_reset_ssc | ( | const EAC_CTX * | ctx | ) |

Reset the Send Sequence Counter.

Parameters

  ctx |

Returns
  1 on success or 0 in case of an error

## EAC_set_ssc()

int EAC_set_ssc | ( | const EAC_CTX * | ctx,
|  | unsigned long | ssc
| ) |  |

Set the Send Sequence Counter.

Parameters

  ctx |
  ssc |

Returns
  1 on success or 0 in case of an error

## EAC_verify_authentication()

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.

Parameters

  [in] | ctx | EAC context
  [in] | data | Data to authenticate
  [in] | mac | The MAC that is going to be verified

Returns
  1 if the MAC can be correctly verified, 0 otherwise