nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Gazell Pairing common functions implementation

Macros

#define SOURCE_FILE   NRF_SOURCE_FILE_GZP
 File identifer for asserts.
 

Global variables

static const uint8_t pairing_base_address [4] = { GZP_ADDRESS }
 
static const uint8_t pairing_address_prefix_byte = 0
 
static const uint8_t gzp_validation_id [GZP_VALIDATION_ID_LENGTH] = GZP_VALIDATION_ID
 
static const uint8_t gzp_secret_key [16] = GZP_SECRET_KEY
 
static gzp_key_select_t gzp_key_select
 

Misc. external variables.

static uint8_t gzp_session_token [GZP_SESSION_TOKEN_LENGTH]
 
static uint8_t gzp_dyn_key [GZP_DYN_KEY_LENGTH]
 

Implementation common internal GZP functions

bool gzp_update_radio_params (const uint8_t *system_address)
 
void gzp_generate_channels (uint8_t *ch_dst, const uint8_t *system_address, uint8_t channel_tab_size)
 
__INLINE void nrf_gzp_disable_gzll (void)
 
void gzp_xor_cipher (uint8_t *dst, const uint8_t *src, const uint8_t *pad, uint8_t length)
 
bool gzp_validate_id (const uint8_t *id)
 
void gzp_add_validation_id (uint8_t *dst)
 
void gzp_crypt_set_session_token (const uint8_t *token)
 
void gzp_crypt_set_dyn_key (const uint8_t *key)
 
void gzp_crypt_get_session_token (uint8_t *dst_token)
 
void gzp_crypt_get_dyn_key (uint8_t *dst_key)
 
void gzp_crypt_select_key (gzp_key_select_t key_select)
 
void gzp_crypt (uint8_t *dst, const uint8_t *src, uint8_t length)
 
void gzp_random_numbers_generate (uint8_t *dst, uint8_t n)
 

Implementation of nRF51 specific GZP functions

static void nrf_gzp_set_primask (uint32_t primask)
 Function for setting the Primask variable. Only necessary if ARMCC compiler skips __set_PRIMASK at high optimization levels. More...
 
void nrf_gzp_flush_rx_fifo (uint32_t pipe)
 

Detailed Description

Function Documentation

bool gzp_update_radio_params ( const uint8_t *  system_address)

Update the channel table and the system address.

The channel table is updated to pseudo-random set generated using the system address. The channel table still includes GZP_CHANNEL_MAX and GZP_CHANNEL_MIN. The system address is applied to base address 1 and therefore applies to pipes 1-7.

Parameters
system_addressPointer to the system_address to set.
Return values
trueIf theradio parameters were updated successfully.
falseIf there was an error updated the radio parameters.
void gzp_generate_channels ( uint8_t *  ch_dst,
const uint8_t *  address,
uint8_t  channel_set_size 
)

Generate a set of channels from a 4 byte address.

Parameters
ch_dstDestination to write the channel set to. The channel set includes GZP_CHANNEL_MAX and GZP_CHANNEL_MIN.
addressFour byte address to generate the channel set from.
channel_set_sizeSize of the channel set to generate.
__INLINE void nrf_gzp_disable_gzll ( void  )

Disable Gazell and sleep while waiting for nrf_gzll_disabled callback.

void gzp_xor_cipher ( uint8_t *  dst,
const uint8_t *  src,
const uint8_t *  pad,
uint8_t  length 
)

Perform an XOR on two byte strings.

Parameters
dstDestination to write the result to. Should be of size length.
src
pad
lengthNumber of bytes to perform the XOR operation on.
bool gzp_validate_id ( const uint8_t *  src_id)

Compare the *src_id with a pre-defined validation ID.

Parameters
src_idPointer to the source validation ID to compare to.
Return values
trueIf *src_id equals the pre-defined ID.
falseIf *src_id does not equal the pre-defined ID.
void gzp_add_validation_id ( uint8_t *  dst_id)

Add the pre-defined validation ID to dst_id. GZP_VALIDATION_ID_LENGTH bytes will be added.

Parameters
dst_idPointer to add the GZP validation ID to.
void gzp_crypt_set_session_token ( const uint8_t *  token)

Set the session token.

Parameters
tokenPointer to the session token to set.
void gzp_crypt_set_dyn_key ( const uint8_t *  dyn_key)

Set the dynamic key.

Parameters
dyn_keyPointer to the dynamic key to set.
void gzp_crypt_get_session_token ( uint8_t *  dst_token)

Get the session token.

Parameters
dst_tokenPointer to write the session token.
void gzp_crypt_get_dyn_key ( uint8_t *  dst_key)

Get the dynamic key.

Parameters
dst_keyPointer to write the dynamic key too.
void gzp_crypt_select_key ( gzp_key_select_t  key_select)

Selecting what key-set that should be used when encrypting data using gzp_crypt().

Parameters
key_selectKey-set to use.
void gzp_crypt ( uint8_t *  dst,
const uint8_t *  src,
uint8_t  length 
)

Encypt / decrypt data.

The current "session token" will be used as initialization vector (IV). The AES key to be used is selected by gzp_crypt_select_key(). AES is a symmetric encryption scheme, this function can be used to perform both encryption and decryption.

Parameters
dstDestination to write encrypted data to. Should be 16 bytes long.
srcSource data to encrypt.
lengthLength in bytes of src.
void gzp_random_numbers_generate ( uint8_t *  dst,
uint8_t  n 
)

Generate random bytes.

Parameters
dstDestination to write the random bytes to.
nNumber of bytes to generate.
static void nrf_gzp_set_primask ( uint32_t  primask)
static
Parameters
primaskThe primask value. 1 to disable interrupts, 0 otherwise.
void nrf_gzp_flush_rx_fifo ( uint32_t  pipe)

Flush the GZLL RX FIFO for a specific pipe while GZLL is disabled.

Parameters
pipePipe.

Variable Documentation

const uint8_t pairing_base_address[4] = { GZP_ADDRESS }
static

Constant holding base address part of the pairing address.

const uint8_t pairing_address_prefix_byte = 0
static

Constant holding prefix byte of the pairing address.

const uint8_t gzp_validation_id[GZP_VALIDATION_ID_LENGTH] = GZP_VALIDATION_ID
static

Constant holding pre-defined "validation ID".

const uint8_t gzp_secret_key[16] = GZP_SECRET_KEY
static

Constant holding pre-defined "secret key".

gzp_key_select_t gzp_key_select
static

Variable used for AES key selection