adding Seed

This commit is contained in:
bg 2011-02-02 14:40:00 +01:00
parent b6f2bb4e1a
commit 57e6e95bbd
9 changed files with 7948 additions and 6 deletions

View File

@ -25,18 +25,17 @@
*
*/
#include <avr/pgmspace.h>
#include <stdlib.h>
#include "blockcipher_descriptor.h"
#include "seed.h"
#include "keysize_descriptor.h"
const char seed_str[] PROGMEM = "SEED";
const char seed_str[] = "SEED";
const uint8_t seed_keysize_desc[] PROGMEM = { KS_TYPE_LIST, 1, KS_INT(128),
KS_TYPE_TERMINATOR };
const uint8_t seed_keysize_desc[] = { KS_TYPE_LIST, 1, KS_INT(128),
KS_TYPE_TERMINATOR };
const bcdesc_t seed_desc PROGMEM = {
const bcdesc_t seed_desc = {
BCDESC_TYPE_BLOCKCIPHER,
BC_INIT_TYPE_1,
seed_str,

View File

@ -25,7 +25,6 @@
*
*/
#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "seed.h"
#include "keysize_descriptor.h"

13
mkfiles/seed_c.mk Normal file
View File

@ -0,0 +1,13 @@
# Makefile for SEED
ALGO_NAME := SEED_C
# comment out the following line for removement of SEED from the build process
BLOCK_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_DIR := seed/
$(ALGO_NAME)_OBJ := seed_c.o seed_sbox.o
$(ALGO_NAME)_INCDIR := bcal/
$(ALGO_NAME)_TEST_BIN := main-seed-test.o bcal_seed.o $(CLI_STD) $(BCAL_STD)
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"

81
seed/seed.h Normal file
View File

@ -0,0 +1,81 @@
/* seed.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file seed.h
* \author Daniel Otte
* \date 2007-06-1
* \brief declarations for seed
* \par License
* GPL
*
*/
#ifndef SEED_H_
#define SEED_H_
#include <stdint.h>
/** \typedef seed_ctx_t
* \brief SEED context
*
* A variable of this type may hold the key material for the SEED cipher.
* This context is regulary generated by the
* void seed_init(const void * key, seed_ctx_t * ctx) function.
*/
typedef struct{
uint32_t k[4];
} seed_ctx_t;
/******************************************************************************/
/** \fn void seed_init(const void * key, seed_ctx_t * ctx)
* \brief initializes context for SEED operation
*
* This function copys the key material into a context variable.
*
* \param key pointer to the key material (128 bit = 16 bytes)
* \param ctx pointer to the context (seed_ctx_t)
*/
void seed_init(const void * key, seed_ctx_t * ctx);
/** \fn void seed_enc(void * buffer,const seed_ctx_t * ctx)
* \brief encrypt a block with SEED
*
* This function encrypts a block of 64 bits (8 bytes) with the SEED algorithm.
* The round keys are computed on demand, so the context is modifyed while
* encrypting but the original stated is restored when the function exits.
*
* \param buffer pointer to the block (64 bit = 8 byte) which will be encrypted
* \param ctx pointer to the key material (seed_ctx_t)
*/
void seed_enc(void * buffer, const seed_ctx_t * ctx);
/** \fn void seed_dec(void * buffer, const seed_ctx_t * ctx)
* \brief decrypt a block with SEED
*
* This function decrypts a block of 64 bits (8 bytes) with the SEED algorithm.
* The round keys are computed on demand, so the context is modifyed while
* decrypting but the original stated is restored when the function exits.
*
* \param buffer pointer to the block (64 bit = 8 byte) which will be decrypted
* \param ctx pointer to the key material (seed_ctx_t)
*/
void seed_dec(void * buffer, const seed_ctx_t * ctx);
#endif /*SEED_H_*/

280
seed/seed_c.c Normal file
View File

@ -0,0 +1,280 @@
/* seed_c.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file seed_c.c
* \author Daniel Otte
* \date 2007-06-1
* \brief SEED parts in C for AVR
* \par License
* GPL
*
*/
#include <stdint.h>
#include <string.h>
#include "seed.h"
#include "seed_sbox.h"
static
uint32_t g_function(uint32_t x);
/******************************************************************************/
static
void changeendian32(uint32_t * a){
*a = (*a & 0x000000FF) << 24 |
(*a & 0x0000FF00) << 8 |
(*a & 0x00FF0000) >> 8 |
(*a & 0xFF000000) >> 24;
}
/******************************************************************************/
static
uint32_t bigendian_sum32(uint32_t a, uint32_t b){
changeendian32(&a);
changeendian32(&b);
a += b;
changeendian32(&a);
return a;
}
/******************************************************************************/
static
uint32_t bigendian_sub32(uint32_t a, uint32_t b){
changeendian32(&a);
changeendian32(&b);
a -= b;
changeendian32(&a);
return a;
}
/******************************************************************************/
static inline
uint64_t bigendian_rotl8_64(uint64_t a){
/*
changeendian64(&a);
a = (a<<8) | (a>>(64-8));
changeendian64(&a);
*/
a = (a>>8) | (a<<(64-8));
return a;
}
/******************************************************************************/
static inline
uint64_t bigendian_rotr8_64(uint64_t a){
/*
changeendian64(&a);
a = (a>>8) | (a<<(64-8));
changeendian64(&a);
*/
a = (a<<8) | (a>>(64-8));
return a;
}
/******************************************************************************/
static
uint64_t f_function(const uint64_t* a, uint32_t k0, uint32_t k1){
uint32_t c,d;
c = *a & 0x00000000FFFFFFFFLL;
d = (*a>>32) & 0x00000000FFFFFFFFLL;
c ^= k0; d ^= k1;
d ^= c;
d = g_function(d);
c = bigendian_sum32(c,d);
c = g_function(c);
d = bigendian_sum32(c,d);
d = g_function(d);
c = bigendian_sum32(c,d);
return ((uint64_t)d << 32) | c;
}
/******************************************************************************/
#define M0 0xfc
#define M1 0xf3
#define M2 0xcf
#define M3 0x3f
#define X3 (((uint8_t*)(&x))[0])
#define X2 (((uint8_t*)(&x))[1])
#define X1 (((uint8_t*)(&x))[2])
#define X0 (((uint8_t*)(&x))[3])
#define Z3 (((uint8_t*)(&z))[0])
#define Z2 (((uint8_t*)(&z))[1])
#define Z1 (((uint8_t*)(&z))[2])
#define Z0 (((uint8_t*)(&z))[3])
static
uint32_t g_function(uint32_t x){
uint32_t z;
/* sbox substitution */
X3 = seed_sbox2[X3];
X2 = seed_sbox1[X2];
X1 = seed_sbox2[X1];
X0 = seed_sbox1[X0];
/* now the permutation */
Z0 = (X0 & M0) ^ (X1 & M1) ^ (X2 & M2) ^ (X3 & M3);
Z1 = (X0 & M1) ^ (X1 & M2) ^ (X2 & M3) ^ (X3 & M0);
Z2 = (X0 & M2) ^ (X1 & M3) ^ (X2 & M0) ^ (X3 & M1);
Z3 = (X0 & M3) ^ (X1 & M0) ^ (X2 & M1) ^ (X3 & M2);
return z;
}
/******************************************************************************/
typedef struct {
uint32_t k0, k1;
} keypair_t;
keypair_t getnextkeys(uint32_t *keystate, uint8_t curround){
keypair_t ret;
if (curround>15){
/* ERROR */
ret.k0 = ret.k1 = 0;
} else {
/* ret.k0 = g_function(keystate[0] + keystate[2] - pgm_read_dword(&(seed_kc[curround])));
ret.k1 = g_function(keystate[1] - keystate[3] + pgm_read_dword(&(seed_kc[curround]))); */
ret.k0 = bigendian_sum32(keystate[0], keystate[2]);
ret.k0 = bigendian_sub32(ret.k0, seed_kc[curround]);
ret.k0 = g_function(ret.k0);
ret.k1 = bigendian_sub32(keystate[1], keystate[3]);
ret.k1 = bigendian_sum32(ret.k1, seed_kc[curround]);
ret.k1 = g_function(ret.k1);
if (curround & 1){
/* odd round (1,3,5, ...) */
((uint64_t*)keystate)[1] = bigendian_rotl8_64( ((uint64_t*)keystate)[1] );
} else {
/* even round (0,2,4, ...) */
((uint64_t*)keystate)[0] = bigendian_rotr8_64(((uint64_t*)keystate)[0]);
}
}
return ret;
}
/******************************************************************************/
keypair_t getprevkeys(uint32_t *keystate, uint8_t curround){
keypair_t ret;
if (curround>15){
/* ERROR */
ret.k0 = ret.k1 = 0;
} else {
if (curround & 1){
/* odd round (1,3,5, ..., 15) */
((uint64_t*)keystate)[1] = bigendian_rotr8_64( ((uint64_t*)keystate)[1] );
} else {
/* even round (0,2,4, ..., 14) */
((uint64_t*)keystate)[0] = bigendian_rotl8_64(((uint64_t*)keystate)[0]);
}
/* ret.k0 = g_function(keystate[0] + keystate[2] - pgm_read_dword(&(seed_kc[curround])));
ret.k1 = g_function(keystate[1] - keystate[3] + pgm_read_dword(&(seed_kc[curround]))); */
ret.k0 = bigendian_sum32(keystate[0], keystate[2]);
ret.k0 = bigendian_sub32(ret.k0, seed_kc[curround]);
ret.k0 = g_function(ret.k0);
ret.k1 = bigendian_sub32(keystate[1], keystate[3]);
ret.k1 = bigendian_sum32(ret.k1, seed_kc[curround]);
ret.k1 = g_function(ret.k1);
}
return ret;
}
/******************************************************************************/
void seed_init(const void * key, seed_ctx_t * ctx){
memcpy(ctx->k, key, 128/8);
}
/******************************************************************************/
#define L (((uint64_t*)buffer)[0])
#define R (((uint64_t*)buffer)[1])
void seed_enc(void * buffer, const seed_ctx_t * ctx){
uint8_t r;
keypair_t k;
for(r=0; r<8; ++r){
k = getnextkeys(((seed_ctx_t*)ctx)->k, 2*r);
/*
DEBUG_S("\r\n\tDBG ka,0: "); cli_hexdump(&k.k0, 4);
DEBUG_S("\r\n\tDBG ka,1: "); cli_hexdump(&k.k1, 4);
DEBUG_S("\r\n\t DBG L: "); cli_hexdump((uint8_t*)buffer+0, 8);
DEBUG_S("\r\n\t DBG R: "); cli_hexdump((uint8_t*)buffer+8, 8);
*/
L ^= f_function(&R,k.k0,k.k1);
k = getnextkeys(((seed_ctx_t*)ctx)->k, 2*r+1);
/*
DEBUG_S("\r\n\tDBG kb,0: "); cli_hexdump(&k.k0, 4);
DEBUG_S("\r\n\tDBG kb,1: "); cli_hexdump(&k.k1, 4);
DEBUG_S("\r\n\t DBG L: "); cli_hexdump((uint8_t*)buffer+8, 8);
DEBUG_S("\r\n\t DBG R: "); cli_hexdump((uint8_t*)buffer+0, 8);
*/
R ^= f_function(&L,k.k0,k.k1);
}
/* just an exchange without temp. variable */
L ^= R;
R ^= L;
L ^= R;
}
/******************************************************************************/
#define L (((uint64_t*)buffer)[0])
#define R (((uint64_t*)buffer)[1])
void seed_dec(void * buffer, const seed_ctx_t * ctx){
int8_t r;
keypair_t k;
for(r=7; r>=0; --r){
k = getprevkeys(((seed_ctx_t*)ctx)->k, 2*r+1);
/*
DEBUG_S("\r\n\tDBG ka,0: "); cli_hexdump(&k.k0, 4);
DEBUG_S("\r\n\tDBG ka,1: "); cli_hexdump(&k.k1, 4);
DEBUG_S("\r\n\t DBG L: "); cli_hexdump((uint8_t*)buffer+0, 8);
DEBUG_S("\r\n\t DBG R: "); cli_hexdump((uint8_t*)buffer+8, 8);
*/
L ^= f_function(&R,k.k0,k.k1);
k = getprevkeys(((seed_ctx_t*)ctx)->k, 2*r+0);
/*
DEBUG_S("\r\n\tDBG kb,0: "); cli_hexdump(&k.k0, 4);
DEBUG_S("\r\n\tDBG kb,1: "); cli_hexdump(&k.k1, 4);
DEBUG_S("\r\n\t DBG L: "); cli_hexdump((uint8_t*)buffer+8, 8);
DEBUG_S("\r\n\t DBG R: "); cli_hexdump((uint8_t*)buffer+0, 8);
*/
R ^= f_function(&L,k.k0,k.k1);
}
/* just an exchange without temp. variable */
L ^= R;
R ^= L;
L ^= R;
}

120
seed/seed_sbox.c Normal file
View File

@ -0,0 +1,120 @@
/* seed_sbox.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2011 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file seed_sbox.c
* \author Daniel Otte
* \date 2011-02-02
* \brief sboxes and constants for seed
* \par License
* GPL
*
*/
#include <stdint.h>
const uint8_t seed_sbox1[256] ={
169, 133, 214, 211, 84, 29, 172, 37,
93, 67, 24, 30, 81, 252, 202, 99,
40, 68, 32, 157, 224, 226, 200, 23,
165, 143, 3, 123, 187, 19, 210, 238,
112, 140, 63, 168, 50, 221, 246, 116,
236, 149, 11, 87, 92, 91, 189, 1,
36, 28, 115, 152, 16, 204, 242, 217,
44, 231, 114, 131, 155, 209, 134, 201,
96, 80, 163, 235, 13, 182, 158, 79,
183, 90, 198, 120, 166, 18, 175, 213,
97, 195, 180, 65, 82, 125, 141, 8,
31, 153, 0, 25, 4, 83, 247, 225,
253, 118, 47, 39, 176, 139, 14, 171,
162, 110, 147, 77, 105, 124, 9, 10,
191, 239, 243, 197, 135, 20, 254, 100,
222, 46, 75, 26, 6, 33, 107, 102,
2, 245, 146, 138, 12, 179, 126, 208,
122, 71, 150, 229, 38, 128, 173, 223,
161, 48, 55, 174, 54, 21, 34, 56,
244, 167, 69, 76, 129, 233, 132, 151,
53, 203, 206, 60, 113, 17, 199, 137,
117, 251, 218, 248, 148, 89, 130, 196,
255, 73, 57, 103, 192, 207, 215, 184,
15, 142, 66, 35, 145, 108, 219, 164,
52, 241, 72, 194, 111, 61, 45, 64,
190, 62, 188, 193, 170, 186, 78, 85,
59, 220, 104, 127, 156, 216, 74, 86,
119, 160, 237, 70, 181, 43, 101, 250,
227, 185, 177, 159, 94, 249, 230, 178,
49, 234, 109, 95, 228, 240, 205, 136,
22, 58, 88, 212, 98, 41, 7, 51,
232, 27, 5, 121, 144, 106, 42, 154
};
const uint8_t seed_sbox2[256] ={
56, 232, 45, 166, 207, 222, 179, 184,
175, 96, 85, 199, 68, 111, 107, 91,
195, 98, 51, 181, 41, 160, 226, 167,
211, 145, 17, 6, 28, 188, 54, 75,
239, 136, 108, 168, 23, 196, 22, 244,
194, 69, 225, 214, 63, 61, 142, 152,
40, 78, 246, 62, 165, 249, 13, 223,
216, 43, 102, 122, 39, 47, 241, 114,
66, 212, 65, 192, 115, 103, 172, 139,
247, 173, 128, 31, 202, 44, 170, 52,
210, 11, 238, 233, 93, 148, 24, 248,
87, 174, 8, 197, 19, 205, 134, 185,
255, 125, 193, 49, 245, 138, 106, 177,
209, 32, 215, 2, 34, 4, 104, 113,
7, 219, 157, 153, 97, 190, 230, 89,
221, 81, 144, 220, 154, 163, 171, 208,
129, 15, 71, 26, 227, 236, 141, 191,
150, 123, 92, 162, 161, 99, 35, 77,
200, 158, 156, 58, 12, 46, 186, 110,
159, 90, 242, 146, 243, 73, 120, 204,
21, 251, 112, 117, 127, 53, 16, 3,
100, 109, 198, 116, 213, 180, 234, 9,
118, 25, 254, 64, 18, 224, 189, 5,
250, 1, 240, 42, 94, 169, 86, 67,
133, 20, 137, 155, 176, 229, 72, 121,
151, 252, 30, 130, 33, 140, 27, 95,
119, 84, 178, 29, 37, 79, 0, 70,
237, 88, 82, 235, 126, 218, 201, 253,
48, 149, 101, 60, 182, 228, 187, 124,
14, 80, 57, 38, 50, 132, 105, 147,
55, 231, 36, 164, 203, 83, 10, 135,
217, 76, 131, 143, 206, 59, 74, 183
};
/* key constants */
const uint32_t seed_kc[16] ={
0xb979379e,
0x73f36e3c,
0xe6e6dd78,
0xcccdbbf1,
0x999b77e3,
0x3337efc6,
0x676ede8d,
0xcfdcbc1b,
0x9eb97937,
0x3c73f36e,
0x78e6e6dd,
0xf1cccdbb,
0xe3999b77,
0xc63337ef,
0x8d676ede,
0x1bcfdcbc
};

39
seed/seed_sbox.h Normal file
View File

@ -0,0 +1,39 @@
/* seed_sbox.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file seed_sbox.h
* \author Daniel Otte
* \date 2007-06-1
* \brief sboxes and constants for seed
* \par License
* GPL
*
*/
#ifndef SEED_SBOX_H_
#define SEED_SBOX_H_
#include <stdint.h>
extern const uint8_t seed_sbox1[256];
extern const uint8_t seed_sbox2[256];
/* key constants */
extern const uint32_t seed_kc[16];
#endif /*SEED_SBOX_H_*/

179
test_src/main-seed-test.c Normal file
View File

@ -0,0 +1,179 @@
/* main-seed-test.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file main-seed-test.c
* \author Daniel Otte
* \email daniel.otte@rub.de
* \date 2007-06-01
* \brief test suit for SEED
* \par License
* GPLv3 or later
*
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "cli.h"
#include "dump.h"
#include "uart_lowlevel.h"
#include "sysclock.h"
#include "hw_gptm.h"
#include "seed.h"
#include "nessie_bc_test.h"
#include "performance_test.h"
#include "bcal-performance.h"
#include "bcal_seed.h"
char* algo_name = "Seed";
void uart0_putc(char byte){
uart_putc(UART_0, byte);
}
char uart0_getc(void){
return uart_getc(UART_0);
}
const bcdesc_t* algolist[] = {
(bcdesc_t*)&seed_desc,
NULL
};
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
void seed_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
seed_init(key, ctx);
}
void testrun_nessie_seed(void){
nessie_bc_ctx.blocksize_B = 16;
nessie_bc_ctx.keysize_b = 128;
nessie_bc_ctx.name = algo_name;
nessie_bc_ctx.ctx_size_B = sizeof(seed_ctx_t);
nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)seed_enc;
nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)seed_dec;
nessie_bc_ctx.cipher_genctx = (nessie_bc_gen_fpt)seed_genctx_dummy;
nessie_bc_run();
}
void testrun_performance_seed(void){
bcal_performance_multiple(algolist);
}
/*****************************************************************************
* self tests *
*****************************************************************************/
void testencrypt(uint8_t* block, uint8_t* key){
seed_ctx_t ctx;
cli_putstr("\r\n==testy-encrypt==\r\n key: ");
cli_hexdump(key,16);
seed_init(key, &ctx);
cli_putstr("\r\n plain: ");
cli_hexdump(block,16);
seed_enc(block, &ctx);
cli_putstr("\r\n crypt: ");
cli_hexdump(block,16);
}
void testdecrypt(uint8_t* block, uint8_t* key){
seed_ctx_t ctx;
cli_putstr("\r\n==testy-decrypt==\r\n key: ");
cli_hexdump(key,16);
seed_init(key, &ctx);
cli_putstr("\r\n crypt: ");
cli_hexdump(block,16);
seed_dec(block, &ctx);
cli_putstr("\r\n plain: ");
cli_hexdump(block,16);
}
void testrun_seed(void){
uint8_t keys[4][16]=
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
{ 0x47, 0x06, 0x48, 0x08, 0x51, 0xE6, 0x1B, 0xE8,
0x5D, 0x74, 0xBF, 0xB3, 0xFD, 0x95, 0x61, 0x85 },
{ 0x28, 0xDB, 0xC3, 0xBC, 0x49, 0xFF, 0xD8, 0x7D,
0xCF, 0xA5, 0x09, 0xB1, 0x1D, 0x42, 0x2B, 0xE7,}
};
uint8_t datas[4][16]=
{ { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x83, 0xA2, 0xF8, 0xA2, 0x88, 0x64, 0x1F, 0xB9,
0xA4, 0xE9, 0xA5, 0xCC, 0x2F, 0x13, 0x1C, 0x7D },
{ 0xB4, 0x1E, 0x6B, 0xE2, 0xEB, 0xA8, 0x4A, 0x14,
0x8E, 0x2E, 0xED, 0x84, 0x59, 0x3C, 0x5E, 0xC7 }
};
uint8_t i=0;
for(i=0; i<4; ++i){
testencrypt(datas[i],keys[i]);
testdecrypt(datas[i],keys[i]);
}
}
/*****************************************************************************
* main *
*****************************************************************************/
const char nessie_str[] = "nessie";
const char test_str[] = "test";
const char performance_str[] = "performance";
const char echo_str[] = "echo";
cmdlist_entry_t cmdlist[] = {
{ nessie_str, NULL, testrun_nessie_seed},
{ test_str, NULL, testrun_seed},
{ performance_str, NULL, testrun_performance_seed},
{ echo_str, (void*)1, (void_fpt)echo_ctrl},
{ NULL, NULL, NULL}
};
int main (void){
sysclk_set_freq(SYS_FREQ);
sysclk_mosc_verify_enable();
uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
gptm_set_timer_32periodic(TIMER0);
cli_rx = uart0_getc;
cli_tx = uart0_putc;
for(;;){
cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
cli_putstr(algo_name);
cli_putstr("; ");
cli_putstr(__DATE__);
cli_putc(' ');
cli_putstr(__TIME__);
cli_putstr(")\r\nloaded and running\r\n");
cmd_interface(cmdlist);
}
}

File diff suppressed because it is too large Load Diff