rc5-586.pl revision 7c478bd95313f5f23a4c958a745db2134aa03244
require "x86asm.pl";
require "cbc.pl";
$RC5_MAX_ROUNDS=16;
$A="edi";
$B="esi";
$S="ebp";
$tmp1="eax";
$r="ebx";
$tmpc="ecx";
$tmp4="edx";
&asm_finish();
sub RC5_32_encrypt
{
&comment("");
&push("ebp");
&push("esi");
&push("edi");
&comment("Load the 2 words");
&push($r);
# encrypting part
if ($enc)
{
for ($i=0; $i<$RC5_MAX_ROUNDS; $i++)
{
&xor($A, $B);
&xor($B, $A);
if (($i == 7) || ($i == 11))
{
&cmp($r, $i+1);
}
}
}
else
{
&cmp($r, 12);
&cmp($r, 8);
for ($i=$RC5_MAX_ROUNDS; $i > 0; $i--)
{
&xor($B, $A);
&xor($A, $B);
}
}
&set_label("rc5_exit");
&pop("ebx");
&pop("edi");
&pop("esi");
&pop("ebp");
&ret();
&function_end_B($name);
}