]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
new mk-stub for Rabbit with estream modifications
authorbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Tue, 12 Jul 2011 19:24:24 +0000 (19:24 +0000)
committerbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Tue, 12 Jul 2011 19:24:24 +0000 (19:24 +0000)
mkfiles/rabbit_c.mk
mkfiles/rabbit_estream_c.mk [new file with mode: 0644]
rabbit/rabbit_c.c
scal/scal_rabbit.c
test_src/main-rabbit-test.c

index 23741fd879732920fec8b52a90a203d293e5791f..a43b0f4dc344c484e14793997b6606ac648893a6 100644 (file)
@@ -10,4 +10,4 @@ $(ALGO_NAME)_INCDIR   := memxor/ scal/
 $(ALGO_NAME)_TEST_BIN := main-rabbit-test.o $(CLI_STD) $(SCAL_STD) scal_rabbit.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
-
+$(ALGO_NAME)_DEF := ESTREAM=0
diff --git a/mkfiles/rabbit_estream_c.mk b/mkfiles/rabbit_estream_c.mk
new file mode 100644 (file)
index 0000000..5070e41
--- /dev/null
@@ -0,0 +1,14 @@
+# Makefile for Rabbit
+ALGO_NAME := RABBIT_ESTREAM_C
+
+# comment out the following line for removement of Rabbit from the build process
+STREAM_CIPHERS += $(ALGO_NAME)
+
+$(ALGO_NAME)_DIR      := rabbit/
+$(ALGO_NAME)_OBJ      := rabbit_c.o
+$(ALGO_NAME)_INCDIR   := memxor/ scal/
+$(ALGO_NAME)_TEST_BIN := main-rabbit-test.o $(CLI_STD) $(SCAL_STD) scal_rabbit.o
+$(ALGO_NAME)_NESSIE_TEST      := "nessie"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
+$(ALGO_NAME)_DEF := ESTREAM=1
+
index 6c750a5280995387a3f6823314340dfb0387da74..c5f8a43321e09dbe3de85ed6807dcb0ce58d4f9d 100644 (file)
@@ -23,7 +23,7 @@
 #include "rabbit.h"
 
 #ifndef ESTREAM
-#define ESTREAM 1
+#define ESTREAM 0
 #endif
 
 /*
index 5ede3d647def1de9883af4a4cdc6aba461a4b558..f1d7007f748af5364c8c449e23775d2ad2e687df 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "rabbit.h"
 
-const char rabbit_str[]   PROGMEM = "rabbit";
+const char rabbit_str[]   PROGMEM = "Rabbit";
 
 const uint8_t rabbit_keysize_desc[] PROGMEM = {
                KS_TYPE_LIST, 2, KS_INT(128), KS_INT(80),
index 1b706b698677218c63a7fcd142863eca5108a663..b60de60decc1d9941eb30d434f228eace58e614d 100644 (file)
@@ -41,38 +41,39 @@ char* algo_name = "Rabbit";
  *  additional validation-functions                                                                                     *
  *****************************************************************************/
 
