2
0

desboth.pl 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #! /usr/bin/env perl
  2. # Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the OpenSSL license (the "License"). You may not use
  5. # this file except in compliance with the License. You can obtain a copy
  6. # in the file LICENSE in the source distribution or at
  7. # https://www.openssl.org/source/license.html
  8. $L="edi";
  9. $R="esi";
  10. sub DES_encrypt3
  11. {
  12. local($name,$enc)=@_;
  13. &function_begin_B($name,"");
  14. &push("ebx");
  15. &mov("ebx",&wparam(0));
  16. &push("ebp");
  17. &push("esi");
  18. &push("edi");
  19. &comment("");
  20. &comment("Load the data words");
  21. &mov($L,&DWP(0,"ebx","",0));
  22. &mov($R,&DWP(4,"ebx","",0));
  23. &stack_push(3);
  24. &comment("");
  25. &comment("IP");
  26. &IP_new($L,$R,"edx",0);
  27. # put them back
  28. if ($enc)
  29. {
  30. &mov(&DWP(4,"ebx","",0),$R);
  31. &mov("eax",&wparam(1));
  32. &mov(&DWP(0,"ebx","",0),"edx");
  33. &mov("edi",&wparam(2));
  34. &mov("esi",&wparam(3));
  35. }
  36. else
  37. {
  38. &mov(&DWP(4,"ebx","",0),$R);
  39. &mov("esi",&wparam(1));
  40. &mov(&DWP(0,"ebx","",0),"edx");
  41. &mov("edi",&wparam(2));
  42. &mov("eax",&wparam(3));
  43. }
  44. &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
  45. &mov(&swtmp(1), "eax");
  46. &mov(&swtmp(0), "ebx");
  47. &call("DES_encrypt2");
  48. &mov(&swtmp(2), (DWC(($enc)?"0":"1")));
  49. &mov(&swtmp(1), "edi");
  50. &mov(&swtmp(0), "ebx");
  51. &call("DES_encrypt2");
  52. &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
  53. &mov(&swtmp(1), "esi");
  54. &mov(&swtmp(0), "ebx");
  55. &call("DES_encrypt2");
  56. &stack_pop(3);
  57. &mov($L,&DWP(0,"ebx","",0));
  58. &mov($R,&DWP(4,"ebx","",0));
  59. &comment("");
  60. &comment("FP");
  61. &FP_new($L,$R,"eax",0);
  62. &mov(&DWP(0,"ebx","",0),"eax");
  63. &mov(&DWP(4,"ebx","",0),$R);
  64. &pop("edi");
  65. &pop("esi");
  66. &pop("ebp");
  67. &pop("ebx");
  68. &ret();
  69. &function_end_B($name);
  70. }