camellia_asm.S 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #include <linux/linkage.h>
  3. #include <asm/visasm.h>
  4. #include "opcodes.h"
  5. #define CAMELLIA_6ROUNDS(KEY_BASE, I0, I1) \
  6. CAMELLIA_F(KEY_BASE + 0, I1, I0, I1) \
  7. CAMELLIA_F(KEY_BASE + 2, I0, I1, I0) \
  8. CAMELLIA_F(KEY_BASE + 4, I1, I0, I1) \
  9. CAMELLIA_F(KEY_BASE + 6, I0, I1, I0) \
  10. CAMELLIA_F(KEY_BASE + 8, I1, I0, I1) \
  11. CAMELLIA_F(KEY_BASE + 10, I0, I1, I0)
  12. #define CAMELLIA_6ROUNDS_FL_FLI(KEY_BASE, I0, I1) \
  13. CAMELLIA_6ROUNDS(KEY_BASE, I0, I1) \
  14. CAMELLIA_FL(KEY_BASE + 12, I0, I0) \
  15. CAMELLIA_FLI(KEY_BASE + 14, I1, I1)
  16. .data
  17. .align 8
  18. SIGMA: .xword 0xA09E667F3BCC908B
  19. .xword 0xB67AE8584CAA73B2
  20. .xword 0xC6EF372FE94F82BE
  21. .xword 0x54FF53A5F1D36F1C
  22. .xword 0x10E527FADE682D1D
  23. .xword 0xB05688C2B3E6C1FD
  24. .text
  25. .align 32
  26. ENTRY(camellia_sparc64_key_expand)
  27. /* %o0=in_key, %o1=encrypt_key, %o2=key_len, %o3=decrypt_key */
  28. VISEntry
  29. ld [%o0 + 0x00], %f0 ! i0, k[0]
  30. ld [%o0 + 0x04], %f1 ! i1, k[1]
  31. ld [%o0 + 0x08], %f2 ! i2, k[2]
  32. ld [%o0 + 0x0c], %f3 ! i3, k[3]
  33. std %f0, [%o1 + 0x00] ! k[0, 1]
  34. fsrc2 %f0, %f28
  35. std %f2, [%o1 + 0x08] ! k[2, 3]
  36. cmp %o2, 16
  37. be 10f
  38. fsrc2 %f2, %f30
  39. ld [%o0 + 0x10], %f0
  40. ld [%o0 + 0x14], %f1
  41. std %f0, [%o1 + 0x20] ! k[8, 9]
  42. cmp %o2, 24
  43. fone %f10
  44. be,a 1f
  45. fxor %f10, %f0, %f2
  46. ld [%o0 + 0x18], %f2
  47. ld [%o0 + 0x1c], %f3
  48. 1:
  49. std %f2, [%o1 + 0x28] ! k[10, 11]
  50. fxor %f28, %f0, %f0
  51. fxor %f30, %f2, %f2
  52. 10:
  53. sethi %hi(SIGMA), %g3
  54. or %g3, %lo(SIGMA), %g3
  55. ldd [%g3 + 0x00], %f16
  56. ldd [%g3 + 0x08], %f18
  57. ldd [%g3 + 0x10], %f20
  58. ldd [%g3 + 0x18], %f22
  59. ldd [%g3 + 0x20], %f24
  60. ldd [%g3 + 0x28], %f26
  61. CAMELLIA_F(16, 2, 0, 2)
  62. CAMELLIA_F(18, 0, 2, 0)
  63. fxor %f28, %f0, %f0
  64. fxor %f30, %f2, %f2
  65. CAMELLIA_F(20, 2, 0, 2)
  66. CAMELLIA_F(22, 0, 2, 0)
  67. #define ROTL128(S01, S23, TMP1, TMP2, N) \
  68. srlx S01, (64 - N), TMP1; \
  69. sllx S01, N, S01; \
  70. srlx S23, (64 - N), TMP2; \
  71. sllx S23, N, S23; \
  72. or S01, TMP2, S01; \
  73. or S23, TMP1, S23
  74. cmp %o2, 16
  75. bne 1f
  76. nop
  77. /* 128-bit key */
  78. std %f0, [%o1 + 0x10] ! k[ 4, 5]
  79. std %f2, [%o1 + 0x18] ! k[ 6, 7]
  80. MOVDTOX_F0_O4
  81. MOVDTOX_F2_O5
  82. ROTL128(%o4, %o5, %g2, %g3, 15)
  83. stx %o4, [%o1 + 0x30] ! k[12, 13]
  84. stx %o5, [%o1 + 0x38] ! k[14, 15]
  85. ROTL128(%o4, %o5, %g2, %g3, 15)
  86. stx %o4, [%o1 + 0x40] ! k[16, 17]
  87. stx %o5, [%o1 + 0x48] ! k[18, 19]
  88. ROTL128(%o4, %o5, %g2, %g3, 15)
  89. stx %o4, [%o1 + 0x60] ! k[24, 25]
  90. ROTL128(%o4, %o5, %g2, %g3, 15)
  91. stx %o4, [%o1 + 0x70] ! k[28, 29]
  92. stx %o5, [%o1 + 0x78] ! k[30, 31]
  93. ROTL128(%o4, %o5, %g2, %g3, 34)
  94. stx %o4, [%o1 + 0xa0] ! k[40, 41]
  95. stx %o5, [%o1 + 0xa8] ! k[42, 43]
  96. ROTL128(%o4, %o5, %g2, %g3, 17)
  97. stx %o4, [%o1 + 0xc0] ! k[48, 49]
  98. stx %o5, [%o1 + 0xc8] ! k[50, 51]
  99. ldx [%o1 + 0x00], %o4 ! k[ 0, 1]
  100. ldx [%o1 + 0x08], %o5 ! k[ 2, 3]
  101. ROTL128(%o4, %o5, %g2, %g3, 15)
  102. stx %o4, [%o1 + 0x20] ! k[ 8, 9]
  103. stx %o5, [%o1 + 0x28] ! k[10, 11]
  104. ROTL128(%o4, %o5, %g2, %g3, 30)
  105. stx %o4, [%o1 + 0x50] ! k[20, 21]
  106. stx %o5, [%o1 + 0x58] ! k[22, 23]
  107. ROTL128(%o4, %o5, %g2, %g3, 15)
  108. stx %o5, [%o1 + 0x68] ! k[26, 27]
  109. ROTL128(%o4, %o5, %g2, %g3, 17)
  110. stx %o4, [%o1 + 0x80] ! k[32, 33]
  111. stx %o5, [%o1 + 0x88] ! k[34, 35]
  112. ROTL128(%o4, %o5, %g2, %g3, 17)
  113. stx %o4, [%o1 + 0x90] ! k[36, 37]
  114. stx %o5, [%o1 + 0x98] ! k[38, 39]
  115. ROTL128(%o4, %o5, %g2, %g3, 17)
  116. stx %o4, [%o1 + 0xb0] ! k[44, 45]
  117. stx %o5, [%o1 + 0xb8] ! k[46, 47]
  118. ba,pt %xcc, 2f
  119. mov (3 * 16 * 4), %o0
  120. 1:
  121. /* 192-bit or 256-bit key */
  122. std %f0, [%o1 + 0x30] ! k[12, 13]
  123. std %f2, [%o1 + 0x38] ! k[14, 15]
  124. ldd [%o1 + 0x20], %f4 ! k[ 8, 9]
  125. ldd [%o1 + 0x28], %f6 ! k[10, 11]
  126. fxor %f0, %f4, %f0
  127. fxor %f2, %f6, %f2
  128. CAMELLIA_F(24, 2, 0, 2)
  129. CAMELLIA_F(26, 0, 2, 0)
  130. std %f0, [%o1 + 0x10] ! k[ 4, 5]
  131. std %f2, [%o1 + 0x18] ! k[ 6, 7]
  132. MOVDTOX_F0_O4
  133. MOVDTOX_F2_O5
  134. ROTL128(%o4, %o5, %g2, %g3, 30)
  135. stx %o4, [%o1 + 0x50] ! k[20, 21]
  136. stx %o5, [%o1 + 0x58] ! k[22, 23]
  137. ROTL128(%o4, %o5, %g2, %g3, 30)
  138. stx %o4, [%o1 + 0xa0] ! k[40, 41]
  139. stx %o5, [%o1 + 0xa8] ! k[42, 43]
  140. ROTL128(%o4, %o5, %g2, %g3, 51)
  141. stx %o4, [%o1 + 0x100] ! k[64, 65]
  142. stx %o5, [%o1 + 0x108] ! k[66, 67]
  143. ldx [%o1 + 0x20], %o4 ! k[ 8, 9]
  144. ldx [%o1 + 0x28], %o5 ! k[10, 11]
  145. ROTL128(%o4, %o5, %g2, %g3, 15)
  146. stx %o4, [%o1 + 0x20] ! k[ 8, 9]
  147. stx %o5, [%o1 + 0x28] ! k[10, 11]
  148. ROTL128(%o4, %o5, %g2, %g3, 15)
  149. stx %o4, [%o1 + 0x40] ! k[16, 17]
  150. stx %o5, [%o1 + 0x48] ! k[18, 19]
  151. ROTL128(%o4, %o5, %g2, %g3, 30)
  152. stx %o4, [%o1 + 0x90] ! k[36, 37]
  153. stx %o5, [%o1 + 0x98] ! k[38, 39]
  154. ROTL128(%o4, %o5, %g2, %g3, 34)
  155. stx %o4, [%o1 + 0xd0] ! k[52, 53]
  156. stx %o5, [%o1 + 0xd8] ! k[54, 55]
  157. ldx [%o1 + 0x30], %o4 ! k[12, 13]
  158. ldx [%o1 + 0x38], %o5 ! k[14, 15]
  159. ROTL128(%o4, %o5, %g2, %g3, 15)
  160. stx %o4, [%o1 + 0x30] ! k[12, 13]
  161. stx %o5, [%o1 + 0x38] ! k[14, 15]
  162. ROTL128(%o4, %o5, %g2, %g3, 30)
  163. stx %o4, [%o1 + 0x70] ! k[28, 29]
  164. stx %o5, [%o1 + 0x78] ! k[30, 31]
  165. srlx %o4, 32, %g2
  166. srlx %o5, 32, %g3
  167. stw %o4, [%o1 + 0xc0] ! k[48]
  168. stw %g3, [%o1 + 0xc4] ! k[49]
  169. stw %o5, [%o1 + 0xc8] ! k[50]
  170. stw %g2, [%o1 + 0xcc] ! k[51]
  171. ROTL128(%o4, %o5, %g2, %g3, 49)
  172. stx %o4, [%o1 + 0xe0] ! k[56, 57]
  173. stx %o5, [%o1 + 0xe8] ! k[58, 59]
  174. ldx [%o1 + 0x00], %o4 ! k[ 0, 1]
  175. ldx [%o1 + 0x08], %o5 ! k[ 2, 3]
  176. ROTL128(%o4, %o5, %g2, %g3, 45)
  177. stx %o4, [%o1 + 0x60] ! k[24, 25]
  178. stx %o5, [%o1 + 0x68] ! k[26, 27]
  179. ROTL128(%o4, %o5, %g2, %g3, 15)
  180. stx %o4, [%o1 + 0x80] ! k[32, 33]
  181. stx %o5, [%o1 + 0x88] ! k[34, 35]
  182. ROTL128(%o4, %o5, %g2, %g3, 17)
  183. stx %o4, [%o1 + 0xb0] ! k[44, 45]
  184. stx %o5, [%o1 + 0xb8] ! k[46, 47]
  185. ROTL128(%o4, %o5, %g2, %g3, 34)
  186. stx %o4, [%o1 + 0xf0] ! k[60, 61]
  187. stx %o5, [%o1 + 0xf8] ! k[62, 63]
  188. mov (4 * 16 * 4), %o0
  189. 2:
  190. add %o1, %o0, %o1
  191. ldd [%o1 + 0x00], %f0
  192. ldd [%o1 + 0x08], %f2
  193. std %f0, [%o3 + 0x00]
  194. std %f2, [%o3 + 0x08]
  195. add %o3, 0x10, %o3
  196. 1:
  197. sub %o1, (16 * 4), %o1
  198. ldd [%o1 + 0x38], %f0
  199. ldd [%o1 + 0x30], %f2
  200. ldd [%o1 + 0x28], %f4
  201. ldd [%o1 + 0x20], %f6
  202. ldd [%o1 + 0x18], %f8
  203. ldd [%o1 + 0x10], %f10
  204. std %f0, [%o3 + 0x00]
  205. std %f2, [%o3 + 0x08]
  206. std %f4, [%o3 + 0x10]
  207. std %f6, [%o3 + 0x18]
  208. std %f8, [%o3 + 0x20]
  209. std %f10, [%o3 + 0x28]
  210. ldd [%o1 + 0x08], %f0
  211. ldd [%o1 + 0x00], %f2
  212. std %f0, [%o3 + 0x30]
  213. std %f2, [%o3 + 0x38]
  214. subcc %o0, (16 * 4), %o0
  215. bne,pt %icc, 1b
  216. add %o3, (16 * 4), %o3
  217. std %f2, [%o3 - 0x10]
  218. std %f0, [%o3 - 0x08]
  219. retl
  220. VISExit
  221. ENDPROC(camellia_sparc64_key_expand)
  222. .align 32
  223. ENTRY(camellia_sparc64_crypt)
  224. /* %o0=key, %o1=input, %o2=output, %o3=key_len */
  225. VISEntry
  226. ld [%o1 + 0x00], %f0
  227. ld [%o1 + 0x04], %f1
  228. ld [%o1 + 0x08], %f2
  229. ld [%o1 + 0x0c], %f3
  230. ldd [%o0 + 0x00], %f4
  231. ldd [%o0 + 0x08], %f6
  232. cmp %o3, 16
  233. fxor %f4, %f0, %f0
  234. be 1f
  235. fxor %f6, %f2, %f2
  236. ldd [%o0 + 0x10], %f8
  237. ldd [%o0 + 0x18], %f10
  238. ldd [%o0 + 0x20], %f12
  239. ldd [%o0 + 0x28], %f14
  240. ldd [%o0 + 0x30], %f16
  241. ldd [%o0 + 0x38], %f18
  242. ldd [%o0 + 0x40], %f20
  243. ldd [%o0 + 0x48], %f22
  244. add %o0, 0x40, %o0
  245. CAMELLIA_6ROUNDS_FL_FLI( 8, 0, 2)
  246. 1:
  247. ldd [%o0 + 0x10], %f8
  248. ldd [%o0 + 0x18], %f10
  249. ldd [%o0 + 0x20], %f12
  250. ldd [%o0 + 0x28], %f14
  251. ldd [%o0 + 0x30], %f16
  252. ldd [%o0 + 0x38], %f18
  253. ldd [%o0 + 0x40], %f20
  254. ldd [%o0 + 0x48], %f22
  255. ldd [%o0 + 0x50], %f24
  256. ldd [%o0 + 0x58], %f26
  257. ldd [%o0 + 0x60], %f28
  258. ldd [%o0 + 0x68], %f30
  259. ldd [%o0 + 0x70], %f32
  260. ldd [%o0 + 0x78], %f34
  261. ldd [%o0 + 0x80], %f36
  262. ldd [%o0 + 0x88], %f38
  263. ldd [%o0 + 0x90], %f40
  264. ldd [%o0 + 0x98], %f42
  265. ldd [%o0 + 0xa0], %f44
  266. ldd [%o0 + 0xa8], %f46
  267. ldd [%o0 + 0xb0], %f48
  268. ldd [%o0 + 0xb8], %f50
  269. ldd [%o0 + 0xc0], %f52
  270. ldd [%o0 + 0xc8], %f54
  271. CAMELLIA_6ROUNDS_FL_FLI( 8, 0, 2)
  272. CAMELLIA_6ROUNDS_FL_FLI(24, 0, 2)
  273. CAMELLIA_6ROUNDS(40, 0, 2)
  274. fxor %f52, %f2, %f2
  275. fxor %f54, %f0, %f0
  276. st %f2, [%o2 + 0x00]
  277. st %f3, [%o2 + 0x04]
  278. st %f0, [%o2 + 0x08]
  279. st %f1, [%o2 + 0x0c]
  280. retl
  281. VISExit
  282. ENDPROC(camellia_sparc64_crypt)
  283. .align 32
  284. ENTRY(camellia_sparc64_load_keys)
  285. /* %o0=key, %o1=key_len */
  286. VISEntry
  287. ldd [%o0 + 0x00], %f4
  288. ldd [%o0 + 0x08], %f6
  289. ldd [%o0 + 0x10], %f8
  290. ldd [%o0 + 0x18], %f10
  291. ldd [%o0 + 0x20], %f12
  292. ldd [%o0 + 0x28], %f14
  293. ldd [%o0 + 0x30], %f16
  294. ldd [%o0 + 0x38], %f18
  295. ldd [%o0 + 0x40], %f20
  296. ldd [%o0 + 0x48], %f22
  297. ldd [%o0 + 0x50], %f24
  298. ldd [%o0 + 0x58], %f26
  299. ldd [%o0 + 0x60], %f28
  300. ldd [%o0 + 0x68], %f30
  301. ldd [%o0 + 0x70], %f32
  302. ldd [%o0 + 0x78], %f34
  303. ldd [%o0 + 0x80], %f36
  304. ldd [%o0 + 0x88], %f38
  305. ldd [%o0 + 0x90], %f40
  306. ldd [%o0 + 0x98], %f42
  307. ldd [%o0 + 0xa0], %f44
  308. ldd [%o0 + 0xa8], %f46
  309. ldd [%o0 + 0xb0], %f48
  310. ldd [%o0 + 0xb8], %f50
  311. ldd [%o0 + 0xc0], %f52
  312. retl
  313. ldd [%o0 + 0xc8], %f54
  314. ENDPROC(camellia_sparc64_load_keys)
  315. .align 32
  316. ENTRY(camellia_sparc64_ecb_crypt_3_grand_rounds)
  317. /* %o0=input, %o1=output, %o2=len, %o3=key */
  318. 1: ldd [%o0 + 0x00], %f0
  319. ldd [%o0 + 0x08], %f2
  320. add %o0, 0x10, %o0
  321. fxor %f4, %f0, %f0
  322. fxor %f6, %f2, %f2
  323. CAMELLIA_6ROUNDS_FL_FLI( 8, 0, 2)
  324. CAMELLIA_6ROUNDS_FL_FLI(24, 0, 2)
  325. CAMELLIA_6ROUNDS(40, 0, 2)
  326. fxor %f52, %f2, %f2
  327. fxor %f54, %f0, %f0
  328. std %f2, [%o1 + 0x00]
  329. std %f0, [%o1 + 0x08]
  330. subcc %o2, 0x10, %o2
  331. bne,pt %icc, 1b
  332. add %o1, 0x10, %o1
  333. retl
  334. nop
  335. ENDPROC(camellia_sparc64_ecb_crypt_3_grand_rounds)
  336. .align 32
  337. ENTRY(camellia_sparc64_ecb_crypt_4_grand_rounds)
  338. /* %o0=input, %o1=output, %o2=len, %o3=key */
  339. 1: ldd [%o0 + 0x00], %f0
  340. ldd [%o0 + 0x08], %f2
  341. add %o0, 0x10, %o0
  342. fxor %f4, %f0, %f0
  343. fxor %f6, %f2, %f2
  344. CAMELLIA_6ROUNDS_FL_FLI( 8, 0, 2)
  345. ldd [%o3 + 0xd0], %f8
  346. ldd [%o3 + 0xd8], %f10
  347. ldd [%o3 + 0xe0], %f12
  348. ldd [%o3 + 0xe8], %f14
  349. ldd [%o3 + 0xf0], %f16
  350. ldd [%o3 + 0xf8], %f18
  351. ldd [%o3 + 0x100], %f20
  352. ldd [%o3 + 0x108], %f22
  353. CAMELLIA_6ROUNDS_FL_FLI(24, 0, 2)
  354. CAMELLIA_6ROUNDS_FL_FLI(40, 0, 2)
  355. CAMELLIA_F(8, 2, 0, 2)
  356. CAMELLIA_F(10, 0, 2, 0)
  357. ldd [%o3 + 0x10], %f8
  358. ldd [%o3 + 0x18], %f10
  359. CAMELLIA_F(12, 2, 0, 2)
  360. CAMELLIA_F(14, 0, 2, 0)
  361. ldd [%o3 + 0x20], %f12
  362. ldd [%o3 + 0x28], %f14
  363. CAMELLIA_F(16, 2, 0, 2)
  364. CAMELLIA_F(18, 0, 2, 0)
  365. ldd [%o3 + 0x30], %f16
  366. ldd [%o3 + 0x38], %f18
  367. fxor %f20, %f2, %f2
  368. fxor %f22, %f0, %f0
  369. ldd [%o3 + 0x40], %f20
  370. ldd [%o3 + 0x48], %f22
  371. std %f2, [%o1 + 0x00]
  372. std %f0, [%o1 + 0x08]
  373. subcc %o2, 0x10, %o2
  374. bne,pt %icc, 1b
  375. add %o1, 0x10, %o1
  376. retl
  377. nop
  378. ENDPROC(camellia_sparc64_ecb_crypt_4_grand_rounds)
  379. .align 32
  380. ENTRY(camellia_sparc64_cbc_encrypt_3_grand_rounds)
  381. /* %o0=input, %o1=output, %o2=len, %o3=key, %o4=IV */
  382. ldd [%o4 + 0x00], %f60
  383. ldd [%o4 + 0x08], %f62
  384. 1: ldd [%o0 + 0x00], %f0
  385. ldd [%o0 + 0x08], %f2
  386. add %o0, 0x10, %o0
  387. fxor %f60, %f0, %f0
  388. fxor %f62, %f2, %f2
  389. fxor %f4, %f0, %f0
  390. fxor %f6, %f2, %f2
  391. CAMELLIA_6ROUNDS_FL_FLI( 8, 0, 2)
  392. CAMELLIA_6ROUNDS_FL_FLI(24, 0, 2)
  393. CAMELLIA_6ROUNDS(40, 0, 2)
  394. fxor %f52, %f2, %f60
  395. fxor %f54, %f0, %f62
  396. std %f60, [%o1 + 0x00]
  397. std %f62, [%o1 + 0x08]
  398. subcc %o2, 0x10, %o2
  399. bne,pt %icc, 1b
  400. add %o1, 0x10, %o1
  401. std %f60, [%o4 + 0x00]
  402. retl
  403. std %f62, [%o4 + 0x08]
  404. ENDPROC(camellia_sparc64_cbc_encrypt_3_grand_rounds)
  405. .align 32
  406. ENTRY(camellia_sparc64_cbc_encrypt_4_grand_rounds)
  407. /* %o0=input, %o1=output, %o2=len, %o3=key, %o4=IV */
  408. ldd [%o4 + 0x00], %f60
  409. ldd [%o4 + 0x08], %f62
  410. 1: ldd [%o0 + 0x00], %f0
  411. ldd [%o0 + 0x08], %f2
  412. add %o0, 0x10, %o0
  413. fxor %f60, %f0, %f0
  414. fxor %f62, %f2, %f2
  415. fxor %f4, %f0, %f0
  416. fxor %f6, %f2, %f2
  417. CAMELLIA_6ROUNDS_FL_FLI( 8, 0, 2)
  418. ldd [%o3 + 0xd0], %f8
  419. ldd [%o3 + 0xd8], %f10
  420. ldd [%o3 + 0xe0], %f12
  421. ldd [%o3 + 0xe8], %f14
  422. ldd [%o3 + 0xf0], %f16
  423. ldd [%o3 + 0xf8], %f18
  424. ldd [%o3 + 0x100], %f20
  425. ldd [%o3 + 0x108], %f22
  426. CAMELLIA_6ROUNDS_FL_FLI(24, 0, 2)
  427. CAMELLIA_6ROUNDS_FL_FLI(40, 0, 2)
  428. CAMELLIA_F(8, 2, 0, 2)
  429. CAMELLIA_F(10, 0, 2, 0)
  430. ldd [%o3 + 0x10], %f8
  431. ldd [%o3 + 0x18], %f10
  432. CAMELLIA_F(12, 2, 0, 2)
  433. CAMELLIA_F(14, 0, 2, 0)
  434. ldd [%o3 + 0x20], %f12
  435. ldd [%o3 + 0x28], %f14
  436. CAMELLIA_F(16, 2, 0, 2)
  437. CAMELLIA_F(18, 0, 2, 0)
  438. ldd [%o3 + 0x30], %f16
  439. ldd [%o3 + 0x38], %f18
  440. fxor %f20, %f2, %f60
  441. fxor %f22, %f0, %f62
  442. ldd [%o3 + 0x40], %f20
  443. ldd [%o3 + 0x48], %f22
  444. std %f60, [%o1 + 0x00]
  445. std %f62, [%o1 + 0x08]
  446. subcc %o2, 0x10, %o2
  447. bne,pt %icc, 1b
  448. add %o1, 0x10, %o1
  449. std %f60, [%o4 + 0x00]
  450. retl
  451. std %f62, [%o4 + 0x08]
  452. ENDPROC(camellia_sparc64_cbc_encrypt_4_grand_rounds)
  453. .align 32
  454. ENTRY(camellia_sparc64_cbc_decrypt_3_grand_rounds)
  455. /* %o0=input, %o1=output, %o2=len, %o3=key, %o4=IV */
  456. ldd [%o4 + 0x00], %f60
  457. ldd [%o4 + 0x08], %f62
  458. 1: ldd [%o0 + 0x00], %f56
  459. ldd [%o0 + 0x08], %f58
  460. add %o0, 0x10, %o0
  461. fxor %f4, %f56, %f0
  462. fxor %f6, %f58, %f2
  463. CAMELLIA_6ROUNDS_FL_FLI( 8, 0, 2)
  464. CAMELLIA_6ROUNDS_FL_FLI(24, 0, 2)
  465. CAMELLIA_6ROUNDS(40, 0, 2)
  466. fxor %f52, %f2, %f2
  467. fxor %f54, %f0, %f0
  468. fxor %f60, %f2, %f2
  469. fxor %f62, %f0, %f0
  470. fsrc2 %f56, %f60
  471. fsrc2 %f58, %f62
  472. std %f2, [%o1 + 0x00]
  473. std %f0, [%o1 + 0x08]
  474. subcc %o2, 0x10, %o2
  475. bne,pt %icc, 1b
  476. add %o1, 0x10, %o1
  477. std %f60, [%o4 + 0x00]
  478. retl
  479. std %f62, [%o4 + 0x08]
  480. ENDPROC(camellia_sparc64_cbc_decrypt_3_grand_rounds)
  481. .align 32
  482. ENTRY(camellia_sparc64_cbc_decrypt_4_grand_rounds)
  483. /* %o0=input, %o1=output, %o2=len, %o3=key, %o4=IV */
  484. ldd [%o4 + 0x00], %f60
  485. ldd [%o4 + 0x08], %f62
  486. 1: ldd [%o0 + 0x00], %f56
  487. ldd [%o0 + 0x08], %f58
  488. add %o0, 0x10, %o0
  489. fxor %f4, %f56, %f0
  490. fxor %f6, %f58, %f2
  491. CAMELLIA_6ROUNDS_FL_FLI( 8, 0, 2)
  492. ldd [%o3 + 0xd0], %f8
  493. ldd [%o3 + 0xd8], %f10
  494. ldd [%o3 + 0xe0], %f12
  495. ldd [%o3 + 0xe8], %f14
  496. ldd [%o3 + 0xf0], %f16
  497. ldd [%o3 + 0xf8], %f18
  498. ldd [%o3 + 0x100], %f20
  499. ldd [%o3 + 0x108], %f22
  500. CAMELLIA_6ROUNDS_FL_FLI(24, 0, 2)
  501. CAMELLIA_6ROUNDS_FL_FLI(40, 0, 2)
  502. CAMELLIA_F(8, 2, 0, 2)
  503. CAMELLIA_F(10, 0, 2, 0)
  504. ldd [%o3 + 0x10], %f8
  505. ldd [%o3 + 0x18], %f10
  506. CAMELLIA_F(12, 2, 0, 2)
  507. CAMELLIA_F(14, 0, 2, 0)
  508. ldd [%o3 + 0x20], %f12
  509. ldd [%o3 + 0x28], %f14
  510. CAMELLIA_F(16, 2, 0, 2)
  511. CAMELLIA_F(18, 0, 2, 0)
  512. ldd [%o3 + 0x30], %f16
  513. ldd [%o3 + 0x38], %f18
  514. fxor %f20, %f2, %f2
  515. fxor %f22, %f0, %f0
  516. ldd [%o3 + 0x40], %f20
  517. ldd [%o3 + 0x48], %f22
  518. fxor %f60, %f2, %f2
  519. fxor %f62, %f0, %f0
  520. fsrc2 %f56, %f60
  521. fsrc2 %f58, %f62
  522. std %f2, [%o1 + 0x00]
  523. std %f0, [%o1 + 0x08]
  524. subcc %o2, 0x10, %o2
  525. bne,pt %icc, 1b
  526. add %o1, 0x10, %o1
  527. std %f60, [%o4 + 0x00]
  528. retl
  529. std %f62, [%o4 + 0x08]
  530. ENDPROC(camellia_sparc64_cbc_decrypt_4_grand_rounds)