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
,
22 C Camellia state
, 128-bit value
in little endian order.
23 C L0
, H0 corresponds to D1
in the spec
and i0
in the C implementation.
24 C while L1
, H1 corresponds to D2
/i1.
36 define
(<FRAME_L0
>, <(%esp)>)
37 define
(<FRAME_H0
>, <4(%esp)>)
38 define
(<FRAME_L1
>, <8(%esp)>)
39 define
(<FRAME_H1
>, <12(%esp)>)
40 define
(<FRAME_CNT
>, <16(%esp)>)
43 define
(<FRAME_CTX
>, <40(%esp)>)
44 define
(<FRAME_TABLE
>, <44(%esp)>)
45 define
(<FRAME_LENGTH
>, <48(%esp)>)
46 define
(<FRAME_DST
>, <52(%esp)>)
47 define
(<FRAME_SRC
>, <56(%esp)>)
49 define
(<SP1110
>, <(T
,$1,4)>)
50 define
(<SP0222
>, <1024(T
,$1,4)>)
51 define
(<SP3033
>, <2048(T
,$1,4)>)
52 define
(<SP4404
>, <3072(T
,$1,4)>)
54 C ROUND
(xl
, xh
, yl
, yh
, key
-offset)
55 C xl
and xh are rotated
16 bits at the
end
56 C yl
and yh are read from stack
, and left
in registers
91 C Six rounds
, with inputs
and outputs
in registers.
98 ROUND
(L0
,H0
,<L1
>,<H1
>,0)
101 ROUND
(L1
,H1
,<L0
>,<H0
>,8)
104 ROUND
(L0
,H0
,<L1
>,<H1
>,16)
107 ROUND
(L1
,H1
,<L0
>,<H0
>,24)
110 ROUND
(L0
,H0
,<L1
>,<H1
>,32)
111 ROUND
(L1
,H1
,<L0
>,<H0
>,40)
116 C FL
(x0
, x1
, key
-offset)
118 movl
$3 + 4(KEY
), TMP
126 C FLINV
(x0
, x1
, key
-offset)
131 movl
$3 + 4(KEY
), TMP
137 .file
"camellia-encrypt-internal.asm"
139 C _camellia_crypt
(struct camellia_context
*ctx
,
140 C const
struct camellia_table
*T
,
141 C unsigned
length, uint8_t
*dst
,
145 PROLOGUE
(_nettle_camellia_crypt
)
146 C save all registers that need to be saved
147 pushl
%ebx C
32(%esp)
148 pushl
%ebp C
28(%esp)
149 pushl
%esi C
24(%esp)
150 pushl
%edi C
20(%esp)
154 movl FRAME_LENGTH
, %ebp
159 C Load data
, note that we
'll happily do unaligned loads
174 C Whitening using first subkey
175 addl $ALIGNOF_UINT64_T + 8, KEY
202 subl $16, FRAME_LENGTH
212 EPILOGUE(_nettle_camellia_crypt)