ProvisioningLibrary
Atmel Security Provisioning Library
atcaprov_bson.c File Reference

BSON (http://bsonspec.org/) handling routines for working with the provisioning server messages. More...

#include "atcaprov_bson.h"

Functions

const uint8_t * bson_memfind (const uint8_t *area, size_t area_size, const uint8_t *data, size_t data_size)
 Find binary data within a search area. More...
 
int32_t bson_dec_int32 (const uint8_t *data)
 Decode a BSON int32 value. More...
 
void bson_enc_int32 (uint8_t *data, int32_t value)
 Encode a BSON int32 value. More...
 
void bson_enc_bool (uint8_t *data, int value)
 Encode a BSON boolean value. More...
 
const uint8_t * bson_find_field (const uint8_t *area, size_t area_size, uint8_t type, const char *name, uint32_t *size, int index)
 Simple routine to find fields in BSON data. More...
 

Detailed Description

BSON (http://bsonspec.org/) handling routines for working with the provisioning server messages.

Function Documentation

int32_t bson_dec_int32 ( const uint8_t *  data)

Decode a BSON int32 value.

void bson_enc_bool ( uint8_t *  data,
int  value 
)

Encode a BSON boolean value.

void bson_enc_int32 ( uint8_t *  data,
int32_t  value 
)

Encode a BSON int32 value.

const uint8_t* bson_find_field ( const uint8_t *  area,
size_t  area_size,
uint8_t  type,
const char *  name,
uint32_t *  size,
int  index 
)

Simple routine to find fields in BSON data.

This is a simple routine that works for the simple BSON we're dealing with. It won't work for all possible BSON data. Notes that when searching for binary data (type=0x05), the returned pointer points to the binary type flag. The actual binary data starts at the next byte.

Parameters
[in]areaPointer to the BSON data to search.
[in]area_sizeSize of the BSON data in bytes.
[in]typeField type to search for.
[in]nameFiled name to search for.
[out]sizeSize of the found field data returned here. Can be set to NULL if not needed.
[in]indexIf the field type and name appears multiple times, find this instance. 0 is the first one.
Returns
Pointer to the field data in area, if found. NULL otherwise.
const uint8_t* bson_memfind ( const uint8_t *  area,
size_t  area_size,
const uint8_t *  data,
size_t  data_size 
)

Find binary data within a search area.