cc2538: Add crypto driver and example for AES-GCM

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
This commit is contained in:
Benoît Thébaudeau 2016-01-02 04:20:16 +01:00
parent e77e9861fe
commit ccceb63e88
7 changed files with 939 additions and 5 deletions

View file

@ -53,8 +53,8 @@ CONTIKI_CPU_DIRS += ../cc253x/usb/common ../cc253x/usb/common/cdc-acm
### CPU-dependent source files
CONTIKI_CPU_SOURCEFILES += clock.c rtimer-arch.c uart.c watchdog.c
CONTIKI_CPU_SOURCEFILES += nvic.c cpu.c sys-ctrl.c gpio.c ioc.c spi.c adc.c
CONTIKI_CPU_SOURCEFILES += crypto.c aes.c ecb.c cbc.c ctr.c cbc-mac.c ccm.c
CONTIKI_CPU_SOURCEFILES += sha256.c
CONTIKI_CPU_SOURCEFILES += crypto.c aes.c ecb.c cbc.c ctr.c cbc-mac.c gcm.c
CONTIKI_CPU_SOURCEFILES += ccm.c sha256.c
CONTIKI_CPU_SOURCEFILES += cc2538-aes-128.c cc2538-ccm-star.c
CONTIKI_CPU_SOURCEFILES += cc2538-rf.c udma.c lpm.c
CONTIKI_CPU_SOURCEFILES += pka.c bignum-driver.c ecc-driver.c ecc-algorithm.c

125
cpu/cc2538/dev/gcm.c Normal file
View file

@ -0,0 +1,125 @@
/*
* Copyright (c) 2015, Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc2538-gcm
* @{
*
* \file
* Implementation of the cc2538 AES-GCM driver
*/
#include "contiki.h"
#include "dev/rom-util.h"
#include "dev/gcm.h"
#include <stdbool.h>
#include <stdint.h>
/*---------------------------------------------------------------------------*/
static uint8_t
gcm_auth_crypt_start(uint8_t encrypt, uint8_t key_area, const void *iv,
const void *adata, uint16_t adata_len,
const void *data_in, void *data_out, uint16_t data_len,
struct process *process)
{
uint32_t ctrl;
uint32_t aes_iv[AES_IV_LEN / sizeof(uint32_t)];
/* Program AES-GCM authentication/crypto operation */
ctrl = AES_AES_CTRL_SAVE_CONTEXT | /* Save context */
AES_AES_CTRL_GCM | /* GCM */
AES_AES_CTRL_CTR_WIDTH_32 | /* CTR width 32 */
AES_AES_CTRL_CTR | /* CTR */
(encrypt ? AES_AES_CTRL_DIRECTION_ENCRYPT : 0); /* En/decryption */
/* Prepare the crypto initialization vector
* Initialization vector */
rom_util_memcpy(aes_iv, iv, GCM_IV_LEN);
/* Initialize counter to 1 */
aes_iv[GCM_IV_LEN / sizeof(aes_iv[0])] = 0x01000000;
return aes_auth_crypt_start(ctrl, key_area, aes_iv, adata, adata_len,
data_in, data_out, data_len, process);
}
/*---------------------------------------------------------------------------*/
static uint8_t
gcm_auth_crypt_get_result(const void *tag_in, void *tag_out)
{
uint32_t tag[AES_TAG_LEN / sizeof(uint32_t)];
uint8_t ret;
ret = aes_auth_crypt_get_result(NULL, tag);
if(ret != CRYPTO_SUCCESS) {
return ret;
}
if(tag_in != NULL) {
/* Check tag */
if(rom_util_memcmp(tag, tag_in, GCM_TAG_LEN)) {
ret = AES_AUTHENTICATION_FAILED;
}
}
if(tag_out != NULL) {
/* Copy tag */
rom_util_memcpy(tag_out, tag, GCM_TAG_LEN);
}
return ret;
}
/*---------------------------------------------------------------------------*/
uint8_t
gcm_auth_encrypt_start(uint8_t key_area, const void *iv, const void *adata,
uint16_t adata_len, const void *pdata,
uint16_t pdata_len, void *cdata, struct process *process)
{
return gcm_auth_crypt_start(true, key_area, iv, adata, adata_len,
pdata, cdata, pdata_len, process);
}
/*---------------------------------------------------------------------------*/
uint8_t
gcm_auth_encrypt_get_result(void *tag)
{
return gcm_auth_crypt_get_result(NULL, tag);
}
/*---------------------------------------------------------------------------*/
uint8_t
gcm_auth_decrypt_start(uint8_t key_area, const void *iv, const void *adata,
uint16_t adata_len, const void *cdata,
uint16_t cdata_len, void *pdata, struct process *process)
{
return gcm_auth_crypt_start(false, key_area, iv, adata, adata_len,
cdata, pdata, cdata_len, process);
}
/*---------------------------------------------------------------------------*/
uint8_t
gcm_auth_decrypt_get_result(const void *tag_in, void *tag_out)
__attribute__ ((alias("gcm_auth_crypt_get_result")));
/** @} */

139
cpu/cc2538/dev/gcm.h Normal file
View file

