llsec: Added AEAD mode to CCM*
This commit is contained in:
parent
c656a4d1c5
commit
0a6b1cb646
7 changed files with 116 additions and 108 deletions
|
@ -72,11 +72,12 @@ test_sec_lvl_6()
|
|||
0x01 , 0xCE };
|
||||
uint8_t oracle[LLSEC802154_MIC_LENGTH] = { 0x4F , 0xDE , 0x52 , 0x90 ,
|
||||
0x61 , 0xF9 , 0xC6 , 0xF1 };
|
||||
uint8_t nonce[13];
|
||||
frame802154_frame_counter_t counter;
|
||||
uint8_t mic[LLSEC802154_MIC_LENGTH];
|
||||
|
||||
printf("Testing verification ... ");
|
||||
|
||||
linkaddr_copy(&linkaddr_node_addr, &source_address);
|
||||
packetbuf_clear();
|
||||
packetbuf_set_datalen(30);
|
||||
memcpy(packetbuf_hdrptr(), data, 30);
|
||||
|
@ -87,9 +88,14 @@ test_sec_lvl_6()
|
|||
packetbuf_hdrreduce(29);
|
||||
|
||||
CCM_STAR.set_key(key);
|
||||
ccm_star_packetbuf_mic(&source_address, mic, LLSEC802154_MIC_LENGTH);
|
||||
ccm_star_packetbuf_set_nonce(nonce, 1);
|
||||
CCM_STAR.aead(nonce,
|
||||
packetbuf_dataptr(), packetbuf_datalen(),
|
||||
packetbuf_hdrptr(), packetbuf_hdrlen(),
|
||||
((uint8_t *) packetbuf_hdrptr()) + 30, LLSEC802154_MIC_LENGTH,
|
||||
1);
|
||||
|
||||
if(memcmp(mic, oracle, LLSEC802154_MIC_LENGTH) == 0) {
|
||||
if(memcmp(((uint8_t *) packetbuf_hdrptr()) + 30, oracle, LLSEC802154_MIC_LENGTH) == 0) {
|
||||
printf("Success\n");
|
||||
} else {
|
||||
printf("Failure\n");
|
||||
|
@ -97,7 +103,6 @@ test_sec_lvl_6()
|
|||
|
||||
printf("Testing encryption ... ");
|
||||
|
||||
ccm_star_packetbuf_ctr(&source_address);
|
||||
if(((uint8_t *) packetbuf_hdrptr())[29] == 0xD8) {
|
||||
printf("Success\n");
|
||||
} else {
|
||||
|
@ -105,7 +110,13 @@ test_sec_lvl_6()
|
|||
}
|
||||
|
||||
printf("Testing decryption ... ");
|
||||
ccm_star_packetbuf_ctr(&source_address);
|
||||
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &source_address);
|
||||
ccm_star_packetbuf_set_nonce(nonce, 0);
|
||||
CCM_STAR.aead(nonce,
|
||||
packetbuf_dataptr(), packetbuf_datalen(),
|
||||
packetbuf_hdrptr(), packetbuf_hdrlen(),
|
||||
((uint8_t *) packetbuf_hdrptr()) + 30, LLSEC802154_MIC_LENGTH,
|
||||
0);
|
||||
if(((uint8_t *) packetbuf_hdrptr())[29] == 0xCE) {
|
||||
printf("Success\n");
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue