|  | Home | Documentation | mecevp.h File Reference updated Thu Nov 19 2020 by Robert van Engelen |

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

Classes | Macros | Enumerations | Functions
mecevp.h File Reference
`#include "stdsoap2.h"`
`#include <openssl/evp.h>`
`#include <openssl/ssl.h>`
`#include <openssl/err.h>`
Include dependency graph for mecevp.h:
This graph shows which files directly or indirectly include this file:

## Classes
struct | soap_mec_data
| The mecevp engine context data. More...

## Macros
#define | SOAP_MEC_KEY_TYPE EVP_PKEY
#define | SOAP_MEC_NONE (0)
#define | SOAP_MEC_DES_CBC (0x0010)
#define | SOAP_MEC_AES128_CBC (0x0020)
#define | SOAP_MEC_AES192_CBC (0x0040)
#define | SOAP_MEC_AES256_CBC (0x0080)
#define | SOAP_MEC_AES512_CBC (0x0100)
#define | SOAP_MEC_GCM (0x1000)
#define | SOAP_MEC_ALGO (0x1FFF)
#define | SOAP_MEC_AES128_GCM (SOAP_MEC_AES128_CBC | SOAP_MEC_GCM)
#define | SOAP_MEC_AES192_GCM (SOAP_MEC_AES192_CBC | SOAP_MEC_GCM)
#define | SOAP_MEC_AES256_GCM (SOAP_MEC_AES256_CBC | SOAP_MEC_GCM)
#define | SOAP_MEC_AES512_GCM (SOAP_MEC_AES512_CBC | SOAP_MEC_GCM)
#define | SOAP_MEC_ENC (0x2000)
#define | SOAP_MEC_DEC (0x0000)
#define | SOAP_MEC_ENV (0x4000)
#define | SOAP_MEC_ENV_ENC (SOAP_MEC_ENV | SOAP_MEC_ENC)
#define | SOAP_MEC_ENV_DEC (SOAP_MEC_ENV | SOAP_MEC_DEC)
#define | SOAP_MEC_MASK (0xFFFF)
#define | SOAP_MEC_STORE (0x010000)
#define | SOAP_MEC_OAEP (0x020000)
#define | SOAP_MEC_ENC_DES_CBC (SOAP_MEC_DES_CBC | SOAP_MEC_ENC)
#define | SOAP_MEC_ENC_AES128_CBC (SOAP_MEC_AES128_CBC | SOAP_MEC_ENC)
#define | SOAP_MEC_ENC_AES192_CBC (SOAP_MEC_AES192_CBC | SOAP_MEC_ENC)
#define | SOAP_MEC_ENC_AES256_CBC (SOAP_MEC_AES256_CBC | SOAP_MEC_ENC)
#define | SOAP_MEC_ENC_AES512_CBC (SOAP_MEC_AES512_CBC | SOAP_MEC_ENC)
#define | SOAP_MEC_ENC_AES128_GCM (SOAP_MEC_AES128_GCM | SOAP_MEC_ENC)
#define | SOAP_MEC_ENC_AES192_GCM (SOAP_MEC_AES192_GCM | SOAP_MEC_ENC)
#define | SOAP_MEC_ENC_AES256_GCM (SOAP_MEC_AES256_GCM | SOAP_MEC_ENC)
#define | SOAP_MEC_ENC_AES512_GCM (SOAP_MEC_AES512_GCM | SOAP_MEC_ENC)
#define | SOAP_MEC_DEC_DES_CBC (SOAP_MEC_DES_CBC | SOAP_MEC_DEC)
#define | SOAP_MEC_DEC_AES128_CBC (SOAP_MEC_AES128_CBC | SOAP_MEC_DEC)
#define | SOAP_MEC_DEC_AES192_CBC (SOAP_MEC_AES192_CBC | SOAP_MEC_DEC)
#define | SOAP_MEC_DEC_AES256_CBC (SOAP_MEC_AES256_CBC | SOAP_MEC_DEC)
#define | SOAP_MEC_DEC_AES512_CBC (SOAP_MEC_AES512_CBC | SOAP_MEC_DEC)
#define | SOAP_MEC_DEC_AES128_GCM (SOAP_MEC_AES128_GCM | SOAP_MEC_DEC)
#define | SOAP_MEC_DEC_AES192_GCM (SOAP_MEC_AES192_GCM | SOAP_MEC_DEC)
#define | SOAP_MEC_DEC_AES256_GCM (SOAP_MEC_AES256_GCM | SOAP_MEC_DEC)
#define | SOAP_MEC_DEC_AES512_GCM (SOAP_MEC_AES512_GCM | SOAP_MEC_DEC)
#define | SOAP_MEC_ENV_ENC_DES_CBC (SOAP_MEC_ENC_DES_CBC | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_ENC_AES128_CBC (SOAP_MEC_ENC_AES128_CBC | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_ENC_AES192_CBC (SOAP_MEC_ENC_AES192_CBC | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_ENC_AES256_CBC (SOAP_MEC_ENC_AES256_CBC | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_ENC_AES512_CBC (SOAP_MEC_ENC_AES512_CBC | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_ENC_AES128_GCM (SOAP_MEC_ENC_AES128_GCM | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_ENC_AES192_GCM (SOAP_MEC_ENC_AES192_GCM | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_ENC_AES256_GCM (SOAP_MEC_ENC_AES256_GCM | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_ENC_AES512_GCM (SOAP_MEC_ENC_AES512_GCM | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_DEC_DES_CBC (SOAP_MEC_DEC_DES_CBC | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_DEC_AES128_CBC (SOAP_MEC_DEC_AES128_CBC | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_DEC_AES192_CBC (SOAP_MEC_DEC_AES192_CBC | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_DEC_AES256_CBC (SOAP_MEC_DEC_AES256_CBC | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_DEC_AES512_CBC (SOAP_MEC_DEC_AES512_CBC | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_DEC_AES128_GCM (SOAP_MEC_DEC_AES128_GCM | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_DEC_AES192_GCM (SOAP_MEC_DEC_AES192_GCM | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_DEC_AES256_GCM (SOAP_MEC_DEC_AES256_GCM | SOAP_MEC_ENV)
#define | SOAP_MEC_ENV_DEC_AES512_GCM (SOAP_MEC_DEC_AES512_GCM | SOAP_MEC_ENV)

