mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-08 06:03:47 +08:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # README.md
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
#!/usr/local/bin/perl
|
||||
#! /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
|
||||
|
||||
|
||||
# Normal is the
|
||||
# md5_block_x86(MD5_CTX *c, ULONG *X);
|
||||
@@ -11,6 +18,9 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
$output=pop;
|
||||
open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],$0);
|
||||
|
||||
$A="eax";
|
||||
@@ -33,6 +43,8 @@ $X="esi";
|
||||
&md5_block("md5_block_asm_data_order");
|
||||
&asm_finish();
|
||||
|
||||
close STDOUT;
|
||||
|
||||
sub Np
|
||||
{
|
||||
local($p)=@_;
|
||||
@@ -56,14 +68,14 @@ sub R0
|
||||
&lea($a,&DWP($t,$a,$tmp2,1));
|
||||
|
||||
&xor($tmp1,$d); # F function - part 4
|
||||
&mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
|
||||
|
||||
&add($a,$tmp1);
|
||||
&mov($tmp1,&Np($c)) if $pos < 1; # next tmp1 for R0
|
||||
&mov($tmp1,&Np($c)) if $pos == 1; # next tmp1 for R1
|
||||
|
||||
&rotl($a,$s);
|
||||
|
||||
&mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
|
||||
&mov($tmp1,&Np($c)) if $pos < 1; # next tmp1 for R0
|
||||
&mov($tmp1,&Np($c)) if $pos == 1; # next tmp1 for R1
|
||||
|
||||
&add($a,$b);
|
||||
}
|
||||
@@ -74,13 +86,12 @@ sub R1
|
||||
|
||||
&comment("R1 $ki");
|
||||
|
||||
&lea($a,&DWP($t,$a,$tmp2,1));
|
||||
|
||||
&xor($tmp1,$b); # G function - part 2
|
||||
&and($tmp1,$d); # G function - part 3
|
||||
&lea($a,&DWP($t,$a,$tmp2,1));
|
||||
|
||||
&mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
|
||||
&xor($tmp1,$c); # G function - part 4
|
||||
&mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
|
||||
|
||||
&add($a,$tmp1);
|
||||
&mov($tmp1,&Np($c)) if $pos < 1; # G function - part 1
|
||||
@@ -108,10 +119,10 @@ if (($n & 1) == 0)
|
||||
&lea($a,&DWP($t,$a,$tmp2,1));
|
||||
|
||||
&add($a,$tmp1);
|
||||
&mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0));
|
||||
|
||||
&rotl($a,$s);
|
||||
|
||||
&mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0));
|
||||
&mov($tmp1,&Np($c));
|
||||
}
|
||||
else
|
||||
@@ -120,11 +131,11 @@ else
|
||||
# make sure to do 'D' first, not 'B', else we clash with
|
||||
# the last add from the previous round.
|
||||
|
||||
&lea($a,&DWP($t,$a,$tmp2,1));
|
||||
|
||||
&add($b,$c); # MOVED FORWARD
|
||||
&xor($tmp1,$d); # H function - part 2
|
||||
|
||||
&lea($a,&DWP($t,$a,$tmp2,1));
|
||||
|
||||
&xor($tmp1,$b); # H function - part 3
|
||||
&mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
|
||||
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2005-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
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2005 Hewlett-Packard Development Company, L.P.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
#!/usr/bin/env perl
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2012-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
|
||||
|
||||
|
||||
# ====================================================================
|
||||
# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
|
||||
@@ -17,7 +24,7 @@
|
||||
# single-process result on 8-core processor, or ~11GBps per 2.85GHz
|
||||
# socket.
|
||||
|
||||
$output=shift;
|
||||
$output=pop;
|
||||
open STDOUT,">$output";
|
||||
|
||||
use integer;
|
||||
@@ -371,7 +378,7 @@ ___
|
||||
|
||||
# Purpose of these subroutines is to explicitly encode VIS instructions,
|
||||
# so that one can compile the module without having to specify VIS
|
||||
# extentions on compiler command line, e.g. -xarch=v9 vs. -xarch=v9a.
|
||||
# extensions on compiler command line, e.g. -xarch=v9 vs. -xarch=v9a.
|
||||
# Idea is to reserve for option to produce "universal" binary and let
|
||||
# programmer detect if current CPU is VIS capable at run-time.
|
||||
sub unvis {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#!/usr/bin/perl -w
|
||||
#
|
||||
# MD5 optimized for AMD64.
|
||||
#
|
||||
#! /usr/bin/env perl
|
||||
# Author: Marc Bevand <bevand_m (at) epita.fr>
|
||||
# Licence: I hereby disclaim the copyright on this code and place it
|
||||
# in the public domain.
|
||||
# Copyright 2005-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
|
||||
|
||||
# MD5 optimized for AMD64.
|
||||
|
||||
use strict;
|
||||
|
||||
@@ -25,8 +27,8 @@ sub round1_step
|
||||
xor $y, %r11d /* y ^ ... */
|
||||
lea $T_i($dst,%r10d),$dst /* Const + dst + ... */
|
||||
and $x, %r11d /* x & ... */
|
||||
xor $z, %r11d /* z ^ ... */
|
||||
mov $k_next*4(%rsi),%r10d /* (NEXT STEP) X[$k_next] */
|
||||
xor $z, %r11d /* z ^ ... */
|
||||
add %r11d, $dst /* dst += ... */
|
||||
rol \$$s, $dst /* dst <<< s */
|
||||
mov $y, %r11d /* (NEXT STEP) z' = $y */
|
||||
@@ -43,13 +45,12 @@ EOF
|
||||
sub round2_step
|
||||
{
|
||||
my ($pos, $dst, $x, $y, $z, $k_next, $T_i, $s) = @_;
|
||||
$code .= " mov 1*4(%rsi), %r10d /* (NEXT STEP) X[1] */\n" if ($pos == -1);
|
||||
$code .= " mov %edx, %r11d /* (NEXT STEP) z' = %edx */\n" if ($pos == -1);
|
||||
$code .= " mov %edx, %r12d /* (NEXT STEP) z' = %edx */\n" if ($pos == -1);
|
||||
$code .= <<EOF;
|
||||
not %r11d /* not z */
|
||||
lea $T_i($dst,%r10d),$dst /* Const + dst + ... */
|
||||
and $x, %r12d /* x & z */
|
||||
lea $T_i($dst,%r10d),$dst /* Const + dst + ... */
|
||||
and $y, %r11d /* y & (not z) */
|
||||
mov $k_next*4(%rsi),%r10d /* (NEXT STEP) X[$k_next] */
|
||||
or %r11d, %r12d /* (y & (not z)) | (x & z) */
|
||||
@@ -66,21 +67,31 @@ EOF
|
||||
# %r10d = X[k_next]
|
||||
# %r11d = y' (copy of y for the next step)
|
||||
# Each round3_step() takes about 4.2 clocks (8 instructions, 1.9 IPC)
|
||||
{ my $round3_alter=0;
|
||||
sub round3_step
|
||||
{
|
||||
my ($pos, $dst, $x, $y, $z, $k_next, $T_i, $s) = @_;
|
||||
$code .= " mov 5*4(%rsi), %r10d /* (NEXT STEP) X[5] */\n" if ($pos == -1);
|
||||
$code .= " mov %ecx, %r11d /* (NEXT STEP) y' = %ecx */\n" if ($pos == -1);
|
||||
$code .= <<EOF;
|
||||
lea $T_i($dst,%r10d),$dst /* Const + dst + ... */
|
||||
mov $k_next*4(%rsi),%r10d /* (NEXT STEP) X[$k_next] */
|
||||
xor $z, %r11d /* z ^ ... */
|
||||
mov $k_next*4(%rsi),%r10d /* (NEXT STEP) X[$k_next] */
|
||||
xor $x, %r11d /* x ^ ... */
|
||||
add %r11d, $dst /* dst += ... */
|
||||
EOF
|
||||
$code .= <<EOF if ($round3_alter);
|
||||
rol \$$s, $dst /* dst <<< s */
|
||||
mov $x, %r11d /* (NEXT STEP) y' = $x */
|
||||
EOF
|
||||
$code .= <<EOF if (!$round3_alter);
|
||||
mov $x, %r11d /* (NEXT STEP) y' = $x */
|
||||
rol \$$s, $dst /* dst <<< s */
|
||||
EOF
|
||||
$code .= <<EOF;
|
||||
add $x, $dst /* dst += x */
|
||||
EOF
|
||||
$round3_alter^=1;
|
||||
}
|
||||
}
|
||||
|
||||
# round4_step() does:
|
||||
@@ -91,16 +102,15 @@ EOF
|
||||
sub round4_step
|
||||
{
|
||||
my ($pos, $dst, $x, $y, $z, $k_next, $T_i, $s) = @_;
|
||||
$code .= " mov 0*4(%rsi), %r10d /* (NEXT STEP) X[0] */\n" if ($pos == -1);
|
||||
$code .= " mov \$0xffffffff, %r11d\n" if ($pos == -1);
|
||||
$code .= " xor %edx, %r11d /* (NEXT STEP) not z' = not %edx*/\n"
|
||||
if ($pos == -1);
|
||||
$code .= <<EOF;
|
||||
lea $T_i($dst,%r10d),$dst /* Const + dst + ... */
|
||||
or $x, %r11d /* x | ... */
|
||||
mov $k_next*4(%rsi),%r10d /* (NEXT STEP) X[$k_next] */
|
||||
xor $y, %r11d /* y ^ ... */
|
||||
add %r11d, $dst /* dst += ... */
|
||||
mov $k_next*4(%rsi),%r10d /* (NEXT STEP) X[$k_next] */
|
||||
mov \$0xffffffff, %r11d
|
||||
rol \$$s, $dst /* dst <<< s */
|
||||
xor $y, %r11d /* (NEXT STEP) not z' = not $y */
|
||||
@@ -120,7 +130,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; my $dir=$1; my $xlate;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$code .= <<EOF;
|
||||
@@ -179,7 +189,7 @@ round1_step( 0,'%ebx','%ecx','%edx','%eax','12','0x895cd7be','22');
|
||||
round1_step( 0,'%eax','%ebx','%ecx','%edx','13','0x6b901122', '7');
|
||||
round1_step( 0,'%edx','%eax','%ebx','%ecx','14','0xfd987193','12');
|
||||
round1_step( 0,'%ecx','%edx','%eax','%ebx','15','0xa679438e','17');
|
||||
round1_step( 1,'%ebx','%ecx','%edx','%eax', '0','0x49b40821','22');
|
||||
round1_step( 1,'%ebx','%ecx','%edx','%eax', '1','0x49b40821','22');
|
||||
|
||||
round2_step(-1,'%eax','%ebx','%ecx','%edx', '6','0xf61e2562', '5');
|
||||
round2_step( 0,'%edx','%eax','%ebx','%ecx','11','0xc040b340', '9');
|
||||
@@ -196,7 +206,7 @@ round2_step( 0,'%ebx','%ecx','%edx','%eax','13','0x455a14ed','20');
|
||||
round2_step( 0,'%eax','%ebx','%ecx','%edx', '2','0xa9e3e905', '5');
|
||||
round2_step( 0,'%edx','%eax','%ebx','%ecx', '7','0xfcefa3f8', '9');
|
||||
round2_step( 0,'%ecx','%edx','%eax','%ebx','12','0x676f02d9','14');
|
||||
round2_step( 1,'%ebx','%ecx','%edx','%eax', '0','0x8d2a4c8a','20');
|
||||
round2_step( 1,'%ebx','%ecx','%edx','%eax', '5','0x8d2a4c8a','20');
|
||||
|
||||
round3_step(-1,'%eax','%ebx','%ecx','%edx', '8','0xfffa3942', '4');
|
||||
round3_step( 0,'%edx','%eax','%ebx','%ecx','11','0x8771f681','11');
|
||||
|
||||
Reference in New Issue
Block a user