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
typedef drip_link_sign_cb_t
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:
contextOpaque context passed to the callback.inputPointer to the payload to sign.input_lengthLength of the payload in bytes.bufferOutput buffer for the signature.buffer_sizeSize of the signature buffer in bytes.output_lengthReceives resulting link length written.
Return value:
0on success.Non-zeroon signing failure.
struct drip_link_t
Variables:
-
drip_det_t child_det
-
drip_hi_t child_hi
-
drip_det_t parent_det
-
uint8_t sam_type
-
drip_signature_t signature
-
uint32_t vna
-
uint32_t vnb
typedef drip_link_verify_cb_t
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:
contextOpaque context passed to the callback.inputPointer to the signed payload data.input_lengthLength of the signed payload in bytes.signaturePointer to the signature to verify against.signature_lengthLength of the signature in bytes.
Return value:
0on success.Non-zeroon verification failure.
Functions Documentation
function drip_link_decode
int drip_link_decode (
drip_link_t *link,
const uint8_t *buffer,
size_t buffer_size
)
function drip_link_encode
int drip_link_encode (
const drip_link_t *link,
uint8_t *buffer,
size_t buffer_size,
size_t *encoded_length
)
function drip_link_get_child_det
const drip_det_t * drip_link_get_child_det (
const drip_link_t *link
)
function drip_link_get_child_hi
const drip_hi_t * drip_link_get_child_hi (
const drip_link_t *link
)
function drip_link_get_parent_det
const drip_det_t * drip_link_get_parent_det (
const drip_link_t *link
)
function drip_link_get_signature
const drip_signature_t * drip_link_get_signature (
const drip_link_t *link
)
function drip_link_get_vna
Get the vna timestamp.
uint32_t drip_link_get_vna (
const drip_link_t *link
)
Returned as seconds since DRIP_TIMESTAMP_EPOCH.
Parameters:
linkPointer to the link.
Returns:
The stored vna, or 0 if link is NULL.
function drip_link_get_vna_unixtime
Get the vna timestamp.
uint32_t drip_link_get_vna_unixtime (
const drip_link_t *link
)
Returned as seconds since DRIP_TIMESTAMP_EPOCH.
Parameters:
manifestPointer to the manifest.
Returns:
The vna timestamp or 0 if manifest is NULL.
function drip_link_get_vnb
Get the vnb timestamp.
uint32_t drip_link_get_vnb (
const drip_link_t *link
)
Returned as seconds since DRIP_TIMESTAMP_EPOCH.
Parameters:
linkPointer to the link.
Returns:
The stored vnb, or 0 if link is NULL.
function drip_link_get_vnb_unixtime
Get the vnb timestamp.
uint32_t drip_link_get_vnb_unixtime (
const drip_link_t *link
)
Returned as seconds since DRIP_TIMESTAMP_EPOCH.
Parameters:
manifestPointer to the manifest.
Returns:
The vnb timestamp or 0 if manifest is NULL.
function drip_link_init
int drip_link_init (
drip_link_t *link
)
function drip_link_set_child_det
int drip_link_set_child_det (
drip_link_t *link,
const drip_det_t *det
)
function drip_link_set_child_hi
int drip_link_set_child_hi (
drip_link_t *link,
const drip_hi_t *hi
)
function drip_link_set_parent_det
int drip_link_set_parent_det (
drip_link_t *link,
const drip_det_t *det
)
function drip_link_set_signature
int drip_link_set_signature (
drip_link_t *link,
const drip_signature_t *signature
)
function drip_link_set_vna
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:
linkPointer to the link to modify.vnaOffset from DRIP_TIMESTAMP_EPOCH in seconds.
Return value:
DRIP_SUCCESSif vna was stored.DRIP_ERROR_NULL_POINTERif link is NULL.DRIP_ERROR_OUT_OF_RANGEif vna > UINT32_MAX - DRIP_TIMESTAMP_EPOCH.
function drip_link_set_vna_unixtime
Set the vna from unix timestamp.
int drip_link_set_vna_unixtime (
drip_link_t *link,
uint32_t unixtime
)
Parameters:
linkPointer to the link to modify.unixtimeUnix timestamp in seconds.
Return value:
DRIP_SUCCESSif vna was stored.DRIP_ERROR_NULL_POINTERif link is NULL.DRIP_ERROR_OUT_OF_RANGEif unixtime < DRIP_TIMESTAMP_EPOCH.
function drip_link_set_vnb
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:
linkPointer to the link to modify.vnbOffset from DRIP_TIMESTAMP_EPOCH in seconds.
Return value:
DRIP_SUCCESSif vnb was stored.DRIP_ERROR_NULL_POINTERif link is NULL.DRIP_ERROR_OUT_OF_RANGEif vnb > UINT32_MAX - DRIP_TIMESTAMP_EPOCH.
function drip_link_set_vnb_unixtime
Set the vnb from unix timestamp.
int drip_link_set_vnb_unixtime (
drip_link_t *link,
uint32_t unixtime
)
Parameters:
linkPointer to the link to modify.unixtimeUnix timestamp in seconds.
Return value:
DRIP_SUCCESSif vnb was stored.DRIP_ERROR_NULL_POINTERif link is NULL.DRIP_ERROR_OUT_OF_RANGEif unixtime < DRIP_TIMESTAMP_EPOCH.
function drip_link_sign
int drip_link_sign (
drip_link_t *link,
drip_link_sign_cb_t callback,
void *context
)
function drip_link_to_json
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:
linkPointer to the link to serialize.bufferOutput buffer for the JSON representation.buffer_sizeSize ofbufferin bytes.json_lengthOptional. Receives receives the number of characters for the full non truncated output. Ignored if NULL.
Return value:
DRIP_SUCCESSon success.DRIP_ERROR_NULL_POINTERiflinkorbufferis NULL.DRIP_ERROR_BUFFER_TOO_SMALLifbuffer_sizeis too small.
function drip_link_validate
int drip_link_validate (
const drip_link_t *link
)
function drip_link_verify
int drip_link_verify (
drip_link_t *link,
drip_link_verify_cb_t callback,
void *context
)
Macros Documentation
define DRIP_LINK_SIZE
#define DRIP_LINK_SIZE 137