-void test_vector(void* key, void* iv){
+void test_vector(void* key, void* iv, const void* ref){
        rabbit_ctx_t ctx;
-       cli_putstr_P(PSTR("\r\n testing with key: "));
+       uint8_t fail=0;
+       cli_putstr_P(PSTR("\r\n testing with\r\n key:  "));
        cli_hexdump(key, 16);
-       cli_putstr_P(PSTR("\r\n              iv:  "));
+       cli_putstr_P(PSTR("\r\n iv:   "));
        if(iv){
                cli_hexdump(iv, 8);
        }else{
                cli_putstr_P(PSTR("[no iv]"));
        }
        rabbit_init(key, 128, iv, &ctx);
-       cli_putstr_P(PSTR("\r\n S[0]: "));
        rabbit_gen(&ctx);
-       cli_hexdump(ctx.buffer, 16);
-       cli_putstr_P(PSTR("\r\n S[1]: "));
-       ctx.buffer_idx=16;
-       rabbit_gen(&ctx);
-       cli_hexdump(ctx.buffer, 16);
-       cli_putstr_P(PSTR("\r\n S[2]: "));
-       ctx.buffer_idx=16;
-       rabbit_gen(&ctx);
-       cli_hexdump(ctx.buffer, 16);
-//     dump_ctx(&ctx);
+       if(!ref || (memcmp_P(ctx.buffer, ref, 16))!=0){
+               fail = 1;
+               cli_putstr_P(PSTR("\r\n S[0]: "));
+               cli_hexdump(ctx.buffer, 16);
+       }
        ctx.buffer_idx=16;
-       rabbit_gen(&ctx);
-//     dump_ctx(&ctx);
-       cli_putstr_P(PSTR("\r\n S[3]: "));
-       cli_hexdump(ctx.buffer, 16);
+       if(!ref || (memcmp_P(ctx.buffer, ref, 16))!=0){
+               fail = 1;
+               cli_putstr_P(PSTR("\r\n S[0]: "));
+               cli_hexdump(ctx.buffer, 16);
+       }
        ctx.buffer_idx=16;
-       rabbit_gen(&ctx);
-       cli_putstr_P(PSTR("\r\n S[4]: "));
-       cli_hexdump(ctx.buffer, 16);
+       if(!ref || (memcmp_P(ctx.buffer, ref, 16))!=0){
+               fail = 1;
+               cli_putstr_P(PSTR("\r\n S[0]: "));
+               cli_hexdump(ctx.buffer, 16);
+       }
+       if(ref){
+               cli_putstr_P(fail?PSTR("\r\n [fail]"):PSTR("\r\n [ok]"));
+       }
        cli_putstr_P(PSTR("\r\n"));
 }
 
@@ -83,11 +84,11 @@ void nessie_first(void){
        memset(iv, 0, 8);
        memset(key, 0, 16);
        key[0] = 0x80;
-       test_vector(key, iv);
+       test_vector(key, iv, NULL);
        key[0] = 0x00;
 
        key[15] = 0x80;
-       test_vector(key, iv);
+       test_vector(key, iv, NULL);
 
 }
 
@@ -110,25 +111,58 @@ const uint8_t spec_iv2[] PROGMEM = {
        0xA6, 0xEB, 0x56, 0x1A, 0xD2, 0xF4, 0x17, 0x27
 };
 
+const uint8_t spec_ref[] PROGMEM = {
+       0xB1, 0x57, 0x54, 0xF0, 0x36, 0xA5, 0xD6, 0xEC, 0xF5, 0x6B, 0x45, 0x26, 0x1C, 0x4A, 0xF7, 0x02,
+       0x88, 0xE8, 0xD8, 0x15, 0xC5, 0x9C, 0x0C, 0x39, 0x7B, 0x69, 0x6C, 0x47, 0x89, 0xC6, 0x8A, 0xA7,
+       0xF4, 0x16, 0xA1, 0xC3, 0x70, 0x0C, 0xD4, 0x51, 0xDA, 0x68, 0xD1, 0x88, 0x16, 0x73, 0xD6, 0x96,
+
+       0x3D, 0x2D, 0xF3, 0xC8, 0x3E, 0xF6, 0x27, 0xA1, 0xE9, 0x7F, 0xC3, 0x84, 0x87, 0xE2, 0x51, 0x9C,
+       0xF5, 0x76, 0xCD, 0x61, 0xF4, 0x40, 0x5B, 0x88, 0x96, 0xBF, 0x53, 0xAA, 0x85, 0x54, 0xFC, 0x19,
+       0xE5, 0x54, 0x74, 0x73, 0xFB, 0xDB, 0x43, 0x50, 0x8A, 0xE5, 0x3B, 0x20, 0x20, 0x4D, 0x4C, 0x5E,
+
+       0x0C, 0xB1, 0x0D, 0xCD, 0xA0, 0x41, 0xCD, 0xAC, 0x32, 0xEB, 0x5C, 0xFD, 0x02, 0xD0, 0x60, 0x9B,
+       0x95, 0xFC, 0x9F, 0xCA, 0x0F, 0x17, 0x01, 0x5A, 0x7B, 0x70, 0x92, 0x11, 0x4C, 0xFF, 0x3E, 0xAD,
+       0x96, 0x49, 0xE5, 0xDE, 0x8B, 0xFC, 0x7F, 0x3F, 0x92, 0x41, 0x47, 0xAD, 0x3A, 0x94, 0x74, 0x28,
+
+       0xC6, 0xA7, 0x27, 0x5E, 0xF8, 0x54, 0x95, 0xD8, 0x7C, 0xCD, 0x5D, 0x37, 0x67, 0x05, 0xB7, 0xED,
+       0x5F, 0x29, 0xA6, 0xAC, 0x04, 0xF5, 0xEF, 0xD4, 0x7B, 0x8F, 0x29, 0x32, 0x70, 0xDC, 0x4A, 0x8D,
+       0x2A, 0xDE, 0x82, 0x2B, 0x29, 0xDE, 0x6C, 0x1E, 0xE5, 0x2B, 0xDB, 0x8A, 0x47, 0xBF, 0x8F, 0x66,
+
+       0x1F, 0xCD, 0x4E, 0xB9, 0x58, 0x00, 0x12, 0xE2, 0xE0, 0xDC, 0xCC, 0x92, 0x22, 0x01, 0x7D, 0x6D,
+       0xA7, 0x5F, 0x4E, 0x10, 0xD1, 0x21, 0x25, 0x01, 0x7B, 0x24, 0x99, 0xFF, 0xED, 0x93, 0x6F, 0x2E,
+       0xEB, 0xC1, 0x12, 0xC3, 0x93, 0xE7, 0x38, 0x39, 0x23, 0x56, 0xBD, 0xD0, 0x12, 0x02, 0x9B, 0xA7,
+
+       0x44, 0x5A, 0xD8, 0xC8, 0x05, 0x85, 0x8D, 0xBF, 0x70, 0xB6, 0xAF, 0x23, 0xA1, 0x51, 0x10, 0x4D,
+       0x96, 0xC8, 0xF2, 0x79, 0x47, 0xF4, 0x2C, 0x5B, 0xAE, 0xAE, 0x67, 0xC6, 0xAC, 0xC3, 0x5B, 0x03,
+       0x9F, 0xCB, 0xFC, 0x89, 0x5F, 0xA7, 0x1C, 0x17, 0x31, 0x3D, 0xF0, 0x34, 0xF0, 0x15, 0x51, 0xCB
+};
+
 void spec_test(void){
        uint8_t key[16];
     uint8_t iv[8];
+    const uint8_t *ref;
+    ref = spec_ref;
 
        memset(key, 0, 16);
-       test_vector(key, NULL);
+       test_vector(key, NULL, ref);
        memcpy_P(key, spec_key1, 16);
-       test_vector(key, NULL);
+       ref += 48;
+       test_vector(key, NULL, ref);
        memcpy_P(key, spec_key2, 16);
-       test_vector(key, NULL);
+       ref += 48;
+       test_vector(key, NULL, ref);
 
 
        memset(key, 0, 16);
        memset(iv, 0, 8);
-       test_vector(key, iv);
+       ref += 48;
+       test_vector(key, iv, ref);
        memcpy_P(iv,  spec_iv1,   8);
-       test_vector(key, iv);
+       ref += 48;
+       test_vector(key, iv, ref);
        memcpy_P(iv,  spec_iv2,   8);
-       test_vector(key, iv);
+       ref += 48;
+       test_vector(key, iv, ref);
 }