X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=skein%2Fthreefish1024_enc.c;h=662e79dd1c03a54db44aba7ecaacef7e9664b1b2;hb=3a9f9d918fb95474996af535c225a7e187d88372;hp=41a35902d695752987360b67ca5c9e2a5ac91177;hpb=4f50c75ee5a6cc88bf7ea71957ed509e298e6c25;p=avr-crypto-lib.git diff --git a/skein/threefish1024_enc.c b/skein/threefish1024_enc.c index 41a3590..662e79d 100644 --- a/skein/threefish1024_enc.c +++ b/skein/threefish1024_enc.c @@ -21,9 +21,9 @@ * \email daniel.otte@rub.de * \date 2009-03-12 * \license GPLv3 or later - * - * - * + * + * + * */ #include @@ -33,7 +33,7 @@ #define X(a) (((uint64_t*)data)[(a)]) static -void permute_16(void* data){ +void permute_16(void *data){ uint64_t t; t = X(1); X(1) = X(9); @@ -55,12 +55,13 @@ void permute_16(void* data){ X(14) = t; } -#define THREEFISH_KEY_CONST 0x5555555555555555LL /* 2**64/3 */ +//#define THREEFISH_KEY_CONST 0x5555555555555555LL /* 2**64/3 */ +#define THREEFISH_KEY_CONST 0x1BD11BDAA9FC1A22LL #define K(s) (((uint64_t*)key)[(s)]) #define T(s) (((uint64_t*)tweak)[(s)]) -void threefish1024_init(const void* key, const void* tweak, threefish1024_ctx_t* ctx){ +void threefish1024_init(const void *key, const void *tweak, threefish1024_ctx_t *ctx){ memcpy(ctx->k, key, 16*8); if(tweak){ memcpy(ctx->t, tweak, 2*8); @@ -76,7 +77,7 @@ void threefish1024_init(const void* key, const void* tweak, threefish1024_ctx_t* } 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]; @@ -86,8 +87,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_enc(void* data, const threefish1024_ctx_t* ctx){ +void threefish1024_enc(void *data, const threefish1024_ctx_t *ctx){ uint8_t i=0,s=0; + /* old constans, changed at round 2 of the SHA-3 contest uint8_t r0[8] = {55, 25, 33, 34, 28, 17, 58, 47}; uint8_t r1[8] = {43, 25, 8, 43, 7, 6, 7, 49}; uint8_t r2[8] = {37, 46, 18, 25, 47, 18, 32, 27}; @@ -96,7 +98,15 @@ void threefish1024_enc(void* data, const threefish1024_ctx_t* ctx){ uint8_t r5[8] = {22, 13, 12, 9, 9, 42, 18, 48}; uint8_t r6[8] = {38, 52, 32, 59, 35, 40, 2, 53}; uint8_t r7[8] = {12, 57, 54, 34, 41, 15, 56, 56}; - + */ + uint8_t r0[8] = {24, 38, 33, 5, 41, 16, 31, 9}; + uint8_t r1[8] = {13, 19, 4, 20, 9, 34, 44, 48}; + uint8_t r2[8] = { 8, 10, 51, 48, 37, 56, 47, 35}; + uint8_t r3[8] = {47, 55, 13, 41, 31, 51, 46, 52}; + uint8_t r4[8] = { 8, 49, 34, 47, 12, 4, 19, 23}; + uint8_t r5[8] = {17, 18, 41, 28, 47, 53, 42, 31}; + uint8_t r6[8] = {22, 23, 59, 16, 44, 42, 44, 37}; + uint8_t r7[8] = {37, 52, 17, 25, 30, 41, 25, 20}; do{ if(i%4==0){ add_key_16(data, ctx, s);