1 C sparc64/arcfour-crypt.asm
4 Copyright (C) 2002, 2005 Niels Möller
6 This file is part of GNU Nettle.
8 GNU Nettle is free software: you can redistribute it and/or
9 modify it under the terms of either:
11 * the GNU Lesser General Public License as published by the Free
12 Software Foundation; either version 3 of the License, or (at your
13 option) any later version.
17 * the GNU General Public License as published by the Free
18 Software Foundation; either version 2 of the License, or (at your
19 option) any later version.
21 or both in parallel, as here.
23 GNU Nettle is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 General Public License for more details.
28 You should have received copies of the GNU General Public License and
29 the GNU Lesser General Public License along with this program. If
30 not, see http://www.gnu.org/licenses/.
33 C Define to YES, to enable the complex code to special case SRC
34 C and DST with compatible alignment.
36 define(<WITH_ALIGN>, <YES>)
41 define(<LENGTH>,<%i1>)
55 C Computes the next byte of the key stream. As input, i must
56 C already point to the index for the current access, the index
57 C for the next access is stored in ni. The resulting key byte is
59 C ARCFOUR_BYTE(i, ni, res)
60 define(<ARCFOUR_BYTE>, <
74 define(<FRAME_SIZE>, 192)
76 .file "arcfour-crypt.asm"
78 C arcfour_crypt(struct arcfour_ctx *ctx,
79 C size_t length, uint8_t *dst,
86 PROLOGUE(nettle_arcfour_crypt)
88 save %sp, -FRAME_SIZE, %sp
94 lduh [CTX + ARCFOUR_I], I1
98 C We want an even address for DST
106 ARCFOUR_BYTE(I2, I1, TMP)
107 subcc LENGTH, 1, LENGTH
118 C Harmless delay slot instruction
124 ARCFOUR_BYTE(I1, I2, TMP)
130 ARCFOUR_BYTE(I2, I1, TMP)
132 subcc LENGTH, 2, LENGTH
142 C Harmless delay slot instruction
146 C Main loop, with aligned writes
148 C FIXME: Could check if SRC is aligned, and
149 C use 32-bit reads in that case.
152 ARCFOUR_BYTE(I1, I2, TMP)
157 ARCFOUR_BYTE(I2, I1, TMP)
163 ARCFOUR_BYTE(I1, I2, TMP)
169 ARCFOUR_BYTE(I2, I1, TMP)
178 andcc LENGTH, 3, LENGTH
183 C DST address must be 2-aligned
189 ARCFOUR_BYTE(I1, I2, TMP)
195 ARCFOUR_BYTE(I2, I1, TMP)
206 ARCFOUR_BYTE(I2, I1, TMP)
214 stuh I2, [CTX + ARCFOUR_I]
220 EPILOGUE(nettle_arcfour_crypt)
222 C Stats for AES 128 on sellafield.lysator.liu.se (UE450, 296 MHz)
224 C 1: nettle-1.13 C-code
225 C 2: New assembler code (basically the same as for sparc32)