3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
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.
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.
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/>.
21 * File: serpent_sboxes.S
24 * License: GPLv3 or later
25 * Description: Implementation of the serpent sbox function.
30 #include "avr-asm-macros.S"
34 .byte 0x83, 0x1F, 0x6A, 0xB5, 0xDE, 0x24, 0x07, 0xC9
35 .byte 0xCF, 0x72, 0x09, 0xA5, 0xB1, 0x8E, 0xD6, 0x43
36 .byte 0x68, 0x97, 0xC3, 0xFA, 0x1D, 0x4E, 0xB0, 0x25
37 .byte 0xF0, 0x8B, 0x9C, 0x36, 0x1D, 0x42, 0x7A, 0xE5
38 .byte 0xF1, 0x38, 0x0C, 0x6B, 0x52, 0xA4, 0xE9, 0xD7
39 .byte 0x5F, 0xB2, 0xA4, 0xC9, 0x30, 0x8E, 0x6D, 0x17
40 .byte 0x27, 0x5C, 0x48, 0xB6, 0x9E, 0xF1, 0x3D, 0x0A
41 .byte 0xD1, 0x0F, 0x8E, 0xB2, 0x47, 0xAC, 0x39, 0x65
44 .byte 0x3D, 0x0B, 0x6A, 0xC5, 0xE1, 0x74, 0x9F, 0x28
45 .byte 0x85, 0xE2, 0x6F, 0x3C, 0x4B, 0x97, 0xD1, 0x0A
46 .byte 0x9C, 0x4F, 0xEB, 0x21, 0x30, 0xD6, 0x85, 0x7A
47 .byte 0x90, 0x7A, 0xEB, 0xD6, 0x53, 0x2C, 0x84, 0x1F
48 .byte 0x05, 0x38, 0x9A, 0xE7, 0xC2, 0x6B, 0xF4, 0x1D
49 .byte 0xF8, 0x92, 0x14, 0xED, 0x6B, 0x35, 0xC7, 0x0A
50 .byte 0xAF, 0xD1, 0x35, 0x06, 0x94, 0x7E, 0xC2, 0xB8
51 .byte 0x03, 0xD6, 0xE9, 0x8F, 0xC5, 0x7B, 0x1A, 0x24
54 * void ip(uint32_t *i, uint8_t *o){
57 * param i is given in r24:r25
58 * parma o is given in r22:r23
72 /* now the whole input is loaded in r2-r18 */
105 * void serpent_fp(uint32_t *i, uint8_t *o){
108 * param i is given in r24:r25
109 * parma o is given in r22:r23
143 * void inv_sbox128(void * w, uint8_t box)
152 * void sbox128(void * w, uint8_t box);
155 * param w is passed in r24:r25
156 * param box is passed in r22
163 * void sbox128x(void * w, uint8_t box);
166 * param w is passed in r24:r25
167 * param box is passed in r22
174 push_ r24, r25, r22, r30, r31
175 movw r22, r30 /* Z points to the stack buffer */
178 ldi r25, hi8(serpent_sbox)
179 ldi r24, lo8(serpent_sbox)
181 lsr r22 /* r22 *= 8 */
184 /* now we have X pointing to the buffer and (r24:r25) pointing to the SBox */