1 C nettle
, low-level cryptographics library
3 C Copyright
(C
) 2010, Niels Möller
5 C The nettle library is free software
; you can redistribute it and/or modify
6 C it under the terms of the GNU Lesser General
Public License as published by
7 C the Free Software Foundation
; either version 2.1 of the License, or (at your
8 C option
) any later version.
10 C The nettle library is distributed
in the hope that it will be useful
, but
11 C WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
12 C
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public
13 C License for more details.
15 C You should have received a copy of the GNU Lesser General
Public License
16 C along with the nettle library
; see the file COPYING.LIB. If not, write to
17 C the Free Software Foundation
, Inc.
, 51 Franklin Street
, Fifth Floor
, Boston
,
20 C Performance
, cycles per block
24 C Camellia
-128 415 347
25 C Camellia
-256 543 461
30 define
(<TABLE
>, <%rsi
>)
31 define
(<LENGTH>, <%rdx
>)
37 define
(<I1
>, <%rbx
>) C callee
-save
39 define
(<TMP
>, <%rbp
>) C callee
-save
42 define
(<IR
>, <%r12
>) C callee
-save
44 define
(<SP1110
>, <(TABLE
,$1,4)>)
45 define
(<SP0222
>, <1024(TABLE
,$1,4)>)
46 define
(<SP3033
>, <2048(TABLE
,$1,4)>)
47 define
(<SP4404
>, <3072(TABLE
,$1,4)>)
49 C ROUND
(x
, y
, key
-offset)
52 movzbl LREG
($1), XREG
(TMP
)
53 movl SP1110
(TMP
), XREG
(IR
)
54 movzbl HREG
($1), XREG
(TMP
)
55 xorl SP4404
(TMP
), XREG
(IR
)
59 movzbl LREG
($1), XREG
(TMP
)
60 movl SP4404
(TMP
), XREG
(IL
)
61 movzbl HREG
($1), XREG
(TMP
)
62 xorl SP3033
(TMP
), XREG
(IL
)
66 movzbl LREG
($1), XREG
(TMP
)
67 xorl SP3033
(TMP
), XREG
(IR
)
68 movzbl HREG
($1), XREG
(TMP
)
69 xorl SP0222
(TMP
), XREG
(IR
)
73 movzbl LREG
($1), XREG
(TMP
)
74 xorl SP0222
(TMP
), XREG
(IL
)
75 movzbl HREG
($1), XREG
(TMP
)
76 xorl SP1110
(TMP
), XREG
(IL
)
81 xorl XREG
(IL
), XREG
(IR
)
83 xorl XREG
(IR
), XREG
(IL
)
94 andl
$2 + 4(KEY
), XREG
(TMP
)
96 C xorl XREG
(TMP
), XREG
($1)
98 movl
$2(KEY
), XREG
(TMP
)
99 orl XREG
($1), XREG
(TMP
)
103 C FLINV
(x0
, key
-offset)
105 movl
$2(KEY
), XREG
(TMP
)
106 orl XREG
($1), XREG
(TMP
)
111 andl
$2 + 4(KEY
), XREG
(TMP
)
113 C xorl XREG
(TMP
), XREG
($1)
117 .file
"camellia-encrypt-internal.asm"
119 C _camellia_crypt
(struct camellia_context
*ctx
,
120 C const
struct camellia_table
*T
,
121 C unsigned
length, uint8_t
*dst
,
125 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
187 EPILOGUE(_nettle_camellia_crypt)