aes_asm.S 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544
  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)