]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
fixing lot of typos, camellia_C now seems to work
authorbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Wed, 10 Dec 2008 15:18:23 +0000 (15:18 +0000)
committerbg <bg@b1d182e4-1ff8-0310-901f-bddb46175740>
Wed, 10 Dec 2008 15:18:23 +0000 (15:18 +0000)
39 files changed:
camellia-asm.S
camellia.c [deleted file]
camellia.h
camellia128-stub.c [new file with mode: 0644]
camellia_C.c
mkfiles/a5_1.mk
mkfiles/arcfour.mk
mkfiles/arcfour_c.mk
mkfiles/camellia.mk
mkfiles/cast5.mk
mkfiles/des.mk
mkfiles/entropium.mk
mkfiles/grain.mk
mkfiles/hmac-sha1.mk
mkfiles/hmac-sha256.mk
mkfiles/md5.mk
mkfiles/noekeon.mk
mkfiles/noekeon_c.mk
mkfiles/present.mk
mkfiles/rc5.mk
mkfiles/rc6.mk
mkfiles/seed.mk
mkfiles/serpent-bitslice.mk
mkfiles/serpent_asm_fast.mk
mkfiles/serpent_asm_small.mk
mkfiles/serpent_c.mk
mkfiles/sha1.mk
mkfiles/sha1_c.mk
mkfiles/sha256.mk
mkfiles/sha256_c.mk
mkfiles/shabea.mk
mkfiles/shacal1enc.mk
mkfiles/shacal2enc.mk
mkfiles/skipjack.mk
mkfiles/tdes.mk
mkfiles/trivium.mk
mkfiles/xtea.mk
mkfiles/xtea_c.mk
test_src/main-camellia-test.c

index 6e58ca5976a4332e35503ce8314f9ca633cde6c6..eeb7b491bc652ebc673440bbc342516fbf176094 100644 (file)
@@ -407,26 +407,26 @@ B1 = 18
 B2 = 19
 .global camellia128_keyop_rot15
 camellia128_keyop_rot15:
-       movw r30, r24 ; Z points at LSB of kl                   ;-- 0
+       movw r30, r24 ; Z points at LSB of kl            ;-- 0
        ldi r22, 2              
-2:     adiw r30, 15                                                                    ;-- 15
+2:     adiw r30, 15                                     ;-- 15
        ld  r21, Z
-       ld  r20, -Z                                                                             ;-- 14
+       ld  r20, -Z                                      ;-- 14
        movw B1, r20 ; store Backup of the 2 MSB of kl
        ror r20
 
        ldi r21, 14
-1:     ld r20, -Z                                                                              ;-- 13..0
+1:     ld r20, -Z                                       ;-- 13..0
        ror r20
-       std Z+2, r20                                                                    ;-- (15..2)
+       std Z+2, r20                                     ;-- (15..2)
        dec r21
        brne 1b
        
        ror B2
        ror B1
-       st Z+, B1                                                                               ;-- 1
+       st Z+, B1                                        ;-- 1
        st Z, B2
-       adiw r30, 15                                                                    ;-- 16
+       adiw r30, 15                                     ;-- 16
        
        dec r22
        brne 2b
@@ -513,26 +513,26 @@ B1 = 18
 B2 = 19
 .global camellia128_keyop_inv_rot15
 camellia128_keyop_inv_rot15:
-       movw r30, r24 ; Z points at LSB of kl                   ;-- 0
+       movw r30, r24 ; Z points at LSB of kl                ;-- 0
        movw r26, r24 ; X also
        ldi r22, 2              
-2:                                                                                                     ;-- 0
-       ld  r20, Z+                                                                             ;-- 0/1
-       ld  r21, Z+                                                                             ;-- 1/2
+2:                                                           ;-- 0
+       ld  r20, Z+                                          ;-- 0/1
+       ld  r21, Z+                                          ;-- 1/2
        movw B1, r20 ; store Backup of the 2 LSB of kl
        rol r21
 
        ldi r20, 14
-1:     ld r21, Z+                                                                              ;-- 2/14..3/16
+1:     ld r21, Z+                                           ;-- 2/14..3/16
        rol r21
-       st X+, r21                                                                              ;-- (0..13)/(1..14)
+       st X+, r21                                           ;-- (0..13)/(1..14)
        dec r20
        brne 1b
        
        rol B1
        rol B2
-       st X+, B1                                                                               ;-- 14/15
-       st X+, B2                                                                               ;-- 15/16
+       st X+, B1                                            ;-- 14/15
+       st X+, B2                                            ;-- 15/16
        
        dec r22
        brne 2b