## Enumerations
enum | SOAP_MEC_STATE { SOAP_MEC_STATE_NONE, SOAP_MEC_STATE_INIT, SOAP_MEC_STATE_IV, SOAP_MEC_STATE_DECRYPT, SOAP_MEC_STATE_FINAL, SOAP_MEC_STATE_FLUSH }

## Functions
SOAP_FMAC1 int SOAP_FMAC2 | soap_mec_begin (struct soap *soap, struct soap_mec_data *data, int alg, SOAP_MEC_KEY_TYPE *pkey, unsigned char *key, int *keylen)
| Initialize the mecevp engine data and begin encryption or decryption message sequence using a private/public key or symmetric secret key. More...
SOAP_FMAC1 int SOAP_FMAC2 | soap_mec_start_alg (struct soap *soap, int alg, const unsigned char *key)
| Start encryption or decryption of current message. If key is non-NULL, use the symmetric key with alg. Use soap_mec_start only after soap_mec_begin. The soap_mec_start should be followed by a soap_mec_stop call. More...
SOAP_FMAC1 int SOAP_FMAC2 | soap_mec_start (struct soap *soap, const unsigned char *key)
| Start encryption or decryption of current message. If key is non-NULL, use the symmetric key with alg. Use soap_mec_start only after soap_mec_begin. The soap_mec_start should be followed by a soap_mec_stop call. More...
SOAP_FMAC1 int SOAP_FMAC2 | soap_mec_stop (struct soap *soap)
| Stops encryption or decryption of current message. Use after soap_mec_start. More...
SOAP_FMAC1 int SOAP_FMAC2 | soap_mec_end (struct soap *soap, struct soap_mec_data *data)
| Ends encryption or decryption of a sequence of message parts that began with soap_mec_begin. More...
SOAP_FMAC1 size_t SOAP_FMAC2 | soap_mec_size (int alg, SOAP_MEC_KEY_TYPE *pkey)
| Returns the number of octets needed to store the public/private key or the symmetric key, depending on the algorithm. More...
SOAP_FMAC1 int SOAP_FMAC2 | soap_mec_init (struct soap *soap, struct soap_mec_data *data, int alg, SOAP_MEC_KEY_TYPE *pkey, unsigned char *key, int *keylen)
| Initialize mecevp engine state and create context for encryption/decryption algorithm using a private/public key or symmetric secret key. More...
SOAP_FMAC1 int SOAP_FMAC2 | soap_mec_update (struct soap *soap, struct soap_mec_data *data, const char **s, size_t *n)
| Update mecevp engine state: encrypts plain text (or raw data) or decrypts cipher data in base64 format. More...
SOAP_FMAC1 int SOAP_FMAC2 | soap_mec_final (struct soap *soap, struct soap_mec_data *data, const char **s, size_t *n)
| Ends mecevp engine state: encrypt/decrypt remainder from buffers. More...
SOAP_FMAC1 void SOAP_FMAC2 | soap_mec_cleanup (struct soap *soap, struct soap_mec_data *data)
| Clean up mecevp engine and deallocate cipher context and buffers. More...

