Atmel Software Framework

stb_generic.h File Reference

Declarations for security tool box.

Copyright (c) 2013-2015 Atmel Corporation. All rights reserved.

#include "compiler.h"
#include "sal_generic.h"

Macros

#define ADATA   (0x40)
 
#define ENCRYPTION_NOT_REQD   (0x00)
 Macros for MIC Calculation and Security. More...
 
#define ENCRYPTION_REQD   (0x01)
 
#define LEN_FIELD   (0x01)
 
#define LEN_MIC_00   (0x00)
 
#define LEN_MIC_128   (0x10)
 
#define LEN_MIC_32   (0x04)
 
#define LEN_MIC_64   (0x08)
 
#define PLAINTEXT_FLAG   (0x01)
 

Enumerations

enum  SHORTENUM {
  ASSOCIATIONREQUEST = (0x01),
  ASSOCIATIONRESPONSE,
  DISASSOCIATIONNOTIFICATION,
  DATAREQUEST,
  PANIDCONFLICTNOTIFICAION,
  ORPHANNOTIFICATION,
  BEACONREQUEST,
  COORDINATORREALIGNMENT,
  GTSREQUEST,
  ORPHANREALIGNMENT,
  BEACON_MESSAGE,
  DATAREQUEST_IMPL_POLL,
  NULL_FRAME,
  MCPS_MESSAGE,
  STB_CCM_OK = 0,
  STB_CCM_ILLPARM,
  STB_CCM_KEYMISS,
  STB_CCM_MICERR,
  SECURITY_00_LEVEL = 0x00,
  SECURITY_01_LEVEL,
  SECURITY_02_LEVEL,
  SECURITY_03_LEVEL,
  SECURITY_04_LEVEL,
  SECURITY_05_LEVEL,
  SECURITY_06_LEVEL,
  SECURITY_07_LEVEL,
  DISCOVERY_REQUEST = 0x01,
  DISCOVERY_RESPONSE = 0x02,
  PAIR_REQUEST = 0x03,
  PAIR_RESPONSE = 0x04,
  UNPAIR_REQUEST = 0x05,
  KEY_SEED = 0x06,
  PING_REQUEST = 0x07,
  PING_RESPONSE = 0x08
}
 CCM status values. More...
 
enum  SHORTENUM {
  ASSOCIATIONREQUEST = (0x01),
  ASSOCIATIONRESPONSE,
  DISASSOCIATIONNOTIFICATION,
  DATAREQUEST,
  PANIDCONFLICTNOTIFICAION,
  ORPHANNOTIFICATION,
  BEACONREQUEST,
  COORDINATORREALIGNMENT,
  GTSREQUEST,
  ORPHANREALIGNMENT,
  BEACON_MESSAGE,
  DATAREQUEST_IMPL_POLL,
  NULL_FRAME,
  MCPS_MESSAGE,
  STB_CCM_OK = 0,
  STB_CCM_ILLPARM,
  STB_CCM_KEYMISS,
  STB_CCM_MICERR,
  SECURITY_00_LEVEL = 0x00,
  SECURITY_01_LEVEL,
  SECURITY_02_LEVEL,
  SECURITY_03_LEVEL,
  SECURITY_04_LEVEL,
  SECURITY_05_LEVEL,
  SECURITY_06_LEVEL,
  SECURITY_07_LEVEL,
  DISCOVERY_REQUEST = 0x01,
  DISCOVERY_RESPONSE = 0x02,
  PAIR_REQUEST = 0x03,
  PAIR_RESPONSE = 0x04,
  UNPAIR_REQUEST = 0x05,
  KEY_SEED = 0x06,
  PING_REQUEST = 0x07,
  PING_RESPONSE = 0x08
}
 

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...
 

#define ADATA   (0x40)

Referenced by stb_ccm_secure().

#define ENCRYPTION_NOT_REQD   (0x00)

Macros for MIC Calculation and Security.

Referenced by stb_ccm_secure().

#define ENCRYPTION_REQD   (0x01)

Referenced by stb_ccm_secure().

#define LEN_FIELD   (0x01)

Referenced by stb_ccm_secure().

#define LEN_MIC_00   (0x00)

Referenced by stb_ccm_secure().

#define LEN_MIC_128   (0x10)

Referenced by stb_ccm_secure().

#define LEN_MIC_32   (0x04)

Referenced by stb_ccm_secure().

