* main *
*****************************************************************************/
-typedef void(*void_fpt)(void);
-
int main (void){
char str[20];
* main *
*****************************************************************************/
-typedef void(*void_fpt)(void);
-
int main (void){
char str[20];
DEBUG_INIT();
* main *
*****************************************************************************/
-typedef void(*void_fpt)(void);
-
int main (void){
char str[20];
DEBUG_INIT();
* main *
*****************************************************************************/
-typedef void(*void_fpt)(void);
-
int main (void){
char str[20];
DEBUG_INIT();
* main *
*****************************************************************************/
-typedef void(*void_fpt)(void);
-
int main (void){
char str[20];
DEBUG_INIT();
* main *
*****************************************************************************/
-typedef void(*void_fpt)(void);
-
int main (void){
char str[20];
DEBUG_INIT();
* main *
*****************************************************************************/
-typedef void(*void_fpt)(void);
-
int main (void){
char str[20];
DEBUG_INIT();
* main *
*****************************************************************************/
-typedef void(*void_fpt)(void);
-
int main (void){
char str[20];
DEBUG_INIT();
--- /dev/null
+/*
+ * Shacal1 encryption only test-suit
+ *
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "shacal1_enc.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+char* cipher_name = "Shacal1 encryption only";
+
+/*****************************************************************************
+ * additional validation-functions *
+ *****************************************************************************/
+void shacal1_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+ memcpy(ctx, key, (keysize_b+7)/8);
+}
+
+void shacal1_enc_dummy(void* buffer, void* ctx){
+ shacal1_enc(buffer, ctx, 512);
+}
+
+void testrun_nessie_shacal1enc(void){
+ nessie_bc_ctx.blocksize_B = SHACAL1_BLOCKSIZE_B;
+ nessie_bc_ctx.keysize_b = SHACAL1_KEYSIZE;
+ nessie_bc_ctx.name = cipher_name;
+ nessie_bc_ctx.ctx_size_B = SHACAL1_KEYSIZE_B;
+ nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)shacal1_enc_dummy;
+ nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)NULL;
+ nessie_bc_ctx.cipher_genctx = (nessie_bc_gen_fpt)shacal1_genctx_dummy;
+
+ nessie_bc_run();
+}
+
+void testrun_performance_shacal1enc(void){
+ uint64_t t;
+ uint8_t key[SHACAL1_KEYSIZE_B], data[SHACAL1_BLOCKSIZE_B];
+
+ calibrateTimer();
+ print_overhead();
+
+ memset(key, 0, SHACAL1_KEYSIZE_B);
+ memset(data, 0, SHACAL1_BLOCKSIZE_B);
+
+
+ startTimer(1);
+ shacal1_enc(data, key, SHACAL1_KEYSIZE);
+ t = stopTimer();
+ print_time_P(PSTR("\tencrypt time: "), t);
+
+ uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ * main *
+ *****************************************************************************/
+
+int main (void){
+ char str[20];
+ DEBUG_INIT();
+ uart_putstr("\r\n");
+
+ uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+ uart_putstr(cipher_name);
+ uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+ PGM_P u = PSTR("nessie\0test\0performance\0");
+ void_fpt v[] = {testrun_nessie_shacal1enc,
+ testrun_nessie_shacal1enc,
+ testrun_performance_shacal1enc};
+
+ while(1){
+ if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;}
+ if(execcommand_d0_P(str, u, v)<0){
+ uart_putstr_P(PSTR("\r\nunknown command\r\n"));
+ }
+ continue;
+ error:
+ uart_putstr("ERROR\r\n");
+ }
+
+}
--- /dev/null
+/*
+ * Shacal2 encryption only test-suit
+ *
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "shacal2_enc.h"
+#include "nessie_bc_test.h"
+#include "cli.h"
+#include "performance_test.h"
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+char* cipher_name = "Shacal2 encryption only";
+
+/*****************************************************************************
+ * additional validation-functions *
+ *****************************************************************************/
+void shacal2_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
+ memcpy(ctx, key, (keysize_b+7)/8);
+}
+
+void shacal2_enc_dummy(void* buffer, void* ctx){
+ shacal2_enc(buffer, ctx, SHACAL2_KEYSIZE);
+}
+
+void testrun_nessie_shacal2enc(void){
+ nessie_bc_ctx.blocksize_B = SHACAL2_BLOCKSIZE_B;
+ nessie_bc_ctx.keysize_b = SHACAL2_KEYSIZE;
+ nessie_bc_ctx.name = cipher_name;
+ nessie_bc_ctx.ctx_size_B = SHACAL2_KEYSIZE_B;
+ nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)shacal2_enc_dummy;
+ nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)NULL;
+ nessie_bc_ctx.cipher_genctx = (nessie_bc_gen_fpt)shacal2_genctx_dummy;
+
+ nessie_bc_run();
+}
+
+void testrun_performance_shacal2enc(void){
+ uint64_t t;
+ uint8_t key[SHACAL2_KEYSIZE_B], data[SHACAL2_BLOCKSIZE_B];
+
+ calibrateTimer();
+ print_overhead();
+
+ memset(key, 0, SHACAL2_KEYSIZE_B);
+ memset(data, 0, SHACAL2_BLOCKSIZE_B);
+
+
+ startTimer(1);
+ shacal2_enc(data, key, SHACAL2_KEYSIZE);
+ t = stopTimer();
+ print_time_P(PSTR("\tencrypt time: "), t);
+
+ uart_putstr_P(PSTR("\r\n"));
+}
+
+/*****************************************************************************
+ * main *
+ *****************************************************************************/
+
+int main (void){
+ char str[20];
+ DEBUG_INIT();
+ uart_putstr("\r\n");
+
+ uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
+ uart_putstr(cipher_name);
+ uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+
+ PGM_P u = PSTR("nessie\0test\0performance\0");
+ void_fpt v[] = {testrun_nessie_shacal2enc,
+ testrun_nessie_shacal2enc,
+ testrun_performance_shacal2enc};
+
+ while(1){
+ if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;}
+ if(execcommand_d0_P(str, u, v)<0){
+ uart_putstr_P(PSTR("\r\nunknown command\r\n"));
+ }
+ continue;
+ error:
+ uart_putstr("ERROR\r\n");
+ }
+
+}
* main *
*****************************************************************************/
-typedef void(*void_fpt)(void);
-
int main (void){
char str[20];
DEBUG_INIT();
* main *
*****************************************************************************/
-typedef void(*void_fpt)(void);
-
int main (void){
char str[20];
DEBUG_INIT();
/* single test */
nessie_print_item("key", key, (nessie_bc_ctx.keysize_b+7)/8);
nessie_bc_ctx.cipher_genctx(key, nessie_bc_ctx.keysize_b, ctx);
+
memcpy(buffer, pt, nessie_bc_ctx.blocksize_B);
nessie_print_item("plain", buffer, nessie_bc_ctx.blocksize_B);
nessie_bc_ctx.cipher_enc(buffer, ctx);
nessie_print_item("cipher", buffer, nessie_bc_ctx.blocksize_B);
- nessie_bc_ctx.cipher_dec(buffer, ctx);
- nessie_print_item("decrypted", buffer, nessie_bc_ctx.blocksize_B);
-
+ if(nessie_bc_ctx.cipher_dec){
+ nessie_bc_ctx.cipher_dec(buffer, ctx);
+ nessie_print_item("decrypted", buffer, nessie_bc_ctx.blocksize_B);
+ }
/* 100 times test */
memcpy(buffer, pt, nessie_bc_ctx.blocksize_B);
for(i=0; i<100; ++i){
}
nessie_bc_enc(key, buffer);
/* half done ;-) */
+ if(nessie_bc_ctx.cipher_dec==NULL)
+ return;
/* test set 5 */
set=5;
nessie_print_setheader(set);
* \author Daniel Otte
* \date 08.10.2006
* \par License:
- * GPL
+ * GPLv3
* \brief SHA-1 implementation.
*
*/
--- /dev/null
+/**
+ * \file shacal1_enc.c
+ * \author Daniel Otte
+ * \date 2008-05-06
+ * \par License:
+ * GPL
+ * \brief SHACAL1 encryption only implementation.
+ *
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "sha1.h"
+#include "shacal1_enc.h"
+
+void shacal1_enc(void* buffer, void* key, uint16_t keysize_b){
+ sha1_ctx_t ctx, t_ctx;
+ uint8_t i;
+ memcpy(t_ctx.h, buffer, SHA1_HASH_BITS/8);
+
+ uint8_t keybuffer[SHA1_BLOCK_BITS/8];
+ memset(keybuffer, 0, SHA1_BLOCK_BITS/8);
+ if(keysize_b>SHA1_BLOCK_BITS)
+ keysize_b=SHA1_BLOCK_BITS;
+ memcpy(keybuffer, key, (keysize_b+7)/8);
+
+ memcpy(t_ctx.h, buffer, SHA1_HASH_BITS/8);
+ sha1_ctx2hash((sha1_hash_t*)(&(ctx.h[0])), &t_ctx);
+ memcpy(t_ctx.h, ctx.h, SHA1_HASH_BITS/8);
+ sha1_nextBlock(&ctx, keybuffer);
+ for(i=0; i<5; ++i)
+ ctx.h[i] -= t_ctx.h[i];
+ sha1_ctx2hash(buffer, &ctx);
+}
+
+
--- /dev/null
+#ifndef SHACAL1_ENC_H_
+#define SHACAL1_ENC_H_
+
+#include <stdint.h>
+
+#define SHACAL1_BLOCKSIZE 160
+#define SHACAL1_BLOCKSIZE_B ((SHACAL1_BLOCKSIZE+7)/8)
+#define SHACAL1_KEYSIZE 512
+#define SHACAL1_KEYSIZE_B ((SHACAL1_KEYSIZE+7)/8)
+
+void shacal1_enc(void* buffer, void* key, uint16_t keysize_b);
+
+#endif /*SHACAL1_ENC_H_*/
--- /dev/null
+# Makefile for present
+ALGO_NAME := SHACAL1ENC
+
+# comment out the following line for removement of present from the build process
+BLOCK_CIPHERS += $(ALGO_NAME)
+
+
+$(ALGO_NAME)_OBJ := shacal1_enc.o sha1-asm.o
+$(ALGO_NAME)_TEST_BIN := main-shacal1_enc-test.o debug.o uart.o serial-tools.o \
+ nessie_bc_test.o nessie_common.o cli.o \
+ performance_test.o shacal1_enc.o sha1-asm.o
+$(ALGO_NAME)_NESSIE_TEST := "nessie"
+$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+
--- /dev/null
+/**
+ * \file shacal2_enc.c
+ * \author Daniel Otte
+ * \date 2008-05-07
+ * \par License:
+ * GPL
+ * \brief SHACAL2 encryption only implementation.
+ *
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include "sha256.h"
+#include "shacal2_enc.h"
+
+
+void shacal2_enc(void* buffer, void* key, uint16_t keysize_b){
+ uint8_t i;
+ sha256_ctx_t ctx, t_ctx;
+ memcpy(ctx.h, buffer, SHACAL2_BLOCKSIZE_B);
+
+ uint8_t keybuffer[SHACAL2_KEYSIZE_B];
+ memset(keybuffer, 0, SHACAL2_KEYSIZE_B);
+ if(keysize_b>SHACAL2_KEYSIZE)
+ keysize_b=SHACAL2_KEYSIZE;
+ memcpy(keybuffer, key, (keysize_b+7)/8);
+
+ memcpy(t_ctx.h, buffer, SHACAL2_BLOCKSIZE_B);
+ sha256_ctx2hash((sha256_hash_t*)(&(ctx.h[0])), &t_ctx);
+ memcpy(t_ctx.h, ctx.h, SHACAL2_BLOCKSIZE_B);
+ sha256_nextBlock(&ctx, keybuffer);
+ for(i=0; i<SHACAL2_BLOCKSIZE/32; ++i){
+ ctx.h[i] -= t_ctx.h[i];
+ }
+ sha256_ctx2hash(buffer, &ctx);
+}
+
+
+
--- /dev/null
+#ifndef SHACAL2_ENC_H_
+#define SHACAL2_ENC_H_
+
+#include <stdint.h>
+#include "sha256.h"
+
+#define SHACAL2_BLOCKSIZE SHA256_HASH_BITS
+#define SHACAL2_BLOCKSIZE_B ((SHACAL2_BLOCKSIZE+7)/8)
+#define SHACAL2_KEYSIZE SHA256_BLOCK_BITS
+#define SHACAL2_KEYSIZE_B ((SHACAL2_KEYSIZE+7)/8)
+
+void shacal2_enc(void* buffer, void* key, uint16_t keysize_b);
+
+
+#endif /*SHACAL2_ENC_H_*/
--- /dev/null
+# Makefile for present
+ALGO_NAME := SHACAL2ENC
+
+# comment out the following line for removement of present from the build process
+BLOCK_CIPHERS += $(ALGO_NAME)
+
+
+$(ALGO_NAME)_OBJ := shacal2_enc.o sha256-asm.o
+$(ALGO_NAME)_TEST_BIN := main-shacal2_enc-test.o debug.o uart.o serial-tools.o \
+ nessie_bc_test.o nessie_common.o cli.o \
+ performance_test.o shacal2_enc.o sha256-asm.o
+$(ALGO_NAME)_NESSIE_TEST := "nessie"
+$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+