]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - camellia.c
+RC5 +size-statistics tool +small modification to nessie_bc_test (optional free(...
[avr-crypto-lib.git] / camellia.c
index 01145d574b1fa441df088de79155cac9efe1d4fd..cfcd561e2811c2a385f5dc928f6125061225fb03 100644 (file)
@@ -21,8 +21,8 @@ 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 */
+/*
+uint64_t PROGMEM camellia_sigma[6]={ / * 64 byte table * /
        0xA09E667F3BCC908BLL,
        0xB67AE8584CAA73B2LL,
        0xC6EF372FE94F82BELL,
@@ -30,10 +30,23 @@ uint64_t PROGMEM camellia_sigma[6]={ /* 64 byte table */
        0x10E527FADE682D1DLL,
        0xB05688C2B3E6C1FDLL
 };     
+*/
+uint32_t PROGMEM camellia_sigma[12]={ /* 64 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))) )
+*/
+#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]))) )
 
 
 
@@ -146,6 +159,7 @@ void camellia128_enc(camellia128_ctx_t* s, void* block){
        BR = BL;
        BL = temp64;
 
+       camellia128_keyop(s,1);
        
        change_endian(&BL, 64/8);       
        change_endian(&BR, 64/8);