X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=sha1%2Fsha1-asm.S;h=f479fcc27ca42db3a1e611dd830624ebf7d73f81;hb=deca11a7e7be5605c387aa2cd577e22925854ff8;hp=3fcc48e3daeb2048016b53af3129b2021302c159;hpb=45ad29acafe8ee17f7b1bd5b933a0e04cd51c94e;p=avr-crypto-lib.git diff --git a/sha1/sha1-asm.S b/sha1/sha1-asm.S index 3fcc48e..f479fcc 100644 --- a/sha1/sha1-asm.S +++ b/sha1/sha1-asm.S @@ -178,20 +178,19 @@ sha1_prolog: push r13 push r16 push r17 - in r16, SPL - in r17, SPH - subi r16, 5*4+8 - sbci r17, 0 + in r30, SPL + in r31, SPH + sbiw r30, 5*4+8 in r0, SREG cli - out SPL, r16 - out SPH, r17 + out SPL, r30 out SREG, r0 + out SPH, r31 push r25 push r24 - inc r16 - adc r17, r1 + adiw r30, 1 + movw r16, r30 movw r8, r18 /* backup of length*/ movw r10, r20 @@ -203,19 +202,16 @@ sha1_prolog: /* if length >= 512 */ 1: tst r11 - brne 4f + brne 2f tst r10 - brne 4f - mov r19, r9 - cpi r19, 0x02 - brlo 4f - + breq 4f +2: movw r24, r16 movw r22, r12 rcall sha1_nextBlock - ldi r19, 0x64 - add r22, r19 - adc r23, r1 + ldi r19, 64 + add r12, r19 + adc r13, r1 /* length -= 512 */ ldi r19, 0x02 sub r9, r19 @@ -241,8 +237,8 @@ sha1_epilog: in r0, SREG cli out SPL, r30 - out SPH, r31 out SREG, r0 + out SPH, r31 pop r17 pop r16 pop r13 @@ -287,19 +283,21 @@ sha1_lastBlock: pop r24 pop r25 subi r21, 2 - subi r23, -2 + ldi r19, 64 + add r22, r19 + adc r23, r1 rjmp sha1_lastBlock sha1_lastBlock_prolog: /* allocate space on stack */ in r30, SPL in r31, SPH - in r1, SREG + in r0, SREG subi r30, lo8(64) sbci r31, hi8(64) /* ??? */ cli out SPL, r30 + out SREG, r0 out SPH, r31 - out SREG,r1 adiw r30, 1 /* SP points to next free byte on stack */ mov r18, r20 /* r20 = LSB(length) */ @@ -423,15 +421,14 @@ sha1_lastBlock_insert_length: sha1_lastBlock_epilog: in r30, SPL in r31, SPH - in r1, SREG + in r0, SREG adiw r30, 63 ; lo8(64) adiw r30, 1 ; hi8(64) cli out SPL, r30 + out SREG, r0 out SPH, r31 - out SREG,r1 clr r1 - clr r0 ret /**/ @@ -490,8 +487,8 @@ sha1_nextBlock: in r0, SREG cli ; we want to be uninterrupted while updating SP out SPL, r20 - out SPH, r21 out SREG, r0 + out SPH, r21 push r18 push r19 /* push old SP on new stack */ @@ -778,8 +775,8 @@ sha1_nextBlock_epilog: in r0, SREG cli ; we want to be uninterrupted while updating SP out SPL, r20 - out SPH, r21 out SREG, r0 + out SPH, r21 clr r1 pop r29