osd-contiki/examples/cc2538dk/crypto/cbc-test.c
Benoît Thébaudeau cf5e9557f8 cc2538: Add crypto driver and example for AES-CBC
Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
2016-01-06 22:01:41 +01:00

696 lines
32 KiB
C

/*
* 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-cbc-test cc2538dk AES-CBC Test Project
*
* AES-CBC access example for CC2538 on SmartRF06EB.
*
* This example shows how AES-CBC should be used. The example also verifies
* the AES-CBC functionality.
*
* @{
*
* \file
* Example demonstrating AES-CBC on the cc2538dk platform
*/
#include "contiki.h"
#include "sys/rtimer.h"
#include "dev/rom-util.h"
#include "dev/cbc.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
/*---------------------------------------------------------------------------*/
#define MDATA_MAX_LEN 160
/*---------------------------------------------------------------------------*/
PROCESS(cbc_test_process, "cbc test process");
AUTOSTART_PROCESSES(&cbc_test_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(cbc_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] = {
{ 0x1f, 0x8e, 0x49, 0x73, 0x95, 0x3f, 0x3f, 0xb0,
0xbd, 0x6b, 0x16, 0x66, 0x2e, 0x9a, 0x3c, 0x17 },
{ 0xb7, 0xf3, 0xc9, 0x57, 0x6e, 0x12, 0xdd, 0x0d,
0xb6, 0x3e, 0x8f, 0x8f, 0xac, 0x2b, 0x9a, 0x39 },
{ 0x89, 0xa5, 0x53, 0x73, 0x04, 0x33, 0xf7, 0xe6,
0xd6, 0x7d, 0x16, 0xd3, 0x73, 0xbd, 0x53, 0x60 },
{ 0x2c, 0x14, 0x41, 0x37, 0x51, 0xc3, 0x1e, 0x27,
0x30, 0x57, 0x0b, 0xa3, 0x36, 0x1c, 0x78, 0x6b },
{ 0x6a, 0x70, 0x82, 0xcf, 0x8c, 0xda, 0x13, 0xef,
0xf4, 0x8c, 0x81, 0x58, 0xdd, 0xa2, 0x06, 0xae },
{ 0x7b, 0x1a, 0xb9, 0x14, 0x4b, 0x02, 0x39, 0x31,
0x5c, 0xd5, 0xee, 0xc6, 0xc7, 0x56, 0x63, 0xbd },
{ 0xba, 0xb0, 0xcc, 0xed, 0xdc, 0x0a, 0xbd, 0x63,
0xe3, 0xf8, 0x2e, 0x9f, 0xbf, 0xf7, 0xb8, 0xaa },
{ 0x97, 0xa1, 0x02, 0x55, 0x29, 0xb9, 0x92, 0x5e,
0x25, 0xbb, 0xe7, 0x87, 0x70, 0xca, 0x2f, 0x99 }
};
static const uint8_t keys192[][192 / 8] = {
{ 0xba, 0x75, 0xf4, 0xd1, 0xd9, 0xd7, 0xcf, 0x7f,
0x55, 0x14, 0x45, 0xd5, 0x6c, 0xc1, 0xa8, 0xab,
0x2a, 0x07, 0x8e, 0x15, 0xe0, 0x49, 0xdc, 0x2c },
{ 0x16, 0x2a, 0xd5, 0x0e, 0xe6, 0x4a, 0x07, 0x02,
0xaa, 0x55, 0x1f, 0x57, 0x1d, 0xed, 0xc1, 0x6b,
0x2c, 0x1b, 0x6a, 0x1e, 0x4d, 0x4b, 0x5e, 0xee },
{ 0x8e, 0x27, 0x40, 0xfb, 0xa1, 0x57, 0xae, 0xf2,
0x42, 0x2e, 0x44, 0x23, 0x12, 0xd1, 0x5c, 0x14,
0xd3, 0x12, 0x55, 0x36, 0x84, 0xfc, 0xdc, 0x15 },
{ 0x50, 0x9b, 0xaf, 0x46, 0xfb, 0x9d, 0xe3, 0x42,
0x81, 0xda, 0xfc, 0xc3, 0xdb, 0x79, 0x59, 0x3b,
0xff, 0xa8, 0x42, 0x69, 0x04, 0x30, 0x26, 0x88 }
};
static const uint8_t keys256[][256 / 8] = {
{ 0x6e, 0xd7, 0x6d, 0x2d, 0x97, 0xc6, 0x9f, 0xd1,
0x33, 0x95, 0x89, 0x52, 0x39, 0x31, 0xf2, 0xa6,
0xcf, 0xf5, 0x54, 0xb1, 0x5f, 0x73, 0x8f, 0x21,
0xec, 0x72, 0xdd, 0x97, 0xa7, 0x33, 0x09, 0x07 },
{ 0x48, 0xbe, 0x59, 0x7e, 0x63, 0x2c, 0x16, 0x77,
0x23, 0x24, 0xc8, 0xd3, 0xfa, 0x1d, 0x9c, 0x5a,
0x9e, 0xcd, 0x01, 0x0f, 0x14, 0xec, 0x5d, 0x11,
0x0d, 0x3b, 0xfe, 0xc3, 0x76, 0xc5, 0x53, 0x2b },
{ 0x43, 0xe9, 0x53, 0xb2, 0xae, 0xa0, 0x8a, 0x3a,
0xd5, 0x2d, 0x18, 0x2f, 0x58, 0xc7, 0x2b, 0x9c,
0x60, 0xfb, 0xe4, 0xa9, 0xca, 0x46, 0xa3, 0xcb,
0x89, 0xe3, 0x86, 0x38, 0x45, 0xe2, 0x2c, 0x9e },
{ 0x87, 0x72, 0x5b, 0xd4, 0x3a, 0x45, 0x60, 0x88,
0x14, 0x18, 0x07, 0x73, 0xf0, 0xe7, 0xab, 0x95,
0xa3, 0xc8, 0x59, 0xd8, 0x3a, 0x21, 0x30, 0xe8,
0x84, 0x19, 0x0e, 0x44, 0xd1, 0x4c, 0x69, 0x96 }
};
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[CBC_IV_LEN];
uint8_t mdata[MDATA_MAX_LEN];
uint16_t mdata_len;
uint8_t expected[MDATA_MAX_LEN];
} vectors[] = {
{
true, /* encrypt */
0, /* key_size_index */
0, /* key_area */
{ 0x2f, 0xe2, 0xb3, 0x33, 0xce, 0xda, 0x8f, 0x98,
0xf4, 0xa9, 0x9b, 0x40, 0xd2, 0xcd, 0x34, 0xa8 }, /* iv */
{ 0x45, 0xcf, 0x12, 0x96, 0x4f, 0xc8, 0x24, 0xab,
0x76, 0x61, 0x6a, 0xe2, 0xf4, 0xbf, 0x08, 0x22 }, /* mdata */
16, /* mdata_len */
{ 0x0f, 0x61, 0xc4, 0xd4, 0x4c, 0x51, 0x47, 0xc0,
0x3c, 0x19, 0x5a, 0xd7, 0xe2, 0xcc, 0x12, 0xb2 } /* expected */
}, {
true, /* encrypt */
0, /* key_size_index */
1, /* key_area */
{ 0xc8, 0x0f, 0x09, 0x5d, 0x8b, 0xb1, 0xa0, 0x60,
0x69, 0x9f, 0x7c, 0x19, 0x97, 0x4a, 0x1a, 0xa0 }, /* iv */
{ 0x9a, 0xc1, 0x99, 0x54, 0xce, 0x13, 0x19, 0xb3,
0x54, 0xd3, 0x22, 0x04, 0x60, 0xf7, 0x1c, 0x1e,
0x37, 0x3f, 0x1c, 0xd3, 0x36, 0x24, 0x08, 0x81,
0x16, 0x0c, 0xfd, 0xe4, 0x6e, 0xbf, 0xed, 0x2e,
0x79, 0x1e, 0x8d, 0x5a, 0x1a, 0x13, 0x6e, 0xbd,
0x1d, 0xc4, 0x69, 0xde, 0xc0, 0x0c, 0x41, 0x87,
0x72, 0x2b, 0x84, 0x1c, 0xda, 0xbc, 0xb2, 0x2c,
0x1b, 0xe8, 0xa1, 0x46, 0x57, 0xda, 0x20, 0x0e }, /* mdata */
64, /* mdata_len */
{ 0x19, 0xb9, 0x60, 0x97, 0x72, 0xc6, 0x3f, 0x33,
0x86, 0x08, 0xbf, 0x6e, 0xb5, 0x2c, 0xa1, 0x0b,
0xe6, 0x50, 0x97, 0xf8, 0x9c, 0x1e, 0x09, 0x05,
0xc4, 0x24, 0x01, 0xfd, 0x47, 0x79, 0x1a, 0xe2,
0xc5, 0x44, 0x0b, 0x2d, 0x47, 0x31, 0x16, 0xca,
0x78, 0xbd, 0x9f, 0xf2, 0xfb, 0x60, 0x15, 0xcf,
0xd3, 0x16, 0x52, 0x4e, 0xae, 0x7d, 0xcb, 0x95,
0xae, 0x73, 0x8e, 0xbe, 0xae, 0x84, 0xa4, 0x67 } /* expected */
}, {
true, /* encrypt */
0, /* key_size_index */
2, /* key_area */
{ 0xf7, 0x24, 0x55, 0x8d, 0xb3, 0x43, 0x3a, 0x52,
0x3f, 0x4e, 0x51, 0xa5, 0xbe, 0xa7, 0x04, 0x97 }, /* iv */
{ 0x80, 0x7b, 0xc4, 0xea, 0x68, 0x4e, 0xed, 0xcf,
0xdc, 0xca, 0x30, 0x18, 0x06, 0x80, 0xb0, 0xf1,
0xae, 0x28, 0x14, 0xf3, 0x5f, 0x36, 0xd0, 0x53,
0xc5, 0xae, 0xa6, 0x59, 0x5a, 0x38, 0x6c, 0x14,
0x42, 0x77, 0x0f, 0x4d, 0x72, 0x97, 0xd8, 0xb9,
0x18, 0x25, 0xee, 0x72, 0x37, 0x24, 0x1d, 0xa8,
0x92, 0x5d, 0xd5, 0x94, 0xcc, 0xf6, 0x76, 0xae,
0xcd, 0x46, 0xca, 0x20, 0x68, 0xe8, 0xd3, 0x7a,
0x3a, 0x0e, 0xc8, 0xa7, 0xd5, 0x18, 0x5a, 0x20,
0x1e, 0x66, 0x3b, 0x5f, 0xf3, 0x6a, 0xe1, 0x97,
0x11, 0x01, 0x88, 0xa2, 0x35, 0x03, 0x76, 0x3b,
0x82, 0x18, 0x82, 0x6d, 0x23, 0xce, 0xd7, 0x4b,
0x31, 0xe9, 0xf6, 0xe2, 0xd7, 0xfb, 0xfa, 0x6c,
0xb4, 0x34, 0x20, 0xc7, 0x80, 0x7a, 0x86, 0x25 }, /* mdata */
112, /* mdata_len */
{ 0x40, 0x6a, 0xf1, 0x42, 0x9a, 0x47, 0x8c, 0x3d,
0x07, 0xe5, 0x55, 0xc5, 0x28, 0x7a, 0x60, 0x50,
0x0d, 0x37, 0xfc, 0x39, 0xb6, 0x8e, 0x5b, 0xbb,
0x9b, 0xaf, 0xd6, 0xdd, 0xb2, 0x23, 0x82, 0x85,
0x61, 0xd6, 0x17, 0x1a, 0x30, 0x8d, 0x5b, 0x1a,
0x45, 0x51, 0xe8, 0xa5, 0xe7, 0xd5, 0x72, 0x91,
0x8d, 0x25, 0xc9, 0x68, 0xd3, 0x87, 0x18, 0x48,
0xd2, 0xf1, 0x66, 0x35, 0xca, 0xa9, 0x84, 0x7f,
0x38, 0x59, 0x0b, 0x1d, 0xf5, 0x8a, 0xb5, 0xef,
0xb9, 0x85, 0xf2, 0xc6, 0x6c, 0xfa, 0xf8, 0x6f,
0x61, 0xb3, 0xf9, 0xc0, 0xaf, 0xad, 0x6c, 0x96,
0x3c, 0x49, 0xce, 0xe9, 0xb8, 0xbc, 0x81, 0xa2,
0xdd, 0xb0, 0x6c, 0x96, 0x7f, 0x32, 0x55, 0x15,
0xa4, 0x84, 0x9e, 0xec, 0x37, 0xce, 0x72, 0x1a } /* expected */
}, {
true, /* encrypt */
0, /* key_size_index */
3, /* key_area */
{ 0x1d, 0xbb, 0xeb, 0x2f, 0x19, 0xab, 0xb4, 0x48,
0xaf, 0x84, 0x97, 0x96, 0x24, 0x4a, 0x19, 0xd7 }, /* iv */
{ 0x40, 0xd9, 0x30, 0xf9, 0xa0, 0x53, 0x34, 0xd9,
0x81, 0x6f, 0xe2, 0x04, 0x99, 0x9c, 0x3f, 0x82,
0xa0, 0x3f, 0x6a, 0x04, 0x57, 0xa8, 0xc4, 0x75,
0xc9, 0x45, 0x53, 0xd1, 0xd1, 0x16, 0x69, 0x3a,
0xdc, 0x61, 0x80, 0x49, 0xf0, 0xa7, 0x69, 0xa2,
0xee, 0xd6, 0xa6, 0xcb, 0x14, 0xc0, 0x14, 0x3e,
0xc5, 0xcc, 0xcd, 0xbc, 0x8d, 0xec, 0x4c, 0xe5,
0x60, 0xcf, 0xd2, 0x06, 0x22, 0x57, 0x09, 0x32,
0x6d, 0x4d, 0xe7, 0x94, 0x8e, 0x54, 0xd6, 0x03,
0xd0, 0x1b, 0x12, 0xd7, 0xfe, 0xd7, 0x52, 0xfb,
0x23, 0xf1, 0xaa, 0x44, 0x94, 0xfb, 0xb0, 0x01,
0x30, 0xe9, 0xde, 0xd4, 0xe7, 0x7e, 0x37, 0xc0,
0x79, 0x04, 0x2d, 0x82, 0x80, 0x40, 0xc3, 0x25,
0xb1, 0xa5, 0xef, 0xd1, 0x5f, 0xc8, 0x42, 0xe4,
0x40, 0x14, 0xca, 0x43, 0x74, 0xbf, 0x38, 0xf3,
0xc3, 0xfc, 0x3e, 0xe3, 0x27, 0x73, 0x3b, 0x0c,
0x8a, 0xee, 0x1a, 0xbc, 0xd0, 0x55, 0x77, 0x2f,
0x18, 0xdc, 0x04, 0x60, 0x3f, 0x7b, 0x2c, 0x1e,
0xa6, 0x9f, 0xf6, 0x62, 0x36, 0x1f, 0x2b, 0xe0,
0xa1, 0x71, 0xbb, 0xdc, 0xea, 0x1e, 0x5d, 0x3f }, /* mdata */
160, /* mdata_len */
{ 0x6b, 0xe8, 0xa1, 0x28, 0x00, 0x45, 0x5a, 0x32,
0x05, 0x38, 0x85, 0x3e, 0x0c, 0xba, 0x31, 0xbd,
0x2d, 0x80, 0xea, 0x0c, 0x85, 0x16, 0x4a, 0x4c,
0x5c, 0x26, 0x1a, 0xe4, 0x85, 0x41, 0x7d, 0x93,
0xef, 0xfe, 0x2e, 0xbc, 0x0d, 0x0a, 0x0b, 0x51,
0xd6, 0xea, 0x18, 0x63, 0x3d, 0x21, 0x0c, 0xf6,
0x3c, 0x0c, 0x4d, 0xdb, 0xc2, 0x76, 0x07, 0xf2,
0xe8, 0x1e, 0xd9, 0x11, 0x31, 0x91, 0xef, 0x86,
0xd5, 0x6f, 0x3b, 0x99, 0xbe, 0x6c, 0x41, 0x5a,
0x41, 0x50, 0x29, 0x9f, 0xb8, 0x46, 0xce, 0x71,
0x60, 0xb4, 0x0b, 0x63, 0xba, 0xf1, 0x17, 0x9d,
0x19, 0x27, 0x5a, 0x2e, 0x83, 0x69, 0x83, 0x76,
0xd2, 0x8b, 0x92, 0x54, 0x8c, 0x68, 0xe0, 0x6e,
0x6d, 0x99, 0x4e, 0x2c, 0x15, 0x01, 0xed, 0x29,
0x70, 0x14, 0xe7, 0x02, 0xcd, 0xef, 0xee, 0x2f,
0x65, 0x64, 0x47, 0x70, 0x60, 0x09, 0x61, 0x4d,
0x80, 0x1d, 0xe1, 0xca, 0xaf, 0x73, 0xf8, 0xb7,
0xfa, 0x56, 0xcf, 0x1b, 0xa9, 0x4b, 0x63, 0x19,
0x33, 0xbb, 0xe5, 0x77, 0x62, 0x43, 0x80, 0x85,
0x0f, 0x11, 0x74, 0x35, 0xa0, 0x35, 0x5b, 0x2b } /* expected */
}, {
false, /* encrypt */
0, /* key_size_index */
4, /* key_area */
{ 0xbd, 0x41, 0x72, 0x93, 0x40, 0x78, 0xc2, 0x01,
0x1c, 0xb1, 0xf3, 0x1c, 0xff, 0xaf, 0x48, 0x6e }, /* iv */
{ 0xf8, 0xeb, 0x31, 0xb3, 0x1e, 0x37, 0x4e, 0x96,
0x00, 0x30, 0xcd, 0x1c, 0xad, 0xb0, 0xef, 0x0c }, /* mdata */
16, /* mdata_len */
{ 0x94, 0x0b, 0xc7, 0x6d, 0x61, 0xe2, 0xc4, 0x9d,
0xdd, 0xd5, 0xdf, 0x7f, 0x37, 0xfc, 0xf1, 0x05 } /* expected */
}, {
false, /* encrypt */
0, /* key_size_index */
5, /* key_area */
{ 0x0b, 0x1e, 0x74, 0xf4, 0x5c, 0x17, 0xff, 0x30,
0x4d, 0x99, 0xc0, 0x59, 0xce, 0x5c, 0xde, 0x09 }, /* iv */
{ 0xd3, 0xf8, 0x9b, 0x71, 0xe0, 0x33, 0x07, 0x0f,
0x9d, 0x75, 0x16, 0xa6, 0xcb, 0x4e, 0xa5, 0xef,
0x51, 0xd6, 0xfb, 0x63, 0xd4, 0xf0, 0xfe, 0xa0,
0x89, 0xd0, 0xa6, 0x0e, 0x47, 0xbb, 0xb3, 0xc2,
0xe1, 0x0e, 0x9b, 0xa3, 0xb2, 0x82, 0xc7, 0xcb,
0x79, 0xae, 0xfe, 0x30, 0x68, 0xce, 0x22, 0x83,
0x77, 0xc2, 0x1a, 0x58, 0xfe, 0x5a, 0x0f, 0x88,
0x83, 0xd0, 0xdb, 0xd3, 0xd0, 0x96, 0xbe, 0xca }, /* mdata */
64, /* mdata_len */
{ 0xb9, 0x68, 0xae, 0xb1, 0x99, 0xad, 0x6b, 0x3c,
0x8e, 0x01, 0xf2, 0x6c, 0x2e, 0xda, 0xd4, 0x44,
0x53, 0x8c, 0x78, 0xbf, 0xa3, 0x6e, 0xd6, 0x8c,
0xa7, 0x61, 0x23, 0xb8, 0xcd, 0xce, 0x61, 0x5a,
0x01, 0xf6, 0x11, 0x2b, 0xb8, 0x0b, 0xfc, 0x3f,
0x17, 0x49, 0x05, 0x78, 0xfb, 0x1f, 0x90, 0x9a,
0x52, 0xe1, 0x62, 0x63, 0x7b, 0x06, 0x2d, 0xb0,
0x4e, 0xfe, 0xe2, 0x91, 0xa1, 0xf1, 0xaf, 0x60 } /* expected */
}, {
false, /* encrypt */
0, /* key_size_index */
6, /* key_area */
{ 0x68, 0xb9, 0x14, 0x0f, 0x30, 0x04, 0x90, 0xc5,
0xc9, 0x42, 0xf6, 0x6e, 0x77, 0x7e, 0xb8, 0x06 }, /* iv */
{ 0xc6, 0x5b, 0x94, 0xb1, 0xf2, 0x91, 0xfa, 0x9f,
0x06, 0x00, 0xf2, 0x2c, 0x3c, 0x04, 0x32, 0xc8,
0x95, 0xad, 0x5d, 0x17, 0x7b, 0xcc, 0xcc, 0x9e,
0xa4, 0x4e, 0x8e, 0xc3, 0x39, 0xc9, 0xad, 0xf4,
0x38, 0x55, 0xb3, 0x26, 0x17, 0x9d, 0x6d, 0x81,
0xaa, 0x36, 0xef, 0x59, 0x46, 0x2f, 0xd8, 0x61,
0x27, 0xe9, 0xd8, 0x1b, 0x0f, 0x28, 0x6f, 0x93,
0x30, 0x6b, 0xf7, 0x4d, 0x4c, 0x79, 0xe4, 0x7c,
0x1b, 0x3d, 0x4b, 0x74, 0xed, 0xd3, 0xa1, 0x62,
0x90, 0xe3, 0xc6, 0x3b, 0x74, 0x2e, 0x41, 0xf2,
0x0d, 0x66, 0xce, 0xee, 0x79, 0x43, 0x16, 0xbb,
0x63, 0xd3, 0xbd, 0x00, 0x27, 0x12, 0xa1, 0xb1,
0x36, 0xba, 0x61, 0x85, 0xbd, 0x5c, 0x1d, 0xab,
0x81, 0xb0, 0x7d, 0xb9, 0x0d, 0x2a, 0xf5, 0xe5 }, /* mdata */
112, /* mdata_len */
{ 0xc5, 0x58, 0x5f, 0xf2, 0x15, 0xbb, 0xb7, 0x3b,
0xa5, 0x39, 0x34, 0x40, 0x85, 0x2f, 0xb1, 0x99,
0x43, 0x6d, 0xe0, 0xd1, 0x5e, 0x55, 0xc6, 0x31,
0xf8, 0x77, 0x67, 0x0a, 0xa3, 0xed, 0xa9, 0xf6,
0x72, 0xeb, 0x1f, 0x87, 0x6f, 0x09, 0x54, 0x4e,
0x63, 0x55, 0x84, 0x36, 0xb8, 0x92, 0x80, 0x00,
0xdb, 0x2f, 0x02, 0xa5, 0xad, 0x90, 0xf9, 0x5b,
0x05, 0xac, 0x4c, 0xf4, 0x9e, 0x19, 0x8e, 0x61,
0x7e, 0x76, 0x78, 0x48, 0x0f, 0xdf, 0x0e, 0xfa,
0xcc, 0x6a, 0xae, 0x69, 0x12, 0x71, 0xe6, 0xcd,
0xd3, 0x54, 0x1e, 0xbf, 0x71, 0x9a, 0x1c, 0xca,
0xed, 0xb2, 0x4e, 0x2f, 0x80, 0xf9, 0x24, 0x55,
0xdd, 0x59, 0x10, 0xcb, 0x50, 0x86, 0xb0, 0x96,
0x0a, 0x39, 0x42, 0xec, 0x18, 0x2d, 0xcb, 0xd7 } /* expected */
}, {
false, /* encrypt */
0, /* key_size_index */
7, /* key_area */
{ 0xd4, 0xb4, 0xea, 0xb9, 0x2a, 0xa9, 0x63, 0x7e,
0x87, 0xd3, 0x66, 0x38, 0x4e, 0xd6, 0x91, 0x5c }, /* iv */
{ 0x22, 0xcd, 0xc3, 0x30, 0x6f, 0xcd, 0x4d, 0x31,
0xcc, 0xd3, 0x27, 0x20, 0xcb, 0xb6, 0x1b, 0xad,
0x28, 0xd8, 0x55, 0x67, 0x06, 0x57, 0xc4, 0x8c,
0x7b, 0x88, 0xc3, 0x1f, 0x4f, 0xa1, 0xf9, 0x3c,
0x01, 0xb5, 0x7d, 0xa9, 0x0b, 0xe6, 0x3e, 0xad,
0x67, 0xd6, 0xa3, 0x25, 0x52, 0x5e, 0x6e, 0xd4,
0x50, 0x83, 0xe6, 0xfb, 0x70, 0xa5, 0x35, 0x29,
0xd1, 0xfa, 0x0f, 0x55, 0x65, 0x3b, 0x94, 0x2a,
0xf5, 0x9d, 0x78, 0xa2, 0x66, 0x03, 0x61, 0xd6,
0x3a, 0x72, 0x90, 0x15, 0x5a, 0xc5, 0xc4, 0x33,
0x12, 0xa2, 0x5b, 0x23, 0x5d, 0xac, 0xbb, 0xc8,
0x63, 0xfa, 0xf0, 0x09, 0x40, 0xc9, 0x96, 0x24,
0x07, 0x6d, 0xfa, 0x44, 0x06, 0x8e, 0x7c, 0x55,
0x4c, 0x90, 0x38, 0x17, 0x69, 0x53, 0xe5, 0x71,
0x75, 0x1d, 0xfc, 0x09, 0x54, 0xd4, 0x1d, 0x11,
0x37, 0x71, 0xb0, 0x64, 0x66, 0xb1, 0xc8, 0xd1,
0x3e, 0x0d, 0x4c, 0xb6, 0x75, 0xed, 0x58, 0xd1,
0xa6, 0x19, 0xe1, 0x54, 0x09, 0x70, 0x98, 0x37,
0x81, 0xdc, 0x11, 0xd2, 0xdd, 0x85, 0x25, 0xab,
0x57, 0x45, 0x95, 0x8d, 0x61, 0x5d, 0xef, 0xda }, /* mdata */
160, /* mdata_len */
{ 0xe8, 0xb8, 0x91, 0x50, 0xd8, 0x43, 0x8b, 0xf5,
0xb1, 0x74, 0x49, 0xd6, 0xed, 0x26, 0xbd, 0x72,
0x12, 0x7e, 0x10, 0xe4, 0xaa, 0x57, 0xca, 0xd8,
0x52, 0x83, 0xe8, 0x35, 0x9e, 0x08, 0x92, 0x08,
0xe8, 0x49, 0x21, 0x64, 0x9f, 0x5b, 0x60, 0xea,
0x21, 0xf7, 0x86, 0x7c, 0xbc, 0x96, 0x20, 0x56,
0x0c, 0x4c, 0x62, 0x38, 0xdb, 0x02, 0x12, 0x16,
0xdb, 0x45, 0x3c, 0x99, 0x43, 0xf1, 0xf1, 0xa6,
0x05, 0x46, 0x17, 0x3d, 0xae, 0xf2, 0x55, 0x7c,
0x3c, 0xdd, 0x85, 0x50, 0x31, 0xb3, 0x53, 0xd4,
0xbf, 0x17, 0x6f, 0x28, 0x43, 0x9e, 0x48, 0x78,
0x5c, 0x37, 0xd3, 0x8f, 0x27, 0x0a, 0xa4, 0xa6,
0xfa, 0xad, 0x2b, 0xaa, 0xbc, 0xb0, 0xc0, 0xb2,
0xd1, 0xdd, 0x53, 0x22, 0x93, 0x74, 0x98, 0xce,
0x80, 0x3b, 0xa1, 0x14, 0x84, 0x40, 0xa5, 0x2e,
0x22, 0x7d, 0xdb, 0xa4, 0x87, 0x2f, 0xe4, 0xd8,
0x1d, 0x2d, 0x76, 0xa9, 0x39, 0xd2, 0x47, 0x55,
0xad, 0xb8, 0xa7, 0xb8, 0x45, 0x2c, 0xee, 0xd2,
0xd1, 0x79, 0xe1, 0xa5, 0x84, 0x8f, 0x31, 0x6f,
0x5c, 0x01, 0x63, 0x00, 0xa3, 0x90, 0xbf, 0xa7 } /* expected */
}, {
true, /* encrypt */
1, /* key_size_index */
0, /* key_area */
{ 0x53, 0x1c, 0xe7, 0x81, 0x76, 0x40, 0x16, 0x66,
0xaa, 0x30, 0xdb, 0x94, 0xec, 0x4a, 0x30, 0xeb }, /* iv */
{ 0xc5, 0x1f, 0xc2, 0x76, 0x77, 0x4d, 0xad, 0x94,
0xbc, 0xdc, 0x1d, 0x28, 0x91, 0xec, 0x86, 0x68 }, /* mdata */
16, /* mdata_len */
{ 0x70, 0xdd, 0x95, 0xa1, 0x4e, 0xe9, 0x75, 0xe2,
0x39, 0xdf, 0x36, 0xff, 0x4a, 0xee, 0x1d, 0x5d } /* expected */
}, {
true, /* encrypt */
1, /* key_size_index */
2, /* key_area */
{ 0x24, 0x40, 0x80, 0x38, 0x16, 0x1a, 0x2c, 0xca,
0xe0, 0x7b, 0x02, 0x9b, 0xb6, 0x63, 0x55, 0xc1 }, /* iv */
{ 0xbe, 0x8a, 0xbf, 0x00, 0x90, 0x13, 0x63, 0x98,
0x7a, 0x82, 0xcc, 0x77, 0xd0, 0xec, 0x91, 0x69,
0x7b, 0xa3, 0x85, 0x7f, 0x9e, 0x4f, 0x84, 0xbd,
0x79, 0x40, 0x6c, 0x13, 0x8d, 0x02, 0x69, 0x8f,
0x00, 0x32, 0x76, 0xd0, 0x44, 0x91, 0x20, 0xbe,
0xf4, 0x57, 0x8d, 0x78, 0xfe, 0xca, 0xbe, 0x8e,
0x07, 0x0e, 0x11, 0x71, 0x0b, 0x3f, 0x0a, 0x27,
0x44, 0xbd, 0x52, 0x43, 0x4e, 0xc7, 0x00, 0x15,
0x88, 0x4c, 0x18, 0x1e, 0xbd, 0xfd, 0x51, 0xc6,
0x04, 0xa7, 0x1c, 0x52, 0xe4, 0xc0, 0xe1, 0x10,
0xbc, 0x40, 0x8c, 0xd4, 0x62, 0xb2, 0x48, 0xa8,
0x0b, 0x8a, 0x8a, 0xc0, 0x6b, 0xb9, 0x52, 0xac,
0x1d, 0x7f, 0xae, 0xd1, 0x44, 0x80, 0x7f, 0x1a,
0x73, 0x1b, 0x7f, 0xeb, 0xca, 0xf7, 0x83, 0x57,
0x62, 0xde, 0xfe, 0x92, 0xec, 0xcf, 0xc7, 0xa9,
0x94, 0x4e, 0x1c, 0x70, 0x2c, 0xff, 0xe6, 0xbc,
0x86, 0x73, 0x3e, 0xd3, 0x21, 0x42, 0x31, 0x21,
0x08, 0x5a, 0xc0, 0x2d, 0xf8, 0x96, 0x2b, 0xcb,
0xc1, 0x93, 0x70, 0x92, 0xee, 0xbf, 0x0e, 0x90,
0xa8, 0xb2, 0x0e, 0x3d, 0xd8, 0xc2, 0x44, 0xae }, /* mdata */
160, /* mdata_len */
{ 0xc8, 0x2c, 0xf2, 0xc4, 0x76, 0xde, 0xa8, 0xcb,
0x6a, 0x6e, 0x60, 0x7a, 0x40, 0xd2, 0xf0, 0x39,
0x1b, 0xe8, 0x2e, 0xa9, 0xec, 0x84, 0xa5, 0x37,
0xa6, 0x82, 0x0f, 0x9a, 0xfb, 0x99, 0x7b, 0x76,
0x39, 0x7d, 0x00, 0x54, 0x24, 0xfa, 0xa6, 0xa7,
0x4d, 0xc4, 0xe8, 0xc7, 0xaa, 0x4a, 0x89, 0x00,
0x69, 0x0f, 0x89, 0x4b, 0x6d, 0x1d, 0xca, 0x80,
0x67, 0x53, 0x93, 0xd2, 0x24, 0x3a, 0xda, 0xc7,
0x62, 0xf1, 0x59, 0x30, 0x1e, 0x35, 0x7e, 0x98,
0xb7, 0x24, 0x76, 0x23, 0x10, 0xcd, 0x5a, 0x7b,
0xaf, 0xe1, 0xc2, 0xa0, 0x30, 0xdb, 0xa4, 0x6f,
0xd9, 0x3a, 0x9f, 0xdb, 0x89, 0xcc, 0x13, 0x2c,
0xa9, 0xc1, 0x7d, 0xc7, 0x20, 0x31, 0xec, 0x68,
0x22, 0xee, 0x5a, 0x9d, 0x99, 0xdb, 0xca, 0x66,
0xc7, 0x84, 0xc0, 0x1b, 0x08, 0x85, 0xcb, 0xb6,
0x2e, 0x29, 0xd9, 0x78, 0x01, 0x92, 0x7e, 0xc4,
0x15, 0xa5, 0xd2, 0x15, 0x15, 0x8d, 0x32, 0x5f,
0x9e, 0xe6, 0x89, 0x43, 0x7a, 0xd1, 0xb7, 0x68,
0x4a, 0xd3, 0x3c, 0x0d, 0x92, 0x73, 0x94, 0x51,
0xac, 0x87, 0xf3, 0x9f, 0xf8, 0xc3, 0x1b, 0x84 } /* expected */
}, {
false, /* encrypt */
1, /* key_size_index */
4, /* key_area */
{ 0x32, 0x40, 0x15, 0x87, 0x8c, 0xdc, 0x82, 0xbf,
0xae, 0x59, 0xa2, 0xdc, 0x1f, 0xf3, 0x4e, 0xa6 }, /* iv */
{ 0x39, 0xa9, 0xb4, 0x2d, 0xe1, 0x9e, 0x51, 0x2a,
0xb7, 0xf3, 0x04, 0x35, 0x64, 0xc3, 0x51, 0x5a }, /* mdata */
16, /* mdata_len */
{ 0xaa, 0x41, 0x17, 0x9d, 0x88, 0x0e, 0x6f, 0xe3,
0xb1, 0x48, 0x18, 0xd6, 0xe4, 0xa6, 0x2e, 0xb5 } /* expected */
}, {
false, /* encrypt */
1, /* key_size_index */
6, /* key_area */
{ 0xd6, 0xd8, 0x6e, 0x0c, 0x82, 0xdd, 0x87, 0x88,
0xf4, 0x14, 0x7a, 0x26, 0xf9, 0xa7, 0x1c, 0x74 }, /* iv */
{ 0x69, 0x28, 0x29, 0x9c, 0x52, 0xb4, 0xf0, 0x47,
0x92, 0x6f, 0x8a, 0x54, 0x15, 0x29, 0xda, 0x2d,
0x6b, 0xba, 0xa3, 0x99, 0x14, 0x3c, 0xed, 0x8e,
0xfb, 0x77, 0xab, 0x47, 0x40, 0x9d, 0x9a, 0x95,
0x3a, 0x38, 0x6c, 0x7a, 0xbd, 0x60, 0x26, 0xf4,
0x98, 0x31, 0xc7, 0x17, 0x62, 0x7c, 0x2a, 0x5e,
0x77, 0xbd, 0x2d, 0x43, 0x3d, 0x4d, 0x13, 0x0d,
0xac, 0xd9, 0x27, 0xea, 0x0d, 0x13, 0xa2, 0x3d,
0x01, 0xa7, 0xcf, 0x39, 0xc6, 0x71, 0x6d, 0xaf,
0xb6, 0xed, 0x55, 0x24, 0x10, 0xef, 0x5d, 0x27,
0xfb, 0x94, 0x7b, 0xe2, 0xc8, 0x78, 0x2e, 0xee,
0x78, 0x29, 0x19, 0x6c, 0x7e, 0xdc, 0xf1, 0x51,
0xc6, 0x5f, 0x9a, 0x01, 0xf5, 0x4f, 0x8d, 0x20,
0xf3, 0x8b, 0x7d, 0xa4, 0xa7, 0xe8, 0x3a, 0x2f,
0x01, 0x27, 0xd5, 0x9d, 0x3e, 0x24, 0x05, 0xd8,
0x67, 0x4f, 0xc9, 0xf4, 0x1b, 0x60, 0x4f, 0x78,
0x8f, 0x47, 0x15, 0xf9, 0xd3, 0x62, 0x4e, 0xee,
0x57, 0xf3, 0x87, 0xbf, 0xad, 0xd1, 0x8a, 0x1f,
0x90, 0x5e, 0x83, 0x9c, 0x26, 0xb8, 0x61, 0x74,
0x82, 0x34, 0x7f, 0xab, 0x6d, 0x08, 0x84, 0x5a }, /* mdata */
160, /* mdata_len */
{ 0x67, 0xd2, 0xdd, 0xa6, 0xda, 0x26, 0xe2, 0x13,
0x07, 0x97, 0x34, 0x00, 0x60, 0x07, 0x25, 0x72,
0x7a, 0xe8, 0x14, 0x15, 0x51, 0x17, 0x72, 0xf4,
0xa0, 0x9a, 0xd9, 0x90, 0x3b, 0xcf, 0x90, 0xcc,
0x2c, 0x0d, 0xac, 0x58, 0xba, 0x55, 0x9a, 0x01,
0x09, 0xc5, 0x4a, 0x9d, 0x61, 0x17, 0xb1, 0x5b,
0xb5, 0x74, 0xca, 0x47, 0x3e, 0x84, 0x80, 0x47,
0xe9, 0xa5, 0x4e, 0xe4, 0xab, 0xde, 0x76, 0xaf,
0xf9, 0x84, 0x9c, 0x44, 0x10, 0x9d, 0x16, 0x1f,
0x46, 0x44, 0x2e, 0x16, 0x10, 0xd8, 0xb0, 0x15,
0xcf, 0x36, 0xa0, 0x10, 0xed, 0x8e, 0xfa, 0x32,
0x07, 0xfd, 0xfc, 0x8f, 0xcc, 0x54, 0x8f, 0x14,
0x5c, 0x02, 0x7e, 0x44, 0xc5, 0xb0, 0xec, 0x35,
0xc9, 0x88, 0x6f, 0x4b, 0x9d, 0x65, 0x13, 0xa5,
0xbc, 0x10, 0xd0, 0xea, 0x6b, 0xbb, 0xc2, 0x6f,
0x54, 0xb1, 0x83, 0xbc, 0xae, 0x27, 0xfb, 0x79,
0x9d, 0x88, 0x72, 0xff, 0x74, 0x8f, 0xc4, 0x59,
0xd5, 0x5c, 0xfa, 0x25, 0x5a, 0xae, 0x29, 0xd7,
0x1b, 0x07, 0x6d, 0x9b, 0x44, 0xc1, 0x4d, 0x5c,
0xeb, 0xa9, 0x33, 0x2a, 0x76, 0x3d, 0x9c, 0x94 } /* expected */
}, {
true, /* encrypt */
2, /* key_size_index */
0, /* key_area */
{ 0x85, 0x1e, 0x87, 0x64, 0x77, 0x6e, 0x67, 0x96,
0xaa, 0xb7, 0x22, 0xdb, 0xb6, 0x44, 0xac, 0xe8 }, /* iv */
{ 0x62, 0x82, 0xb8, 0xc0, 0x5c, 0x5c, 0x15, 0x30,
0xb9, 0x7d, 0x48, 0x16, 0xca, 0x43, 0x47, 0x62 }, /* mdata */
16, /* mdata_len */
{ 0x6a, 0xcc, 0x04, 0x14, 0x2e, 0x10, 0x0a, 0x65,
0xf5, 0x1b, 0x97, 0xad, 0xf5, 0x17, 0x2c, 0x41 } /* expected */
}, {
true, /* encrypt */
2, /* key_size_index */
2, /* key_area */
{ 0xd6, 0xd5, 0x81, 0xb8, 0xcf, 0x04, 0xeb, 0xd3,
0xb6, 0xea, 0xa1, 0xb5, 0x3f, 0x04, 0x7e, 0xe1 }, /* iv */
{ 0x0c, 0x63, 0xd4, 0x13, 0xd3, 0x86, 0x45, 0x70,
0xe7, 0x0b, 0xb6, 0x61, 0x8b, 0xf8, 0xa4, 0xb9,
0x58, 0x55, 0x86, 0x68, 0x8c, 0x32, 0xbb, 0xa0,
0xa5, 0xec, 0xc1, 0x36, 0x2f, 0xad, 0xa7, 0x4a,
0xda, 0x32, 0xc5, 0x2a, 0xcf, 0xd1, 0xaa, 0x74,
0x44, 0xba, 0x56, 0x7b, 0x4e, 0x7d, 0xaa, 0xec,
0xf7, 0xcc, 0x1c, 0xb2, 0x91, 0x82, 0xaf, 0x16,
0x4a, 0xe5, 0x23, 0x2b, 0x00, 0x28, 0x68, 0x69,
0x56, 0x35, 0x59, 0x98, 0x07, 0xa9, 0xa7, 0xf0,
0x7a, 0x1f, 0x13, 0x7e, 0x97, 0xb1, 0xe1, 0xc9,
0xda, 0xbc, 0x89, 0xb6, 0xa5, 0xe4, 0xaf, 0xa9,
0xdb, 0x58, 0x55, 0xed, 0xaa, 0x57, 0x50, 0x56,
0xa8, 0xf4, 0xf8, 0x24, 0x22, 0x16, 0x24, 0x2b,
0xb0, 0xc2, 0x56, 0x31, 0x0d, 0x9d, 0x32, 0x98,
0x26, 0xac, 0x35, 0x3d, 0x71, 0x5f, 0xa3, 0x9f,
0x80, 0xce, 0xc1, 0x44, 0xd6, 0x42, 0x45, 0x58,
0xf9, 0xf7, 0x0b, 0x98, 0xc9, 0x20, 0x09, 0x6e,
0x0f, 0x2c, 0x85, 0x5d, 0x59, 0x48, 0x85, 0xa0,
0x06, 0x25, 0x88, 0x0e, 0x9d, 0xfb, 0x73, 0x41,
0x63, 0xce, 0xce, 0xf7, 0x2c, 0xf0, 0x30, 0xb8 }, /* mdata */
160, /* mdata_len */
{ 0xfc, 0x58, 0x73, 0xe5, 0x0d, 0xe8, 0xfa, 0xf4,
0xc6, 0xb8, 0x4b, 0xa7, 0x07, 0xb0, 0x85, 0x4e,
0x9d, 0xb9, 0xab, 0x2e, 0x9f, 0x7d, 0x70, 0x7f,
0xbb, 0xa3, 0x38, 0xc6, 0x84, 0x3a, 0x18, 0xfc,
0x6f, 0xac, 0xeb, 0xaf, 0x66, 0x3d, 0x26, 0x29,
0x6f, 0xb3, 0x29, 0xb4, 0xd2, 0x6f, 0x18, 0x49,
0x4c, 0x79, 0xe0, 0x9e, 0x77, 0x96, 0x47, 0xf9,
0xba, 0xfa, 0x87, 0x48, 0x96, 0x30, 0xd7, 0x9f,
0x43, 0x01, 0x61, 0x0c, 0x23, 0x00, 0xc1, 0x9d,
0xbf, 0x31, 0x48, 0xb7, 0xca, 0xc8, 0xc4, 0xf4,
0x94, 0x41, 0x02, 0x75, 0x4f, 0x33, 0x2e, 0x92,
0xb6, 0xf7, 0xc5, 0xe7, 0x5b, 0xc6, 0x17, 0x9e,
0xb8, 0x77, 0xa0, 0x78, 0xd4, 0x71, 0x90, 0x09,
0x02, 0x17, 0x44, 0xc1, 0x4f, 0x13, 0xfd, 0x2a,
0x55, 0xa2, 0xb9, 0xc4, 0x4d, 0x18, 0x00, 0x06,
0x85, 0xa8, 0x45, 0xa4, 0xf6, 0x32, 0xc7, 0xc5,
0x6a, 0x77, 0x30, 0x6e, 0xfa, 0x66, 0xa2, 0x4d,
0x05, 0xd0, 0x88, 0xdc, 0xd7, 0xc1, 0x3f, 0xe2,
0x4f, 0xc4, 0x47, 0x27, 0x59, 0x65, 0xdb, 0x9e,
0x4d, 0x37, 0xfb, 0xc9, 0x30, 0x44, 0x48, 0xcd } /* expected */
}, {
false, /* encrypt */
2, /* key_size_index */
4, /* key_area */
{ 0xdd, 0xbb, 0xb0, 0x17, 0x3f, 0x1e, 0x2d, 0xeb,
0x23, 0x94, 0xa6, 0x2a, 0xa2, 0xa0, 0x24, 0x0e }, /* iv */
{ 0xd5, 0x1d, 0x19, 0xde, 0xd5, 0xca, 0x4a, 0xe1,
0x4b, 0x2b, 0x20, 0xb0, 0x27, 0xff, 0xb0, 0x20 }, /* mdata */
16, /* mdata_len */
{ 0x07, 0x27, 0x0d, 0x0e, 0x63, 0xaa, 0x36, 0xda,
0xed, 0x8c, 0x6a, 0xde, 0x13, 0xac, 0x1a, 0xf1 } /* expected */
}, {
false, /* encrypt */
2, /* key_size_index */
6, /* key_area */
{ 0xe4, 0x96, 0x51, 0x98, 0x8e, 0xbb, 0xb7, 0x2e,
0xb8, 0xbb, 0x80, 0xbb, 0x9a, 0xbb, 0xca, 0x34 }, /* iv */
{ 0x5b, 0x97, 0xa9, 0xd4, 0x23, 0xf4, 0xb9, 0x74,
0x13, 0xf3, 0x88, 0xd9, 0xa3, 0x41, 0xe7, 0x27,
0xbb, 0x33, 0x9f, 0x8e, 0x18, 0xa3, 0xfa, 0xc2,
0xf2, 0xfb, 0x85, 0xab, 0xdc, 0x8f, 0x13, 0x5d,
0xeb, 0x30, 0x05, 0x4a, 0x1a, 0xfd, 0xc9, 0xb6,
0xed, 0x7d, 0xa1, 0x6c, 0x55, 0xeb, 0xa6, 0xb0,
0xd4, 0xd1, 0x0c, 0x74, 0xe1, 0xd9, 0xa7, 0xcf,
0x8e, 0xdf, 0xae, 0xaa, 0x68, 0x4a, 0xc0, 0xbd,
0x9f, 0x9d, 0x24, 0xba, 0x67, 0x49, 0x55, 0xc7,
0x9d, 0xc6, 0xbe, 0x32, 0xae, 0xe1, 0xc2, 0x60,
0xb5, 0x58, 0xff, 0x07, 0xe3, 0xa4, 0xd4, 0x9d,
0x24, 0x16, 0x20, 0x11, 0xff, 0x25, 0x4d, 0xb8,
0xbe, 0x07, 0x8e, 0x8a, 0xd0, 0x7e, 0x64, 0x8e,
0x6b, 0xf5, 0x67, 0x93, 0x76, 0xcb, 0x43, 0x21,
0xa5, 0xef, 0x01, 0xaf, 0xe6, 0xad, 0x88, 0x16,
0xfc, 0xc7, 0x63, 0x46, 0x69, 0xc8, 0xc4, 0x38,
0x92, 0x95, 0xc9, 0x24, 0x1e, 0x45, 0xff, 0xf3,
0x9f, 0x32, 0x25, 0xf7, 0x74, 0x50, 0x32, 0xda,
0xee, 0xbe, 0x99, 0xd4, 0xb1, 0x9b, 0xcb, 0x21,
0x5d, 0x1b, 0xfd, 0xb3, 0x6e, 0xda, 0x2c, 0x24 }, /* mdata */
160, /* mdata_len */
{ 0xbf, 0xe5, 0xc6, 0x35, 0x4b, 0x7a, 0x3f, 0xf3,
0xe1, 0x92, 0xe0, 0x57, 0x75, 0xb9, 0xb7, 0x58,
0x07, 0xde, 0x12, 0xe3, 0x8a, 0x62, 0x6b, 0x8b,
0xf0, 0xe1, 0x2d, 0x5f, 0xff, 0x78, 0xe4, 0xf1,
0x77, 0x5a, 0xa7, 0xd7, 0x92, 0xd8, 0x85, 0x16,
0x2e, 0x66, 0xd8, 0x89, 0x30, 0xf9, 0xc3, 0xb2,
0xcd, 0xf8, 0x65, 0x4f, 0x56, 0x97, 0x25, 0x04,
0x80, 0x31, 0x90, 0x38, 0x62, 0x70, 0xf0, 0xaa,
0x43, 0x64, 0x5d, 0xb1, 0x87, 0xaf, 0x41, 0xfc,
0xea, 0x63, 0x9b, 0x1f, 0x80, 0x26, 0xcc, 0xdd,
0x0c, 0x23, 0xe0, 0xde, 0x37, 0x09, 0x4a, 0x8b,
0x94, 0x1e, 0xcb, 0x76, 0x02, 0x99, 0x8a, 0x4b,
0x26, 0x04, 0xe6, 0x9f, 0xc0, 0x42, 0x19, 0x58,
0x5d, 0x85, 0x46, 0x00, 0xe0, 0xad, 0x6f, 0x99,
0xa5, 0x3b, 0x25, 0x04, 0x04, 0x3c, 0x08, 0xb1,
0xc3, 0xe2, 0x14, 0xd1, 0x7c, 0xde, 0x05, 0x3c,
0xbd, 0xf9, 0x1d, 0xaa, 0x99, 0x9e, 0xd5, 0xb4,
0x7c, 0x37, 0x98, 0x3b, 0xa3, 0xee, 0x25, 0x4b,
0xc5, 0xc7, 0x93, 0x83, 0x7d, 0xaa, 0xa8, 0xc8,
0x5c, 0xfc, 0x12, 0xf7, 0xf5, 0x4f, 0x69, 0x9f } /* expected */
}
};
static uint8_t mdata[MDATA_MAX_LEN];
static int i;
static uint8_t key_size_index = -1, ret;
static int8_t res;
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 mdata_len=%d\n",
i, vectors[i].encrypt ? "encrypt" : "decrypt",
vectors[i].key_area, vectors[i].mdata_len);
/* mdata has to be in SRAM. */
rom_util_memcpy(mdata, vectors[i].mdata, vectors[i].mdata_len);
time = RTIMER_NOW();
ret = cbc_crypt_start(vectors[i].encrypt, vectors[i].key_area,
vectors[i].iv, mdata, mdata, vectors[i].mdata_len,
&cbc_test_process);
time2 = RTIMER_NOW();
time = time2 - time;
total_time = time;
if(ret == CRYPTO_SUCCESS) {
PROCESS_WAIT_EVENT_UNTIL((res = cbc_crypt_check_status()) !=
CRYPTO_PENDING);
time2 = RTIMER_NOW() - time2;
total_time += time2;
}
printf("cbc_crypt_start(): %s, %lu us\n", str_res[ret],
(uint32_t)((uint64_t)time * 1000000 / RTIMER_SECOND));
if(ret != CRYPTO_SUCCESS) {
PROCESS_PAUSE();
continue;
}
printf("cbc_crypt_check_status() wait: %s, %lu us\n", str_res[res],
(uint32_t)((uint64_t)time2 * 1000000 / RTIMER_SECOND));
PROCESS_PAUSE();
if(res != CRYPTO_SUCCESS) {
continue;
}
if(rom_util_memcmp(mdata, vectors[i].expected, vectors[i].mdata_len)) {
puts("Output message does not match expected one");
} else {
puts("Output 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();
}
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/