aes_asm.S 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543
  1. #include <linux/linkage.h>
  2. #include <asm/visasm.h>
  3. #include "opcodes.h"
  4. #define ENCRYPT_TWO_ROUNDS(KEY_BASE, I0, I1, T0, T1) \
  5. AES_EROUND01(KEY_BASE + 0, I0, I1, T0) \
  6. AES_EROUND23(KEY_BASE + 2, I0, I1, T1) \
  7. AES_EROUND01(KEY_BASE + 4, T0, T1, I0) \
  8. AES_EROUND23(KEY_BASE + 6, T0, T1, I1)
  9. #define ENCRYPT_TWO_ROUNDS_2(KEY_BASE, I0, I1, I2, I3, T0, T1, T2, T3) \
  10. AES_EROUND01(KEY_BASE + 0, I0, I1, T0) \
  11. AES_EROUND23(KEY_BASE + 2, I0, I1, T1) \
  12. AES_EROUND01(KEY_BASE + 0, I2, I3, T2) \
  13. AES_EROUND23(KEY_BASE + 2, I2, I3, T3) \
  14. AES_EROUND01(KEY_BASE + 4, T0, T1, I0) \
  15. AES_EROUND23(KEY_BASE + 6, T0, T1, I1) \
  16. AES_EROUND01(KEY_BASE + 4, T2, T3, I2) \
  17. AES_EROUND23(KEY_BASE + 6, T2, T3, I3)
  18. #define ENCRYPT_TWO_ROUNDS_LAST(KEY_BASE, I0, I1, T0, T1) \
  19. AES_EROUND01(KEY_BASE + 0, I0, I1, T0) \
  20. AES_EROUND23(KEY_BASE + 2, I0, I1, T1) \
  21. AES_EROUND01_L(KEY_BASE + 4, T0, T1, I0) \
  22. AES_EROUND23_L(KEY_BASE + 6, T0, T1, I1)
  23. #define ENCRYPT_TWO_ROUNDS_LAST_2(KEY_BASE, I0, I1, I2, I3, T0, T1, T2, T3) \
  24. AES_EROUND01(KEY_BASE + 0, I0, I1, T0) \
  25. AES_EROUND23(KEY_BASE + 2, I0, I1, T1) \
  26. AES_EROUND01(KEY_BASE + 0, I2, I3, T2) \
  27. AES_EROUND23(KEY_BASE + 2, I2, I3, T3) \
  28. AES_EROUND01_L(KEY_BASE + 4, T0, T1, I0) \
  29. AES_EROUND23_L(KEY_BASE + 6, T0, T1, I1) \
  30. AES_EROUND01_L(KEY_BASE + 4, T2, T3, I2) \
  31. AES_EROUND23_L(KEY_BASE + 6, T2, T3, I3)
  32. /* 10 rounds */
  33. #define ENCRYPT_128(KEY_BASE, I0, I1, T0, T1) \
  34. ENCRYPT_TWO_ROUNDS(KEY_BASE + 0, I0, I1, T0, T1) \
  35. ENCRYPT_TWO_ROUNDS(KEY_BASE + 8, I0, I1, T0, T1) \
  36. ENCRYPT_TWO_ROUNDS(KEY_BASE + 16, I0, I1, T0, T1) \
  37. ENCRYPT_TWO_ROUNDS(KEY_BASE + 24, I0, I1, T0, T1) \
  38. ENCRYPT_TWO_ROUNDS_LAST(KEY_BASE + 32, I0, I1, T0, T1)
  39. #define ENCRYPT_128_2(KEY_BASE, I0, I1, I2, I3, T0, T1, T2, T3) \
  40. ENCRYPT_TWO_ROUNDS_2(KEY_BASE + 0, I0, I1, I2, I3, T0, T1, T2, T3) \
  41. ENCRYPT_TWO_ROUNDS_2(KEY_BASE + 8, I0, I1, I2, I3, T0, T1, T2, T3) \
  42. ENCRYPT_TWO_ROUNDS_2(KEY_BASE + 16, I0, I1, I2, I3, T0, T1, T2, T3) \
  43. ENCRYPT_TWO_ROUNDS_2(KEY_BASE + 24, I0, I1, I2, I3, T0, T1, T2, T3) \
  44. ENCRYPT_TWO_ROUNDS_LAST_2(KEY_BASE + 32, I0, I1, I2, I3, T0, T1, T2, T3)
  45. /* 12 rounds */
  46. #define ENCRYPT_192(KEY_BASE, I0, I1, T0, T1) \
  47. ENCRYPT_TWO_ROUNDS(KEY_BASE + 0, I0, I1, T0, T1) \
  48. ENCRYPT_TWO_ROUNDS(KEY_BASE + 8, I0, I1, T0, T1) \
  49. ENCRYPT_TWO_ROUNDS(KEY_BASE + 16, I0, I1, T0, T1) \
  50. ENCRYPT_TWO_ROUNDS(KEY_BASE + 24, I0, I1, T0, T1) \
  51. ENCRYPT_TWO_ROUNDS(KEY_BASE + 32, I0, I1, T0, T1) \
  52. ENCRYPT_TWO_ROUNDS_LAST(KEY_BASE + 40, I0, I1, T0, T1)
  53. #define ENCRYPT_192_2(KEY_BASE, I0, I1, I2, I3, T0, T1, T2, T3) \
  54. ENCRYPT_TWO_ROUNDS_2(KEY_BASE + 0, I0, I1, I2, I3, T0, T1, T2, T3) \
  55. ENCRYPT_TWO_ROUNDS_2(KEY_BASE + 8, I0, I1, I2, I3, T0, T1, T2, T3) \
  56. ENCRYPT_TWO_ROUNDS_2(KEY_BASE + 16, I0, I1, I2, I3, T0, T1, T2, T3) \
  57. ENCRYPT_TWO_ROUNDS_2(KEY_BASE + 24, I0, I1, I2, I3, T0, T1, T2, T3) \
  58. ENCRYPT_TWO_ROUNDS_2(KEY_BASE + 32, I0, I1, I2, I3, T0, T1, T2, T3) \
  59. ENCRYPT_TWO_ROUNDS_LAST_2(KEY_BASE + 40, I0, I1, I2, I3, T0, T1, T2, T3)
  60. /* 14 rounds */
  61. #define ENCRYPT_256(KEY_BASE, I0, I1, T0, T1) \
  62. ENCRYPT_TWO_ROUNDS(KEY_BASE + 0, I0, I1, T0, T1) \
  63. ENCRYPT_TWO_ROUNDS(KEY_BASE + 8, I0, I1, T0, T1) \
  64. ENCRYPT_TWO_ROUNDS(KEY_BASE + 16, I0, I1, T0, T1) \
  65. ENCRYPT_TWO_ROUNDS(KEY_BASE + 24, I0, I1, T0, T1) \
  66. ENCRYPT_TWO_ROUNDS(KEY_BASE + 32, I0, I1, T0, T1) \
  67. ENCRYPT_TWO_ROUNDS(KEY_BASE + 40, I0, I1, T0, T1) \
  68. ENCRYPT_TWO_ROUNDS_LAST(KEY_BASE + 48, I0, I1, T0, T1)
  69. #define ENCRYPT_256_TWO_ROUNDS_2(KEY_BASE, I0, I1, I2, I3, TMP_BASE) \
  70. ENCRYPT_TWO_ROUNDS_2(KEY_BASE, I0, I1, I2, I3, \
  71. TMP_BASE + 0, TMP_BASE + 2, TMP_BASE + 4, TMP_BASE + 6)
  72. #define ENCRYPT_256_2(KEY_BASE, I0, I1, I2, I3) \
  73. ENCRYPT_256_TWO_ROUNDS_2(KEY_BASE + 0, I0, I1, I2, I3, KEY_BASE + 48) \
  74. ldd [%o0 + 0xd0], %f56; \
  75. ldd [%o0 + 0xd8], %f58; \
  76. ENCRYPT_256_TWO_ROUNDS_2(KEY_BASE + 8, I0, I1, I2, I3, KEY_BASE + 0) \
  77. ldd [%o0 + 0xe0], %f60; \
  78. ldd [%o0 + 0xe8], %f62; \
  79. ENCRYPT_256_TWO_ROUNDS_2(KEY_BASE + 16, I0, I1, I2, I3, KEY_BASE + 0) \
  80. ENCRYPT_256_TWO_ROUNDS_2(KEY_BASE + 24, I0, I1, I2, I3, KEY_BASE + 0) \
  81. ENCRYPT_256_TWO_ROUNDS_2(KEY_BASE + 32, I0, I1, I2, I3, KEY_BASE + 0) \
  82. ENCRYPT_256_TWO_ROUNDS_2(KEY_BASE + 40, I0, I1, I2, I3, KEY_BASE + 0) \
  83. AES_EROUND01(KEY_BASE + 48, I0, I1, KEY_BASE + 0) \
  84. AES_EROUND23(KEY_BASE + 50, I0, I1, KEY_BASE + 2) \
  85. AES_EROUND01(KEY_BASE + 48, I2, I3, KEY_BASE + 4) \
  86. AES_EROUND23(KEY_BASE + 50, I2, I3, KEY_BASE + 6) \
  87. AES_EROUND01_L(KEY_BASE + 52, KEY_BASE + 0, KEY_BASE + 2, I0) \
  88. AES_EROUND23_L(KEY_BASE + 54, KEY_BASE + 0, KEY_BASE + 2, I1) \
  89. ldd [%o0 + 0x10], %f8; \
  90. ldd [%o0 + 0x18], %f10; \
  91. AES_EROUND01_L(KEY_BASE + 52, KEY_BASE + 4, KEY_BASE + 6, I2) \
  92. AES_EROUND23_L(KEY_BASE + 54, KEY_BASE + 4, KEY_BASE + 6, I3) \
  93. ldd [%o0 + 0x20], %f12; \
  94. ldd [%o0 + 0x28], %f14;
  95. #define DECRYPT_TWO_ROUNDS(KEY_BASE, I0, I1, T0, T1) \
  96. AES_DROUND23(KEY_BASE + 0, I0, I1, T1) \
  97. AES_DROUND01(KEY_BASE + 2, I0, I1, T0) \
  98. AES_DROUND23(KEY_BASE + 4, T0, T1, I1) \
  99. AES_DROUND01(KEY_BASE + 6, T0, T1, I0)
  100. #define DECRYPT_TWO_ROUNDS_2(KEY_BASE, I0, I1, I2, I3, T0, T1, T2, T3) \
  101. AES_DROUND23(KEY_BASE + 0, I0, I1, T1) \
  102. AES_DROUND01(KEY_BASE + 2, I0, I1, T0) \
  103. AES_DROUND23(KEY_BASE + 0, I2, I3, T3) \
  104. AES_DROUND01(KEY_BASE + 2, I2, I3, T2) \
  105. AES_DROUND23(KEY_BASE + 4, T0, T1, I1) \
  106. AES_DROUND01(KEY_BASE + 6, T0, T1, I0) \
  107. AES_DROUND23(KEY_BASE + 4, T2, T3, I3) \
  108. AES_DROUND01(KEY_BASE + 6, T2, T3, I2)
  109. #define DECRYPT_TWO_ROUNDS_LAST(KEY_BASE, I0, I1, T0, T1) \
  110. AES_DROUND23(KEY_BASE + 0, I0, I1, T1) \
  111. AES_DROUND01(KEY_BASE + 2, I0, I1, T0) \
  112. AES_DROUND23_L(KEY_BASE + 4, T0, T1, I1) \
  113. AES_DROUND01_L(KEY_BASE + 6, T0, T1, I0)
  114. #define DECRYPT_TWO_ROUNDS_LAST_2(KEY_BASE, I0, I1, I2, I3, T0, T1, T2, T3) \
  115. AES_DROUND23(KEY_BASE + 0, I0, I1, T1) \
  116. AES_DROUND01(KEY_BASE + 2, I0, I1, T0) \
  117. AES_DROUND23(KEY_BASE + 0, I2, I3, T3) \
  118. AES_DROUND01(KEY_BASE + 2, I2, I3, T2) \
  119. AES_DROUND23_L(KEY_BASE + 4, T0, T1, I1) \
  120. AES_DROUND01_L(KEY_BASE + 6, T0, T1, I0) \
  121. AES_DROUND23_L(KEY_BASE + 4, T2, T3, I3) \
  122. AES_DROUND01_L(KEY_BASE + 6, T2, T3, I2)
  123. /* 10 rounds */
  124. #define DECRYPT_128(KEY_BASE, I0, I1, T0, T1) \
  125. DECRYPT_TWO_ROUNDS(KEY_BASE + 0, I0, I1, T0, T1) \
  126. DECRYPT_TWO_ROUNDS(KEY_BASE + 8, I0, I1, T0, T1) \
  127. DECRYPT_TWO_ROUNDS(KEY_BASE + 16, I0, I1, T0, T1) \
  128. DECRYPT_TWO_ROUNDS(KEY_BASE + 24, I0, I1, T0, T1) \
  129. DECRYPT_TWO_ROUNDS_LAST(KEY_BASE + 32, I0, I1, T0, T1)
  130. #define DECRYPT_128_2(KEY_BASE, I0, I1, I2, I3, T0, T1, T2, T3) \
  131. DECRYPT_TWO_ROUNDS_2(KEY_BASE + 0, I0, I1, I2, I3, T0, T1, T2, T3) \
  132. DECRYPT_TWO_ROUNDS_2(KEY_BASE + 8, I0, I1, I2, I3, T0, T1, T2, T3) \
  133. DECRYPT_TWO_ROUNDS_2(KEY_BASE + 16, I0, I1, I2, I3, T0, T1, T2, T3) \
  134. DECRYPT_TWO_ROUNDS_2(KEY_BASE + 24, I0, I1, I2, I3, T0, T1, T2, T3) \
  135. DECRYPT_TWO_ROUNDS_LAST_2(KEY_BASE + 32, I0, I1, I2, I3, T0, T1, T2, T3)
  136. /* 12 rounds */
  137. #define DECRYPT_192(KEY_BASE, I0, I1, T0, T1) \
  138. DECRYPT_TWO_ROUNDS(KEY_BASE + 0, I0, I1, T0, T1) \
  139. DECRYPT_TWO_ROUNDS(KEY_BASE + 8, I0, I1, T0, T1) \
  140. DECRYPT_TWO_ROUNDS(KEY_BASE + 16, I0, I1, T0, T1) \
  141. DECRYPT_TWO_ROUNDS(KEY_BASE + 24, I0, I1, T0, T1) \
  142. DECRYPT_TWO_ROUNDS(KEY_BASE + 32, I0, I1, T0, T1) \
  143. DECRYPT_TWO_ROUNDS_LAST(KEY_BASE + 40, I0, I1, T0, T1)
  144. #define DECRYPT_192_2(KEY_BASE, I0, I1, I2, I3, T0, T1, T2, T3) \
  145. DECRYPT_TWO_ROUNDS_2(KEY_BASE + 0, I0, I1, I2, I3, T0, T1, T2, T3) \
  146. DECRYPT_TWO_ROUNDS_2(KEY_BASE + 8, I0, I1, I2, I3, T0, T1, T2, T3) \
  147. DECRYPT_TWO_ROUNDS_2(KEY_BASE + 16, I0, I1, I2, I3, T0, T1, T2, T3) \
  148. DECRYPT_TWO_ROUNDS_2(KEY_BASE + 24, I0, I1, I2, I3, T0, T1, T2, T3) \
  149. DECRYPT_TWO_ROUNDS_2(KEY_BASE + 32, I0, I1, I2, I3, T0, T1, T2, T3) \
  150. DECRYPT_TWO_ROUNDS_LAST_2(KEY_BASE + 40, I0, I1, I2, I3, T0, T1, T2, T3)
  151. /* 14 rounds */
  152. #define DECRYPT_256(KEY_BASE, I0, I1, T0, T1) \
  153. DECRYPT_TWO_ROUNDS(KEY_BASE + 0, I0, I1, T0, T1) \
  154. DECRYPT_TWO_ROUNDS(KEY_BASE + 8, I0, I1, T0, T1) \
  155. DECRYPT_TWO_ROUNDS(KEY_BASE + 16, I0, I1, T0, T1) \
  156. DECRYPT_TWO_ROUNDS(KEY_BASE + 24, I0, I1, T0, T1) \
  157. DECRYPT_TWO_ROUNDS(KEY_BASE + 32, I0, I1, T0, T1) \
  158. DECRYPT_TWO_ROUNDS(KEY_BASE + 40, I0, I1, T0, T1) \
  159. DECRYPT_TWO_ROUNDS_LAST(KEY_BASE + 48, I0, I1, T0, T1)
  160. #define DECRYPT_256_TWO_ROUNDS_2(KEY_BASE, I0, I1, I2, I3, TMP_BASE) \
  161. DECRYPT_TWO_ROUNDS_2(KEY_BASE, I0, I1, I2, I3, \
  162. TMP_BASE + 0, TMP_BASE + 2, TMP_BASE + 4, TMP_BASE + 6)
  163. #define DECRYPT_256_2(KEY_BASE, I0, I1, I2, I3) \
  164. DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 0, I0, I1, I2, I3, KEY_BASE + 48) \
  165. ldd [%o0 + 0x18], %f56; \
  166. ldd [%o0 + 0x10], %f58; \
  167. DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 8, I0, I1, I2, I3, KEY_BASE + 0) \
  168. ldd [%o0 + 0x08], %f60; \
  169. ldd [%o0 + 0x00], %f62; \
  170. DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 16, I0, I1, I2, I3, KEY_BASE + 0) \
  171. DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 24, I0, I1, I2, I3, KEY_BASE + 0) \
  172. DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 32, I0, I1, I2, I3, KEY_BASE + 0) \
  173. DECRYPT_256_TWO_ROUNDS_2(KEY_BASE + 40, I0, I1, I2, I3, KEY_BASE + 0) \
  174. AES_DROUND23(KEY_BASE + 48, I0, I1, KEY_BASE + 2) \
  175. AES_DROUND01(KEY_BASE + 50, I0, I1, KEY_BASE + 0) \
  176. AES_DROUND23(KEY_BASE + 48, I2, I3, KEY_BASE + 6) \
  177. AES_DROUND01(KEY_BASE + 50, I2, I3, KEY_BASE + 4) \
  178. AES_DROUND23_L(KEY_BASE + 52, KEY_BASE + 0, KEY_BASE + 2, I1) \
  179. AES_DROUND01_L(KEY_BASE + 54, KEY_BASE + 0, KEY_BASE + 2, I0) \
  180. ldd [%o0 + 0xd8], %f8; \
  181. ldd [%o0 + 0xd0], %f10; \
  182. AES_DROUND23_L(KEY_BASE + 52, KEY_BASE + 4, KEY_BASE + 6, I3) \
  183. AES_DROUND01_L(KEY_BASE + 54, KEY_BASE + 4, KEY_BASE + 6, I2) \
  184. ldd [%o0 + 0xc8], %f12; \
  185. ldd [%o0 + 0xc0], %f14;
  186. .align 32
  187. ENTRY(aes_sparc64_key_expand)
  188. /* %o0=input_key, %o1=output_key, %o2=key_len */
  189. VISEntry
  190. ld [%o0 + 0x00], %f0
  191. ld [%o0 + 0x04], %f1
  192. ld [%o0 + 0x08], %f2
  193. ld [%o0 + 0x0c], %f3
  194. std %f0, [%o1 + 0x00]
  195. std %f2, [%o1 + 0x08]
  196. add %o1, 0x10, %o1
  197. cmp %o2, 24
  198. bl 2f
  199. nop
  200. be 1f
  201. nop
  202. /* 256-bit key expansion */
  203. ld [%o0 + 0x10], %f4
  204. ld [%o0 + 0x14], %f5
  205. ld [%o0 + 0x18], %f6
  206. ld [%o0 + 0x1c], %f7
  207. std %f4, [%o1 + 0x00]
  208. std %f6, [%o1 + 0x08]
  209. add %o1, 0x10, %o1
  210. AES_KEXPAND1(0, 6, 0x0, 8)
  211. AES_KEXPAND2(2, 8, 10)
  212. AES_KEXPAND0(4, 10, 12)
  213. AES_KEXPAND2(6, 12, 14)
  214. AES_KEXPAND1(8, 14, 0x1, 16)
  215. AES_KEXPAND2(10, 16, 18)
  216. AES_KEXPAND0(12, 18, 20)
  217. AES_KEXPAND2(14, 20, 22)
  218. AES_KEXPAND1(16, 22, 0x2, 24)
  219. AES_KEXPAND2(18, 24, 26)
  220. AES_KEXPAND0(20, 26, 28)
  221. AES_KEXPAND2(22, 28, 30)
  222. AES_KEXPAND1(24, 30, 0x3, 32)
  223. AES_KEXPAND2(26, 32, 34)
  224. AES_KEXPAND0(28, 34, 36)
  225. AES_KEXPAND2(30, 36, 38)
  226. AES_KEXPAND1(32, 38, 0x4, 40)
  227. AES_KEXPAND2(34, 40, 42)
  228. AES_KEXPAND0(36, 42, 44)
  229. AES_KEXPAND2(38, 44, 46)
  230. AES_KEXPAND1(40, 46, 0x5, 48)
  231. AES_KEXPAND2(42, 48, 50)
  232. AES_KEXPAND0(44, 50, 52)
  233. AES_KEXPAND2(46, 52, 54)
  234. AES_KEXPAND1(48, 54, 0x6, 56)
  235. AES_KEXPAND2(50, 56, 58)
  236. std %f8, [%o1 + 0x00]
  237. std %f10, [%o1 + 0x08]
  238. std %f12, [%o1 + 0x10]
  239. std %f14, [%o1 + 0x18]
  240. std %f16, [%o1 + 0x20]
  241. std %f18, [%o1 + 0x28]
  242. std %f20, [%o1 + 0x30]
  243. std %f22, [%o1 + 0x38]
  244. std %f24, [%o1 + 0x40]
  245. std %f26, [%o1 + 0x48]
  246. std %f28, [%o1 + 0x50]
  247. std %f30, [%o1 + 0x58]
  248. std %f32, [%o1 + 0x60]
  249. std %f34, [%o1 + 0x68]
  250. std %f36, [%o1 + 0x70]
  251. std %f38, [%o1 + 0x78]
  252. std %f40, [%o1 + 0x80]
  253. std %f42, [%o1 + 0x88]
  254. std %f44, [%o1 + 0x90]
  255. std %f46, [%o1 + 0x98]
  256. std %f48, [%o1 + 0xa0]
  257. std %f50, [%o1 + 0xa8]
  258. std %f52, [%o1 + 0xb0]
  259. std %f54, [%o1 + 0xb8]
  260. std %f56, [%o1 + 0xc0]
  261. ba,pt %xcc, 80f
  262. std %f58, [%o1 + 0xc8]
  263. 1:
  264. /* 192-bit key expansion */
  265. ld [%o0 + 0x10], %f4
  266. ld [%o0 + 0x14], %f5
  267. std %f4, [%o1 + 0x00]
  268. add %o1, 0x08, %o1
  269. AES_KEXPAND1(0, 4, 0x0, 6)
  270. AES_KEXPAND2(2, 6, 8)
  271. AES_KEXPAND2(4, 8, 10)
  272. AES_KEXPAND1(6, 10, 0x1, 12)
  273. AES_KEXPAND2(8, 12, 14)
  274. AES_KEXPAND2(10, 14, 16)
  275. AES_KEXPAND1(12, 16, 0x2, 18)
  276. AES_KEXPAND2(14, 18, 20)
  277. AES_KEXPAND2(16, 20, 22)
  278. AES_KEXPAND1(18, 22, 0x3, 24)
  279. AES_KEXPAND2(20, 24, 26)
  280. AES_KEXPAND2(22, 26, 28)
  281. AES_KEXPAND1(24, 28, 0x4, 30)
  282. AES_KEXPAND2(26, 30, 32)
  283. AES_KEXPAND2(28, 32, 34)
  284. AES_KEXPAND1(30, 34, 0x5, 36)
  285. AES_KEXPAND2(32, 36, 38)
  286. AES_KEXPAND2(34, 38, 40)
  287. AES_KEXPAND1(36, 40, 0x6, 42)
  288. AES_KEXPAND2(38, 42, 44)
  289. AES_KEXPAND2(40, 44, 46)
  290. AES_KEXPAND1(42, 46, 0x7, 48)
  291. AES_KEXPAND2(44, 48, 50)
  292. std %f6, [%o1 + 0x00]
  293. std %f8, [%o1 + 0x08]
  294. std %f10, [%o1 + 0x10]
  295. std %f12, [%o1 + 0x18]
  296. std %f14, [%o1 + 0x20]
  297. std %f16, [%o1 + 0x28]
  298. std %f18, [%o1 + 0x30]
  299. std %f20, [%o1 + 0x38]
  300. std %f22, [%o1 + 0x40]
  301. std %f24, [%o1 + 0x48]
  302. std %f26, [%o1 + 0x50]
  303. std %f28, [%o1 + 0x58]
  304. std %f30, [%o1 + 0x60]
  305. std %f32, [%o1 + 0x68]
  306. std %f34, [%o1 + 0x70]
  307. std %f36, [%o1 + 0x78]
  308. std %f38, [%o1 + 0x80]
  309. std %f40, [%o1 + 0x88]
  310. std %f42, [%o1 + 0x90]
  311. std %f44, [%o1 + 0x98]
  312. std %f46, [%o1 + 0xa0]
  313. std %f48, [%o1 + 0xa8]
  314. ba,pt %xcc, 80f
  315. std %f50, [%o1 + 0xb0]
  316. 2:
  317. /* 128-bit key expansion */
  318. AES_KEXPAND1(0, 2, 0x0, 4)
  319. AES_KEXPAND2(2, 4, 6)
  320. AES_KEXPAND1(4, 6, 0x1, 8)
  321. AES_KEXPAND2(6, 8, 10)
  322. AES_KEXPAND1(8, 10, 0x2, 12)
  323. AES_KEXPAND2(10, 12, 14)
  324. AES_KEXPAND1(12, 14, 0x3, 16)
  325. AES_KEXPAND2(14, 16, 18)
  326. AES_KEXPAND1(16, 18, 0x4, 20)
  327. AES_KEXPAND2(18, 20, 22)
  328. AES_KEXPAND1(20, 22, 0x5, 24)
  329. AES_KEXPAND2(22, 24, 26)
  330. AES_KEXPAND1(24, 26, 0x6, 28)
  331. AES_KEXPAND2(26, 28, 30)
  332. AES_KEXPAND1(28, 30, 0x7, 32)
  333. AES_KEXPAND2(30, 32, 34)
  334. AES_KEXPAND1(32, 34, 0x8, 36)
  335. AES_KEXPAND2(34, 36, 38)
  336. AES_KEXPAND1(36, 38, 0x9, 40)
  337. AES_KEXPAND2(38, 40, 42)
  338. std %f4, [%o1 + 0x00]
  339. std %f6, [%o1 + 0x08]
  340. std %f8, [%o1 + 0x10]
  341. std %f10, [%o1 + 0x18]
  342. std %f12, [%o1 + 0x20]
  343. std %f14, [%o1 + 0x28]
  344. std %f16, [%o1 + 0x30]
  345. std %f18, [%o1 + 0x38]
  346. std %f20, [%o1 + 0x40]
  347. std %f22, [%o1 + 0x48]
  348. std %f24, [%o1 + 0x50]
  349. std %f26, [%o1 + 0x58]
  350. std %f28, [%o1 + 0x60]
  351. std %f30, [%o1 + 0x68]
  352. std %f32, [%o1 + 0x70]
  353. std %f34, [%o1 + 0x78]
  354. std %f36, [%o1 + 0x80]
  355. std %f38, [%o1 + 0x88]
  356. std %f40, [%o1 + 0x90]
  357. std %f42, [%o1 + 0x98]
  358. 80:
  359. retl
  360. VISExit
  361. ENDPROC(aes_sparc64_key_expand)
  362. .align 32
  363. ENTRY(aes_sparc64_encrypt_128)
  364. /* %o0=key, %o1=input, %o2=output */
  365. VISEntry
  366. ld [%o1 + 0x00], %f4
  367. ld [%o1 + 0x04], %f5
  368. ld [%o1 + 0x08], %f6
  369. ld [%o1 + 0x0c], %f7
  370. ldd [%o0 + 0x00], %f8
  371. ldd [%o0 + 0x08], %f10
  372. ldd [%o0 + 0x10], %f12
  373. ldd [%o0 + 0x18], %f14
  374. ldd [%o0 + 0x20], %f16
  375. ldd [%o0 + 0x28], %f18
  376. ldd [%o0 + 0x30], %f20
  377. ldd [%o0 + 0x38], %f22
  378. ldd [%o0 + 0x40], %f24
  379. ldd [%o0 + 0x48], %f26
  380. ldd [%o0 + 0x50], %f28
  381. ldd [%o0 + 0x58], %f30
  382. ldd [%o0 + 0x60], %f32
  383. ldd [%o0 + 0x68], %f34
  384. ldd [%o0 + 0x70], %f36
  385. ldd [%o0 + 0x78], %f38
  386. ldd [%o0 + 0x80], %f40
  387. ldd [%o0 + 0x88], %f42
  388. ldd [%o0 + 0x90], %f44
  389. ldd [%o0 + 0x98], %f46
  390. ldd [%o0 + 0xa0], %f48
  391. ldd [%o0 + 0xa8], %f50
  392. fxor %f8, %f4, %f4
  393. fxor %f10, %f6, %f6
  394. ENCRYPT_128(12, 4, 6, 0, 2)
  395. st %f4, [%o2 + 0x00]
  396. st %f5, [%o2 + 0x04]
  397. st %f6, [%o2 + 0x08]
  398. st %f7, [%o2 + 0x0c]
  399. retl
  400. VISExit
  401. ENDPROC(aes_sparc64_encrypt_128)
  402. .align 32
  403. ENTRY(aes_sparc64_encrypt_192)
  404. /* %o0=key, %o1=input, %o2=output */
  405. VISEntry
  406. ld [%o1 + 0x00], %f4
  407. ld [%o1 + 0x04], %f5
  408. ld [%o1 + 0x08], %f6
  409. ld [%o1 + 0x0c], %f7
  410. ldd [%o0 + 0x00], %f8
  411. ldd [%o0 + 0x08], %f10
  412. fxor %f8, %f4, %f4
  413. fxor %f10, %f6, %f6
  414. ldd [%o0 + 0x10], %f8
  415. ldd [%o0 + 0x18], %f10
  416. ldd [%o0 + 0x20], %f12
  417. ldd [%o0 + 0x28], %f14
  418. add %o0, 0x20, %o0
  419. ENCRYPT_TWO_ROUNDS(8, 4, 6, 0, 2)
  420. ldd [%o0 + 0x10], %f12
  421. ldd [%o0 + 0x18], %f14
  422. ldd [%o0 + 0x20], %f16
  423. ldd [%o0 + 0x28], %f18
  424. ldd [%o0 + 0x30], %f20
  425. ldd [%o0 + 0x38], %f22
  426. ldd [%o0 + 0x40], %f24
  427. ldd [%o0 + 0x48], %f26
  428. ldd [%o0 + 0x50], %f28
  429. ldd [%o0 + 0x58], %f30
  430. ldd [%o0 + 0x60], %f32
  431. ldd [%o0 + 0x68], %f34
  432. ldd [%o0 + 0x70], %f36
  433. ldd [%o0 + 0x78], %f38
  434. ldd [%o0 + 0x80], %f40
  435. ldd [%o0 + 0x88], %f42
  436. ldd [%o0 + 0x90], %f44
  437. ldd [%o0 + 0x98], %f46
  438. ldd [%o0 + 0xa0], %f48
  439. ldd [%o0 + 0xa8], %f50
  440. ENCRYPT_128(12, 4, 6, 0, 2)
  441. st %f4, [%o2 + 0x00]
  442. st %f5, [%o2 + 0x04]
  443. st %f6, [%o2 + 0x08]
  444. st %f7, [%o2 + 0x0c]
  445. retl
  446. VISExit
  447. ENDPROC(aes_sparc64_encrypt_192)
  448. .align 32
  449. ENTRY(aes_sparc64_encrypt_256)
  450. /* %o0=key, %o1=input, %o2=output */
  451. VISEntry
  452. ld [%o1 + 0x00], %f4
  453. ld [%o1 + 0x04], %f5
  454. ld [%o1 + 0x08], %f6
  455. ld [%o1 + 0x0c], %f7
  456. ldd [%o0 + 0x00], %f8
  457. ldd [%o0 + 0x08], %f10
  458. fxor %f8, %f4, %f4
  459. fxor %f10, %f6, %f6
  460. ldd [%o0 + 0x10], %f8
  461. ldd [%o0 + 0x18], %f10
  462. ldd [%o0 + 0x20], %f12
  463. ldd [%o0 + 0x28], %f14
  464. add %o0, 0x20, %o0
  465. ENCRYPT_TWO_ROUNDS(8, 4, 6, 0, 2)
  466. ldd [%o0 + 0x10], %f8
  467. ldd [%o0 + 0x18], %f10
  468. ldd [%o0 + 0x20], %f12
  469. ldd [%o0 + 0x28], %f14
  470. add %o0, 0x20, %o0
  471. ENCRYPT_TWO_ROUNDS(8, 4, 6, 0, 2)
  472. ldd [%o0 + 0x10], %f12
  473. ldd [%o0 + 0x18], %f14
  474. ldd [%o0 + 0x20], %f16
  475. ldd [%o0 + 0x28], %f18
  476. ldd [%o0 + 0x30], %f20
  477. ldd [%o0 + 0x38], %f22
  478. ldd [%o0 + 0x40], %f24
  479. ldd [%o0 + 0x48], %f26
  480. ldd [%o0 + 0x50], %f28
  481. ldd [%o0 + 0x58], %f30
  482. ldd [%o0 + 0x60], %f32
  483. ldd [%o0 + 0x68], %f34
  484. ldd [%o0 + 0x70], %f36
  485. ldd [%o0 + 0x78], %f38
  486. ldd [%o0 + 0x80], %f40
  487. ldd [%o0 + 0x88], %f42
  488. ldd [%o0 + 0x90], %f44
  489. ldd [%o0 + 0x98], %f46
  490. ldd [%o0 + 0xa0], %f48
  491. ldd [%o0 + 0xa8], %f50
  492. ENCRYPT_128(12, 4, 6, 0, 2)
  493. st %f4, [%o2 + 0x00]
  494. st %f5, [%o2 + 0x04]
  495. st %f6, [%o2 + 0x08]
  496. st %f7, [%o2 + 0x0c]
  497. retl
  498. VISExit
  499. ENDPROC(aes_sparc64_encrypt_256)
  500. .align 32
  501. ENTRY(aes_sparc64_decrypt_128)
  502. /* %o0=key, %o1=input, %o2=output */
  503. VISEntry
  504. ld [%o1 + 0x00], %f4
  505. ld [%o1 + 0x04], %f5
  506. ld [%o1 + 0x08], %f6
  507. ld [%o1 + 0x0c], %f7
  508. ldd [%o0 + 0xa0], %f8
  509. ldd [%o0 + 0xa8], %f10
  510. ldd [%o0 + 0x98], %f12
  511. ldd [%o0 + 0x90], %f14
  512. ldd [%o0 + 0x88], %f16
  513. ldd [%o0 + 0x80], %f18
  514. ldd [%o0 + 0x78], %f20
  515. ldd [%o0 + 0x70], %f22
  516. ldd [%o0 + 0x68], %f24
  517. ldd [%o0 + 0x60], %f26
  518. ldd [%o0 + 0x58], %f28
  519. ldd [%o0 + 0x50], %f30
  520. ldd [%o0 + 0x48], %f32
  521. ldd [%o0 + 0x40], %f34
  522. ldd [%o0 + 0x38], %f36
  523. ldd [%o0 + 0x30], %f38
  524. ldd [%o0 + 0x28], %f40
  525. ldd [%o0 + 0x20], %f42
  526. ldd [%o0 + 0x18], %f44
  527. ldd [%o0 + 0x10], %f46
  528. ldd [%o0 + 0x08], %f48
  529. ldd [%o0 + 0x00], %f50
  530. fxor %f8, %f4, %f4
  531. fxor %f10, %f6, %f6
  532. DECRYPT_128(12, 4, 6, 0, 2)
  533. st %f4, [%o2 + 0x00]
  534. st %f5, [%o2 + 0x04]
  535. st %f6, [%o2 + 0x08]
  536. st %f7, [%o2 + 0x0c]
  537. retl
  538. VISExit
  539. ENDPROC(aes_sparc64_decrypt_128)
  540. .align 32
  541. ENTRY(aes_sparc64_decrypt_192)
  542. /* %o0=key, %o1=input, %o2=output */
  543. VISEntry
  544. ld [%o1 + 0x00], %f4
  545. ld [%o1 + 0x04], %f5
  546. ld [%o1 + 0x08], %f6
  547. ld [%o1 + 0x0c], %f7
  548. ldd [%o0 + 0xc0], %f8
  549. ldd [%o0 + 0xc8], %f10
  550. ldd [%o0 + 0xb8], %f12
  551. ldd [%o0 + 0xb0], %f14
  552. ldd [%o0 + 0xa8], %f16
  553. ldd [%o0 + 0xa0], %f18
  554. fxor %f8, %f4, %f4
  555. fxor %f10, %f6, %f6
  556. ldd [%o0 + 0x98], %f20
  557. ldd [%o0 + 0x90], %f22
  558. ldd [%o0 + 0x88], %f24
  559. ldd [%o0 + 0x80], %f26
  560. DECRYPT_TWO_ROUNDS(12, 4, 6, 0, 2)
  561. ldd [%o0 + 0x78], %f28
  562. ldd [%o0 + 0x70], %f30
  563. ldd [%o0 + 0x68], %f32
  564. ldd [%o0 + 0x60], %f34
  565. ldd [%o0 + 0x58], %f36
  566. ldd [%o0 + 0x50], %f38
  567. ldd [%o0 + 0x48], %f40
  568. ldd [%o0 + 0x40], %f42
  569. ldd [%o0 + 0x38], %f44
  570. ldd [%o0 + 0x30], %f46
  571. ldd [%o0 + 0x28], %f48
  572. ldd [%o0 + 0x20], %f50
  573. ldd [%o0 + 0x18], %f52
  574. ldd [%o0 + 0x10], %f54
  575. ldd [%o0 + 0x08], %f56
  576. ldd [%o0 + 0x00], %f58
  577. DECRYPT_128(20, 4, 6, 0, 2)
  578. st %f4, [%o2 + 0x00]
  579. st %f5, [%o2 + 0x04]
  580. st %f6, [%o2 + 0x08]
  581. st %f7, [%o2 + 0x0c]
  582. retl
  583. VISExit
  584. ENDPROC(aes_sparc64_decrypt_192)
  585. .align 32
  586. ENTRY(aes_sparc64_decrypt_256)
  587. /* %o0=key, %o1=input, %o2=output */
  588. VISEntry
  589. ld [%o1 + 0x00], %f4
  590. ld [%o1 + 0x04], %f5
  591. ld [%o1 + 0x08], %f6
  592. ld [%o1 + 0x0c], %f7
  593. ldd [%o0 + 0xe0], %f8
  594. ldd [%o0 + 0xe8], %f10
  595. ldd [%o0 + 0xd8], %f12
  596. ldd [%o0 + 0xd0], %f14
  597. ldd [%o0 + 0xc8], %f16
  598. fxor %f8, %f4, %f4
  599. ldd [%o0 + 0xc0], %f18
  600. fxor %f10, %f6, %f6
  601. ldd [%o0 + 0xb8], %f20
  602. AES_DROUND23(12, 4, 6, 2)
  603. ldd [%o0 + 0xb0], %f22
  604. AES_DROUND01(14, 4, 6, 0)
  605. ldd [%o0 + 0xa8], %f24
  606. AES_DROUND23(16, 0, 2, 6)
  607. ldd [%o0 + 0xa0], %f26
  608. AES_DROUND01(18, 0, 2, 4)
  609. ldd [%o0 + 0x98], %f12
  610. AES_DROUND23(20, 4, 6, 2)
  611. ldd [%o0 + 0x90], %f14
  612. AES_DROUND01(22, 4, 6, 0)
  613. ldd [%o0 + 0x88], %f16
  614. AES_DROUND23(24, 0, 2, 6)
  615. ldd [%o0 + 0x80], %f18
  616. AES_DROUND01(26, 0, 2, 4)
  617. ldd [%o0 + 0x78], %f20
  618. AES_DROUND23(12, 4, 6, 2)
  619. ldd [%o0 + 0x70], %f22
  620. AES_DROUND01(14, 4, 6, 0)
  621. ldd [%o0 + 0x68], %f24
  622. AES_DROUND23(16, 0, 2, 6)
  623. ldd [%o0 + 0x60], %f26
  624. AES_DROUND01(18, 0, 2, 4)
  625. ldd [%o0 + 0x58], %f28
  626. AES_DROUND23(20, 4, 6, 2)
  627. ldd [%o0 + 0x50], %f30
  628. AES_DROUND01(22, 4, 6, 0)
  629. ldd [%o0 + 0x48], %f32
  630. AES_DROUND23(24, 0, 2, 6)
  631. ldd [%o0 + 0x40], %f34
  632. AES_DROUND01(26, 0, 2, 4)
  633. ldd [%o0 + 0x38], %f36
  634. AES_DROUND23(28, 4, 6, 2)
  635. ldd [%o0 + 0x30], %f38
  636. AES_DROUND01(30, 4, 6, 0)
  637. ldd [%o0 + 0x28], %f40
  638. AES_DROUND23(32, 0, 2, 6)
  639. ldd [%o0 + 0x20], %f42
  640. AES_DROUND01(34, 0, 2, 4)
  641. ldd [%o0 + 0x18], %f44
  642. AES_DROUND23(36, 4, 6, 2)
  643. ldd [%o0 + 0x10], %f46
  644. AES_DROUND01(38, 4, 6, 0)
  645. ldd [%o0 + 0x08], %f48
  646. AES_DROUND23(40, 0, 2, 6)
  647. ldd [%o0 + 0x00], %f50
  648. AES_DROUND01(42, 0, 2, 4)
  649. AES_DROUND23(44, 4, 6, 2)
  650. AES_DROUND01(46, 4, 6, 0)
  651. AES_DROUND23_L(48, 0, 2, 6)
  652. AES_DROUND01_L(50, 0, 2, 4)
  653. st %f4, [%o2 + 0x00]
  654. st %f5, [%o2 + 0x04]
  655. st %f6, [%o2 + 0x08]
  656. st %f7, [%o2 + 0x0c]
  657. retl
  658. VISExit
  659. ENDPROC(aes_sparc64_decrypt_256)
  660. .align 32
  661. ENTRY(aes_sparc64_load_encrypt_keys_128)
  662. /* %o0=key */
  663. VISEntry
  664. ldd [%o0 + 0x10], %f8
  665. ldd [%o0 + 0x18], %f10
  666. ldd [%o0 + 0x20], %f12
  667. ldd [%o0 + 0x28], %f14
  668. ldd [%o0 + 0x30], %f16
  669. ldd [%o0 + 0x38], %f18
  670. ldd [%o0 + 0x40], %f20
  671. ldd [%o0 + 0x48], %f22
  672. ldd [%o0 + 0x50], %f24
  673. ldd [%o0 + 0x58], %f26
  674. ldd [%o0 + 0x60], %f28
  675. ldd [%o0 + 0x68], %f30
  676. ldd [%o0 + 0x70], %f32
  677. ldd [%o0 + 0x78], %f34
  678. ldd [%o0 + 0x80], %f36
  679. ldd [%o0 + 0x88], %f38
  680. ldd [%o0 + 0x90], %f40
  681. ldd [%o0 + 0x98], %f42
  682. ldd [%o0 + 0xa0], %f44
  683. retl
  684. ldd [%o0 + 0xa8], %f46
  685. ENDPROC(aes_sparc64_load_encrypt_keys_128)
  686. .align 32
  687. ENTRY(aes_sparc64_load_encrypt_keys_192)
  688. /* %o0=key */
  689. VISEntry
  690. ldd [%o0 + 0x10], %f8
  691. ldd [%o0 + 0x18], %f10
  692. ldd [%o0 + 0x20], %f12
  693. ldd [%o0 + 0x28], %f14
  694. ldd [%o0 + 0x30], %f16
  695. ldd [%o0 + 0x38], %f18
  696. ldd [%o0 + 0x40], %f20
  697. ldd [%o0 + 0x48], %f22
  698. ldd [%o0 + 0x50], %f24
  699. ldd [%o0 + 0x58], %f26
  700. ldd [%o0 + 0x60], %f28
  701. ldd [%o0 + 0x68], %f30
  702. ldd [%o0 + 0x70], %f32
  703. ldd [%o0 + 0x78], %f34
  704. ldd [%o0 + 0x80], %f36
  705. ldd [%o0 + 0x88], %f38
  706. ldd [%o0 + 0x90], %f40
  707. ldd [%o0 + 0x98], %f42
  708. ldd [%o0 + 0xa0], %f44
  709. ldd [%o0 + 0xa8], %f46
  710. ldd [%o0 + 0xb0], %f48
  711. ldd [%o0 + 0xb8], %f50
  712. ldd [%o0 + 0xc0], %f52
  713. retl
  714. ldd [%o0 + 0xc8], %f54
  715. ENDPROC(aes_sparc64_load_encrypt_keys_192)
  716. .align 32
  717. ENTRY(aes_sparc64_load_encrypt_keys_256)
  718. /* %o0=key */
  719. VISEntry
  720. ldd [%o0 + 0x10], %f8
  721. ldd [%o0 + 0x18], %f10
  722. ldd [%o0 + 0x20], %f12
  723. ldd [%o0 + 0x28], %f14
  724. ldd [%o0 + 0x30], %f16
  725. ldd [%o0 + 0x38], %f18
  726. ldd [%o0 + 0x40], %f20
  727. ldd [%o0 + 0x48], %f22
  728. ldd [%o0 + 0x50], %f24
  729. ldd [%o0 + 0x58], %f26
  730. ldd [%o0 + 0x60], %f28
  731. ldd [%o0 + 0x68], %f30
  732. ldd [%o0 + 0x70], %f32
  733. ldd [%o0 + 0x78], %f34
  734. ldd [%o0 + 0x80], %f36
  735. ldd [%o0 + 0x88], %f38
  736. ldd [%o0 + 0x90], %f40
  737. ldd [%o0 + 0x98], %f42
  738. ldd [%o0 + 0xa0], %f44
  739. ldd [%o0 + 0xa8], %f46
  740. ldd [%o0 + 0xb0], %f48
  741. ldd [%o0 + 0xb8], %f50
  742. ldd [%o0 + 0xc0], %f52
  743. ldd [%o0 + 0xc8], %f54
  744. ldd [%o0 + 0xd0], %f56
  745. ldd [%o0 + 0xd8], %f58
  746. ldd [%o0 + 0xe0], %f60
  747. retl
  748. ldd [%o0 + 0xe8], %f62
  749. ENDPROC(aes_sparc64_load_encrypt_keys_256)
  750. .align 32
  751. ENTRY(aes_sparc64_load_decrypt_keys_128)
  752. /* %o0=key */
  753. VISEntry
  754. ldd [%o0 + 0x98], %f8
  755. ldd [%o0 + 0x90], %f10
  756. ldd [%o0 + 0x88], %f12
  757. ldd [%o0 + 0x80], %f14
  758. ldd [%o0 + 0x78], %f16
  759. ldd [%o0 + 0x70], %f18
  760. ldd [%o0 + 0x68], %f20
  761. ldd [%o0 + 0x60], %f22
  762. ldd [%o0 + 0x58], %f24
  763. ldd [%o0 + 0x50], %f26
  764. ldd [%o0 + 0x48], %f28
  765. ldd [%o0 + 0x40], %f30
  766. ldd [%o0 + 0x38], %f32
  767. ldd [%o0 + 0x30], %f34
  768. ldd [%o0 + 0x28], %f36
  769. ldd [%o0 + 0x20], %f38
  770. ldd [%o0 + 0x18], %f40
  771. ldd [%o0 + 0x10], %f42
  772. ldd [%o0 + 0x08], %f44
  773. retl
  774. ldd [%o0 + 0x00], %f46
  775. ENDPROC(aes_sparc64_load_decrypt_keys_128)
  776. .align 32
  777. ENTRY(aes_sparc64_load_decrypt_keys_192)
  778. /* %o0=key */
  779. VISEntry
  780. ldd [%o0 + 0xb8], %f8
  781. ldd [%o0 + 0xb0], %f10
  782. ldd [%o0 + 0xa8], %f12
  783. ldd [%o0 + 0xa0], %f14
  784. ldd [%o0 + 0x98], %f16
  785. ldd [%o0 + 0x90], %f18
  786. ldd [%o0 + 0x88], %f20
  787. ldd [%o0 + 0x80], %f22
  788. ldd [%o0 + 0x78], %f24
  789. ldd [%o0 + 0x70], %f26
  790. ldd [%o0 + 0x68], %f28
  791. ldd [%o0 + 0x60], %f30
  792. ldd [%o0 + 0x58], %f32
  793. ldd [%o0 + 0x50], %f34
  794. ldd [%o0 + 0x48], %f36
  795. ldd [%o0 + 0x40], %f38
  796. ldd [%o0 + 0x38], %f40
  797. ldd [%o0 + 0x30], %f42
  798. ldd [%o0 + 0x28], %f44
  799. ldd [%o0 + 0x20], %f46
  800. ldd [%o0 + 0x18], %f48
  801. ldd [%o0 + 0x10], %f50
  802. ldd [%o0 + 0x08], %f52
  803. retl
  804. ldd [%o0 + 0x00], %f54
  805. ENDPROC(aes_sparc64_load_decrypt_keys_192)
  806. .align 32
  807. ENTRY(aes_sparc64_load_decrypt_keys_256)
  808. /* %o0=key */
  809. VISEntry
  810. ldd [%o0 + 0xd8], %f8
  811. ldd [%o0 + 0xd0], %f10
  812. ldd [%o0 + 0xc8], %f12
  813. ldd [%o0 + 0xc0], %f14
  814. ldd [%o0 + 0xb8], %f16
  815. ldd [%o0 + 0xb0], %f18
  816. ldd [%o0 + 0xa8], %f20
  817. ldd [%o0 + 0xa0], %f22
  818. ldd [%o0 + 0x98], %f24
  819. ldd [%o0 + 0x90], %f26
  820. ldd [%o0 + 0x88], %f28
  821. ldd [%o0 + 0x80], %f30
  822. ldd [%o0 + 0x78], %f32
  823. ldd [%o0 + 0x70], %f34
  824. ldd [%o0 + 0x68], %f36
  825. ldd [%o0 + 0x60], %f38
  826. ldd [%o0 + 0x58], %f40
  827. ldd [%o0 + 0x50], %f42
  828. ldd [%o0 + 0x48], %f44
  829. ldd [%o0 + 0x40], %f46
  830. ldd [%o0 + 0x38], %f48
  831. ldd [%o0 + 0x30], %f50
  832. ldd [%o0 + 0x28], %f52
  833. ldd [%o0 + 0x20], %f54
  834. ldd [%o0 + 0x18], %f56
  835. ldd [%o0 + 0x10], %f58
  836. ldd [%o0 + 0x08], %f60
  837. retl
  838. ldd [%o0 + 0x00], %f62
  839. ENDPROC(aes_sparc64_load_decrypt_keys_256)
  840. .align 32
  841. ENTRY(aes_sparc64_ecb_encrypt_128)
  842. /* %o0=key, %o1=input, %o2=output, %o3=len */
  843. ldx [%o0 + 0x00], %g1
  844. subcc %o3, 0x10, %o3
  845. be 10f
  846. ldx [%o0 + 0x08], %g2
  847. 1: ldx [%o1 + 0x00], %g3
  848. ldx [%o1 + 0x08], %g7
  849. ldx [%o1 + 0x10], %o4
  850. ldx [%o1 + 0x18], %o5
  851. xor %g1, %g3, %g3
  852. xor %g2, %g7, %g7
  853. MOVXTOD_G3_F4
  854. MOVXTOD_G7_F6
  855. xor %g1, %o4, %g3
  856. xor %g2, %o5, %g7
  857. MOVXTOD_G3_F60
  858. MOVXTOD_G7_F62
  859. ENCRYPT_128_2(8, 4, 6, 60, 62, 0, 2, 56, 58)
  860. std %f4, [%o2 + 0x00]
  861. std %f6, [%o2 + 0x08]
  862. std %f60, [%o2 + 0x10]
  863. std %f62, [%o2 + 0x18]
  864. sub %o3, 0x20, %o3
  865. add %o1, 0x20, %o1
  866. brgz %o3, 1b
  867. add %o2, 0x20, %o2
  868. brlz,pt %o3, 11f
  869. nop
  870. 10: ldx [%o1 + 0x00], %g3
  871. ldx [%o1 + 0x08], %g7
  872. xor %g1, %g3, %g3
  873. xor %g2, %g7, %g7
  874. MOVXTOD_G3_F4
  875. MOVXTOD_G7_F6
  876. ENCRYPT_128(8, 4, 6, 0, 2)
  877. std %f4, [%o2 + 0x00]
  878. std %f6, [%o2 + 0x08]
  879. 11: retl
  880. nop
  881. ENDPROC(aes_sparc64_ecb_encrypt_128)
  882. .align 32
  883. ENTRY(aes_sparc64_ecb_encrypt_192)
  884. /* %o0=key, %o1=input, %o2=output, %o3=len */
  885. ldx [%o0 + 0x00], %g1
  886. subcc %o3, 0x10, %o3
  887. be 10f
  888. ldx [%o0 + 0x08], %g2
  889. 1: ldx [%o1 + 0x00], %g3
  890. ldx [%o1 + 0x08], %g7
  891. ldx [%o1 + 0x10], %o4
  892. ldx [%o1 + 0x18], %o5
  893. xor %g1, %g3, %g3
  894. xor %g2, %g7, %g7
  895. MOVXTOD_G3_F4
  896. MOVXTOD_G7_F6
  897. xor %g1, %o4, %g3
  898. xor %g2, %o5, %g7
  899. MOVXTOD_G3_F60
  900. MOVXTOD_G7_F62
  901. ENCRYPT_192_2(8, 4, 6, 60, 62, 0, 2, 56, 58)
  902. std %f4, [%o2 + 0x00]
  903. std %f6, [%o2 + 0x08]
  904. std %f60, [%o2 + 0x10]
  905. std %f62, [%o2 + 0x18]
  906. sub %o3, 0x20, %o3
  907. add %o1, 0x20, %o1
  908. brgz %o3, 1b
  909. add %o2, 0x20, %o2
  910. brlz,pt %o3, 11f
  911. nop
  912. 10: ldx [%o1 + 0x00], %g3
  913. ldx [%o1 + 0x08], %g7
  914. xor %g1, %g3, %g3
  915. xor %g2, %g7, %g7
  916. MOVXTOD_G3_F4
  917. MOVXTOD_G7_F6
  918. ENCRYPT_192(8, 4, 6, 0, 2)
  919. std %f4, [%o2 + 0x00]
  920. std %f6, [%o2 + 0x08]
  921. 11: retl
  922. nop
  923. ENDPROC(aes_sparc64_ecb_encrypt_192)
  924. .align 32
  925. ENTRY(aes_sparc64_ecb_encrypt_256)
  926. /* %o0=key, %o1=input, %o2=output, %o3=len */
  927. ldx [%o0 + 0x00], %g1
  928. subcc %o3, 0x10, %o3
  929. be 10f
  930. ldx [%o0 + 0x08], %g2
  931. 1: ldx [%o1 + 0x00], %g3
  932. ldx [%o1 + 0x08], %g7
  933. ldx [%o1 + 0x10], %o4
  934. ldx [%o1 + 0x18], %o5
  935. xor %g1, %g3, %g3
  936. xor %g2, %g7, %g7
  937. MOVXTOD_G3_F4
  938. MOVXTOD_G7_F6
  939. xor %g1, %o4, %g3
  940. xor %g2, %o5, %g7
  941. MOVXTOD_G3_F0
  942. MOVXTOD_G7_F2
  943. ENCRYPT_256_2(8, 4, 6, 0, 2)
  944. std %f4, [%o2 + 0x00]
  945. std %f6, [%o2 + 0x08]
  946. std %f0, [%o2 + 0x10]
  947. std %f2, [%o2 + 0x18]
  948. sub %o3, 0x20, %o3
  949. add %o1, 0x20, %o1
  950. brgz %o3, 1b
  951. add %o2, 0x20, %o2
  952. brlz,pt %o3, 11f
  953. nop
  954. 10: ldd [%o0 + 0xd0], %f56
  955. ldd [%o0 + 0xd8], %f58
  956. ldd [%o0 + 0xe0], %f60
  957. ldd [%o0 + 0xe8], %f62
  958. ldx [%o1 + 0x00], %g3
  959. ldx [%o1 + 0x08], %g7
  960. xor %g1, %g3, %g3
  961. xor %g2, %g7, %g7
  962. MOVXTOD_G3_F4
  963. MOVXTOD_G7_F6
  964. ENCRYPT_256(8, 4, 6, 0, 2)
  965. std %f4, [%o2 + 0x00]
  966. std %f6, [%o2 + 0x08]
  967. 11: retl
  968. nop
  969. ENDPROC(aes_sparc64_ecb_encrypt_256)
  970. .align 32
  971. ENTRY(aes_sparc64_ecb_decrypt_128)
  972. /* %o0=&key[key_len], %o1=input, %o2=output, %o3=len */
  973. ldx [%o0 - 0x10], %g1
  974. subcc %o3, 0x10, %o3
  975. be 10f
  976. ldx [%o0 - 0x08], %g2
  977. 1: ldx [%o1 + 0x00], %g3
  978. ldx [%o1 + 0x08], %g7
  979. ldx [%o1 + 0x10], %o4
  980. ldx [%o1 + 0x18], %o5
  981. xor %g1, %g3, %g3
  982. xor %g2, %g7, %g7
  983. MOVXTOD_G3_F4
  984. MOVXTOD_G7_F6
  985. xor %g1, %o4, %g3
  986. xor %g2, %o5, %g7
  987. MOVXTOD_G3_F60
  988. MOVXTOD_G7_F62
  989. DECRYPT_128_2(8, 4, 6, 60, 62, 0, 2, 56, 58)
  990. std %f4, [%o2 + 0x00]
  991. std %f6, [%o2 + 0x08]
  992. std %f60, [%o2 + 0x10]
  993. std %f62, [%o2 + 0x18]
  994. sub %o3, 0x20, %o3
  995. add %o1, 0x20, %o1
  996. brgz,pt %o3, 1b
  997. add %o2, 0x20, %o2
  998. brlz,pt %o3, 11f
  999. nop
  1000. 10: ldx [%o1 + 0x00], %g3
  1001. ldx [%o1 + 0x08], %g7
  1002. xor %g1, %g3, %g3
  1003. xor %g2, %g7, %g7
  1004. MOVXTOD_G3_F4
  1005. MOVXTOD_G7_F6
  1006. DECRYPT_128(8, 4, 6, 0, 2)
  1007. std %f4, [%o2 + 0x00]
  1008. std %f6, [%o2 + 0x08]
  1009. 11: retl
  1010. nop
  1011. ENDPROC(aes_sparc64_ecb_decrypt_128)
  1012. .align 32
  1013. ENTRY(aes_sparc64_ecb_decrypt_192)
  1014. /* %o0=&key[key_len], %o1=input, %o2=output, %o3=len */
  1015. ldx [%o0 - 0x10], %g1
  1016. subcc %o3, 0x10, %o3
  1017. be 10f
  1018. ldx [%o0 - 0x08], %g2
  1019. 1: ldx [%o1 + 0x00], %g3
  1020. ldx [%o1 + 0x08], %g7
  1021. ldx [%o1 + 0x10], %o4
  1022. ldx [%o1 + 0x18], %o5
  1023. xor %g1, %g3, %g3
  1024. xor %g2, %g7, %g7
  1025. MOVXTOD_G3_F4
  1026. MOVXTOD_G7_F6
  1027. xor %g1, %o4, %g3
  1028. xor %g2, %o5, %g7
  1029. MOVXTOD_G3_F60
  1030. MOVXTOD_G7_F62
  1031. DECRYPT_192_2(8, 4, 6, 60, 62, 0, 2, 56, 58)
  1032. std %f4, [%o2 + 0x00]
  1033. std %f6, [%o2 + 0x08]
  1034. std %f60, [%o2 + 0x10]
  1035. std %f62, [%o2 + 0x18]
  1036. sub %o3, 0x20, %o3
  1037. add %o1, 0x20, %o1
  1038. brgz,pt %o3, 1b
  1039. add %o2, 0x20, %o2
  1040. brlz,pt %o3, 11f
  1041. nop
  1042. 10: ldx [%o1 + 0x00], %g3
  1043. ldx [%o1 + 0x08], %g7
  1044. xor %g1, %g3, %g3
  1045. xor %g2, %g7, %g7
  1046. MOVXTOD_G3_F4
  1047. MOVXTOD_G7_F6
  1048. DECRYPT_192(8, 4, 6, 0, 2)
  1049. std %f4, [%o2 + 0x00]
  1050. std %f6, [%o2 + 0x08]
  1051. 11: retl
  1052. nop
  1053. ENDPROC(aes_sparc64_ecb_decrypt_192)
  1054. .align 32
  1055. ENTRY(aes_sparc64_ecb_decrypt_256)
  1056. /* %o0=&key[key_len], %o1=input, %o2=output, %o3=len */
  1057. ldx [%o0 - 0x10], %g1
  1058. subcc %o3, 0x10, %o3
  1059. ldx [%o0 - 0x08], %g2
  1060. be 10f
  1061. sub %o0, 0xf0, %o0
  1062. 1: ldx [%o1 + 0x00], %g3
  1063. ldx [%o1 + 0x08], %g7
  1064. ldx [%o1 + 0x10], %o4
  1065. ldx [%o1 + 0x18], %o5
  1066. xor %g1, %g3, %g3
  1067. xor %g2, %g7, %g7
  1068. MOVXTOD_G3_F4
  1069. MOVXTOD_G7_F6
  1070. xor %g1, %o4, %g3
  1071. xor %g2, %o5, %g7
  1072. MOVXTOD_G3_F0
  1073. MOVXTOD_G7_F2
  1074. DECRYPT_256_2(8, 4, 6, 0, 2)
  1075. std %f4, [%o2 + 0x00]
  1076. std %f6, [%o2 + 0x08]
  1077. std %f0, [%o2 + 0x10]
  1078. std %f2, [%o2 + 0x18]
  1079. sub %o3, 0x20, %o3
  1080. add %o1, 0x20, %o1
  1081. brgz,pt %o3, 1b
  1082. add %o2, 0x20, %o2
  1083. brlz,pt %o3, 11f
  1084. nop
  1085. 10: ldd [%o0 + 0x18], %f56
  1086. ldd [%o0 + 0x10], %f58
  1087. ldd [%o0 + 0x08], %f60
  1088. ldd [%o0 + 0x00], %f62
  1089. ldx [%o1 + 0x00], %g3
  1090. ldx [%o1 + 0x08], %g7
  1091. xor %g1, %g3, %g3
  1092. xor %g2, %g7, %g7
  1093. MOVXTOD_G3_F4
  1094. MOVXTOD_G7_F6
  1095. DECRYPT_256(8, 4, 6, 0, 2)
  1096. std %f4, [%o2 + 0x00]
  1097. std %f6, [%o2 + 0x08]
  1098. 11: retl
  1099. nop
  1100. ENDPROC(aes_sparc64_ecb_decrypt_256)
  1101. .align 32
  1102. ENTRY(aes_sparc64_cbc_encrypt_128)
  1103. /* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */
  1104. ldd [%o4 + 0x00], %f4
  1105. ldd [%o4 + 0x08], %f6
  1106. ldx [%o0 + 0x00], %g1
  1107. ldx [%o0 + 0x08], %g2
  1108. 1: ldx [%o1 + 0x00], %g3
  1109. ldx [%o1 + 0x08], %g7
  1110. add %o1, 0x10, %o1
  1111. xor %g1, %g3, %g3
  1112. xor %g2, %g7, %g7
  1113. MOVXTOD_G3_F0
  1114. MOVXTOD_G7_F2
  1115. fxor %f4, %f0, %f4
  1116. fxor %f6, %f2, %f6
  1117. ENCRYPT_128(8, 4, 6, 0, 2)
  1118. std %f4, [%o2 + 0x00]
  1119. std %f6, [%o2 + 0x08]
  1120. subcc %o3, 0x10, %o3
  1121. bne,pt %xcc, 1b
  1122. add %o2, 0x10, %o2
  1123. std %f4, [%o4 + 0x00]
  1124. std %f6, [%o4 + 0x08]
  1125. retl
  1126. nop
  1127. ENDPROC(aes_sparc64_cbc_encrypt_128)
  1128. .align 32
  1129. ENTRY(aes_sparc64_cbc_encrypt_192)
  1130. /* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */
  1131. ldd [%o4 + 0x00], %f4
  1132. ldd [%o4 + 0x08], %f6
  1133. ldx [%o0 + 0x00], %g1
  1134. ldx [%o0 + 0x08], %g2
  1135. 1: ldx [%o1 + 0x00], %g3
  1136. ldx [%o1 + 0x08], %g7
  1137. add %o1, 0x10, %o1
  1138. xor %g1, %g3, %g3
  1139. xor %g2, %g7, %g7
  1140. MOVXTOD_G3_F0
  1141. MOVXTOD_G7_F2
  1142. fxor %f4, %f0, %f4
  1143. fxor %f6, %f2, %f6
  1144. ENCRYPT_192(8, 4, 6, 0, 2)
  1145. std %f4, [%o2 + 0x00]
  1146. std %f6, [%o2 + 0x08]
  1147. subcc %o3, 0x10, %o3
  1148. bne,pt %xcc, 1b
  1149. add %o2, 0x10, %o2
  1150. std %f4, [%o4 + 0x00]
  1151. std %f6, [%o4 + 0x08]
  1152. retl
  1153. nop
  1154. ENDPROC(aes_sparc64_cbc_encrypt_192)
  1155. .align 32
  1156. ENTRY(aes_sparc64_cbc_encrypt_256)
  1157. /* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */
  1158. ldd [%o4 + 0x00], %f4
  1159. ldd [%o4 + 0x08], %f6
  1160. ldx [%o0 + 0x00], %g1
  1161. ldx [%o0 + 0x08], %g2
  1162. 1: ldx [%o1 + 0x00], %g3
  1163. ldx [%o1 + 0x08], %g7
  1164. add %o1, 0x10, %o1
  1165. xor %g1, %g3, %g3
  1166. xor %g2, %g7, %g7
  1167. MOVXTOD_G3_F0
  1168. MOVXTOD_G7_F2
  1169. fxor %f4, %f0, %f4
  1170. fxor %f6, %f2, %f6
  1171. ENCRYPT_256(8, 4, 6, 0, 2)
  1172. std %f4, [%o2 + 0x00]
  1173. std %f6, [%o2 + 0x08]
  1174. subcc %o3, 0x10, %o3
  1175. bne,pt %xcc, 1b
  1176. add %o2, 0x10, %o2
  1177. std %f4, [%o4 + 0x00]
  1178. std %f6, [%o4 + 0x08]
  1179. retl
  1180. nop
  1181. ENDPROC(aes_sparc64_cbc_encrypt_256)
  1182. .align 32
  1183. ENTRY(aes_sparc64_cbc_decrypt_128)
  1184. /* %o0=&key[key_len], %o1=input, %o2=output, %o3=len, %o4=iv */
  1185. ldx [%o0 - 0x10], %g1
  1186. ldx [%o0 - 0x08], %g2
  1187. ldx [%o4 + 0x00], %o0
  1188. ldx [%o4 + 0x08], %o5
  1189. 1: ldx [%o1 + 0x00], %g3
  1190. ldx [%o1 + 0x08], %g7
  1191. add %o1, 0x10, %o1
  1192. xor %g1, %g3, %g3
  1193. xor %g2, %g7, %g7
  1194. MOVXTOD_G3_F4
  1195. MOVXTOD_G7_F6
  1196. DECRYPT_128(8, 4, 6, 0, 2)
  1197. MOVXTOD_O0_F0
  1198. MOVXTOD_O5_F2
  1199. xor %g1, %g3, %o0
  1200. xor %g2, %g7, %o5
  1201. fxor %f4, %f0, %f4
  1202. fxor %f6, %f2, %f6
  1203. std %f4, [%o2 + 0x00]
  1204. std %f6, [%o2 + 0x08]
  1205. subcc %o3, 0x10, %o3
  1206. bne,pt %xcc, 1b
  1207. add %o2, 0x10, %o2
  1208. stx %o0, [%o4 + 0x00]
  1209. stx %o5, [%o4 + 0x08]
  1210. retl
  1211. nop
  1212. ENDPROC(aes_sparc64_cbc_decrypt_128)
  1213. .align 32
  1214. ENTRY(aes_sparc64_cbc_decrypt_192)
  1215. /* %o0=&key[key_len], %o1=input, %o2=output, %o3=len, %o4=iv */
  1216. ldx [%o0 - 0x10], %g1
  1217. ldx [%o0 - 0x08], %g2
  1218. ldx [%o4 + 0x00], %o0
  1219. ldx [%o4 + 0x08], %o5
  1220. 1: ldx [%o1 + 0x00], %g3
  1221. ldx [%o1 + 0x08], %g7
  1222. add %o1, 0x10, %o1
  1223. xor %g1, %g3, %g3
  1224. xor %g2, %g7, %g7
  1225. MOVXTOD_G3_F4
  1226. MOVXTOD_G7_F6
  1227. DECRYPT_192(8, 4, 6, 0, 2)
  1228. MOVXTOD_O0_F0
  1229. MOVXTOD_O5_F2
  1230. xor %g1, %g3, %o0
  1231. xor %g2, %g7, %o5
  1232. fxor %f4, %f0, %f4
  1233. fxor %f6, %f2, %f6
  1234. std %f4, [%o2 + 0x00]
  1235. std %f6, [%o2 + 0x08]
  1236. subcc %o3, 0x10, %o3
  1237. bne,pt %xcc, 1b
  1238. add %o2, 0x10, %o2
  1239. stx %o0, [%o4 + 0x00]
  1240. stx %o5, [%o4 + 0x08]
  1241. retl
  1242. nop
  1243. ENDPROC(aes_sparc64_cbc_decrypt_192)
  1244. .align 32
  1245. ENTRY(aes_sparc64_cbc_decrypt_256)
  1246. /* %o0=&key[key_len], %o1=input, %o2=output, %o3=len, %o4=iv */
  1247. ldx [%o0 - 0x10], %g1
  1248. ldx [%o0 - 0x08], %g2
  1249. ldx [%o4 + 0x00], %o0
  1250. ldx [%o4 + 0x08], %o5
  1251. 1: ldx [%o1 + 0x00], %g3
  1252. ldx [%o1 + 0x08], %g7
  1253. add %o1, 0x10, %o1
  1254. xor %g1, %g3, %g3
  1255. xor %g2, %g7, %g7
  1256. MOVXTOD_G3_F4
  1257. MOVXTOD_G7_F6
  1258. DECRYPT_256(8, 4, 6, 0, 2)
  1259. MOVXTOD_O0_F0
  1260. MOVXTOD_O5_F2
  1261. xor %g1, %g3, %o0
  1262. xor %g2, %g7, %o5
  1263. fxor %f4, %f0, %f4
  1264. fxor %f6, %f2, %f6
  1265. std %f4, [%o2 + 0x00]
  1266. std %f6, [%o2 + 0x08]
  1267. subcc %o3, 0x10, %o3
  1268. bne,pt %xcc, 1b
  1269. add %o2, 0x10, %o2
  1270. stx %o0, [%o4 + 0x00]
  1271. stx %o5, [%o4 + 0x08]
  1272. retl
  1273. nop
  1274. ENDPROC(aes_sparc64_cbc_decrypt_256)
  1275. .align 32
  1276. ENTRY(aes_sparc64_ctr_crypt_128)
  1277. /* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */
  1278. ldx [%o4 + 0x00], %g3
  1279. ldx [%o4 + 0x08], %g7
  1280. subcc %o3, 0x10, %o3
  1281. ldx [%o0 + 0x00], %g1
  1282. be 10f
  1283. ldx [%o0 + 0x08], %g2
  1284. 1: xor %g1, %g3, %o5
  1285. MOVXTOD_O5_F0
  1286. xor %g2, %g7, %o5
  1287. MOVXTOD_O5_F2
  1288. add %g7, 1, %g7
  1289. add %g3, 1, %o5
  1290. movrz %g7, %o5, %g3
  1291. xor %g1, %g3, %o5
  1292. MOVXTOD_O5_F4
  1293. xor %g2, %g7, %o5
  1294. MOVXTOD_O5_F6
  1295. add %g7, 1, %g7
  1296. add %g3, 1, %o5
  1297. movrz %g7, %o5, %g3
  1298. ENCRYPT_128_2(8, 0, 2, 4, 6, 56, 58, 60, 62)
  1299. ldd [%o1 + 0x00], %f56
  1300. ldd [%o1 + 0x08], %f58
  1301. ldd [%o1 + 0x10], %f60
  1302. ldd [%o1 + 0x18], %f62
  1303. fxor %f56, %f0, %f56
  1304. fxor %f58, %f2, %f58
  1305. fxor %f60, %f4, %f60
  1306. fxor %f62, %f6, %f62
  1307. std %f56, [%o2 + 0x00]
  1308. std %f58, [%o2 + 0x08]
  1309. std %f60, [%o2 + 0x10]
  1310. std %f62, [%o2 + 0x18]
  1311. subcc %o3, 0x20, %o3
  1312. add %o1, 0x20, %o1
  1313. brgz %o3, 1b
  1314. add %o2, 0x20, %o2
  1315. brlz,pt %o3, 11f
  1316. nop
  1317. 10: xor %g1, %g3, %o5
  1318. MOVXTOD_O5_F0
  1319. xor %g2, %g7, %o5
  1320. MOVXTOD_O5_F2
  1321. add %g7, 1, %g7
  1322. add %g3, 1, %o5
  1323. movrz %g7, %o5, %g3
  1324. ENCRYPT_128(8, 0, 2, 4, 6)
  1325. ldd [%o1 + 0x00], %f4
  1326. ldd [%o1 + 0x08], %f6
  1327. fxor %f4, %f0, %f4
  1328. fxor %f6, %f2, %f6
  1329. std %f4, [%o2 + 0x00]
  1330. std %f6, [%o2 + 0x08]
  1331. 11: stx %g3, [%o4 + 0x00]
  1332. retl
  1333. stx %g7, [%o4 + 0x08]
  1334. ENDPROC(aes_sparc64_ctr_crypt_128)
  1335. .align 32
  1336. ENTRY(aes_sparc64_ctr_crypt_192)
  1337. /* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */
  1338. ldx [%o4 + 0x00], %g3
  1339. ldx [%o4 + 0x08], %g7
  1340. subcc %o3, 0x10, %o3
  1341. ldx [%o0 + 0x00], %g1
  1342. be 10f
  1343. ldx [%o0 + 0x08], %g2
  1344. 1: xor %g1, %g3, %o5
  1345. MOVXTOD_O5_F0
  1346. xor %g2, %g7, %o5
  1347. MOVXTOD_O5_F2
  1348. add %g7, 1, %g7
  1349. add %g3, 1, %o5
  1350. movrz %g7, %o5, %g3
  1351. xor %g1, %g3, %o5
  1352. MOVXTOD_O5_F4
  1353. xor %g2, %g7, %o5
  1354. MOVXTOD_O5_F6
  1355. add %g7, 1, %g7
  1356. add %g3, 1, %o5
  1357. movrz %g7, %o5, %g3
  1358. ENCRYPT_192_2(8, 0, 2, 4, 6, 56, 58, 60, 62)
  1359. ldd [%o1 + 0x00], %f56
  1360. ldd [%o1 + 0x08], %f58
  1361. ldd [%o1 + 0x10], %f60
  1362. ldd [%o1 + 0x18], %f62
  1363. fxor %f56, %f0, %f56
  1364. fxor %f58, %f2, %f58
  1365. fxor %f60, %f4, %f60
  1366. fxor %f62, %f6, %f62
  1367. std %f56, [%o2 + 0x00]
  1368. std %f58, [%o2 + 0x08]
  1369. std %f60, [%o2 + 0x10]
  1370. std %f62, [%o2 + 0x18]
  1371. subcc %o3, 0x20, %o3
  1372. add %o1, 0x20, %o1
  1373. brgz %o3, 1b
  1374. add %o2, 0x20, %o2
  1375. brlz,pt %o3, 11f
  1376. nop
  1377. 10: xor %g1, %g3, %o5
  1378. MOVXTOD_O5_F0
  1379. xor %g2, %g7, %o5
  1380. MOVXTOD_O5_F2
  1381. add %g7, 1, %g7
  1382. add %g3, 1, %o5
  1383. movrz %g7, %o5, %g3
  1384. ENCRYPT_192(8, 0, 2, 4, 6)
  1385. ldd [%o1 + 0x00], %f4
  1386. ldd [%o1 + 0x08], %f6
  1387. fxor %f4, %f0, %f4
  1388. fxor %f6, %f2, %f6
  1389. std %f4, [%o2 + 0x00]
  1390. std %f6, [%o2 + 0x08]
  1391. 11: stx %g3, [%o4 + 0x00]
  1392. retl
  1393. stx %g7, [%o4 + 0x08]
  1394. ENDPROC(aes_sparc64_ctr_crypt_192)
  1395. .align 32
  1396. ENTRY(aes_sparc64_ctr_crypt_256)
  1397. /* %o0=key, %o1=input, %o2=output, %o3=len, %o4=IV */
  1398. ldx [%o4 + 0x00], %g3
  1399. ldx [%o4 + 0x08], %g7
  1400. subcc %o3, 0x10, %o3
  1401. ldx [%o0 + 0x00], %g1
  1402. be 10f
  1403. ldx [%o0 + 0x08], %g2
  1404. 1: xor %g1, %g3, %o5
  1405. MOVXTOD_O5_F0
  1406. xor %g2, %g7, %o5
  1407. MOVXTOD_O5_F2
  1408. add %g7, 1, %g7
  1409. add %g3, 1, %o5
  1410. movrz %g7, %o5, %g3
  1411. xor %g1, %g3, %o5
  1412. MOVXTOD_O5_F4
  1413. xor %g2, %g7, %o5
  1414. MOVXTOD_O5_F6
  1415. add %g7, 1, %g7
  1416. add %g3, 1, %o5
  1417. movrz %g7, %o5, %g3
  1418. ENCRYPT_256_2(8, 0, 2, 4, 6)
  1419. ldd [%o1 + 0x00], %f56
  1420. ldd [%o1 + 0x08], %f58
  1421. ldd [%o1 + 0x10], %f60
  1422. ldd [%o1 + 0x18], %f62
  1423. fxor %f56, %f0, %f56
  1424. fxor %f58, %f2, %f58
  1425. fxor %f60, %f4, %f60
  1426. fxor %f62, %f6, %f62
  1427. std %f56, [%o2 + 0x00]
  1428. std %f58, [%o2 + 0x08]
  1429. std %f60, [%o2 + 0x10]
  1430. std %f62, [%o2 + 0x18]
  1431. subcc %o3, 0x20, %o3
  1432. add %o1, 0x20, %o1
  1433. brgz %o3, 1b
  1434. add %o2, 0x20, %o2
  1435. brlz,pt %o3, 11f
  1436. nop
  1437. 10: ldd [%o0 + 0xd0], %f56
  1438. ldd [%o0 + 0xd8], %f58
  1439. ldd [%o0 + 0xe0], %f60
  1440. ldd [%o0 + 0xe8], %f62
  1441. xor %g1, %g3, %o5
  1442. MOVXTOD_O5_F0
  1443. xor %g2, %g7, %o5
  1444. MOVXTOD_O5_F2
  1445. add %g7, 1, %g7
  1446. add %g3, 1, %o5
  1447. movrz %g7, %o5, %g3
  1448. ENCRYPT_256(8, 0, 2, 4, 6)
  1449. ldd [%o1 + 0x00], %f4
  1450. ldd [%o1 + 0x08], %f6
  1451. fxor %f4, %f0, %f4
  1452. fxor %f6, %f2, %f6
  1453. std %f4, [%o2 + 0x00]
  1454. std %f6, [%o2 + 0x08]
  1455. 11: stx %g3, [%o4 + 0x00]
  1456. retl
  1457. stx %g7, [%o4 + 0x08]
  1458. ENDPROC(aes_sparc64_ctr_crypt_256)