mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-30 09:43:38 +08:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # README.md
This commit is contained in:
@@ -1,107 +0,0 @@
|
||||
#
|
||||
# OpenSSL/crypto/md5/Makefile
|
||||
#
|
||||
|
||||
DIR= md5
|
||||
TOP= ../..
|
||||
CC= cc
|
||||
CPP= $(CC) -E
|
||||
INCLUDES=-I.. -I$(TOP) -I../../include
|
||||
CFLAG=-g
|
||||
MAKEFILE= Makefile
|
||||
AR= ar r
|
||||
|
||||
MD5_ASM_OBJ=
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
ASFLAGS= $(INCLUDES) $(ASFLAG)
|
||||
AFLAGS= $(ASFLAGS)
|
||||
|
||||
GENERAL=Makefile
|
||||
TEST=md5test.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC=md5_dgst.c md5_one.c
|
||||
LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= md5.h
|
||||
HEADER= md5_locl.h $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
|
||||
top:
|
||||
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(LIBOBJ)
|
||||
$(AR) $(LIB) $(LIBOBJ)
|
||||
$(RANLIB) $(LIB) || echo Never mind.
|
||||
@touch lib
|
||||
|
||||
md5-586.s: asm/md5-586.pl ../perlasm/x86asm.pl
|
||||
$(PERL) asm/md5-586.pl $(PERLASM_SCHEME) $(CFLAGS) > $@
|
||||
|
||||
md5-x86_64.s: asm/md5-x86_64.pl
|
||||
$(PERL) asm/md5-x86_64.pl $(PERLASM_SCHEME) > $@
|
||||
|
||||
md5-ia64.s: asm/md5-ia64.S
|
||||
$(CC) $(CFLAGS) -E asm/md5-ia64.S | \
|
||||
$(PERL) -ne 's/;\s+/;\n/g; print;' > $@
|
||||
|
||||
md5-sparcv9.S: asm/md5-sparcv9.pl
|
||||
$(PERL) asm/md5-sparcv9.pl $@ $(CFLAGS)
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
|
||||
|
||||
install:
|
||||
@[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
|
||||
@headerlist="$(EXHEADER)"; for i in $$headerlist ; \
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
|
||||
tags:
|
||||
ctags $(SRC)
|
||||
|
||||
tests:
|
||||
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
update: depend
|
||||
|
||||
depend:
|
||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
|
||||
|
||||
dclean:
|
||||
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
md5_dgst.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
md5_dgst.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
|
||||
md5_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
md5_dgst.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
md5_dgst.o: ../../include/openssl/symhacks.h ../md32_common.h md5_dgst.c
|
||||
md5_dgst.o: md5_locl.h
|
||||
md5_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
md5_one.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
|
||||
md5_one.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
md5_one.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
md5_one.o: ../../include/openssl/symhacks.h md5_one.c
|
||||
@@ -1,107 +0,0 @@
|
||||
#
|
||||
# OpenSSL/crypto/md5/Makefile
|
||||
#
|
||||
|
||||
DIR= md5
|
||||
TOP= ../..
|
||||
CC= cc
|
||||
CPP= $(CC) -E
|
||||
INCLUDES=-I.. -I$(TOP) -I../../include
|
||||
CFLAG=-g
|
||||
MAKEFILE= Makefile
|
||||
AR= ar r
|
||||
|
||||
MD5_ASM_OBJ=
|
||||
|
||||
CFLAGS= $(INCLUDES) $(CFLAG)
|
||||
ASFLAGS= $(INCLUDES) $(ASFLAG)
|
||||
AFLAGS= $(ASFLAGS)
|
||||
|
||||
GENERAL=Makefile
|
||||
TEST=md5test.c
|
||||
APPS=
|
||||
|
||||
LIB=$(TOP)/libcrypto.a
|
||||
LIBSRC=md5_dgst.c md5_one.c
|
||||
LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
|
||||
|
||||
SRC= $(LIBSRC)
|
||||
|
||||
EXHEADER= md5.h
|
||||
HEADER= md5_locl.h $(EXHEADER)
|
||||
|
||||
ALL= $(GENERAL) $(SRC) $(HEADER)
|
||||
|
||||
top:
|
||||
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
|
||||
|
||||
all: lib
|
||||
|
||||
lib: $(LIBOBJ)
|
||||
$(AR) $(LIB) $(LIBOBJ)
|
||||
$(RANLIB) $(LIB) || echo Never mind.
|
||||
@touch lib
|
||||
|
||||
md5-586.s: asm/md5-586.pl ../perlasm/x86asm.pl
|
||||
$(PERL) asm/md5-586.pl $(PERLASM_SCHEME) $(CFLAGS) > $@
|
||||
|
||||
md5-x86_64.s: asm/md5-x86_64.pl
|
||||
$(PERL) asm/md5-x86_64.pl $(PERLASM_SCHEME) > $@
|
||||
|
||||
md5-ia64.s: asm/md5-ia64.S
|
||||
$(CC) $(CFLAGS) -E asm/md5-ia64.S | \
|
||||
$(PERL) -ne 's/;\s+/;\n/g; print;' > $@
|
||||
|
||||
md5-sparcv9.S: asm/md5-sparcv9.pl
|
||||
$(PERL) asm/md5-sparcv9.pl $@ $(CFLAGS)
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
|
||||
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
|
||||
|
||||
install:
|
||||
@[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
|
||||
@headerlist="$(EXHEADER)"; for i in $$headerlist ; \
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
|
||||
tags:
|
||||
ctags $(SRC)
|
||||
|
||||
tests:
|
||||
|
||||
lint:
|
||||
lint -DLINT $(INCLUDES) $(SRC)>fluff
|
||||
|
||||
update: depend
|
||||
|
||||
depend:
|
||||
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
|
||||
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
|
||||
|
||||
dclean:
|
||||
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
|
||||
mv -f Makefile.new $(MAKEFILE)
|
||||
|
||||
clean:
|
||||
rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
||||
|
||||
md5_dgst.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
md5_dgst.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
|
||||
md5_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
md5_dgst.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
md5_dgst.o: ../../include/openssl/symhacks.h ../md32_common.h md5_dgst.c
|
||||
md5_dgst.o: md5_locl.h
|
||||
md5_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
md5_one.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
|
||||
md5_one.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
md5_one.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
md5_one.o: ../../include/openssl/symhacks.h md5_one.c
|
||||
@@ -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');
|
||||
|
||||
22
crypto/md5/build.info
Normal file
22
crypto/md5/build.info
Normal file
@@ -0,0 +1,22 @@
|
||||
LIBS=../../libcrypto
|
||||
SOURCE[../../libcrypto]=\
|
||||
md5_dgst.c md5_one.c {- $target{md5_asm_src} -}
|
||||
|
||||
GENERATE[md5-586.s]=asm/md5-586.pl $(PERLASM_SCHEME) $(CFLAGS) $(LIB_CFLAGS)
|
||||
|
||||
GENERATE[md5-x86_64.s]=asm/md5-x86_64.pl $(PERLASM_SCHEME)
|
||||
|
||||
GENERATE[md5-sparcv9.S]=asm/md5-sparcv9.pl $(PERLASM_SCHEME)
|
||||
INCLUDE[md5-sparcv9.o]=..
|
||||
|
||||
BEGINRAW[makefile(windows)]
|
||||
{- $builddir -}\md5-ia64.asm: {- $sourcedir -}\asm\md5-ia64.S
|
||||
$(CC) $(CFLAGS) -EP {- $sourcedir -}\asm\md5-ia64.S > $@.i && move /Y $@.i $@
|
||||
ENDRAW[makefile(windows)]
|
||||
|
||||
BEGINRAW[Makefile]
|
||||
{- $builddir -}/md5-ia64.s: {- $sourcedir -}/asm/md5-ia64.S
|
||||
$(CC) $(CFLAGS) -E {- $sourcedir -}/asm/md5-ia64.S | \
|
||||
$(PERL) -ne 's/;\s+/;\n/g; print;' > $@
|
||||
|
||||
ENDRAW[Makefile]
|
||||
121
crypto/md5/md5.c
121
crypto/md5/md5.c
@@ -1,121 +0,0 @@
|
||||
/* crypto/md5/md5.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
#define BUFSIZE 1024*16
|
||||
|
||||
void do_fp(FILE *f);
|
||||
void pt(unsigned char *md);
|
||||
#if !defined(_OSD_POSIX) && !defined(__DJGPP__)
|
||||
int read(int, void *, unsigned int);
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i, err = 0;
|
||||
FILE *IN;
|
||||
|
||||
if (argc == 1) {
|
||||
do_fp(stdin);
|
||||
} else {
|
||||
for (i = 1; i < argc; i++) {
|
||||
IN = fopen(argv[i], "r");
|
||||
if (IN == NULL) {
|
||||
perror(argv[i]);
|
||||
err++;
|
||||
continue;
|
||||
}
|
||||
printf("MD5(%s)= ", argv[i]);
|
||||
do_fp(IN);
|
||||
fclose(IN);
|
||||
}
|
||||
}
|
||||
exit(err);
|
||||
}
|
||||
|
||||
void do_fp(FILE *f)
|
||||
{
|
||||
MD5_CTX c;
|
||||
unsigned char md[MD5_DIGEST_LENGTH];
|
||||
int fd;
|
||||
int i;
|
||||
static unsigned char buf[BUFSIZE];
|
||||
|
||||
fd = fileno(f);
|
||||
MD5_Init(&c);
|
||||
for (;;) {
|
||||
i = read(fd, buf, BUFSIZE);
|
||||
if (i <= 0)
|
||||
break;
|
||||
MD5_Update(&c, buf, (unsigned long)i);
|
||||
}
|
||||
MD5_Final(&(md[0]), &c);
|
||||
pt(md);
|
||||
}
|
||||
|
||||
void pt(unsigned char *md)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MD5_DIGEST_LENGTH; i++)
|
||||
printf("%02x", md[i]);
|
||||
printf("\n");
|
||||
}
|
||||
119
crypto/md5/md5.h
119
crypto/md5/md5.h
@@ -1,119 +0,0 @@
|
||||
/* crypto/md5/md5.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_MD5_H
|
||||
# define HEADER_MD5_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
# include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
# ifdef OPENSSL_NO_MD5
|
||||
# error MD5 is disabled.
|
||||
# endif
|
||||
|
||||
/*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* ! MD5_LONG has to be at least 32 bits wide. If it's wider, then !
|
||||
* ! MD5_LONG_LOG2 has to be defined along. !
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*/
|
||||
|
||||
# if defined(__LP32__)
|
||||
# define MD5_LONG unsigned long
|
||||
# elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__)
|
||||
# define MD5_LONG unsigned long
|
||||
# define MD5_LONG_LOG2 3
|
||||
/*
|
||||
* _CRAY note. I could declare short, but I have no idea what impact
|
||||
* does it have on performance on none-T3E machines. I could declare
|
||||
* int, but at least on C90 sizeof(int) can be chosen at compile time.
|
||||
* So I've chosen long...
|
||||
* <appro@fy.chalmers.se>
|
||||
*/
|
||||
# else
|
||||
# define MD5_LONG unsigned int
|
||||
# endif
|
||||
|
||||
# define MD5_CBLOCK 64
|
||||
# define MD5_LBLOCK (MD5_CBLOCK/4)
|
||||
# define MD5_DIGEST_LENGTH 16
|
||||
|
||||
typedef struct MD5state_st {
|
||||
MD5_LONG A, B, C, D;
|
||||
MD5_LONG Nl, Nh;
|
||||
MD5_LONG data[MD5_LBLOCK];
|
||||
unsigned int num;
|
||||
} MD5_CTX;
|
||||
|
||||
# ifdef OPENSSL_FIPS
|
||||
int private_MD5_Init(MD5_CTX *c);
|
||||
# endif
|
||||
int MD5_Init(MD5_CTX *c);
|
||||
int MD5_Update(MD5_CTX *c, const void *data, size_t len);
|
||||
int MD5_Final(unsigned char *md, MD5_CTX *c);
|
||||
unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);
|
||||
void MD5_Transform(MD5_CTX *c, const unsigned char *b);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,67 +1,15 @@
|
||||
/* crypto/md5/md5_dgst.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "md5_locl.h"
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
const char MD5_version[] = "MD5" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
/*
|
||||
* Implemented from RFC1321 The MD5 Message-Digest Algorithm
|
||||
@@ -72,7 +20,7 @@ const char MD5_version[] = "MD5" OPENSSL_VERSION_PTEXT;
|
||||
#define INIT_DATA_C (unsigned long)0x98badcfeL
|
||||
#define INIT_DATA_D (unsigned long)0x10325476L
|
||||
|
||||
fips_md_init(MD5)
|
||||
int MD5_Init(MD5_CTX *c)
|
||||
{
|
||||
memset(c, 0, sizeof(*c));
|
||||
c->A = INIT_DATA_A;
|
||||
@@ -106,52 +54,52 @@ void md5_block_data_order(MD5_CTX *c, const void *data_, size_t num)
|
||||
D = c->D;
|
||||
|
||||
for (; num--;) {
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(0) = l;
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(1) = l;
|
||||
/* Round 0 */
|
||||
R0(A, B, C, D, X(0), 7, 0xd76aa478L);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(2) = l;
|
||||
R0(D, A, B, C, X(1), 12, 0xe8c7b756L);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(3) = l;
|
||||
R0(C, D, A, B, X(2), 17, 0x242070dbL);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(4) = l;
|
||||
R0(B, C, D, A, X(3), 22, 0xc1bdceeeL);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(5) = l;
|
||||
R0(A, B, C, D, X(4), 7, 0xf57c0fafL);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(6) = l;
|
||||
R0(D, A, B, C, X(5), 12, 0x4787c62aL);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(7) = l;
|
||||
R0(C, D, A, B, X(6), 17, 0xa8304613L);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(8) = l;
|
||||
R0(B, C, D, A, X(7), 22, 0xfd469501L);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(9) = l;
|
||||
R0(A, B, C, D, X(8), 7, 0x698098d8L);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(10) = l;
|
||||
R0(D, A, B, C, X(9), 12, 0x8b44f7afL);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(11) = l;
|
||||
R0(C, D, A, B, X(10), 17, 0xffff5bb1L);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(12) = l;
|
||||
R0(B, C, D, A, X(11), 22, 0x895cd7beL);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(13) = l;
|
||||
R0(A, B, C, D, X(12), 7, 0x6b901122L);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(14) = l;
|
||||
R0(D, A, B, C, X(13), 12, 0xfd987193L);
|
||||
HOST_c2l(data, l);
|
||||
(void)HOST_c2l(data, l);
|
||||
X(15) = l;
|
||||
R0(C, D, A, B, X(14), 17, 0xa679438eL);
|
||||
R0(B, C, D, A, X(15), 22, 0x49b40821L);
|
||||
|
||||
@@ -1,59 +1,10 @@
|
||||
/* crypto/md5/md5_locl.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -61,12 +12,8 @@
|
||||
#include <openssl/e_os2.h>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
#ifndef MD5_LONG_LOG2
|
||||
# define MD5_LONG_LOG2 2 /* default to 32 bits */
|
||||
#endif
|
||||
|
||||
#ifdef MD5_ASM
|
||||
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) || \
|
||||
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
|
||||
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)
|
||||
# define md5_block_data_order md5_block_asm_data_order
|
||||
# elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
|
||||
@@ -95,7 +42,7 @@ void md5_block_data_order(MD5_CTX *c, const void *p, size_t num);
|
||||
} while (0)
|
||||
#define HASH_BLOCK_DATA_ORDER md5_block_data_order
|
||||
|
||||
#include "md32_common.h"
|
||||
#include "internal/md32_common.h"
|
||||
|
||||
/*-
|
||||
#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
|
||||
|
||||
@@ -1,59 +1,10 @@
|
||||
/* crypto/md5/md5_one.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
//
|
||||
// gettsc.inl
|
||||
//
|
||||
// gives access to the Pentium's (secret) cycle counter
|
||||
//
|
||||
// This software was written by Leonard Janke (janke@unixg.ubc.ca)
|
||||
// in 1996-7 and is entered, by him, into the public domain.
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
void GetTSC(unsigned long&);
|
||||
#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax];
|
||||
#elif defined(__GNUC__)
|
||||
inline
|
||||
void GetTSC(unsigned long& tsc)
|
||||
{
|
||||
asm volatile(".byte 15, 49\n\t"
|
||||
: "=eax" (tsc)
|
||||
:
|
||||
: "%edx", "%eax");
|
||||
}
|
||||
#elif defined(_MSC_VER)
|
||||
inline
|
||||
void GetTSC(unsigned long& tsc)
|
||||
{
|
||||
unsigned long a;
|
||||
__asm _emit 0fh
|
||||
__asm _emit 31h
|
||||
__asm mov a, eax;
|
||||
tsc=a;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
extern "C" {
|
||||
void md5_block_x86(MD5_CTX *ctx, unsigned char *buffer,int num);
|
||||
}
|
||||
|
||||
void main(int argc,char *argv[])
|
||||
{
|
||||
unsigned char buffer[64*256];
|
||||
MD5_CTX ctx;
|
||||
unsigned long s1,s2,e1,e2;
|
||||
unsigned char k[16];
|
||||
unsigned long data[2];
|
||||
unsigned char iv[8];
|
||||
int i,num=0,numm;
|
||||
int j=0;
|
||||
|
||||
if (argc >= 2)
|
||||
num=atoi(argv[1]);
|
||||
|
||||
if (num == 0) num=16;
|
||||
if (num > 250) num=16;
|
||||
numm=num+2;
|
||||
num*=64;
|
||||
numm*=64;
|
||||
|
||||
for (j=0; j<6; j++)
|
||||
{
|
||||
for (i=0; i<10; i++) /**/
|
||||
{
|
||||
md5_block_x86(&ctx,buffer,numm);
|
||||
GetTSC(s1);
|
||||
md5_block_x86(&ctx,buffer,numm);
|
||||
GetTSC(e1);
|
||||
GetTSC(s2);
|
||||
md5_block_x86(&ctx,buffer,num);
|
||||
GetTSC(e2);
|
||||
md5_block_x86(&ctx,buffer,num);
|
||||
}
|
||||
printf("md5 (%d bytes) %d %d (%.2f)\n",num,
|
||||
e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
/* crypto/md5/md5test.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../e_os.h"
|
||||
|
||||
#ifdef OPENSSL_NO_MD5
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("No MD5 support\n");
|
||||
return (0);
|
||||
}
|
||||
#else
|
||||
# include <openssl/evp.h>
|
||||
# include <openssl/md5.h>
|
||||
|
||||
static char *test[] = {
|
||||
"",
|
||||
"a",
|
||||
"abc",
|
||||
"message digest",
|
||||
"abcdefghijklmnopqrstuvwxyz",
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
||||
"12345678901234567890123456789012345678901234567890123456789012345678901234567890",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static char *ret[] = {
|
||||
"d41d8cd98f00b204e9800998ecf8427e",
|
||||
"0cc175b9c0f1b6a831c399e269772661",
|
||||
"900150983cd24fb0d6963f7d28e17f72",
|
||||
"f96b697d7cb7938d525a2f31aaf161d0",
|
||||
"c3fcd3d76192e4007dfb496cca67e13b",
|
||||
"d174ab98d277d9f5a5611c2c9f419d9f",
|
||||
"57edf4a22be3c955ac49da2e2107b67a",
|
||||
};
|
||||
|
||||
static char *pt(unsigned char *md);
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i, err = 0;
|
||||
char **P, **R;
|
||||
char *p;
|
||||
unsigned char md[MD5_DIGEST_LENGTH];
|
||||
|
||||
P = test;
|
||||
R = ret;
|
||||
i = 1;
|
||||
while (*P != NULL) {
|
||||
EVP_Digest(&(P[0][0]), strlen((char *)*P), md, NULL, EVP_md5(), NULL);
|
||||
p = pt(md);
|
||||
if (strcmp(p, (char *)*R) != 0) {
|
||||
printf("error calculating MD5 on '%s'\n", *P);
|
||||
printf("got %s instead of %s\n", p, *R);
|
||||
err++;
|
||||
} else
|
||||
printf("test %d ok\n", i);
|
||||
i++;
|
||||
R++;
|
||||
P++;
|
||||
}
|
||||
|
||||
# ifdef OPENSSL_SYS_NETWARE
|
||||
if (err)
|
||||
printf("ERROR: %d\n", err);
|
||||
# endif
|
||||
EXIT(err);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static char *pt(unsigned char *md)
|
||||
{
|
||||
int i;
|
||||
static char buf[80];
|
||||
|
||||
for (i = 0; i < MD5_DIGEST_LENGTH; i++)
|
||||
sprintf(&(buf[i * 2]), "%02x", md[i]);
|
||||
return (buf);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user