rc5-586.S revision 1.5
1#include <machine/asm.h> 2.text 3.globl RC5_32_encrypt 4.type RC5_32_encrypt,@function 5.align 16 6RC5_32_encrypt: 7.L_RC5_32_encrypt_begin: 8 #ifdef __CET__ 9 10.byte 243,15,30,251 11 #endif 12 13 14 pushl %ebp 15 pushl %esi 16 pushl %edi 17 movl 16(%esp),%edx 18 movl 20(%esp),%ebp 19 20 movl (%edx),%edi 21 movl 4(%edx),%esi 22 pushl %ebx 23 movl (%ebp),%ebx 24 addl 4(%ebp),%edi 25 addl 8(%ebp),%esi 26 xorl %esi,%edi 27 movl 12(%ebp),%eax 28 movl %esi,%ecx 29 roll %cl,%edi 30 addl %eax,%edi 31 xorl %edi,%esi 32 movl 16(%ebp),%eax 33 movl %edi,%ecx 34 roll %cl,%esi 35 addl %eax,%esi 36 xorl %esi,%edi 37 movl 20(%ebp),%eax 38 movl %esi,%ecx 39 roll %cl,%edi 40 addl %eax,%edi 41 xorl %edi,%esi 42 movl 24(%ebp),%eax 43 movl %edi,%ecx 44 roll %cl,%esi 45 addl %eax,%esi 46 xorl %esi,%edi 47 movl 28(%ebp),%eax 48 movl %esi,%ecx 49 roll %cl,%edi 50 addl %eax,%edi 51 xorl %edi,%esi 52 movl 32(%ebp),%eax 53 movl %edi,%ecx 54 roll %cl,%esi 55 addl %eax,%esi 56 xorl %esi,%edi 57 movl 36(%ebp),%eax 58 movl %esi,%ecx 59 roll %cl,%edi 60 addl %eax,%edi 61 xorl %edi,%esi 62 movl 40(%ebp),%eax 63 movl %edi,%ecx 64 roll %cl,%esi 65 addl %eax,%esi 66 xorl %esi,%edi 67 movl 44(%ebp),%eax 68 movl %esi,%ecx 69 roll %cl,%edi 70 addl %eax,%edi 71 xorl %edi,%esi 72 movl 48(%ebp),%eax 73 movl %edi,%ecx 74 roll %cl,%esi 75 addl %eax,%esi 76 xorl %esi,%edi 77 movl 52(%ebp),%eax 78 movl %esi,%ecx 79 roll %cl,%edi 80 addl %eax,%edi 81 xorl %edi,%esi 82 movl 56(%ebp),%eax 83 movl %edi,%ecx 84 roll %cl,%esi 85 addl %eax,%esi 86 xorl %esi,%edi 87 movl 60(%ebp),%eax 88 movl %esi,%ecx 89 roll %cl,%edi 90 addl %eax,%edi 91 xorl %edi,%esi 92 movl 64(%ebp),%eax 93 movl %edi,%ecx 94 roll %cl,%esi 95 addl %eax,%esi 96 xorl %esi,%edi 97 movl 68(%ebp),%eax 98 movl %esi,%ecx 99 roll %cl,%edi 100 addl %eax,%edi 101 xorl %edi,%esi 102 movl 72(%ebp),%eax 103 movl %edi,%ecx 104 roll %cl,%esi 105 addl %eax,%esi 106 cmpl $8,%ebx 107 je .L000rc5_exit 108 xorl %esi,%edi 109 movl 76(%ebp),%eax 110 movl %esi,%ecx 111 roll %cl,%edi 112 addl %eax,%edi 113 xorl %edi,%esi 114 movl 80(%ebp),%eax 115 movl %edi,%ecx 116 roll %cl,%esi 117 addl %eax,%esi 118 xorl %esi,%edi 119 movl 84(%ebp),%eax 120 movl %esi,%ecx 121 roll %cl,%edi 122 addl %eax,%edi 123 xorl %edi,%esi 124 movl 88(%ebp),%eax 125 movl %edi,%ecx 126 roll %cl,%esi 127 addl %eax,%esi 128 xorl %esi,%edi 129 movl 92(%ebp),%eax 130 movl %esi,%ecx 131 roll %cl,%edi 132 addl %eax,%edi 133 xorl %edi,%esi 134 movl 96(%ebp),%eax 135 movl %edi,%ecx 136 roll %cl,%esi 137 addl %eax,%esi 138 xorl %esi,%edi 139 movl 100(%ebp),%eax 140 movl %esi,%ecx 141 roll %cl,%edi 142 addl %eax,%edi 143 xorl %edi,%esi 144 movl 104(%ebp),%eax 145 movl %edi,%ecx 146 roll %cl,%esi 147 addl %eax,%esi 148 cmpl $12,%ebx 149 je .L000rc5_exit 150 xorl %esi,%edi 151 movl 108(%ebp),%eax 152 movl %esi,%ecx 153 roll %cl,%edi 154 addl %eax,%edi 155 xorl %edi,%esi 156 movl 112(%ebp),%eax 157 movl %edi,%ecx 158 roll %cl,%esi 159 addl %eax,%esi 160 xorl %esi,%edi 161 movl 116(%ebp),%eax 162 movl %esi,%ecx 163 roll %cl,%edi 164 addl %eax,%edi 165 xorl %edi,%esi 166 movl 120(%ebp),%eax 167 movl %edi,%ecx 168 roll %cl,%esi 169 addl %eax,%esi 170 xorl %esi,%edi 171 movl 124(%ebp),%eax 172 movl %esi,%ecx 173 roll %cl,%edi 174 addl %eax,%edi 175 xorl %edi,%esi 176 movl 128(%ebp),%eax 177 movl %edi,%ecx 178 roll %cl,%esi 179 addl %eax,%esi 180 xorl %esi,%edi 181 movl 132(%ebp),%eax 182 movl %esi,%ecx 183 roll %cl,%edi 184 addl %eax,%edi 185 xorl %edi,%esi 186 movl 136(%ebp),%eax 187 movl %edi,%ecx 188 roll %cl,%esi 189 addl %eax,%esi 190.L000rc5_exit: 191 movl %edi,(%edx) 192 movl %esi,4(%edx) 193 popl %ebx 194 popl %edi 195 popl %esi 196 popl %ebp 197 ret 198.size RC5_32_encrypt,.-.L_RC5_32_encrypt_begin 199.globl RC5_32_decrypt 200.type RC5_32_decrypt,@function 201.align 16 202RC5_32_decrypt: 203.L_RC5_32_decrypt_begin: 204 #ifdef __CET__ 205 206.byte 243,15,30,251 207 #endif 208 209 210 pushl %ebp 211 pushl %esi 212 pushl %edi 213 movl 16(%esp),%edx 214 movl 20(%esp),%ebp 215 216 movl (%edx),%edi 217 movl 4(%edx),%esi 218 pushl %ebx 219 movl (%ebp),%ebx 220 cmpl $12,%ebx 221 je .L001rc5_dec_12 222 cmpl $8,%ebx 223 je .L002rc5_dec_8 224 movl 136(%ebp),%eax 225 subl %eax,%esi 226 movl %edi,%ecx 227 rorl %cl,%esi 228 xorl %edi,%esi 229 movl 132(%ebp),%eax 230 subl %eax,%edi 231 movl %esi,%ecx 232 rorl %cl,%edi 233 xorl %esi,%edi 234 movl 128(%ebp),%eax 235 subl %eax,%esi 236 movl %edi,%ecx 237 rorl %cl,%esi 238 xorl %edi,%esi 239 movl 124(%ebp),%eax 240 subl %eax,%edi 241 movl %esi,%ecx 242 rorl %cl,%edi 243 xorl %esi,%edi 244 movl 120(%ebp),%eax 245 subl %eax,%esi 246 movl %edi,%ecx 247 rorl %cl,%esi 248 xorl %edi,%esi 249 movl 116(%ebp),%eax 250 subl %eax,%edi 251 movl %esi,%ecx 252 rorl %cl,%edi 253 xorl %esi,%edi 254 movl 112(%ebp),%eax 255 subl %eax,%esi 256 movl %edi,%ecx 257 rorl %cl,%esi 258 xorl %edi,%esi 259 movl 108(%ebp),%eax 260 subl %eax,%edi 261 movl %esi,%ecx 262 rorl %cl,%edi 263 xorl %esi,%edi 264.L001rc5_dec_12: 265 movl 104(%ebp),%eax 266 subl %eax,%esi 267 movl %edi,%ecx 268 rorl %cl,%esi 269 xorl %edi,%esi 270 movl 100(%ebp),%eax 271 subl %eax,%edi 272 movl %esi,%ecx 273 rorl %cl,%edi 274 xorl %esi,%edi 275 movl 96(%ebp),%eax 276 subl %eax,%esi 277 movl %edi,%ecx 278 rorl %cl,%esi 279 xorl %edi,%esi 280 movl 92(%ebp),%eax 281 subl %eax,%edi 282 movl %esi,%ecx 283 rorl %cl,%edi 284 xorl %esi,%edi 285 movl 88(%ebp),%eax 286 subl %eax,%esi 287 movl %edi,%ecx 288 rorl %cl,%esi 289 xorl %edi,%esi 290 movl 84(%ebp),%eax 291 subl %eax,%edi 292 movl %esi,%ecx 293 rorl %cl,%edi 294 xorl %esi,%edi 295 movl 80(%ebp),%eax 296 subl %eax,%esi 297 movl %edi,%ecx 298 rorl %cl,%esi 299 xorl %edi,%esi 300 movl 76(%ebp),%eax 301 subl %eax,%edi 302 movl %esi,%ecx 303 rorl %cl,%edi 304 xorl %esi,%edi 305.L002rc5_dec_8: 306 movl 72(%ebp),%eax 307 subl %eax,%esi 308 movl %edi,%ecx 309 rorl %cl,%esi 310 xorl %edi,%esi 311 movl 68(%ebp),%eax 312 subl %eax,%edi 313 movl %esi,%ecx 314 rorl %cl,%edi 315 xorl %esi,%edi 316 movl 64(%ebp),%eax 317 subl %eax,%esi 318 movl %edi,%ecx 319 rorl %cl,%esi 320 xorl %edi,%esi 321 movl 60(%ebp),%eax 322 subl %eax,%edi 323 movl %esi,%ecx 324 rorl %cl,%edi 325 xorl %esi,%edi 326 movl 56(%ebp),%eax 327 subl %eax,%esi 328 movl %edi,%ecx 329 rorl %cl,%esi 330 xorl %edi,%esi 331 movl 52(%ebp),%eax 332 subl %eax,%edi 333 movl %esi,%ecx 334 rorl %cl,%edi 335 xorl %esi,%edi 336 movl 48(%ebp),%eax 337 subl %eax,%esi 338 movl %edi,%ecx 339 rorl %cl,%esi 340 xorl %edi,%esi 341 movl 44(%ebp),%eax 342 subl %eax,%edi 343 movl %esi,%ecx 344 rorl %cl,%edi 345 xorl %esi,%edi 346 movl 40(%ebp),%eax 347 subl %eax,%esi 348 movl %edi,%ecx 349 rorl %cl,%esi 350 xorl %edi,%esi 351 movl 36(%ebp),%eax 352 subl %eax,%edi 353 movl %esi,%ecx 354 rorl %cl,%edi 355 xorl %esi,%edi 356 movl 32(%ebp),%eax 357 subl %eax,%esi 358 movl %edi,%ecx 359 rorl %cl,%esi 360 xorl %edi,%esi 361 movl 28(%ebp),%eax 362 subl %eax,%edi 363 movl %esi,%ecx 364 rorl %cl,%edi 365 xorl %esi,%edi 366 movl 24(%ebp),%eax 367 subl %eax,%esi 368 movl %edi,%ecx 369 rorl %cl,%esi 370 xorl %edi,%esi 371 movl 20(%ebp),%eax 372 subl %eax,%edi 373 movl %esi,%ecx 374 rorl %cl,%edi 375 xorl %esi,%edi 376 movl 16(%ebp),%eax 377 subl %eax,%esi 378 movl %edi,%ecx 379 rorl %cl,%esi 380 xorl %edi,%esi 381 movl 12(%ebp),%eax 382 subl %eax,%edi 383 movl %esi,%ecx 384 rorl %cl,%edi 385 xorl %esi,%edi 386 subl 8(%ebp),%esi 387 subl 4(%ebp),%edi 388.L003rc5_exit: 389 movl %edi,(%edx) 390 movl %esi,4(%edx) 391 popl %ebx 392 popl %edi 393 popl %esi 394 popl %ebp 395 ret 396.size RC5_32_decrypt,.-.L_RC5_32_decrypt_begin 397.globl RC5_32_cbc_encrypt 398.type RC5_32_cbc_encrypt,@function 399.align 16 400RC5_32_cbc_encrypt: 401.L_RC5_32_cbc_encrypt_begin: 402 #ifdef __CET__ 403 404.byte 243,15,30,251 405 #endif 406 407 408 pushl %ebp 409 pushl %ebx 410 pushl %esi 411 pushl %edi 412 movl 28(%esp),%ebp 413 414 movl 36(%esp),%ebx 415 movl (%ebx),%esi 416 movl 4(%ebx),%edi 417 pushl %edi 418 pushl %esi 419 pushl %edi 420 pushl %esi 421 movl %esp,%ebx 422 movl 36(%esp),%esi 423 movl 40(%esp),%edi 424 425 movl 56(%esp),%ecx 426 427 movl 48(%esp),%eax 428 pushl %eax 429 pushl %ebx 430 cmpl $0,%ecx 431 jz .L004decrypt 432 andl $4294967288,%ebp 433 movl 8(%esp),%eax 434 movl 12(%esp),%ebx 435 jz .L005encrypt_finish 436.L006encrypt_loop: 437 movl (%esi),%ecx 438 movl 4(%esi),%edx 439 xorl %ecx,%eax 440 xorl %edx,%ebx 441 movl %eax,8(%esp) 442 movl %ebx,12(%esp) 443 call .L_RC5_32_encrypt_begin 444 movl 8(%esp),%eax 445 movl 12(%esp),%ebx 446 movl %eax,(%edi) 447 movl %ebx,4(%edi) 448 addl $8,%esi 449 addl $8,%edi 450 subl $8,%ebp 451 jnz .L006encrypt_loop 452.L005encrypt_finish: 453 movl 52(%esp),%ebp 454 andl $7,%ebp 455 jz .L007finish 456 call .L008PIC_point 457.L008PIC_point: 458 popl %edx 459 leal .L009cbc_enc_jmp_table-.L008PIC_point(%edx),%ecx 460 movl (%ecx,%ebp,4),%ebp 461 addl %edx,%ebp 462 xorl %ecx,%ecx 463 xorl %edx,%edx 464 jmp *%ebp 465.L010ej7: 466 #ifdef __CET__ 467 468.byte 243,15,30,251 469 #endif 470 471 movb 6(%esi),%dh 472 shll $8,%edx 473.L011ej6: 474 #ifdef __CET__ 475 476.byte 243,15,30,251 477 #endif 478 479 movb 5(%esi),%dh 480.L012ej5: 481 #ifdef __CET__ 482 483.byte 243,15,30,251 484 #endif 485 486 movb 4(%esi),%dl 487.L013ej4: 488 #ifdef __CET__ 489 490.byte 243,15,30,251 491 #endif 492 493 movl (%esi),%ecx 494 jmp .L014ejend 495.L015ej3: 496 #ifdef __CET__ 497 498.byte 243,15,30,251 499 #endif 500 501 movb 2(%esi),%ch 502 shll $8,%ecx 503.L016ej2: 504 #ifdef __CET__ 505 506.byte 243,15,30,251 507 #endif 508 509 movb 1(%esi),%ch 510.L017ej1: 511 #ifdef __CET__ 512 513.byte 243,15,30,251 514 #endif 515 516 movb (%esi),%cl 517.L014ejend: 518 xorl %ecx,%eax 519 xorl %edx,%ebx 520 movl %eax,8(%esp) 521 movl %ebx,12(%esp) 522 call .L_RC5_32_encrypt_begin 523 movl 8(%esp),%eax 524 movl 12(%esp),%ebx 525 movl %eax,(%edi) 526 movl %ebx,4(%edi) 527 jmp .L007finish 528.L004decrypt: 529 andl $4294967288,%ebp 530 movl 16(%esp),%eax 531 movl 20(%esp),%ebx 532 jz .L018decrypt_finish 533.L019decrypt_loop: 534 movl (%esi),%eax 535 movl 4(%esi),%ebx 536 movl %eax,8(%esp) 537 movl %ebx,12(%esp) 538 call .L_RC5_32_decrypt_begin 539 movl 8(%esp),%eax 540 movl 12(%esp),%ebx 541 movl 16(%esp),%ecx 542 movl 20(%esp),%edx 543 xorl %eax,%ecx 544 xorl %ebx,%edx 545 movl (%esi),%eax 546 movl 4(%esi),%ebx 547 movl %ecx,(%edi) 548 movl %edx,4(%edi) 549 movl %eax,16(%esp) 550 movl %ebx,20(%esp) 551 addl $8,%esi 552 addl $8,%edi 553 subl $8,%ebp 554 jnz .L019decrypt_loop 555.L018decrypt_finish: 556 movl 52(%esp),%ebp 557 andl $7,%ebp 558 jz .L007finish 559 movl (%esi),%eax 560 movl 4(%esi),%ebx 561 movl %eax,8(%esp) 562 movl %ebx,12(%esp) 563 call .L_RC5_32_decrypt_begin 564 movl 8(%esp),%eax 565 movl 12(%esp),%ebx 566 movl 16(%esp),%ecx 567 movl 20(%esp),%edx 568 xorl %eax,%ecx 569 xorl %ebx,%edx 570 movl (%esi),%eax 571 movl 4(%esi),%ebx 572.L020dj7: 573 rorl $16,%edx 574 movb %dl,6(%edi) 575 shrl $16,%edx 576.L021dj6: 577 movb %dh,5(%edi) 578.L022dj5: 579 movb %dl,4(%edi) 580.L023dj4: 581 movl %ecx,(%edi) 582 jmp .L024djend 583.L025dj3: 584 rorl $16,%ecx 585 movb %cl,2(%edi) 586 shll $16,%ecx 587.L026dj2: 588 movb %ch,1(%esi) 589.L027dj1: 590 movb %cl,(%esi) 591.L024djend: 592 jmp .L007finish 593.L007finish: 594 movl 60(%esp),%ecx 595 addl $24,%esp 596 movl %eax,(%ecx) 597 movl %ebx,4(%ecx) 598 popl %edi 599 popl %esi 600 popl %ebx 601 popl %ebp 602 ret 603.align 64 604.L009cbc_enc_jmp_table: 605.long 0 606.long .L017ej1-.L008PIC_point 607.long .L016ej2-.L008PIC_point 608.long .L015ej3-.L008PIC_point 609.long .L013ej4-.L008PIC_point 610.long .L012ej5-.L008PIC_point 611.long .L011ej6-.L008PIC_point 612.long .L010ej7-.L008PIC_point 613.align 64 614.size RC5_32_cbc_encrypt,.-.L_RC5_32_cbc_encrypt_begin 615 616 .section ".note.gnu.property", "a" 617 .p2align 2 618 .long 1f - 0f 619 .long 4f - 1f 620 .long 5 6210: 622 .asciz "GNU" 6231: 624 .p2align 2 625 .long 0xc0000002 626 .long 3f - 2f 6272: 628 .long 3 6293: 630 .p2align 2 6314: 632