diff --git a/camellia.c b/camellia.c
deleted file mode 100644 (file)
index 4c5b1c8..0000000
+++ /dev/null
@@ -1,246 +0,0 @@
-/* camellia.c */
-/*
-    This file is part of the Crypto-avr-lib/microcrypt-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/>.
-*/
-/**
- * 
- * 
- * 
- * 
- */
-#include <stdint.h>
-#include <avr/io.h>
-#include <avr/pgmspace.h>
-#include "camellia.h"
-#include "uart.h"
-#include "debug.h"
-#include <util/delay.h>
-/*****************************************************************************/
-uint64_t camellia_f(uint64_t x, uint64_t k);
-/*****************************************************************************/
-uint64_t camellia_fl(uint64_t x, uint64_t k);
-/*****************************************************************************/
-uint64_t camellia_fl_inv(uint64_t y, uint64_t k);
-/*****************************************************************************/
-void change_endian(void* data, uint8_t length);
-/*
-uint64_t PROGMEM camellia_sigma[6]={ / * 64 byte table * /
-       0xA09E667F3BCC908BLL,
-       0xB67AE8584CAA73B2LL,
-       0xC6EF372FE94F82BELL,
-       0x54FF53A5F1D36F1CLL,
-       0x10E527FADE682D1DLL,
-       0xB05688C2B3E6C1FDLL
-};     
-*/
-uint32_t PROGMEM camellia_sigma[12]={ /* 48 byte table */
-         0x3BCC908BL, 0xA09E667FL,
-         0x4CAA73B2L, 0xB67AE858L,
-         0xE94F82BEL, 0xC6EF372FL,
-         0xF1D36F1CL, 0x54FF53A5L,
-         0xDE682D1DL, 0x10E527FAL,
-         0xB3E6C1FDL, 0xB05688C2L
-};
-
-/* an ugly macro to load an entry form the table above */
-/*
-#define SIGMA(p) (( ((uint64_t)(pgm_read_dword((prog_uint32_t*)camellia_sigma+2*(p)+1)))<<32) | \
-                    ((uint64_t)(pgm_read_dword((prog_uint32_t*)camellia_sigma+2*(p)+0))) )
-*/
-#define SIGMA(p) (( ((uint64_t)(pgm_read_dword(&(((prog_uint32_t*)camellia_sigma)[2*(p)+1]))))<<32) | \
-                    ((uint64_t)(pgm_read_dword(&(((prog_uint32_t*)camellia_sigma)[2*(p)+0])))) )
-
-
-
-/*****************************************************************************/
-
-void camellia128_ctx_dump(camellia128_ctx_t *s){
-       uart_putstr_P(PSTR("\r\n==State Dump=="));
-       uart_putstr_P(PSTR("\n\rKAl: ")); uart_hexdump(&(s->kal), 8);
-       uart_putstr_P(PSTR("\n\rKAr: ")); uart_hexdump(&(s->kar), 8);
-       uart_putstr_P(PSTR("\n\rKLl: ")); uart_hexdump(&(s->kll), 8);
-       uart_putstr_P(PSTR("\n\rKLr: ")); uart_hexdump(&(s->klr), 8);   
-       return;
-}
-
-/*****************************************************************************/
-/* extern prog_uint64_t camellia_sigma[6]; */
-
-void camellia128_init(const uint8_t* key, camellia128_ctx_t* s){
-       uint8_t i;
-       s->kll = 0; /* ((uint64_t*)key)[0]; */
-       
-       /* load the key, endian-adjusted, to kll,klr */
-       for(i=0; i<8; ++i){
-               s->kll <<= 8;
-               s->kll |= *key++;
-       }
-       for(i=0; i<8; ++i){
-               s->klr <<= 8;
-               s->klr |= *key++;
-       }
-
-       s->kal = s->kll;
-       s->kar = s->klr;
-       
-       s->kar ^= camellia_f(s->kal, SIGMA(0));
-       s->kal ^= camellia_f(s->kar, SIGMA(1));
-       
-       s->kal ^= s->kll;
-       s->kar ^= s->klr;
-       
-       s->kar ^= camellia_f(s->kal, SIGMA(2));
-       s->kal ^= camellia_f(s->kar, SIGMA(3));
-}
-
-/*****************************************************************************/
-void camellia128_keyop(camellia128_ctx_t* s, int8_t q);
-/*****************************************************************************/
-void camellia128_keyop_inv(camellia128_ctx_t* s, int8_t q); 
-/*****************************************************************************/
-
-#define SEL_KA 1
-#define SEL_KL 0
-
-#define KEY_POSTC1             0x00
-#define KEY_POSTC2             0x01
-#define KEY_INC2               0x02
-
-#define KEY_DIR                        0x04
-#define KEY_DIR_NORM   0x00
-#define KEY_DIR_INV            0x04
-
-#define KEY_AMMOUNT            0x08 
-#define KEY_ROL17              0x08
-#define KEY_ROL15              0x00
-
-void camellia_6rounds(const camellia128_ctx_t* s, uint64_t* bl, uint64_t* br, 
-                      uint8_t roundop, uint8_t keychoice);
-/*****************************************************************************/
-
-
-void camellia128_enc(void* block, const camellia128_ctx_t* s){
-
-       #define BL (((uint64_t*)block)[0])
-       #define BR (((uint64_t*)block)[1])
-       /* endian adjustment */
-        /*BL*/
-        /* 1 2 3 4 5 6 7 8
-         *     8 7 6 5 4 3 2 1
-         */
-        
-       uint64_t temp64;
-       
-       change_endian(&BL, 64/8);       
-       change_endian(&BR, 64/8);
-       
-       /* Prewhitening */
-       BL ^= s->kll;
-       BR ^= s->klr;
-       
-       /* the first 6 */
-       camellia_6rounds(s, &BL, &BR, KEY_ROL15 | KEY_DIR_NORM | KEY_POSTC1 , 0x33);
-       /* FL injection  */
-   camellia128_keyop((camellia128_ctx_t*)s, -1);
-       BL = camellia_fl(BL, s->kal);
-       BR = camellia_fl_inv(BR, s->kar);
-   camellia128_keyop((camellia128_ctx_t*)s, -1);
-       /* middle 6 */
-       camellia_6rounds(s, &BL, &BR, KEY_ROL15 | KEY_DIR_NORM | KEY_INC2 , 0x34);
-       /* FL injection  */
-   camellia128_keyop((camellia128_ctx_t*)s, 1);
-       BL = camellia_fl(BL, s->kll);
-       BR = camellia_fl_inv(BR, s->klr);
-   camellia128_keyop((camellia128_ctx_t*)s, 1);
-   /* last 6 */
-       camellia_6rounds(s, &BL, &BR, KEY_ROL17 | KEY_DIR_NORM | KEY_POSTC2 , 0x0C);
-       /* Postwhitening */
-       BR ^= s->kal;
-       BL ^= s->kar;
-       
-       temp64 = BR;
-       BR = BL;
-       BL = temp64;
-
-       camellia128_keyop((camellia128_ctx_t*)s,1);
-       
-       change_endian(&BL, 64/8);       
-       change_endian(&BR, 64/8);
-               
-       #undef BL
-       #undef BR       
-}
-
-/*****************************************************************************/
-
-void camellia128_dec(void* block, const camellia128_ctx_t* s){
-
-       #define BL (((uint64_t*)block)[1])
-       #define BR (((uint64_t*)block)[0])
-       /* endian adjustment */
-        /*BL*/
-        /* 1 2 3 4 5 6 7 8
-         * 8 7 6 5 4 3 2 1
-         */
-        
-       uint64_t temp64;
-               
-       change_endian(&BL, 64/8);       
-       change_endian(&BR, 64/8);
-               
-       camellia128_keyop_inv((camellia128_ctx_t*)s, 1);
-       /* Prewhitening */
-       BR ^= s->kal; /* kw3 */
-       BL ^= s->kar; /* kw4 */
-       /* the first 6 */
-       camellia_6rounds(s, &BR, &BL, KEY_ROL17 | KEY_DIR_INV | KEY_POSTC1 , 0x0C);
-       /* FL injection  */
-   camellia128_keyop_inv((camellia128_ctx_t*)s, 1);
-       BR = camellia_fl(BR, s->klr);
-       BL = camellia_fl_inv(BL, s->kll);
-   camellia128_keyop_inv((camellia128_ctx_t*)s, 1);
-       /* middle 6 */  
-       camellia_6rounds(s, &BR, &BL, KEY_ROL15 | KEY_DIR_INV | KEY_INC2 , 0x0B);
-       /* FL injection  */
-   camellia128_keyop_inv((camellia128_ctx_t*)s, -1);
-       BR = camellia_fl(BR, s->kar);
-       BL = camellia_fl_inv(BL, s->kal);
-   camellia128_keyop_inv((camellia128_ctx_t*)s, -1);
-   /* last 6 */
-       camellia_6rounds(s, &BR, &BL, KEY_ROL15 | KEY_DIR_INV | KEY_POSTC2 , 0x33);
-       
-       /* Postwhitening */
-       BL ^= s->kll; /* kw1 */ 
-       BR ^= s->klr; /* kw2 */
-       
-       temp64 = BR;
-       BR = BL;
-       BL = temp64;
-       
-       change_endian(&BL, 64/8);       
-       change_endian(&BR, 64/8);
-               
-}
-
-/*****************************************************************************/
-/*****************************************************************************/
-
-
-
-/* EOF */
index 99700895d6fc1da5ae80afa7d64c8d28d59fab04..0ae637d0ff176d2a7ef82f7e517588e65c644688 100644 (file)
@@ -29,7 +29,7 @@ typedef struct camellia128_ctx_s{
 }camellia128_ctx_t;
 
 
-void camellia128_init(const uint8_t* key, camellia128_ctx_t* s);
+void camellia128_init(const void* key, camellia128_ctx_t* s);
 void camellia128_enc(void* block, const camellia128_ctx_t* s);
 void camellia128_dec(void* block, const camellia128_ctx_t* s);
 
