* \email daniel.otte@rub.de
* \date 2009-03-24
* \license GPLv3 or later
- */
+ */
#include "avr-asm-macros.S"
clr I
ldi r26, 18
mov S, r26
-1:
+1:
mov r30, I
andi r30, 0x03
breq 2f
add r30, IDX7
adc r31, r1
rcall sub_z_from_x8
-
+
/* now the remaining key */
sbiw r26, 3*8
ldi r30, lo8(threefish512_slut3)
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
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
push IDX1
adiw r30, 8
lpm IDX1, Z
-
+
movw r24, DATA0
call threefish_invmix_asm /* no rcall? */
movw r24, DATA0
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+
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