#define LEN_MIC_64   (0x08)

Referenced by stb_ccm_secure().

#define PLAINTEXT_FLAG   (0x01)

Referenced by stb_ccm_secure().

enum SHORTENUM

CCM status values.

Enumerator
ASSOCIATIONREQUEST 
ASSOCIATIONRESPONSE 
DISASSOCIATIONNOTIFICATION 
DATAREQUEST 
PANIDCONFLICTNOTIFICAION 
ORPHANNOTIFICATION 
BEACONREQUEST 
COORDINATORREALIGNMENT 
GTSREQUEST 
ORPHANREALIGNMENT 
BEACON_MESSAGE 
DATAREQUEST_IMPL_POLL 
NULL_FRAME 
MCPS_MESSAGE 
STB_CCM_OK 

CCM en/decryption OK.

STB_CCM_ILLPARM 

Illegal parameter value in stb_ccm_secure()

STB_CCM_KEYMISS 

No previous key init in stb_ccm_secure()

STB_CCM_MICERR 

MIC error detected in stb_ccm_secure()

SECURITY_00_LEVEL 

Security Level 0.

SECURITY_01_LEVEL 

Security Level 1.

SECURITY_02_LEVEL 

Security Level 2.

SECURITY_03_LEVEL 

Security Level 3.

SECURITY_04_LEVEL 

Security Level 4.

SECURITY_05_LEVEL 

Security Level 5.

SECURITY_06_LEVEL 

Security Level 6.

SECURITY_07_LEVEL 

Security Level 7.

DISCOVERY_REQUEST 
DISCOVERY_RESPONSE 
PAIR_REQUEST 
PAIR_RESPONSE 
UNPAIR_REQUEST 
KEY_SEED 
PING_REQUEST 
PING_RESPONSE 
enum SHORTENUM
Enumerator
ASSOCIATIONREQUEST 
ASSOCIATIONRESPONSE 
DISASSOCIATIONNOTIFICATION 
DATAREQUEST 
PANIDCONFLICTNOTIFICAION 
ORPHANNOTIFICATION 
BEACONREQUEST 
COORDINATORREALIGNMENT 
GTSREQUEST 
ORPHANREALIGNMENT 
BEACON_MESSAGE 
DATAREQUEST_IMPL_POLL 
NULL_FRAME 
MCPS_MESSAGE 
STB_CCM_OK 

CCM en/decryption OK.

STB_CCM_ILLPARM 

Illegal parameter value in stb_ccm_secure()

STB_CCM_KEYMISS 

No previous key init in stb_ccm_secure()

STB_CCM_MICERR 

MIC error detected in stb_ccm_secure()

SECURITY_00_LEVEL 

Security Level 0.

SECURITY_01_LEVEL 

Security Level 1.

SECURITY_02_LEVEL 

Security Level 2.

SECURITY_03_LEVEL 

Security Level 3.

SECURITY_04_LEVEL 

Security Level 4.

SECURITY_05_LEVEL 

Security Level 5.

SECURITY_06_LEVEL 

Security Level 6.

SECURITY_07_LEVEL 

Security Level 7.

DISCOVERY_REQUEST 
DISCOVERY_RESPONSE 
PAIR_REQUEST 
PAIR_RESPONSE 
UNPAIR_REQUEST 
KEY_SEED 
PING_REQUEST 
PING_RESPONSE 

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 plaintext 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 unsecure
Returns
STB CCM Status

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 ADATA, AES_BLOCKSIZE, AES_DIR_ENCRYPT, AES_KEYSIZE, AES_MODE_ECB, aMaxPHYPacketSize, compute_mic(), encrypt_pldmic(), ENCRYPTION_NOT_REQD, ENCRYPTION_REQD, key_change, last_key, LEN_FIELD, LEN_MIC_00, LEN_MIC_128, LEN_MIC_32, LEN_MIC_64, PLAINTEXT_FLAG, sal_aes_clean_up, sal_aes_restart(), sal_aes_setup(), SECURITY_00_LEVEL, SECURITY_01_LEVEL, SECURITY_02_LEVEL, SECURITY_03_LEVEL, SECURITY_04_LEVEL, SECURITY_05_LEVEL, SECURITY_06_LEVEL, SECURITY_07_LEVEL, STB_CCM_ILLPARM, STB_CCM_KEYMISS, STB_CCM_MICERR, STB_CCM_OK, 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().