rc4-586.s 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. .text
  2. .globl RC4
  3. .type RC4,@function
  4. .align 16
  5. RC4:
  6. .L_RC4_begin:
  7. pushl %ebp
  8. pushl %ebx
  9. pushl %esi
  10. pushl %edi
  11. movl 20(%esp),%edi
  12. movl 24(%esp),%edx
  13. movl 28(%esp),%esi
  14. movl 32(%esp),%ebp
  15. xorl %eax,%eax
  16. xorl %ebx,%ebx
  17. cmpl $0,%edx
  18. je .L000abort
  19. movb (%edi),%al
  20. movb 4(%edi),%bl
  21. addl $8,%edi
  22. leal (%esi,%edx,1),%ecx
  23. subl %esi,%ebp
  24. movl %ecx,24(%esp)
  25. incb %al
  26. cmpl $-1,256(%edi)
  27. je .L001RC4_CHAR
  28. movl (%edi,%eax,4),%ecx
  29. andl $-4,%edx
  30. jz .L002loop1
  31. movl %ebp,32(%esp)
  32. testl $-8,%edx
  33. jz .L003go4loop4
  34. call .L004PIC_me_up
  35. .L004PIC_me_up:
  36. popl %ebp
  37. leal OPENSSL_ia32cap_P-.L004PIC_me_up(%ebp),%ebp
  38. btl $26,(%ebp)
  39. jnc .L003go4loop4
  40. movl 32(%esp),%ebp
  41. andl $-8,%edx
  42. leal -8(%esi,%edx,1),%edx
  43. movl %edx,-4(%edi)
  44. addb %cl,%bl
  45. movl (%edi,%ebx,4),%edx
  46. movl %ecx,(%edi,%ebx,4)
  47. movl %edx,(%edi,%eax,4)
  48. incl %eax
  49. addl %ecx,%edx
  50. movzbl %al,%eax
  51. movzbl %dl,%edx
  52. movq (%esi),%mm0
  53. movl (%edi,%eax,4),%ecx
  54. movd (%edi,%edx,4),%mm2
  55. jmp .L005loop_mmx_enter
  56. .align 16
  57. .L006loop_mmx:
  58. addb %cl,%bl
  59. psllq $56,%mm1
  60. movl (%edi,%ebx,4),%edx
  61. movl %ecx,(%edi,%ebx,4)
  62. movl %edx,(%edi,%eax,4)
  63. incl %eax
  64. addl %ecx,%edx
  65. movzbl %al,%eax
  66. movzbl %dl,%edx
  67. pxor %mm1,%mm2
  68. movq (%esi),%mm0
  69. movq %mm2,-8(%ebp,%esi,1)
  70. movl (%edi,%eax,4),%ecx
  71. movd (%edi,%edx,4),%mm2
  72. .L005loop_mmx_enter:
  73. addb %cl,%bl
  74. movl (%edi,%ebx,4),%edx
  75. movl %ecx,(%edi,%ebx,4)
  76. movl %edx,(%edi,%eax,4)
  77. incl %eax
  78. addl %ecx,%edx
  79. movzbl %al,%eax
  80. movzbl %dl,%edx
  81. pxor %mm0,%mm2
  82. movl (%edi,%eax,4),%ecx
  83. movd (%edi,%edx,4),%mm1
  84. addb %cl,%bl
  85. psllq $8,%mm1
  86. movl (%edi,%ebx,4),%edx
  87. movl %ecx,(%edi,%ebx,4)
  88. movl %edx,(%edi,%eax,4)
  89. incl %eax
  90. addl %ecx,%edx
  91. movzbl %al,%eax
  92. movzbl %dl,%edx
  93. pxor %mm1,%mm2
  94. movl (%edi,%eax,4),%ecx
  95. movd (%edi,%edx,4),%mm1
  96. addb %cl,%bl
  97. psllq $16,%mm1
  98. movl (%edi,%ebx,4),%edx
  99. movl %ecx,(%edi,%ebx,4)
  100. movl %edx,(%edi,%eax,4)
  101. incl %eax
  102. addl %ecx,%edx
  103. movzbl %al,%eax
  104. movzbl %dl,%edx
  105. pxor %mm1,%mm2
  106. movl (%edi,%eax,4),%ecx
  107. movd (%edi,%edx,4),%mm1
  108. addb %cl,%bl
  109. psllq $24,%mm1
  110. movl (%edi,%ebx,4),%edx
  111. movl %ecx,(%edi,%ebx,4)
  112. movl %edx,(%edi,%eax,4)
  113. incl %eax
  114. addl %ecx,%edx
  115. movzbl %al,%eax
  116. movzbl %dl,%edx
  117. pxor %mm1,%mm2
  118. movl (%edi,%eax,4),%ecx
  119. movd (%edi,%edx,4),%mm1
  120. addb %cl,%bl
  121. psllq $32,%mm1
  122. movl (%edi,%ebx,4),%edx
  123. movl %ecx,(%edi,%ebx,4)
  124. movl %edx,(%edi,%eax,4)
  125. incl %eax
  126. addl %ecx,%edx
  127. movzbl %al,%eax
  128. movzbl %dl,%edx
  129. pxor %mm1,%mm2
  130. movl (%edi,%eax,4),%ecx
  131. movd (%edi,%edx,4),%mm1
  132. addb %cl,%bl
  133. psllq $40,%mm1
  134. movl (%edi,%ebx,4),%edx
  135. movl %ecx,(%edi,%ebx,4)
  136. movl %edx,(%edi,%eax,4)
  137. incl %eax
  138. addl %ecx,%edx
  139. movzbl %al,%eax
  140. movzbl %dl,%edx
  141. pxor %mm1,%mm2
  142. movl (%edi,%eax,4),%ecx
  143. movd (%edi,%edx,4),%mm1
  144. addb %cl,%bl
  145. psllq $48,%mm1
  146. movl (%edi,%ebx,4),%edx
  147. movl %ecx,(%edi,%ebx,4)
  148. movl %edx,(%edi,%eax,4)
  149. incl %eax
  150. addl %ecx,%edx
  151. movzbl %al,%eax
  152. movzbl %dl,%edx
  153. pxor %mm1,%mm2
  154. movl (%edi,%eax,4),%ecx
  155. movd (%edi,%edx,4),%mm1
  156. movl %ebx,%edx
  157. xorl %ebx,%ebx
  158. movb %dl,%bl
  159. cmpl -4(%edi),%esi
  160. leal 8(%esi),%esi
  161. jb .L006loop_mmx
  162. psllq $56,%mm1
  163. pxor %mm1,%mm2
  164. movq %mm2,-8(%ebp,%esi,1)
  165. emms
  166. cmpl 24(%esp),%esi
  167. je .L007done
  168. jmp .L002loop1
  169. .align 16
  170. .L003go4loop4:
  171. leal -4(%esi,%edx,1),%edx
  172. movl %edx,28(%esp)
  173. .L008loop4:
  174. addb %cl,%bl
  175. movl (%edi,%ebx,4),%edx
  176. movl %ecx,(%edi,%ebx,4)
  177. movl %edx,(%edi,%eax,4)
  178. addl %ecx,%edx
  179. incb %al
  180. andl $255,%edx
  181. movl (%edi,%eax,4),%ecx
  182. movl (%edi,%edx,4),%ebp
  183. addb %cl,%bl
  184. movl (%edi,%ebx,4),%edx
  185. movl %ecx,(%edi,%ebx,4)
  186. movl %edx,(%edi,%eax,4)
  187. addl %ecx,%edx
  188. incb %al
  189. andl $255,%edx
  190. rorl $8,%ebp
  191. movl (%edi,%eax,4),%ecx
  192. orl (%edi,%edx,4),%ebp
  193. addb %cl,%bl
  194. movl (%edi,%ebx,4),%edx
  195. movl %ecx,(%edi,%ebx,4)
  196. movl %edx,(%edi,%eax,4)
  197. addl %ecx,%edx
  198. incb %al
  199. andl $255,%edx
  200. rorl $8,%ebp
  201. movl (%edi,%eax,4),%ecx
  202. orl (%edi,%edx,4),%ebp
  203. addb %cl,%bl
  204. movl (%edi,%ebx,4),%edx
  205. movl %ecx,(%edi,%ebx,4)
  206. movl %edx,(%edi,%eax,4)
  207. addl %ecx,%edx
  208. incb %al
  209. andl $255,%edx
  210. rorl $8,%ebp
  211. movl 32(%esp),%ecx
  212. orl (%edi,%edx,4),%ebp
  213. rorl $8,%ebp
  214. xorl (%esi),%ebp
  215. cmpl 28(%esp),%esi
  216. movl %ebp,(%ecx,%esi,1)
  217. leal 4(%esi),%esi
  218. movl (%edi,%eax,4),%ecx
  219. jb .L008loop4
  220. cmpl 24(%esp),%esi
  221. je .L007done
  222. movl 32(%esp),%ebp
  223. .align 16
  224. .L002loop1:
  225. addb %cl,%bl
  226. movl (%edi,%ebx,4),%edx
  227. movl %ecx,(%edi,%ebx,4)
  228. movl %edx,(%edi,%eax,4)
  229. addl %ecx,%edx
  230. incb %al
  231. andl $255,%edx
  232. movl (%edi,%edx,4),%edx
  233. xorb (%esi),%dl
  234. leal 1(%esi),%esi
  235. movl (%edi,%eax,4),%ecx
  236. cmpl 24(%esp),%esi
  237. movb %dl,-1(%ebp,%esi,1)
  238. jb .L002loop1
  239. jmp .L007done
  240. .align 16
  241. .L001RC4_CHAR:
  242. movzbl (%edi,%eax,1),%ecx
  243. .L009cloop1:
  244. addb %cl,%bl
  245. movzbl (%edi,%ebx,1),%edx
  246. movb %cl,(%edi,%ebx,1)
  247. movb %dl,(%edi,%eax,1)
  248. addb %cl,%dl
  249. movzbl (%edi,%edx,1),%edx
  250. addb $1,%al
  251. xorb (%esi),%dl
  252. leal 1(%esi),%esi
  253. movzbl (%edi,%eax,1),%ecx
  254. cmpl 24(%esp),%esi
  255. movb %dl,-1(%ebp,%esi,1)
  256. jb .L009cloop1
  257. .L007done:
  258. decb %al
  259. movl %ebx,-4(%edi)
  260. movb %al,-8(%edi)
  261. .L000abort:
  262. popl %edi
  263. popl %esi
  264. popl %ebx
  265. popl %ebp
  266. ret
  267. .size RC4,.-.L_RC4_begin
  268. .globl RC4_set_key
  269. .type RC4_set_key,@function
  270. .align 16
  271. RC4_set_key:
  272. .L_RC4_set_key_begin:
  273. pushl %ebp
  274. pushl %ebx
  275. pushl %esi
  276. pushl %edi
  277. movl 20(%esp),%edi
  278. movl 24(%esp),%ebp
  279. movl 28(%esp),%esi
  280. call .L010PIC_me_up
  281. .L010PIC_me_up:
  282. popl %edx
  283. leal OPENSSL_ia32cap_P-.L010PIC_me_up(%edx),%edx
  284. leal 8(%edi),%edi
  285. leal (%esi,%ebp,1),%esi
  286. negl %ebp
  287. xorl %eax,%eax
  288. movl %ebp,-4(%edi)
  289. btl $20,(%edx)
  290. jc .L011c1stloop
  291. .align 16
  292. .L012w1stloop:
  293. movl %eax,(%edi,%eax,4)
  294. addb $1,%al
  295. jnc .L012w1stloop
  296. xorl %ecx,%ecx
  297. xorl %edx,%edx
  298. .align 16
  299. .L013w2ndloop:
  300. movl (%edi,%ecx,4),%eax
  301. addb (%esi,%ebp,1),%dl
  302. addb %al,%dl
  303. addl $1,%ebp
  304. movl (%edi,%edx,4),%ebx
  305. jnz .L014wnowrap
  306. movl -4(%edi),%ebp
  307. .L014wnowrap:
  308. movl %eax,(%edi,%edx,4)
  309. movl %ebx,(%edi,%ecx,4)
  310. addb $1,%cl
  311. jnc .L013w2ndloop
  312. jmp .L015exit
  313. .align 16
  314. .L011c1stloop:
  315. movb %al,(%edi,%eax,1)
  316. addb $1,%al
  317. jnc .L011c1stloop
  318. xorl %ecx,%ecx
  319. xorl %edx,%edx
  320. xorl %ebx,%ebx
  321. .align 16
  322. .L016c2ndloop:
  323. movb (%edi,%ecx,1),%al
  324. addb (%esi,%ebp,1),%dl
  325. addb %al,%dl
  326. addl $1,%ebp
  327. movb (%edi,%edx,1),%bl
  328. jnz .L017cnowrap
  329. movl -4(%edi),%ebp
  330. .L017cnowrap:
  331. movb %al,(%edi,%edx,1)
  332. movb %bl,(%edi,%ecx,1)
  333. addb $1,%cl
  334. jnc .L016c2ndloop
  335. movl $-1,256(%edi)
  336. .L015exit:
  337. xorl %eax,%eax
  338. movl %eax,-8(%edi)
  339. movl %eax,-4(%edi)
  340. popl %edi
  341. popl %esi
  342. popl %ebx
  343. popl %ebp
  344. ret
  345. .size RC4_set_key,.-.L_RC4_set_key_begin
  346. .globl RC4_options
  347. .type RC4_options,@function
  348. .align 16
  349. RC4_options:
  350. .L_RC4_options_begin:
  351. call .L018pic_point
  352. .L018pic_point:
  353. popl %eax
  354. leal .L019opts-.L018pic_point(%eax),%eax
  355. call .L020PIC_me_up
  356. .L020PIC_me_up:
  357. popl %edx
  358. leal OPENSSL_ia32cap_P-.L020PIC_me_up(%edx),%edx
  359. movl (%edx),%edx
  360. btl $20,%edx
  361. jc .L0211xchar
  362. btl $26,%edx
  363. jnc .L022ret
  364. addl $25,%eax
  365. ret
  366. .L0211xchar:
  367. addl $12,%eax
  368. .L022ret:
  369. ret
  370. .align 64
  371. .L019opts:
  372. .byte 114,99,52,40,52,120,44,105,110,116,41,0
  373. .byte 114,99,52,40,49,120,44,99,104,97,114,41,0
  374. .byte 114,99,52,40,56,120,44,109,109,120,41,0
  375. .byte 82,67,52,32,102,111,114,32,120,56,54,44,32,67,82,89
  376. .byte 80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114
  377. .byte 111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
  378. .align 64
  379. .size RC4_options,.-.L_RC4_options_begin
  380. .comm OPENSSL_ia32cap_P,16,4