Logo
DSR GreenBOSS  1.1.0
Macros | Functions

Macros

#define zb_aes128   zb_osif_aes128
 Makes one AES128 encryption cycle. More...
 

Functions

void zb_security_init (const zb_uint8_t *key, zb_uint8_t key_type, zb_uint8_t application_id, zb_uint32_t src_id, const zb_ieee_addr_t src_addr)
 Initializes the security module. More...
 
zb_uint32_t zb_security_encode (const zb_uint8_t *header, const zb_uint8_t *payload, zb_uint8_t header_size, zb_uint8_t payload_size, zb_uint8_t security_level, zb_uint32_t seq_number, zb_uint8_t *result)
 Encrypts the user packet using a key selected earlier. More...
 
zb_ret_t zb_security_decode (zb_uint8_t app_id, zb_uint32_t src_id, const zb_ieee_addr_t ieee_addr, const zb_uint8_t *header, const zb_uint8_t *payload, zb_uint8_t header_size, zb_uint8_t payload_size, zb_uint32_t seq_number, zb_uint32_t mic, zb_uint8_t *result)
 Decrypts the user packet using a key selected earlier. More...
 
const zb_uint8_tzb_security_get_key ()
 Returns current encryption key. More...
 
void zb_security_set_key (const zb_uint8_t *key)
 Sets current encryption key. More...
 
zb_uint8_t zb_security_get_key_type ()
 Returns type of the current encryption key. More...
 
void zb_security_set_key_type (zb_uint8_t key_type)
 Sets type of the current encryption key. More...
 
void zb_security_set_initial_key (void)
 Sets the initial encryption key that was used at startup. More...
 
void zb_security_set_initial_key_type (void)
 Sets the initial key type that was used at startup. More...
 
zb_uint32_t zb_security_encode_key_for_commiss (const zb_uint8_t *key_tobe_encoded, zb_uint8_t app_id, zb_uint32_t src_id, const zb_ieee_addr_t ieee_addr, zb_uint8_t *result_key)
 Performs personal key encryption for commissioning. More...
 
zb_ret_t zgpd_decrypt_n_auth_gpd_key (zb_uint8_t app_id, zb_uint32_t src_id, const zb_ieee_addr_t ieee_addr, zb_uint8_t *encrypted_key, zb_uint32_t frame_counter, zb_uint32_t mic, zb_uint8_t *plain_key)
 Performs GPD key decryption from commissioning reply frame. More...
 

Detailed Description

Macro Definition Documentation

§ zb_aes128

#define zb_aes128   zb_osif_aes128

Makes one AES128 encryption cycle.

Parameters
keyKey to be used for encryption
msgMessage to be processed
cBuffer for the result

Function Documentation

§ zb_security_init()

void zb_security_init ( const zb_uint8_t key,
zb_uint8_t  key_type,
zb_uint8_t  application_id,
zb_uint32_t  src_id,
const zb_ieee_addr_t  src_addr 
)

Initializes the security module.

Note
Typically the function shouldn't be called by user application because it is called internally by gboss_app_init().
The function should be called before any encoding operation.
Parameters
key16-bytes encryption key to be used for security operations
key_typeGPD key type used for GPD frames encryption
application_idApplication ID, which defines the GPDF frame format
src_idGPD source ID
src_addr64-bit source address

§ zb_security_encode()

zb_uint32_t zb_security_encode ( const zb_uint8_t header,
const zb_uint8_t payload,
zb_uint8_t  header_size,
zb_uint8_t  payload_size,
zb_uint8_t  security_level,
zb_uint32_t  seq_number,
zb_uint8_t result 
)

Encrypts the user packet using a key selected earlier.

According to Zigbee CCM encryption standard the data to be encrypted consists of two parts: "a" and "m" strings.

Parameters
header"a" string according to CCM description
payload"m" string according to CCM description
header_sizeLength of the "a" part
m_payload_sizeLength of the "m" part
securiy_levelLevels 2 are 3 valid
seq_numberPacket sequential number
resultBuffer where the result should be stored to
Returns
zb_uint32_t MIC encryption value

References GBOSS_SECURITY_KEY_CAP_L2, and GBOSS_SECURITY_KEY_CAP_L3.

