fixing more missing adjustments [tests running]

This commit is contained in:
bg nerilex 2016-01-24 00:56:31 +01:00
parent 3f406d67a2
commit e34260dea3
1 changed files with 24 additions and 29 deletions

View File

@ -352,14 +352,12 @@ sha256_lastBlock_insert_stuffing_bit:
/* now we should subtract 512 from length */ /* now we should subtract 512 from length */
movw r26, r24 movw r26, r24
adiw r26, 4*8+1 /* we can skip the lowest byte */ adiw r26, 4*8 /* we can skip the lowest byte */
ld r19, X sec
subi r19, hi8(512) ldi r18, 4
st X+, r19
ldi r18, 6
1: 1:
ld r19, X ld r19, X
sbci r19, 0 sbc r19, r1
st X+, r19 st X+, r19
dec r18 dec r18
brne 1b brne 1b
@ -382,21 +380,24 @@ sha256_lastBlock_insert_length:
movw r26, r24 /* X points to state */ movw r26, r24 /* X points to state */
adiw r26, 8*4 /* X points to (state.length) */ adiw r26, 8*4 /* X points to (state.length) */
adiw r30, 8 /* Z points one after the last byte of block */ adiw r30, 8 /* Z points one after the last byte of block */
ldi r19, 3
st -Z, r20
ld r0, X+ ld r0, X+
add r0, r20 lsl r0
or r0, r21
st -Z, r0 st -Z, r0
ld r0, X+
adc r0, r21
st -Z, r0
ldi r19, 6
1: 1:
ld r0, X+ ld r0, X+
adc r0, r1 rol r0
st -Z, r0 st -Z, r0
dec r19 dec r19
brne 1b brne 1b
clr r0
sbiw r30, 64-8 rol r0
st -Z, r0
st -Z, r1
st -Z, r1
sbiw r30, 64 - 8
movw r22, r30 movw r22, r30
rcall sha256_nextBlock rcall sha256_nextBlock
@ -851,20 +852,15 @@ update_state_loop:
dec r21 dec r21
brne update_state_loop brne update_state_loop
/* now we just have to update the length */ /* now we just have to update the length */
adiw r30, 1 /* since we add 512, we can simply skip the LSB */ clr r1
ldi r21, 2 ldi r21, 4
ldi r22, 6 sec
ld r20, Z 1:
add r20, r21 ld r22, Z
st Z+, r20 adc r22, r1
clr r21 st Z+, r22
sha256_nextBlock_fix_length: dec r21
brcc sha256_nextBlock_epilog brne 1b
ld r20, Z
adc r20, r21
st Z+, r20
dec r22
brne sha256_nextBlock_fix_length
; EPILOG ; EPILOG
sha256_nextBlock_epilog: sha256_nextBlock_epilog:
@ -877,7 +873,6 @@ sha256_nextBlock_epilog:
out SPL, r20 out SPL, r20
out SREG, r0 out SREG, r0
out SPH, r21 out SPH, r21
clr r1
pop r29 pop r29
pop r28 pop r28
pop r17 pop r17