@ -0,0 +1,139 @@
/*
* Copyright (c) 2015, Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc2538-aes
* @{
*
* \defgroup cc2538-gcm cc2538 AES-GCM
*
* Driver for the cc2538 AES-GCM mode of the security core
* @{
*
* \file
* Header file for the cc2538 AES-GCM driver
*/
#ifndef GCM_H_
#define GCM_H_
#include "contiki.h"
#include "dev/aes.h"
#include <stdbool.h>
#include <stdint.h>
/*---------------------------------------------------------------------------*/
/** \name AES-GCM constants
* @{
*/
#define GCM_IV_LEN (96 / 8)
#define GCM_TAG_LEN AES_TAG_LEN
/** @} */
/*---------------------------------------------------------------------------*/
/** \name AES-GCM functions
* @{
*/
/** \brief Starts a GCM authentication and encryption operation
* \param key_area Area in Key RAM where the key is stored (0 to
* \c AES_KEY_AREAS - 1)
* \param iv Pointer to 96-bit initialization vector
* \param adata Pointer to additional authenticated data in SRAM, or \c NULL
* \param adata_len Length of additional authenticated data in octets, or \c 0
* \param pdata Pointer to message to authenticate and encrypt in SRAM, or
* \c NULL
* \param pdata_len Length of message to authenticate and encrypt in octets, or
* \c 0
* \param cdata Pointer to encrypted message in SRAM (may be \p pdata), or
* \c NULL
* \param process Process to be polled upon completion of the operation, or
* \c NULL
* \return \c CRYPTO_SUCCESS if successful, or CRYPTO/AES/GCM error code
*/
uint8_t gcm_auth_encrypt_start(uint8_t key_area, const void *iv,
const void *adata, uint16_t adata_len,
const void *pdata, uint16_t pdata_len,
void *cdata, struct process *process);
/** \brief Checks the status of the GCM authentication and encryption operation
* \retval false Result not yet available, and no error occurred
* \retval true Result available, or error occurred
*/
#define gcm_auth_encrypt_check_status aes_auth_crypt_check_status
/** \brief Gets the result of the GCM authentication and encryption operation
* \param tag Pointer to 128-bit authentication tag, or \c NULL
* \return \c CRYPTO_SUCCESS if successful, or CRYPTO/AES/GCM error code
* \note This function must be called only after \c gcm_auth_encrypt_start().
*/
uint8_t gcm_auth_encrypt_get_result(void *tag);
/** \brief Starts a GCM authentication checking and decryption operation
* \param key_area Area in Key RAM where the key is stored (0 to
* \c AES_KEY_AREAS - 1)
* \param iv Pointer to 96-bit initialization vector
* \param adata Pointer to additional authenticated data in SRAM, or \c NULL
* \param adata_len Length of additional authenticated data in octets, or \c 0
* \param cdata Pointer to encrypted message in SRAM, or \c NULL
* \param cdata_len Length of encrypted message in octets, or \c 0
* \param pdata Pointer to decrypted message in SRAM (may be \p cdata), or
* \c NULL
* \param process Process to be polled upon completion of the operation, or
* \c NULL
* \return \c CRYPTO_SUCCESS if successful, or CRYPTO/AES/GCM error code
*/
uint8_t gcm_auth_decrypt_start(uint8_t key_area, const void *iv,
const void *adata, uint16_t adata_len,
const void *cdata, uint16_t cdata_len,
void *pdata, struct process *process);
/** \brief Checks the status of the GCM authentication checking and decryption
* operation
* \retval false Result not yet available, and no error occurred
* \retval true Result available, or error occurred
*/
#define gcm_auth_decrypt_check_status aes_auth_crypt_check_status
/** \brief Gets the result of the GCM authentication checking and decryption
* operation
* \param tag_in Pointer to 128-bit input authentication tag, or \c NULL
* \param tag_out Pointer to 128-bit output authentication tag, or \c NULL
* \return \c CRYPTO_SUCCESS if successful, or CRYPTO/AES/GCM error code
* \note This function must be called only after \c gcm_auth_decrypt_start().
*/
uint8_t gcm_auth_decrypt_get_result(const void *tag_in, void *tag_out);
/** @} */
#endif /* GCM_H_ */
/**
* @}
* @}
*/

View file

@ -1,4 +1,5 @@
CONTIKI_PROJECT = ecb-test cbc-test ctr-test cbc-mac-test ccm-test sha256-test
CONTIKI_PROJECT = ecb-test cbc-test ctr-test cbc-mac-test gcm-test ccm-test
CONTIKI_PROJECT += sha256-test
all: $(CONTIKI_PROJECT)

View file

