]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - noekeon_asm.S
+A5/1
[avr-crypto-lib.git] / noekeon_asm.S
index 43ffa93a33f9a39714bfe8a5a420ecd144ecb311..0422964cd49d935fe3f1add7ebfc7aeb136a68bc 100644 (file)
        push r17
        push r28
        push r29
-       in r28, _SFR_IO_ADDR(SREG)
-       push r28
 .endm
 
 .macro pop_all
-       pop r28
-       out _SFR_IO_ADDR(SREG), r28
        pop r29
        pop r28
        pop r17
@@ -83,7 +79,6 @@
        \op \p\()\d, \q\()\z
 .endm
 
-.global bigendian_rotl32
 ; === bigendian_rotl32 ===
 ; this function rotates a 32bit bigendian word n bits to the left
 ;  param1: the 32-bit value
@@ -94,7 +89,6 @@
 ;   given in r25,r24,r23,r22   
 
 bigendian_rotl32:
-       in r0, _SFR_IO_ADDR(SREG)
        /* copy high bit of r22 to carry */
        mov r1, r22
 2:
@@ -109,13 +103,11 @@ bigendian_rotl32:
        brne 2b
 bigendian_rotl32_exit:
        clr r1
-       out _SFR_IO_ADDR(SREG), r0
        ret
        
        
 /******************************************************************************/
 
-.global bigendian_rotr32
 ; === bigendian_rotl32 ===
 ; this function rotates a 32bit bigendian word n bits to the right
 ;  param1: the 32-bit value
@@ -126,7 +118,6 @@ bigendian_rotl32_exit:
 ;   given in r25,r24,r23,r22   
 
 bigendian_rotr32:
-       in r0, _SFR_IO_ADDR(SREG)
        /* copy high bit of r25 to carry */
 
        mov r1, r25
@@ -141,7 +132,6 @@ bigendian_rotr32:
        brne 2b
 bigendian_rotr32_exit:
        clr r1
-       out _SFR_IO_ADDR(SREG), r0
        ret
 
 /******************************************************************************/
@@ -457,7 +447,8 @@ round:
        push r25
        push r24
 pi_gamma_pi:
-       clc
+       ldi r30, pm_lo8(bigendian_rotl32)
+       ldi r31, pm_hi8(bigendian_rotl32)
        call pi
        /* pi1 done; now gamma */
        call gamma_1
@@ -470,22 +461,10 @@ pi_gamma_pi:
        op32 eor, state2, state0
        op32 eor, state2, state1
        op32 eor, state2, state3
-/*     
-       eor state2_0, state0_0
-       eor state2_1, state0_1
-       eor state2_2, state0_2
-       eor state2_3, state0_3
-       eor state2_0, state1_0
-       eor state2_1, state1_1
-       eor state2_2, state1_2
-       eor state2_3, state1_3
-       eor state2_0, state3_0
-       eor state2_1, state3_1
-       eor state2_2, state3_2
-       eor state2_3, state3_3
-*/
+
        call gamma_1
-       sec
+       ldi r30, pm_lo8(bigendian_rotr32)
+       ldi r31, pm_hi8(bigendian_rotr32)
        call pi
        ret
        
@@ -529,17 +508,7 @@ gamma_1:
        eor state0_3, r1
        ret
        
-pi:
-       brcs 1f
-       ldi r30, lo8(bigendian_rotl32)
-       ldi r31, hi8(bigendian_rotl32)
-       rjmp 2f
-1:
-       ldi r30, lo8(bigendian_rotr32)
-       ldi r31, hi8(bigendian_rotr32)
-2:     
-       lsr r31
-       ror r30
+pi:    
        /* a[1] <<<= 1*/
        mov r22, state1_0
        mov r23, state1_1