fixing some warnings (AES); simplifyning AES headers (now simply include "aes.h"); some renaming in the debug module
This commit is contained in:
parent
ca71e48e8e
commit
aa060d30f8
33
aes/aes.h
33
aes/aes.h
|
@ -29,28 +29,15 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct{
|
#include "aes_types.h"
|
||||||
uint8_t ks[16];
|
#include "aes128_enc.h"
|
||||||
} aes_roundkey_t;
|
#include "aes192_enc.h"
|
||||||
|
#include "aes256_enc.h"
|
||||||
typedef struct{
|
#include "aes128_dec.h"
|
||||||
aes_roundkey_t key[10+1];
|
#include "aes192_dec.h"
|
||||||
} aes128_ctx_t;
|
#include "aes256_dec.h"
|
||||||
|
#include "aes_enc.h"
|
||||||
typedef struct{
|
#include "aes_dec.h"
|
||||||
aes_roundkey_t key[12+1];
|
#include "aes_keyschedule.h"
|
||||||
} aes192_ctx_t;
|
|
||||||
|
|
||||||
typedef struct{
|
|
||||||
aes_roundkey_t key[14+1];
|
|
||||||
} aes256_ctx_t;
|
|
||||||
|
|
||||||
typedef struct{
|
|
||||||
aes_roundkey_t key[1]; /* just to avoid the warning */
|
|
||||||
} aes_genctx_t;
|
|
||||||
|
|
||||||
typedef struct{
|
|
||||||
uint8_t s[16];
|
|
||||||
} aes_cipher_state_t;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,10 +28,10 @@
|
||||||
#ifndef AES128_DEC_H_
|
#ifndef AES128_DEC_H_
|
||||||
#define AES128_DEC_H_
|
#define AES128_DEC_H_
|
||||||
|
|
||||||
#include "aes.h"
|
#include "aes_types.h"
|
||||||
#include "aes_dec.h"
|
#include "aes_dec.h"
|
||||||
|
|
||||||
/** \fn void aes128_dec(void* buffer, aes128_ctx_t* ctx)
|
/**
|
||||||
* \brief decrypt with 128 bit key.
|
* \brief decrypt with 128 bit key.
|
||||||
*
|
*
|
||||||
* This function decrypts one block with the AES algorithm under control of
|
* This function decrypts one block with the AES algorithm under control of
|
||||||
|
|
|
@ -28,11 +28,11 @@
|
||||||
#ifndef AES128_ENC_H_
|
#ifndef AES128_ENC_H_
|
||||||
#define AES128_ENC_H_
|
#define AES128_ENC_H_
|
||||||
|
|
||||||
#include "aes.h"
|
#include "aes_types.h"
|
||||||
#include "aes_enc.h"
|
#include "aes_enc.h"
|
||||||
|
|
||||||
|
|
||||||
/** \fn void aes128_enc(void* buffer, aes128_ctx_t* ctx)
|
/**
|
||||||
* \brief encrypt with 128 bit key.
|
* \brief encrypt with 128 bit key.
|
||||||
*
|
*
|
||||||
* This function encrypts one block with the AES algorithm under control of
|
* This function encrypts one block with the AES algorithm under control of
|
||||||
|
|
|
@ -28,10 +28,10 @@
|
||||||
#ifndef AES192_DEC_H_
|
#ifndef AES192_DEC_H_
|
||||||
#define AES192_DEC_H_
|
#define AES192_DEC_H_
|
||||||
|
|
||||||
#include "aes.h"
|
#include "aes_types.h"
|
||||||
#include "aes_dec.h"
|
#include "aes_dec.h"
|
||||||
|
|
||||||
/** \fn void aes192_dec(void* buffer, aes192_ctx_t* ctx)
|
/**
|
||||||
* \brief decrypt with 192 bit key.
|
* \brief decrypt with 192 bit key.
|
||||||
*
|
*
|
||||||
* This function decrypts one block with the AES algorithm under control of
|
* This function decrypts one block with the AES algorithm under control of
|
||||||
|
|
|
@ -28,11 +28,11 @@
|
||||||
#ifndef AES192_ENC_H_
|
#ifndef AES192_ENC_H_
|
||||||
#define AES192_ENC_H_
|
#define AES192_ENC_H_
|
||||||
|
|
||||||
#include "aes.h"
|
#include "aes_types.h"
|
||||||
#include "aes_enc.h"
|
#include "aes_enc.h"
|
||||||
|
|
||||||
|
|
||||||
/** \fn void aes192_enc(void* buffer, aes192_ctx_t* ctx)
|
/**
|
||||||
* \brief encrypt with 192 bit key.
|
* \brief encrypt with 192 bit key.
|
||||||
*
|
*
|
||||||
* This function encrypts one block with the AES algorithm under control of
|
* This function encrypts one block with the AES algorithm under control of
|
||||||
|
|
|
@ -28,10 +28,10 @@
|
||||||
#ifndef AES256_DEC_H_
|
#ifndef AES256_DEC_H_
|
||||||
#define AES256_DEC_H_
|
#define AES256_DEC_H_
|
||||||
|
|
||||||
#include "aes.h"
|
#include "aes_types.h"
|
||||||
#include "aes_dec.h"
|
#include "aes_dec.h"
|
||||||
|
|
||||||
/** \fn void aes256_dec(void* buffer, aes256_ctx_t* ctx)
|
/**
|
||||||
* \brief decrypt with 256 bit key.
|
* \brief decrypt with 256 bit key.
|
||||||
*
|
*
|
||||||
* This function decrypts one block with the AES algorithm under control of
|
* This function decrypts one block with the AES algorithm under control of
|
||||||
|
|
|
@ -28,11 +28,11 @@
|
||||||
#ifndef AES256_ENC_H_
|
#ifndef AES256_ENC_H_
|
||||||
#define AES256_ENC_H_
|
#define AES256_ENC_H_
|
||||||
|
|
||||||
#include "aes.h"
|
#include "aes_types.h"
|
||||||
#include "aes_enc.h"
|
#include "aes_enc.h"
|
||||||
|
|
||||||
|
|
||||||
/** \fn void aes256_enc(void* buffer, aes256_ctx_t* ctx)
|
/**
|
||||||
* \brief encrypt with 256 bit key.
|
* \brief encrypt with 256 bit key.
|
||||||
*
|
*
|
||||||
* This function encrypts one block with the AES algorithm under control of
|
* This function encrypts one block with the AES algorithm under control of
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef AES_DEC_H_
|
#ifndef AES_DEC_H_
|
||||||
#define AES_DEC_H_
|
#define AES_DEC_H_
|
||||||
#include "aes.h"
|
#include "aes_types.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef AES_ENC_H_
|
#ifndef AES_ENC_H_
|
||||||
#define AES_ENC_H_
|
#define AES_ENC_H_
|
||||||
#include "aes.h"
|
#include "aes_types.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,32 +49,35 @@ uint8_t rc_tab[] PROGMEM = { 0x01, 0x02, 0x04, 0x08,
|
||||||
void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx){
|
void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx){
|
||||||
uint8_t hi,i,nk, next_nk;
|
uint8_t hi,i,nk, next_nk;
|
||||||
uint8_t rc=0;
|
uint8_t rc=0;
|
||||||
uint8_t tmp[4];
|
union {
|
||||||
|
uint32_t v32;
|
||||||
|
uint8_t v8[4];
|
||||||
|
} tmp;
|
||||||
nk=keysize_b>>5; /* 4, 6, 8 */
|
nk=keysize_b>>5; /* 4, 6, 8 */
|
||||||
hi=4*(nk+6+1);
|
hi=4*(nk+6+1);
|
||||||
memcpy(ctx, key, keysize_b/8);
|
memcpy(ctx, key, keysize_b/8);
|
||||||
next_nk = nk;
|
next_nk = nk;
|
||||||
for(i=nk;i<hi;++i){
|
for(i=nk;i<hi;++i){
|
||||||
*((uint32_t*)tmp) = ((uint32_t*)(ctx->key[0].ks))[i-1];
|
tmp.v32 = ((uint32_t*)(ctx->key[0].ks))[i-1];
|
||||||
if(i!=next_nk){
|
if(i!=next_nk){
|
||||||
if(nk==8 && i%8==4){
|
if(nk==8 && i%8==4){
|
||||||
tmp[0] = pgm_read_byte(aes_sbox+tmp[0]);
|
tmp.v8[0] = pgm_read_byte(aes_sbox+tmp.v8[0]);
|
||||||
tmp[1] = pgm_read_byte(aes_sbox+tmp[1]);
|
tmp.v8[1] = pgm_read_byte(aes_sbox+tmp.v8[1]);
|
||||||
tmp[2] = pgm_read_byte(aes_sbox+tmp[2]);
|
tmp.v8[2] = pgm_read_byte(aes_sbox+tmp.v8[2]);
|
||||||
tmp[3] = pgm_read_byte(aes_sbox+tmp[3]);
|
tmp.v8[3] = pgm_read_byte(aes_sbox+tmp.v8[3]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
next_nk += nk;
|
next_nk += nk;
|
||||||
aes_rotword(tmp);
|
aes_rotword(&(tmp.v32));
|
||||||
tmp[0] = pgm_read_byte(aes_sbox+tmp[0]);
|
tmp.v8[0] = pgm_read_byte(aes_sbox+tmp.v8[0]);
|
||||||
tmp[1] = pgm_read_byte(aes_sbox+tmp[1]);
|
tmp.v8[1] = pgm_read_byte(aes_sbox+tmp.v8[1]);
|
||||||
tmp[2] = pgm_read_byte(aes_sbox+tmp[2]);
|
tmp.v8[2] = pgm_read_byte(aes_sbox+tmp.v8[2]);
|
||||||
tmp[3] = pgm_read_byte(aes_sbox+tmp[3]);
|
tmp.v8[3] = pgm_read_byte(aes_sbox+tmp.v8[3]);
|
||||||
tmp[0] ^= pgm_read_byte(rc_tab+rc);
|
tmp.v8[0] ^= pgm_read_byte(rc_tab+rc);
|
||||||
rc++;
|
rc++;
|
||||||
}
|
}
|
||||||
((uint32_t*)(ctx->key[0].ks))[i] = ((uint32_t*)(ctx->key[0].ks))[i-nk]
|
((uint32_t*)(ctx->key[0].ks))[i] = ((uint32_t*)(ctx->key[0].ks))[i-nk]
|
||||||
^ *((uint32_t*)tmp);
|
^ tmp.v32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
#ifndef AES_KEYSCHEDULE_H_
|
#ifndef AES_KEYSCHEDULE_H_
|
||||||
#define AES_KEYSCHEDULE_H_
|
#define AES_KEYSCHEDULE_H_
|
||||||
|
|
||||||
#include "aes.h"
|
#include "aes_types.h"
|
||||||
/** \fn void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx)
|
/**
|
||||||
* \brief initialize the keyschedule
|
* \brief initialize the keyschedule
|
||||||
*
|
*
|
||||||
* This function computes the keyschedule from a given key with a given length
|
* This function computes the keyschedule from a given key with a given length
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
*/
|
*/
|
||||||
void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx);
|
void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx);
|
||||||
|
|
||||||
/** \fn void aes128_init(const void* key, aes128_ctx_t* ctx)
|
/**
|
||||||
* \brief initialize the keyschedule for 128 bit key
|
* \brief initialize the keyschedule for 128 bit key
|
||||||
*
|
*
|
||||||
* This function computes the keyschedule from a given 128 bit key
|
* This function computes the keyschedule from a given 128 bit key
|
||||||
|
@ -51,7 +51,7 @@ void aes_init(const void* key, uint16_t keysize_b, aes_genctx_t* ctx);
|
||||||
*/
|
*/
|
||||||
void aes128_init(const void* key, aes128_ctx_t* ctx);
|
void aes128_init(const void* key, aes128_ctx_t* ctx);
|
||||||
|
|
||||||
/** \fn void aes192_init(const void* key, aes192_ctx_t* ctx)
|
/**
|
||||||
* \brief initialize the keyschedule for 192 bit key
|
* \brief initialize the keyschedule for 192 bit key
|
||||||
*
|
*
|
||||||
* This function computes the keyschedule from a given 192 bit key
|
* This function computes the keyschedule from a given 192 bit key
|
||||||
|
@ -61,7 +61,7 @@ void aes128_init(const void* key, aes128_ctx_t* ctx);
|
||||||
*/
|
*/
|
||||||
void aes192_init(const void* key, aes192_ctx_t* ctx);
|
void aes192_init(const void* key, aes192_ctx_t* ctx);
|
||||||
|
|
||||||
/** \fn void aes256_init(const void* key, aes256_ctx_t* ctx)
|
/**
|
||||||
* \brief initialize the keyschedule for 256 bit key
|
* \brief initialize the keyschedule for 256 bit key
|
||||||
*
|
*
|
||||||
* This function computes the keyschedule from a given 256 bit key
|
* This function computes the keyschedule from a given 256 bit key
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* serial-tools.h */
|
/* aes.h */
|
||||||
/*
|
/*
|
||||||
This file is part of the AVR-Crypto-Lib.
|
This file is part of the AVR-Crypto-Lib.
|
||||||
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
|
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
|
||||||
|
@ -16,12 +16,41 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef SERIALTOOLS_H_
|
/**
|
||||||
#define SERIALTOOLS_H_
|
* \file aes_types.h
|
||||||
|
* \email daniel.otte@rub.de
|
||||||
|
* \author Daniel Otte
|
||||||
|
* \date 2008-12-30
|
||||||
|
* \license GPLv3 or later
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef AES_TYPES_H_
|
||||||
|
#define AES_TYPES_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
int getnextwordn(char *s, int n); /* words are seperated by spaces */
|
typedef struct{
|
||||||
void readhex2buffer(void* buffer, int n);
|
uint8_t ks[16];
|
||||||
void uart_putptr(void* p);
|
} aes_roundkey_t;
|
||||||
|
|
||||||
#endif /*SERIALTOOLS_H_*/
|
typedef struct{
|
||||||
|
aes_roundkey_t key[10+1];
|
||||||
|
} aes128_ctx_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
aes_roundkey_t key[12+1];
|
||||||
|
} aes192_ctx_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
aes_roundkey_t key[14+1];
|
||||||
|
} aes256_ctx_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
aes_roundkey_t key[1]; /* just to avoid the warning */
|
||||||
|
} aes_genctx_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t s[16];
|
||||||
|
} aes_cipher_state_t;
|
||||||
|
|
||||||
|
#endif
|
|
@ -213,24 +213,25 @@ uint32_t k_lut[] PROGMEM = {
|
||||||
static
|
static
|
||||||
uint32_t bmw_small_expand1(uint8_t j, const uint32_t* q, const void* m, const void* h){
|
uint32_t bmw_small_expand1(uint8_t j, const uint32_t* q, const void* m, const void* h){
|
||||||
uint32_t(*s[])(uint32_t) = {bmw_small_s1, bmw_small_s2, bmw_small_s3, bmw_small_s0};
|
uint32_t(*s[])(uint32_t) = {bmw_small_s1, bmw_small_s2, bmw_small_s3, bmw_small_s0};
|
||||||
uint32_t r=0;
|
uint32_t r;
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
/* r = 0x05555555*(j+16); */
|
/* r = 0x05555555*(j+16); */
|
||||||
for(i=0; i<16; ++i){
|
|
||||||
r += s[i%4](q[j+i]);
|
|
||||||
}
|
|
||||||
#if TWEAK
|
#if TWEAK
|
||||||
r += ( ROTL32(((uint32_t*)m)[j&0xf], ((j+0)&0xf)+1 )
|
r = ( ROTL32(((uint32_t*)m)[j&0xf], ((j+0)&0xf)+1 )
|
||||||
+ ROTL32(((uint32_t*)m)[(j+3)&0xf], ((j+3)&0xf)+1 )
|
+ ROTL32(((uint32_t*)m)[(j+3)&0xf], ((j+3)&0xf)+1 )
|
||||||
- ROTL32(((uint32_t*)m)[(j+10)&0xf], ((j+10)&0xf)+1 )
|
- ROTL32(((uint32_t*)m)[(j+10)&0xf], ((j+10)&0xf)+1 )
|
||||||
+ pgm_read_dword(k_lut+j)
|
+ pgm_read_dword(k_lut+j)
|
||||||
) ^ ((uint32_t*)h)[(j+7)&0xf];
|
) ^ ((uint32_t*)h)[(j+7)&0xf];
|
||||||
#else
|
#else
|
||||||
r += pgm_read_dword(k_lut+j);
|
r = pgm_read_dword(k_lut+j);
|
||||||
r += ((uint32_t*)m)[j&0xf];
|
r += ((uint32_t*)m)[j&0xf];
|
||||||
r += ((uint32_t*)m)[(j+3)&0xf];
|
r += ((uint32_t*)m)[(j+3)&0xf];
|
||||||
r -= ((uint32_t*)m)[(j+10)&0xf];
|
r -= ((uint32_t*)m)[(j+10)&0xf];
|
||||||
#endif
|
#endif
|
||||||
|
for(i=0; i<16; ++i){
|
||||||
|
r += s[i%4](q[j+i]);
|
||||||
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
q[ 0] = (+ h[ 5] - h[ 7] + h[10] + h[13] + h[14]);
|
q[ 0] = (+ h[ 5] - h[ 7] + h[10] + h[13] + h[14]);
|
||||||
q[ 1] = (+ h[ 6] - h[ 8] + h[11] + h[14] - h[15]);
|
q[ 1] = (+ h[ 6] - h[ 8] + h[11] + h[14] - h[15]);
|
||||||
q[ 2] = (+ h[ 7] + h[ 9] - h[12] + h[15] + h[ 0]);
|
q[ 2] = (+ h[ 7] + h[ 9] - h[12] + h[15] + h[ 0]);
|
||||||
|
|
8
config.h
8
config.h
|
@ -20,16 +20,14 @@
|
||||||
#define __CONFIG_H__
|
#define __CONFIG_H__
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
// #define F_CPU 20000000
|
// #define F_CPU 20000000
|
||||||
#define F_CPU 16000000 /* Oszillator-Frequenz in Hz */
|
// #define F_CPU 16000000 /* oscillator-frequency in Hz */
|
||||||
// #define F_CPU 14745600
|
// #define F_CPU 14745600
|
||||||
|
#define F_CPU 20000000 /* this is out of spec but lets try it */
|
||||||
|
|
||||||
|
#define DEBUG_METHOD uart
|
||||||
|
|
||||||
#include "uart_defs.h"
|
#include "uart_defs.h"
|
||||||
|
|
||||||
#define DEBUG uart
|
|
||||||
|
|
||||||
#undef UART_LEDS
|
|
||||||
|
|
||||||
#define UART0_I 1
|
#define UART0_I 1
|
||||||
#define UART0_BAUD_RATE 38400
|
#define UART0_BAUD_RATE 38400
|
||||||
#define UART0_PARATY UART_PARATY_NONE
|
#define UART0_PARATY UART_PARATY_NONE
|
||||||
|
|
2
debug.h
2
debug.h
|
@ -19,7 +19,7 @@
|
||||||
#ifndef DEBUG_H_
|
#ifndef DEBUG_H_
|
||||||
#define DEBUG_H_
|
#define DEBUG_H_
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_METHOD
|
||||||
#define DEBUG_INIT() debug_init()
|
#define DEBUG_INIT() debug_init()
|
||||||
#define DEBUG_C(_c) debug_char(_c)
|
#define DEBUG_C(_c) debug_char(_c)
|
||||||
#define DEBUG_S(_s) debug_str(_s)
|
#define DEBUG_S(_s) debug_str(_s)
|
||||||
|
|
|
@ -121,13 +121,13 @@ void groestl_small_rounds(uint8_t *m, uint8_t q){
|
||||||
void groestl224_init(groestl224_ctx_t* ctx){
|
void groestl224_init(groestl224_ctx_t* ctx){
|
||||||
memset(ctx->h, 0, 8*8);
|
memset(ctx->h, 0, 8*8);
|
||||||
ctx->h[8*8-1] = 224;
|
ctx->h[8*8-1] = 224;
|
||||||
ctx->counter = 0;
|
ctx->counter = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void groestl256_init(groestl256_ctx_t* ctx){
|
void groestl256_init(groestl256_ctx_t* ctx){
|
||||||
memset(ctx->h, 0, 8*8);
|
memset(ctx->h, 0, 8*8);
|
||||||
ctx->h[8*8-2] = 1;
|
ctx->h[8*8-2] = 1;
|
||||||
ctx->counter = 0;
|
ctx->counter = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void groestl_small_nextBlock(groestl_small_ctx_t* ctx, const void* block){
|
void groestl_small_nextBlock(groestl_small_ctx_t* ctx, const void* block){
|
||||||
|
@ -157,12 +157,12 @@ void groestl_small_lastBlock(groestl_small_ctx_t* ctx, const void* block, uint16
|
||||||
}
|
}
|
||||||
memset(buffer, 0, 64);
|
memset(buffer, 0, 64);
|
||||||
memcpy(buffer, block, (length_b+7)/8);
|
memcpy(buffer, block, (length_b+7)/8);
|
||||||
buffer[length_b/8] |= 0x80>>(length_b%8);
|
buffer[length_b/8] |= 0x80>>(length_b&0x7);
|
||||||
if(length_b>512-65){
|
if(length_b>512-65){
|
||||||
groestl_small_nextBlock(ctx, buffer);
|
groestl_small_nextBlock(ctx, buffer);
|
||||||
memset(buffer, 0, 64-4);
|
memset(buffer, 0, 64-4);
|
||||||
}
|
}
|
||||||
ctx->counter++;
|
// ctx->counter++;
|
||||||
buffer[64-1] = (uint8_t)(ctx->counter);
|
buffer[64-1] = (uint8_t)(ctx->counter);
|
||||||
buffer[64-2] = (uint8_t)((ctx->counter)>>8);
|
buffer[64-2] = (uint8_t)((ctx->counter)>>8);
|
||||||
buffer[64-3] = (uint8_t)((ctx->counter)>>16);
|
buffer[64-3] = (uint8_t)((ctx->counter)>>16);
|
||||||
|
|
|
@ -57,6 +57,7 @@ void hfal_performance(const hfdesc_t* hd){
|
||||||
if(hf.type!=HFDESC_TYPE_HASHFUNCTION)
|
if(hf.type!=HFDESC_TYPE_HASHFUNCTION)
|
||||||
return;
|
return;
|
||||||
calibrateTimer();
|
calibrateTimer();
|
||||||
|
print_overhead();
|
||||||
cli_putstr_P(PSTR("\r\n\r\n === "));
|
cli_putstr_P(PSTR("\r\n\r\n === "));
|
||||||
cli_putstr_P(hf.name);
|
cli_putstr_P(hf.name);
|
||||||
cli_putstr_P(PSTR(" performance === "
|
cli_putstr_P(PSTR(" performance === "
|
||||||
|
|
|
@ -25,8 +25,12 @@ require 'serialport'
|
||||||
require 'getopt/std'
|
require 'getopt/std'
|
||||||
|
|
||||||
$buffer_size = 0
|
$buffer_size = 0
|
||||||
|
$conffile_check = Hash.new
|
||||||
|
$conffile_check.default = 0
|
||||||
|
|
||||||
def readconfigfile(fname, conf)
|
def readconfigfile(fname, conf)
|
||||||
|
return conf if $conffile_check[fname]==1
|
||||||
|
$conffile_check[fname]=1
|
||||||
section = "default"
|
section = "default"
|
||||||
if not File.exists?(fname)
|
if not File.exists?(fname)
|
||||||
return conf
|
return conf
|
||||||
|
@ -42,8 +46,12 @@ def readconfigfile(fname, conf)
|
||||||
end
|
end
|
||||||
next if not /=/.match(line)
|
next if not /=/.match(line)
|
||||||
m=/[\s]*([^\s]*)[\s]*=[\s]*([^\s]*)/.match(line)
|
m=/[\s]*([^\s]*)[\s]*=[\s]*([^\s]*)/.match(line)
|
||||||
|
if m[1]=="include"
|
||||||
|
Dir.glob(m[2]){ |fn| conf = readconfigfile(fn, conf) }
|
||||||
|
else
|
||||||
conf[section][m[1]] = m[2]
|
conf[section][m[1]] = m[2]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
file.close()
|
file.close()
|
||||||
return conf
|
return conf
|
||||||
end
|
end
|
||||||
|
@ -96,6 +104,7 @@ def send_md(md_string)
|
||||||
for i in 0..md_string.length-1
|
for i in 0..md_string.length-1
|
||||||
$sp.print(md_string[i].chr)
|
$sp.print(md_string[i].chr)
|
||||||
# print("DBG s: "+ md_string[i].chr) if $debug
|
# print("DBG s: "+ md_string[i].chr) if $debug
|
||||||
|
sleep(0.01)
|
||||||
if((i%($buffer_size*2)==0)&&(i!=0))
|
if((i%($buffer_size*2)==0)&&(i!=0))
|
||||||
begin
|
begin
|
||||||
line=$sp.gets()
|
line=$sp.gets()
|
||||||
|
@ -148,7 +157,8 @@ def run_test(filename, skip=0)
|
||||||
putc('*')
|
putc('*')
|
||||||
else
|
else
|
||||||
putc('!')
|
putc('!')
|
||||||
printf("<%d>",len)
|
# printf("<%d>",len)
|
||||||
|
printf("\nError @%05d: %s \n != %s - ",len, a, b)
|
||||||
nerrors += 1
|
nerrors += 1
|
||||||
end
|
end
|
||||||
pos += 1
|
pos += 1
|
||||||
|
@ -156,10 +166,14 @@ def run_test(filename, skip=0)
|
||||||
return nerrors.to_i
|
return nerrors.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts = Getopt::Std.getopts("s:f:i:hdca")
|
||||||
|
|
||||||
conf = Hash.new
|
conf = Hash.new
|
||||||
conf = readconfigfile("/etc/testport.conf", conf)
|
conf = readconfigfile("/etc/testport.conf", conf)
|
||||||
conf = readconfigfile("~/.testport.conf", conf)
|
conf = readconfigfile("~/.testport.conf", conf)
|
||||||
conf = readconfigfile("testport.conf", conf)
|
conf = readconfigfile("testport.conf", conf)
|
||||||
|
conf = readconfigfile(opts["f"], conf) if opts["f"]
|
||||||
|
|
||||||
#puts conf.inspect
|
#puts conf.inspect
|
||||||
|
|
||||||
puts("serial port interface version: " + SerialPort::VERSION);
|
puts("serial port interface version: " + SerialPort::VERSION);
|
||||||
|
@ -190,7 +204,19 @@ reset_system()
|
||||||
algos=scan_system()
|
algos=scan_system()
|
||||||
#puts algos.inspect
|
#puts algos.inspect
|
||||||
|
|
||||||
algos.sort.each do |algoa|
|
if opts["s"]
|
||||||
|
algos_rev = algos.invert
|
||||||
|
algo_tasks = Array.new
|
||||||
|
opts["s"].each_byte{ |x|
|
||||||
|
if algos_rev[x.chr]
|
||||||
|
algo_tasks << [algos_rev[x.chr],x.chr]
|
||||||
|
end
|
||||||
|
}
|
||||||
|
else
|
||||||
|
algo_tasks=algos.sort
|
||||||
|
end
|
||||||
|
|
||||||
|
algo_tasks.each do |algoa|
|
||||||
algo = algoa[0]
|
algo = algoa[0]
|
||||||
if conf[algo]==nil
|
if conf[algo]==nil
|
||||||
puts("No test-set defined for #{algo} \r\n")
|
puts("No test-set defined for #{algo} \r\n")
|
||||||
|
@ -202,7 +228,9 @@ algos.sort.each do |algoa|
|
||||||
puts("Testing #{algo} with #{conf[algo]["file_#{i}"]}")
|
puts("Testing #{algo} with #{conf[algo]["file_#{i}"]}")
|
||||||
reset_system()
|
reset_system()
|
||||||
init_system(algoa[1])
|
init_system(algoa[1])
|
||||||
nerrors=run_test(conf[algo]["file_#{i}"], 0)
|
skip=0
|
||||||
|
skip=opts["i"].to_i if opts["i"]
|
||||||
|
nerrors=run_test(conf[algo]["file_#{i}"], skip)
|
||||||
if nerrors == 0
|
if nerrors == 0
|
||||||
puts("\n[ok]")
|
puts("\n[ok]")
|
||||||
logfile.puts("[ok] "+conf[algo]["file_#{i}"]+ " ("+Time.now.to_s()+")")
|
logfile.puts("[ok] "+conf[algo]["file_#{i}"]+ " ("+Time.now.to_s()+")")
|
||||||
|
|
|
@ -20,16 +20,14 @@
|
||||||
#define __CONFIG_H__
|
#define __CONFIG_H__
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
// #define F_CPU 20000000
|
// #define F_CPU 20000000
|
||||||
#define F_CPU 16000000 /* Oszillator-Frequenz in Hz */
|
// #define F_CPU 16000000 /* oscillator-frequency in Hz */
|
||||||
// #define F_CPU 14745600
|
// #define F_CPU 14745600
|
||||||
|
#define F_CPU 20000000 /* this is out of spec but lets try it */
|
||||||
|
|
||||||
|
#define DEBUG_METHOD uart
|
||||||
|
|
||||||
#include "uart_defs.h"
|
#include "uart_defs.h"
|
||||||
|
|
||||||
#define DEBUG uart
|
|
||||||
|
|
||||||
#undef UART_LEDS
|
|
||||||
|
|
||||||
#define UART0_I 1
|
#define UART0_I 1
|
||||||
#define UART0_BAUD_RATE 38400
|
#define UART0_BAUD_RATE 38400
|
||||||
#define UART0_PARATY UART_PARATY_NONE
|
#define UART0_PARATY UART_PARATY_NONE
|
||||||
|
|
|
@ -23,15 +23,15 @@
|
||||||
****************************/
|
****************************/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#if DEBUG == uart
|
#if DEBUG_METHOD == uart
|
||||||
#include "uart_i.h"
|
#include "uart_i.h"
|
||||||
#else
|
#else
|
||||||
#error "Your DEBUG methode is not suported!"
|
#error "Your DEBUG methode is not suported!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG_METHOD
|
||||||
void debug_init(void){
|
void debug_init(void){
|
||||||
#if DBUG==uart
|
#if DEBUG_METHOD==uart
|
||||||
uart0_init();
|
uart0_init();
|
||||||
#else
|
#else
|
||||||
#error "Your DEBUG methode is not suported!"
|
#error "Your DEBUG methode is not suported!"
|
||||||
|
|
|
@ -27,13 +27,6 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include "aes/aes.h"
|
#include "aes/aes.h"
|
||||||
#include "aes/aes128_enc.h"
|
|
||||||
#include "aes/aes128_dec.h"
|
|
||||||
#include "aes/aes192_enc.h"
|
|
||||||
#include "aes/aes192_dec.h"
|
|
||||||
#include "aes/aes256_enc.h"
|
|
||||||
#include "aes/aes256_dec.h"
|
|
||||||
#include "aes/aes_keyschedule.h"
|
|
||||||
|
|
||||||
#include "nessie_bc_test.h"
|
#include "nessie_bc_test.h"
|
||||||
#include "cli.h"
|
#include "cli.h"
|
||||||
|
|
|
@ -27,10 +27,6 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include "aes/aes.h"
|
#include "aes/aes.h"
|
||||||
#include "aes/aes128_enc.h"
|
|
||||||
#include "aes/aes128_dec.h"
|
|
||||||
#include "aes/aes_keyschedule.h"
|
|
||||||
|
|
||||||
#include "nessie_bc_test.h"
|
#include "nessie_bc_test.h"
|
||||||
#include "cli.h"
|
#include "cli.h"
|
||||||
#include "performance_test.h"
|
#include "performance_test.h"
|
||||||
|
|
|
@ -27,9 +27,6 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include "aes/aes.h"
|
#include "aes/aes.h"
|
||||||
#include "aes/aes192_enc.h"
|
|
||||||
#include "aes/aes192_dec.h"
|
|
||||||
#include "aes/aes_keyschedule.h"
|
|
||||||
|
|
||||||
#include "nessie_bc_test.h"
|
#include "nessie_bc_test.h"
|
||||||
#include "cli.h"
|
#include "cli.h"
|
||||||
|
|
|
@ -27,9 +27,6 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include "aes/aes.h"
|
#include "aes/aes.h"
|
||||||
#include "aes/aes256_enc.h"
|
|
||||||
#include "aes/aes256_dec.h"
|
|
||||||
#include "aes/aes_keyschedule.h"
|
|
||||||
|
|
||||||
#include "nessie_bc_test.h"
|
#include "nessie_bc_test.h"
|
||||||
#include "cli.h"
|
#include "cli.h"
|
||||||
|
|
|
@ -98,6 +98,19 @@ void testlshort(void){
|
||||||
groestl512_test("abc", 24);
|
groestl512_test("abc", 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test505(void){
|
||||||
|
uint8_t data[] = {
|
||||||
|
0x84, 0x73, 0xDC, 0x53, 0x82, 0xDE, 0x32, 0x95,
|
||||||
|
0x7E, 0x3A, 0x15, 0xCA, 0x3D, 0x79, 0x1C, 0x67,
|
||||||
|
0xD2, 0x0C, 0xF9, 0xEF, 0xBE, 0x3E, 0x46, 0x40,
|
||||||
|
0x7D, 0xCA, 0x5D, 0x02, 0x63, 0x5A, 0xC8, 0x6D,
|
||||||
|
0x2E, 0x0B, 0x22, 0xC7, 0x6D, 0x7D, 0x08, 0x0D,
|
||||||
|
0x36, 0x2E, 0x82, 0x75, 0x89, 0x14, 0xCC, 0x0A,
|
||||||
|
0xE2, 0xB8, 0x9B, 0xD3, 0x5F, 0x71, 0xD8, 0x44,
|
||||||
|
0x92, 0xD9, 0x43, 0x07, 0x42, 0x78, 0x9C, 0x80 };
|
||||||
|
groestl224_test(data, 505);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void performance_groestl(void){
|
void performance_groestl(void){
|
||||||
hfal_performance_multiple(algolist);
|
hfal_performance_multiple(algolist);
|
||||||
|
@ -112,6 +125,7 @@ const char nessie_str[] PROGMEM = "nessie";
|
||||||
const char test_str[] PROGMEM = "test";
|
const char test_str[] PROGMEM = "test";
|
||||||
const char testshort_str[] PROGMEM = "short";
|
const char testshort_str[] PROGMEM = "short";
|
||||||
const char testlshort_str[] PROGMEM = "lshort";
|
const char testlshort_str[] PROGMEM = "lshort";
|
||||||
|
const char test505_str[] PROGMEM = "test505";
|
||||||
const char performance_str[] PROGMEM = "performance";
|
const char performance_str[] PROGMEM = "performance";
|
||||||
const char echo_str[] PROGMEM = "echo";
|
const char echo_str[] PROGMEM = "echo";
|
||||||
const char shavs_list_str[] PROGMEM = "shavs_list";
|
const char shavs_list_str[] PROGMEM = "shavs_list";
|
||||||
|
@ -123,6 +137,7 @@ cmdlist_entry_t cmdlist[] PROGMEM = {
|
||||||
{ test_str, NULL, testrun_stdtest_groestl},
|
{ test_str, NULL, testrun_stdtest_groestl},
|
||||||
{ testshort_str, NULL, testshort},
|
{ testshort_str, NULL, testshort},
|
||||||
{ testlshort_str, NULL, testlshort},
|
{ testlshort_str, NULL, testlshort},
|
||||||
|
{ test505_str, NULL, test505},
|
||||||
{ performance_str, NULL, performance_groestl},
|
{ performance_str, NULL, performance_groestl},
|
||||||
{ shavs_list_str, NULL, shavs_listalgos},
|
{ shavs_list_str, NULL, shavs_listalgos},
|
||||||
{ shavs_set_str, (void*)1, (void_fpt)shavs_setalgo},
|
{ shavs_set_str, (void*)1, (void_fpt)shavs_setalgo},
|
||||||
|
|
|
@ -51,7 +51,7 @@ ISR(TIMER1_OVF_vect){
|
||||||
}
|
}
|
||||||
|
|
||||||
void calibrateTimer(void){
|
void calibrateTimer(void){
|
||||||
volatile uint8_t i;
|
volatile uint8_t i=0;
|
||||||
startTimer(1);
|
startTimer(1);
|
||||||
stopTimer();
|
stopTimer();
|
||||||
const_overhead = TCNT1;
|
const_overhead = TCNT1;
|
||||||
|
|
|
@ -6,60 +6,9 @@ baud = 38400
|
||||||
databits = 8
|
databits = 8
|
||||||
stopbits = 1
|
stopbits = 1
|
||||||
paraty = none
|
paraty = none
|
||||||
testlogbase = testlog_
|
testlogbase = testlog/testlog_
|
||||||
|
|
||||||
###############################################################################
|
include=testconf/*.conf
|
||||||
|
|
||||||
[BlueMidnightWish-224]
|
|
||||||
algo=a
|
|
||||||
file_0=testvectors/shavs/BlueMidnightWish/ShortMsgKAT_224.txt
|
|
||||||
file_1=testvectors/shavs/BlueMidnightWish/LongMsgKAT_224.txt
|
|
||||||
|
|
||||||
[BlueMidnightWish-256]
|
|
||||||
algo=b
|
|
||||||
file_0=testvectors/shavs/BlueMidnightWish/ShortMsgKAT_256.txt
|
|
||||||
file_1=testvectors/shavs/BlueMidnightWish/LongMsgKAT_256.txt
|
|
||||||
|
|
||||||
[BlueMidnightWish-384]
|
|
||||||
algo=c
|
|
||||||
file_0=testvectors/shavs/BlueMidnightWish/ShortMsgKAT_384.txt
|
|
||||||
file_1=testvectors/shavs/BlueMidnightWish/LongMsgKAT_384.txt
|
|
||||||
|
|
||||||
[BlueMidnightWish-512]
|
|
||||||
algo=d
|
|
||||||
file_0=testvectors/shavs/BlueMidnightWish/ShortMsgKAT_512.txt
|
|
||||||
file_1=testvectors/shavs/BlueMidnightWish/LongMsgKAT_512.txt
|
|
||||||
|
|
||||||
[BlueMidnightWish]
|
|
||||||
meta=1
|
|
||||||
test_0=BlueMidnightWish-256
|
|
||||||
test_1=BlueMidnightWish-512
|
|
||||||
test_2=BlueMidnightWish-224
|
|
||||||
test_3=BlueMidnightWish-384
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
[Blake-28]
|
|
||||||
algo=a
|
|
||||||
file_0=testvectors/shavs/Blake/ShortMsgKAT_224.txt
|
|
||||||
file_1=testvectors/shavs/Blake/LongMsgKAT_224.txt
|
|
||||||
|
|
||||||
[Blake-32]
|
|
||||||
algo=b
|
|
||||||
file_0=testvectors/shavs/Blake/ShortMsgKAT_256.txt
|
|
||||||
file_1=testvectors/shavs/Blake/LongMsgKAT_256.txt
|
|
||||||
|
|
||||||
[Blake-48]
|
|
||||||
algo=c
|
|
||||||
file_0=testvectors/shavs/Blake/ShortMsgKAT_384.txt
|
|
||||||
file_1=testvectors/shavs/Blake/LongMsgKAT_384.txt
|
|
||||||
|
|
||||||
[Blake-64]
|
|
||||||
algo=d
|
|
||||||
file_0=testvectors/shavs/Blake/ShortMsgKAT_512.txt
|
|
||||||
file_1=testvectors/shavs/Blake/LongMsgKAT_512.txt
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
|
|
||||||
# END OF CONFIGFILE
|
# END OF CONFIGFILE
|
||||||
|
|
Loading…
Reference in New Issue