X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=sha1-asm.S;h=f571685984c5046fd0f4280adbc9a5fe513720a8;hb=8f855d283a31a468ea014774c4723a8b77b81644;hp=5d0a2410c93d361a72fef65d89e92d04745df782;hpb=17332291e15183d71d88ed868275e3cb53917180;p=avr-crypto-lib.git diff --git a/sha1-asm.S b/sha1-asm.S index 5d0a241..f571685 100644 --- a/sha1-asm.S +++ b/sha1-asm.S @@ -1,6 +1,6 @@ /* sha1-asm.S */ /* - This file is part of the This file is part of the AVR-Crypto-Lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -271,21 +271,24 @@ sha1_lastBlock_localSpace = (SHA1_BLOCK_BITS/8+1) sha1_lastBlock: - tst r20 - brne sha1_lastBlock_prolog cpi r21, 0x02 - brne sha1_lastBlock_prolog + brlo sha1_lastBlock_prolog push r25 push r24 push r23 push r22 + push r21 + push r20 rcall sha1_nextBlock + pop r20 + pop r21 pop r22 pop r23 pop r24 pop r25 - clr r21 - clr r22 + subi r21, 2 + subi r23, -2 + rjmp sha1_lastBlock sha1_lastBlock_prolog: /* allocate space on stack */ in r30, SPL @@ -659,7 +662,7 @@ sha1_nextBlock_mainloop_core: /* ther core function; T=ROTL5(a) ....*/ adc T4, tmp1 /* T = ROTL(a,5) + e + kt + w[s] */ - /* wo Z-4 gerade auf kt zeigt ... */ + /* Z-4 is just pointing to kt ... */ movw r28, r26 /* copy X in Y */ adiw r30, 3*4 /* now Z points to the rigth locatin in our jump-vector-table */ lsr r31 @@ -732,7 +735,7 @@ sha1_nextBlock_update_a: inc LoopC cpi LoopC, 80 brge 1f - jmp sha1_nextBlock_mainloop + rjmp sha1_nextBlock_mainloop /**************************************/ 1: /* littel patch */ @@ -799,10 +802,13 @@ sha1_nextBlock_KTable: .int 0x8f1bbcdc .int 0xca62c1d6 sha1_nextBlock_JumpTable: -jmp sha1_nextBlock_Ch -jmp sha1_nextBlock_Parity -jmp sha1_nextBlock_Maj -jmp sha1_nextBlock_Parity +rjmp sha1_nextBlock_Ch + nop +rjmp sha1_nextBlock_Parity + nop +rjmp sha1_nextBlock_Maj + nop +rjmp sha1_nextBlock_Parity /* X and Y still point at a[1] aka b ; return value in tmp1 */ sha1_nextBlock_Ch: @@ -814,13 +820,6 @@ sha1_nextBlock_Ch: ldd tmp3, Y+7 /* load from d */ and tmp2, tmp3 eor tmp1, tmp2 - /** - precall - ldi r24, lo8(ch_str) - ldi r25, hi8(ch_str) - call uart_putstr_P - postcall - /**/ ret sha1_nextBlock_Maj: @@ -833,13 +832,6 @@ sha1_nextBlock_Maj: eor tmp1, tmp2 and tmp3, tmp4 eor tmp1, tmp3 - /** - precall - ldi r24, lo8(maj_str) - ldi r25, hi8(maj_str) - call uart_putstr_P - postcall - /**/ ret sha1_nextBlock_Parity: @@ -848,14 +840,6 @@ sha1_nextBlock_Parity: eor tmp1, tmp2 ldd tmp2, Y+7 /* load from d */ eor tmp1, tmp2 - - /** - precall - ldi r24, lo8(parity_str) - ldi r25, hi8(parity_str) - call uart_putstr_P - postcall - /**/ ret /* ch_str: .asciz "\r\nCh" @@ -887,7 +871,6 @@ sha1_init_vloop: dec r22 brne sha1_init_vloop ldi r22, 8 - clr r1 /* this should not be needed */ sha1_init_lloop: st X+, r1 dec r22 @@ -900,96 +883,4 @@ sha1_init_vector: .int 0x98badcfe; .int 0x10325476; .int 0xc3d2e1f0; -/* -;########################################################### -.global rotl32 -; === ROTL32 === -; function that rotates a 32 bit word to the left -; param1: the 32-bit word to rotate -; given in r25,r24,r23,r22 (r25 is most significant) -; param2: an 8-bit value telling how often to rotate -; given in r20 -; modifys: r21, r22 -rotl32: - cpi r20, 8 - brlo bitrotl - mov r21, r25 - mov r25, r24 - mov r24, r23 - mov r23, r22 - mov r22, r21 - subi r20, 8 - rjmp rotr32 -bitrotl: - clr r21 - clc -bitrotl_loop: - tst r20 - breq fixrotl - rol r22 - rol r23 - rol r24 - rol r25 - rol r21 - dec r20 - rjmp bitrotl_loop -fixrotl: - or r22, r21 - ret - - -;########################################################### - -.global rotr32 -; === ROTR32 === -; function that rotates a 32 bit word to the right -; param1: the 32-bit word to rotate -; given in r25,r24,r23,22 (r25 is most significant) -; param2: an 8-bit value telling how often to rotate -; given in r20 -; modifys: r21, r22 -rotr32: - cpi r20, 8 - brlo bitrotr - mov r21, r22 - mov r22, r23 - mov r23, r24 - mov r24, r25 - mov r25, r21 - subi r20, 8 - rjmp rotr32 -bitrotr: - clr r21 - clc -bitrotr_loop: - tst r20 - breq fixrotr - ror r25 - ror r24 - ror r23 - ror r22 - ror r21 - dec r20 - rjmp bitrotr_loop -fixrotr: - or r25, r21 - ret - - -;########################################################### - -.global change_endian32 -; === change_endian32 === -; function that changes the endianess of a 32-bit word -; param1: the 32-bit word -; given in r25,r24,r23,22 (r25 is most significant) -; modifys: r21, r22 -change_endian32: - movw r20, r22 ; (r22,r23) --> (r20,r21) - mov r22, r25 - mov r23, r24 - mov r24, r21 - mov r25, r20 - ret -*/