Microchip® Advanced Software Framework

stb.c File Reference

High-level security tool box.

High-level security tool box for ARM7 with crypto engine (SAM7XC)

Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <string.h>
#include "pal.h"
#include "tal.h"
#include "ieee_const.h"
#include "stb.h"
#include "sal.h"
#include "stb_internal.h"

Macros

#define NO_HDR_MIC   (0x00)
 

Functions

stb_ccm_t stb_ccm_secure (uint8_t *buffer, uint8_t nonce[AES_BLOCKSIZE], uint8_t *key, uint8_t hdr_len, uint8_t pld_len, uint8_t sec_level, uint8_t aes_dir)
 Secure one block with CCM*. More...
 
void stb_init (void)
 STB Initialization. More...
 
void stb_restart (void)
 STB Restart. More...
 

Variables

static bool key_change = true
 
static uint8_t last_key [AES_BLOCKSIZE]
 
static bool stb_restart_required = false
 

#define NO_HDR_MIC   (0x00)

stb_ccm_t stb_ccm_secure ( uint8_t *  buffer,
uint8_t  nonce[AES_BLOCKSIZE],
uint8_t *  key,
uint8_t  hdr_len,
uint8_t  pld_len,
uint8_t  sec_level,
uint8_t  aes_dir 
)

Secure one block with CCM*.

This functions secures one block with CCM* according to 802.15.4.

Parameters
[in,out]bufferInput: plaintext header and payload concatenated; for encryption: MUST HAVE 'AES_BLOCKSIZE' BYTES SPACE AT THE END FOR THE MIC! Output: frame secured (with MIC at end)/unsecured
[in]nonceThe nonce: Initialization Vector (IV) as used in cryptography; the ZigBee nonce (13 bytes long) are the bytes 2...14 of this nonce
[in]keyThe key to be used; if NULL, use the current key
[in]hdr_lenLength of plain text header (will not be encrypted)
[in]pld_lenLength of payload to be encrypted; if 0, then only MIC authentication implies
[in]sec_levelSecurity level according to IEEE 802.15.4, 7.6.2.2.1, Table 95:
  • the value may be 0 ... 7;
  • the two LSBs contain the MIC length in bytes (0, 4, 8 or 16);
  • bit 2 indicates whether encryption applies or not
[in]aes_dirAES_DIR_ENCRYPT if secure, AES_DIR_DECRYPT if unsecured
Returns
STB CCM Status

References AES_BLOCKSIZE, AES_DIR_ENCRYPT, AES_KEYSIZE, AES_MODE_ECB, aMaxPHYPacketSize, compute_mic(), encrypt_pldmic(), i, key_change, last_key, NULL, sal_aes_clean_up, sal_aes_restart(), sal_aes_setup(), stb_restart_required, tal_trx_status, tal_trx_wakeup(), and TRX_SLEEP.

void stb_init ( void  )

STB Initialization.

This function initializes the STB.

References sal_init().

Referenced by mac_init().

void stb_restart ( void  )

STB Restart.

This function re-starts the STB after power down.

References stb_restart_required.

Referenced by tal_trx_sleep(), and trx_reset().

bool key_change = true
static

Referenced by stb_ccm_secure().

uint8_t last_key[AES_BLOCKSIZE]
static

Referenced by stb_ccm_secure().

bool stb_restart_required = false
static

Referenced by stb_ccm_secure(), and stb_restart().