|  | Home | Documentation | smdevp.c File Reference updated by Robert van Engelen |

Functions
smdevp.c File Reference
`#include "smdevp.h"`
Include dependency graph for smdevp.c:

## Functions

static int | soap_smd_send (struct soap *soap, const char *buf, size_t len)
| Callback to intercept messages for digest or signature computation/verification.
static size_t | soap_smd_recv (struct soap *soap, char *buf, size_t len)
| Callback to intercept messages for digest or signature computation/verification.
static int | soap_smd_check (struct soap *soap, struct soap_smd_data *data, int err, const char *msg)
| Check result of init/update/final smdevp engine operations.
SOAP_FMAC1 size_t SOAP_FMAC2 | soap_smd_size (int alg, const void *key)
| Returns the number of octets needed to store the digest or signature returned by soap_smd_end.
SOAP_FMAC1 int SOAP_FMAC2 | soap_smd_begin (struct soap *soap, int alg, const void *key, int keylen)
| Initiates a digest or signature computation.
SOAP_FMAC1 int SOAP_FMAC2 | soap_smd_end (struct soap *soap, char *buf, int *len)
| Completes a digest or signature computation. Also deallocates temporary storage allocated by soap_smd_begin(), so MUST be called after soap_smd_begin().
SOAP_FMAC1 int SOAP_FMAC2 | soap_smd_init (struct soap *soap, struct soap_smd_data *data, int alg, const void *key, int keylen)
| Initiates a (signed) digest computation.
SOAP_FMAC1 int SOAP_FMAC2 | soap_smd_update (struct soap *soap, struct soap_smd_data *data, const char *buf, size_t len)
| Updates (signed) digest computation with message part.
SOAP_FMAC1 int SOAP_FMAC2 | soap_smd_final (struct soap *soap, struct soap_smd_data *data, char *buf, int *len)
| Finalizes (signed) digest computation, delete context and returns digest or signature.
SOAP_FMAC1 void SOAP_FMAC2 | soap_smd_cleanup (struct soap *soap, struct soap_smd_data *data)
| Clear (signed) digest computation and delete context.

## Function Documentation

## ◆ soap_smd_begin()

SOAP_FMAC1 int SOAP_FMAC2 soap_smd_begin | ( | struct soap * | soap,
|  | int | alg,
|  | const void * | key,
|  | int | keylen )

Initiates a digest or signature computation.

Parameters

  | soap | context
  [in] | alg | is the digest or signature (sign/verification) algorithm used
  [in] | key | is a HMAC key or pointer to EVP_PKEY object or NULL for digests
  [in] | keylen | is the length of the HMAC key or 0

Returns
  SOAP_OK, SOAP_EOM, or SOAP_SSL_ERROR

## ◆ soap_smd_check()

int soap_smd_check | ( | struct soap * | soap,
|  | struct soap_smd_data * | data,
|  | int | ok,
|  | const char * | msg )

static

Check result of init/update/final smdevp engine operations.

Parameters

  | soap | context
  [in,out] | data | smdevp engine context
  [in] | ok | EVP error value
  [in] | msg | error message

Returns
  SOAP_OK or SOAP_SSL_ERROR

## ◆ soap_smd_cleanup()

SOAP_FMAC1 void SOAP_FMAC2 soap_smd_cleanup | ( | struct soap * | soap,
|  | struct soap_smd_data * | data )

Clear (signed) digest computation and delete context.

Parameters

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

## ◆ soap_smd_end()

SOAP_FMAC1 int SOAP_FMAC2 soap_smd_end | ( | struct soap * | soap,
|  | char * | buf,
|  | int * | len )

Completes a digest or signature computation. Also deallocates temporary storage allocated by soap_smd_begin(), so MUST be called after soap_smd_begin().

Parameters

  | soap | context
  [in] | buf | contains signature for verification (when using a SOAP_SMD_VRFY algorithm) or NULL for cleanup
  [out] | buf | is populated with the digest or signature with maximum length soap_smd_size(alg, key)
  [in] | len | points to length of signature to verify (when using a SOAP_SMD_VRFY algorithm) or NULL for cleanup
  [out] | len | points to length of stored digest or signature (when not NULL)

Returns
  SOAP_OK, SOAP_USER_ERROR, or SOAP_SSL_ERROR

## ◆ soap_smd_final()

SOAP_FMAC1 int SOAP_FMAC2 soap_smd_final | ( | struct soap * | soap,
|  | struct soap_smd_data * | data,
|  | char * | buf,
|  | int * | len )

Finalizes (signed) digest computation, delete context and returns digest or signature.

Parameters

  | soap | context
  [in,out] | data | smdevp engine context
  [in] | buf | contains signature for verification (SOAP_SMD_VRFY algorithms) maximum length soap_smd_size(alg, key)
  [out] | buf | is populated with the digest or signature of
  [in] | len | points to length of signature to verify (SOAP_SMD_VRFY algorithms)
  [out] | len | points to length of stored digest or signature (pass NULL if you are not interested in this value)

Returns
  SOAP_OK or SOAP_SSL_ERROR

## ◆ soap_smd_init()

SOAP_FMAC1 int SOAP_FMAC2 soap_smd_init | ( | struct soap * | soap,
|  | struct soap_smd_data * | data,
|  | int | alg,
|  | const void * | key,
|  | int | keylen )

Initiates a (signed) digest computation.

Parameters

  | soap | context
  [in,out] | data | smdevp engine context
  [in] | alg | is algorithm to use
  [in] | key | is key to use or NULL for digests
  [in] | keylen | is length of HMAC key (when provided)

Returns
  SOAP_OK or SOAP_SSL_ERROR

## ◆ soap_smd_recv()

size_t soap_smd_recv | ( | struct soap * | soap,
|  | char * | buf,
|  | size_t | len )

static

Callback to intercept messages for digest or signature computation/verification.

Parameters

  | soap | context
  [in] | buf | buffer
  [in] | len | max buffer length

Returns
  message size in buffer or 0 on error.

## ◆ soap_smd_send()

int soap_smd_send | ( | struct soap * | soap,
|  | const char * | buf,
|  | size_t | len )

static

Callback to intercept messages for digest or signature computation/verification.

Parameters

  | soap | context
  [in] | buf | message
  [in] | len | message length

Returns
  SOAP_OK or SOAP_SSL_ERROR

## ◆ soap_smd_size()

SOAP_FMAC1 size_t SOAP_FMAC2 soap_smd_size | ( | int | alg,
|  | const void * | key )

Returns the number of octets needed to store the digest or signature returned by soap_smd_end.

Parameters

  [in] | alg | is the digest or signature algorithm to be used
  [in] | key | is a pointer to an EVP_PKEY object for RSA/DSA signatures or NULL for digests and HMAC

Returns
  size_t number of octets that is needed to hold digest or signature

See also
  soap_smd_end

The values returned for digests are SOAP_SMD_MD5_SIZE, SOAP_SMD_SHA1_SIZE, SOAP_SMD_SHA256_SIZE, SOAP_SMD_SHA512_SIZE.

## ◆ soap_smd_update()

SOAP_FMAC1 int SOAP_FMAC2 soap_smd_update | ( | struct soap * | soap,
|  | struct soap_smd_data * | data,
|  | const char * | buf,
|  | size_t | len )

Updates (signed) digest computation with message part.

Parameters

  | soap | context
  [in,out] | data | smdevp engine context
  [in] | buf | contains message part
  [in] | len | of message part

Returns
  SOAP_OK or SOAP_SSL_ERROR