1 C -*- mode: asm; asm-comment-char: ?C; -*-
2 C nettle, low-level cryptographics library
4 C Copyright (C) 2010, 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 Performance, cycles per block
25 C Camellia-128 415 347
26 C Camellia-256 543 461
31 define(<TABLE>, <%rsi>)
32 define(<LENGTH>, <%rdx>)
38 define(<I1>, <%rbx>) C callee-save
40 define(<TMP>, <%rbp>) C callee-save
43 define(<IR>, <%r12>) C callee-save
45 define(<SP1110>, <(TABLE,$1,4)>)
46 define(<SP0222>, <1024(TABLE,$1,4)>)
47 define(<SP3033>, <2048(TABLE,$1,4)>)
48 define(<SP4404>, <3072(TABLE,$1,4)>)
50 C ROUND(x, y, key-offset)
53 movzbl LREG($1), XREG(TMP)
54 movl SP1110(TMP), XREG(IR)
55 movzbl HREG($1), XREG(TMP)
56 xorl SP4404(TMP), XREG(IR)
60 movzbl LREG($1), XREG(TMP)
61 movl SP4404(TMP), XREG(IL)
62 movzbl HREG($1), XREG(TMP)
63 xorl SP3033(TMP), XREG(IL)
67 movzbl LREG($1), XREG(TMP)
68 xorl SP3033(TMP), XREG(IR)
69 movzbl HREG($1), XREG(TMP)
70 xorl SP0222(TMP), XREG(IR)
74 movzbl LREG($1), XREG(TMP)
75 xorl SP0222(TMP), XREG(IL)
76 movzbl HREG($1), XREG(TMP)
77 xorl SP1110(TMP), XREG(IL)
82 xorl XREG(IL), XREG(IR)
84 xorl XREG(IR), XREG(IL)
95 andl $2 + 4(KEY), XREG(TMP)
97 C xorl XREG(TMP), XREG($1)
99 movl $2(KEY), XREG(TMP)
100 orl XREG($1), XREG(TMP)
104 C FLINV(x0, key-offset)
106 movl $2(KEY), XREG(TMP)
107 orl XREG($1), XREG(TMP)
112 andl $2 + 4(KEY), XREG(TMP)
114 C xorl XREG(TMP), XREG($1)
118 .file "camellia-encrypt-internal.asm"
120 C _camellia_crypt(struct camellia_context *ctx,
121 C const struct camellia_table *T,
122 C unsigned length, uint8_t *dst,
126 PROLOGUE(_nettle_camellia_crypt)
136 C Load data, note that we'll happily do unaligned loads
143 movl (KEY), XREG(CNT)
146 C Whitening using first subkey
186 EPILOGUE(_nettle_camellia_crypt)