diff --git a/camellia128-stub.c b/camellia128-stub.c
new file mode 100644 (file)
index 0000000..3461d1f
--- /dev/null
@@ -0,0 +1,249 @@
+/* camellia128-stub.c */
+/*
+    This file is part of the Crypto-avr-lib/microcrypt-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/>.
+*/
+/**
+ * 
+ * 
+ * 
+ * 
+ */
+#include <stdint.h>
+#include <avr/io.h>
+#include <avr/pgmspace.h>
+#include "camellia.h"
+#if 0
+ #include "uart.h"
+ #include "debug.h"
+ #include <util/delay.h>
+#endif
+/*****************************************************************************/
+uint64_t camellia_f(uint64_t x, uint64_t k);
+/*****************************************************************************/
+uint64_t camellia_fl(uint64_t x, uint64_t k);
+/*****************************************************************************/
+uint64_t camellia_fl_inv(uint64_t y, uint64_t k);
+/*****************************************************************************/
+void change_endian(void* data, uint8_t length);
+/*
+uint64_t PROGMEM camellia_sigma[6]={ / * 64 byte table * /
+       0xA09E667F3BCC908BLL,
+       0xB67AE8584CAA73B2LL,
+       0xC6EF372FE94F82BELL,
+       0x54FF53A5F1D36F1CLL,
+       0x10E527FADE682D1DLL,
+       0xB05688C2B3E6C1FDLL
+};     
+*/
+uint32_t PROGMEM camellia_sigma[12]={ /* 48 byte table */
+         0x3BCC908BL, 0xA09E667FL,
+         0x4CAA73B2L, 0xB67AE858L,
+         0xE94F82BEL, 0xC6EF372FL,
+         0xF1D36F1CL, 0x54FF53A5L,
+         0xDE682D1DL, 0x10E527FAL,
+         0xB3E6C1FDL, 0xB05688C2L
+};
+
+/* an ugly macro to load an entry form the table above */
+/*
+#define SIGMA(p) (( ((uint64_t)(pgm_read_dword((prog_uint32_t*)camellia_sigma+2*(p)+1)))<<32) | \
+                    ((uint64_t)(pgm_read_dword((prog_uint32_t*)camellia_sigma+2*(p)+0))) )
+*/
+#define SIGMA(p) (( ((uint64_t)(pgm_read_dword(&(((prog_uint32_t*)camellia_sigma)[2*(p)+1]))))<<32) | \
+                    ((uint64_t)(pgm_read_dword(&(((prog_uint32_t*)camellia_sigma)[2*(p)+0])))) )
+
+
+
+/*****************************************************************************/
+/*
+void camellia128_ctx_dump(camellia128_ctx_t *s){
+       uart_putstr_P(PSTR("\r\n==State Dump=="));
+       uart_putstr_P(PSTR("\n\rKAl: ")); uart_hexdump(&(s->kal), 8);
+       uart_putstr_P(PSTR("\n\rKAr: ")); uart_hexdump(&(s->kar), 8);
+       uart_putstr_P(PSTR("\n\rKLl: ")); uart_hexdump(&(s->kll), 8);
+       uart_putstr_P(PSTR("\n\rKLr: ")); uart_hexdump(&(s->klr), 8);   
+       return;
+}
+*/
+/*****************************************************************************/
+/* extern prog_uint64_t camellia_sigma[6]; */
+
+void camellia128_init(const void* key, camellia128_ctx_t* s){
+       uint8_t i;
+       s->kll = 0; /* ((uint64_t*)key)[0]; */
+       
+       /* load the key, endian-adjusted, to kll,klr */
+       for(i=0; i<8; ++i){
+               s->kll <<= 8;
+               s->kll |= *((uint8_t*)key);
+               key = (uint8_t*)key+1;
+       }
+       for(i=0; i<8; ++i){
+               s->klr <<= 8;
+               s->klr |= *((uint8_t*)key);
+               key = (uint8_t*)key+1;
+       }
+
+       s->kal = s->kll;
+       s->kar = s->klr;
+       
+       s->kar ^= camellia_f(s->kal, SIGMA(0));
+       s->kal ^= camellia_f(s->kar, SIGMA(1));
+       
+       s->kal ^= s->kll;
+       s->kar ^= s->klr;
+       
+       s->kar ^= camellia_f(s->kal, SIGMA(2));
+       s->kal ^= camellia_f(s->kar, SIGMA(3));
+}
+
+/*****************************************************************************/
+void camellia128_keyop(camellia128_ctx_t* s, int8_t q);
+/*****************************************************************************/
+void camellia128_keyop_inv(camellia128_ctx_t* s, int8_t q); 
+/*****************************************************************************/
+
+#define SEL_KA 1
+#define SEL_KL 0
+
+#define KEY_POSTC1             0x00
+#define KEY_POSTC2             0x01
+#define KEY_INC2               0x02
+
+#define KEY_DIR                        0x04
+#define KEY_DIR_NORM   0x00
+#define KEY_DIR_INV            0x04
+
+#define KEY_AMMOUNT            0x08 
+#define KEY_ROL17              0x08
+#define KEY_ROL15              0x00
+
+void camellia_6rounds(const camellia128_ctx_t* s, uint64_t* bl, uint64_t* br, 
+                      uint8_t roundop, uint8_t keychoice);
+/*****************************************************************************/
+
+
+void camellia128_enc(void* block, const camellia128_ctx_t* s){
+
+       #define BL (((uint64_t*)block)[0])
+       #define BR (((uint64_t*)block)[1])
+       /* endian adjustment */
+        /*BL*/
+        /* 1 2 3 4 5 6 7 8
+         *     8 7 6 5 4 3 2 1
+         */
+        
+       uint64_t temp64;
+       
+       change_endian(&BL, 64/8);       
+       change_endian(&BR, 64/8);
+       
+       /* Prewhitening */
+       BL ^= s->kll;
+       BR ^= s->klr;
+       
+       /* the first 6 */
+       camellia_6rounds(s, &BL, &BR, KEY_ROL15 | KEY_DIR_NORM | KEY_POSTC1 , 0x33);
+       /* FL injection  */
+   camellia128_keyop((camellia128_ctx_t*)s, -1);
+       BL = camellia_fl(BL, s->kal);
+       BR = camellia_fl_inv(BR, s->kar);
+   camellia128_keyop((camellia128_ctx_t*)s, -1);
+       /* middle 6 */
+       camellia_6rounds(s, &BL, &BR, KEY_ROL15 | KEY_DIR_NORM | KEY_INC2 , 0x34);
+       /* FL injection  */
+   camellia128_keyop((camellia128_ctx_t*)s, 1);
+       BL = camellia_fl(BL, s->kll);
+       BR = camellia_fl_inv(BR, s->klr);
+   camellia128_keyop((camellia128_ctx_t*)s, 1);
+   /* last 6 */
+       camellia_6rounds(s, &BL, &BR, KEY_ROL17 | KEY_DIR_NORM | KEY_POSTC2 , 0x0C);
+       /* Postwhitening */
+       BR ^= s->kal;
+       BL ^= s->kar;
+       
+       temp64 = BR;
+       BR = BL;
+       BL = temp64;
+
+       camellia128_keyop((camellia128_ctx_t*)s,1);
+       
+       change_endian(&BL, 64/8);       
+       change_endian(&BR, 64/8);
+               
+       #undef BL
+       #undef BR       
+}
+
+/*****************************************************************************/
+
+void camellia128_dec(void* block, const camellia128_ctx_t* s){
+
+       #define BL (((uint64_t*)block)[1])
+       #define BR (((uint64_t*)block)[0])
+       /* endian adjustment */
+        /*BL*/
+        /* 1 2 3 4 5 6 7 8
+         * 8 7 6 5 4 3 2 1
+         */
+        
+       uint64_t temp64;
+               
+       change_endian(&BL, 64/8);       
+       change_endian(&BR, 64/8);
+               
+       camellia128_keyop_inv((camellia128_ctx_t*)s, 1);
+       /* Prewhitening */
+       BR ^= s->kal; /* kw3 */
+       BL ^= s->kar; /* kw4 */
+       /* the first 6 */
+       camellia_6rounds(s, &BR, &BL, KEY_ROL17 | KEY_DIR_INV | KEY_POSTC1 , 0x0C);
+       /* FL injection  */
+   camellia128_keyop_inv((camellia128_ctx_t*)s, 1);
+       BR = camellia_fl(BR, s->klr);
+       BL = camellia_fl_inv(BL, s->kll);
+   camellia128_keyop_inv((camellia128_ctx_t*)s, 1);
+       /* middle 6 */  
+       camellia_6rounds(s, &BR, &BL, KEY_ROL15 | KEY_DIR_INV | KEY_INC2 , 0x0B);
+       /* FL injection  */
+   camellia128_keyop_inv((camellia128_ctx_t*)s, -1);
+       BR = camellia_fl(BR, s->kar);
+       BL = camellia_fl_inv(BL, s->kal);
+   camellia128_keyop_inv((camellia128_ctx_t*)s, -1);
+   /* last 6 */
+       camellia_6rounds(s, &BR, &BL, KEY_ROL15 | KEY_DIR_INV | KEY_POSTC2 , 0x33);
+       
+       /* Postwhitening */
+       BL ^= s->kll; /* kw1 */ 
+       BR ^= s->klr; /* kw2 */
+       
+       temp64 = BR;
+       BR = BL;
+       BL = temp64;
+       
+       change_endian(&BL, 64/8);       
+       change_endian(&BR, 64/8);
+               
+}
+
+/*****************************************************************************/
+/*****************************************************************************/
+
+
+
+/* EOF */
index f341d6b566832853c8b4666bb88959f40acf4554..1db82f33ddc9032aac1724557f2963b488146f82 100644 (file)
 #include <avr/io.h>
 #include <avr/pgmspace.h>
 #include "camellia.h"
