camellia_asm.S 13 KB

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