#include <stdlib.h>
#include <stdint.h>
#include <string.h>
+#include <avr/pgmspace.h>
#include "blockcipher_descriptor.h"
#include "keysize_descriptor.h"
-
uint8_t bcal_cipher_init(const bcdesc_t* cipher_descriptor,
const void* key, uint16_t keysize, bcgen_ctx_t* ctx){
- if(!is_valid_keysize_P((PGM_VOID_P)(pgm_read_word(cipher_descriptor->valid_keysize_desc)),
- keysize))
+ if(!is_valid_keysize_P((PGM_VOID_P)pgm_read_word(&(cipher_descriptor->valid_keysize_desc)),
+ keysize)){
return 1;
-
+ }
uint8_t flags;
bc_init_fpt init_fpt;
ctx->desc_ptr = (bcdesc_t*)cipher_descriptor;
ctx->keysize = keysize;
flags = pgm_read_byte(cipher_descriptor->flags);
- init_fpt.initvoid = (void_fpt)(pgm_read_word(cipher_descriptor->init.initvoid));
+ init_fpt.initvoid = (void_fpt)(pgm_read_word(&(cipher_descriptor->init.initvoid)));
if(init_fpt.initvoid == NULL){
- if(!(ctx->ctx = malloc(keysize/8)))
+ if(!(ctx->ctx = malloc((keysize+7)/8)))
return 2;
- memcpy(ctx->ctx, key, keysize/8);
+ memcpy(ctx->ctx, key, (keysize+7)/8);
return 0;
}
- if(!(ctx->ctx = malloc(pgm_read_word(cipher_descriptor->ctxsize_B))))
+ if(!(ctx->ctx = malloc(pgm_read_word(&(cipher_descriptor->ctxsize_B)))))
return 3;
if((flags&BC_INIT_TYPE)==BC_INIT_TYPE_1){
- init_fpt.init1((void*)key, ctx->ctx);
+ init_fpt.init1((void*)key, (ctx->ctx));
}else{
- init_fpt.init2((void*)key, keysize, ctx->ctx);
+ init_fpt.init2((void*)key, keysize, (ctx->ctx));
}
return 0;
}
if(!ctx)
return;
bc_free_fpt free_fpt;
- free_fpt = (bc_free_fpt)(pgm_read_word(ctx->desc_ptr->free));
+ free_fpt = (bc_free_fpt)(pgm_read_word(&(ctx->desc_ptr->free)));
if(free_fpt)
- free_fpt(ctx->ctx);
+ free_fpt((ctx->ctx));
free(ctx->ctx);
}
void bcal_cipher_enc(void* block, const bcgen_ctx_t* ctx){
bc_enc_fpt enc_fpt;
- enc_fpt.encvoid = (void_fpt)pgm_read_word(ctx->desc_ptr->enc.encvoid);
+ enc_fpt.encvoid = (void_fpt)pgm_read_word(&(ctx->desc_ptr->enc.encvoid));
if(!enc_fpt.encvoid){
/* very bad error, no enciphering function specified */
return;
}
- enc_fpt.enc1(block, ctx->ctx);
+ enc_fpt.enc1(block, (ctx->ctx));
}
void bcal_cipher_dec(void* block, const bcgen_ctx_t* ctx){
bc_dec_fpt dec_fpt;
- dec_fpt.decvoid = (void_fpt)pgm_read_word(ctx->desc_ptr->dec.decvoid);
+ dec_fpt.decvoid = (void_fpt)pgm_read_word(&(ctx->desc_ptr->dec.decvoid));
if(!dec_fpt.decvoid){
/* very bad error, no deciphering function specified */
return;
}
- dec_fpt.dec1(block, ctx->ctx);
+ dec_fpt.dec1(block, (ctx->ctx));
}
+uint16_t bcal_cipher_getBlocksize_b(const bcdesc_t* desc){
+ return pgm_read_word(&(desc->blocksize_b));
+}
+
+PGM_VOID_P bcal_cipher_getKeysizeDesc(const bcdesc_t* desc){
+ return (PGM_VOID_P)pgm_read_word(&(desc->valid_keysize_desc));
+}
#include <stdlib.h>
#include <stdint.h>
-#include "blockciper_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "keysize_descriptor.h"
-
+#include <avr/pgmspace.h>
uint8_t bcal_cipher_init(const bcdesc_t* cipher_descriptor,
const void* key, uint16_t keysize, bcgen_ctx_t* ctx);
void bcal_cipher_free(bcgen_ctx_t* ctx);
void bcal_cipher_enc(void* block, const bcgen_ctx_t* ctx);
void bcal_cipher_dec(void* block, const bcgen_ctx_t* ctx);
-
+uint16_t bcal_cipher_getBlocksize_b(const bcdesc_t* desc);
+PGM_VOID_P bcal_cipher_getKeysizeDesc(const bcdesc_t* desc);
#endif /* BCAL_BASIC_H_ */
--- /dev/null
+/* bcal-cbc.c */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 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/>.
+*/
+
+#include <stdint.h>
+#include <string.h>
+#include "bcal-cbc.h"
+#include "bcal-basic.h"
+#include "memxor.h"
+
+uint8_t bcal_cbc_init(const bcdesc_t* desc, const void* key, uint16_t keysize, bcal_cbc_ctx_t* ctx){
+ ctx->desc = (bcdesc_t*)desc;
+ ctx->blocksize_B = (bcal_cipher_getBlocksize_b(desc)+7)/8;
+ ctx->prev_block = malloc(ctx->blocksize_B);
+
+ if(!(ctx->prev_block)){
+ return 0x11;
+ }
+ return bcal_cipher_init(desc, key, keysize, &(ctx->cctx));
+}
+
+void bcal_cbc_free(bcal_cbc_ctx_t* ctx){
+ bcal_cipher_free(&(ctx->cctx));
+ free(ctx->prev_block);
+}
+
+
+void bcal_cbc_loadIV(const void* iv, bcal_cbc_ctx_t* ctx){
+ memcpy(ctx->prev_block, iv, ctx->blocksize_B);
+}
+
+void bcal_cbc_encNext(void* block, bcal_cbc_ctx_t* ctx){
+ memxor(block, ctx->prev_block, ctx->blocksize_B);
+ bcal_cipher_enc(block, &(ctx->cctx));
+ memcpy(ctx->prev_block, block, ctx->blocksize_B);
+}
+
+void bcal_cbc_decNext(void* block, bcal_cbc_ctx_t* ctx){
+ uint8_t tmp[ctx->blocksize_B];
+ memcpy(tmp, block, ctx->blocksize_B);
+ bcal_cipher_dec(block, &(ctx->cctx));
+ memxor(block, ctx->prev_block, ctx->blocksize_B);
+ memcpy(ctx->prev_block, tmp, ctx->blocksize_B);
+}
+void bcal_cbc_decRand(void* block, const void* prev_block, bcal_cbc_ctx_t* ctx){
+ bcal_cipher_dec(block, &(ctx->cctx));
+ memxor(block, prev_block, ctx->blocksize_B);
+}
+
+void bcal_cbc_encMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cbc_ctx_t* ctx){
+ bcal_cbc_loadIV(iv, ctx);
+ while(msg_blocks){
+ bcal_cbc_encNext(msg, ctx);
+ msg_blocks -= 1;
+ msg = (uint8_t*)msg + ctx->blocksize_B;
+ }
+}
+
+void bcal_cbc_decMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cbc_ctx_t* ctx){
+ msg=(uint8_t*)msg + (msg_blocks-1)*ctx->blocksize_B;
+ while(msg_blocks>1){
+ bcal_cbc_decRand(msg, (uint8_t*)msg-ctx->blocksize_B, ctx);
+ msg_blocks -= 1;
+ msg=(uint8_t*)msg-ctx->blocksize_B;
+ }
+ bcal_cbc_decRand(msg, iv, ctx);
+}
+
--- /dev/null
+/* bcal-cbc.h */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 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/>.
+*/
+
+#ifndef BCALCBC_H_
+#define BCALCBC_H_
+
+#include <stdint.h>
+#include "blockcipher_descriptor.h"
+#include "bcal-basic.h"
+
+typedef struct{
+ bcdesc_t* desc;
+ bcgen_ctx_t cctx;
+ uint8_t* prev_block;
+ uint8_t blocksize_B;
+} bcal_cbc_ctx_t;
+
+uint8_t bcal_cbc_init(const bcdesc_t* desc, const void* key, uint16_t keysize, bcal_cbc_ctx_t* ctx);
+void bcal_cbc_free(bcal_cbc_ctx_t* ctx);
+void bcal_cbc_loadIV(const void* iv, bcal_cbc_ctx_t* ctx);
+void bcal_cbc_encNext(void* block, bcal_cbc_ctx_t* ctx);
+void bcal_cbc_decNext(void* block, bcal_cbc_ctx_t* ctx);
+void bcal_cbc_decRand(void* block, const void* prev_block, bcal_cbc_ctx_t* ctx);
+void bcal_cbc_encMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cbc_ctx_t* ctx);
+void bcal_cbc_decMsg(const void* iv, void* msg, uint16_t msg_blocks, bcal_cbc_ctx_t* ctx);
+
+
+#endif /* BCALCBC_H_ */
const bcdesc_t aes128_desc PROGMEM = {
BCDESC_TYPE_BLOCKCIPHER,
- BC_INIT_TYPE_2,
+ BC_INIT_TYPE_1,
aes128_str,
sizeof(aes128_ctx_t),
128,
- {(void_fpt)aes_init},
+ {(void_fpt)aes128_init},
{(void_fpt)aes128_enc},
{(void_fpt)aes128_dec},
(bc_free_fpt)NULL,
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "aes.h"
#include "aes128_enc.h"
#include "aes128_dec.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "aes.h"
#include "aes192_enc.h"
#include "aes192_dec.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "aes.h"
#include "aes256_enc.h"
#include "aes256_dec.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "camellia.h"
#include "keysize_descriptor.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "cast5.h"
#include "keysize_descriptor.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "cast6.h"
#include "keysize_descriptor.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "des.h"
#include "keysize_descriptor.h"
/* bcal_noekeon.h */
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "noekeon.h"
#include "keysize_descriptor.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "present.h"
#include "keysize_descriptor.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "rc5.h"
#include "keysize_descriptor.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "rc6.h"
#include "keysize_descriptor.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "seed.h"
#include "keysize_descriptor.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "serpent.h"
#include "keysize_descriptor.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "skipjack.h"
#include "keysize_descriptor.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "des.h"
#include "keysize_descriptor.h"
*/
#include <avr/pgmspace.h>
-#include "blopckcipher_descriptor.h"
+#include "blockcipher_descriptor.h"
#include "xtea.h"
#include "keysize_descriptor.h"
items = pgm_read_byte(ks_desc++);
while(items--){
item = pgm_read_word(ks_desc);
- ks_desc+=2;
+ ks_desc = (uint8_t*)ks_desc + 2;
if(item==keysize)
return 1;
}
- ks_desc -= 2;
+ ks_desc = (uint8_t*)ks_desc - 2;
}
if(type==KS_TYPE_RANGE){
uint16_t max, min;
min = pgm_read_word(ks_desc);
- ks_desc+=2;
+ ks_desc = (uint8_t*)ks_desc + 2;
max = pgm_read_word(ks_desc);
if(min<=keysize && keysize<=max)
return 1;
if(type==KS_TYPE_ARG_RANGE){
uint16_t max, min, dist, offset;
min = pgm_read_word(ks_desc);
- ks_desc+=2;
+ ks_desc = (uint8_t*)ks_desc + 2;
max = pgm_read_word(ks_desc);
- ks_desc+=2;
+ ks_desc = (uint8_t*)ks_desc + 2;
dist = pgm_read_word(ks_desc);
- ks_desc+=2;
+ ks_desc = (uint8_t*)ks_desc + 2;
offset = pgm_read_word(ks_desc);
if(min<=keysize && keysize<=max && (keysize%dist==offset))
return 1;
/* bad error, you may insert a big warning message here */
return 0;
}
- return is_valid_keysize(ks_desc+1, keysize) /* search the next record */
+ return is_valid_keysize_P((uint8_t*)ks_desc+1, keysize); /* search the next record */
}
$(ALGO_NAME)_DIR := aes/
$(ALGO_NAME)_OBJ := aes_enc-asm.o aes_dec-asm.o aes_sbox-asm.o aes_invsbox-asm.o \
- aes_keyschedule-asm.o
+ aes_keyschedule-asm.o
$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD) \
- nessie_bc_test.o nessie_common.o performance_test.o
+ nessie_bc_test.o nessie_common.o performance_test.o memxor.o \
+ bcal_aes128.o bcal_aes192.o bcal_aes256.o bcal-basic.o bcal-cbc.o \
+ keysize_descriptor.o dump-asm.o dump-decl.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
aes128_enc.o aes128_dec.o aes192_enc.o aes192_dec.o \
aes256_enc.o aes256_dec.o
$(ALGO_NAME)_TEST_BIN := main-aes-test.o $(CLI_STD) \
- nessie_bc_test.o nessie_common.o performance_test.o
+ nessie_bc_test.o nessie_common.o performance_test.o memxor.o \
+ bcal_aes128.o bcal_aes192.o bcal_aes256.o bcal-basic.o bcal-cbc.o \
+ keysize_descriptor.o dump-asm.o dump-decl.o
$(ALGO_NAME)_NESSIE_TEST := test nessie
$(ALGO_NAME)_PERFORMANCE_TEST := performance
#include "nessie_bc_test.h"
#include "cli.h"
#include "performance_test.h"
+#include "dump.h"
+
+#include "bcal_aes128.h"
+#include "bcal_aes192.h"
+#include "bcal_aes256.h"
+#include "bcal-cbc.h"
#include <stdint.h>
#include <string.h>
aes128_dec(data, &ctx);
cli_putstr_P(PSTR("\r\n plaintext: "));
cli_hexdump(data, 16);
-
-
+ cli_putstr(PSTR("\r\n testing bcal:"));
+ bcgen_ctx_t bcal_ctx;
+ uint8_t r;
+ r = bcal_cipher_init(&aes128_desc, key, 128, &bcal_ctx);
+ cli_putstr_P(PSTR("\r\n init = 0x"));
+ cli_hexdump(&r, 1);
+
+ bcal_cipher_enc(data, &bcal_ctx);
+ cli_putstr_P(PSTR("\r\n ciphertext: "));
+ cli_hexdump(data, 16);
+ bcal_cipher_dec(data, &bcal_ctx);
+ cli_putstr_P(PSTR("\r\n plaintext: "));
+ cli_hexdump(data, 16);
}
void testrun_testkey_aes128(void){
testrun_testkey_aes192();
testrun_testkey_aes256();
}
+
+
+void testrun_aes128_cbc(void){
+ uint8_t key[] = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c };
+ uint8_t iv[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
+ uint8_t plain[] = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+ /* --- */
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+ /* --- */
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+ /* --- */
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 };
+ bcal_cbc_ctx_t ctx;
+ uint8_t r;
+ cli_putstr_P(PSTR("\r\n** AES128-CBC-TEST **"));
+ r = bcal_cbc_init(&aes128_desc, key, 128, &ctx);
+ cli_putstr_P(PSTR("\r\n init = 0x"));
+ cli_hexdump(&r, 1);
+ cli_putstr_P(PSTR("\r\n key: "));
+ cli_hexdump(key, 128/8);
+ cli_putstr_P(PSTR("\r\n IV: "));
+ cli_hexdump(iv, 128/8);
+ cli_putstr_P(PSTR("\r\n plaintext:"));
+ cli_hexdump_block(plain, 4*128/8, 4, 8);
+ if(r)
+ return;
+ bcal_cbc_encMsg(iv, plain, 4, &ctx);
+ cli_putstr_P(PSTR("\r\n ciphertext: "));
+ cli_hexdump_block(plain, 4*128/8, 4, 8);
+ bcal_cbc_decMsg(iv, plain, 4, &ctx);
+ cli_putstr_P(PSTR("\r\n plaintext: "));
+ cli_hexdump_block(plain, 4*128/8, 4, 8);
+ bcal_cbc_free(&ctx);
+}
+
+
/*****************************************************************************/
void testrun_performance_aes128(void){
const char nessie_str[] PROGMEM = "nessie";
const char test_str[] PROGMEM = "test";
const char testkey_str[] PROGMEM = "testkey";
+const char testcbc128_str[] PROGMEM = "testcbc128";
const char performance_str[] PROGMEM = "performance";
+const char dump_str[] PROGMEM = "dump";
const char echo_str[] PROGMEM = "echo";
cmdlist_entry_t cmdlist[] PROGMEM = {
{ nessie_str, NULL, testrun_nessie_aes },
{ test_str, NULL, testrun_test_aes},
{ testkey_str, NULL, testrun_testkey_aes},
+ { testcbc128_str, NULL, testrun_aes128_cbc},
{ performance_str, NULL, testrun_performance_aes},
+ { dump_str, (void*)1, (void_fpt)dump},
{ echo_str, (void*)1, (void_fpt)echo_ctrl},
{ NULL, NULL, NULL}
};
#include "nessie_bc_test.h"
#include "cli.h"
#include "performance_test.h"
-
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
+#include <avr/pgmspace.h>
char* algo_name = "AES-128";
void testrun_testkey_aes(void){
testrun_testkey_aes128();
}
+
/*****************************************************************************/
void testrun_performance_aes128(void){
0x38, 0xF0, 0xDF, 0x70, 0x1D, 0xA9, 0x3C, 0x3B,
0xF2, 0xC9, 0xC8, 0x68, 0x96, 0xE7, 0xE6, 0xC7 };
uint8_t hash[SHA256_HASH_BYTES];
- sha256(hash, data1, 3*32*8);
+ sha256((sha256_hash_t*)hash, data1, 3*32*8);
cli_putstr_P(PSTR("\r\n hash(data1) = "));
cli_hexdump(hash, 32);
- sha256(hash, data2, 3*32*8);
+ sha256((sha256_hash_t*)hash, data2, 3*32*8);
cli_putstr_P(PSTR("\r\n hash(data2) = "));
cli_hexdump(hash, 32);
}
0x39, 0xd8, 0x35, 0xa7, 0x24, 0xe2, 0xfa, 0xe7 };
uint8_t hash[SHA256_HASH_BYTES];
- sha256(hash, data, 1024);
+ sha256((sha256_hash_t*)hash, data, 1024);
cli_putstr_P(PSTR("\r\n hash(data) = "));
cli_hexdump(hash, 32);
}
const char dump_str[] PROGMEM = "dump";
cmdlist_entry_t cmdlist[] PROGMEM = {
- { nessie_str, NULL, testrun_nessie_sha256},
- { test_str, NULL, testrun_nessie_sha256},
- { monte_str, NULL, test_monte},
- { monte2_str, NULL, test_monte2},
- { performance_str, NULL, testrun_performance_sha256},
- { echo_str, (void*)1, (void_fpt)echo_ctrl},
- { shavs_list_str, NULL, shavs_listalgos},
- { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo},
- { shavs_test1_str, NULL, shavs_test1},
- { shavs_test2_str, NULL, shavs_test2},
- { shavs_test3_str, NULL, shavs_test3},
- { dump_str, (void*)1, (void_fpt)dump},
- { NULL, NULL, NULL}
+ { nessie_str, NULL, testrun_nessie_sha256 },
+ { test_str, NULL, testrun_nessie_sha256 },
+ { monte_str, NULL, test_monte },
+ { monte2_str, NULL, test_monte2 },
+ { performance_str, NULL, testrun_performance_sha256 },
+ { echo_str, (void*)1, (void_fpt)echo_ctrl },
+ { shavs_list_str, NULL, shavs_listalgos },
+ { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo },
+ { shavs_test1_str, NULL, shavs_test1 },
+ { shavs_test2_str, NULL, shavs_test2 },
+ { shavs_test3_str, NULL, shavs_test3 },
+ { dump_str, (void*)1, (void_fpt)dump },
+ { NULL, NULL, NULL }
};
int main (void){
*/
/*
* shabal test-suit
- *
+ *
*/
#include "config.h"
(hfdesc_t*)&shabal224_desc,
(hfdesc_t*)&shabal256_desc,
(hfdesc_t*)&shabal384_desc,
- (hfdesc_t*)&shabal512_desc,
+ (hfdesc_t*)&shabal512_desc,
NULL
};
cli_putc('0'+i/100);
if(i>=10)
cli_putc('0'+(i/10)%10);
- cli_putc('0'+i%10);
+ cli_putc('0'+i%10);
cli_putstr_P(PSTR("\r\n a = "));
cli_hexdump_block(ctx->a, 12*4, 5, 4*8);
cli_putstr_P(PSTR("\r\n b_buffer = "));
if(ctx->b == &(ctx->b_buffer[0]))
cli_putstr_P(PSTR("\r\nb --> b_buffer"));
if(ctx->b == &(ctx->c_buffer[0]))
- cli_putstr_P(PSTR("\r\nb --> c_buffer"));
+ cli_putstr_P(PSTR("\r\nb --> c_buffer"));
if(ctx->c == &(ctx->b_buffer[0]))
cli_putstr_P(PSTR("\r\nc --> b_buffer"));
if(ctx->c == &(ctx->c_buffer[0]))
cli_putstr_P(PSTR("\r\n b (should) = "));
cli_hexdump(&p, 2);
cli_putstr_P(PSTR("\r\n c = "));
- cli_hexdump(&(ctx->c), 2);
+ cli_hexdump(&(ctx->c), 2);
p = ctx->c_buffer;
cli_putstr_P(PSTR("\r\n c (should) = "));
cli_hexdump(&p, 2);
const char shavs_list_str[] PROGMEM = "shavs_list";
const char shavs_set_str[] PROGMEM = "shavs_set";
const char shavs_test1_str[] PROGMEM = "shavs_test1";
+const char shavs_test2_str[] PROGMEM = "shavs_test2";
+const char shavs_test3_str[] PROGMEM = "shavs_test3";
cmdlist_entry_t cmdlist[] PROGMEM = {
- { nessie_str, NULL, testrun_nessie_shabal},
- { test_str, NULL, testrun_stdtest_shabal},
- { testinit192_str, NULL, testinit_192},
- { testinit_str, NULL, testinit},
- { testshort_str, NULL, testshort},
- { performance_str, NULL, performance_shabal},
- { shavs_list_str, NULL, shavs_listalgos},
- { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo},
- { shavs_test1_str, NULL, shavs_test1},
- { echo_str, (void*)1, (void_fpt)echo_ctrl},
- { NULL, NULL, NULL}
+ { nessie_str, NULL, testrun_nessie_shabal },
+ { test_str, NULL, testrun_stdtest_shabal },
+ { testinit192_str, NULL, testinit_192 },
+ { testinit_str, NULL, testinit },
+ { testshort_str, NULL, testshort },
+ { performance_str, NULL, performance_shabal },
+ { shavs_list_str, NULL, shavs_listalgos },
+ { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo },
+ { shavs_test1_str, NULL, shavs_test1 },
+ { shavs_test2_str, NULL, shavs_test2 },
+ { shavs_test3_str, NULL, shavs_test3 },
+ { echo_str, (void*)1, (void_fpt)echo_ctrl },
+ { NULL, NULL, NULL }
};
int main (void){
DEBUG_INIT();
-
+
cli_rx = (cli_rx_fpt)uart0_getc;
- cli_tx = (cli_tx_fpt)uart0_putc;
+ cli_tx = (cli_tx_fpt)uart0_putc;
shavs_algolist=(hfdesc_t**)algolist;
shavs_algo=(hfdesc_t*)&shabal256_desc;
for(;;){
cli_putstr_P(PSTR(" "));
cli_putstr(__TIME__);
cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
-
+
cmd_interface(cmdlist);
}
-}
+}