Referenced by zgpd_pkt_send_bidir().

§ zb_security_decode()

zb_ret_t zb_security_decode ( zb_uint8_t  app_id,
zb_uint32_t  src_id,
const zb_ieee_addr_t  ieee_addr,
const zb_uint8_t header,
const zb_uint8_t payload,
zb_uint8_t  header_size,
zb_uint8_t  payload_size,
zb_uint32_t  seq_number,
zb_uint32_t  mic,
zb_uint8_t result 
)

Decrypts the user packet using a key selected earlier.

According to Zigbee CCM encryption standard the data to be decrypted consists of two parts: "a" and "m" strings.

Parameters
app_idGP device Application ID
src_idGP device's source id (for AppID = 0b000)
ieee_addrGP device's IEEE address (for AppID = 0b010)
header"a" string according to CCM description
payload"m" string according to CCM description
header_sizeLength of the "a" part
m_payload_sizeLength of the "m" part
seq_numberPacket sequential number
micIncome Message Integrity Code
resultBuffer where the result should be stored to
Returns
zb_ret_t Decode status

§ zb_security_get_key()

const zb_uint8_t* zb_security_get_key ( )

Returns current encryption key.

Returns
const zb_uint8_t* pointer to the encryption key

§ zb_security_set_key()

void zb_security_set_key ( const zb_uint8_t key)

Sets current encryption key.

Note
Function doesn't perform copy of the passed key and refers to the key by pointer.
Parameters
constzb_uint8_t* pointer to the encryption key

§ zb_security_get_key_type()

zb_uint8_t zb_security_get_key_type ( )

Returns type of the current encryption key.

Returns
GP device encryption key type

Referenced by zb_nwk_frame_prepare().

§ zb_security_set_key_type()

void zb_security_set_key_type ( zb_uint8_t  key_type)

Sets type of the current encryption key.

Parameters
key_typeGP device encryption key type

§ zb_security_set_initial_key()

void zb_security_set_initial_key ( void  )

Sets the initial encryption key that was used at startup.

zb_security_init

§ zb_security_set_initial_key_type()

void zb_security_set_initial_key_type ( void  )

Sets the initial key type that was used at startup.

zb_security_init

§ zb_security_encode_key_for_commiss()

zb_uint32_t zb_security_encode_key_for_commiss ( const zb_uint8_t key_tobe_encoded,
zb_uint8_t  app_id,
zb_uint32_t  src_id,
const zb_ieee_addr_t  ieee_addr,
zb_uint8_t result_key 
)

Performs personal key encryption for commissioning.

Encryption of commissioning command significantly differs from ordinary packet security. In the commissioning packet only the key should be encrypted instead of full data packet.

Parameters
key_tobe_encodedDevice's key to be encoded
app_idGP device Application ID
src_idGP device's source id (for AppID = 0b000)
ieee_addrGP device's IEEE address (for AppID = 0b010)
result_keyBuffer where the encoded key should be stored to
Returns
zb_uint32_t MIC encryption value

References GBOSS_APP_ID_0, and GBOSS_APP_ID_2.

§ zgpd_decrypt_n_auth_gpd_key()

zb_ret_t zgpd_decrypt_n_auth_gpd_key ( zb_uint8_t  app_id,
zb_uint32_t  src_id,
const zb_ieee_addr_t  ieee_addr,
zb_uint8_t encrypted_key,
zb_uint32_t  frame_counter,
zb_uint32_t  mic,
zb_uint8_t plain_key 
)

Performs GPD key decryption from commissioning reply frame.

Decryption of GPD key significantly differs from ordinary packet security. In the commissioning reply packet only the key should be decrypted instead of full data packet.

Parameters
app_idGP device Application ID
src_idGP device's source id (for AppID = 0b000)
ieee_addrGP device's IEEE address (for AppID = 0b010)
encrypted_keyPointer to key passed in Commissioning Reply frame
frame_counterReceived Commissioning Reply frame counter
micCommissioning Reply Message Integrity Code
plain_keyBuffer where the encoded key should be stored to
Returns
zb_ret_t Key decryption and authentication status