## Macro Definition Documentation

#define SOAP_MEC_AES128_CBC (0x0020)

Cipher type (AES128 CBC)

#define SOAP_MEC_AES128_GCM (SOAP_MEC_AES128_CBC | SOAP_MEC_GCM)

Cipher type (AES128 GCM)

#define SOAP_MEC_AES192_CBC (0x0040)

Cipher type (AES192 CBC)

#define SOAP_MEC_AES192_GCM (SOAP_MEC_AES192_CBC | SOAP_MEC_GCM)

Cipher type (AES192 GCM)

#define SOAP_MEC_AES256_CBC (0x0080)

Cipher type (AES256 CBC)

#define SOAP_MEC_AES256_GCM (SOAP_MEC_AES256_CBC | SOAP_MEC_GCM)

Cipher type (AES256 GCM)

#define SOAP_MEC_AES512_CBC (0x0100)

Cipher type (AES512 CBC)

#define SOAP_MEC_AES512_GCM (SOAP_MEC_AES512_CBC | SOAP_MEC_GCM)

Cipher type (AES512 GCM)

#define SOAP_MEC_ALGO (0x1FFF)

Algorithm

#define SOAP_MEC_DEC (0x0000)

Decode mode

#define SOAP_MEC_DEC_AES128_CBC (SOAP_MEC_AES128_CBC | SOAP_MEC_DEC)

#define SOAP_MEC_DEC_AES128_GCM (SOAP_MEC_AES128_GCM | SOAP_MEC_DEC)

#define SOAP_MEC_DEC_AES192_CBC (SOAP_MEC_AES192_CBC | SOAP_MEC_DEC)

#define SOAP_MEC_DEC_AES192_GCM (SOAP_MEC_AES192_GCM | SOAP_MEC_DEC)

#define SOAP_MEC_DEC_AES256_CBC (SOAP_MEC_AES256_CBC | SOAP_MEC_DEC)

#define SOAP_MEC_DEC_AES256_GCM (SOAP_MEC_AES256_GCM | SOAP_MEC_DEC)

#define SOAP_MEC_DEC_AES512_CBC (SOAP_MEC_AES512_CBC | SOAP_MEC_DEC)

#define SOAP_MEC_DEC_AES512_GCM (SOAP_MEC_AES512_GCM | SOAP_MEC_DEC)

#define SOAP_MEC_DEC_DES_CBC (SOAP_MEC_DES_CBC | SOAP_MEC_DEC)

Symmetric secret key decryption

#define SOAP_MEC_DES_CBC (0x0010)

Cipher type (triple 3DES EDE CBC)

#define SOAP_MEC_ENC (0x2000)

Encode mode

#define SOAP_MEC_ENC_AES128_CBC (SOAP_MEC_AES128_CBC | SOAP_MEC_ENC)

#define SOAP_MEC_ENC_AES128_GCM (SOAP_MEC_AES128_GCM | SOAP_MEC_ENC)

#define SOAP_MEC_ENC_AES192_CBC (SOAP_MEC_AES192_CBC | SOAP_MEC_ENC)

#define SOAP_MEC_ENC_AES192_GCM (SOAP_MEC_AES192_GCM | SOAP_MEC_ENC)

#define SOAP_MEC_ENC_AES256_CBC (SOAP_MEC_AES256_CBC | SOAP_MEC_ENC)

