summaryrefslogtreecommitdiff
path: root/crypto/des/asm/desboth.pl
blob: 288984d135bf93d80c7cd6573328bb9d42d02f06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/local/bin/perl

$L="edi";
$R="esi";

sub des_encrypt3
	{
	local($name,$enc)=@_;

	&function_begin_B($name,"");
	&push("ebx");
	&mov("ebx",&wparam(0));

	&push("ebp");
	&push("esi");

	&push("edi");

	&comment("");
	&comment("Load the data words");
	&mov($L,&DWP(0,"ebx","",0));
	&mov($R,&DWP(4,"ebx","",0));
	&stack_push(3);

	&comment("");
	&comment("IP");
	&IP_new($L,$R,"edx",0);

	# put them back
	
	if ($enc)
		{
		&mov(&DWP(4,"ebx","",0),$R);
		 &mov("eax",&wparam(1));
		&mov(&DWP(0,"ebx","",0),"edx");
		 &mov("edi",&wparam(2));
		 &mov("esi",&wparam(3));
		}
	else
		{
		&mov(&DWP(4,"ebx","",0),$R);
		 &mov("esi",&wparam(1));
		&mov(&DWP(0,"ebx","",0),"edx");
		 &mov("edi",&wparam(2));
		 &mov("eax",&wparam(3));
		}
	&mov(&swtmp(2),	(($enc)?"1":"0"));
	&mov(&swtmp(1),	"eax");
	&mov(&swtmp(0),	"ebx");
	&call("des_encrypt2");
	&mov(&swtmp(2),	(($enc)?"0":"1"));
	&mov(&swtmp(1),	"edi");
	&mov(&swtmp(0),	"ebx");
	&call("des_encrypt2");
	&mov(&swtmp(2),	(($enc)?"1":"0"));
	&mov(&swtmp(1),	"esi");
	&mov(&swtmp(0),	"ebx");
	&call("des_encrypt2");

	&stack_pop(3);
	&mov($L,&DWP(0,"ebx","",0));
	&mov($R,&DWP(4,"ebx","",0));

	&comment("");
	&comment("FP");
	&FP_new($L,$R,"eax",0);

	&mov(&DWP(0,"ebx","",0),"eax");
	&mov(&DWP(4,"ebx","",0),$R);

	&pop("edi");
	&pop("esi");
	&pop("ebp");
	&pop("ebx");
	&ret();
	&function_end_B($name);
	}