Link

include/drip/link.h

Structures and Types

Type Name
typedef int(* drip_link_sign_cb_t
Callback function type for producing link signatures.
struct drip_link_t
typedef int(* drip_link_verify_cb_t
Callback function type for verifying link signatures.

Functions

Type Name
int drip_link_decode (drip_link_t *link, const uint8_t *buffer, size_t buffer_size)
int drip_link_encode (const drip_link_t *link, uint8_t *buffer, size_t buffer_size, size_t *encoded_length)
const drip_det_t * drip_link_get_child_det (const drip_link_t *link)
const drip_hi_t * drip_link_get_child_hi (const drip_link_t *link)
const drip_det_t * drip_link_get_parent_det (const drip_link_t *link)
const drip_signature_t * drip_link_get_signature (const drip_link_t *link)
uint32_t drip_link_get_vna (const drip_link_t *link)
Get the vna timestamp.
uint32_t drip_link_get_vna_unixtime (const drip_link_t *link)
Get the vna timestamp.
uint32_t drip_link_get_vnb (const drip_link_t *link)
Get the vnb timestamp.
uint32_t drip_link_get_vnb_unixtime (const drip_link_t *link)
Get the vnb timestamp.
int drip_link_init (drip_link_t *link)
int drip_link_set_child_det (drip_link_t *link, const drip_det_t *det)
int drip_link_set_child_hi (drip_link_t *link, const drip_hi_t *hi)
int drip_link_set_parent_det (drip_link_t *link, const drip_det_t *det)
int drip_link_set_signature (drip_link_t *link, const drip_signature_t *signature)
int drip_link_set_vna (drip_link_t *link, uint32_t vna)
Set the vna timestamp.
int drip_link_set_vna_unixtime (drip_link_t *link, uint32_t unixtime)
Set the vna from unix timestamp.
int drip_link_set_vnb (drip_link_t *link, uint32_t vnb)
Set the vnb timestamp.
int drip_link_set_vnb_unixtime (drip_link_t *link, uint32_t unixtime)
Set the vnb from unix timestamp.
int drip_link_sign (drip_link_t *link, drip_link_sign_cb_t callback, void *context)
int drip_link_to_json (const drip_link_t *link, char *buffer, size_t buffer_size, size_t *json_length)
Serialize a DRIP link to a JSON string.
int drip_link_validate (const drip_link_t *link)
int drip_link_verify (drip_link_t *link, drip_link_verify_cb_t callback, void *context)

Macros

Type Name
define DRIP_LINK_SIZE 137

Structures and Types Documentation

Callback function type for producing link signatures.

typedef int(* drip_link_sign_cb_t) (void *context, const uint8_t *input, size_t input_length, uint8_t *buffer, size_t buffer_size, size_t *output_length);

Called by drip_link_sign() to perform the actual signing of the payload.

Parameters:

  • context Opaque context passed to the callback.
  • input Pointer to the payload to sign.
  • input_length Length of the payload in bytes.
  • buffer Output buffer for the signature.
  • buffer_size Size of the signature buffer in bytes.
  • output_length Receives resulting link length written.

Return value:

  • 0 on success.
  • Non-zero on signing failure.

Variables:

Callback function type for verifying link signatures.

typedef int(* drip_link_verify_cb_t) (void *context, const uint8_t *input, size_t input_length, const uint8_t *signature, size_t signature_length);

Called by drip_link_verify() to perform the actual verification of the signed payload.

Parameters:

  • context Opaque context passed to the callback.
  • input Pointer to the signed payload data.
  • input_length Length of the signed payload in bytes.
  • signature Pointer to the signature to verify against.
  • signature_length Length of the signature in bytes.

Return value:

  • 0 on success.
  • Non-zero on verification failure.

Functions Documentation

int drip_link_decode (
    drip_link_t *link,
    const uint8_t *buffer,
    size_t buffer_size
) 
int drip_link_encode (
    const drip_link_t *link,
    uint8_t *buffer,
    size_t buffer_size,
    size_t *encoded_length
) 
const drip_det_t * drip_link_get_child_det (
    const drip_link_t *link
) 
const drip_hi_t * drip_link_get_child_hi (
    const drip_link_t *link
) 
const drip_det_t * drip_link_get_parent_det (
    const drip_link_t *link
) 
const drip_signature_t * drip_link_get_signature (
    const drip_link_t *link
) 

Get the vna timestamp.

uint32_t drip_link_get_vna (
    const drip_link_t *link
) 

Returned as seconds since DRIP_TIMESTAMP_EPOCH.

Parameters:

  • link Pointer to the link.

Returns:

The stored vna, or 0 if link is NULL.

Get the vna timestamp.

uint32_t drip_link_get_vna_unixtime (
    const drip_link_t *link
) 

Returned as seconds since DRIP_TIMESTAMP_EPOCH.

Parameters:

  • manifest Pointer to the manifest.

Returns:

The vna timestamp or 0 if manifest is NULL.

Get the vnb timestamp.

uint32_t drip_link_get_vnb (
    const drip_link_t *link
) 

Returned as seconds since DRIP_TIMESTAMP_EPOCH.

Parameters:

  • link Pointer to the link.

Returns:

The stored vnb, or 0 if link is NULL.

Get the vnb timestamp.

uint32_t drip_link_get_vnb_unixtime (
    const drip_link_t *link
) 

Returned as seconds since DRIP_TIMESTAMP_EPOCH.

Parameters:

  • manifest Pointer to the manifest.

Returns:

The vnb timestamp or 0 if manifest is NULL.

int drip_link_init (
    drip_link_t *link
) 
int drip_link_set_child_det (
    drip_link_t *link,
    const drip_det_t *det
) 
int drip_link_set_child_hi (
    drip_link_t *link,
    const drip_hi_t *hi
) 
int drip_link_set_parent_det (
    drip_link_t *link,
    const drip_det_t *det
) 
int drip_link_set_signature (
    drip_link_t *link,
    const drip_signature_t *signature
) 

Set the vna timestamp.

int drip_link_set_vna (
    drip_link_t *link,
    uint32_t vna
) 

Stored internally as seconds since DRIP_TIMESTAMP_EPOCH.

Parameters:

  • link Pointer to the link to modify.
  • vna Offset from DRIP_TIMESTAMP_EPOCH in seconds.

Return value:

  • DRIP_SUCCESS if vna was stored.
  • DRIP_ERROR_NULL_POINTER if link is NULL.
  • DRIP_ERROR_OUT_OF_RANGE if vna > UINT32_MAX - DRIP_TIMESTAMP_EPOCH.

Set the vna from unix timestamp.

int drip_link_set_vna_unixtime (
    drip_link_t *link,
    uint32_t unixtime
) 

Parameters:

  • link Pointer to the link to modify.
  • unixtime Unix timestamp in seconds.

Return value:

  • DRIP_SUCCESS if vna was stored.
  • DRIP_ERROR_NULL_POINTER if link is NULL.
  • DRIP_ERROR_OUT_OF_RANGE if unixtime < DRIP_TIMESTAMP_EPOCH.

Set the vnb timestamp.

int drip_link_set_vnb (
    drip_link_t *link,
    uint32_t vnb
) 

Stored internally as seconds since DRIP_TIMESTAMP_EPOCH.

Parameters:

  • link Pointer to the link to modify.
  • vnb Offset from DRIP_TIMESTAMP_EPOCH in seconds.

Return value:

  • DRIP_SUCCESS if vnb was stored.
  • DRIP_ERROR_NULL_POINTER if link is NULL.
  • DRIP_ERROR_OUT_OF_RANGE if vnb > UINT32_MAX - DRIP_TIMESTAMP_EPOCH.

Set the vnb from unix timestamp.

int drip_link_set_vnb_unixtime (
    drip_link_t *link,
    uint32_t unixtime
) 

Parameters:

  • link Pointer to the link to modify.
  • unixtime Unix timestamp in seconds.

Return value:

  • DRIP_SUCCESS if vnb was stored.
  • DRIP_ERROR_NULL_POINTER if link is NULL.
  • DRIP_ERROR_OUT_OF_RANGE if unixtime < DRIP_TIMESTAMP_EPOCH.
int drip_link_sign (
    drip_link_t *link,
    drip_link_sign_cb_t callback,
    void *context
) 

Serialize a DRIP link to a JSON string.

int drip_link_to_json (
    const drip_link_t *link,
    char *buffer,
    size_t buffer_size,
    size_t *json_length
) 

On success writes a NULL terminated JSON to buffer. Whenbuffer_size is too small the output is truncated and DRIP_ERROR_BUFFER_TOO_SMALL is returned. The truncated buffer is still NULL terminated.

Parameters:

  • link Pointer to the link to serialize.
  • buffer Output buffer for the JSON representation.
  • buffer_size Size of buffer in bytes.
  • json_length Optional. Receives receives the number of characters for the full non truncated output. Ignored if NULL.

Return value:

  • DRIP_SUCCESS on success.
  • DRIP_ERROR_NULL_POINTER if link orbuffer is NULL.
  • DRIP_ERROR_BUFFER_TOO_SMALL if buffer_size is too small.
int drip_link_validate (
    const drip_link_t *link
) 
int drip_link_verify (
    drip_link_t *link,
    drip_link_verify_cb_t callback,
    void *context
) 

Macros Documentation

#define DRIP_LINK_SIZE 137