#define SOAP_MEC_ENC_AES256_GCM (SOAP_MEC_AES256_GCM | SOAP_MEC_ENC)

#define SOAP_MEC_ENC_AES512_CBC (SOAP_MEC_AES512_CBC | SOAP_MEC_ENC)

#define SOAP_MEC_ENC_AES512_GCM (SOAP_MEC_AES512_GCM | SOAP_MEC_ENC)

#define SOAP_MEC_ENC_DES_CBC (SOAP_MEC_DES_CBC | SOAP_MEC_ENC)

Symmetric secret key encryption

#define SOAP_MEC_ENV (0x4000)

Envelope mode

#define SOAP_MEC_ENV_DEC (SOAP_MEC_ENV | SOAP_MEC_DEC)

Envelope decryption mode

#define SOAP_MEC_ENV_DEC_AES128_CBC (SOAP_MEC_DEC_AES128_CBC | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_DEC_AES128_GCM (SOAP_MEC_DEC_AES128_GCM | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_DEC_AES192_CBC (SOAP_MEC_DEC_AES192_CBC | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_DEC_AES192_GCM (SOAP_MEC_DEC_AES192_GCM | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_DEC_AES256_CBC (SOAP_MEC_DEC_AES256_CBC | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_DEC_AES256_GCM (SOAP_MEC_DEC_AES256_GCM | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_DEC_AES512_CBC (SOAP_MEC_DEC_AES512_CBC | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_DEC_AES512_GCM (SOAP_MEC_DEC_AES512_GCM | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_DEC_DES_CBC (SOAP_MEC_DEC_DES_CBC | SOAP_MEC_ENV)

Envelope (using RSA private key) decryption

#define SOAP_MEC_ENV_ENC (SOAP_MEC_ENV | SOAP_MEC_ENC)

Envelope encryption mode

#define SOAP_MEC_ENV_ENC_AES128_CBC (SOAP_MEC_ENC_AES128_CBC | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_ENC_AES128_GCM (SOAP_MEC_ENC_AES128_GCM | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_ENC_AES192_CBC (SOAP_MEC_ENC_AES192_CBC | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_ENC_AES192_GCM (SOAP_MEC_ENC_AES192_GCM | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_ENC_AES256_CBC (SOAP_MEC_ENC_AES256_CBC | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_ENC_AES256_GCM (SOAP_MEC_ENC_AES256_GCM | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_ENC_AES512_CBC (SOAP_MEC_ENC_AES512_CBC | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_ENC_AES512_GCM (SOAP_MEC_ENC_AES512_GCM | SOAP_MEC_ENV)

#define SOAP_MEC_ENV_ENC_DES_CBC (SOAP_MEC_ENC_DES_CBC | SOAP_MEC_ENV)

Envelope (using RSA public key) encryption

#define SOAP_MEC_GCM (0x1000)

Enable Galois Counter Mode (GCM)

#define SOAP_MEC_KEY_TYPE EVP_PKEY

Expose EVP_PKEY in a portable representation

#define SOAP_MEC_MASK (0xFFFF)

Mask

#define SOAP_MEC_NONE (0)

Engine off

#define SOAP_MEC_OAEP (0x020000)

RSA-OAEP padding

#define SOAP_MEC_STORE (0x010000)

Enable store (in buffer) instead of streaming mode

## Enumeration Type Documentation

enum SOAP_MEC_STATE

Decryption engine states

Enumerator
SOAP_MEC_STATE_NONE |
SOAP_MEC_STATE_INIT |
SOAP_MEC_STATE_IV |
SOAP_MEC_STATE_DECRYPT |
SOAP_MEC_STATE_FINAL |
SOAP_MEC_STATE_FLUSH |

## Function Documentation

int soap_mec_begin | ( | struct soap * | soap,
|  | struct soap_mec_data * | data,
|  | int | alg,
|  | SOAP_MEC_KEY_TYPE * | pkey,
|  | unsigned char * | key,
|  | int * | keylen
| ) |  |

Initialize the mecevp engine data and begin encryption or decryption message sequence using a private/public key or symmetric secret key.

