aesni-x86_64.asm 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806
  1. ; This file is generated from a similarly-named Perl script in the BoringSSL
  2. ; source tree. Do not edit by hand.
  3. default rel
  4. %define XMMWORD
  5. %define YMMWORD
  6. %define ZMMWORD
  7. %ifdef BORINGSSL_PREFIX
  8. %include "boringssl_prefix_symbols_nasm.inc"
  9. %endif
  10. section .text code align=64
  11. EXTERN OPENSSL_ia32cap_P
  12. global aes_hw_encrypt
  13. ALIGN 16
  14. aes_hw_encrypt:
  15. %ifdef BORINGSSL_DISPATCH_TEST
  16. EXTERN BORINGSSL_function_hit
  17. mov BYTE[((BORINGSSL_function_hit+1))],1
  18. %endif
  19. movups xmm2,XMMWORD[rcx]
  20. mov eax,DWORD[240+r8]
  21. movups xmm0,XMMWORD[r8]
  22. movups xmm1,XMMWORD[16+r8]
  23. lea r8,[32+r8]
  24. xorps xmm2,xmm0
  25. $L$oop_enc1_1:
  26. DB 102,15,56,220,209
  27. dec eax
  28. movups xmm1,XMMWORD[r8]
  29. lea r8,[16+r8]
  30. jnz NEAR $L$oop_enc1_1
  31. DB 102,15,56,221,209
  32. pxor xmm0,xmm0
  33. pxor xmm1,xmm1
  34. movups XMMWORD[rdx],xmm2
  35. pxor xmm2,xmm2
  36. DB 0F3h,0C3h ;repret
  37. global aes_hw_decrypt
  38. ALIGN 16
  39. aes_hw_decrypt:
  40. movups xmm2,XMMWORD[rcx]
  41. mov eax,DWORD[240+r8]
  42. movups xmm0,XMMWORD[r8]
  43. movups xmm1,XMMWORD[16+r8]
  44. lea r8,[32+r8]
  45. xorps xmm2,xmm0
  46. $L$oop_dec1_2:
  47. DB 102,15,56,222,209
  48. dec eax
  49. movups xmm1,XMMWORD[r8]
  50. lea r8,[16+r8]
  51. jnz NEAR $L$oop_dec1_2
  52. DB 102,15,56,223,209
  53. pxor xmm0,xmm0
  54. pxor xmm1,xmm1
  55. movups XMMWORD[rdx],xmm2
  56. pxor xmm2,xmm2
  57. DB 0F3h,0C3h ;repret
  58. ALIGN 16
  59. _aesni_encrypt2:
  60. movups xmm0,XMMWORD[rcx]
  61. shl eax,4
  62. movups xmm1,XMMWORD[16+rcx]
  63. xorps xmm2,xmm0
  64. xorps xmm3,xmm0
  65. movups xmm0,XMMWORD[32+rcx]
  66. lea rcx,[32+rax*1+rcx]
  67. neg rax
  68. add rax,16
  69. $L$enc_loop2:
  70. DB 102,15,56,220,209
  71. DB 102,15,56,220,217
  72. movups xmm1,XMMWORD[rax*1+rcx]
  73. add rax,32
  74. DB 102,15,56,220,208
  75. DB 102,15,56,220,216
  76. movups xmm0,XMMWORD[((-16))+rax*1+rcx]
  77. jnz NEAR $L$enc_loop2
  78. DB 102,15,56,220,209
  79. DB 102,15,56,220,217
  80. DB 102,15,56,221,208
  81. DB 102,15,56,221,216
  82. DB 0F3h,0C3h ;repret
  83. ALIGN 16
  84. _aesni_decrypt2:
  85. movups xmm0,XMMWORD[rcx]
  86. shl eax,4
  87. movups xmm1,XMMWORD[16+rcx]
  88. xorps xmm2,xmm0
  89. xorps xmm3,xmm0
  90. movups xmm0,XMMWORD[32+rcx]
  91. lea rcx,[32+rax*1+rcx]
  92. neg rax
  93. add rax,16
  94. $L$dec_loop2:
  95. DB 102,15,56,222,209
  96. DB 102,15,56,222,217
  97. movups xmm1,XMMWORD[rax*1+rcx]
  98. add rax,32
  99. DB 102,15,56,222,208
  100. DB 102,15,56,222,216
  101. movups xmm0,XMMWORD[((-16))+rax*1+rcx]
  102. jnz NEAR $L$dec_loop2
  103. DB 102,15,56,222,209
  104. DB 102,15,56,222,217
  105. DB 102,15,56,223,208
  106. DB 102,15,56,223,216
  107. DB 0F3h,0C3h ;repret
  108. ALIGN 16
  109. _aesni_encrypt3:
  110. movups xmm0,XMMWORD[rcx]
  111. shl eax,4
  112. movups xmm1,XMMWORD[16+rcx]
  113. xorps xmm2,xmm0
  114. xorps xmm3,xmm0
  115. xorps xmm4,xmm0
  116. movups xmm0,XMMWORD[32+rcx]
  117. lea rcx,[32+rax*1+rcx]
  118. neg rax
  119. add rax,16
  120. $L$enc_loop3:
  121. DB 102,15,56,220,209
  122. DB 102,15,56,220,217
  123. DB 102,15,56,220,225
  124. movups xmm1,XMMWORD[rax*1+rcx]
  125. add rax,32
  126. DB 102,15,56,220,208
  127. DB 102,15,56,220,216
  128. DB 102,15,56,220,224
  129. movups xmm0,XMMWORD[((-16))+rax*1+rcx]
  130. jnz NEAR $L$enc_loop3
  131. DB 102,15,56,220,209
  132. DB 102,15,56,220,217
  133. DB 102,15,56,220,225
  134. DB 102,15,56,221,208
  135. DB 102,15,56,221,216
  136. DB 102,15,56,221,224
  137. DB 0F3h,0C3h ;repret
  138. ALIGN 16
  139. _aesni_decrypt3:
  140. movups xmm0,XMMWORD[rcx]
  141. shl eax,4
  142. movups xmm1,XMMWORD[16+rcx]
  143. xorps xmm2,xmm0
  144. xorps xmm3,xmm0
  145. xorps xmm4,xmm0
  146. movups xmm0,XMMWORD[32+rcx]
  147. lea rcx,[32+rax*1+rcx]
  148. neg rax
  149. add rax,16
  150. $L$dec_loop3:
  151. DB 102,15,56,222,209
  152. DB 102,15,56,222,217
  153. DB 102,15,56,222,225
  154. movups xmm1,XMMWORD[rax*1+rcx]
  155. add rax,32
  156. DB 102,15,56,222,208
  157. DB 102,15,56,222,216
  158. DB 102,15,56,222,224
  159. movups xmm0,XMMWORD[((-16))+rax*1+rcx]
  160. jnz NEAR $L$dec_loop3
  161. DB 102,15,56,222,209
  162. DB 102,15,56,222,217
  163. DB 102,15,56,222,225
  164. DB 102,15,56,223,208
  165. DB 102,15,56,223,216
  166. DB 102,15,56,223,224
  167. DB 0F3h,0C3h ;repret
  168. ALIGN 16
  169. _aesni_encrypt4:
  170. movups xmm0,XMMWORD[rcx]
  171. shl eax,4
  172. movups xmm1,XMMWORD[16+rcx]
  173. xorps xmm2,xmm0
  174. xorps xmm3,xmm0
  175. xorps xmm4,xmm0
  176. xorps xmm5,xmm0
  177. movups xmm0,XMMWORD[32+rcx]
  178. lea rcx,[32+rax*1+rcx]
  179. neg rax
  180. DB 0x0f,0x1f,0x00
  181. add rax,16
  182. $L$enc_loop4:
  183. DB 102,15,56,220,209
  184. DB 102,15,56,220,217
  185. DB 102,15,56,220,225
  186. DB 102,15,56,220,233
  187. movups xmm1,XMMWORD[rax*1+rcx]
  188. add rax,32
  189. DB 102,15,56,220,208
  190. DB 102,15,56,220,216
  191. DB 102,15,56,220,224
  192. DB 102,15,56,220,232
  193. movups xmm0,XMMWORD[((-16))+rax*1+rcx]
  194. jnz NEAR $L$enc_loop4
  195. DB 102,15,56,220,209
  196. DB 102,15,56,220,217
  197. DB 102,15,56,220,225
  198. DB 102,15,56,220,233
  199. DB 102,15,56,221,208
  200. DB 102,15,56,221,216
  201. DB 102,15,56,221,224
  202. DB 102,15,56,221,232
  203. DB 0F3h,0C3h ;repret
  204. ALIGN 16
  205. _aesni_decrypt4:
  206. movups xmm0,XMMWORD[rcx]
  207. shl eax,4
  208. movups xmm1,XMMWORD[16+rcx]
  209. xorps xmm2,xmm0
  210. xorps xmm3,xmm0
  211. xorps xmm4,xmm0
  212. xorps xmm5,xmm0
  213. movups xmm0,XMMWORD[32+rcx]
  214. lea rcx,[32+rax*1+rcx]
  215. neg rax
  216. DB 0x0f,0x1f,0x00
  217. add rax,16
  218. $L$dec_loop4:
  219. DB 102,15,56,222,209
  220. DB 102,15,56,222,217
  221. DB 102,15,56,222,225
  222. DB 102,15,56,222,233
  223. movups xmm1,XMMWORD[rax*1+rcx]
  224. add rax,32
  225. DB 102,15,56,222,208
  226. DB 102,15,56,222,216
  227. DB 102,15,56,222,224
  228. DB 102,15,56,222,232
  229. movups xmm0,XMMWORD[((-16))+rax*1+rcx]
  230. jnz NEAR $L$dec_loop4
  231. DB 102,15,56,222,209
  232. DB 102,15,56,222,217
  233. DB 102,15,56,222,225
  234. DB 102,15,56,222,233
  235. DB 102,15,56,223,208
  236. DB 102,15,56,223,216
  237. DB 102,15,56,223,224
  238. DB 102,15,56,223,232
  239. DB 0F3h,0C3h ;repret
  240. ALIGN 16
  241. _aesni_encrypt6:
  242. movups xmm0,XMMWORD[rcx]
  243. shl eax,4
  244. movups xmm1,XMMWORD[16+rcx]
  245. xorps xmm2,xmm0
  246. pxor xmm3,xmm0
  247. pxor xmm4,xmm0
  248. DB 102,15,56,220,209
  249. lea rcx,[32+rax*1+rcx]
  250. neg rax
  251. DB 102,15,56,220,217
  252. pxor xmm5,xmm0
  253. pxor xmm6,xmm0
  254. DB 102,15,56,220,225
  255. pxor xmm7,xmm0
  256. movups xmm0,XMMWORD[rax*1+rcx]
  257. add rax,16
  258. jmp NEAR $L$enc_loop6_enter
  259. ALIGN 16
  260. $L$enc_loop6:
  261. DB 102,15,56,220,209
  262. DB 102,15,56,220,217
  263. DB 102,15,56,220,225
  264. $L$enc_loop6_enter:
  265. DB 102,15,56,220,233
  266. DB 102,15,56,220,241
  267. DB 102,15,56,220,249
  268. movups xmm1,XMMWORD[rax*1+rcx]
  269. add rax,32
  270. DB 102,15,56,220,208
  271. DB 102,15,56,220,216
  272. DB 102,15,56,220,224
  273. DB 102,15,56,220,232
  274. DB 102,15,56,220,240
  275. DB 102,15,56,220,248
  276. movups xmm0,XMMWORD[((-16))+rax*1+rcx]
  277. jnz NEAR $L$enc_loop6
  278. DB 102,15,56,220,209
  279. DB 102,15,56,220,217
  280. DB 102,15,56,220,225
  281. DB 102,15,56,220,233
  282. DB 102,15,56,220,241
  283. DB 102,15,56,220,249
  284. DB 102,15,56,221,208
  285. DB 102,15,56,221,216
  286. DB 102,15,56,221,224
  287. DB 102,15,56,221,232
  288. DB 102,15,56,221,240
  289. DB 102,15,56,221,248
  290. DB 0F3h,0C3h ;repret
  291. ALIGN 16
  292. _aesni_decrypt6:
  293. movups xmm0,XMMWORD[rcx]
  294. shl eax,4
  295. movups xmm1,XMMWORD[16+rcx]
  296. xorps xmm2,xmm0
  297. pxor xmm3,xmm0
  298. pxor xmm4,xmm0
  299. DB 102,15,56,222,209
  300. lea rcx,[32+rax*1+rcx]
  301. neg rax
  302. DB 102,15,56,222,217
  303. pxor xmm5,xmm0
  304. pxor xmm6,xmm0
  305. DB 102,15,56,222,225
  306. pxor xmm7,xmm0
  307. movups xmm0,XMMWORD[rax*1+rcx]
  308. add rax,16
  309. jmp NEAR $L$dec_loop6_enter
  310. ALIGN 16
  311. $L$dec_loop6:
  312. DB 102,15,56,222,209
  313. DB 102,15,56,222,217
  314. DB 102,15,56,222,225
  315. $L$dec_loop6_enter:
  316. DB 102,15,56,222,233
  317. DB 102,15,56,222,241
  318. DB 102,15,56,222,249
  319. movups xmm1,XMMWORD[rax*1+rcx]
  320. add rax,32
  321. DB 102,15,56,222,208
  322. DB 102,15,56,222,216
  323. DB 102,15,56,222,224
  324. DB 102,15,56,222,232
  325. DB 102,15,56,222,240
  326. DB 102,15,56,222,248
  327. movups xmm0,XMMWORD[((-16))+rax*1+rcx]
  328. jnz NEAR $L$dec_loop6
  329. DB 102,15,56,222,209
  330. DB 102,15,56,222,217
  331. DB 102,15,56,222,225
  332. DB 102,15,56,222,233
  333. DB 102,15,56,222,241
  334. DB 102,15,56,222,249
  335. DB 102,15,56,223,208
  336. DB 102,15,56,223,216
  337. DB 102,15,56,223,224
  338. DB 102,15,56,223,232
  339. DB 102,15,56,223,240
  340. DB 102,15,56,223,248
  341. DB 0F3h,0C3h ;repret
  342. ALIGN 16
  343. _aesni_encrypt8:
  344. movups xmm0,XMMWORD[rcx]
  345. shl eax,4
  346. movups xmm1,XMMWORD[16+rcx]
  347. xorps xmm2,xmm0
  348. xorps xmm3,xmm0
  349. pxor xmm4,xmm0
  350. pxor xmm5,xmm0
  351. pxor xmm6,xmm0
  352. lea rcx,[32+rax*1+rcx]
  353. neg rax
  354. DB 102,15,56,220,209
  355. pxor xmm7,xmm0
  356. pxor xmm8,xmm0
  357. DB 102,15,56,220,217
  358. pxor xmm9,xmm0
  359. movups xmm0,XMMWORD[rax*1+rcx]
  360. add rax,16
  361. jmp NEAR $L$enc_loop8_inner
  362. ALIGN 16
  363. $L$enc_loop8:
  364. DB 102,15,56,220,209
  365. DB 102,15,56,220,217
  366. $L$enc_loop8_inner:
  367. DB 102,15,56,220,225
  368. DB 102,15,56,220,233
  369. DB 102,15,56,220,241
  370. DB 102,15,56,220,249
  371. DB 102,68,15,56,220,193
  372. DB 102,68,15,56,220,201
  373. $L$enc_loop8_enter:
  374. movups xmm1,XMMWORD[rax*1+rcx]
  375. add rax,32
  376. DB 102,15,56,220,208
  377. DB 102,15,56,220,216
  378. DB 102,15,56,220,224
  379. DB 102,15,56,220,232
  380. DB 102,15,56,220,240
  381. DB 102,15,56,220,248
  382. DB 102,68,15,56,220,192
  383. DB 102,68,15,56,220,200
  384. movups xmm0,XMMWORD[((-16))+rax*1+rcx]
  385. jnz NEAR $L$enc_loop8
  386. DB 102,15,56,220,209
  387. DB 102,15,56,220,217
  388. DB 102,15,56,220,225
  389. DB 102,15,56,220,233
  390. DB 102,15,56,220,241
  391. DB 102,15,56,220,249
  392. DB 102,68,15,56,220,193
  393. DB 102,68,15,56,220,201
  394. DB 102,15,56,221,208
  395. DB 102,15,56,221,216
  396. DB 102,15,56,221,224
  397. DB 102,15,56,221,232
  398. DB 102,15,56,221,240
  399. DB 102,15,56,221,248
  400. DB 102,68,15,56,221,192
  401. DB 102,68,15,56,221,200
  402. DB 0F3h,0C3h ;repret
  403. ALIGN 16
  404. _aesni_decrypt8:
  405. movups xmm0,XMMWORD[rcx]
  406. shl eax,4
  407. movups xmm1,XMMWORD[16+rcx]
  408. xorps xmm2,xmm0
  409. xorps xmm3,xmm0
  410. pxor xmm4,xmm0
  411. pxor xmm5,xmm0
  412. pxor xmm6,xmm0
  413. lea rcx,[32+rax*1+rcx]
  414. neg rax
  415. DB 102,15,56,222,209
  416. pxor xmm7,xmm0
  417. pxor xmm8,xmm0
  418. DB 102,15,56,222,217
  419. pxor xmm9,xmm0
  420. movups xmm0,XMMWORD[rax*1+rcx]
  421. add rax,16
  422. jmp NEAR $L$dec_loop8_inner
  423. ALIGN 16
  424. $L$dec_loop8:
  425. DB 102,15,56,222,209
  426. DB 102,15,56,222,217
  427. $L$dec_loop8_inner:
  428. DB 102,15,56,222,225
  429. DB 102,15,56,222,233
  430. DB 102,15,56,222,241
  431. DB 102,15,56,222,249
  432. DB 102,68,15,56,222,193
  433. DB 102,68,15,56,222,201
  434. $L$dec_loop8_enter:
  435. movups xmm1,XMMWORD[rax*1+rcx]
  436. add rax,32
  437. DB 102,15,56,222,208
  438. DB 102,15,56,222,216
  439. DB 102,15,56,222,224
  440. DB 102,15,56,222,232
  441. DB 102,15,56,222,240
  442. DB 102,15,56,222,248
  443. DB 102,68,15,56,222,192
  444. DB 102,68,15,56,222,200
  445. movups xmm0,XMMWORD[((-16))+rax*1+rcx]
  446. jnz NEAR $L$dec_loop8
  447. DB 102,15,56,222,209
  448. DB 102,15,56,222,217
  449. DB 102,15,56,222,225
  450. DB 102,15,56,222,233
  451. DB 102,15,56,222,241
  452. DB 102,15,56,222,249
  453. DB 102,68,15,56,222,193
  454. DB 102,68,15,56,222,201
  455. DB 102,15,56,223,208
  456. DB 102,15,56,223,216
  457. DB 102,15,56,223,224
  458. DB 102,15,56,223,232
  459. DB 102,15,56,223,240
  460. DB 102,15,56,223,248
  461. DB 102,68,15,56,223,192
  462. DB 102,68,15,56,223,200
  463. DB 0F3h,0C3h ;repret
  464. global aes_hw_ecb_encrypt
  465. ALIGN 16
  466. aes_hw_ecb_encrypt:
  467. mov QWORD[8+rsp],rdi ;WIN64 prologue
  468. mov QWORD[16+rsp],rsi
  469. mov rax,rsp
  470. $L$SEH_begin_aes_hw_ecb_encrypt:
  471. mov rdi,rcx
  472. mov rsi,rdx
  473. mov rdx,r8
  474. mov rcx,r9
  475. mov r8,QWORD[40+rsp]
  476. lea rsp,[((-88))+rsp]
  477. movaps XMMWORD[rsp],xmm6
  478. movaps XMMWORD[16+rsp],xmm7
  479. movaps XMMWORD[32+rsp],xmm8
  480. movaps XMMWORD[48+rsp],xmm9
  481. $L$ecb_enc_body:
  482. and rdx,-16
  483. jz NEAR $L$ecb_ret
  484. mov eax,DWORD[240+rcx]
  485. movups xmm0,XMMWORD[rcx]
  486. mov r11,rcx
  487. mov r10d,eax
  488. test r8d,r8d
  489. jz NEAR $L$ecb_decrypt
  490. cmp rdx,0x80
  491. jb NEAR $L$ecb_enc_tail
  492. movdqu xmm2,XMMWORD[rdi]
  493. movdqu xmm3,XMMWORD[16+rdi]
  494. movdqu xmm4,XMMWORD[32+rdi]
  495. movdqu xmm5,XMMWORD[48+rdi]
  496. movdqu xmm6,XMMWORD[64+rdi]
  497. movdqu xmm7,XMMWORD[80+rdi]
  498. movdqu xmm8,XMMWORD[96+rdi]
  499. movdqu xmm9,XMMWORD[112+rdi]
  500. lea rdi,[128+rdi]
  501. sub rdx,0x80
  502. jmp NEAR $L$ecb_enc_loop8_enter
  503. ALIGN 16
  504. $L$ecb_enc_loop8:
  505. movups XMMWORD[rsi],xmm2
  506. mov rcx,r11
  507. movdqu xmm2,XMMWORD[rdi]
  508. mov eax,r10d
  509. movups XMMWORD[16+rsi],xmm3
  510. movdqu xmm3,XMMWORD[16+rdi]
  511. movups XMMWORD[32+rsi],xmm4
  512. movdqu xmm4,XMMWORD[32+rdi]
  513. movups XMMWORD[48+rsi],xmm5
  514. movdqu xmm5,XMMWORD[48+rdi]
  515. movups XMMWORD[64+rsi],xmm6
  516. movdqu xmm6,XMMWORD[64+rdi]
  517. movups XMMWORD[80+rsi],xmm7
  518. movdqu xmm7,XMMWORD[80+rdi]
  519. movups XMMWORD[96+rsi],xmm8
  520. movdqu xmm8,XMMWORD[96+rdi]
  521. movups XMMWORD[112+rsi],xmm9
  522. lea rsi,[128+rsi]
  523. movdqu xmm9,XMMWORD[112+rdi]
  524. lea rdi,[128+rdi]
  525. $L$ecb_enc_loop8_enter:
  526. call _aesni_encrypt8
  527. sub rdx,0x80
  528. jnc NEAR $L$ecb_enc_loop8
  529. movups XMMWORD[rsi],xmm2
  530. mov rcx,r11
  531. movups XMMWORD[16+rsi],xmm3
  532. mov eax,r10d
  533. movups XMMWORD[32+rsi],xmm4
  534. movups XMMWORD[48+rsi],xmm5
  535. movups XMMWORD[64+rsi],xmm6
  536. movups XMMWORD[80+rsi],xmm7
  537. movups XMMWORD[96+rsi],xmm8
  538. movups XMMWORD[112+rsi],xmm9
  539. lea rsi,[128+rsi]
  540. add rdx,0x80
  541. jz NEAR $L$ecb_ret
  542. $L$ecb_enc_tail:
  543. movups xmm2,XMMWORD[rdi]
  544. cmp rdx,0x20
  545. jb NEAR $L$ecb_enc_one
  546. movups xmm3,XMMWORD[16+rdi]
  547. je NEAR $L$ecb_enc_two
  548. movups xmm4,XMMWORD[32+rdi]
  549. cmp rdx,0x40
  550. jb NEAR $L$ecb_enc_three
  551. movups xmm5,XMMWORD[48+rdi]
  552. je NEAR $L$ecb_enc_four
  553. movups xmm6,XMMWORD[64+rdi]
  554. cmp rdx,0x60
  555. jb NEAR $L$ecb_enc_five
  556. movups xmm7,XMMWORD[80+rdi]
  557. je NEAR $L$ecb_enc_six
  558. movdqu xmm8,XMMWORD[96+rdi]
  559. xorps xmm9,xmm9
  560. call _aesni_encrypt8
  561. movups XMMWORD[rsi],xmm2
  562. movups XMMWORD[16+rsi],xmm3
  563. movups XMMWORD[32+rsi],xmm4
  564. movups XMMWORD[48+rsi],xmm5
  565. movups XMMWORD[64+rsi],xmm6
  566. movups XMMWORD[80+rsi],xmm7
  567. movups XMMWORD[96+rsi],xmm8
  568. jmp NEAR $L$ecb_ret
  569. ALIGN 16
  570. $L$ecb_enc_one:
  571. movups xmm0,XMMWORD[rcx]
  572. movups xmm1,XMMWORD[16+rcx]
  573. lea rcx,[32+rcx]
  574. xorps xmm2,xmm0
  575. $L$oop_enc1_3:
  576. DB 102,15,56,220,209
  577. dec eax
  578. movups xmm1,XMMWORD[rcx]
  579. lea rcx,[16+rcx]
  580. jnz NEAR $L$oop_enc1_3
  581. DB 102,15,56,221,209
  582. movups XMMWORD[rsi],xmm2
  583. jmp NEAR $L$ecb_ret
  584. ALIGN 16
  585. $L$ecb_enc_two:
  586. call _aesni_encrypt2
  587. movups XMMWORD[rsi],xmm2
  588. movups XMMWORD[16+rsi],xmm3
  589. jmp NEAR $L$ecb_ret
  590. ALIGN 16
  591. $L$ecb_enc_three:
  592. call _aesni_encrypt3
  593. movups XMMWORD[rsi],xmm2
  594. movups XMMWORD[16+rsi],xmm3
  595. movups XMMWORD[32+rsi],xmm4
  596. jmp NEAR $L$ecb_ret
  597. ALIGN 16
  598. $L$ecb_enc_four:
  599. call _aesni_encrypt4
  600. movups XMMWORD[rsi],xmm2
  601. movups XMMWORD[16+rsi],xmm3
  602. movups XMMWORD[32+rsi],xmm4
  603. movups XMMWORD[48+rsi],xmm5
  604. jmp NEAR $L$ecb_ret
  605. ALIGN 16
  606. $L$ecb_enc_five:
  607. xorps xmm7,xmm7
  608. call _aesni_encrypt6
  609. movups XMMWORD[rsi],xmm2
  610. movups XMMWORD[16+rsi],xmm3
  611. movups XMMWORD[32+rsi],xmm4
  612. movups XMMWORD[48+rsi],xmm5
  613. movups XMMWORD[64+rsi],xmm6
  614. jmp NEAR $L$ecb_ret
  615. ALIGN 16
  616. $L$ecb_enc_six:
  617. call _aesni_encrypt6
  618. movups XMMWORD[rsi],xmm2
  619. movups XMMWORD[16+rsi],xmm3
  620. movups XMMWORD[32+rsi],xmm4
  621. movups XMMWORD[48+rsi],xmm5
  622. movups XMMWORD[64+rsi],xmm6
  623. movups XMMWORD[80+rsi],xmm7
  624. jmp NEAR $L$ecb_ret
  625. ALIGN 16
  626. $L$ecb_decrypt:
  627. cmp rdx,0x80
  628. jb NEAR $L$ecb_dec_tail
  629. movdqu xmm2,XMMWORD[rdi]
  630. movdqu xmm3,XMMWORD[16+rdi]
  631. movdqu xmm4,XMMWORD[32+rdi]
  632. movdqu xmm5,XMMWORD[48+rdi]
  633. movdqu xmm6,XMMWORD[64+rdi]
  634. movdqu xmm7,XMMWORD[80+rdi]
  635. movdqu xmm8,XMMWORD[96+rdi]
  636. movdqu xmm9,XMMWORD[112+rdi]
  637. lea rdi,[128+rdi]
  638. sub rdx,0x80
  639. jmp NEAR $L$ecb_dec_loop8_enter
  640. ALIGN 16
  641. $L$ecb_dec_loop8:
  642. movups XMMWORD[rsi],xmm2
  643. mov rcx,r11
  644. movdqu xmm2,XMMWORD[rdi]
  645. mov eax,r10d
  646. movups XMMWORD[16+rsi],xmm3
  647. movdqu xmm3,XMMWORD[16+rdi]
  648. movups XMMWORD[32+rsi],xmm4
  649. movdqu xmm4,XMMWORD[32+rdi]
  650. movups XMMWORD[48+rsi],xmm5
  651. movdqu xmm5,XMMWORD[48+rdi]
  652. movups XMMWORD[64+rsi],xmm6
  653. movdqu xmm6,XMMWORD[64+rdi]
  654. movups XMMWORD[80+rsi],xmm7
  655. movdqu xmm7,XMMWORD[80+rdi]
  656. movups XMMWORD[96+rsi],xmm8
  657. movdqu xmm8,XMMWORD[96+rdi]
  658. movups XMMWORD[112+rsi],xmm9
  659. lea rsi,[128+rsi]
  660. movdqu xmm9,XMMWORD[112+rdi]
  661. lea rdi,[128+rdi]
  662. $L$ecb_dec_loop8_enter:
  663. call _aesni_decrypt8
  664. movups xmm0,XMMWORD[r11]
  665. sub rdx,0x80
  666. jnc NEAR $L$ecb_dec_loop8
  667. movups XMMWORD[rsi],xmm2
  668. pxor xmm2,xmm2
  669. mov rcx,r11
  670. movups XMMWORD[16+rsi],xmm3
  671. pxor xmm3,xmm3
  672. mov eax,r10d
  673. movups XMMWORD[32+rsi],xmm4
  674. pxor xmm4,xmm4
  675. movups XMMWORD[48+rsi],xmm5
  676. pxor xmm5,xmm5
  677. movups XMMWORD[64+rsi],xmm6
  678. pxor xmm6,xmm6
  679. movups XMMWORD[80+rsi],xmm7
  680. pxor xmm7,xmm7
  681. movups XMMWORD[96+rsi],xmm8
  682. pxor xmm8,xmm8
  683. movups XMMWORD[112+rsi],xmm9
  684. pxor xmm9,xmm9
  685. lea rsi,[128+rsi]
  686. add rdx,0x80
  687. jz NEAR $L$ecb_ret
  688. $L$ecb_dec_tail:
  689. movups xmm2,XMMWORD[rdi]
  690. cmp rdx,0x20
  691. jb NEAR $L$ecb_dec_one
  692. movups xmm3,XMMWORD[16+rdi]
  693. je NEAR $L$ecb_dec_two
  694. movups xmm4,XMMWORD[32+rdi]
  695. cmp rdx,0x40
  696. jb NEAR $L$ecb_dec_three
  697. movups xmm5,XMMWORD[48+rdi]
  698. je NEAR $L$ecb_dec_four
  699. movups xmm6,XMMWORD[64+rdi]
  700. cmp rdx,0x60
  701. jb NEAR $L$ecb_dec_five
  702. movups xmm7,XMMWORD[80+rdi]
  703. je NEAR $L$ecb_dec_six
  704. movups xmm8,XMMWORD[96+rdi]
  705. movups xmm0,XMMWORD[rcx]
  706. xorps xmm9,xmm9
  707. call _aesni_decrypt8
  708. movups XMMWORD[rsi],xmm2
  709. pxor xmm2,xmm2
  710. movups XMMWORD[16+rsi],xmm3
  711. pxor xmm3,xmm3
  712. movups XMMWORD[32+rsi],xmm4
  713. pxor xmm4,xmm4
  714. movups XMMWORD[48+rsi],xmm5
  715. pxor xmm5,xmm5
  716. movups XMMWORD[64+rsi],xmm6
  717. pxor xmm6,xmm6
  718. movups XMMWORD[80+rsi],xmm7
  719. pxor xmm7,xmm7
  720. movups XMMWORD[96+rsi],xmm8
  721. pxor xmm8,xmm8
  722. pxor xmm9,xmm9
  723. jmp NEAR $L$ecb_ret
  724. ALIGN 16
  725. $L$ecb_dec_one:
  726. movups xmm0,XMMWORD[rcx]
  727. movups xmm1,XMMWORD[16+rcx]
  728. lea rcx,[32+rcx]
  729. xorps xmm2,xmm0
  730. $L$oop_dec1_4:
  731. DB 102,15,56,222,209
  732. dec eax
  733. movups xmm1,XMMWORD[rcx]
  734. lea rcx,[16+rcx]
  735. jnz NEAR $L$oop_dec1_4
  736. DB 102,15,56,223,209
  737. movups XMMWORD[rsi],xmm2
  738. pxor xmm2,xmm2
  739. jmp NEAR $L$ecb_ret
  740. ALIGN 16
  741. $L$ecb_dec_two:
  742. call _aesni_decrypt2
  743. movups XMMWORD[rsi],xmm2
  744. pxor xmm2,xmm2
  745. movups XMMWORD[16+rsi],xmm3
  746. pxor xmm3,xmm3
  747. jmp NEAR $L$ecb_ret
  748. ALIGN 16
  749. $L$ecb_dec_three:
  750. call _aesni_decrypt3
  751. movups XMMWORD[rsi],xmm2
  752. pxor xmm2,xmm2
  753. movups XMMWORD[16+rsi],xmm3
  754. pxor xmm3,xmm3
  755. movups XMMWORD[32+rsi],xmm4
  756. pxor xmm4,xmm4
  757. jmp NEAR $L$ecb_ret
  758. ALIGN 16
  759. $L$ecb_dec_four:
  760. call _aesni_decrypt4
  761. movups XMMWORD[rsi],xmm2
  762. pxor xmm2,xmm2
  763. movups XMMWORD[16+rsi],xmm3
  764. pxor xmm3,xmm3
  765. movups XMMWORD[32+rsi],xmm4
  766. pxor xmm4,xmm4
  767. movups XMMWORD[48+rsi],xmm5
  768. pxor xmm5,xmm5
  769. jmp NEAR $L$ecb_ret
  770. ALIGN 16
  771. $L$ecb_dec_five:
  772. xorps xmm7,xmm7
  773. call _aesni_decrypt6
  774. movups XMMWORD[rsi],xmm2
  775. pxor xmm2,xmm2
  776. movups XMMWORD[16+rsi],xmm3
  777. pxor xmm3,xmm3
  778. movups XMMWORD[32+rsi],xmm4
  779. pxor xmm4,xmm4
  780. movups XMMWORD[48+rsi],xmm5
  781. pxor xmm5,xmm5
  782. movups XMMWORD[64+rsi],xmm6
  783. pxor xmm6,xmm6
  784. pxor xmm7,xmm7
  785. jmp NEAR $L$ecb_ret
  786. ALIGN 16
  787. $L$ecb_dec_six:
  788. call _aesni_decrypt6
  789. movups XMMWORD[rsi],xmm2
  790. pxor xmm2,xmm2
  791. movups XMMWORD[16+rsi],xmm3
  792. pxor xmm3,xmm3
  793. movups XMMWORD[32+rsi],xmm4
  794. pxor xmm4,xmm4
  795. movups XMMWORD[48+rsi],xmm5
  796. pxor xmm5,xmm5
  797. movups XMMWORD[64+rsi],xmm6
  798. pxor xmm6,xmm6
  799. movups XMMWORD[80+rsi],xmm7
  800. pxor xmm7,xmm7
  801. $L$ecb_ret:
  802. xorps xmm0,xmm0
  803. pxor xmm1,xmm1
  804. movaps xmm6,XMMWORD[rsp]
  805. movaps XMMWORD[rsp],xmm0
  806. movaps xmm7,XMMWORD[16+rsp]
  807. movaps XMMWORD[16+rsp],xmm0
  808. movaps xmm8,XMMWORD[32+rsp]
  809. movaps XMMWORD[32+rsp],xmm0
  810. movaps xmm9,XMMWORD[48+rsp]
  811. movaps XMMWORD[48+rsp],xmm0
  812. lea rsp,[88+rsp]
  813. $L$ecb_enc_ret:
  814. mov rdi,QWORD[8+rsp] ;WIN64 epilogue
  815. mov rsi,QWORD[16+rsp]
  816. DB 0F3h,0C3h ;repret
  817. $L$SEH_end_aes_hw_ecb_encrypt:
  818. global aes_hw_ctr32_encrypt_blocks
  819. ALIGN 16
  820. aes_hw_ctr32_encrypt_blocks:
  821. mov QWORD[8+rsp],rdi ;WIN64 prologue
  822. mov QWORD[16+rsp],rsi
  823. mov rax,rsp
  824. $L$SEH_begin_aes_hw_ctr32_encrypt_blocks:
  825. mov rdi,rcx
  826. mov rsi,rdx
  827. mov rdx,r8
  828. mov rcx,r9
  829. mov r8,QWORD[40+rsp]
  830. %ifdef BORINGSSL_DISPATCH_TEST
  831. mov BYTE[BORINGSSL_function_hit],1
  832. %endif
  833. cmp rdx,1
  834. jne NEAR $L$ctr32_bulk
  835. movups xmm2,XMMWORD[r8]
  836. movups xmm3,XMMWORD[rdi]
  837. mov edx,DWORD[240+rcx]
  838. movups xmm0,XMMWORD[rcx]
  839. movups xmm1,XMMWORD[16+rcx]
  840. lea rcx,[32+rcx]
  841. xorps xmm2,xmm0
  842. $L$oop_enc1_5:
  843. DB 102,15,56,220,209
  844. dec edx
  845. movups xmm1,XMMWORD[rcx]
  846. lea rcx,[16+rcx]
  847. jnz NEAR $L$oop_enc1_5
  848. DB 102,15,56,221,209
  849. pxor xmm0,xmm0
  850. pxor xmm1,xmm1
  851. xorps xmm2,xmm3
  852. pxor xmm3,xmm3
  853. movups XMMWORD[rsi],xmm2
  854. xorps xmm2,xmm2
  855. jmp NEAR $L$ctr32_epilogue
  856. ALIGN 16
  857. $L$ctr32_bulk:
  858. lea r11,[rsp]
  859. push rbp
  860. sub rsp,288
  861. and rsp,-16
  862. movaps XMMWORD[(-168)+r11],xmm6
  863. movaps XMMWORD[(-152)+r11],xmm7
  864. movaps XMMWORD[(-136)+r11],xmm8
  865. movaps XMMWORD[(-120)+r11],xmm9
  866. movaps XMMWORD[(-104)+r11],xmm10
  867. movaps XMMWORD[(-88)+r11],xmm11
  868. movaps XMMWORD[(-72)+r11],xmm12
  869. movaps XMMWORD[(-56)+r11],xmm13
  870. movaps XMMWORD[(-40)+r11],xmm14
  871. movaps XMMWORD[(-24)+r11],xmm15
  872. $L$ctr32_body:
  873. movdqu xmm2,XMMWORD[r8]
  874. movdqu xmm0,XMMWORD[rcx]
  875. mov r8d,DWORD[12+r8]
  876. pxor xmm2,xmm0
  877. mov ebp,DWORD[12+rcx]
  878. movdqa XMMWORD[rsp],xmm2
  879. bswap r8d
  880. movdqa xmm3,xmm2
  881. movdqa xmm4,xmm2
  882. movdqa xmm5,xmm2
  883. movdqa XMMWORD[64+rsp],xmm2
  884. movdqa XMMWORD[80+rsp],xmm2
  885. movdqa XMMWORD[96+rsp],xmm2
  886. mov r10,rdx
  887. movdqa XMMWORD[112+rsp],xmm2
  888. lea rax,[1+r8]
  889. lea rdx,[2+r8]
  890. bswap eax
  891. bswap edx
  892. xor eax,ebp
  893. xor edx,ebp
  894. DB 102,15,58,34,216,3
  895. lea rax,[3+r8]
  896. movdqa XMMWORD[16+rsp],xmm3
  897. DB 102,15,58,34,226,3
  898. bswap eax
  899. mov rdx,r10
  900. lea r10,[4+r8]
  901. movdqa XMMWORD[32+rsp],xmm4
  902. xor eax,ebp
  903. bswap r10d
  904. DB 102,15,58,34,232,3
  905. xor r10d,ebp
  906. movdqa XMMWORD[48+rsp],xmm5
  907. lea r9,[5+r8]
  908. mov DWORD[((64+12))+rsp],r10d
  909. bswap r9d
  910. lea r10,[6+r8]
  911. mov eax,DWORD[240+rcx]
  912. xor r9d,ebp
  913. bswap r10d
  914. mov DWORD[((80+12))+rsp],r9d
  915. xor r10d,ebp
  916. lea r9,[7+r8]
  917. mov DWORD[((96+12))+rsp],r10d
  918. bswap r9d
  919. lea r10,[OPENSSL_ia32cap_P]
  920. mov r10d,DWORD[4+r10]
  921. xor r9d,ebp
  922. and r10d,71303168
  923. mov DWORD[((112+12))+rsp],r9d
  924. movups xmm1,XMMWORD[16+rcx]
  925. movdqa xmm6,XMMWORD[64+rsp]
  926. movdqa xmm7,XMMWORD[80+rsp]
  927. cmp rdx,8
  928. jb NEAR $L$ctr32_tail
  929. sub rdx,6
  930. cmp r10d,4194304
  931. je NEAR $L$ctr32_6x
  932. lea rcx,[128+rcx]
  933. sub rdx,2
  934. jmp NEAR $L$ctr32_loop8
  935. ALIGN 16
  936. $L$ctr32_6x:
  937. shl eax,4
  938. mov r10d,48
  939. bswap ebp
  940. lea rcx,[32+rax*1+rcx]
  941. sub r10,rax
  942. jmp NEAR $L$ctr32_loop6
  943. ALIGN 16
  944. $L$ctr32_loop6:
  945. add r8d,6
  946. movups xmm0,XMMWORD[((-48))+r10*1+rcx]
  947. DB 102,15,56,220,209
  948. mov eax,r8d
  949. xor eax,ebp
  950. DB 102,15,56,220,217
  951. DB 0x0f,0x38,0xf1,0x44,0x24,12
  952. lea eax,[1+r8]
  953. DB 102,15,56,220,225
  954. xor eax,ebp
  955. DB 0x0f,0x38,0xf1,0x44,0x24,28
  956. DB 102,15,56,220,233
  957. lea eax,[2+r8]
  958. xor eax,ebp
  959. DB 102,15,56,220,241
  960. DB 0x0f,0x38,0xf1,0x44,0x24,44
  961. lea eax,[3+r8]
  962. DB 102,15,56,220,249
  963. movups xmm1,XMMWORD[((-32))+r10*1+rcx]
  964. xor eax,ebp
  965. DB 102,15,56,220,208
  966. DB 0x0f,0x38,0xf1,0x44,0x24,60
  967. lea eax,[4+r8]
  968. DB 102,15,56,220,216
  969. xor eax,ebp
  970. DB 0x0f,0x38,0xf1,0x44,0x24,76
  971. DB 102,15,56,220,224
  972. lea eax,[5+r8]
  973. xor eax,ebp
  974. DB 102,15,56,220,232
  975. DB 0x0f,0x38,0xf1,0x44,0x24,92
  976. mov rax,r10
  977. DB 102,15,56,220,240
  978. DB 102,15,56,220,248
  979. movups xmm0,XMMWORD[((-16))+r10*1+rcx]
  980. call $L$enc_loop6
  981. movdqu xmm8,XMMWORD[rdi]
  982. movdqu xmm9,XMMWORD[16+rdi]
  983. movdqu xmm10,XMMWORD[32+rdi]
  984. movdqu xmm11,XMMWORD[48+rdi]
  985. movdqu xmm12,XMMWORD[64+rdi]
  986. movdqu xmm13,XMMWORD[80+rdi]
  987. lea rdi,[96+rdi]
  988. movups xmm1,XMMWORD[((-64))+r10*1+rcx]
  989. pxor xmm8,xmm2
  990. movaps xmm2,XMMWORD[rsp]
  991. pxor xmm9,xmm3
  992. movaps xmm3,XMMWORD[16+rsp]
  993. pxor xmm10,xmm4
  994. movaps xmm4,XMMWORD[32+rsp]
  995. pxor xmm11,xmm5
  996. movaps xmm5,XMMWORD[48+rsp]
  997. pxor xmm12,xmm6
  998. movaps xmm6,XMMWORD[64+rsp]
  999. pxor xmm13,xmm7
  1000. movaps xmm7,XMMWORD[80+rsp]
  1001. movdqu XMMWORD[rsi],xmm8
  1002. movdqu XMMWORD[16+rsi],xmm9
  1003. movdqu XMMWORD[32+rsi],xmm10
  1004. movdqu XMMWORD[48+rsi],xmm11
  1005. movdqu XMMWORD[64+rsi],xmm12
  1006. movdqu XMMWORD[80+rsi],xmm13
  1007. lea rsi,[96+rsi]
  1008. sub rdx,6
  1009. jnc NEAR $L$ctr32_loop6
  1010. add rdx,6
  1011. jz NEAR $L$ctr32_done
  1012. lea eax,[((-48))+r10]
  1013. lea rcx,[((-80))+r10*1+rcx]
  1014. neg eax
  1015. shr eax,4
  1016. jmp NEAR $L$ctr32_tail
  1017. ALIGN 32
  1018. $L$ctr32_loop8:
  1019. add r8d,8
  1020. movdqa xmm8,XMMWORD[96+rsp]
  1021. DB 102,15,56,220,209
  1022. mov r9d,r8d
  1023. movdqa xmm9,XMMWORD[112+rsp]
  1024. DB 102,15,56,220,217
  1025. bswap r9d
  1026. movups xmm0,XMMWORD[((32-128))+rcx]
  1027. DB 102,15,56,220,225
  1028. xor r9d,ebp
  1029. nop
  1030. DB 102,15,56,220,233
  1031. mov DWORD[((0+12))+rsp],r9d
  1032. lea r9,[1+r8]
  1033. DB 102,15,56,220,241
  1034. DB 102,15,56,220,249
  1035. DB 102,68,15,56,220,193
  1036. DB 102,68,15,56,220,201
  1037. movups xmm1,XMMWORD[((48-128))+rcx]
  1038. bswap r9d
  1039. DB 102,15,56,220,208
  1040. DB 102,15,56,220,216
  1041. xor r9d,ebp
  1042. DB 0x66,0x90
  1043. DB 102,15,56,220,224
  1044. DB 102,15,56,220,232
  1045. mov DWORD[((16+12))+rsp],r9d
  1046. lea r9,[2+r8]
  1047. DB 102,15,56,220,240
  1048. DB 102,15,56,220,248
  1049. DB 102,68,15,56,220,192
  1050. DB 102,68,15,56,220,200
  1051. movups xmm0,XMMWORD[((64-128))+rcx]
  1052. bswap r9d
  1053. DB 102,15,56,220,209
  1054. DB 102,15,56,220,217
  1055. xor r9d,ebp
  1056. DB 0x66,0x90
  1057. DB 102,15,56,220,225
  1058. DB 102,15,56,220,233
  1059. mov DWORD[((32+12))+rsp],r9d
  1060. lea r9,[3+r8]
  1061. DB 102,15,56,220,241
  1062. DB 102,15,56,220,249
  1063. DB 102,68,15,56,220,193
  1064. DB 102,68,15,56,220,201
  1065. movups xmm1,XMMWORD[((80-128))+rcx]
  1066. bswap r9d
  1067. DB 102,15,56,220,208
  1068. DB 102,15,56,220,216
  1069. xor r9d,ebp
  1070. DB 0x66,0x90
  1071. DB 102,15,56,220,224
  1072. DB 102,15,56,220,232
  1073. mov DWORD[((48+12))+rsp],r9d
  1074. lea r9,[4+r8]
  1075. DB 102,15,56,220,240
  1076. DB 102,15,56,220,248
  1077. DB 102,68,15,56,220,192
  1078. DB 102,68,15,56,220,200
  1079. movups xmm0,XMMWORD[((96-128))+rcx]
  1080. bswap r9d
  1081. DB 102,15,56,220,209
  1082. DB 102,15,56,220,217
  1083. xor r9d,ebp
  1084. DB 0x66,0x90
  1085. DB 102,15,56,220,225
  1086. DB 102,15,56,220,233
  1087. mov DWORD[((64+12))+rsp],r9d
  1088. lea r9,[5+r8]
  1089. DB 102,15,56,220,241
  1090. DB 102,15,56,220,249
  1091. DB 102,68,15,56,220,193
  1092. DB 102,68,15,56,220,201
  1093. movups xmm1,XMMWORD[((112-128))+rcx]
  1094. bswap r9d
  1095. DB 102,15,56,220,208
  1096. DB 102,15,56,220,216
  1097. xor r9d,ebp
  1098. DB 0x66,0x90
  1099. DB 102,15,56,220,224
  1100. DB 102,15,56,220,232
  1101. mov DWORD[((80+12))+rsp],r9d
  1102. lea r9,[6+r8]
  1103. DB 102,15,56,220,240
  1104. DB 102,15,56,220,248
  1105. DB 102,68,15,56,220,192
  1106. DB 102,68,15,56,220,200
  1107. movups xmm0,XMMWORD[((128-128))+rcx]
  1108. bswap r9d
  1109. DB 102,15,56,220,209
  1110. DB 102,15,56,220,217
  1111. xor r9d,ebp
  1112. DB 0x66,0x90
  1113. DB 102,15,56,220,225
  1114. DB 102,15,56,220,233
  1115. mov DWORD[((96+12))+rsp],r9d
  1116. lea r9,[7+r8]
  1117. DB 102,15,56,220,241
  1118. DB 102,15,56,220,249
  1119. DB 102,68,15,56,220,193
  1120. DB 102,68,15,56,220,201
  1121. movups xmm1,XMMWORD[((144-128))+rcx]
  1122. bswap r9d
  1123. DB 102,15,56,220,208
  1124. DB 102,15,56,220,216
  1125. DB 102,15,56,220,224
  1126. xor r9d,ebp
  1127. movdqu xmm10,XMMWORD[rdi]
  1128. DB 102,15,56,220,232
  1129. mov DWORD[((112+12))+rsp],r9d
  1130. cmp eax,11
  1131. DB 102,15,56,220,240
  1132. DB 102,15,56,220,248
  1133. DB 102,68,15,56,220,192
  1134. DB 102,68,15,56,220,200
  1135. movups xmm0,XMMWORD[((160-128))+rcx]
  1136. jb NEAR $L$ctr32_enc_done
  1137. DB 102,15,56,220,209
  1138. DB 102,15,56,220,217
  1139. DB 102,15,56,220,225
  1140. DB 102,15,56,220,233
  1141. DB 102,15,56,220,241
  1142. DB 102,15,56,220,249
  1143. DB 102,68,15,56,220,193
  1144. DB 102,68,15,56,220,201
  1145. movups xmm1,XMMWORD[((176-128))+rcx]
  1146. DB 102,15,56,220,208
  1147. DB 102,15,56,220,216
  1148. DB 102,15,56,220,224
  1149. DB 102,15,56,220,232
  1150. DB 102,15,56,220,240
  1151. DB 102,15,56,220,248
  1152. DB 102,68,15,56,220,192
  1153. DB 102,68,15,56,220,200
  1154. movups xmm0,XMMWORD[((192-128))+rcx]
  1155. je NEAR $L$ctr32_enc_done
  1156. DB 102,15,56,220,209
  1157. DB 102,15,56,220,217
  1158. DB 102,15,56,220,225
  1159. DB 102,15,56,220,233
  1160. DB 102,15,56,220,241
  1161. DB 102,15,56,220,249
  1162. DB 102,68,15,56,220,193
  1163. DB 102,68,15,56,220,201
  1164. movups xmm1,XMMWORD[((208-128))+rcx]
  1165. DB 102,15,56,220,208
  1166. DB 102,15,56,220,216
  1167. DB 102,15,56,220,224
  1168. DB 102,15,56,220,232
  1169. DB 102,15,56,220,240
  1170. DB 102,15,56,220,248
  1171. DB 102,68,15,56,220,192
  1172. DB 102,68,15,56,220,200
  1173. movups xmm0,XMMWORD[((224-128))+rcx]
  1174. jmp NEAR $L$ctr32_enc_done
  1175. ALIGN 16
  1176. $L$ctr32_enc_done:
  1177. movdqu xmm11,XMMWORD[16+rdi]
  1178. pxor xmm10,xmm0
  1179. movdqu xmm12,XMMWORD[32+rdi]
  1180. pxor xmm11,xmm0
  1181. movdqu xmm13,XMMWORD[48+rdi]
  1182. pxor xmm12,xmm0
  1183. movdqu xmm14,XMMWORD[64+rdi]
  1184. pxor xmm13,xmm0
  1185. movdqu xmm15,XMMWORD[80+rdi]
  1186. pxor xmm14,xmm0
  1187. pxor xmm15,xmm0
  1188. DB 102,15,56,220,209
  1189. DB 102,15,56,220,217
  1190. DB 102,15,56,220,225
  1191. DB 102,15,56,220,233
  1192. DB 102,15,56,220,241
  1193. DB 102,15,56,220,249
  1194. DB 102,68,15,56,220,193
  1195. DB 102,68,15,56,220,201
  1196. movdqu xmm1,XMMWORD[96+rdi]
  1197. lea rdi,[128+rdi]
  1198. DB 102,65,15,56,221,210
  1199. pxor xmm1,xmm0
  1200. movdqu xmm10,XMMWORD[((112-128))+rdi]
  1201. DB 102,65,15,56,221,219
  1202. pxor xmm10,xmm0
  1203. movdqa xmm11,XMMWORD[rsp]
  1204. DB 102,65,15,56,221,228
  1205. DB 102,65,15,56,221,237
  1206. movdqa xmm12,XMMWORD[16+rsp]
  1207. movdqa xmm13,XMMWORD[32+rsp]
  1208. DB 102,65,15,56,221,246
  1209. DB 102,65,15,56,221,255
  1210. movdqa xmm14,XMMWORD[48+rsp]
  1211. movdqa xmm15,XMMWORD[64+rsp]
  1212. DB 102,68,15,56,221,193
  1213. movdqa xmm0,XMMWORD[80+rsp]
  1214. movups xmm1,XMMWORD[((16-128))+rcx]
  1215. DB 102,69,15,56,221,202
  1216. movups XMMWORD[rsi],xmm2
  1217. movdqa xmm2,xmm11
  1218. movups XMMWORD[16+rsi],xmm3
  1219. movdqa xmm3,xmm12
  1220. movups XMMWORD[32+rsi],xmm4
  1221. movdqa xmm4,xmm13
  1222. movups XMMWORD[48+rsi],xmm5
  1223. movdqa xmm5,xmm14
  1224. movups XMMWORD[64+rsi],xmm6
  1225. movdqa xmm6,xmm15
  1226. movups XMMWORD[80+rsi],xmm7
  1227. movdqa xmm7,xmm0
  1228. movups XMMWORD[96+rsi],xmm8
  1229. movups XMMWORD[112+rsi],xmm9
  1230. lea rsi,[128+rsi]
  1231. sub rdx,8
  1232. jnc NEAR $L$ctr32_loop8
  1233. add rdx,8
  1234. jz NEAR $L$ctr32_done
  1235. lea rcx,[((-128))+rcx]
  1236. $L$ctr32_tail:
  1237. lea rcx,[16+rcx]
  1238. cmp rdx,4
  1239. jb NEAR $L$ctr32_loop3
  1240. je NEAR $L$ctr32_loop4
  1241. shl eax,4
  1242. movdqa xmm8,XMMWORD[96+rsp]
  1243. pxor xmm9,xmm9
  1244. movups xmm0,XMMWORD[16+rcx]
  1245. DB 102,15,56,220,209
  1246. DB 102,15,56,220,217
  1247. lea rcx,[((32-16))+rax*1+rcx]
  1248. neg rax
  1249. DB 102,15,56,220,225
  1250. add rax,16
  1251. movups xmm10,XMMWORD[rdi]
  1252. DB 102,15,56,220,233
  1253. DB 102,15,56,220,241
  1254. movups xmm11,XMMWORD[16+rdi]
  1255. movups xmm12,XMMWORD[32+rdi]
  1256. DB 102,15,56,220,249
  1257. DB 102,68,15,56,220,193
  1258. call $L$enc_loop8_enter
  1259. movdqu xmm13,XMMWORD[48+rdi]
  1260. pxor xmm2,xmm10
  1261. movdqu xmm10,XMMWORD[64+rdi]
  1262. pxor xmm3,xmm11
  1263. movdqu XMMWORD[rsi],xmm2
  1264. pxor xmm4,xmm12
  1265. movdqu XMMWORD[16+rsi],xmm3
  1266. pxor xmm5,xmm13
  1267. movdqu XMMWORD[32+rsi],xmm4
  1268. pxor xmm6,xmm10
  1269. movdqu XMMWORD[48+rsi],xmm5
  1270. movdqu XMMWORD[64+rsi],xmm6
  1271. cmp rdx,6
  1272. jb NEAR $L$ctr32_done
  1273. movups xmm11,XMMWORD[80+rdi]
  1274. xorps xmm7,xmm11
  1275. movups XMMWORD[80+rsi],xmm7
  1276. je NEAR $L$ctr32_done
  1277. movups xmm12,XMMWORD[96+rdi]
  1278. xorps xmm8,xmm12
  1279. movups XMMWORD[96+rsi],xmm8
  1280. jmp NEAR $L$ctr32_done
  1281. ALIGN 32
  1282. $L$ctr32_loop4:
  1283. DB 102,15,56,220,209
  1284. lea rcx,[16+rcx]
  1285. dec eax
  1286. DB 102,15,56,220,217
  1287. DB 102,15,56,220,225
  1288. DB 102,15,56,220,233
  1289. movups xmm1,XMMWORD[rcx]
  1290. jnz NEAR $L$ctr32_loop4
  1291. DB 102,15,56,221,209
  1292. DB 102,15,56,221,217
  1293. movups xmm10,XMMWORD[rdi]
  1294. movups xmm11,XMMWORD[16+rdi]
  1295. DB 102,15,56,221,225
  1296. DB 102,15,56,221,233
  1297. movups xmm12,XMMWORD[32+rdi]
  1298. movups xmm13,XMMWORD[48+rdi]
  1299. xorps xmm2,xmm10
  1300. movups XMMWORD[rsi],xmm2
  1301. xorps xmm3,xmm11
  1302. movups XMMWORD[16+rsi],xmm3
  1303. pxor xmm4,xmm12
  1304. movdqu XMMWORD[32+rsi],xmm4
  1305. pxor xmm5,xmm13
  1306. movdqu XMMWORD[48+rsi],xmm5
  1307. jmp NEAR $L$ctr32_done
  1308. ALIGN 32
  1309. $L$ctr32_loop3:
  1310. DB 102,15,56,220,209
  1311. lea rcx,[16+rcx]
  1312. dec eax
  1313. DB 102,15,56,220,217
  1314. DB 102,15,56,220,225
  1315. movups xmm1,XMMWORD[rcx]
  1316. jnz NEAR $L$ctr32_loop3
  1317. DB 102,15,56,221,209
  1318. DB 102,15,56,221,217
  1319. DB 102,15,56,221,225
  1320. movups xmm10,XMMWORD[rdi]
  1321. xorps xmm2,xmm10
  1322. movups XMMWORD[rsi],xmm2
  1323. cmp rdx,2
  1324. jb NEAR $L$ctr32_done
  1325. movups xmm11,XMMWORD[16+rdi]
  1326. xorps xmm3,xmm11
  1327. movups XMMWORD[16+rsi],xmm3
  1328. je NEAR $L$ctr32_done
  1329. movups xmm12,XMMWORD[32+rdi]
  1330. xorps xmm4,xmm12
  1331. movups XMMWORD[32+rsi],xmm4
  1332. $L$ctr32_done:
  1333. xorps xmm0,xmm0
  1334. xor ebp,ebp
  1335. pxor xmm1,xmm1
  1336. pxor xmm2,xmm2
  1337. pxor xmm3,xmm3
  1338. pxor xmm4,xmm4
  1339. pxor xmm5,xmm5
  1340. movaps xmm6,XMMWORD[((-168))+r11]
  1341. movaps XMMWORD[(-168)+r11],xmm0
  1342. movaps xmm7,XMMWORD[((-152))+r11]
  1343. movaps XMMWORD[(-152)+r11],xmm0
  1344. movaps xmm8,XMMWORD[((-136))+r11]
  1345. movaps XMMWORD[(-136)+r11],xmm0
  1346. movaps xmm9,XMMWORD[((-120))+r11]
  1347. movaps XMMWORD[(-120)+r11],xmm0
  1348. movaps xmm10,XMMWORD[((-104))+r11]
  1349. movaps XMMWORD[(-104)+r11],xmm0
  1350. movaps xmm11,XMMWORD[((-88))+r11]
  1351. movaps XMMWORD[(-88)+r11],xmm0
  1352. movaps xmm12,XMMWORD[((-72))+r11]
  1353. movaps XMMWORD[(-72)+r11],xmm0
  1354. movaps xmm13,XMMWORD[((-56))+r11]
  1355. movaps XMMWORD[(-56)+r11],xmm0
  1356. movaps xmm14,XMMWORD[((-40))+r11]
  1357. movaps XMMWORD[(-40)+r11],xmm0
  1358. movaps xmm15,XMMWORD[((-24))+r11]
  1359. movaps XMMWORD[(-24)+r11],xmm0
  1360. movaps XMMWORD[rsp],xmm0
  1361. movaps XMMWORD[16+rsp],xmm0
  1362. movaps XMMWORD[32+rsp],xmm0
  1363. movaps XMMWORD[48+rsp],xmm0
  1364. movaps XMMWORD[64+rsp],xmm0
  1365. movaps XMMWORD[80+rsp],xmm0
  1366. movaps XMMWORD[96+rsp],xmm0
  1367. movaps XMMWORD[112+rsp],xmm0
  1368. mov rbp,QWORD[((-8))+r11]
  1369. lea rsp,[r11]
  1370. $L$ctr32_epilogue:
  1371. mov rdi,QWORD[8+rsp] ;WIN64 epilogue
  1372. mov rsi,QWORD[16+rsp]
  1373. DB 0F3h,0C3h ;repret
  1374. $L$SEH_end_aes_hw_ctr32_encrypt_blocks:
  1375. global aes_hw_cbc_encrypt
  1376. ALIGN 16
  1377. aes_hw_cbc_encrypt:
  1378. mov QWORD[8+rsp],rdi ;WIN64 prologue
  1379. mov QWORD[16+rsp],rsi
  1380. mov rax,rsp
  1381. $L$SEH_begin_aes_hw_cbc_encrypt:
  1382. mov rdi,rcx
  1383. mov rsi,rdx
  1384. mov rdx,r8
  1385. mov rcx,r9
  1386. mov r8,QWORD[40+rsp]
  1387. mov r9,QWORD[48+rsp]
  1388. test rdx,rdx
  1389. jz NEAR $L$cbc_ret
  1390. mov r10d,DWORD[240+rcx]
  1391. mov r11,rcx
  1392. test r9d,r9d
  1393. jz NEAR $L$cbc_decrypt
  1394. movups xmm2,XMMWORD[r8]
  1395. mov eax,r10d
  1396. cmp rdx,16
  1397. jb NEAR $L$cbc_enc_tail
  1398. sub rdx,16
  1399. jmp NEAR $L$cbc_enc_loop
  1400. ALIGN 16
  1401. $L$cbc_enc_loop:
  1402. movups xmm3,XMMWORD[rdi]
  1403. lea rdi,[16+rdi]
  1404. movups xmm0,XMMWORD[rcx]
  1405. movups xmm1,XMMWORD[16+rcx]
  1406. xorps xmm3,xmm0
  1407. lea rcx,[32+rcx]
  1408. xorps xmm2,xmm3
  1409. $L$oop_enc1_6:
  1410. DB 102,15,56,220,209
  1411. dec eax
  1412. movups xmm1,XMMWORD[rcx]
  1413. lea rcx,[16+rcx]
  1414. jnz NEAR $L$oop_enc1_6
  1415. DB 102,15,56,221,209
  1416. mov eax,r10d
  1417. mov rcx,r11
  1418. movups XMMWORD[rsi],xmm2
  1419. lea rsi,[16+rsi]
  1420. sub rdx,16
  1421. jnc NEAR $L$cbc_enc_loop
  1422. add rdx,16
  1423. jnz NEAR $L$cbc_enc_tail
  1424. pxor xmm0,xmm0
  1425. pxor xmm1,xmm1
  1426. movups XMMWORD[r8],xmm2
  1427. pxor xmm2,xmm2
  1428. pxor xmm3,xmm3
  1429. jmp NEAR $L$cbc_ret
  1430. $L$cbc_enc_tail:
  1431. mov rcx,rdx
  1432. xchg rsi,rdi
  1433. DD 0x9066A4F3
  1434. mov ecx,16
  1435. sub rcx,rdx
  1436. xor eax,eax
  1437. DD 0x9066AAF3
  1438. lea rdi,[((-16))+rdi]
  1439. mov eax,r10d
  1440. mov rsi,rdi
  1441. mov rcx,r11
  1442. xor rdx,rdx
  1443. jmp NEAR $L$cbc_enc_loop
  1444. ALIGN 16
  1445. $L$cbc_decrypt:
  1446. cmp rdx,16
  1447. jne NEAR $L$cbc_decrypt_bulk
  1448. movdqu xmm2,XMMWORD[rdi]
  1449. movdqu xmm3,XMMWORD[r8]
  1450. movdqa xmm4,xmm2
  1451. movups xmm0,XMMWORD[rcx]
  1452. movups xmm1,XMMWORD[16+rcx]
  1453. lea rcx,[32+rcx]
  1454. xorps xmm2,xmm0
  1455. $L$oop_dec1_7:
  1456. DB 102,15,56,222,209
  1457. dec r10d
  1458. movups xmm1,XMMWORD[rcx]
  1459. lea rcx,[16+rcx]
  1460. jnz NEAR $L$oop_dec1_7
  1461. DB 102,15,56,223,209
  1462. pxor xmm0,xmm0
  1463. pxor xmm1,xmm1
  1464. movdqu XMMWORD[r8],xmm4
  1465. xorps xmm2,xmm3
  1466. pxor xmm3,xmm3
  1467. movups XMMWORD[rsi],xmm2
  1468. pxor xmm2,xmm2
  1469. jmp NEAR $L$cbc_ret
  1470. ALIGN 16
  1471. $L$cbc_decrypt_bulk:
  1472. lea r11,[rsp]
  1473. push rbp
  1474. sub rsp,176
  1475. and rsp,-16
  1476. movaps XMMWORD[16+rsp],xmm6
  1477. movaps XMMWORD[32+rsp],xmm7
  1478. movaps XMMWORD[48+rsp],xmm8
  1479. movaps XMMWORD[64+rsp],xmm9
  1480. movaps XMMWORD[80+rsp],xmm10
  1481. movaps XMMWORD[96+rsp],xmm11
  1482. movaps XMMWORD[112+rsp],xmm12
  1483. movaps XMMWORD[128+rsp],xmm13
  1484. movaps XMMWORD[144+rsp],xmm14
  1485. movaps XMMWORD[160+rsp],xmm15
  1486. $L$cbc_decrypt_body:
  1487. mov rbp,rcx
  1488. movups xmm10,XMMWORD[r8]
  1489. mov eax,r10d
  1490. cmp rdx,0x50
  1491. jbe NEAR $L$cbc_dec_tail
  1492. movups xmm0,XMMWORD[rcx]
  1493. movdqu xmm2,XMMWORD[rdi]
  1494. movdqu xmm3,XMMWORD[16+rdi]
  1495. movdqa xmm11,xmm2
  1496. movdqu xmm4,XMMWORD[32+rdi]
  1497. movdqa xmm12,xmm3
  1498. movdqu xmm5,XMMWORD[48+rdi]
  1499. movdqa xmm13,xmm4
  1500. movdqu xmm6,XMMWORD[64+rdi]
  1501. movdqa xmm14,xmm5
  1502. movdqu xmm7,XMMWORD[80+rdi]
  1503. movdqa xmm15,xmm6
  1504. lea r9,[OPENSSL_ia32cap_P]
  1505. mov r9d,DWORD[4+r9]
  1506. cmp rdx,0x70
  1507. jbe NEAR $L$cbc_dec_six_or_seven
  1508. and r9d,71303168
  1509. sub rdx,0x50
  1510. cmp r9d,4194304
  1511. je NEAR $L$cbc_dec_loop6_enter
  1512. sub rdx,0x20
  1513. lea rcx,[112+rcx]
  1514. jmp NEAR $L$cbc_dec_loop8_enter
  1515. ALIGN 16
  1516. $L$cbc_dec_loop8:
  1517. movups XMMWORD[rsi],xmm9
  1518. lea rsi,[16+rsi]
  1519. $L$cbc_dec_loop8_enter:
  1520. movdqu xmm8,XMMWORD[96+rdi]
  1521. pxor xmm2,xmm0
  1522. movdqu xmm9,XMMWORD[112+rdi]
  1523. pxor xmm3,xmm0
  1524. movups xmm1,XMMWORD[((16-112))+rcx]
  1525. pxor xmm4,xmm0
  1526. mov rbp,-1
  1527. cmp rdx,0x70
  1528. pxor xmm5,xmm0
  1529. pxor xmm6,xmm0
  1530. pxor xmm7,xmm0
  1531. pxor xmm8,xmm0
  1532. DB 102,15,56,222,209
  1533. pxor xmm9,xmm0
  1534. movups xmm0,XMMWORD[((32-112))+rcx]
  1535. DB 102,15,56,222,217
  1536. DB 102,15,56,222,225
  1537. DB 102,15,56,222,233
  1538. DB 102,15,56,222,241
  1539. DB 102,15,56,222,249
  1540. DB 102,68,15,56,222,193
  1541. adc rbp,0
  1542. and rbp,128
  1543. DB 102,68,15,56,222,201
  1544. add rbp,rdi
  1545. movups xmm1,XMMWORD[((48-112))+rcx]
  1546. DB 102,15,56,222,208
  1547. DB 102,15,56,222,216
  1548. DB 102,15,56,222,224
  1549. DB 102,15,56,222,232
  1550. DB 102,15,56,222,240
  1551. DB 102,15,56,222,248
  1552. DB 102,68,15,56,222,192
  1553. DB 102,68,15,56,222,200
  1554. movups xmm0,XMMWORD[((64-112))+rcx]
  1555. nop
  1556. DB 102,15,56,222,209
  1557. DB 102,15,56,222,217
  1558. DB 102,15,56,222,225
  1559. DB 102,15,56,222,233
  1560. DB 102,15,56,222,241
  1561. DB 102,15,56,222,249
  1562. DB 102,68,15,56,222,193
  1563. DB 102,68,15,56,222,201
  1564. movups xmm1,XMMWORD[((80-112))+rcx]
  1565. nop
  1566. DB 102,15,56,222,208
  1567. DB 102,15,56,222,216
  1568. DB 102,15,56,222,224
  1569. DB 102,15,56,222,232
  1570. DB 102,15,56,222,240
  1571. DB 102,15,56,222,248
  1572. DB 102,68,15,56,222,192
  1573. DB 102,68,15,56,222,200
  1574. movups xmm0,XMMWORD[((96-112))+rcx]
  1575. nop
  1576. DB 102,15,56,222,209
  1577. DB 102,15,56,222,217
  1578. DB 102,15,56,222,225
  1579. DB 102,15,56,222,233
  1580. DB 102,15,56,222,241
  1581. DB 102,15,56,222,249
  1582. DB 102,68,15,56,222,193
  1583. DB 102,68,15,56,222,201
  1584. movups xmm1,XMMWORD[((112-112))+rcx]
  1585. nop
  1586. DB 102,15,56,222,208
  1587. DB 102,15,56,222,216
  1588. DB 102,15,56,222,224
  1589. DB 102,15,56,222,232
  1590. DB 102,15,56,222,240
  1591. DB 102,15,56,222,248
  1592. DB 102,68,15,56,222,192
  1593. DB 102,68,15,56,222,200
  1594. movups xmm0,XMMWORD[((128-112))+rcx]
  1595. nop
  1596. DB 102,15,56,222,209
  1597. DB 102,15,56,222,217
  1598. DB 102,15,56,222,225
  1599. DB 102,15,56,222,233
  1600. DB 102,15,56,222,241
  1601. DB 102,15,56,222,249
  1602. DB 102,68,15,56,222,193
  1603. DB 102,68,15,56,222,201
  1604. movups xmm1,XMMWORD[((144-112))+rcx]
  1605. cmp eax,11
  1606. DB 102,15,56,222,208
  1607. DB 102,15,56,222,216
  1608. DB 102,15,56,222,224
  1609. DB 102,15,56,222,232
  1610. DB 102,15,56,222,240
  1611. DB 102,15,56,222,248
  1612. DB 102,68,15,56,222,192
  1613. DB 102,68,15,56,222,200
  1614. movups xmm0,XMMWORD[((160-112))+rcx]
  1615. jb NEAR $L$cbc_dec_done
  1616. DB 102,15,56,222,209
  1617. DB 102,15,56,222,217
  1618. DB 102,15,56,222,225
  1619. DB 102,15,56,222,233
  1620. DB 102,15,56,222,241
  1621. DB 102,15,56,222,249
  1622. DB 102,68,15,56,222,193
  1623. DB 102,68,15,56,222,201
  1624. movups xmm1,XMMWORD[((176-112))+rcx]
  1625. nop
  1626. DB 102,15,56,222,208
  1627. DB 102,15,56,222,216
  1628. DB 102,15,56,222,224
  1629. DB 102,15,56,222,232
  1630. DB 102,15,56,222,240
  1631. DB 102,15,56,222,248
  1632. DB 102,68,15,56,222,192
  1633. DB 102,68,15,56,222,200
  1634. movups xmm0,XMMWORD[((192-112))+rcx]
  1635. je NEAR $L$cbc_dec_done
  1636. DB 102,15,56,222,209
  1637. DB 102,15,56,222,217
  1638. DB 102,15,56,222,225
  1639. DB 102,15,56,222,233
  1640. DB 102,15,56,222,241
  1641. DB 102,15,56,222,249
  1642. DB 102,68,15,56,222,193
  1643. DB 102,68,15,56,222,201
  1644. movups xmm1,XMMWORD[((208-112))+rcx]
  1645. nop
  1646. DB 102,15,56,222,208
  1647. DB 102,15,56,222,216
  1648. DB 102,15,56,222,224
  1649. DB 102,15,56,222,232
  1650. DB 102,15,56,222,240
  1651. DB 102,15,56,222,248
  1652. DB 102,68,15,56,222,192
  1653. DB 102,68,15,56,222,200
  1654. movups xmm0,XMMWORD[((224-112))+rcx]
  1655. jmp NEAR $L$cbc_dec_done
  1656. ALIGN 16
  1657. $L$cbc_dec_done:
  1658. DB 102,15,56,222,209
  1659. DB 102,15,56,222,217
  1660. pxor xmm10,xmm0
  1661. pxor xmm11,xmm0
  1662. DB 102,15,56,222,225
  1663. DB 102,15,56,222,233
  1664. pxor xmm12,xmm0
  1665. pxor xmm13,xmm0
  1666. DB 102,15,56,222,241
  1667. DB 102,15,56,222,249
  1668. pxor xmm14,xmm0
  1669. pxor xmm15,xmm0
  1670. DB 102,68,15,56,222,193
  1671. DB 102,68,15,56,222,201
  1672. movdqu xmm1,XMMWORD[80+rdi]
  1673. DB 102,65,15,56,223,210
  1674. movdqu xmm10,XMMWORD[96+rdi]
  1675. pxor xmm1,xmm0
  1676. DB 102,65,15,56,223,219
  1677. pxor xmm10,xmm0
  1678. movdqu xmm0,XMMWORD[112+rdi]
  1679. DB 102,65,15,56,223,228
  1680. lea rdi,[128+rdi]
  1681. movdqu xmm11,XMMWORD[rbp]
  1682. DB 102,65,15,56,223,237
  1683. DB 102,65,15,56,223,246
  1684. movdqu xmm12,XMMWORD[16+rbp]
  1685. movdqu xmm13,XMMWORD[32+rbp]
  1686. DB 102,65,15,56,223,255
  1687. DB 102,68,15,56,223,193
  1688. movdqu xmm14,XMMWORD[48+rbp]
  1689. movdqu xmm15,XMMWORD[64+rbp]
  1690. DB 102,69,15,56,223,202
  1691. movdqa xmm10,xmm0
  1692. movdqu xmm1,XMMWORD[80+rbp]
  1693. movups xmm0,XMMWORD[((-112))+rcx]
  1694. movups XMMWORD[rsi],xmm2
  1695. movdqa xmm2,xmm11
  1696. movups XMMWORD[16+rsi],xmm3
  1697. movdqa xmm3,xmm12
  1698. movups XMMWORD[32+rsi],xmm4
  1699. movdqa xmm4,xmm13
  1700. movups XMMWORD[48+rsi],xmm5
  1701. movdqa xmm5,xmm14
  1702. movups XMMWORD[64+rsi],xmm6
  1703. movdqa xmm6,xmm15
  1704. movups XMMWORD[80+rsi],xmm7
  1705. movdqa xmm7,xmm1
  1706. movups XMMWORD[96+rsi],xmm8
  1707. lea rsi,[112+rsi]
  1708. sub rdx,0x80
  1709. ja NEAR $L$cbc_dec_loop8
  1710. movaps xmm2,xmm9
  1711. lea rcx,[((-112))+rcx]
  1712. add rdx,0x70
  1713. jle NEAR $L$cbc_dec_clear_tail_collected
  1714. movups XMMWORD[rsi],xmm9
  1715. lea rsi,[16+rsi]
  1716. cmp rdx,0x50
  1717. jbe NEAR $L$cbc_dec_tail
  1718. movaps xmm2,xmm11
  1719. $L$cbc_dec_six_or_seven:
  1720. cmp rdx,0x60
  1721. ja NEAR $L$cbc_dec_seven
  1722. movaps xmm8,xmm7
  1723. call _aesni_decrypt6
  1724. pxor xmm2,xmm10
  1725. movaps xmm10,xmm8
  1726. pxor xmm3,xmm11
  1727. movdqu XMMWORD[rsi],xmm2
  1728. pxor xmm4,xmm12
  1729. movdqu XMMWORD[16+rsi],xmm3
  1730. pxor xmm3,xmm3
  1731. pxor xmm5,xmm13
  1732. movdqu XMMWORD[32+rsi],xmm4
  1733. pxor xmm4,xmm4
  1734. pxor xmm6,xmm14
  1735. movdqu XMMWORD[48+rsi],xmm5
  1736. pxor xmm5,xmm5
  1737. pxor xmm7,xmm15
  1738. movdqu XMMWORD[64+rsi],xmm6
  1739. pxor xmm6,xmm6
  1740. lea rsi,[80+rsi]
  1741. movdqa xmm2,xmm7
  1742. pxor xmm7,xmm7
  1743. jmp NEAR $L$cbc_dec_tail_collected
  1744. ALIGN 16
  1745. $L$cbc_dec_seven:
  1746. movups xmm8,XMMWORD[96+rdi]
  1747. xorps xmm9,xmm9
  1748. call _aesni_decrypt8
  1749. movups xmm9,XMMWORD[80+rdi]
  1750. pxor xmm2,xmm10
  1751. movups xmm10,XMMWORD[96+rdi]
  1752. pxor xmm3,xmm11
  1753. movdqu XMMWORD[rsi],xmm2
  1754. pxor xmm4,xmm12
  1755. movdqu XMMWORD[16+rsi],xmm3
  1756. pxor xmm3,xmm3
  1757. pxor xmm5,xmm13
  1758. movdqu XMMWORD[32+rsi],xmm4
  1759. pxor xmm4,xmm4
  1760. pxor xmm6,xmm14
  1761. movdqu XMMWORD[48+rsi],xmm5
  1762. pxor xmm5,xmm5
  1763. pxor xmm7,xmm15
  1764. movdqu XMMWORD[64+rsi],xmm6
  1765. pxor xmm6,xmm6
  1766. pxor xmm8,xmm9
  1767. movdqu XMMWORD[80+rsi],xmm7
  1768. pxor xmm7,xmm7
  1769. lea rsi,[96+rsi]
  1770. movdqa xmm2,xmm8
  1771. pxor xmm8,xmm8
  1772. pxor xmm9,xmm9
  1773. jmp NEAR $L$cbc_dec_tail_collected
  1774. ALIGN 16
  1775. $L$cbc_dec_loop6:
  1776. movups XMMWORD[rsi],xmm7
  1777. lea rsi,[16+rsi]
  1778. movdqu xmm2,XMMWORD[rdi]
  1779. movdqu xmm3,XMMWORD[16+rdi]
  1780. movdqa xmm11,xmm2
  1781. movdqu xmm4,XMMWORD[32+rdi]
  1782. movdqa xmm12,xmm3
  1783. movdqu xmm5,XMMWORD[48+rdi]
  1784. movdqa xmm13,xmm4
  1785. movdqu xmm6,XMMWORD[64+rdi]
  1786. movdqa xmm14,xmm5
  1787. movdqu xmm7,XMMWORD[80+rdi]
  1788. movdqa xmm15,xmm6
  1789. $L$cbc_dec_loop6_enter:
  1790. lea rdi,[96+rdi]
  1791. movdqa xmm8,xmm7
  1792. call _aesni_decrypt6
  1793. pxor xmm2,xmm10
  1794. movdqa xmm10,xmm8
  1795. pxor xmm3,xmm11
  1796. movdqu XMMWORD[rsi],xmm2
  1797. pxor xmm4,xmm12
  1798. movdqu XMMWORD[16+rsi],xmm3
  1799. pxor xmm5,xmm13
  1800. movdqu XMMWORD[32+rsi],xmm4
  1801. pxor xmm6,xmm14
  1802. mov rcx,rbp
  1803. movdqu XMMWORD[48+rsi],xmm5
  1804. pxor xmm7,xmm15
  1805. mov eax,r10d
  1806. movdqu XMMWORD[64+rsi],xmm6
  1807. lea rsi,[80+rsi]
  1808. sub rdx,0x60
  1809. ja NEAR $L$cbc_dec_loop6
  1810. movdqa xmm2,xmm7
  1811. add rdx,0x50
  1812. jle NEAR $L$cbc_dec_clear_tail_collected
  1813. movups XMMWORD[rsi],xmm7
  1814. lea rsi,[16+rsi]
  1815. $L$cbc_dec_tail:
  1816. movups xmm2,XMMWORD[rdi]
  1817. sub rdx,0x10
  1818. jbe NEAR $L$cbc_dec_one
  1819. movups xmm3,XMMWORD[16+rdi]
  1820. movaps xmm11,xmm2
  1821. sub rdx,0x10
  1822. jbe NEAR $L$cbc_dec_two
  1823. movups xmm4,XMMWORD[32+rdi]
  1824. movaps xmm12,xmm3
  1825. sub rdx,0x10
  1826. jbe NEAR $L$cbc_dec_three
  1827. movups xmm5,XMMWORD[48+rdi]
  1828. movaps xmm13,xmm4
  1829. sub rdx,0x10
  1830. jbe NEAR $L$cbc_dec_four
  1831. movups xmm6,XMMWORD[64+rdi]
  1832. movaps xmm14,xmm5
  1833. movaps xmm15,xmm6
  1834. xorps xmm7,xmm7
  1835. call _aesni_decrypt6
  1836. pxor xmm2,xmm10
  1837. movaps xmm10,xmm15
  1838. pxor xmm3,xmm11
  1839. movdqu XMMWORD[rsi],xmm2
  1840. pxor xmm4,xmm12
  1841. movdqu XMMWORD[16+rsi],xmm3
  1842. pxor xmm3,xmm3
  1843. pxor xmm5,xmm13
  1844. movdqu XMMWORD[32+rsi],xmm4
  1845. pxor xmm4,xmm4
  1846. pxor xmm6,xmm14
  1847. movdqu XMMWORD[48+rsi],xmm5
  1848. pxor xmm5,xmm5
  1849. lea rsi,[64+rsi]
  1850. movdqa xmm2,xmm6
  1851. pxor xmm6,xmm6
  1852. pxor xmm7,xmm7
  1853. sub rdx,0x10
  1854. jmp NEAR $L$cbc_dec_tail_collected
  1855. ALIGN 16
  1856. $L$cbc_dec_one:
  1857. movaps xmm11,xmm2
  1858. movups xmm0,XMMWORD[rcx]
  1859. movups xmm1,XMMWORD[16+rcx]
  1860. lea rcx,[32+rcx]
  1861. xorps xmm2,xmm0
  1862. $L$oop_dec1_8:
  1863. DB 102,15,56,222,209
  1864. dec eax
  1865. movups xmm1,XMMWORD[rcx]
  1866. lea rcx,[16+rcx]
  1867. jnz NEAR $L$oop_dec1_8
  1868. DB 102,15,56,223,209
  1869. xorps xmm2,xmm10
  1870. movaps xmm10,xmm11
  1871. jmp NEAR $L$cbc_dec_tail_collected
  1872. ALIGN 16
  1873. $L$cbc_dec_two:
  1874. movaps xmm12,xmm3
  1875. call _aesni_decrypt2
  1876. pxor xmm2,xmm10
  1877. movaps xmm10,xmm12
  1878. pxor xmm3,xmm11
  1879. movdqu XMMWORD[rsi],xmm2
  1880. movdqa xmm2,xmm3
  1881. pxor xmm3,xmm3
  1882. lea rsi,[16+rsi]
  1883. jmp NEAR $L$cbc_dec_tail_collected
  1884. ALIGN 16
  1885. $L$cbc_dec_three:
  1886. movaps xmm13,xmm4
  1887. call _aesni_decrypt3
  1888. pxor xmm2,xmm10
  1889. movaps xmm10,xmm13
  1890. pxor xmm3,xmm11
  1891. movdqu XMMWORD[rsi],xmm2
  1892. pxor xmm4,xmm12
  1893. movdqu XMMWORD[16+rsi],xmm3
  1894. pxor xmm3,xmm3
  1895. movdqa xmm2,xmm4
  1896. pxor xmm4,xmm4
  1897. lea rsi,[32+rsi]
  1898. jmp NEAR $L$cbc_dec_tail_collected
  1899. ALIGN 16
  1900. $L$cbc_dec_four:
  1901. movaps xmm14,xmm5
  1902. call _aesni_decrypt4
  1903. pxor xmm2,xmm10
  1904. movaps xmm10,xmm14
  1905. pxor xmm3,xmm11
  1906. movdqu XMMWORD[rsi],xmm2
  1907. pxor xmm4,xmm12
  1908. movdqu XMMWORD[16+rsi],xmm3
  1909. pxor xmm3,xmm3
  1910. pxor xmm5,xmm13
  1911. movdqu XMMWORD[32+rsi],xmm4
  1912. pxor xmm4,xmm4
  1913. movdqa xmm2,xmm5
  1914. pxor xmm5,xmm5
  1915. lea rsi,[48+rsi]
  1916. jmp NEAR $L$cbc_dec_tail_collected
  1917. ALIGN 16
  1918. $L$cbc_dec_clear_tail_collected:
  1919. pxor xmm3,xmm3
  1920. pxor xmm4,xmm4
  1921. pxor xmm5,xmm5
  1922. $L$cbc_dec_tail_collected:
  1923. movups XMMWORD[r8],xmm10
  1924. and rdx,15
  1925. jnz NEAR $L$cbc_dec_tail_partial
  1926. movups XMMWORD[rsi],xmm2
  1927. pxor xmm2,xmm2
  1928. jmp NEAR $L$cbc_dec_ret
  1929. ALIGN 16
  1930. $L$cbc_dec_tail_partial:
  1931. movaps XMMWORD[rsp],xmm2
  1932. pxor xmm2,xmm2
  1933. mov rcx,16
  1934. mov rdi,rsi
  1935. sub rcx,rdx
  1936. lea rsi,[rsp]
  1937. DD 0x9066A4F3
  1938. movdqa XMMWORD[rsp],xmm2
  1939. $L$cbc_dec_ret:
  1940. xorps xmm0,xmm0
  1941. pxor xmm1,xmm1
  1942. movaps xmm6,XMMWORD[16+rsp]
  1943. movaps XMMWORD[16+rsp],xmm0
  1944. movaps xmm7,XMMWORD[32+rsp]
  1945. movaps XMMWORD[32+rsp],xmm0
  1946. movaps xmm8,XMMWORD[48+rsp]
  1947. movaps XMMWORD[48+rsp],xmm0
  1948. movaps xmm9,XMMWORD[64+rsp]
  1949. movaps XMMWORD[64+rsp],xmm0
  1950. movaps xmm10,XMMWORD[80+rsp]
  1951. movaps XMMWORD[80+rsp],xmm0
  1952. movaps xmm11,XMMWORD[96+rsp]
  1953. movaps XMMWORD[96+rsp],xmm0
  1954. movaps xmm12,XMMWORD[112+rsp]
  1955. movaps XMMWORD[112+rsp],xmm0
  1956. movaps xmm13,XMMWORD[128+rsp]
  1957. movaps XMMWORD[128+rsp],xmm0
  1958. movaps xmm14,XMMWORD[144+rsp]
  1959. movaps XMMWORD[144+rsp],xmm0
  1960. movaps xmm15,XMMWORD[160+rsp]
  1961. movaps XMMWORD[160+rsp],xmm0
  1962. mov rbp,QWORD[((-8))+r11]
  1963. lea rsp,[r11]
  1964. $L$cbc_ret:
  1965. mov rdi,QWORD[8+rsp] ;WIN64 epilogue
  1966. mov rsi,QWORD[16+rsp]
  1967. DB 0F3h,0C3h ;repret
  1968. $L$SEH_end_aes_hw_cbc_encrypt:
  1969. global aes_hw_set_decrypt_key
  1970. ALIGN 16
  1971. aes_hw_set_decrypt_key:
  1972. DB 0x48,0x83,0xEC,0x08
  1973. call __aesni_set_encrypt_key
  1974. shl edx,4
  1975. test eax,eax
  1976. jnz NEAR $L$dec_key_ret
  1977. lea rcx,[16+rdx*1+r8]
  1978. movups xmm0,XMMWORD[r8]
  1979. movups xmm1,XMMWORD[rcx]
  1980. movups XMMWORD[rcx],xmm0
  1981. movups XMMWORD[r8],xmm1
  1982. lea r8,[16+r8]
  1983. lea rcx,[((-16))+rcx]
  1984. $L$dec_key_inverse:
  1985. movups xmm0,XMMWORD[r8]
  1986. movups xmm1,XMMWORD[rcx]
  1987. DB 102,15,56,219,192
  1988. DB 102,15,56,219,201
  1989. lea r8,[16+r8]
  1990. lea rcx,[((-16))+rcx]
  1991. movups XMMWORD[16+rcx],xmm0
  1992. movups XMMWORD[(-16)+r8],xmm1
  1993. cmp rcx,r8
  1994. ja NEAR $L$dec_key_inverse
  1995. movups xmm0,XMMWORD[r8]
  1996. DB 102,15,56,219,192
  1997. pxor xmm1,xmm1
  1998. movups XMMWORD[rcx],xmm0
  1999. pxor xmm0,xmm0
  2000. $L$dec_key_ret:
  2001. add rsp,8
  2002. DB 0F3h,0C3h ;repret
  2003. $L$SEH_end_set_decrypt_key:
  2004. global aes_hw_set_encrypt_key
  2005. ALIGN 16
  2006. aes_hw_set_encrypt_key:
  2007. __aesni_set_encrypt_key:
  2008. %ifdef BORINGSSL_DISPATCH_TEST
  2009. mov BYTE[((BORINGSSL_function_hit+3))],1
  2010. %endif
  2011. DB 0x48,0x83,0xEC,0x08
  2012. mov rax,-1
  2013. test rcx,rcx
  2014. jz NEAR $L$enc_key_ret
  2015. test r8,r8
  2016. jz NEAR $L$enc_key_ret
  2017. movups xmm0,XMMWORD[rcx]
  2018. xorps xmm4,xmm4
  2019. lea r10,[OPENSSL_ia32cap_P]
  2020. mov r10d,DWORD[4+r10]
  2021. and r10d,268437504
  2022. lea rax,[16+r8]
  2023. cmp edx,256
  2024. je NEAR $L$14rounds
  2025. cmp edx,192
  2026. je NEAR $L$12rounds
  2027. cmp edx,128
  2028. jne NEAR $L$bad_keybits
  2029. $L$10rounds:
  2030. mov edx,9
  2031. cmp r10d,268435456
  2032. je NEAR $L$10rounds_alt
  2033. movups XMMWORD[r8],xmm0
  2034. DB 102,15,58,223,200,1
  2035. call $L$key_expansion_128_cold
  2036. DB 102,15,58,223,200,2
  2037. call $L$key_expansion_128
  2038. DB 102,15,58,223,200,4
  2039. call $L$key_expansion_128
  2040. DB 102,15,58,223,200,8
  2041. call $L$key_expansion_128
  2042. DB 102,15,58,223,200,16
  2043. call $L$key_expansion_128
  2044. DB 102,15,58,223,200,32
  2045. call $L$key_expansion_128
  2046. DB 102,15,58,223,200,64
  2047. call $L$key_expansion_128
  2048. DB 102,15,58,223,200,128
  2049. call $L$key_expansion_128
  2050. DB 102,15,58,223,200,27
  2051. call $L$key_expansion_128
  2052. DB 102,15,58,223,200,54
  2053. call $L$key_expansion_128
  2054. movups XMMWORD[rax],xmm0
  2055. mov DWORD[80+rax],edx
  2056. xor eax,eax
  2057. jmp NEAR $L$enc_key_ret
  2058. ALIGN 16
  2059. $L$10rounds_alt:
  2060. movdqa xmm5,XMMWORD[$L$key_rotate]
  2061. mov r10d,8
  2062. movdqa xmm4,XMMWORD[$L$key_rcon1]
  2063. movdqa xmm2,xmm0
  2064. movdqu XMMWORD[r8],xmm0
  2065. jmp NEAR $L$oop_key128
  2066. ALIGN 16
  2067. $L$oop_key128:
  2068. DB 102,15,56,0,197
  2069. DB 102,15,56,221,196
  2070. pslld xmm4,1
  2071. lea rax,[16+rax]
  2072. movdqa xmm3,xmm2
  2073. pslldq xmm2,4
  2074. pxor xmm3,xmm2
  2075. pslldq xmm2,4
  2076. pxor xmm3,xmm2
  2077. pslldq xmm2,4
  2078. pxor xmm2,xmm3
  2079. pxor xmm0,xmm2
  2080. movdqu XMMWORD[(-16)+rax],xmm0
  2081. movdqa xmm2,xmm0
  2082. dec r10d
  2083. jnz NEAR $L$oop_key128
  2084. movdqa xmm4,XMMWORD[$L$key_rcon1b]
  2085. DB 102,15,56,0,197
  2086. DB 102,15,56,221,196
  2087. pslld xmm4,1
  2088. movdqa xmm3,xmm2
  2089. pslldq xmm2,4
  2090. pxor xmm3,xmm2
  2091. pslldq xmm2,4
  2092. pxor xmm3,xmm2
  2093. pslldq xmm2,4
  2094. pxor xmm2,xmm3
  2095. pxor xmm0,xmm2
  2096. movdqu XMMWORD[rax],xmm0
  2097. movdqa xmm2,xmm0
  2098. DB 102,15,56,0,197
  2099. DB 102,15,56,221,196
  2100. movdqa xmm3,xmm2
  2101. pslldq xmm2,4
  2102. pxor xmm3,xmm2
  2103. pslldq xmm2,4
  2104. pxor xmm3,xmm2
  2105. pslldq xmm2,4
  2106. pxor xmm2,xmm3
  2107. pxor xmm0,xmm2
  2108. movdqu XMMWORD[16+rax],xmm0
  2109. mov DWORD[96+rax],edx
  2110. xor eax,eax
  2111. jmp NEAR $L$enc_key_ret
  2112. ALIGN 16
  2113. $L$12rounds:
  2114. movq xmm2,QWORD[16+rcx]
  2115. mov edx,11
  2116. cmp r10d,268435456
  2117. je NEAR $L$12rounds_alt
  2118. movups XMMWORD[r8],xmm0
  2119. DB 102,15,58,223,202,1
  2120. call $L$key_expansion_192a_cold
  2121. DB 102,15,58,223,202,2
  2122. call $L$key_expansion_192b
  2123. DB 102,15,58,223,202,4
  2124. call $L$key_expansion_192a
  2125. DB 102,15,58,223,202,8
  2126. call $L$key_expansion_192b
  2127. DB 102,15,58,223,202,16
  2128. call $L$key_expansion_192a
  2129. DB 102,15,58,223,202,32
  2130. call $L$key_expansion_192b
  2131. DB 102,15,58,223,202,64
  2132. call $L$key_expansion_192a
  2133. DB 102,15,58,223,202,128
  2134. call $L$key_expansion_192b
  2135. movups XMMWORD[rax],xmm0
  2136. mov DWORD[48+rax],edx
  2137. xor rax,rax
  2138. jmp NEAR $L$enc_key_ret
  2139. ALIGN 16
  2140. $L$12rounds_alt:
  2141. movdqa xmm5,XMMWORD[$L$key_rotate192]
  2142. movdqa xmm4,XMMWORD[$L$key_rcon1]
  2143. mov r10d,8
  2144. movdqu XMMWORD[r8],xmm0
  2145. jmp NEAR $L$oop_key192
  2146. ALIGN 16
  2147. $L$oop_key192:
  2148. movq QWORD[rax],xmm2
  2149. movdqa xmm1,xmm2
  2150. DB 102,15,56,0,213
  2151. DB 102,15,56,221,212
  2152. pslld xmm4,1
  2153. lea rax,[24+rax]
  2154. movdqa xmm3,xmm0
  2155. pslldq xmm0,4
  2156. pxor xmm3,xmm0
  2157. pslldq xmm0,4
  2158. pxor xmm3,xmm0
  2159. pslldq xmm0,4
  2160. pxor xmm0,xmm3
  2161. pshufd xmm3,xmm0,0xff
  2162. pxor xmm3,xmm1
  2163. pslldq xmm1,4
  2164. pxor xmm3,xmm1
  2165. pxor xmm0,xmm2
  2166. pxor xmm2,xmm3
  2167. movdqu XMMWORD[(-16)+rax],xmm0
  2168. dec r10d
  2169. jnz NEAR $L$oop_key192
  2170. mov DWORD[32+rax],edx
  2171. xor eax,eax
  2172. jmp NEAR $L$enc_key_ret
  2173. ALIGN 16
  2174. $L$14rounds:
  2175. movups xmm2,XMMWORD[16+rcx]
  2176. mov edx,13
  2177. lea rax,[16+rax]
  2178. cmp r10d,268435456
  2179. je NEAR $L$14rounds_alt
  2180. movups XMMWORD[r8],xmm0
  2181. movups XMMWORD[16+r8],xmm2
  2182. DB 102,15,58,223,202,1
  2183. call $L$key_expansion_256a_cold
  2184. DB 102,15,58,223,200,1
  2185. call $L$key_expansion_256b
  2186. DB 102,15,58,223,202,2
  2187. call $L$key_expansion_256a
  2188. DB 102,15,58,223,200,2
  2189. call $L$key_expansion_256b
  2190. DB 102,15,58,223,202,4
  2191. call $L$key_expansion_256a
  2192. DB 102,15,58,223,200,4
  2193. call $L$key_expansion_256b
  2194. DB 102,15,58,223,202,8
  2195. call $L$key_expansion_256a
  2196. DB 102,15,58,223,200,8
  2197. call $L$key_expansion_256b
  2198. DB 102,15,58,223,202,16
  2199. call $L$key_expansion_256a
  2200. DB 102,15,58,223,200,16
  2201. call $L$key_expansion_256b
  2202. DB 102,15,58,223,202,32
  2203. call $L$key_expansion_256a
  2204. DB 102,15,58,223,200,32
  2205. call $L$key_expansion_256b
  2206. DB 102,15,58,223,202,64
  2207. call $L$key_expansion_256a
  2208. movups XMMWORD[rax],xmm0
  2209. mov DWORD[16+rax],edx
  2210. xor rax,rax
  2211. jmp NEAR $L$enc_key_ret
  2212. ALIGN 16
  2213. $L$14rounds_alt:
  2214. movdqa xmm5,XMMWORD[$L$key_rotate]
  2215. movdqa xmm4,XMMWORD[$L$key_rcon1]
  2216. mov r10d,7
  2217. movdqu XMMWORD[r8],xmm0
  2218. movdqa xmm1,xmm2
  2219. movdqu XMMWORD[16+r8],xmm2
  2220. jmp NEAR $L$oop_key256
  2221. ALIGN 16
  2222. $L$oop_key256:
  2223. DB 102,15,56,0,213
  2224. DB 102,15,56,221,212
  2225. movdqa xmm3,xmm0
  2226. pslldq xmm0,4
  2227. pxor xmm3,xmm0
  2228. pslldq xmm0,4
  2229. pxor xmm3,xmm0
  2230. pslldq xmm0,4
  2231. pxor xmm0,xmm3
  2232. pslld xmm4,1
  2233. pxor xmm0,xmm2
  2234. movdqu XMMWORD[rax],xmm0
  2235. dec r10d
  2236. jz NEAR $L$done_key256
  2237. pshufd xmm2,xmm0,0xff
  2238. pxor xmm3,xmm3
  2239. DB 102,15,56,221,211
  2240. movdqa xmm3,xmm1
  2241. pslldq xmm1,4
  2242. pxor xmm3,xmm1
  2243. pslldq xmm1,4
  2244. pxor xmm3,xmm1
  2245. pslldq xmm1,4
  2246. pxor xmm1,xmm3
  2247. pxor xmm2,xmm1
  2248. movdqu XMMWORD[16+rax],xmm2
  2249. lea rax,[32+rax]
  2250. movdqa xmm1,xmm2
  2251. jmp NEAR $L$oop_key256
  2252. $L$done_key256:
  2253. mov DWORD[16+rax],edx
  2254. xor eax,eax
  2255. jmp NEAR $L$enc_key_ret
  2256. ALIGN 16
  2257. $L$bad_keybits:
  2258. mov rax,-2
  2259. $L$enc_key_ret:
  2260. pxor xmm0,xmm0
  2261. pxor xmm1,xmm1
  2262. pxor xmm2,xmm2
  2263. pxor xmm3,xmm3
  2264. pxor xmm4,xmm4
  2265. pxor xmm5,xmm5
  2266. add rsp,8
  2267. DB 0F3h,0C3h ;repret
  2268. $L$SEH_end_set_encrypt_key:
  2269. ALIGN 16
  2270. $L$key_expansion_128:
  2271. movups XMMWORD[rax],xmm0
  2272. lea rax,[16+rax]
  2273. $L$key_expansion_128_cold:
  2274. shufps xmm4,xmm0,16
  2275. xorps xmm0,xmm4
  2276. shufps xmm4,xmm0,140
  2277. xorps xmm0,xmm4
  2278. shufps xmm1,xmm1,255
  2279. xorps xmm0,xmm1
  2280. DB 0F3h,0C3h ;repret
  2281. ALIGN 16
  2282. $L$key_expansion_192a:
  2283. movups XMMWORD[rax],xmm0
  2284. lea rax,[16+rax]
  2285. $L$key_expansion_192a_cold:
  2286. movaps xmm5,xmm2
  2287. $L$key_expansion_192b_warm:
  2288. shufps xmm4,xmm0,16
  2289. movdqa xmm3,xmm2
  2290. xorps xmm0,xmm4
  2291. shufps xmm4,xmm0,140
  2292. pslldq xmm3,4
  2293. xorps xmm0,xmm4
  2294. pshufd xmm1,xmm1,85
  2295. pxor xmm2,xmm3
  2296. pxor xmm0,xmm1
  2297. pshufd xmm3,xmm0,255
  2298. pxor xmm2,xmm3
  2299. DB 0F3h,0C3h ;repret
  2300. ALIGN 16
  2301. $L$key_expansion_192b:
  2302. movaps xmm3,xmm0
  2303. shufps xmm5,xmm0,68
  2304. movups XMMWORD[rax],xmm5
  2305. shufps xmm3,xmm2,78
  2306. movups XMMWORD[16+rax],xmm3
  2307. lea rax,[32+rax]
  2308. jmp NEAR $L$key_expansion_192b_warm
  2309. ALIGN 16
  2310. $L$key_expansion_256a:
  2311. movups XMMWORD[rax],xmm2
  2312. lea rax,[16+rax]
  2313. $L$key_expansion_256a_cold:
  2314. shufps xmm4,xmm0,16
  2315. xorps xmm0,xmm4
  2316. shufps xmm4,xmm0,140
  2317. xorps xmm0,xmm4
  2318. shufps xmm1,xmm1,255
  2319. xorps xmm0,xmm1
  2320. DB 0F3h,0C3h ;repret
  2321. ALIGN 16
  2322. $L$key_expansion_256b:
  2323. movups XMMWORD[rax],xmm0
  2324. lea rax,[16+rax]
  2325. shufps xmm4,xmm2,16
  2326. xorps xmm2,xmm4
  2327. shufps xmm4,xmm2,140
  2328. xorps xmm2,xmm4
  2329. shufps xmm1,xmm1,170
  2330. xorps xmm2,xmm1
  2331. DB 0F3h,0C3h ;repret
  2332. ALIGN 64
  2333. $L$bswap_mask:
  2334. DB 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
  2335. $L$increment32:
  2336. DD 6,6,6,0
  2337. $L$increment64:
  2338. DD 1,0,0,0
  2339. $L$xts_magic:
  2340. DD 0x87,0,1,0
  2341. $L$increment1:
  2342. DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
  2343. $L$key_rotate:
  2344. DD 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d
  2345. $L$key_rotate192:
  2346. DD 0x04070605,0x04070605,0x04070605,0x04070605
  2347. $L$key_rcon1:
  2348. DD 1,1,1,1
  2349. $L$key_rcon1b:
  2350. DD 0x1b,0x1b,0x1b,0x1b
  2351. DB 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69
  2352. DB 83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83
  2353. DB 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115
  2354. DB 115,108,46,111,114,103,62,0
  2355. ALIGN 64
  2356. EXTERN __imp_RtlVirtualUnwind
  2357. ALIGN 16
  2358. ecb_ccm64_se_handler:
  2359. push rsi
  2360. push rdi
  2361. push rbx
  2362. push rbp
  2363. push r12
  2364. push r13
  2365. push r14
  2366. push r15
  2367. pushfq
  2368. sub rsp,64
  2369. mov rax,QWORD[120+r8]
  2370. mov rbx,QWORD[248+r8]
  2371. mov rsi,QWORD[8+r9]
  2372. mov r11,QWORD[56+r9]
  2373. mov r10d,DWORD[r11]
  2374. lea r10,[r10*1+rsi]
  2375. cmp rbx,r10
  2376. jb NEAR $L$common_seh_tail
  2377. mov rax,QWORD[152+r8]
  2378. mov r10d,DWORD[4+r11]
  2379. lea r10,[r10*1+rsi]
  2380. cmp rbx,r10
  2381. jae NEAR $L$common_seh_tail
  2382. lea rsi,[rax]
  2383. lea rdi,[512+r8]
  2384. mov ecx,8
  2385. DD 0xa548f3fc
  2386. lea rax,[88+rax]
  2387. jmp NEAR $L$common_seh_tail
  2388. ALIGN 16
  2389. ctr_xts_se_handler:
  2390. push rsi
  2391. push rdi
  2392. push rbx
  2393. push rbp
  2394. push r12
  2395. push r13
  2396. push r14
  2397. push r15
  2398. pushfq
  2399. sub rsp,64
  2400. mov rax,QWORD[120+r8]
  2401. mov rbx,QWORD[248+r8]
  2402. mov rsi,QWORD[8+r9]
  2403. mov r11,QWORD[56+r9]
  2404. mov r10d,DWORD[r11]
  2405. lea r10,[r10*1+rsi]
  2406. cmp rbx,r10
  2407. jb NEAR $L$common_seh_tail
  2408. mov rax,QWORD[152+r8]
  2409. mov r10d,DWORD[4+r11]
  2410. lea r10,[r10*1+rsi]
  2411. cmp rbx,r10
  2412. jae NEAR $L$common_seh_tail
  2413. mov rax,QWORD[208+r8]
  2414. lea rsi,[((-168))+rax]
  2415. lea rdi,[512+r8]
  2416. mov ecx,20
  2417. DD 0xa548f3fc
  2418. mov rbp,QWORD[((-8))+rax]
  2419. mov QWORD[160+r8],rbp
  2420. jmp NEAR $L$common_seh_tail
  2421. ALIGN 16
  2422. cbc_se_handler:
  2423. push rsi
  2424. push rdi
  2425. push rbx
  2426. push rbp
  2427. push r12
  2428. push r13
  2429. push r14
  2430. push r15
  2431. pushfq
  2432. sub rsp,64
  2433. mov rax,QWORD[152+r8]
  2434. mov rbx,QWORD[248+r8]
  2435. lea r10,[$L$cbc_decrypt_bulk]
  2436. cmp rbx,r10
  2437. jb NEAR $L$common_seh_tail
  2438. mov rax,QWORD[120+r8]
  2439. lea r10,[$L$cbc_decrypt_body]
  2440. cmp rbx,r10
  2441. jb NEAR $L$common_seh_tail
  2442. mov rax,QWORD[152+r8]
  2443. lea r10,[$L$cbc_ret]
  2444. cmp rbx,r10
  2445. jae NEAR $L$common_seh_tail
  2446. lea rsi,[16+rax]
  2447. lea rdi,[512+r8]
  2448. mov ecx,20
  2449. DD 0xa548f3fc
  2450. mov rax,QWORD[208+r8]
  2451. mov rbp,QWORD[((-8))+rax]
  2452. mov QWORD[160+r8],rbp
  2453. $L$common_seh_tail:
  2454. mov rdi,QWORD[8+rax]
  2455. mov rsi,QWORD[16+rax]
  2456. mov QWORD[152+r8],rax
  2457. mov QWORD[168+r8],rsi
  2458. mov QWORD[176+r8],rdi
  2459. mov rdi,QWORD[40+r9]
  2460. mov rsi,r8
  2461. mov ecx,154
  2462. DD 0xa548f3fc
  2463. mov rsi,r9
  2464. xor rcx,rcx
  2465. mov rdx,QWORD[8+rsi]
  2466. mov r8,QWORD[rsi]
  2467. mov r9,QWORD[16+rsi]
  2468. mov r10,QWORD[40+rsi]
  2469. lea r11,[56+rsi]
  2470. lea r12,[24+rsi]
  2471. mov QWORD[32+rsp],r10
  2472. mov QWORD[40+rsp],r11
  2473. mov QWORD[48+rsp],r12
  2474. mov QWORD[56+rsp],rcx
  2475. call QWORD[__imp_RtlVirtualUnwind]
  2476. mov eax,1
  2477. add rsp,64
  2478. popfq
  2479. pop r15
  2480. pop r14
  2481. pop r13
  2482. pop r12
  2483. pop rbp
  2484. pop rbx
  2485. pop rdi
  2486. pop rsi
  2487. DB 0F3h,0C3h ;repret
  2488. section .pdata rdata align=4
  2489. ALIGN 4
  2490. DD $L$SEH_begin_aes_hw_ecb_encrypt wrt ..imagebase
  2491. DD $L$SEH_end_aes_hw_ecb_encrypt wrt ..imagebase
  2492. DD $L$SEH_info_ecb wrt ..imagebase
  2493. DD $L$SEH_begin_aes_hw_ctr32_encrypt_blocks wrt ..imagebase
  2494. DD $L$SEH_end_aes_hw_ctr32_encrypt_blocks wrt ..imagebase
  2495. DD $L$SEH_info_ctr32 wrt ..imagebase
  2496. DD $L$SEH_begin_aes_hw_cbc_encrypt wrt ..imagebase
  2497. DD $L$SEH_end_aes_hw_cbc_encrypt wrt ..imagebase
  2498. DD $L$SEH_info_cbc wrt ..imagebase
  2499. DD aes_hw_set_decrypt_key wrt ..imagebase
  2500. DD $L$SEH_end_set_decrypt_key wrt ..imagebase
  2501. DD $L$SEH_info_key wrt ..imagebase
  2502. DD aes_hw_set_encrypt_key wrt ..imagebase
  2503. DD $L$SEH_end_set_encrypt_key wrt ..imagebase
  2504. DD $L$SEH_info_key wrt ..imagebase
  2505. section .xdata rdata align=8
  2506. ALIGN 8
  2507. $L$SEH_info_ecb:
  2508. DB 9,0,0,0
  2509. DD ecb_ccm64_se_handler wrt ..imagebase
  2510. DD $L$ecb_enc_body wrt ..imagebase,$L$ecb_enc_ret wrt ..imagebase
  2511. $L$SEH_info_ctr32:
  2512. DB 9,0,0,0
  2513. DD ctr_xts_se_handler wrt ..imagebase
  2514. DD $L$ctr32_body wrt ..imagebase,$L$ctr32_epilogue wrt ..imagebase
  2515. $L$SEH_info_cbc:
  2516. DB 9,0,0,0
  2517. DD cbc_se_handler wrt ..imagebase
  2518. $L$SEH_info_key:
  2519. DB 0x01,0x04,0x01,0x00
  2520. DB 0x04,0x02,0x00,0x00