@ -0,0 +1,669 @@
/*
* Copyright (c) 2015, Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc2538-examples
* @{
*
* \defgroup cc2538-gcm-test cc2538dk AES-GCM Test Project
*
* AES-GCM access example for CC2538 on SmartRF06EB.
*
* This example shows how AES-GCM should be used. The example also verifies
* the AES-GCM functionality.
*
* @{
*
* \file
* Example demonstrating AES-GCM on the cc2538dk platform
*/
#include "contiki.h"
#include "sys/rtimer.h"
#include "dev/rom-util.h"
#include "dev/gcm.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
/*---------------------------------------------------------------------------*/
#define ADATA_MAX_LEN 90
#define MDATA_MAX_LEN 51
/*---------------------------------------------------------------------------*/
PROCESS(gcm_test_process, "gcm test process");
AUTOSTART_PROCESSES(&gcm_test_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(gcm_test_process, ev, data)
{
static const char *const str_res[] = {
"success",
"invalid param",
"NULL error",
"resource in use",
"DMA bus error",
"keystore read error",
"keystore write error",
"authentication failed"
};
static const uint8_t keys128[][128 / 8] = {
{ 0x2f, 0xb4, 0x5e, 0x5b, 0x8f, 0x99, 0x3a, 0x2b,
0xfe, 0xbc, 0x4b, 0x15, 0xb5, 0x33, 0xe0, 0xb4 },
{ 0xc9, 0x39, 0xcc, 0x13, 0x39, 0x7c, 0x1d, 0x37,
0xde, 0x6a, 0xe0, 0xe1, 0xcb, 0x7c, 0x42, 0x3c },
{ 0xfe, 0x01, 0x21, 0xf4, 0x2e, 0x59, 0x9f, 0x88,
0xff, 0x02, 0xa9, 0x85, 0x40, 0x3e, 0x19, 0xbb },
{ 0x99, 0x71, 0x07, 0x10, 0x59, 0xab, 0xc0, 0x09,
0xe4, 0xf2, 0xbd, 0x69, 0x86, 0x9d, 0xb3, 0x38 },
{ 0x76, 0x2d, 0xa5, 0x8b, 0xb0, 0x00, 0xf5, 0xd4,
0x99, 0x81, 0x8b, 0xc8, 0x59, 0x98, 0x9a, 0x30 },
{ 0x30, 0x0b, 0x8f, 0xfa, 0xb4, 0x36, 0x8c, 0xc9,
0x0f, 0x6d, 0x40, 0x63, 0xe4, 0x27, 0x9f, 0x2a },
{ 0xef, 0x1d, 0xa9, 0xdd, 0x79, 0x42, 0x19, 0xeb,
0xf8, 0xf7, 0x17, 0xd5, 0xa9, 0x8a, 0xb0, 0xaf },
{ 0x93, 0xae, 0x11, 0x40, 0x52, 0xb7, 0x98, 0x5d,
0x40, 0x9a, 0x39, 0xa4, 0x0d, 0xf8, 0xc7, 0xee }
};
static const uint8_t keys192[][192 / 8] = {
{ 0x5d, 0xaa, 0x89, 0x10, 0xd9, 0xdc, 0x50, 0x68,
0xf2, 0xf5, 0x5c, 0x16, 0x39, 0x86, 0xd0, 0x71,
0x45, 0x23, 0x44, 0xa5, 0xea, 0xc5, 0xa8, 0x05 },
{ 0x1b, 0x8f, 0xef, 0x01, 0xcf, 0x6e, 0xfa, 0xbc,
0x2c, 0x7c, 0xff, 0x16, 0xff, 0x67, 0xa3, 0x30,
0x13, 0xf0, 0x62, 0x9a, 0x0a, 0xd9, 0x36, 0x95 },
{ 0x51, 0x9d, 0xdb, 0xcf, 0xb3, 0x41, 0x1c, 0x75,
0x39, 0xdf, 0x0b, 0x61, 0xff, 0x2b, 0x3e, 0x3d,
0x2b, 0x6a, 0xd8, 0xf0, 0x30, 0xcd, 0xdc, 0xc2 },
{ 0x9b, 0x37, 0xbf, 0x6b, 0x0a, 0xa8, 0xff, 0x75,
0xf3, 0x04, 0xed, 0xa7, 0xa9, 0x51, 0x2d, 0xba,
0x7c, 0x9f, 0x80, 0xd6, 0x1e, 0x29, 0x5e, 0x85 }
};
static const uint8_t keys256[][256 / 8] = {
{ 0xdc, 0x77, 0x6f, 0x01, 0x56, 0xc1, 0x5d, 0x03,
0x26, 0x23, 0x85, 0x4b, 0x62, 0x5c, 0x61, 0x86,
0x8e, 0x5d, 0xb8, 0x4b, 0x7b, 0x6f, 0x9f, 0xbd,
0x36, 0x72, 0xf1, 0x2f, 0x00, 0x25, 0xe0, 0xf6 },
{ 0x14, 0x85, 0x79, 0xa3, 0xcb, 0xca, 0x86, 0xd5,
0x52, 0x0d, 0x66, 0xc0, 0xec, 0x71, 0xca, 0x5f,
0x7e, 0x41, 0xba, 0x78, 0xe5, 0x6d, 0xc6, 0xee,
0xbd, 0x56, 0x6f, 0xed, 0x54, 0x7f, 0xe6, 0x91 },
{ 0x42, 0xf6, 0xc2, 0x51, 0x59, 0xb8, 0x65, 0x53,
0x80, 0xf0, 0x52, 0xdd, 0x5d, 0xad, 0x18, 0x0e,
0x76, 0x81, 0x3b, 0x60, 0xeb, 0x81, 0x36, 0x65,
0xc5, 0x01, 0x5f, 0x26, 0xcf, 0x32, 0xe8, 0xf1 },
{ 0x5f, 0x72, 0x04, 0x62, 0x45, 0xd3, 0xf4, 0xa0,
0x87, 0x7e, 0x50, 0xa8, 0x65, 0x54, 0xbf, 0xd5,
0x7d, 0x1c, 0x5e, 0x07, 0x3d, 0x1e, 0xd3, 0xb5,
0x45, 0x1f, 0x6d, 0x0f, 0xc2, 0xa8, 0x50, 0x7a }
};
static const struct {
const void *keys;
uint8_t key_size;
uint8_t count;
} keys[] = {
{ keys128, AES_KEY_STORE_SIZE_KEY_SIZE_128,
sizeof(keys128) / sizeof(keys128[0]) },
{ keys192, AES_KEY_STORE_SIZE_KEY_SIZE_192,
sizeof(keys192) / sizeof(keys192[0]) },
{ keys256, AES_KEY_STORE_SIZE_KEY_SIZE_256,
sizeof(keys256) / sizeof(keys256[0]) }
};
static const struct {
bool encrypt;
uint8_t key_size_index;
uint8_t key_area;
uint8_t iv[GCM_IV_LEN];
uint8_t adata[ADATA_MAX_LEN];
uint16_t adata_len;
uint8_t mdata[MDATA_MAX_LEN];
uint16_t mdata_len;
uint8_t tag[GCM_TAG_LEN];
uint8_t expected[MDATA_MAX_LEN];
} vectors[] = {
{
true, /* encrypt */
0, /* key_size_index */
0, /* key_area */
{ 0x5b, 0x05, 0x75, 0x5f, 0x98, 0x4d, 0x2b, 0x90,
0xf9, 0x4b, 0x80, 0x27 }, /* iv */
{ 0xe8, 0x54, 0x91, 0xb2, 0x20, 0x2c, 0xaf, 0x1d,
0x7d, 0xce, 0x03, 0xb9, 0x7e, 0x09, 0x33, 0x1c,
0x32, 0x47, 0x39, 0x41 }, /* adata */
20, /* adata_len */
{}, /* mdata */
0, /* mdata_len */
{ 0xc7, 0x5b, 0x78, 0x32, 0xb2, 0xa2, 0xd9, 0xbd,
0x82, 0x74, 0x12, 0xb6, 0xef, 0x57, 0x69, 0xdb }, /* tag */
{} /* expected */
}, {
true, /* encrypt */
0, /* key_size_index */
1, /* key_area */
{ 0xb3, 0xd8, 0xcc, 0x01, 0x7c, 0xbb, 0x89, 0xb3,
0x9e, 0x0f, 0x67, 0xe2 }, /* iv */
{ 0x24, 0x82, 0x56, 0x02, 0xbd, 0x12, 0xa9, 0x84,
0xe0, 0x09, 0x2d, 0x3e, 0x44, 0x8e, 0xda, 0x5f }, /* adata */
16, /* adata_len */
{ 0xc3, 0xb3, 0xc4, 0x1f, 0x11, 0x3a, 0x31, 0xb7,
0x3d, 0x9a, 0x5c, 0xd4, 0x32, 0x10, 0x30, 0x69 }, /* mdata */
16, /* mdata_len */
{ 0x00, 0x32, 0xa1, 0xdc, 0x85, 0xf1, 0xc9, 0x78,
0x69, 0x25, 0xa2, 0xe7, 0x1d, 0x82, 0x72, 0xdd }, /* tag */
{ 0x93, 0xfe, 0x7d, 0x9e, 0x9b, 0xfd, 0x10, 0x34,
0x8a, 0x56, 0x06, 0xe5, 0xca, 0xfa, 0x73, 0x54 } /* expected */
}, {
true, /* encrypt */
0, /* key_size_index */
2, /* key_area */
{ 0x3b, 0xb9, 0xeb, 0x77, 0x24, 0xcb, 0xe1, 0x94,
0x3d, 0x43, 0xde, 0x21 }, /* iv */
{ 0x26, 0x62, 0xd8, 0x95, 0x03, 0x5b, 0x65, 0x19,
0xf3, 0x51, 0x0e, 0xae, 0x0f, 0xaa, 0x39, 0x00,
0xad, 0x23, 0xcf, 0xdf }, /* adata */
20, /* adata_len */
{ 0xfd, 0x33, 0x1c, 0xa8, 0x64, 0x60, 0x91, 0xc2,
0x9f, 0x21, 0xe5, 0xf0, 0xa1 }, /* mdata */
13, /* mdata_len */
{ 0xd2, 0x4c, 0x3e, 0x9c, 0x1c, 0x73, 0xc0, 0xaf,
0x10, 0x97, 0xe2, 0x60, 0x61, 0xc8, 0x57, 0xde }, /* tag */
{ 0x59, 0xfe, 0x29, 0xb0, 0x7b, 0x0d, 0xe8, 0xd8,
0x69, 0xef, 0xbb, 0xd9, 0xb4 } /* expected */
}, {
true, /* encrypt */
0, /* key_size_index */
3, /* key_area */
{ 0x07, 0xa9, 0xa9, 0x5e, 0xa3, 0x82, 0x1e, 0x9c,
0x13, 0xc6, 0x32, 0x51 }, /* iv */
{}, /* adata */
0, /* adata_len */
{ 0xf5, 0x4b, 0xc3, 0x50, 0x1f, 0xed, 0x4f, 0x6f,
0x6d, 0xfb, 0x5e, 0xa8, 0x01, 0x06, 0xdf, 0x0b,
0xd8, 0x36, 0xe6, 0x82, 0x62, 0x25, 0xb7, 0x5c,
0x02, 0x22, 0xf6, 0xe8, 0x59, 0xb3, 0x59, 0x83 }, /* mdata */
32, /* mdata_len */
{ 0x78, 0x70, 0xd9, 0x11, 0x7f, 0x54, 0x81, 0x1a,
0x34, 0x69, 0x70, 0xf1, 0xde, 0x09, 0x0c, 0x41 }, /* tag */
{ 0x05, 0x56, 0xc1, 0x59, 0xf8, 0x4e, 0xf3, 0x6c,
0xb1, 0x60, 0x2b, 0x45, 0x26, 0xb1, 0x20, 0x09,
0xc7, 0x75, 0x61, 0x1b, 0xff, 0xb6, 0x4d, 0xc0,
0xd9, 0xca, 0x92, 0x97, 0xcd, 0x2c, 0x6a, 0x01 } /* expected */
}, {
false, /* encrypt */
0, /* key_size_index */
4, /* key_area */
{ 0x58, 0x4c, 0x29, 0x1f, 0xf1, 0xaa, 0x38, 0x8a,
0x51, 0x12, 0x52, 0x1e }, /* iv */
{ 0x91, 0xf9, 0x2e, 0x8b, 0xbd, 0xa7, 0xb5, 0xec,
0x96, 0x7a, 0xde, 0x76, 0x6f, 0x4f, 0x26, 0xe9,
0x18, 0x9e, 0xaa, 0xfa, 0xd4, 0x16, 0xf3, 0x7b,
0x48, 0x91, 0xd3, 0xe3, 0x7d, 0x70, 0xcb, 0x9a,
0x26, 0x7a, 0xa8, 0x43, 0xdd, 0x20, 0x28, 0x58,
0xad, 0xe0, 0x20, 0x26, 0x12, 0x23, 0xdf, 0xce }, /* adata */
48, /* adata_len */
{}, /* mdata */
0, /* mdata_len */
{ 0x9a, 0xc7, 0xeb, 0x2d, 0x76, 0x2f, 0xac, 0xae,
0x06, 0x08, 0x6c, 0x95, 0x79, 0x59, 0x88, 0x0e }, /* tag */
{} /* expected */
}, {
false, /* encrypt */
0, /* key_size_index */
5, /* key_area */
{ 0x8e, 0x69, 0xfa, 0x64, 0xe8, 0x71, 0xd0, 0xe9,
0x8a, 0x18, 0x3a, 0x49 }, /* iv */
{ 0x51, 0x66, 0x30, 0x9e, 0x15, 0x34, 0x47, 0xb2,
0x7c, 0x67, 0x05, 0x14, 0x53, 0xab, 0xf4, 0x41,
0xde, 0x3f, 0x4a, 0x7f, 0x6b, 0x63, 0x3e, 0xc6,
0x12, 0x2f, 0xf8, 0x2d, 0xc1, 0x32, 0xcf, 0xb4,
0x22, 0xd3, 0x6c, 0x5e, 0xc6, 0xe7, 0xcc, 0x90,
0xa9, 0xad, 0x55, 0xca, 0xa1, 0xcc, 0xdc, 0xb8,
0x2d, 0xc5, 0x02, 0x2a, 0x20, 0x06, 0x2a, 0x9c,
0x6e, 0x92, 0x38, 0xf3, 0x4d, 0x08, 0x5b, 0x1f,
0x55, 0x4b, 0x5e, 0xac, 0x05, 0xef, 0xf2, 0x5b,
0x5a, 0x5c, 0xb6, 0xe1, 0x8e, 0x78, 0x27, 0xd7,
0x01, 0x75, 0xdc, 0x06, 0x62, 0xd7, 0x70, 0x33,
0xd1, 0x18 }, /* adata */
90, /* adata_len */
{ 0x2d, 0x22, 0x92, 0xda, 0x61, 0xc2, 0x80, 0xaf,
0xf8, 0x67, 0x67, 0xd2, 0x5b, 0x75, 0xe8, 0x14 }, /* mdata */
16, /* mdata_len */
{ 0x63, 0x3e, 0xe6, 0x57, 0xa8, 0x98, 0x1a, 0x76,
0x82, 0xf8, 0x75, 0x05, 0x59, 0x4c, 0x95, 0xad }, /* tag */
{ 0x49, 0x53, 0xb5, 0x48, 0x59, 0x87, 0x06, 0x31,
0xe8, 0x18, 0xda, 0x71, 0xfc, 0x69, 0xc9, 0x81 } /* expected */
}, {
false, /* encrypt */
0, /* key_size_index */
6, /* key_area */
{ 0x3f, 0x39, 0x83, 0xdc, 0x63, 0x98, 0x6e, 0x33,
0xd1, 0xb6, 0xbf, 0xfc }, /* iv */
{ 0x5a, 0xbd, 0x0c, 0x1c, 0x52, 0xb6, 0x87, 0xe9,
0xa1, 0x67, 0x3b, 0x69, 0x13, 0x78, 0x95, 0xe5,
0x02, 0x5c, 0x2b, 0xd1, 0x8c, 0xbe, 0xac, 0xdb,
0x94, 0x72, 0xe9, 0x18, 0xfe, 0x15, 0x87, 0xda,
0x55, 0x8c, 0x49, 0x2c, 0xc7, 0x08, 0xd2, 0x70,
0xfd, 0x10, 0x57, 0x2e, 0xea, 0x83, 0xd2, 0xde }, /* adata */
48, /* adata_len */
{ 0x95, 0xea, 0x05, 0x70, 0x14, 0x81, 0xe9, 0x15,
0xc7, 0x24, 0x46, 0xc8, 0x76 }, /* mdata */
13, /* mdata_len */
{ 0x5c, 0x86, 0x69, 0x92, 0x66, 0x20, 0x05, 0xca,
0x88, 0x86, 0x81, 0x0e, 0x27, 0x8c, 0x8a, 0xb4 }, /* tag */
{ 0x55, 0x11, 0x87, 0x29, 0x05, 0x43, 0x6c, 0x7d,
0xe3, 0x8e, 0x95, 0x01, 0xe7 } /* expected */
}, {
false, /* encrypt */
0, /* key_size_index */
7, /* key_area */
{ 0x8a, 0xd7, 0x33, 0xa4, 0xa9, 0xb8, 0x33, 0x06,
0x90, 0x23, 0x8c, 0x42 }, /* iv */
{}, /* adata */
0, /* adata_len */
{ 0xbb, 0xb5, 0xb6, 0x72, 0xa4, 0x79, 0xaf, 0xca,
0x2b, 0x11, 0xad, 0xb0, 0xa4, 0xc7, 0x62, 0xb6,
0x98, 0xdd, 0x56, 0x59, 0x08, 0xfe, 0xe1, 0xd1,
0x01, 0xf6, 0xa0, 0x1d, 0x63, 0x33, 0x2c, 0x91,
0xb8, 0x5d, 0x7f, 0x03, 0xac, 0x48, 0xa4, 0x77,
0x89, 0x7d, 0x51, 0x2b, 0x45, 0x72, 0xf9, 0x04,
0x2c, 0xb7, 0xea }, /* mdata */
51, /* mdata_len */
{ 0x4d, 0x78, 0xbd, 0xcb, 0x13, 0x66, 0xfc, 0xba,
0x02, 0xfd, 0xcc, 0xee, 0x57, 0xe1, 0xff, 0x44 }, /* tag */
{ 0x3f, 0x3b, 0xb0, 0x64, 0x4e, 0xac, 0x87, 0x8b,
0x97, 0xd9, 0x90, 0xd2, 0x57, 0xf5, 0xb3, 0x6e,
0x17, 0x93, 0x49, 0x0d, 0xbc, 0x13, 0xfe, 0xa4,
0xef, 0xe9, 0x82, 0x2c, 0xeb, 0xba, 0x74, 0x44,
0xcc, 0xe4, 0xde, 0xe5, 0xa7, 0xf5, 0xdf, 0xdf,
0x28, 0x5f, 0x96, 0x78, 0x57, 0x92, 0x81, 0x22,
0x00, 0xc2, 0x79 } /* expected */
}, {
true, /* encrypt */
1, /* key_size_index */
0, /* key_area */
{ 0x8f, 0x88, 0xd7, 0x0e, 0x25, 0x0d, 0xbf, 0x12,
0x82, 0x41, 0x3f, 0xd7 }, /* iv */
{ 0x3b, 0x3b, 0xbb, 0x2c, 0xcd, 0x76, 0x23, 0x6f,
0x07, 0x4e, 0xec, 0xc1, 0x9f, 0x34, 0x10, 0x57 }, /* adata */
16, /* adata_len */
{ 0x42, 0x35, 0xe4, 0x2f, 0x32, 0xcf, 0xf4, 0x4a,
0x50, 0x7d, 0xd8, 0xa3, 0x66 }, /* mdata */
13, /* mdata_len */
{ 0x4c, 0xdd, 0xdb, 0x4a, 0x95, 0x46, 0xa8, 0xd7,
0x3a, 0xfc, 0x9f, 0x5e, 0x46, 0xa9, 0x26, 0xf3 }, /* tag */
{ 0xe9, 0x2d, 0xf9, 0xd2, 0xfd, 0x43, 0x6e, 0xd2,
0x54, 0xfa, 0x92, 0x78, 0x9c } /* expected */
}, {
true, /* encrypt */
1, /* key_size_index */
2, /* key_area */
{ 0xe9, 0x5e, 0xbb, 0x1e, 0x8d, 0x31, 0xd1, 0xac,
0x41, 0x4a, 0xd5, 0xf1 }, /* iv */
{ 0x9c, 0x1a, 0x35, 0x60, 0x40, 0xa1, 0x87, 0xb7,
0xd8, 0x5c, 0x7b, 0xbd, 0xc2, 0x3d, 0x3e, 0x9c,
0x63, 0x8f, 0x01, 0x4b, 0xd5, 0x62, 0x90, 0x88,
0x75, 0x7b, 0x57, 0x05, 0xb4, 0xf2, 0x78, 0x33,
0xb0, 0xa2, 0xb3, 0xfa, 0x4c, 0x9c, 0x43, 0xa7,
0x7c, 0x69, 0xa3, 0xa2, 0x0a, 0xff, 0xd2, 0xac,
0x4a, 0xa6, 0xfd, 0xf2, 0xe0, 0x7c, 0x0a, 0x8d,
0xaf, 0x1a, 0x19, 0xc4, 0x9a, 0x6a, 0x69, 0xfb,
0xf4, 0x25, 0x1b, 0x77, 0x98, 0x17, 0x31, 0x82,
0xa5, 0x28, 0xe6, 0xeb, 0x94, 0x19, 0x28, 0xaf,
0x99, 0x53, 0xbf, 0x59, 0x5b, 0xfb, 0x7b, 0xdf,
0x5c, 0x3a }, /* adata */
90, /* adata_len */
{ 0xc0, 0xc9, 0x22, 0x56, 0x03, 0x2e, 0xd3, 0x11,
0x3a, 0x79, 0x41, 0x0a, 0x8b, 0x0e, 0x25, 0x0e,
0x9a, 0x97, 0xfb, 0x47, 0x29, 0x8d, 0x12, 0x29,
0x32, 0xff, 0x94, 0xd8, 0xf9, 0x40, 0xbc, 0xf8 }, /* mdata */
32, /* mdata_len */
{ 0x6b, 0xce, 0x3a, 0xbe, 0xe7, 0xb7, 0xa6, 0x56,
0x3a, 0xb7, 0x9f, 0x68, 0xa4, 0x19, 0x72, 0xf4 }, /* tag */
{ 0x2c, 0x04, 0x3e, 0xc6, 0x9c, 0x25, 0x5c, 0x7e,
0xaf, 0x7b, 0xef, 0x47, 0x9b, 0x74, 0x67, 0x4f,
0xf2, 0x0c, 0x18, 0x5b, 0xcc, 0x6f, 0x94, 0x24,
0x22, 0xc7, 0xb5, 0xbe, 0x19, 0x99, 0x68, 0x37 } /* expected */
}, {
false, /* encrypt */
1, /* key_size_index */
4, /* key_area */
{ 0x78, 0xec, 0x38, 0x73, 0xbd, 0x88, 0x46, 0xac,
0x42, 0xff, 0x3a, 0x9b }, /* iv */
{ 0x7b, 0x4d, 0x41, 0x23, 0x02, 0xf3, 0x31, 0x96,
0x53, 0xcc, 0xed, 0x7d, 0xc6, 0xd7, 0xd8, 0x45,
0xcf, 0x10, 0x71, 0xd3, 0x80, 0x2c, 0xf0, 0x9b,
0xcd, 0x2b, 0xf3, 0x07, 0x76, 0x09, 0xa1, 0xda,
0xe1, 0xbf, 0x64, 0xe7, 0x88, 0x20, 0xf3, 0x68,
0x86, 0x2b, 0x2c, 0x0d, 0xaa, 0x17, 0xff, 0x9b,
0x33, 0xd1, 0xa7, 0xe4, 0xf6, 0x27, 0x50, 0x7c,
0x5a, 0x91, 0x6a, 0x80, 0x0e, 0x6d, 0x34, 0x9f,
0x72, 0xa4, 0x5f, 0x8f, 0x76, 0xb0, 0x1e, 0x63,
0xdf, 0xcb, 0x44, 0xf0, 0x0a, 0x22, 0x57, 0x41,
0xd1, 0x72, 0x37, 0x1e, 0xb9, 0x6f, 0x96, 0x49,
0x87, 0xeb }, /* adata */
90, /* adata_len */
{ 0xf1, 0xfb, 0x8d, 0xf2, 0x8f, 0x5a, 0x86, 0x49,
0xd9, 0x30, 0xb4, 0x77, 0xe6 }, /* mdata */
13, /* mdata_len */
{ 0xf7, 0x1b, 0x01, 0x98, 0xae, 0xe9, 0x70, 0xe0,
0xcb, 0x9f, 0x83, 0x5b, 0x4e, 0xe9, 0xf4, 0x33 }, /* tag */
{ 0x16, 0xea, 0xad, 0xec, 0x26, 0x20, 0x4a, 0x64,
0x4e, 0x2f, 0x24, 0xb1, 0xee } /* expected */
}, {
false, /* encrypt */
1, /* key_size_index */
6, /* key_area */
{ 0x2e, 0x8e, 0xf3, 0x3d, 0x26, 0x5d, 0x48, 0x19,
0xb6, 0x3c, 0xfd, 0xfc }, /* iv */
{ 0xf2, 0x16, 0xc7, 0xde, 0xf5, 0x5c, 0x8f, 0xf3,
0x25, 0x93, 0x35, 0x40, 0x96, 0x35, 0x62, 0xef,
0xe9, 0x6a, 0xe3, 0xf4, 0xb5, 0x4e, 0x6e, 0xc9,
0x5b, 0x25, 0x19, 0x42, 0x64, 0x67, 0x11, 0xd1,
0x7e, 0x4e, 0x39, 0xf2, 0x0f, 0xfb, 0x35, 0xd0,
0x33, 0x4c, 0x9c, 0x03, 0x83, 0x0d, 0x00, 0xc3 }, /* adata */
48, /* adata_len */
{ 0x66, 0xd3, 0xe6, 0x06, 0x6c, 0x51, 0xf3, 0x74,
0xc8, 0xde, 0xf9, 0x1d, 0xdd, 0xd7, 0x76, 0xeb,
0xc3, 0xbd, 0x9c, 0x96, 0x19, 0xeb, 0xc6, 0x81,
0x3c, 0x63, 0xd6, 0x9a, 0xac, 0x51, 0xb9, 0x77,
0x5a, 0x47, 0x19, 0x6e, 0x48, 0x83, 0xce, 0x5e,
0x32, 0x33, 0x2c, 0xe0, 0x09, 0xe0, 0x27, 0xec,
0x62, 0x2a, 0xe3 }, /* mdata */
51, /* mdata_len */
{ 0xcc, 0xef, 0x02, 0x7c, 0x0a, 0xe1, 0x90, 0x87,
0xe1, 0x8b, 0x13, 0xab, 0x5e, 0x1c, 0x89, 0xa6 }, /* tag */
{ 0x44, 0x8e, 0x59, 0xef, 0x95, 0x88, 0x67, 0xd6,
0x99, 0xfa, 0xf7, 0x4a, 0xa0, 0x46, 0x28, 0x1d,
0xb5, 0x1c, 0x44, 0xbd, 0x7a, 0xac, 0xb0, 0x52,
0x21, 0xcf, 0x3c, 0x7f, 0x1e, 0xfd, 0x47, 0x04,
0xf9, 0xb4, 0x79, 0x67, 0xb7, 0x05, 0x16, 0x8b,
0x5e, 0xd2, 0x52, 0x38, 0x64, 0x48, 0x29, 0xb7,
0x54, 0xdc, 0x75 } /* expected */
}, {
true, /* encrypt */
2, /* key_size_index */
0, /* key_area */
{ 0x67, 0x13, 0x09, 0x51, 0xc4, 0xa5, 0x7f, 0x6a,
0xe7, 0xf1, 0x32, 0x41 }, /* iv */
{ 0xfd, 0x09, 0x20, 0xfa, 0xeb, 0x7b, 0x21, 0x29,
0x32, 0x28, 0x0a, 0x00, 0x9b, 0xac, 0x96, 0x91,
0x45, 0xe5, 0xc3, 0x16, 0xcf, 0x39, 0x22, 0x62,
0x2c, 0x37, 0x05, 0xc3, 0x45, 0x7c, 0x4e, 0x9f,
0x12, 0x4b, 0x20, 0x76, 0x99, 0x43, 0x23, 0xfb,
0xcf, 0xb5, 0x23, 0xf8, 0xed, 0x16, 0xd2, 0x41 }, /* adata */
48, /* adata_len */
{ 0x93, 0x78, 0xa7, 0x27, 0xa5, 0x11, 0x95, 0x95,
0xad, 0x63, 0x1b, 0x12, 0xa5, 0xa6, 0xbc, 0x8a,
0x91, 0x75, 0x6e, 0xf0, 0x9c, 0x8d, 0x6e, 0xaa,
0x2b, 0x71, 0x8f, 0xe8, 0x68, 0x76, 0xda, 0x20 }, /* mdata */
32, /* mdata_len */
{ 0xb8, 0x76, 0x83, 0x1b, 0x4e, 0xcd, 0x72, 0x42,
0x96, 0x3b, 0x04, 0x0a, 0xa4, 0x5c, 0x41, 0x14 }, /* tag */
{ 0x6d, 0x95, 0x8c, 0x20, 0x87, 0x0d, 0x40, 0x1a,
0x3c, 0x1f, 0x7a, 0x0a, 0xc0, 0x92, 0xc9, 0x77,
0x74, 0xd4, 0x51, 0xc0, 0x9f, 0x7a, 0xae, 0x99,
0x2a, 0x88, 0x41, 0xff, 0x0a, 0xb9, 0xd6, 0x0d } /* expected */
}, {
true, /* encrypt */
2, /* key_size_index */
2, /* key_area */
{ 0xb0, 0x8a, 0x5e, 0xa1, 0x92, 0x74, 0x99, 0xc6,
0xec, 0xbf, 0xd4, 0xe0 }, /* iv */
{ 0xe4, 0xf9, 0x63, 0xf0, 0x15, 0xff, 0xbb, 0x99,
0xee, 0x33, 0x49, 0xbb, 0xaf, 0x7e, 0x8e, 0x8e,
0x6c, 0x2a, 0x71, 0xc2, 0x30, 0xa4, 0x8f, 0x9d,
0x59, 0x86, 0x0a, 0x29, 0x09, 0x1d, 0x27, 0x47,
0xe0, 0x1a, 0x5c, 0xa5, 0x72, 0x34, 0x7e, 0x24,
0x7d, 0x25, 0xf5, 0x6b, 0xa7, 0xae, 0x8e, 0x05,
0xcd, 0xe2, 0xbe, 0x3c, 0x97, 0x93, 0x12, 0x92,
0xc0, 0x23, 0x70, 0x20, 0x8e, 0xcd, 0x09, 0x7e,
0xf6, 0x92, 0x68, 0x7f, 0xec, 0xf2, 0xf4, 0x19,
0xd3, 0x20, 0x01, 0x62, 0xa6, 0x48, 0x0a, 0x57,
0xda, 0xd4, 0x08, 0xa0, 0xdf, 0xeb, 0x49, 0x2e,
0x2c, 0x5d }, /* adata */
90, /* adata_len */
{ 0x9d, 0x0b, 0x15, 0xfd, 0xf1, 0xbd, 0x59, 0x5f,
0x91, 0xf8, 0xb3, 0xab, 0xc0, 0xf7, 0xde, 0xc9,
0x27, 0xdf, 0xd4, 0x79, 0x99, 0x35, 0xa1, 0x79,
0x5d, 0x9c, 0xe0, 0x0c, 0x9b, 0x87, 0x94, 0x34,
0x42, 0x0f, 0xe4, 0x2c, 0x27, 0x5a, 0x7c, 0xd7,
0xb3, 0x9d, 0x63, 0x8f, 0xb8, 0x1c, 0xa5, 0x2b,
0x49, 0xdc, 0x41 }, /* mdata */
51, /* mdata_len */
{ 0xad, 0xbe, 0xcd, 0xb0, 0xd5, 0xc2, 0x22, 0x4d,
0x80, 0x4d, 0x28, 0x86, 0xff, 0x9a, 0x57, 0x60 }, /* tag */
{ 0x20, 0x97, 0xe3, 0x72, 0x95, 0x0a, 0x5e, 0x93,
0x83, 0xc6, 0x75, 0xe8, 0x9e, 0xea, 0x1c, 0x31,
0x4f, 0x99, 0x91, 0x59, 0xf5, 0x61, 0x13, 0x44,
0xb2, 0x98, 0xcd, 0xa4, 0x5e, 0x62, 0x84, 0x37,
0x16, 0xf2, 0x15, 0xf8, 0x2e, 0xe6, 0x63, 0x91,
0x9c, 0x64, 0x00, 0x2a, 0x5c, 0x19, 0x8d, 0x78,
0x78, 0xfd, 0x3f } /* expected */
}, {
false, /* encrypt */
2, /* key_size_index */
4, /* key_area */
{ 0x72, 0x48, 0xa5, 0xed, 0x48, 0xf4, 0xf1, 0xb4,
0xa9, 0xdb, 0x38, 0x26 }, /* iv */
{ 0x8e, 0x3c, 0x74, 0xf1, 0x27, 0xdb, 0xfe, 0x29,
0xac, 0x4d, 0xe0, 0xa7, 0xc3, 0x24, 0x0e, 0xe8,
0xaa, 0x8d, 0x38, 0xa8, 0x2f, 0x38, 0xad, 0x6b,
0x48, 0x02, 0x36, 0xc8, 0xcd, 0x42, 0x32, 0x05,
0x7a, 0x55, 0x02, 0xe9, 0x36, 0xbf, 0xe2, 0x22,
0x25, 0x83, 0x0f, 0xa1, 0x95, 0xa8, 0xaf, 0xce }, /* adata */
48, /* adata_len */
{ 0x26, 0x32, 0x5c, 0x34, 0x63, 0x81, 0x3a, 0x7d,
0x59, 0xd1, 0x84, 0xa3, 0x30, 0xef, 0x80, 0x95,
0x96, 0x37, 0xfa, 0x6d, 0xb4, 0xf5, 0xdb, 0x30,
0x62, 0xd3, 0xd2, 0xec, 0x7e, 0x32, 0xd8, 0x2a }, /* mdata */
32, /* mdata_len */
{ 0x4f, 0x39, 0xc6, 0x3d, 0x4f, 0x21, 0x5d, 0x5b,
0x39, 0xa5, 0x88, 0x53, 0xd3, 0x84, 0x21, 0x75 }, /* tag */
{ 0x9a, 0x32, 0x9c, 0xb4, 0x5b, 0x00, 0x93, 0xe9,
0xc0, 0x06, 0x15, 0x13, 0x7d, 0xd7, 0xdb, 0xd1,
0xf8, 0xb5, 0x25, 0x99, 0x9a, 0xf3, 0xbf, 0xc2,
0x22, 0x31, 0x5f, 0x41, 0x81, 0x77, 0x17, 0xa7 } /* expected */
}, {
false, /* encrypt */
2, /* key_size_index */
6, /* key_area */
{ 0xea, 0x6f, 0x5b, 0x39, 0x1e, 0x44, 0xb7, 0x51,
0xb2, 0x6b, 0xce, 0x6f }, /* iv */
{ 0x9b, 0x3a, 0x68, 0xc9, 0x41, 0xd4, 0x27, 0x44,
0x67, 0x3f, 0xb6, 0x0f, 0xea, 0x49, 0x07, 0x5e,
0xae, 0x77, 0x32, 0x2e, 0x7e, 0x70, 0xe3, 0x45,
0x02, 0xc1, 0x15, 0xb6, 0x49, 0x5e, 0xbf, 0xc7,
0x96, 0xd6, 0x29, 0x08, 0x07, 0x65, 0x3c, 0x6b,
0x53, 0xcd, 0x84, 0x28, 0x1b, 0xd0, 0x31, 0x16,
0x56, 0xd0, 0x01, 0x3f, 0x44, 0x61, 0x9d, 0x27,
0x48, 0x17, 0x7e, 0x99, 0xe8, 0xf8, 0x34, 0x7c,
0x98, 0x9a, 0x7b, 0x59, 0xf9, 0xd8, 0xdc, 0xf0,
0x0f, 0x31, 0xdb, 0x06, 0x84, 0xa4, 0xa8, 0x3e,
0x03, 0x7e, 0x87, 0x77, 0xba, 0xe5, 0x5f, 0x79,
0x9b, 0x0d }, /* adata */
90, /* adata_len */
{ 0x0e, 0x6e, 0x0b, 0x21, 0x14, 0xc4, 0x07, 0x69,
0xc1, 0x59, 0x58, 0xd9, 0x65, 0xa1, 0x4d, 0xcf,
0x50, 0xb6, 0x80, 0xe0, 0x18, 0x5a, 0x44, 0x09,
0xd7, 0x7d, 0x89, 0x4c, 0xa1, 0x5b, 0x1e, 0x69,
0x8d, 0xd8, 0x3b, 0x35, 0x36, 0xb1, 0x8c, 0x05,
0xd8, 0xcd, 0x08, 0x73, 0xd1, 0xed, 0xce, 0x81,
0x50, 0xec, 0xb5 }, /* mdata */
51, /* mdata_len */
{ 0xfd, 0xaa, 0xff, 0x86, 0xce, 0xb9, 0x37, 0x50,
0x2c, 0xd9, 0x01, 0x2d, 0x03, 0x58, 0x58, 0x00 }, /* tag */
{ 0xb0, 0xa8, 0x81, 0xb7, 0x51, 0xcc, 0x1e, 0xb0,
0xc9, 0x12, 0xa4, 0xcf, 0x9b, 0xd9, 0x71, 0x98,
0x37, 0x07, 0xdb, 0xd2, 0x41, 0x17, 0x25, 0x66,
0x45, 0x03, 0x45, 0x5c, 0x55, 0xdb, 0x25, 0xcd,
0xb1, 0x9b, 0xc6, 0x69, 0xc2, 0x65, 0x4a, 0x3a,
0x80, 0x11, 0xde, 0x6b, 0xf7, 0xef, 0xf3, 0xf9,
0xf0, 0x78, 0x34 } /* expected */
}
};
static uint8_t adata[ADATA_MAX_LEN];
static uint8_t mdata[MDATA_MAX_LEN];
static uint8_t tag[GCM_TAG_LEN];
static int i;
static uint8_t key_size_index = -1, ret;
static rtimer_clock_t time, time2, total_time;
PROCESS_BEGIN();
puts("-----------------------------------------\n"
"Initializing cryptoprocessor...");
crypto_init();
for(i = 0; i < sizeof(vectors) / sizeof(vectors[0]); i++) {
if(key_size_index != vectors[i].key_size_index) {
key_size_index = vectors[i].key_size_index;
printf("-----------------------------------------\n"
"Filling %d-bit key store...\n", 128 + (key_size_index << 6));
time = RTIMER_NOW();
ret = aes_load_keys(keys[key_size_index].keys,
keys[key_size_index].key_size, keys[key_size_index].count, 0);
time = RTIMER_NOW() - time;
printf("aes_load_keys(): %s, %lu us\n", str_res[ret],
(uint32_t)((uint64_t)time * 1000000 / RTIMER_SECOND));
PROCESS_PAUSE();
if(ret != CRYPTO_SUCCESS) {
break;
}
}
printf("-----------------------------------------\n"
"Test vector #%d: %s\n"
"key_area=%d adata_len=%d mdata_len=%d\n",
i, vectors[i].encrypt ? "encrypt" : "decrypt",
vectors[i].key_area, vectors[i].adata_len, vectors[i].mdata_len);
/* adata and mdata have to be in SRAM. */
rom_util_memcpy(adata, vectors[i].adata, vectors[i].adata_len);
rom_util_memcpy(mdata, vectors[i].mdata, vectors[i].mdata_len);
time = RTIMER_NOW();
if(vectors[i].encrypt) {
ret = gcm_auth_encrypt_start(vectors[i].key_area, vectors[i].iv, adata,
vectors[i].adata_len, mdata,
vectors[i].mdata_len, mdata,
&gcm_test_process);
time2 = RTIMER_NOW();
time = time2 - time;
total_time = time;
if(ret == CRYPTO_SUCCESS) {
PROCESS_WAIT_EVENT_UNTIL(gcm_auth_encrypt_check_status());
time2 = RTIMER_NOW() - time2;
total_time += time2;
}
printf("gcm_auth_encrypt_start(): %s, %lu us\n", str_res[ret],
(uint32_t)((uint64_t)time * 1000000 / RTIMER_SECOND));
if(ret != CRYPTO_SUCCESS) {
PROCESS_PAUSE();
continue;
}
printf("gcm_auth_encrypt_check_status() wait: %lu us\n",
(uint32_t)((uint64_t)time2 * 1000000 / RTIMER_SECOND));
time = RTIMER_NOW();
ret = gcm_auth_encrypt_get_result(tag);
time = RTIMER_NOW() - time;
total_time += time;
printf("gcm_auth_encrypt_get_result(): %s, %lu us\n", str_res[ret],
(uint32_t)((uint64_t)time * 1000000 / RTIMER_SECOND));
PROCESS_PAUSE();
if(ret != CRYPTO_SUCCESS) {
continue;
}
if(rom_util_memcmp(mdata, vectors[i].expected, vectors[i].mdata_len)) {
puts("Encrypted message does not match expected one");
} else {
puts("Encrypted message OK");
}
if(rom_util_memcmp(tag, vectors[i].tag, GCM_TAG_LEN)) {
puts("Tag does not match expected one");
} else {
puts("Tag OK");
}
} else {
ret = gcm_auth_decrypt_start(vectors[i].key_area, vectors[i].iv, adata,
vectors[i].adata_len, mdata,
vectors[i].mdata_len, mdata,
&gcm_test_process);
time2 = RTIMER_NOW();
time = time2 - time;
total_time = time;
if(ret == CRYPTO_SUCCESS) {
PROCESS_WAIT_EVENT_UNTIL(gcm_auth_decrypt_check_status());
time2 = RTIMER_NOW() - time2;
total_time += time2;
}
printf("gcm_auth_decrypt_start(): %s, %lu us\n", str_res[ret],
(uint32_t)((uint64_t)time * 1000000 / RTIMER_SECOND));
if(ret != CRYPTO_SUCCESS) {
PROCESS_PAUSE();
continue;
}
printf("gcm_auth_decrypt_check_status() wait: %lu us\n",
(uint32_t)((uint64_t)time2 * 1000000 / RTIMER_SECOND));
time = RTIMER_NOW();
ret = gcm_auth_decrypt_get_result(vectors[i].tag, tag);
time = RTIMER_NOW() - time;
total_time += time;
printf("gcm_auth_decrypt_get_result(): %s, %lu us\n", str_res[ret],
(uint32_t)((uint64_t)time * 1000000 / RTIMER_SECOND));
PROCESS_PAUSE();
if(ret != CRYPTO_SUCCESS) {
continue;
}
if(rom_util_memcmp(mdata, vectors[i].expected, vectors[i].mdata_len)) {
puts("Decrypted message does not match expected one");
} else {
puts("Decrypted message OK");
}
}
printf("Total duration: %lu us\n",
(uint32_t)((uint64_t)total_time * 1000000 / RTIMER_SECOND));
}
puts("-----------------------------------------\n"
"Disabling cryptoprocessor...");
crypto_disable();
puts("Done!");
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View file

@ -30,7 +30,7 @@ In terms of hardware support, the following drivers have been implemented:
* General-Purpose Timers. NB: GPT0 is in use by the platform code, the remaining GPTs are available for application development.
* ADC
* PWM
* Cryptoprocessor (AES-ECB/CBC/CTR/CBC-MAC/CCM-128/192/256, SHA-256)
* Cryptoprocessor (AES-ECB/CBC/CTR/CBC-MAC/GCM/CCM-128/192/256, SHA-256)
* Public Key Accelerator (ECDH, ECDSA)
* Flash-based port of Coffee
* SmartRF06 EB and BB peripherals

View file

@ -51,7 +51,7 @@ In terms of hardware support, the following drivers have been implemented for th
* Low Power Modes
* General-Purpose Timers. NB: GPT0 is in use by the platform code, the remaining GPTs are available for application development.
* ADC
* Cryptoprocessor (AES-ECB/CBC/CTR/CBC-MAC/CCM-128/192/256, SHA-256)
* Cryptoprocessor (AES-ECB/CBC/CTR/CBC-MAC/GCM/CCM-128/192/256, SHA-256)
* Public Key Accelerator (ECDH, ECDSA)
* Flash-based port of Coffee
* PWM