]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - sha256-asm.S
forgotten files
[avr-crypto-lib.git] / sha256-asm.S
index 403506ef5f4ab29150315c7837a7ee469ae88873..d9eb6b65a789a49a7dc730775685114f146ed53b 100644 (file)
@@ -1,6 +1,6 @@
 /* sha256-asm.S */
 /*
-    This file is part of the Crypto-avr-lib/microcrypt-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
@@ -253,21 +253,24 @@ sha256_lastBlock_localSpace = (SHA256_BLOCK_BITS/8+1)
 
 
 sha256_lastBlock:
-       tst r20
-       brne sha256_lastBlock_prolog
        cpi r21, 0x02
-       brne sha256_lastBlock_prolog
+       brlo sha256_lastBlock_prolog
        push r25
        push r24
        push r23
        push r22
+       push r21
+       push r20
        rcall sha256_nextBlock
+       pop r20
+       pop r21
        pop r22
        pop r23
        pop r24
        pop r25
-       clr r21
-       clr r22
+       subi r21, 0x02
+       subi r23, -2
+       rjmp sha256_lastBlock   
 sha256_lastBlock_prolog:
        /* allocate space on stack */
        in r30, SPL
@@ -919,24 +922,18 @@ sha256_kv: ; round-key-vector stored in ProgMem
 ;      state->length=0;
 ;      memcpy(state->h, sha256_init_vector, 8*4);
 ;}
-; param1: (Func3,r24) 16-bit pointer to sha256_ctx_t struct in ram
+; param1: (r23,r24) 16-bit pointer to sha256_ctx_t struct in ram
 ; modifys: Z(r30,r31), Func1, r22
 sha256_init:
        movw r26, r24 ; (24,25) --> (26,27) load X with param1
        ldi r30, lo8((sha256_init_vector))
        ldi r31, hi8((sha256_init_vector))
-       ldi r22, 32
+       ldi r22, 32+8
 sha256_init_vloop:     
        lpm r23, Z+ 
        st X+, r23
        dec r22
        brne sha256_init_vloop
-       ldi r22, 8
-       clr r1 ;this should not be needed
-sha256_init_lloop:
-       st X+, r1
-       dec r22
-       brne sha256_init_lloop
        ret
        
 sha256_init_vector:
@@ -948,6 +945,8 @@ sha256_init_vector:
 .word 0x688C, 0x9B05 
 .word 0xD9AB, 0x1F83 
 .word 0xCD19, 0x5BE0
+.word 0x0000, 0x0000
+.word 0x0000, 0x0000
 
 ;###########################################################   
 
@@ -968,7 +967,7 @@ rotl32:
        mov r23, r22
        mov r22, r21
        subi r20, 8
-       rjmp rotr32
+       rjmp rotl32
 bitrotl:
        clr r21
        clc