]> git.cryptolib.org Git - avr-crypto-lib.git/blob - twister/twister512.S
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / twister / twister512.S
1 /* twister512.S */
2 /*
3     This file is part of the AVR-Crypto-Lib.
4     Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
5
6     This program is free software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 /**
20  * \file     twister512.S
21  * \email    bg@nerilex.org
22  * \author   Daniel Otte 
23  * \date     2008-12-28
24  * \license  GPLv3 or later
25  * 
26  */
27  
28 #include "avr-asm-macros.S"
29 /*********************************************************************/
30 /* void twister384(void *dest, void *msg, uint32_t msg_length_b) */
31 /*
32  * param dest:         r24:r25
33  * param msg:          r22:r23
34  * param msg_length_b: r18:r21
35  */
36  
37 CTX_SAVE0 = 10
38 CTX_SAVE1 = 11
39 DST_SAVE0 = 14
40 DST_SAVE1 = 15
41 MSG_LEN0  = 16
42 MSG_LEN1  = 17
43 MSG_LEN2  = 12
44 MSG_LEN3  = 13
45 MSG_SAVE0 = 28
46 MSG_SAVE1 = 29
47  
48 .global twister512
49 twister512:
50         push_range 10, 17
51         push r28
52         push r29
53         stack_alloc_large 64+2*8+64
54         adiw r30, 1
55         movw CTX_SAVE0, r30
56         movw DST_SAVE0, r24
57         movw MSG_SAVE0, r22
58         movw MSG_LEN0, r18
59         movw MSG_LEN2, r20
60         movw r24, CTX_SAVE0
61         ldi r22, lo8(512)
62         ldi r23, hi8(512)
63         rcall twister_large_init
64 1:
65         tst MSG_LEN3
66         brne 2f
67         tst MSG_LEN2
68         brne 2f
69         cpi MSG_LEN1, 2
70         brmi 3f
71 2:
72         movw r24, CTX_SAVE0
73         movw r22, MSG_SAVE0
74         rcall twister_large_nextBlock
75         adiw MSG_SAVE0, 63
76         adiw MSG_SAVE0,  1      
77         subi MSG_LEN1, 2
78         sbc MSG_LEN2, r1
79         sbc MSG_LEN3, r1
80         rjmp 1b
81 3:
82         movw r24, CTX_SAVE0
83         movw r22, MSG_SAVE0
84         movw r20, MSG_LEN0
85         rcall twister_large_lastBlock
86         
87         movw r24, DST_SAVE0
88         movw r22, CTX_SAVE0
89         ldi r20, lo8(512)
90         ldi r21, hi8(512)
91         rcall twister_large_ctx2hash
92
93         stack_free_large2 64+2*8+64
94         pop r29
95         pop r28
96         pop_range 10, 17
97         ret