]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - skein/threefish512_dec_asm.S
introducing the tweak on skein
[avr-crypto-lib.git] / skein / threefish512_dec_asm.S
index 5ac9c0d9b003bcfffd5f49f63a0651e63000e711..3f8f8f6f2d734468fb9bbbaf9540cb89f59568f6 100644 (file)
@@ -21,7 +21,7 @@
  * \email   daniel.otte@rub.de
  * \date    2009-03-24
  * \license GPLv3 or later
- */ 
+ */
 
 #include "avr-asm-macros.S"
 
@@ -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