wickr-crypto-c

Data Structures | Functions
wickr_payload

## Data Structures
struct | wickr_payload
| The encrypted body content of a Wickr packet. More...

## Functions
wickr_payload_t * | wickr_payload_create (wickr_packet_meta_t *meta, wickr_buffer_t *body)
wickr_payload_t * | wickr_payload_copy (const wickr_payload_t *source)
void | wickr_payload_destroy (wickr_payload_t **payload)
wickr_buffer_t * | wickr_payload_serialize (const wickr_payload_t *payload)
wickr_payload_t * | wickr_payload_create_from_buffer (const wickr_buffer_t *buffer)
wickr_cipher_result_t * | wickr_payload_encrypt (const wickr_payload_t *payload, const wickr_crypto_engine_t *engine, const wickr_cipher_key_t *payload_key)
wickr_payload_t * | wickr_payload_create_from_cipher (const wickr_crypto_engine_t *engine, const wickr_cipher_result_t *cipher_result, const wickr_cipher_key_t *payload_key)

## Detailed Description

## Function Documentation

## ◆ wickr_payload_copy()

wickr_payload_t* wickr_payload_copy | ( | const wickr_payload_t * | source | ) |

Copy a payload

Parameters

  source | the payload to copy

Returns
  a newly allocated payload holding a deep copy of the properties of 'source'

## ◆ wickr_payload_create()

wickr_payload_t* wickr_payload_create | ( | wickr_packet_meta_t * | meta,
|  | wickr_buffer_t * | body
| ) |  |

Create a payload from components

Parameters

  meta | see 'wickr_payload' property documentation property documentation
  body | see 'wickr_payload' property documentation property documentation

Returns
  a newly allocated payload owning the properties passed in

## ◆ wickr_payload_create_from_buffer()

wickr_payload_t* wickr_payload_create_from_buffer | ( | const wickr_buffer_t * | buffer | ) |

Deserialize a buffer into a payload

Parameters

  buffer | a buffer containing a payload serialized with 'wickr_payload_serialize'

Returns
  a payload with data contained in 'buffer', or NULL if 'buffer' is not formatted properly

## ◆ wickr_payload_create_from_cipher()

wickr_payload_t* wickr_payload_create_from_cipher | ( | const wickr_crypto_engine_t * | engine,
|  | const wickr_cipher_result_t * | cipher_result,
|  | const wickr_cipher_key_t * | payload_key
| ) |  |

Decrypt-Then-Deserialize

Parameters

  engine | a crypto engine capable of decryption using payload_key
  cipher_result | an encrypted payload
  payload_key | the key to use for decrypting 'cipher_result'

Returns
  a payload or NULL if an incorrect key is provided

## ◆ wickr_payload_destroy()

void wickr_payload_destroy | ( | wickr_payload_t ** | payload | ) |

Destroy a payload

Parameters

  payload | a pointer to the payload to destroy. All properties of '*payload' will also be destroyed

## ◆ wickr_payload_encrypt()

wickr_cipher_result_t* wickr_payload_encrypt | ( | const wickr_payload_t * | payload,
|  | const wickr_crypto_engine_t * | engine,
|  | const wickr_cipher_key_t * | payload_key
| ) |  |

Serialize-Then-Encrypt a payload

Payloads are serialized using protocol buffers (message.pb-c.h)

Parameters

  payload | the payload to encrypt
  engine | a crypto engine capable of encryption using payload_key
  payload_key | the key to use for encryption

Returns
  an encrypted payload

## ◆ wickr_payload_serialize()

wickr_buffer_t* wickr_payload_serialize | ( | const wickr_payload_t * | payload | ) |

Serialize a payload to a buffer

Parameters

  payload | the payload to serialize

Returns
  a buffer containing the properties of 'payload'