wickr-crypto-c

Data Structures | Functions
Wickr_transport_packet

## Data Structures
struct | wickr_transport_packet
| A packet used within the wickr_transport_ctx to package up data and related metadata + authentication in one serializable structure. More...

## Functions
wickr_transport_packet_t * | wickr_transport_packet_create (wickr_transport_packet_meta_t meta, wickr_buffer_t *body)
wickr_transport_packet_t * | wickr_transport_packet_copy (const wickr_transport_packet_t *pkt)
void | wickr_transport_packet_destroy (wickr_transport_packet_t **pkt)
wickr_buffer_t * | wickr_transport_packet_serialize (const wickr_transport_packet_t *pkt)
wickr_transport_packet_t * | wickr_transport_packet_create_from_buffer (const wickr_buffer_t *buffer)
bool | wickr_transport_packet_sign (wickr_transport_packet_t *pkt, const wickr_crypto_engine_t *engine, const wickr_identity_chain_t *identity_chain)
bool | wickr_transport_packet_verify (const wickr_transport_packet_t *packet, const wickr_crypto_engine_t *engine, wickr_identity_chain_t *identity_chain)

## Detailed Description

## Function Documentation

## ◆ wickr_transport_packet_copy()

wickr_transport_packet_t* wickr_transport_packet_copy | ( | const wickr_transport_packet_t * | pkt | ) |

Make a deep copy of a transport packet

Parameters

  pkt | the transport packet to make a copy of

Returns
  a newly allocated transport packet holding a deep copy of the properties of 'pkt'

## ◆ wickr_transport_packet_create()

wickr_transport_packet_t* wickr_transport_packet_create | ( | wickr_transport_packet_meta_t | meta,
|  | wickr_buffer_t * | body
| ) |  |

Create a transport packet

Parameters

  meta | metadata describing `body`
  body | the main contents of the packet

## ◆ wickr_transport_packet_create_from_buffer()

wickr_transport_packet_t* wickr_transport_packet_create_from_buffer | ( | const wickr_buffer_t * | buffer | ) |

Create a transport packet from a serialized transport packet

Parameters

  buffer | a buffer that was created by a call to `wickr_transport_packet_serialize`

Returns
  a newly allocated transport packet from the data contained in `buffer` or NULL if the buffer is corrupt or does not represent a transport packet

## ◆ wickr_transport_packet_destroy()

void wickr_transport_packet_destroy | ( | wickr_transport_packet_t ** | pkt | ) |

Destroy a transport packet

Parameters

  pkt | a pointer to the transport packet to destroy. All properties of `*pkt` will also be destroyed

## ◆ wickr_transport_packet_serialize()

wickr_buffer_t* wickr_transport_packet_serialize | ( | const wickr_transport_packet_t * | pkt | ) |

Serialize a transport packet down to a buffer for transfer

Parameters

  pkt | the packet to serialize

Returns
  the byte representation of `pkt` or NULL if serialization fails

## ◆ wickr_transport_packet_sign()

bool wickr_transport_packet_sign | ( | wickr_transport_packet_t * | pkt,
|  | const wickr_crypto_engine_t * | engine,
|  | const wickr_identity_chain_t * | identity_chain
| ) |  |

Sign a transport packet to authenticate it using an identity chain. Upon successful signing, the mac type of `pkt` will be set based on the type of key used for the signature

Parameters

  pkt | the packet to sign
  engine | a pointer to a crypto engine that support digital signatures
  identity_chain | an identity chain that at minimum contains the private key for a node identity in order to sign the packet

Returns
  true if signing is successful

## ◆ wickr_transport_packet_verify()

bool wickr_transport_packet_verify | ( | const wickr_transport_packet_t * | packet,
|  | const wickr_crypto_engine_t * | engine,
|  | wickr_identity_chain_t * | identity_chain
| ) |  |

Verify a packet that was signed by a call to `wickr_transport_packet_sign`

Parameters

  packet | the packet to verify
  engine | a pointer to a crypto engine that supports verifying digital signatures
  identity_chain | the public identity chain that is believed to have signed `packet`

Returns
  true if `packet` was signed by `identity_chain`