-#include "uart.h"
-#include "debug.h"
-#include <util/delay.h>
+#if 0
+ #include "uart.h"
+ #include "debug.h"
+ #include <util/delay.h>
+#endif 
 /*****************************************************************************/
 
 uint8_t rol(uint8_t a, uint8_t n){return ((a<<n) | (a>>(8-n)));}
@@ -54,22 +55,22 @@ uint64_t rol64(uint64_t a, uint8_t n){
 /*****************************************************************************/
  
 uint8_t camellia_s1_table[256] PROGMEM = {
      112, 130,  44, 236, 179,  39, 192, 229, 228, 133,  87,  53, 234,  12, 174,  65,
-        35, 239, 107, 147,  69,  25, 165,  33, 237,  14,  79,  78,  29, 101, 146, 189,
      134, 184, 175, 143, 124, 235,  31, 206,  62,  48, 220,  95,  94, 197,  11,  26,
      166, 225,  57, 202, 213,  71,  93,  61, 217,   1,  90, 214,  81,  86, 108,  77,
      139,  13, 154, 102, 251, 204, 176,  45, 116,  18,  43,  32, 240, 177, 132, 153,
      223,  76, 203, 194,  52, 126, 118,   5, 109, 183, 169,  49, 209,  23,   4, 215,
-        20,  88,  58,  97, 222,  27,  17,  28,  50,  15, 156,  22,  83,  24, 242,  34,
      254,  68, 207, 178, 195, 181, 122, 145,  36,   8, 232, 168,  96, 252, 105,  80,
      170, 208, 160, 125, 161, 137,  98, 151,  84,  91,  30, 149, 224, 255, 100, 210,
-        16, 196,   0,  72, 163, 247, 117, 219, 138,   3, 230, 218,   9,  63, 221, 148,
      135,  92, 131,   2, 205,  74, 144,  51, 115, 103, 246, 243, 157, 127, 191, 226,
-        82, 155, 216,  38, 200,  55, 198,  59, 129, 150, 111,  75,  19, 190,  99,  46,
      233, 121, 167, 140, 159, 110, 188, 142,  41, 245, 249, 182,  47, 253, 180,  89,
      120, 152,   6, 106, 231,  70, 113, 186, 212,  37, 171,  66, 136, 162, 141, 250,
      114,   7, 185,  85, 248, 238, 172,  10,  54,  73,  42, 104,  60,  56, 241, 164,
-        64,  40, 211, 123, 187, 201,  67, 193,  21, 227, 173, 244, 119, 199, 128, 158
+ 112, 130,  44, 236, 179,  39, 192, 229, 228, 133,  87,  53, 234,  12, 174,  65,
+  35, 239, 107, 147,  69,  25, 165,  33, 237,  14,  79,  78,  29, 101, 146, 189,
+ 134, 184, 175, 143, 124, 235,  31, 206,  62,  48, 220,  95,  94, 197,  11,  26,
+ 166, 225,  57, 202, 213,  71,  93,  61, 217,   1,  90, 214,  81,  86, 108,  77,
+ 139,  13, 154, 102, 251, 204, 176,  45, 116,  18,  43,  32, 240, 177, 132, 153,
+ 223,  76, 203, 194,  52, 126, 118,   5, 109, 183, 169,  49, 209,  23,   4, 215,
+  20,  88,  58,  97, 222,  27,  17,  28,  50,  15, 156,  22,  83,  24, 242,  34,
+ 254,  68, 207, 178, 195, 181, 122, 145,  36,   8, 232, 168,  96, 252, 105,  80,
+ 170, 208, 160, 125, 161, 137,  98, 151,  84,  91,  30, 149, 224, 255, 100, 210,
+  16, 196,   0,  72, 163, 247, 117, 219, 138,   3, 230, 218,   9,  63, 221, 148,
+ 135,  92, 131,   2, 205,  74, 144,  51, 115, 103, 246, 243, 157, 127, 191, 226,
+  82, 155, 216,  38, 200,  55, 198,  59, 129, 150, 111,  75,  19, 190,  99,  46,
+ 233, 121, 167, 140, 159, 110, 188, 142,  41, 245, 249, 182,  47, 253, 180,  89,
+ 120, 152,   6, 106, 231,  70, 113, 186, 212,  37, 171,  66, 136, 162, 141, 250,
+ 114,   7, 185,  85, 248, 238, 172,  10,  54,  73,  42, 104,  60,  56, 241, 164,
+  64,  40, 211, 123, 187, 201,  67, 193,  21, 227, 173, 244, 119, 199, 128, 158
 };
 
 /*****************************************************************************/
@@ -155,29 +156,24 @@ uint64_t camellia_p(uint64_t d){
 uint64_t camellia_f(uint64_t x, uint64_t k){
        uint64_t y;
        y = camellia_p(camellia_s(x ^ k));
-/*
-       uart_putstr("\r\nEfunc X=");
-       uart_hexdump(&(x), 8);
-       uart_putstr("  K=");
-       uart_hexdump(&(k), 8);
-       uart_putstr("  Y=");
-       uart_hexdump(&(y), 8);
-*/     
        return y;
 }
 
 /*****************************************************************************/
 
 uint64_t camellia_fl(uint64_t x, uint64_t k){
-       uint64_t lx[1], lk[1], y[1];
-       lx[0]=x; lk[0] = k; 
-       
+//     uint64_t lx, lk, y;
+       uint32_t lx[2], lk[2], yr, yl;
+       lx[0]=(uint32_t)x;
+       lx[1]=(uint32_t)(x>>32); 
+       lk[0]=(uint32_t)k; 
+       lk[1]=(uint32_t)(k>>32); 
        #define Y ((uint32_t*)y)
        #define X ((uint32_t*)lx)
        #define K ((uint32_t*)lk)
 
-       Y[0] = rol32((X[1]) & K[1] ,1) ^ (X[0]); /* Yr */
-       Y[1] = (Y[0] | K[0]) ^ (X[1]);           /* Yl */
+       yr = rol32((X[1]) & (K[1]) ,1) ^ (X[0]); /* Yr */
+       yl = (yr | K[0]) ^ (X[1]);           /* Yl */
        
 /*     
        uart_putstr("\r\nFL(");
@@ -190,15 +186,18 @@ uint64_t camellia_fl(uint64_t x, uint64_t k){
        #undef K
        #undef X
        #undef Y
-       return y[0];    
+       return (((uint64_t)yl)<<32 | yr);       
 }
 
 /*****************************************************************************/
 
 uint64_t camellia_fl_inv(uint64_t y, uint64_t k){
 //volatile     uint32_t xl, xr;
-       volatile uint64_t ly[1], lk[1], x[1];
-       ly[0]=y; lk[0] = k; 
+       uint32_t ly[2], lk[2], x[2];
+       ly[0]=(uint32_t)y;
+       ly[1]=(uint32_t)(y>>32);
+       lk[0]=(uint32_t)k; 
+       lk[1]=(uint32_t)(k>>32); 
        #define Y ((uint32_t*)ly) 
        #define X ((uint32_t*)x) 
        #define K ((uint32_t*)lk) 
@@ -216,7 +215,7 @@ uint64_t camellia_fl_inv(uint64_t y, uint64_t k){
        #undef K
        #undef X
        #undef Y
-       return x[0];    
+       return ((uint64_t)(x[1]))<<32 | x[0];   
 }
 
 /*****************************************************************************/
@@ -231,7 +230,7 @@ uint64_t camellia_sigma[6]={
 };     
 
 /*****************************************************************************/
-
+#if 0
 void camellia128_ctx_dump(camellia128_ctx_t *s){
        uart_putstr("\r\n==State Dump==");
        uart_putstr("\n\rKAl: "); uart_hexdump(&(s->kal), 8);
@@ -240,21 +239,23 @@ void camellia128_ctx_dump(camellia128_ctx_t *s){
        uart_putstr("\n\rKLr: "); uart_hexdump(&(s->klr), 8);   
        return;
 }
-
+#endif
 /*****************************************************************************/
 
-void camellia128_init(const uint8_t* key, camellia128_ctx_t* s){
+void camellia128_init(const void* key, camellia128_ctx_t* s){
        uint8_t i;
        s->kll = 0; //((uint64_t*)key)[0];
        
        /* load the key, endian-adjusted, to kll,klr */
        for(i=0; i<8; ++i){
                s->kll <<= 8;
-               s->kll |= *key++;
+               s->kll |= *((uint8_t*)key);
+               key = (uint8_t*)key+1;
        }
        for(i=0; i<8; ++i){
                s->klr <<= 8;
-               s->klr |= *key++;
+               s->klr |= *((uint8_t*)key);
+               key = (uint8_t*)key+1;
        }
        
        s->kal = s->kll;
@@ -309,31 +310,31 @@ void camellia128_keyop_inv(camellia128_ctx_t* s, int8_t q){
 #define SEL_KA 1
 #define SEL_KL 0
 
-#define KEY_POSTC1             0x00
-#define KEY_POSTC2             0x01
-#define KEY_INC2               0x02
+#define KEY_POSTC1              0x00
+#define KEY_POSTC2              0x01
+#define KEY_INC2                0x02
 
-#define KEY_DIR                        0x04
-#define KEY_DIR_NORM   0x00
-#define KEY_DIR_INV            0x04
+#define KEY_DIR                        0x04
+#define KEY_DIR_NORM            0x00
+#define KEY_DIR_INV             0x04
 
-#define KEY_AMMOUNT            0x08 
-#define KEY_ROL17              0x08
-#define KEY_ROL15              0x00
+#define KEY_AMMOUNT             0x08 
+#define KEY_ROL17               0x08
+#define KEY_ROL15               0x00
 
 void camellia_6rounds(const camellia128_ctx_t* s, uint64_t* bl, uint64_t* br, uint8_t roundop, uint8_t keychoice){
        uint8_t i;
        uint64_t* k[4];
-       k[0] = &(s->kll);
-       k[1] = &(s->klr);
-       k[2] = &(s->kal);
-       k[3] = &(s->kar);
+       k[0] = &(((camellia128_ctx_t*)s)->kll);
+       k[1] = &(((camellia128_ctx_t*)s)->klr);
+       k[2] = &(((camellia128_ctx_t*)s)->kal);
+       k[3] = &(((camellia128_ctx_t*)s)->kar);
        for(i=0; i<3; ++i){ /* each cycle */
                br[0] ^= camellia_f(bl[0],*(k[(keychoice&1)*2+((roundop&KEY_DIR)?1:0)]));
                keychoice >>= 1;
                
                if((i == 1) && (roundop&KEY_INC2)){
-                       ((roundop&KEY_DIR)?camellia128_keyop_inv:camellia128_keyop)(s,(roundop&KEY_AMMOUNT)?1:-1);
+                       ((roundop&KEY_DIR)?camellia128_keyop_inv:camellia128_keyop)(((camellia128_ctx_t*)s),(roundop&KEY_AMMOUNT)?1:-1);
                }
                
                bl[0] ^= camellia_f(br[0],*(k[(keychoice&1)*2+((roundop&KEY_DIR)?0:1)]));
@@ -341,7 +342,7 @@ void camellia_6rounds(const camellia128_ctx_t* s, uint64_t* bl, uint64_t* br, ui
                
                /* check if we should do some keyop */
                if((i == (roundop&1)) && (!(roundop&KEY_INC2)) ){
-                       ((roundop&KEY_DIR)?camellia128_keyop_inv:camellia128_keyop)(s,(roundop&KEY_AMMOUNT)?1:-1);
+                       ((roundop&KEY_DIR)?camellia128_keyop_inv:camellia128_keyop)(((camellia128_ctx_t*)s),(roundop&KEY_AMMOUNT)?1:-1);
                        /* isn't it fuckin nice what we can do in C?! */
                }
        }
@@ -349,6 +350,16 @@ void camellia_6rounds(const camellia128_ctx_t* s, uint64_t* bl, uint64_t* br, ui
 
 /*****************************************************************************/
 
+void change_endian(void* data, uint8_t length){
+       uint8_t i,a;
+       for(i=0; i<length/2; ++i){
+               a = ((uint8_t*)data)[i];
+               ((uint8_t*)data)[i] = ((uint8_t*)data)[length-i-1];
+               ((uint8_t*)data)[length-i-1] = a;
+       }
+}
+
+/*****************************************************************************/
 
 void camellia128_enc(void* block, const camellia128_ctx_t* s){
 
@@ -361,32 +372,15 @@ void camellia128_enc(void* block, const camellia128_ctx_t* s){
          */
         
        uint64_t temp64;
-
-       temp64 = BL;
-       BL = temp64 >> 56 | temp64 << 56  /* swap the most out bytes (1 & 8) */
-               | (temp64 & (0xffLL<<48))>>(5*8) | (temp64 & (0xffLL<< 8))<<(5*8) /* 2 & 7 */
-               | (temp64 & (0xffLL<<40))>>(3*8) | (temp64 & (0xffLL<<16))<<(3*8) /* 3 & 6 */           
-               | (temp64 & (0xffLL<<32))>>(1*8) | (temp64 & (0xffLL<<24))<<(1*8); /* 4 & 5 */
-       temp64 = BR;
-       BR = temp64 >> 56 | temp64 << 56  /* swap the most out bytes (1 & 8) */
-               | (temp64 & (0xffLL<<48))>>(5*8) | (temp64 & (0xffLL<< 8))<<(5*8) /* 2 & 7 */
-               | (temp64 & (0xffLL<<40))>>(3*8) | (temp64 & (0xffLL<<16))<<(3*8) /* 3 & 6 */           
-               | (temp64 & (0xffLL<<32))>>(1*8) | (temp64 & (0xffLL<<24))<<(1*8); /* 4 & 5 */
+       
+       change_endian(&BL, 64/8);       
+       change_endian(&BR, 64/8);
        
        /* Prewhitening */
        BL ^= s->kll;
        BR ^= s->klr;
        
        /* the first 6 */
-/*     
-       BR ^= camellia_f(BL, s->kal);
-       BL ^= camellia_f(BR, s->kar);
-   camellia128_keyop(s, -1);
-       BR ^= camellia_f(BL, s->kll);
-       BL ^= camellia_f(BR, s->klr);
-       BR ^= camellia_f(BL, s->kal);
-       BL ^= camellia_f(BR, s->kar);
-*/
        camellia_6rounds(s, &BL, &BR, KEY_ROL15 | KEY_DIR_NORM | KEY_POSTC1 , 0x33);
        /* FL injection  */
    camellia128_keyop((camellia128_ctx_t*)s, -1);
@@ -394,14 +388,6 @@ void camellia128_enc(void* block, const camellia128_ctx_t* s){
        BR = camellia_fl_inv(BR, s->kar);
    camellia128_keyop((camellia128_ctx_t*)s, -1);
        /* middle 6 */
-/*     BR ^= camellia_f(BL, s->kll);
-       BL ^= camellia_f(BR, s->klr);
-       BR ^= camellia_f(BL, s->kal);
-   camellia128_keyop(s, -1);
-       BL ^= camellia_f(BR, s->klr);
-       BR ^= camellia_f(BL, s->kal);
-       BL ^= camellia_f(BR, s->kar);
-/*/
        camellia_6rounds(s, &BL, &BR, KEY_ROL15 | KEY_DIR_NORM | KEY_INC2 , 0x34);
        /* FL injection  */
    camellia128_keyop((camellia128_ctx_t*)s, 1);
@@ -409,15 +395,6 @@ void camellia128_enc(void* block, const camellia128_ctx_t* s){
        BR = camellia_fl_inv(BR, s->klr);
    camellia128_keyop((camellia128_ctx_t*)s, 1);
    /* last 6 */
-/*     BR ^= camellia_f(BL, s->kll);
-       BL ^= camellia_f(BR, s->klr);
-       BR ^= camellia_f(BL, s->kal);
-       BL ^= camellia_f(BR, s->kar);
-   camellia128_keyop(s, 1);
-  
-       BR ^= camellia_f(BL, s->kll);
-       BL ^= camellia_f(BR, s->klr);
-*/
        camellia_6rounds(s, &BL, &BR, KEY_ROL17 | KEY_DIR_NORM | KEY_POSTC2 , 0x0C);
        /* Postwhitening */
        BR ^= s->kal;
@@ -427,16 +404,10 @@ void camellia128_enc(void* block, const camellia128_ctx_t* s){
        BR = BL;
        BL = temp64;
 
+       camellia128_keyop((camellia128_ctx_t*)s,1);
        
-       BL = temp64 >> 56 | temp64 << 56  /* swap the most out bytes (1 & 8) */
-               | (temp64 & (0xffLL<<48))>>(5*8) | (temp64 & (0xffLL<< 8))<<(5*8) /* 2 & 7 */
-               | (temp64 & (0xffLL<<40))>>(3*8) | (temp64 & (0xffLL<<16))<<(3*8) /* 3 & 6 */           
-               | (temp64 & (0xffLL<<32))>>(1*8) | (temp64 & (0xffLL<<24))<<(1*8); /* 4 & 5 */
-       temp64 = BR;
-       BR = temp64 >> 56 | temp64 << 56  /* swap the most out bytes (1 & 8) */
-               | (temp64 & (0xffLL<<48))>>(5*8) | (temp64 & (0xffLL<< 8))<<(5*8) /* 2 & 7 */
-               | (temp64 & (0xffLL<<40))>>(3*8) | (temp64 & (0xffLL<<16))<<(3*8) /* 3 & 6 */           
-               | (temp64 & (0xffLL<<32))>>(1*8) | (temp64 & (0xffLL<<24))<<(1*8); /* 4 & 5 */
+       change_endian(&BL, 64/8);       
+       change_endian(&BR, 64/8);
                
        #undef BL
        #undef BR       
@@ -455,67 +426,28 @@ void camellia128_dec(void* block, const camellia128_ctx_t* s){
          */
         
        uint64_t temp64;
-       
-       temp64 = BL;
-
-       BL = temp64 >> 56 | temp64 << 56  /* swap the most out bytes (1 & 8) */
-               | (temp64 & (0xffLL<<48))>>(5*8) | (temp64 & (0xffLL<< 8))<<(5*8) /* 2 & 7 */
-               | (temp64 & (0xffLL<<40))>>(3*8) | (temp64 & (0xffLL<<16))<<(3*8) /* 3 & 6 */           
-               | (temp64 & (0xffLL<<32))>>(1*8) | (temp64 & (0xffLL<<24))<<(1*8); /* 4 & 5 */
-       temp64 = BR;
-       BR = temp64 >> 56 | temp64 << 56  /* swap the most out bytes (1 & 8) */
-               | (temp64 & (0xffLL<<48))>>(5*8) | (temp64 & (0xffLL<< 8))<<(5*8) /* 2 & 7 */
-               | (temp64 & (0xffLL<<40))>>(3*8) | (temp64 & (0xffLL<<16))<<(3*8) /* 3 & 6 */           
-               | (temp64 & (0xffLL<<32))>>(1*8) | (temp64 & (0xffLL<<24))<<(1*8); /* 4 & 5 */
+       change_endian(&BL, 64/8);       
+       change_endian(&BR, 64/8);
                
        camellia128_keyop_inv((camellia128_ctx_t*)s, 1);
        /* Prewhitening */
        BR ^= s->kal; /* kw3 */
        BL ^= s->kar; /* kw4 */
-
        /* the first 6 */
-/*     
-       BL ^= camellia_f(BR, s->klr); /* k18 * /
-       BR ^= camellia_f(BL, s->kll); /* k17 * /
-   camellia128_keyop_inv(s, 1);
-       BL ^= camellia_f(BR, s->kar);
-       BR ^= camellia_f(BL, s->kal);
-       BL ^= camellia_f(BR, s->klr);
-       BR ^= camellia_f(BL, s->kll);
-*/
        camellia_6rounds(s, &BR, &BL, KEY_ROL17 | KEY_DIR_INV | KEY_POSTC1 , 0x0C);
-
        /* FL injection  */
    camellia128_keyop_inv((camellia128_ctx_t*)s, 1);
        BR = camellia_fl(BR, s->klr);
        BL = camellia_fl_inv(BL, s->kll);
    camellia128_keyop_inv((camellia128_ctx_t*)s, 1);
        /* middle 6 */  
-/*     BL ^= camellia_f(BR, s->kar);
-       BR ^= camellia_f(BL, s->kal);
-       BL ^= camellia_f(BR, s->klr);
-   camellia128_keyop_inv(s, -1);
-       BR ^= camellia_f(BL, s->kal);
-       BL ^= camellia_f(BR, s->klr);
-       BR ^= camellia_f(BL, s->kll);
-*/
        camellia_6rounds(s, &BR, &BL, KEY_ROL15 | KEY_DIR_INV | KEY_INC2 , 0x0B);
-
        /* FL injection  */
-   camellia128_keyop_inv(s, -1);
+   camellia128_keyop_inv((camellia128_ctx_t*)s, -1);
        BR = camellia_fl(BR, s->kar);
        BL = camellia_fl_inv(BL, s->kal);
    camellia128_keyop_inv((camellia128_ctx_t*)s, -1);
    /* last 6 */
-/*   
-       BL ^= camellia_f(BR, s->kar);
-       BR ^= camellia_f(BL, s->kal);
-       BL ^= camellia_f(BR, s->klr);
-       BR ^= camellia_f(BL, s->kll);
-   camellia128_keyop_inv(s, -1);
-       BL ^= camellia_f(BR, s->kar);
-       BR ^= camellia_f(BL, s->kal);
-/*/
        camellia_6rounds(s, &BR, &BL, KEY_ROL15 | KEY_DIR_INV | KEY_POSTC2 , 0x33);
        
        /* Postwhitening */
@@ -525,20 +457,14 @@ void camellia128_dec(void* block, const camellia128_ctx_t* s){
        temp64 = BR;
        BR = BL;
        BL = temp64;
-
        
-       BL = temp64 >> 56 | temp64 << 56  /* swap the most out bytes (1 & 8) */
-               | (temp64 & (0xffLL<<48))>>(5*8) | (temp64 & (0xffLL<< 8))<<(5*8) /* 2 & 7 */
-               | (temp64 & (0xffLL<<40))>>(3*8) | (temp64 & (0xffLL<<16))<<(3*8) /* 3 & 6 */           
-               | (temp64 & (0xffLL<<32))>>(1*8) | (temp64 & (0xffLL<<24))<<(1*8); /* 4 & 5 */
-       temp64 = BR;
-       BR = temp64 >> 56 | temp64 << 56  /* swap the most out bytes (1 & 8) */
-               | (temp64 & (0xffLL<<48))>>(5*8) | (temp64 & (0xffLL<< 8))<<(5*8) /* 2 & 7 */
-               | (temp64 & (0xffLL<<40))>>(3*8) | (temp64 & (0xffLL<<16))<<(3*8) /* 3 & 6 */           
-               | (temp64 & (0xffLL<<32))>>(1*8) | (temp64 & (0xffLL<<24))<<(1*8); /* 4 & 5 */
+       change_endian(&BL, 64/8);       
+       change_endian(&BR, 64/8);
                
 }
 
+
+
 /*****************************************************************************/
 /*****************************************************************************/
 
index e4264befe114d4623dad663af9f02432e904de13..4305d0e9b6c889149e60ad067cf9fdb34e54127a 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := A5_1.o
 $(ALGO_NAME)_TEST_BIN := main-a5_1-test.o debug.o uart.o serial-tools.o \
                          nessie_stream_test.o nessie_common.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 58563f6fa5e7516a10a0cb87b3f212c21014380a..c1345ae6c66d4374fb76f7c0c26bd73695726879 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o serial-tools.o \
                          nessie_stream_test.o nessie_common.o cli.o \
                          performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 7e3d23ed7aa591f2a95f1bf32000ec7920ca5d61..7f7097783ef7225011d4b31305a92736c092976a 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_TEST_BIN := main-arcfour-test.o debug.o uart.o serial-tools.o \
                          nessie_stream_test.o nessie_common.o cli.o \
                          performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 1e304a9debb7a892f3570f9c9b3c8f4f162e2b8c..f6befb095a0799b652cf1ab54e3a653ab9dffdd4 100644 (file)
@@ -4,10 +4,10 @@ ALGO_NAME := CAMELLIA
 # comment out the following line for removement of Camellia from the build process
 BLOCK_CIPHERS += $(ALGO_NAME)
 
-$(ALGO_NAME)_OBJ      := camellia.o camellia-asm.o
+$(ALGO_NAME)_OBJ      := camellia128-stub.o camellia-asm.o
 $(ALGO_NAME)_TEST_BIN := main-camellia-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o \
                         nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 33c32bad13a4297b4043320600258165f02b2e02..1b772e4b541c86fe324a2090dd4a813560ba7cb9 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := cast5.o
 $(ALGO_NAME)_TEST_BIN := main-cast5-test.o debug.o uart.o serial-tools.o cli.o\
                          nessie_bc_test.o nessie_common.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 15c16ec2751153ece251a375874573fdf248ac06..ccfcc13e59bc4f48378a49d6b431f9cebf443a33 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := des.o
 $(ALGO_NAME)_TEST_BIN := main-des-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index e5806c3073416ea1f5f4bcb441059379bc21faf5..466d6ae63f43f98b3720fa53b2d625eef986cc7f 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_TEST_BIN := main-entropium-test.o debug.o uart.o serial-tools.o \
                          cli.o performance_test.o
                          
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 4f026a985a4bb2dd876ee8ce6612ee545b2e19c4..4fbdfcbb5cd035e12eda004a2b34e36785c9b50e 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_TEST_BIN := main-grain-test.o debug.o uart.o serial-tools.o \
                          nessie_stream_test.o nessie_common.o cli.o \
                                     performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index b63308ffafa73be31022f1e600860ec811d17ed0..fa2053be27a46432fae39097519d23f3d41c6a24 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := hmac-sha1.o sha1-asm.o
 $(ALGO_NAME)_TEST_BIN := main-hmac-sha1-test.o debug.o uart.o serial-tools.o cli.o \
                          nessie_mac_test.o nessie_common.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 6b665468891e93b3c5f952de60a006e2c59c5aa9..4bed2fab33173ef757fe80d8d9ce02801a7b2ce2 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := hmac-sha256.o sha256-asm.o
 $(ALGO_NAME)_TEST_BIN := main-hmac-sha256-test.o debug.o uart.o serial-tools.o \
                          nessie_mac_test.o nessie_common.o cli.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 3fb9d65902e7f27dff63f61d3e25179172bf2325..8c00703981fcc1c38740415411817a2378d05398 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := md5.o
 $(ALGO_NAME)_TEST_BIN := main-md5-test.o debug.o uart.o serial-tools.o \
                          nessie_hash_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 359aef37e5b258f45757bf418e8ab9850f3c3c44..0398879dfc3b7b73fad6934762efb620588e02c3 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_OBJ      := noekeon_asm.o
 $(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
-$(ALGO_NAME)_PEROFRMANCE_TEST := performance
+$(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index 90d378d128e0b17a49c4ca7effb8974bd63b9dce..84696fb895dd29d7f9d692195b3b8a37f1a25520 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_OBJ      := noekeon.o
 $(ALGO_NAME)_TEST_BIN := main-noekeon-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
-$(ALGO_NAME)_PEROFRMANCE_TEST := performance
+$(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index e30c506624594f338e3e698154b5d3d77547dfef..b614cc9f9ae5f2a53736d95325481f8e064cd2c9 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_OBJ      := present.o
 $(ALGO_NAME)_TEST_BIN := main-present-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index ff20873b03aa25344dbb99c7f986e287404bf04f..a64db3d6dc38585fae02acd12694af3f7947583c 100644 (file)
@@ -10,5 +10,5 @@ $(ALGO_NAME)_TEST_BIN := main-rc5-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o \
                          nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
-$(ALGO_NAME)_PEROFRMANCE_TEST := performance
+$(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index 47e2f00f6259f1f978fb4689a11f7efba3dd2da0..c660d29c0654b72eae5c064a551b9fc91ea51e9b 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_OBJ      := rc6.o
 $(ALGO_NAME)_TEST_BIN := main-rc6-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := test nessie
-$(ALGO_NAME)_PEROFRMANCE_TEST := performance
+$(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index 35724f239e9840e85166e8d3d788645632c276ef..ca2afced7a81c401c2921c9d3a910e7cf0bccf06 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_TEST_BIN := main-seed-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o \
                          cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 20bcf5e048ae8c1eeb6754bf5f84b6f07ed5b4e0..bde2ce4f5aeee0fed736fd6c4049fe48f5079e17 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_OBJ      := serpent-asm.o serpent-sboxes-bitslice.o memxor.o
 $(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 3b0d3c216d6a929109a467ba6c7b73993c295fdb..58258e78b38d856baf5deccf917d3f2837b2a2fc 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_OBJ      := serpent-asm.o serpent-sboxes-fast.o memxor.o
 $(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 78b8217da2dd683056adaefef167dcf132f06f1b..c696e2e9afb96f8199da39bb04015d0be9d8f70e 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_OBJ      := serpent-asm.o serpent-sboxes-small.o memxor.o
 $(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 11291b93bd3d09c61da087559da443b86484e934..94d05e68fc33267d74308dd223ef0297c65943c6 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_OBJ      := serpent.o serpent-sboxes_c.o memxor.o
 $(ALGO_NAME)_TEST_BIN := main-serpent-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index eb2d9196bb9a2515bbd7cda7efdb77ca66ec2c0f..8bdcef8b3b67ce5984489255055bc2da840ad291 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := sha1-asm.o
 $(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o serial-tools.o \
                          nessie_hash_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 061f7a9a073b299867fd91bebd997f9600f48dda..4dce2d9773116e574b292dd62eda666fcb52b427 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_TEST_BIN := main-sha1-test.o debug.o uart.o serial-tools.o \
                          nessie_hash_test.o nessie_common.o cli.o \
                         performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index dcea21f2230b1677b2e1d944ddc1859ba55fd0a1..d1dd3f5119e55ef952de2454dcbfca08d1ea4266 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := sha256-asm.o
 $(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o serial-tools.o \
                          nessie_hash_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index cf850fcad6e09d5be4ea889961fa5bc1cadd9250..0a85c4f30296e70bc2dbfee7881acabb95092401 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := sha256.o
 $(ALGO_NAME)_TEST_BIN := main-sha256-test.o debug.o uart.o serial-tools.o \
                          nessie_hash_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 4e9acaffd453e85995ec77fbe31aa944229f55d8..1b55cbde3bcd8b158b0d589b8d2ce34901b5affa 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := shabea.o sha256-asm.o memxor.o
 $(ALGO_NAME)_TEST_BIN := main-shabea-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index d329db79ec54beef13768d2c95721db4a85115df..56087b7d51bbcd3bbb10a0f1057140a256e32303 100644 (file)
@@ -9,5 +9,5 @@ $(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 
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 739d9eb546bef97d2903ed9bb2b6941a08c1bace..d82b28273858f7929501abb71b2665d30698b242 100644 (file)
@@ -9,5 +9,5 @@ $(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 
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index e48d8b95f56306a212dcb9b88d9cb35a077f119f..f82cd21fd600b5b1b647604c55865bc81859b45a 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_TEST_BIN := main-skipjack-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o \
                         performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index f0b43e5d23c4dbf1b4a7362054e38509fb248146..f151aa809a5c45a76ec9d18ee5f95236a327edd4 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := des.o
 $(ALGO_NAME)_TEST_BIN := main-tdes-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 45ee4f3250926d46f654272b09f7283535bbc3ab..1c65bd8ced943e6e13221f88252cca53ddc604e8 100644 (file)
@@ -9,5 +9,5 @@ $(ALGO_NAME)_TEST_BIN := main-trivium-test.o debug.o uart.o serial-tools.o \
                          nessie_stream_test.o nessie_common.o cli.o \
                          performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index b4edc30ba66fc917ff95d7a76dd110015c50c197..0128f864c9f9190c0c0ef0be34a03dd4aab1dacc 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := xtea-asm.o
 $(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 7ebbded885c89290c833929aadf59ca3c4826cf5..6f10d767fa09be0a0acca2a57fdb7882127f79a6 100644 (file)
@@ -8,5 +8,5 @@ $(ALGO_NAME)_OBJ      := xtea.o
 $(ALGO_NAME)_TEST_BIN := main-xtea-test.o debug.o uart.o serial-tools.o \
                          nessie_bc_test.o nessie_common.o cli.o performance_test.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
-$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
+$(ALGO_NAME)_PERFORMANCE_TEST := "performance"
 
index 19153b57fcfa4548c537a7a0230ec3cdb89a691c..7e2cc352a28e388cdde389d8b5f270f1fe2e1c2c 100644 (file)
@@ -115,15 +115,15 @@ void testrun_camellia(void){
                        0x89, 0xab, 0xcd, 0xef, 
                        0xfe, 0xdc, 0xba, 0x98, 
                        0x76, 0x54, 0x32, 0x10 };
-/*
-  uint8_t data[16] = {  
-                       0x10, 0x32, 0x54, 0x76
-                       0x98, 0xba, 0xdc, 0xfe
-                       0xfe, 0xcd, 0xab, 0x89 
-                       0x67, 0x89, 0x67, 0x01};
-*/
+
+  uint8_t key[16] = { 0x01, 0x23, 0x45, 0x67, 
+                       0x89, 0xab, 0xcd, 0xef
+                       0xfe, 0xdc, 0xba, 0x98
+                       0x76, 0x54, 0x32, 0x10 };
+
+
   camellia128_ctx_t ctx;
-  camellia128_init(data, &ctx);
+  camellia128_init(key, &ctx);
   uart_putstr_P(PSTR("\r\n key:        "));
   uart_hexdump(data, 16);
   uart_putstr_P(PSTR("\r\n plaintext:  "));
@@ -131,6 +131,9 @@ void testrun_camellia(void){
   camellia128_enc(data, &ctx);
   uart_putstr_P(PSTR("\r\n ciphertext: "));
   uart_hexdump(data, 16);
+  camellia128_dec(data, &ctx);
+  uart_putstr_P(PSTR("\r\n decrypted:  "));
+  uart_hexdump(data, 16);
 
 }