]> git.cryptolib.org Git - avr-crypto-lib.git/blob - keccak/keccak-asm.S
first steps to keccak in asm
[avr-crypto-lib.git] / keccak / keccak-asm.S
1 /* keccac-asm.S */
2 /*
3     This file is part of the AVR-Crypto-Lib.
4     Copyright (C) 2012  Daniel Otte (daniel.otte@rub.de)
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     keccak-asm.S
21  * \email    daniel.otte@rub.de
22  * \author   Daniel Otte
23  * \date     2012-12-16
24  * \license  GPLv3 or later
25  *
26  */
27
28 .nolist
29 #include "avr-asm-macros.S"
30 .list
31 /*
32         void keccak_theta (uint64_t *a, uint64_t *b){
33         // uint64_t b[5][5];
34                 for(i = 0; i < 5; ++i){
35                         b[i][0] = a[0][i] ^ a[1][i] ^ a[2][i] ^ a[3][i] ^ a[4][i];
36                 }
37         }
38 */
39
40 .global keccak_theta
41 keccak_theta:
42         movw r30, r24
43         movw r26, r22
44
45 ;       .irp offset, 0, 1, 2, 3, 4
46
47         ldi r19, 5
48 10:
49         ldi r20, 8
50 20:
51
52         ld  r22, Z
53         adiw ZL, 40
54         ld  r21, Z
55         eor r22, r21
56         adiw ZL, 40
57         ld  r21, Z
58         eor r22, r21
59         adiw ZL, 40
60         ld  r21, Z
61         eor r22, r21
62         adiw ZL, 40
63         ld  r21, Z
64         eor r22, r21
65
66         adiw r24, 1
67         movw r30, r24
68
69         st X+, r22
70         dec r20
71         brne 20b
72
73         adiw XL, 8 * 4
74         dec r19
75         brne 10b
76 ;       .endr
77
78         ret