diff options
Diffstat (limited to 'src/lib/libcrypto/ripemd')
-rw-r--r-- | src/lib/libcrypto/ripemd/Makefile | 111 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/Makefile.ssl | 108 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/README | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/asm/rips.cpp | 82 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/ripemd.h | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/rmd160.c | 127 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/rmd_dgst.c | 7 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/rmdtest.c | 145 |
8 files changed, 577 insertions, 8 deletions
diff --git a/src/lib/libcrypto/ripemd/Makefile b/src/lib/libcrypto/ripemd/Makefile new file mode 100644 index 0000000000..dc086e3434 --- /dev/null +++ b/src/lib/libcrypto/ripemd/Makefile | |||
@@ -0,0 +1,111 @@ | |||
1 | # | ||
2 | # SSLeay/crypto/ripemd/Makefile | ||
3 | # | ||
4 | |||
5 | DIR= ripemd | ||
6 | TOP= ../.. | ||
7 | CC= cc | ||
8 | CPP= $(CC) -E | ||
9 | INCLUDES= | ||
10 | CFLAG=-g | ||
11 | INSTALL_PREFIX= | ||
12 | OPENSSLDIR= /usr/local/ssl | ||
13 | INSTALLTOP=/usr/local/ssl | ||
14 | MAKEDEPPROG= makedepend | ||
15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
16 | MAKEFILE= Makefile | ||
17 | AR= ar r | ||
18 | |||
19 | RIP_ASM_OBJ= | ||
20 | |||
21 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
22 | ASFLAGS= $(INCLUDES) $(ASFLAG) | ||
23 | |||
24 | GENERAL=Makefile | ||
25 | TEST=rmdtest.c | ||
26 | APPS= | ||
27 | |||
28 | LIB=$(TOP)/libcrypto.a | ||
29 | LIBSRC=rmd_dgst.c rmd_one.c | ||
30 | LIBOBJ=rmd_dgst.o rmd_one.o $(RMD160_ASM_OBJ) | ||
31 | |||
32 | SRC= $(LIBSRC) | ||
33 | |||
34 | EXHEADER= ripemd.h | ||
35 | HEADER= rmd_locl.h rmdconst.h $(EXHEADER) | ||
36 | |||
37 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
38 | |||
39 | top: | ||
40 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
41 | |||
42 | all: lib | ||
43 | |||
44 | lib: $(LIBOBJ) | ||
45 | $(AR) $(LIB) $(LIBOBJ) | ||
46 | $(RANLIB) $(LIB) || echo Never mind. | ||
47 | @touch lib | ||
48 | |||
49 | # elf | ||
50 | asm/rm86-elf.s: asm/rmd-586.pl ../perlasm/x86asm.pl | ||
51 | (cd asm; $(PERL) rmd-586.pl elf $(CFLAGS) > rm86-elf.s) | ||
52 | |||
53 | # a.out | ||
54 | asm/rm86-out.o: asm/rm86unix.cpp | ||
55 | $(CPP) -DOUT asm/rm86unix.cpp | as -o asm/rm86-out.o | ||
56 | |||
57 | # bsdi | ||
58 | asm/rm86bsdi.o: asm/rm86unix.cpp | ||
59 | $(CPP) -DBSDI asm/rm86unix.cpp | sed 's/ :/:/' | as -o asm/rm86bsdi.o | ||
60 | |||
61 | asm/rm86unix.cpp: asm/rmd-586.pl ../perlasm/x86asm.pl | ||
62 | (cd asm; $(PERL) rmd-586.pl cpp >rm86unix.cpp) | ||
63 | |||
64 | files: | ||
65 | $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO | ||
66 | |||
67 | links: | ||
68 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
69 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
70 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
71 | |||
72 | install: | ||
73 | @headerlist="$(EXHEADER)"; for i in $$headerlist ; \ | ||
74 | do \ | ||
75 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
76 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
77 | done; | ||
78 | |||
79 | tags: | ||
80 | ctags $(SRC) | ||
81 | |||
82 | tests: | ||
83 | |||
84 | lint: | ||
85 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
86 | |||
87 | depend: | ||
88 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
89 | |||
90 | dclean: | ||
91 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
92 | mv -f Makefile.new $(MAKEFILE) | ||
93 | |||
94 | clean: | ||
95 | rm -f asm/rm86unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
96 | |||
97 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
98 | |||
99 | rmd_dgst.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | ||
100 | rmd_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
101 | rmd_dgst.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | ||
102 | rmd_dgst.o: ../../include/openssl/opensslconf.h | ||
103 | rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h | ||
104 | rmd_dgst.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
105 | rmd_dgst.o: ../../include/openssl/symhacks.h ../md32_common.h rmd_dgst.c | ||
106 | rmd_dgst.o: rmd_locl.h rmdconst.h | ||
107 | rmd_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
108 | rmd_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
109 | rmd_one.o: ../../include/openssl/ripemd.h ../../include/openssl/safestack.h | ||
110 | rmd_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
111 | rmd_one.o: rmd_one.c | ||
diff --git a/src/lib/libcrypto/ripemd/Makefile.ssl b/src/lib/libcrypto/ripemd/Makefile.ssl new file mode 100644 index 0000000000..f22ac790ae --- /dev/null +++ b/src/lib/libcrypto/ripemd/Makefile.ssl | |||
@@ -0,0 +1,108 @@ | |||
1 | # | ||
2 | # SSLeay/crypto/ripemd/Makefile | ||
3 | # | ||
4 | |||
5 | DIR= ripemd | ||
6 | TOP= ../.. | ||
7 | CC= cc | ||
8 | CPP= $(CC) -E | ||
9 | INCLUDES= | ||
10 | CFLAG=-g | ||
11 | INSTALL_PREFIX= | ||
12 | OPENSSLDIR= /usr/local/ssl | ||
13 | INSTALLTOP=/usr/local/ssl | ||
14 | MAKE= make -f Makefile.ssl | ||
15 | MAKEDEPPROG= makedepend | ||
16 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
17 | MAKEFILE= Makefile.ssl | ||
18 | AR= ar r | ||
19 | |||
20 | RIP_ASM_OBJ= | ||
21 | |||
22 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
23 | ASFLAGS= $(INCLUDES) $(ASFLAG) | ||
24 | |||
25 | GENERAL=Makefile | ||
26 | TEST=rmdtest.c | ||
27 | APPS= | ||
28 | |||
29 | LIB=$(TOP)/libcrypto.a | ||
30 | LIBSRC=rmd_dgst.c rmd_one.c | ||
31 | LIBOBJ=rmd_dgst.o rmd_one.o $(RMD160_ASM_OBJ) | ||
32 | |||
33 | SRC= $(LIBSRC) | ||
34 | |||
35 | EXHEADER= ripemd.h | ||
36 | HEADER= rmd_locl.h rmdconst.h $(EXHEADER) | ||
37 | |||
38 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
39 | |||
40 | top: | ||
41 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
42 | |||
43 | all: lib | ||
44 | |||
45 | lib: $(LIBOBJ) | ||
46 | $(AR) $(LIB) $(LIBOBJ) | ||
47 | $(RANLIB) $(LIB) || echo Never mind. | ||
48 | @touch lib | ||
49 | |||
50 | # elf | ||
51 | asm/rm86-elf.s: asm/rmd-586.pl ../perlasm/x86asm.pl | ||
52 | (cd asm; $(PERL) rmd-586.pl elf $(CFLAGS) > rm86-elf.s) | ||
53 | |||
54 | # a.out | ||
55 | asm/rm86-out.o: asm/rm86unix.cpp | ||
56 | $(CPP) -DOUT asm/rm86unix.cpp | as -o asm/rm86-out.o | ||
57 | |||
58 | # bsdi | ||
59 | asm/rm86bsdi.o: asm/rm86unix.cpp | ||
60 | $(CPP) -DBSDI asm/rm86unix.cpp | sed 's/ :/:/' | as -o asm/rm86bsdi.o | ||
61 | |||
62 | asm/rm86unix.cpp: asm/rmd-586.pl ../perlasm/x86asm.pl | ||
63 | (cd asm; $(PERL) rmd-586.pl cpp >rm86unix.cpp) | ||
64 | |||
65 | files: | ||
66 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | ||
67 | |||
68 | links: | ||
69 | @sh $(TOP)/util/point.sh Makefile.ssl Makefile | ||
70 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
71 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
72 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
73 | |||
74 | install: | ||
75 | @for i in $(EXHEADER) ; \ | ||
76 | do \ | ||
77 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
78 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
79 | done; | ||
80 | |||
81 | tags: | ||
82 | ctags $(SRC) | ||
83 | |||
84 | tests: | ||
85 | |||
86 | lint: | ||
87 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
88 | |||
89 | depend: | ||
90 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
91 | |||
92 | dclean: | ||
93 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
94 | mv -f Makefile.new $(MAKEFILE) | ||
95 | |||
96 | clean: | ||
97 | rm -f asm/rm86unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
98 | |||
99 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
100 | |||
101 | rmd_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h | ||
102 | rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h | ||
103 | rmd_dgst.o: ../md32_common.h rmd_dgst.c rmd_locl.h rmdconst.h | ||
104 | rmd_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | ||
105 | rmd_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
106 | rmd_one.o: ../../include/openssl/ripemd.h ../../include/openssl/safestack.h | ||
107 | rmd_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
108 | rmd_one.o: rmd_one.c | ||
diff --git a/src/lib/libcrypto/ripemd/README b/src/lib/libcrypto/ripemd/README index 7097707264..f1ffc8b134 100644 --- a/src/lib/libcrypto/ripemd/README +++ b/src/lib/libcrypto/ripemd/README | |||
@@ -4,7 +4,7 @@ http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html | |||
4 | This is my implementation of RIPEMD-160. The pentium assember is a little | 4 | This is my implementation of RIPEMD-160. The pentium assember is a little |
5 | off the pace since I only get 1050 cycles, while the best is 1013. | 5 | off the pace since I only get 1050 cycles, while the best is 1013. |
6 | I have a few ideas for how to get another 20 or so cycles, but at | 6 | I have a few ideas for how to get another 20 or so cycles, but at |
7 | this point I will not bother right now. I belive the trick will be | 7 | this point I will not bother right now. I believe the trick will be |
8 | to remove my 'copy X array onto stack' until inside the RIP1() finctions the | 8 | to remove my 'copy X array onto stack' until inside the RIP1() finctions the |
9 | first time round. To do this I need another register and will only have one | 9 | first time round. To do this I need another register and will only have one |
10 | temporary one. A bit tricky.... I can also cleanup the saving of the 5 words | 10 | temporary one. A bit tricky.... I can also cleanup the saving of the 5 words |
diff --git a/src/lib/libcrypto/ripemd/asm/rips.cpp b/src/lib/libcrypto/ripemd/asm/rips.cpp new file mode 100644 index 0000000000..f7a13677a9 --- /dev/null +++ b/src/lib/libcrypto/ripemd/asm/rips.cpp | |||
@@ -0,0 +1,82 @@ | |||
1 | // | ||
2 | // gettsc.inl | ||
3 | // | ||
4 | // gives access to the Pentium's (secret) cycle counter | ||
5 | // | ||
6 | // This software was written by Leonard Janke (janke@unixg.ubc.ca) | ||
7 | // in 1996-7 and is entered, by him, into the public domain. | ||
8 | |||
9 | #if defined(__WATCOMC__) | ||
10 | void GetTSC(unsigned long&); | ||
11 | #pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax]; | ||
12 | #elif defined(__GNUC__) | ||
13 | inline | ||
14 | void GetTSC(unsigned long& tsc) | ||
15 | { | ||
16 | asm volatile(".byte 15, 49\n\t" | ||
17 | : "=eax" (tsc) | ||
18 | : | ||
19 | : "%edx", "%eax"); | ||
20 | } | ||
21 | #elif defined(_MSC_VER) | ||
22 | inline | ||
23 | void GetTSC(unsigned long& tsc) | ||
24 | { | ||
25 | unsigned long a; | ||
26 | __asm _emit 0fh | ||
27 | __asm _emit 31h | ||
28 | __asm mov a, eax; | ||
29 | tsc=a; | ||
30 | } | ||
31 | #endif | ||
32 | |||
33 | #include <stdio.h> | ||
34 | #include <stdlib.h> | ||
35 | #include <openssl/ripemd.h> | ||
36 | |||
37 | #define ripemd160_block_x86 ripemd160_block_asm_host_order | ||
38 | |||
39 | extern "C" { | ||
40 | void ripemd160_block_x86(RIPEMD160_CTX *ctx, unsigned char *buffer,int num); | ||
41 | } | ||
42 | |||
43 | void main(int argc,char *argv[]) | ||
44 | { | ||
45 | unsigned char buffer[64*256]; | ||
46 | RIPEMD160_CTX ctx; | ||
47 | unsigned long s1,s2,e1,e2; | ||
48 | unsigned char k[16]; | ||
49 | unsigned long data[2]; | ||
50 | unsigned char iv[8]; | ||
51 | int i,num=0,numm; | ||
52 | int j=0; | ||
53 | |||
54 | if (argc >= 2) | ||
55 | num=atoi(argv[1]); | ||
56 | |||
57 | if (num == 0) num=16; | ||
58 | if (num > 250) num=16; | ||
59 | numm=num+2; | ||
60 | #if 0 | ||
61 | num*=64; | ||
62 | numm*=64; | ||
63 | #endif | ||
64 | |||
65 | for (j=0; j<6; j++) | ||
66 | { | ||
67 | for (i=0; i<10; i++) /**/ | ||
68 | { | ||
69 | ripemd160_block_x86(&ctx,buffer,numm); | ||
70 | GetTSC(s1); | ||
71 | ripemd160_block_x86(&ctx,buffer,numm); | ||
72 | GetTSC(e1); | ||
73 | GetTSC(s2); | ||
74 | ripemd160_block_x86(&ctx,buffer,num); | ||
75 | GetTSC(e2); | ||
76 | ripemd160_block_x86(&ctx,buffer,num); | ||
77 | } | ||
78 | printf("ripemd160 (%d bytes) %d %d (%.2f)\n",num*64, | ||
79 | e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2); | ||
80 | } | ||
81 | } | ||
82 | |||
diff --git a/src/lib/libcrypto/ripemd/ripemd.h b/src/lib/libcrypto/ripemd/ripemd.h index 7d0d998189..78d5f36560 100644 --- a/src/lib/libcrypto/ripemd/ripemd.h +++ b/src/lib/libcrypto/ripemd/ripemd.h | |||
@@ -90,9 +90,6 @@ typedef struct RIPEMD160state_st | |||
90 | int num; | 90 | int num; |
91 | } RIPEMD160_CTX; | 91 | } RIPEMD160_CTX; |
92 | 92 | ||
93 | #ifdef OPENSSL_FIPS | ||
94 | int private_RIPEMD160_Init(RIPEMD160_CTX *c); | ||
95 | #endif | ||
96 | int RIPEMD160_Init(RIPEMD160_CTX *c); | 93 | int RIPEMD160_Init(RIPEMD160_CTX *c); |
97 | int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, unsigned long len); | 94 | int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, unsigned long len); |
98 | int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); | 95 | int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); |
diff --git a/src/lib/libcrypto/ripemd/rmd160.c b/src/lib/libcrypto/ripemd/rmd160.c new file mode 100644 index 0000000000..b0ec574498 --- /dev/null +++ b/src/lib/libcrypto/ripemd/rmd160.c | |||
@@ -0,0 +1,127 @@ | |||
1 | /* crypto/ripemd/rmd160.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | #include <stdlib.h> | ||
61 | #include <openssl/ripemd.h> | ||
62 | |||
63 | #define BUFSIZE 1024*16 | ||
64 | |||
65 | void do_fp(FILE *f); | ||
66 | void pt(unsigned char *md); | ||
67 | #if !defined(_OSD_POSIX) && !defined(__DJGPP__) | ||
68 | int read(int, void *, unsigned int); | ||
69 | #endif | ||
70 | |||
71 | int main(int argc, char **argv) | ||
72 | { | ||
73 | int i,err=0; | ||
74 | FILE *IN; | ||
75 | |||
76 | if (argc == 1) | ||
77 | { | ||
78 | do_fp(stdin); | ||
79 | } | ||
80 | else | ||
81 | { | ||
82 | for (i=1; i<argc; i++) | ||
83 | { | ||
84 | IN=fopen(argv[i],"r"); | ||
85 | if (IN == NULL) | ||
86 | { | ||
87 | perror(argv[i]); | ||
88 | err++; | ||
89 | continue; | ||
90 | } | ||
91 | printf("RIPEMD160(%s)= ",argv[i]); | ||
92 | do_fp(IN); | ||
93 | fclose(IN); | ||
94 | } | ||
95 | } | ||
96 | exit(err); | ||
97 | } | ||
98 | |||
99 | void do_fp(FILE *f) | ||
100 | { | ||
101 | RIPEMD160_CTX c; | ||
102 | unsigned char md[RIPEMD160_DIGEST_LENGTH]; | ||
103 | int fd; | ||
104 | int i; | ||
105 | static unsigned char buf[BUFSIZE]; | ||
106 | |||
107 | fd=fileno(f); | ||
108 | RIPEMD160_Init(&c); | ||
109 | for (;;) | ||
110 | { | ||
111 | i=read(fd,buf,BUFSIZE); | ||
112 | if (i <= 0) break; | ||
113 | RIPEMD160_Update(&c,buf,(unsigned long)i); | ||
114 | } | ||
115 | RIPEMD160_Final(&(md[0]),&c); | ||
116 | pt(md); | ||
117 | } | ||
118 | |||
119 | void pt(unsigned char *md) | ||
120 | { | ||
121 | int i; | ||
122 | |||
123 | for (i=0; i<RIPEMD160_DIGEST_LENGTH; i++) | ||
124 | printf("%02x",md[i]); | ||
125 | printf("\n"); | ||
126 | } | ||
127 | |||
diff --git a/src/lib/libcrypto/ripemd/rmd_dgst.c b/src/lib/libcrypto/ripemd/rmd_dgst.c index 5dff6bafa1..28896512e7 100644 --- a/src/lib/libcrypto/ripemd/rmd_dgst.c +++ b/src/lib/libcrypto/ripemd/rmd_dgst.c | |||
@@ -58,7 +58,6 @@ | |||
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include "rmd_locl.h" | 60 | #include "rmd_locl.h" |
61 | #include <openssl/fips.h> | ||
62 | #include <openssl/opensslv.h> | 61 | #include <openssl/opensslv.h> |
63 | 62 | ||
64 | const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT; | 63 | const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT; |
@@ -70,7 +69,7 @@ const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT; | |||
70 | void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,int num); | 69 | void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,int num); |
71 | # endif | 70 | # endif |
72 | 71 | ||
73 | FIPS_NON_FIPS_MD_Init(RIPEMD160) | 72 | int RIPEMD160_Init(RIPEMD160_CTX *c) |
74 | { | 73 | { |
75 | c->A=RIPEMD160_A; | 74 | c->A=RIPEMD160_A; |
76 | c->B=RIPEMD160_B; | 75 | c->B=RIPEMD160_B; |
@@ -91,7 +90,7 @@ FIPS_NON_FIPS_MD_Init(RIPEMD160) | |||
91 | void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num) | 90 | void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num) |
92 | { | 91 | { |
93 | const RIPEMD160_LONG *XX=p; | 92 | const RIPEMD160_LONG *XX=p; |
94 | register unsigned MD32_REG_T A,B,C,D,E; | 93 | register volatile unsigned MD32_REG_T A,B,C,D,E; |
95 | register unsigned MD32_REG_T a,b,c,d,e; | 94 | register unsigned MD32_REG_T a,b,c,d,e; |
96 | 95 | ||
97 | for (;num--;XX+=HASH_LBLOCK) | 96 | for (;num--;XX+=HASH_LBLOCK) |
@@ -291,7 +290,7 @@ void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num) | |||
291 | void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, int num) | 290 | void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, int num) |
292 | { | 291 | { |
293 | const unsigned char *data=p; | 292 | const unsigned char *data=p; |
294 | register unsigned MD32_REG_T A,B,C,D,E; | 293 | register volatile unsigned MD32_REG_T A,B,C,D,E; |
295 | unsigned MD32_REG_T a,b,c,d,e,l; | 294 | unsigned MD32_REG_T a,b,c,d,e,l; |
296 | #ifndef MD32_XARRAY | 295 | #ifndef MD32_XARRAY |
297 | /* See comment in crypto/sha/sha_locl.h for details. */ | 296 | /* See comment in crypto/sha/sha_locl.h for details. */ |
diff --git a/src/lib/libcrypto/ripemd/rmdtest.c b/src/lib/libcrypto/ripemd/rmdtest.c new file mode 100644 index 0000000000..d4c709e646 --- /dev/null +++ b/src/lib/libcrypto/ripemd/rmdtest.c | |||
@@ -0,0 +1,145 @@ | |||
1 | /* crypto/ripemd/rmdtest.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | #include <string.h> | ||
61 | #include <stdlib.h> | ||
62 | |||
63 | #include "../e_os.h" | ||
64 | |||
65 | #ifdef OPENSSL_NO_RIPEMD | ||
66 | int main(int argc, char *argv[]) | ||
67 | { | ||
68 | printf("No ripemd support\n"); | ||
69 | return(0); | ||
70 | } | ||
71 | #else | ||
72 | #include <openssl/ripemd.h> | ||
73 | #include <openssl/evp.h> | ||
74 | |||
75 | #ifdef CHARSET_EBCDIC | ||
76 | #include <openssl/ebcdic.h> | ||
77 | #endif | ||
78 | |||
79 | static char *test[]={ | ||
80 | "", | ||
81 | "a", | ||
82 | "abc", | ||
83 | "message digest", | ||
84 | "abcdefghijklmnopqrstuvwxyz", | ||
85 | "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", | ||
86 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", | ||
87 | "12345678901234567890123456789012345678901234567890123456789012345678901234567890", | ||
88 | NULL, | ||
89 | }; | ||
90 | |||
91 | static char *ret[]={ | ||
92 | "9c1185a5c5e9fc54612808977ee8f548b2258d31", | ||
93 | "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe", | ||
94 | "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc", | ||
95 | "5d0689ef49d2fae572b881b123a85ffa21595f36", | ||
96 | "f71c27109c692c1b56bbdceb5b9d2865b3708dbc", | ||
97 | "12a053384a9c0c88e405a06c27dcf49ada62eb2b", | ||
98 | "b0e20b6e3116640286ed3a87a5713079b21f5189", | ||
99 | "9b752e45573d4b39f4dbd3323cab82bf63326bfb", | ||
100 | }; | ||
101 | |||
102 | static char *pt(unsigned char *md); | ||
103 | int main(int argc, char *argv[]) | ||
104 | { | ||
105 | int i,err=0; | ||
106 | unsigned char **P,**R; | ||
107 | char *p; | ||
108 | unsigned char md[RIPEMD160_DIGEST_LENGTH]; | ||
109 | |||
110 | P=(unsigned char **)test; | ||
111 | R=(unsigned char **)ret; | ||
112 | i=1; | ||
113 | while (*P != NULL) | ||
114 | { | ||
115 | #ifdef CHARSET_EBCDIC | ||
116 | ebcdic2ascii((char *)*P, (char *)*P, strlen((char *)*P)); | ||
117 | #endif | ||
118 | EVP_Digest(&(P[0][0]),(unsigned long)strlen((char *)*P),md,NULL,EVP_ripemd160(), NULL); | ||
119 | p=pt(md); | ||
120 | if (strcmp(p,(char *)*R) != 0) | ||
121 | { | ||
122 | printf("error calculating RIPEMD160 on '%s'\n",*P); | ||
123 | printf("got %s instead of %s\n",p,*R); | ||
124 | err++; | ||
125 | } | ||
126 | else | ||
127 | printf("test %d ok\n",i); | ||
128 | i++; | ||
129 | R++; | ||
130 | P++; | ||
131 | } | ||
132 | EXIT(err); | ||
133 | return(0); | ||
134 | } | ||
135 | |||
136 | static char *pt(unsigned char *md) | ||
137 | { | ||
138 | int i; | ||
139 | static char buf[80]; | ||
140 | |||
141 | for (i=0; i<RIPEMD160_DIGEST_LENGTH; i++) | ||
142 | sprintf(&(buf[i*2]),"%02x",md[i]); | ||
143 | return(buf); | ||
144 | } | ||
145 | #endif | ||