wickr-crypto-c

Data Structures | Functions
wickr_stream

## Data Structures
struct | wickr_stream_ctx
| A context that is used for encrypting or decrypting a sequenced stream of data packets The stream context manages the state of stream operations including key evolution management based on the sequence number of the being encrypted / decrypted. The stream context is assigned a direction, and can only be used for encoding OR decoding of packets, and not both. More...

## Functions
wickr_stream_ctx_t * | wickr_stream_ctx_create (const wickr_crypto_engine_t engine, wickr_stream_key_t *stream_key, wickr_stream_direction direction)
wickr_stream_ctx_t * | wickr_stream_ctx_copy (const wickr_stream_ctx_t *ctx)
wickr_cipher_result_t * | wickr_stream_ctx_encode (wickr_stream_ctx_t *ctx, const wickr_buffer_t *data, const wickr_buffer_t *aad, uint64_t seq_num)
wickr_buffer_t * | wickr_stream_ctx_decode (wickr_stream_ctx_t *ctx, const wickr_cipher_result_t *data, const wickr_buffer_t *aad, uint64_t seq_num)
void | wickr_stream_ctx_destroy (wickr_stream_ctx_t **ctx)
bool | wickr_stream_ctx_ref_up (wickr_stream_ctx_t *ctx)

## Detailed Description

## Function Documentation

## ◆ wickr_stream_ctx_copy()

wickr_stream_ctx_t* wickr_stream_ctx_copy | ( | const wickr_stream_ctx_t * | ctx | ) |

Copy a stream context

Parameters

  ctx | the stream context to copy

Returns
  a newly allocated stream context holding a deep copy of properties from 'ctx'

## ◆ wickr_stream_ctx_create()

wickr_stream_ctx_t* wickr_stream_ctx_create | ( | const wickr_crypto_engine_t | engine,
|  | wickr_stream_key_t * | stream_key,
|  | wickr_stream_direction | direction
| ) |  |

Create a stream context

Parameters

  engine | see wickr_stream_ctx documentation
  stream_key | see wickr_stream_ctx documentation
  direction | see wickr_stream_ctx documentation

Returns
  a newly allocated stream context owning the properties passed in

## ◆ wickr_stream_ctx_decode()

wickr_buffer_t* wickr_stream_ctx_decode | ( | wickr_stream_ctx_t * | ctx,
|  | const wickr_cipher_result_t * | data,
|  | const wickr_buffer_t * | aad,
|  | uint64_t | seq_num
| ) |  |

Encode a packet

Parameters

  ctx | context to use for decoding
  data | the data to decode using the context's key
  aad | additional data to authenticate with the ciphertext
  seq_num | the sequence number assoiciated with 'data'

Returns
  a buffer representing 'data' decrypted with 'ctx->key'

## ◆ wickr_stream_ctx_destroy()

void wickr_stream_ctx_destroy | ( | wickr_stream_ctx_t ** | ctx | ) |

Destroy a stream context

Parameters

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

## ◆ wickr_stream_ctx_encode()

wickr_cipher_result_t* wickr_stream_ctx_encode | ( | wickr_stream_ctx_t * | ctx,
|  | const wickr_buffer_t * | data,
|  | const wickr_buffer_t * | aad,
|  | uint64_t | seq_num
| ) |  |

Encode a packet

Parameters

  ctx | context to use for encoding
  data | the data to encode using the context's key
  aad | additional data to authenticate with the ciphertext
  seq_num | the sequence number assoiciated with 'data'

Returns
  a cipher result representing 'data' encrypted with 'ctx->key'

## ◆ wickr_stream_ctx_ref_up()

bool wickr_stream_ctx_ref_up | ( | wickr_stream_ctx_t * | ctx | ) |

Increment the reference count of a stream

Parameters

  ctx | the context to bump the reference count of