1 C -*- mode: asm; asm-comment-char: ?C; -*-
2 C nettle, low-level cryptographics library
4 C Copyright (C) 2002, 2005 Niels Möller
6 C The nettle library is free software; you can redistribute it and/or modify
7 C it under the terms of the GNU Lesser General Public License as published by
8 C the Free Software Foundation; either version 2.1 of the License, or (at your
9 C option) any later version.
11 C The nettle library is distributed in the hope that it will be useful, but
12 C WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 C or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 C License for more details.
16 C You should have received a copy of the GNU Lesser General Public License
17 C along with the nettle library; see the file COPYING.LIB. If not, write to
18 C the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 C Define to YES, to enable the complex code to special case SRC
22 C and DST with compatible alignment.
24 define(<WITH_ALIGN>, <YES>)
29 define(<LENGTH>,<%i1>)
43 C Computes the next byte of the key stream. As input, i must
44 C already point to the index for the current access, the index
45 C for the next access is stored in ni. The resulting key byte is
47 C ARCFOUR_BYTE(i, ni, res)
48 define(<ARCFOUR_BYTE>, <
62 define(<FRAME_SIZE>, 192)
64 .file "arcfour-crypt.asm"
66 C arcfour_crypt(struct arcfour_ctx *ctx,
67 C unsigned length, uint8_t *dst,
74 PROLOGUE(nettle_arcfour_crypt)
76 save %sp, -FRAME_SIZE, %sp
82 lduh [CTX + ARCFOUR_I], I1
86 C We want an even address for DST
94 ARCFOUR_BYTE(I2, I1, TMP)
95 subcc LENGTH, 1, LENGTH
106 C Harmless delay slot instruction
112 ARCFOUR_BYTE(I1, I2, TMP)
118 ARCFOUR_BYTE(I2, I1, TMP)
120 subcc LENGTH, 2, LENGTH
130 C Harmless delay slot instruction
134 C Main loop, with aligned writes
136 C FIXME: Could check if SRC is aligned, and
137 C use 32-bit reads in that case.
140 ARCFOUR_BYTE(I1, I2, TMP)
145 ARCFOUR_BYTE(I2, I1, TMP)
151 ARCFOUR_BYTE(I1, I2, TMP)
157 ARCFOUR_BYTE(I2, I1, TMP)
166 andcc LENGTH, 3, LENGTH
171 C DST address must be 2-aligned
177 ARCFOUR_BYTE(I1, I2, TMP)
183 ARCFOUR_BYTE(I2, I1, TMP)
194 ARCFOUR_BYTE(I2, I1, TMP)
202 stuh I2, [CTX + ARCFOUR_I]
208 EPILOGUE(nettle_arcfour_crypt)
210 C Stats for AES 128 on sellafield.lysator.liu.se (UE450, 296 MHz)
212 C 1: nettle-1.13 C-code
213 C 2: New assembler code (basically the same as for sparc32)