des-586.pl revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
#
require "x86asm.pl";
require "cbc.pl";
require "desboth.pl";
# base code is in microsft
# op dest, source
# format.
#
$L="edi";
$R="esi";
&external_label("DES_SPtrans");
&asm_finish();
sub DES_encrypt
{
&push("esi");
&push("edi");
&comment("");
&comment("Load the 2 words");
$trans="ebp";
if ($do_ip)
{
&push("ebx");
&push("ebp");
&comment("");
&comment("IP");
}
else
{
&push("ebx");
&push("ebp");
&rotl($R,3);
&rotl($L,3);
}
# PIC-ification:-)
#if ($cpp) { &picmeup($trans,"DES_SPtrans"); }
#else { &lea($trans,&DWP("DES_SPtrans")); }
for ($i=0; $i<16; $i+=2)
{
&comment("");
&comment("Round $i");
&comment("");
}
&set_label("start_decrypt");
for ($i=15; $i>0; $i-=2)
{
&comment("");
&comment("Round $i");
&comment("");
}
&set_label("end");
if ($do_ip)
{
&comment("");
&comment("FP");
}
else
{
&comment("");
&comment("Fixup");
}
&pop("ebp");
&pop("ebx");
&pop("edi");
&pop("esi");
&ret();
&function_end_B($name);
}
sub D_ENCRYPT
{
&xor( $u, $R);
&xor( $t, $R);
&and( $u, "0xfcfcfcfc" );
&and( $t, "0xcfcfcfcf" );
&rotr( $t, 4 );
&shr( $u, 16);
&shr( $t, 16);
&and( $u, "0xff" );
&and( $t, "0xff" );
}
sub n2a
{
sprintf("%d",$_[0]);
}
# now has a side affect of rotating $a by $shift
sub R_PERM_OP
{
&xor( $a, $b );
# This can never succeed, and besides it is difficult to see what the
# idea was - Ben 13 Feb 99
if (!$last eq $b)
{
&xor( $b, $a );
}
else
{
&xor( $b, $a );
}
&comment("");
}
sub IP_new
{
if ($lr != 3)
{
}
if ($lr != 2)
{
}
}
sub FP_new
{
if ($lr != 2)
{
}
if ($lr != 3)
{
}
}