crypt586.pl revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
# I've added the stuff needed for crypt() but I've not worried about making
# things perfect.
#
require "x86asm.pl";
$L="edi";
$R="esi";
&external_label("DES_SPtrans");
&fcrypt_body("fcrypt_body");
&asm_finish();
sub fcrypt_body
{
&comment("");
&comment("Load the 2 words");
$trans="ebp";
&xor( $L, $L);
&xor( $R, $R);
# PIC-ification:-)
#if ($cpp) { &picmeup("edx","DES_SPtrans"); }
#else { &lea("edx",&DWP("DES_SPtrans")); }
#
&set_label("start");
for ($i=0; $i<16; $i+=2)
{
&comment("");
&comment("Round $i");
&comment("");
}
&mov("eax", $L);
&dec("ebx");
&mov($L, $R);
&mov($R, "eax");
&comment("");
&comment("FP");
&function_end($name);
}
sub D_ENCRYPT
{
&mov( $t, $R);
&xor( $t, $R); # 1
&and( $u, $t); # 2
&xor( $u, $R);
&xor( $t, $R);
&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 );
if ($notlast 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)
{
}
}