summaryrefslogtreecommitdiff
path: root/crypto/cast/asm/cast-586.pl
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/cast/asm/cast-586.pl')
-rw-r--r--crypto/cast/asm/cast-586.pl31
1 files changed, 23 insertions, 8 deletions
diff --git a/crypto/cast/asm/cast-586.pl b/crypto/cast/asm/cast-586.pl
index bf6810d335f2..d5d38965cf76 100644
--- a/crypto/cast/asm/cast-586.pl
+++ b/crypto/cast/asm/cast-586.pl
@@ -1,6 +1,16 @@
-#!/usr/local/bin/perl
-
-# define for pentium pro friendly version
+#! /usr/bin/env perl
+# Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License"). You may not use
+# this file except in compliance with the License. You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+
+# This flag makes the inner loop one cycle longer, but generates
+# code that runs %30 faster on the pentium pro/II, 44% faster
+# of PIII, while only %7 slower on the pentium.
+# By default, this flag is on.
$ppro=1;
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
@@ -8,7 +18,10 @@ push(@INC,"${dir}","${dir}../../perlasm");
require "x86asm.pl";
require "cbc.pl";
-&asm_init($ARGV[0],"cast-586.pl",$ARGV[$#ARGV] eq "386");
+$output=pop;
+open STDOUT,">$output";
+
+&asm_init($ARGV[0],$ARGV[$#ARGV] eq "386");
$CAST_ROUNDS=16;
$L="edi";
@@ -33,6 +46,8 @@ $S4="CAST_S_table3";
&asm_finish();
+close STDOUT;
+
sub CAST_encrypt {
local($name,$enc)=@_;
@@ -140,18 +155,18 @@ sub E_CAST {
&rotl( $tmp4, &LB($tmp1));
if ($ppro) {
- &mov( $tmp2, $tmp4); # B
&xor( $tmp1, $tmp1);
-
+ &mov( $tmp2, 0xff);
+
&movb( &LB($tmp1), &HB($tmp4)); # A
- &and( $tmp2, 0xff);
+ &and( $tmp2, $tmp4);
&shr( $tmp4, 16); #
&xor( $tmp3, $tmp3);
} else {
&mov( $tmp2, $tmp4); # B
&movb( &LB($tmp1), &HB($tmp4)); # A # BAD BAD BAD
-
+
&shr( $tmp4, 16); #
&and( $tmp2, 0xff);
}