]> git.cryptolib.org Git - avr-crypto-lib.git/blob - gf256mul.S
02e85e95c9003999a0c25ba4982edf36006ee296
[avr-crypto-lib.git] / gf256mul.S
1 /* gf256mul.S */
2 /*
3     This file is part of the Crypto-avr-lib/microcrypt-lib.
4     Copyright (C) 2008  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 /* 
21  * File:        gf256mul.S
22  * Author:      Daniel Otte
23  * Date:        2008-12-19
24  * License:     GPLv3 or later
25  * Description: peasant's algorithm for multiplication in GF(2^8)
26  * 
27  */
28
29
30 /*
31  * param a: r24
32  * param b; r22
33  * param reducer: r20
34  */
35 A = 21
36 B = 22
37 P = 24
38 .global gf256mul
39 gf256mul:
40         mov r21, r24
41         clr r24
42         ldi r25, 8
43 1:      
44         lsr B
45         brcc 2f
46         eor P, A
47 2:
48         lsl A
49         brcc 3f
50         eor A, r20      
51 3:
52         dec r25
53         brne 1b
54         ret
55