Parameters

  | soap | context
  [in,out] | data | mecevp engine context
  [in] | alg | encryption/decryption algorithm
  [in] | pkey | public/private key or NULL
  [in,out] | key | secret key or encrypted ephemeral secret key set with envelope encryption, or NULL
  [in,out] | keylen | secret key length

Returns
  SOAP_OK or error code

void soap_mec_cleanup | ( | struct soap * | soap,
|  | struct soap_mec_data * | data
| ) |  |

Clean up mecevp engine and deallocate cipher context and buffers.

Parameters

  | soap | context
  [in,out] | data | mecevp engine context

Returns
  SOAP_OK or SOAP_SSL_ERROR

int soap_mec_end | ( | struct soap * | soap,
|  | struct soap_mec_data * | data
| ) |  |

Ends encryption or decryption of a sequence of message parts that began with soap_mec_begin.

Parameters

  | soap | context
  [in,out] | data | mecevp engine context

Returns
  SOAP_OK or error code

int soap_mec_final | ( | struct soap * | soap,
|  | struct soap_mec_data * | data,
|  | const char ** | s,
|  | size_t * | n
| ) |  |

Ends mecevp engine state: encrypt/decrypt remainder from buffers.

Parameters

  | soap | context
  [in,out] | data | mecevp engine context
  [out] | s | afterwards points to converted remaining data in streaming mode, or entire converted data in buffer mode (SOAP_MEC_STORE option)
  [out] | n | afterwards size of remaining data

Returns
  SOAP_OK or SOAP_SSL_ERROR

int soap_mec_init | ( | struct soap * | soap,
|  | struct soap_mec_data * | data,
|  | int | alg,
|  | SOAP_MEC_KEY_TYPE * | pkey,
|  | unsigned char * | key,
|  | int * | keylen
| ) |  |

Initialize mecevp engine state and create context for encryption/decryption algorithm using a private/public key or symmetric secret key.

Parameters

  | soap | context
  [in,out] | data | mecevp engine context
  [in] | alg | encryption/decryption algorithm
  [in] | pkey | public/private key or NULL
  [in,out] | key | secret key or encrypted ephemeral secret key set with envelope encryption, or NULL
  [in,out] | keylen | secret key length

Returns
  SOAP_OK or SOAP_SSL_ERROR

size_t soap_mec_size | ( | int | alg,
|  | SOAP_MEC_KEY_TYPE * | pkey
| ) |  |

Returns the number of octets needed to store the public/private key or the symmetric key, depending on the algorithm.

Parameters

  [in] | alg | is the algorithm to be used
  [in] | pkey | is a pointer to an EVP_PKEY object or NULL for symmetric keys

Returns
  size_t number of octets that is needed to hold the key.

int soap_mec_start | ( | struct soap * | soap,
|  | const unsigned char * | key
| ) |  |

Start encryption or decryption of current message. If key is non-NULL, use the symmetric key with alg. Use soap_mec_start only after soap_mec_begin. The soap_mec_start should be followed by a soap_mec_stop call.

Parameters

  | soap | context
  [in] | key | secret DES/AES key or NULL

Returns
  SOAP_OK or error code

int soap_mec_start_alg | ( | struct soap * | soap,
|  | int | alg,
|  | const unsigned char * | key
| ) |  |

Start encryption or decryption of current message. If key is non-NULL, use the symmetric key with alg. Use soap_mec_start only after soap_mec_begin. The soap_mec_start should be followed by a soap_mec_stop call.

Parameters

  | soap | context
  [in] | alg | algorithm
  [in] | key | secret DES/AES key or NULL for private key

Returns
  SOAP_OK or error code

int soap_mec_stop | ( | struct soap * | soap | ) |

Stops encryption or decryption of current message. Use after soap_mec_start.

Parameters

  soap | context

Returns
  SOAP_OK or error code

int soap_mec_update | ( | struct soap * | soap,
|  | struct soap_mec_data * | data,
|  | const char ** | s,
|  | size_t * | n
| ) |  |

Update mecevp engine state: encrypts plain text (or raw data) or decrypts cipher data in base64 format.

Parameters

  | soap | context
  [in,out] | data | mecevp engine context
  [in,out] | s | input data to convert, afterwards points to converted data (original content is unchanged)
  [in,out] | n | size of input, afterwards size of output

Returns
  SOAP_OK or SOAP_SSL_ERROR