X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=skein%2Fthreefish512_dec_asm.S;h=ac91fd41ccbc01eb07f3a5fa430388c150d5b71f;hp=5ac9c0d9b003bcfffd5f49f63a0651e63000e711;hb=4b5da1dc27a791b5c448274a3db09cd035b33493;hpb=4f50c75ee5a6cc88bf7ea71957ed509e298e6c25 diff --git a/skein/threefish512_dec_asm.S b/skein/threefish512_dec_asm.S index 5ac9c0d..ac91fd4 100644 --- a/skein/threefish512_dec_asm.S +++ b/skein/threefish512_dec_asm.S @@ -1,7 +1,7 @@ /* threefish512_enc_asm.S */ /* 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 @@ -18,10 +18,10 @@ */ /* * \author Daniel Otte - * \email daniel.otte@rub.de + * \email bg@nerilex.org * \date 2009-03-24 * \license GPLv3 or later - */ + */ #include "avr-asm-macros.S" @@ -31,7 +31,7 @@ static -void permute_inv8(void* data){ +void permute_inv8(void *data){ uint64_t t; t = X(6); X(6) = X(4); @@ -44,7 +44,7 @@ void permute_inv8(void* data){ } static -void add_key_8(void* data, const threefish512_ctx_t* ctx, uint8_t s){ +void add_key_8(void *data, const threefish512_ctx_t *ctx, uint8_t s){ uint8_t i; for(i=0; i<5; ++i){ X(i) -= ctx->k[(s+i)%9]; @@ -54,7 +54,7 @@ void add_key_8(void* data, const threefish512_ctx_t* ctx, uint8_t s){ X(7) -= ctx->k[(s+7)%9] + s; } -void threefish512_dec(void* data, const threefish512_ctx_t* ctx){ +void threefish512_dec(void *data, const threefish512_ctx_t *ctx){ uint8_t i=0,s=18; uint8_t r0[8] = {0x41, 0x4b, 0x59, 0x41, 0x32, 0x42, 0x60, 0x5a}; uint8_t r1[8] = {0x63, 0x32, 0x33, 0x61, 0x14, 0x2a, 0x24, 0x4a}; @@ -103,7 +103,7 @@ threefish512_dec: clr I ldi r26, 18 mov S, r26 -1: +1: mov r30, I andi r30, 0x03 breq 2f @@ -154,7 +154,7 @@ threefish512_dec: add r30, IDX7 adc r31, r1 rcall sub_z_from_x8 - + /* now the remaining key */ sbiw r26, 3*8 ldi r30, lo8(threefish512_slut3) @@ -204,10 +204,10 @@ exit: pop_range 2, 17 pop r29 pop r28 - ret + ret 3: - dec S -4: + dec S +4: /* now the permutation */ movw r26, DATA0 movw r30, DATA0 @@ -222,7 +222,7 @@ exit: adiw r26, 2*8 movw r30, DATA0 adiw r30, 4*8 - rcall xchg_zx8 + rcall xchg_zx8 movw r26, DATA0 adiw r26, 3*8 movw r30, DATA0 @@ -243,7 +243,7 @@ exit: push IDX1 adiw r30, 8 lpm IDX1, Z - + movw r24, DATA0 call threefish_invmix_asm /* no rcall? */ movw r24, DATA0 @@ -261,21 +261,27 @@ exit: call threefish_invmix_asm /* no rcall? */ inc I rjmp 1b - + threefish512_slut9: .byte 0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38 .byte 0x40, 0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30 - .byte 0x38, 0x40, 0x00, 0x08, 0x10, 0x18, 0x20, 0x28 + .byte 0x38, 0x40, 0x00, 0x08, 0x10, 0x18, 0x20, 0x28 .byte 0x30, 0x38, 0x40 threefish512_slut3: .byte 0x00, 0x08, 0x10, 0x00, 0x08, 0x10, 0x00, 0x08 - .byte 0x10, 0x00, 0x08, 0x10, 0x00, 0x08, 0x10, 0x00 + .byte 0x10, 0x00, 0x08, 0x10, 0x00, 0x08, 0x10, 0x00 .byte 0x08, 0x10, 0x00, 0x08, 0x10, 0x00, 0x08 +/* old round constants threefish512_rc0: .byte 0x41, 0x4b, 0x59, 0x41, 0x32, 0x42, 0x60, 0x5a threefish512_rc1: .byte 0x63, 0x32, 0x33, 0x61, 0x14, 0x2a, 0x24, 0x4a threefish512_rc2: .byte 0x59, 0x13, 0x51, 0x10, 0x72, 0x29, 0x53, 0x62 threefish512_rc3: .byte 0x43, 0x11, 0x2a, 0x52, 0x19, 0x33, 0x49, 0x7b +*/ +threefish512_rc0: .byte 0x10, 0x31, 0x2b, 0x59, 0x54, 0x21, 0x41, 0x6a +threefish512_rc1: .byte 0x43, 0x4b, 0x62, 0x4a, 0x11, 0x61, 0x33, 0x44 +threefish512_rc2: .byte 0x70, 0x59, 0x12, 0x42, 0x7a, 0x44, 0x2a, 0x23 +threefish512_rc3: .byte 0x3a, 0x53, 0x21, 0x30, 0x70, 0x59, 0x52, 0x5b sub_z_from_x8: ld r0, Z+ @@ -312,16 +318,16 @@ sub_z_from_x8: st X+, r1 clr r1 ret - + T0 = IDX0 T1 = 0 -CNT = 24 +CNT = 24 xchg_zx8: ldi CNT, 8 1: ld T0, X ld T1, Z st X+, T1 - st Z+, T0 + st Z+, T0 dec CNT brne 1b ret