#include "contiki.h"
#include "net/ip/uip.h"
#include "aes-ccm.h"
#include "aes.h"
#include "dev/watchdog.h"
#include <stdio.h>
#include <string.h>
Macros | |
#define | aes_ccm_memcpy memcpy |
#define | BLOCK_SIZE 16 |
#define | CBCMAC_PRINTF(...) |
#define | CTR_MIC_PRINTF(...) |
#define | CTR_PRINTF(...) |
#define | L_SIZELEN 2 /* Size field length: 2 to 8 bytes */ |
#define | NONCE_LEN (15-L_SIZELEN) /* Nonce length: fixed to 13 bytes */ |
#define | PRINT_CBCMAC_BLOCKS 0 |
#define | PRINT_CTR_BLOCKS 0 |
#define | PRINT_CTR_MIC_BLOCKS 0 |
#define | PRINTF(...) |
Functions | |
long | aes_ccm_decrypt (const unsigned char *key, const unsigned char *nonce, const unsigned char *adata, unsigned long adata_len, const unsigned char *ciphermic, signed long ciphermic_len, int mic_len, unsigned char *outbuf) |
long | aes_ccm_encrypt (const unsigned char *key, const unsigned char *nonce, const unsigned char *adata, unsigned long adata_len, const unsigned char *payload, unsigned long payload_len, int mic_len, unsigned char *outbuf) |
void | aes_ccm_memcpy (const unsigned char *dest, const unsigned char *from, int len) |
int | aes_ccm_verify (const unsigned char *key, const unsigned char *nonce, const unsigned char *adata, unsigned long adata_len, const unsigned char *ciphermic, unsigned long ciphermic_len, int mic_len) |
static void | cbcmac_append (const unsigned char *key, unsigned char *block) |
static int | cbcmac_calc (const unsigned char *key, const unsigned char *nonce, const unsigned char *adata, unsigned long adata_len, const unsigned char *payload, unsigned long payload_len, int mic_len, unsigned char *outbuf) |
static void | cbcmac_clear (void) |
static int | cbcmac_verify (const unsigned char *key, const unsigned char *nonce, const unsigned char *adata, unsigned long adata_len, const unsigned char *cipher, unsigned long cipher_len, int mic_len, unsigned char *outbuf) |
static int | ctr_mic (const unsigned char *key, const unsigned char *nonce, const unsigned char *cbcmac, int mic_len, unsigned char *outbuf) |
static void | ctr_next_ctr_block (const unsigned char *key, const unsigned char *nonce, uint16_t counter, unsigned char *outbuf) |
static unsigned long | ctr_payload (const unsigned char *key, const unsigned char *nonce, const unsigned char *payload, unsigned long payload_len, unsigned char *outbuf) |
Variables | |
static unsigned char | cbcmac_xor [BLOCK_SIZE] |
#define aes_ccm_memcpy memcpy |
Referenced by ctr_payload().
#define BLOCK_SIZE 16 |
Referenced by cbcmac_append(), cbcmac_calc(), cbcmac_verify(), ctr_mic(), ctr_next_ctr_block(), and ctr_payload().
#define CBCMAC_PRINTF | ( | ... | ) |
Referenced by cbcmac_append(), cbcmac_calc(), and cbcmac_verify().
#define CTR_MIC_PRINTF | ( | ... | ) |
Referenced by ctr_mic().
#define CTR_PRINTF | ( | ... | ) |
Referenced by ctr_next_ctr_block(), and ctr_payload().
#define L_SIZELEN 2 /* Size field length: 2 to 8 bytes */ |
Referenced by cbcmac_calc(), cbcmac_verify(), ctr_mic(), and ctr_next_ctr_block().
#define NONCE_LEN (15-L_SIZELEN) /* Nonce length: fixed to 13 bytes */ |
Referenced by cbcmac_calc(), cbcmac_verify(), ctr_mic(), and ctr_next_ctr_block().
#define PRINT_CBCMAC_BLOCKS 0 |
#define PRINT_CTR_BLOCKS 0 |
#define PRINT_CTR_MIC_BLOCKS 0 |
#define PRINTF | ( | ... | ) |
Referenced by aes_ccm_decrypt(), aes_ccm_encrypt(), and aes_ccm_verify().
long aes_ccm_decrypt | ( | const unsigned char * | key, |
const unsigned char * | nonce, | ||
const unsigned char * | adata, | ||
unsigned long | adata_len, | ||
const unsigned char * | ciphermic, | ||
signed long | ciphermic_len, | ||
int | mic_len, | ||
unsigned char * | outbuf | ||
) |
References cbcmac_calc(), ctr_mic(), ctr_payload(), i, and PRINTF.
Referenced by netstack_aes_decrypt().
long aes_ccm_encrypt | ( | const unsigned char * | key, |
const unsigned char * | nonce, | ||
const unsigned char * | adata, | ||
unsigned long | adata_len, | ||
const unsigned char * | payload, | ||
unsigned long | payload_len, | ||
int | mic_len, | ||
unsigned char * | outbuf | ||
) |
References cbcmac_calc(), ctr_mic(), ctr_payload(), i, and PRINTF.
Referenced by netstack_aes_encrypt().
void aes_ccm_memcpy | ( | const unsigned char * | dest, |
const unsigned char * | from, | ||
int | len | ||
) |
int aes_ccm_verify | ( | const unsigned char * | key, |
const unsigned char * | nonce, | ||
const unsigned char * | adata, | ||
unsigned long | adata_len, | ||
const unsigned char * | ciphermic, | ||
unsigned long | ciphermic_len, | ||
int | mic_len | ||
) |
References cbcmac_verify(), ctr_mic(), i, and PRINTF.
Referenced by netstack_aes_verify().
|
static |
References aes_encrypt(), BLOCK_SIZE, CBCMAC_PRINTF, cbcmac_xor, and i.
Referenced by cbcmac_calc(), and cbcmac_verify().
|
static |
References BLOCK_SIZE, BUF, cbcmac_append(), cbcmac_clear(), CBCMAC_PRINTF, L_SIZELEN, len, NONCE_LEN, and UIP_HTONS.
Referenced by aes_ccm_decrypt(), and aes_ccm_encrypt().
|
static |
References cbcmac_xor.
Referenced by cbcmac_calc(), and cbcmac_verify().
|
static |
References BLOCK_SIZE, BUF, cbcmac_append(), cbcmac_clear(), CBCMAC_PRINTF, counter, ctr_next_ctr_block(), i, L_SIZELEN, len, NONCE_LEN, UIP_HTONS, and wdt_reset_count().
Referenced by aes_ccm_verify().
|
static |
References aes_encrypt(), BLOCK_SIZE, BUF, CTR_MIC_PRINTF, i, L_SIZELEN, NONCE_LEN, and UIP_HTONS.
Referenced by aes_ccm_decrypt(), aes_ccm_encrypt(), and aes_ccm_verify().
|
static |
References aes_encrypt(), BLOCK_SIZE, CTR_PRINTF, i, L_SIZELEN, NONCE_LEN, and UIP_HTONS.
Referenced by cbcmac_verify(), and ctr_payload().
|
static |
References aes_ccm_memcpy, BLOCK_SIZE, BUF, counter, ctr_next_ctr_block(), CTR_PRINTF, and i.
Referenced by aes_ccm_decrypt(), and aes_ccm_encrypt().
|
static |
Referenced by cbcmac_append(), and cbcmac_clear().