]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - skein/threefish1024_dec.c
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / skein / threefish1024_dec.c
index edb46d45462d7ff1b48478900076719a17e612bb..362eaf382c990065a6974684475b7fa3c6cb5b67 100644 (file)
@@ -1,7 +1,7 @@
 /* threefish1024_enc.c */
 /*
     This file is part of the AVR-Crypto-Lib.
-    Copyright (C) 2009  Daniel Otte (daniel.otte@rub.de)
+    Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
 
     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
 */
 /*
  * \author  Daniel Otte
- * \email   daniel.otte@rub.de
+ * \email   bg@nerilex.org
  * \date    2009-03-12
  * \license GPLv3 or later
- * 
- * 
- * 
+ *
+ *
+ *
  */
 
 #include <stdint.h>
@@ -33,7 +33,7 @@
 #define X(a) (((uint64_t*)data)[(a)])
 
 static
-void permute_inv16(voiddata){
+void permute_inv16(void *data){
        uint64_t t;
        t = X(15);
        X(15) = X(7);
@@ -44,7 +44,7 @@ void permute_inv16(void* data){
        X(11) = X(5);
        X(5) = X(13);
        X(13) = X(3);
-       X(3) = t;               
+       X(3) = t;
        t = X(4);
        X(4) = X(6);
        X(6) = t;
@@ -56,7 +56,7 @@ void permute_inv16(void* data){
 }
 
 static
-void add_key_16(void* data, const threefish1024_ctx_t* ctx, uint8_t s){
+void add_key_16(void *data, const threefish1024_ctx_t *ctx, uint8_t s){
        uint8_t i;
        for(i=0; i<13; ++i){
                X(i) -= ctx->k[(s+i)%17];
@@ -66,8 +66,9 @@ void add_key_16(void* data, const threefish1024_ctx_t* ctx, uint8_t s){
        X(15) -= ctx->k[(s+15)%17] + s;
 }
 
-void threefish1024_dec(void* data, const threefish1024_ctx_t* ctx){
+void threefish1024_dec(void *data, const threefish1024_ctx_t *ctx){
        uint8_t i=0,s=20;
+       /* old round constants
        uint8_t r0[8] = {47, 58, 17, 28, 34, 33, 25, 55};
        uint8_t r1[8] = {49,  7,  6,  7, 43,  8, 25, 43};
        uint8_t r2[8] = {27, 32, 18, 47, 25, 18, 46, 37};
@@ -76,6 +77,15 @@ void threefish1024_dec(void* data, const threefish1024_ctx_t* ctx){
        uint8_t r5[8] = {48, 18, 42,  9,  9, 12, 13, 22};
        uint8_t r6[8] = {53,  2, 40, 35, 59, 32, 52, 38};
        uint8_t r7[8] = {56, 56, 15, 41, 34, 54, 57, 12};
+       */
+       uint8_t r0[8] = {  9, 31, 16, 41,  5, 33, 38, 24};
+       uint8_t r1[8] = { 48, 44, 34,  9, 20,  4, 19, 13};
+       uint8_t r2[8] = { 35, 47, 56, 37, 48, 51, 10,  8};
+       uint8_t r3[8] = { 52, 46, 51, 31, 41, 13, 55, 47};
+       uint8_t r4[8] = { 23, 19,  4, 12, 47, 34, 49,  8};
+       uint8_t r5[8] = { 31, 42, 53, 47, 28, 41, 18, 17};
+       uint8_t r6[8] = { 37, 44, 42, 44, 16, 59, 23, 22};
+       uint8_t r7[8] = { 20, 25, 41, 30, 25, 17, 52, 37};
        do{
                if(i%4==0){
                        add_key_16(data, ctx, s);