summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ripemd
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/ripemd')
-rw-r--r--src/lib/libcrypto/ripemd/Makefile99
-rw-r--r--src/lib/libcrypto/ripemd/Makefile.ssl108
-rw-r--r--src/lib/libcrypto/ripemd/README2
-rw-r--r--src/lib/libcrypto/ripemd/asm/rips.cpp82
-rw-r--r--src/lib/libcrypto/ripemd/asm/rmd-586.pl4
-rw-r--r--src/lib/libcrypto/ripemd/ripemd.h10
-rw-r--r--src/lib/libcrypto/ripemd/rmd160.c127
-rw-r--r--src/lib/libcrypto/ripemd/rmd_dgst.c214
-rw-r--r--src/lib/libcrypto/ripemd/rmd_locl.h14
-rw-r--r--src/lib/libcrypto/ripemd/rmd_one.c2
-rw-r--r--src/lib/libcrypto/ripemd/rmdtest.c145
11 files changed, 791 insertions, 16 deletions
diff --git a/src/lib/libcrypto/ripemd/Makefile b/src/lib/libcrypto/ripemd/Makefile
new file mode 100644
index 0000000000..d55875c20c
--- /dev/null
+++ b/src/lib/libcrypto/ripemd/Makefile
@@ -0,0 +1,99 @@
1#
2# OpenSSL/crypto/ripemd/Makefile
3#
4
5DIR= ripemd
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11MAKEFILE= Makefile
12AR= ar r
13
14RIP_ASM_OBJ=
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17ASFLAGS= $(INCLUDES) $(ASFLAG)
18AFLAGS= $(ASFLAGS)
19
20GENERAL=Makefile
21TEST=rmdtest.c
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC=rmd_dgst.c rmd_one.c
26LIBOBJ=rmd_dgst.o rmd_one.o $(RMD160_ASM_OBJ)
27
28SRC= $(LIBSRC)
29
30EXHEADER= ripemd.h
31HEADER= rmd_locl.h rmdconst.h $(EXHEADER)
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38all: lib
39
40lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 $(RANLIB) $(LIB) || echo Never mind.
43 @touch lib
44
45# ELF
46rm86-elf.s: asm/rmd-586.pl ../perlasm/x86asm.pl
47 (cd asm; $(PERL) rmd-586.pl elf $(CFLAGS) > ../$@)
48# COFF
49rm86-cof.s: asm/rmd-586.pl ../perlasm/x86asm.pl
50 (cd asm; $(PERL) rmd-586.pl coff $(CFLAGS) > ../$@)
51# a.out
52rm86-out.s: asm/rmd-586.pl ../perlasm/x86asm.pl
53 (cd asm; $(PERL) rmd-586.pl a.out $(CFLAGS) > ../$@)
54
55files:
56 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
57
58links:
59 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
60 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
61 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
62
63install:
64 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
65 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
66 do \
67 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
68 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
69 done;
70
71tags:
72 ctags $(SRC)
73
74tests:
75
76lint:
77 lint -DLINT $(INCLUDES) $(SRC)>fluff
78
79depend:
80 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
81 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
82
83dclean:
84 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
85 mv -f Makefile.new $(MAKEFILE)
86
87clean:
88 rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
89
90# DO NOT DELETE THIS LINE -- make depend depends on it.
91
92rmd_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
93rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h
94rmd_dgst.o: ../md32_common.h rmd_dgst.c rmd_locl.h rmdconst.h
95rmd_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
96rmd_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
97rmd_one.o: ../../include/openssl/ossl_typ.h ../../include/openssl/ripemd.h
98rmd_one.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
99rmd_one.o: ../../include/openssl/symhacks.h 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
5DIR= ripemd
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19
20RIP_ASM_OBJ=
21
22CFLAGS= $(INCLUDES) $(CFLAG)
23ASFLAGS= $(INCLUDES) $(ASFLAG)
24
25GENERAL=Makefile
26TEST=rmdtest.c
27APPS=
28
29LIB=$(TOP)/libcrypto.a
30LIBSRC=rmd_dgst.c rmd_one.c
31LIBOBJ=rmd_dgst.o rmd_one.o $(RMD160_ASM_OBJ)
32
33SRC= $(LIBSRC)
34
35EXHEADER= ripemd.h
36HEADER= rmd_locl.h rmdconst.h $(EXHEADER)
37
38ALL= $(GENERAL) $(SRC) $(HEADER)
39
40top:
41 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
42
43all: lib
44
45lib: $(LIBOBJ)
46 $(AR) $(LIB) $(LIBOBJ)
47 $(RANLIB) $(LIB) || echo Never mind.
48 @touch lib
49
50# elf
51asm/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
55asm/rm86-out.o: asm/rm86unix.cpp
56 $(CPP) -DOUT asm/rm86unix.cpp | as -o asm/rm86-out.o
57
58# bsdi
59asm/rm86bsdi.o: asm/rm86unix.cpp
60 $(CPP) -DBSDI asm/rm86unix.cpp | sed 's/ :/:/' | as -o asm/rm86bsdi.o
61
62asm/rm86unix.cpp: asm/rmd-586.pl ../perlasm/x86asm.pl
63 (cd asm; $(PERL) rmd-586.pl cpp >rm86unix.cpp)
64
65files:
66 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
67
68links:
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
74install:
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
81tags:
82 ctags $(SRC)
83
84tests:
85
86lint:
87 lint -DLINT $(INCLUDES) $(SRC)>fluff
88
89depend:
90 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
91
92dclean:
93 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
94 mv -f Makefile.new $(MAKEFILE)
95
96clean:
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
101rmd_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
102rmd_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/ripemd.h
103rmd_dgst.o: ../md32_common.h rmd_dgst.c rmd_locl.h rmdconst.h
104rmd_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
105rmd_one.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
106rmd_one.o: ../../include/openssl/ripemd.h ../../include/openssl/safestack.h
107rmd_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
108rmd_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
4This is my implementation of RIPEMD-160. The pentium assember is a little 4This is my implementation of RIPEMD-160. The pentium assember is a little
5off the pace since I only get 1050 cycles, while the best is 1013. 5off the pace since I only get 1050 cycles, while the best is 1013.
6I have a few ideas for how to get another 20 or so cycles, but at 6I have a few ideas for how to get another 20 or so cycles, but at
7this point I will not bother right now. I belive the trick will be 7this point I will not bother right now. I believe the trick will be
8to remove my 'copy X array onto stack' until inside the RIP1() finctions the 8to remove my 'copy X array onto stack' until inside the RIP1() finctions the
9first time round. To do this I need another register and will only have one 9first time round. To do this I need another register and will only have one
10temporary one. A bit tricky.... I can also cleanup the saving of the 5 words 10temporary 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__)
10void GetTSC(unsigned long&);
11#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax];
12#elif defined(__GNUC__)
13inline
14void 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)
22inline
23void 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
39extern "C" {
40void ripemd160_block_x86(RIPEMD160_CTX *ctx, unsigned char *buffer,int num);
41}
42
43void 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/asm/rmd-586.pl b/src/lib/libcrypto/ripemd/asm/rmd-586.pl
index 4f3c4c967f..0ab6f76bff 100644
--- a/src/lib/libcrypto/ripemd/asm/rmd-586.pl
+++ b/src/lib/libcrypto/ripemd/asm/rmd-586.pl
@@ -1,7 +1,7 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2 2
3# Normal is the 3# Normal is the
4# ripemd160_block_asm_data_order(RIPEMD160_CTX *c, ULONG *X,int blocks); 4# ripemd160_block_asm_host_order(RIPEMD160_CTX *c, ULONG *X,int blocks);
5 5
6$normal=0; 6$normal=0;
7 7
@@ -56,7 +56,7 @@ $KR3=0x7A6D76E9;
56 8, 5,12, 9,12, 5,14, 6, 8,13, 6, 5,15,13,11,11, 56 8, 5,12, 9,12, 5,14, 6, 8,13, 6, 5,15,13,11,11,
57 ); 57 );
58 58
59&ripemd160_block("ripemd160_block_asm_data_order"); 59&ripemd160_block("ripemd160_block_asm_host_order");
60&asm_finish(); 60&asm_finish();
61 61
62sub Xv 62sub Xv
diff --git a/src/lib/libcrypto/ripemd/ripemd.h b/src/lib/libcrypto/ripemd/ripemd.h
index 033a5965b5..7d0d998189 100644
--- a/src/lib/libcrypto/ripemd/ripemd.h
+++ b/src/lib/libcrypto/ripemd/ripemd.h
@@ -60,7 +60,6 @@
60#define HEADER_RIPEMD_H 60#define HEADER_RIPEMD_H
61 61
62#include <openssl/e_os2.h> 62#include <openssl/e_os2.h>
63#include <stddef.h>
64 63
65#ifdef __cplusplus 64#ifdef __cplusplus
66extern "C" { 65extern "C" {
@@ -88,13 +87,16 @@ typedef struct RIPEMD160state_st
88 RIPEMD160_LONG A,B,C,D,E; 87 RIPEMD160_LONG A,B,C,D,E;
89 RIPEMD160_LONG Nl,Nh; 88 RIPEMD160_LONG Nl,Nh;
90 RIPEMD160_LONG data[RIPEMD160_LBLOCK]; 89 RIPEMD160_LONG data[RIPEMD160_LBLOCK];
91 unsigned int num; 90 int num;
92 } RIPEMD160_CTX; 91 } RIPEMD160_CTX;
93 92
93#ifdef OPENSSL_FIPS
94int private_RIPEMD160_Init(RIPEMD160_CTX *c);
95#endif
94int RIPEMD160_Init(RIPEMD160_CTX *c); 96int RIPEMD160_Init(RIPEMD160_CTX *c);
95int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); 97int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, unsigned long len);
96int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); 98int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);
97unsigned char *RIPEMD160(const unsigned char *d, size_t n, 99unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
98 unsigned char *md); 100 unsigned char *md);
99void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); 101void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);
100#ifdef __cplusplus 102#ifdef __cplusplus
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
65void do_fp(FILE *f);
66void pt(unsigned char *md);
67#if !defined(_OSD_POSIX) && !defined(__DJGPP__)
68int read(int, void *, unsigned int);
69#endif
70
71int 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
99void 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
119void 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 61626284b8..58ff010d11 100644
--- a/src/lib/libcrypto/ripemd/rmd_dgst.c
+++ b/src/lib/libcrypto/ripemd/rmd_dgst.c
@@ -58,18 +58,19 @@
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>
61#include <openssl/opensslv.h> 62#include <openssl/opensslv.h>
62 63
63const char RMD160_version[]="RIPE-MD160" OPENSSL_VERSION_PTEXT; 64const char *RMD160_version="RIPE-MD160" OPENSSL_VERSION_PTEXT;
64 65
65# ifdef RMD160_ASM 66# ifdef RMD160_ASM
66 void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,size_t num); 67 void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,int num);
67# define ripemd160_block ripemd160_block_x86 68# define ripemd160_block ripemd160_block_x86
68# else 69# else
69 void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,size_t num); 70 void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,int num);
70# endif 71# endif
71 72
72int RIPEMD160_Init(RIPEMD160_CTX *c) 73FIPS_NON_FIPS_MD_Init(RIPEMD160)
73 { 74 {
74 c->A=RIPEMD160_A; 75 c->A=RIPEMD160_A;
75 c->B=RIPEMD160_B; 76 c->B=RIPEMD160_B;
@@ -82,14 +83,215 @@ int RIPEMD160_Init(RIPEMD160_CTX *c)
82 return 1; 83 return 1;
83 } 84 }
84 85
86#ifndef ripemd160_block_host_order
87#ifdef X
88#undef X
89#endif
90#define X(i) XX[i]
91void ripemd160_block_host_order (RIPEMD160_CTX *ctx, const void *p, int num)
92 {
93 const RIPEMD160_LONG *XX=p;
94 register volatile unsigned MD32_REG_T A,B,C,D,E;
95 register unsigned MD32_REG_T a,b,c,d,e;
96
97 for (;num--;XX+=HASH_LBLOCK)
98 {
99
100 A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
101
102 RIP1(A,B,C,D,E,WL00,SL00);
103 RIP1(E,A,B,C,D,WL01,SL01);
104 RIP1(D,E,A,B,C,WL02,SL02);
105 RIP1(C,D,E,A,B,WL03,SL03);
106 RIP1(B,C,D,E,A,WL04,SL04);
107 RIP1(A,B,C,D,E,WL05,SL05);
108 RIP1(E,A,B,C,D,WL06,SL06);
109 RIP1(D,E,A,B,C,WL07,SL07);
110 RIP1(C,D,E,A,B,WL08,SL08);
111 RIP1(B,C,D,E,A,WL09,SL09);
112 RIP1(A,B,C,D,E,WL10,SL10);
113 RIP1(E,A,B,C,D,WL11,SL11);
114 RIP1(D,E,A,B,C,WL12,SL12);
115 RIP1(C,D,E,A,B,WL13,SL13);
116 RIP1(B,C,D,E,A,WL14,SL14);
117 RIP1(A,B,C,D,E,WL15,SL15);
118
119 RIP2(E,A,B,C,D,WL16,SL16,KL1);
120 RIP2(D,E,A,B,C,WL17,SL17,KL1);
121 RIP2(C,D,E,A,B,WL18,SL18,KL1);
122 RIP2(B,C,D,E,A,WL19,SL19,KL1);
123 RIP2(A,B,C,D,E,WL20,SL20,KL1);
124 RIP2(E,A,B,C,D,WL21,SL21,KL1);
125 RIP2(D,E,A,B,C,WL22,SL22,KL1);
126 RIP2(C,D,E,A,B,WL23,SL23,KL1);
127 RIP2(B,C,D,E,A,WL24,SL24,KL1);
128 RIP2(A,B,C,D,E,WL25,SL25,KL1);
129 RIP2(E,A,B,C,D,WL26,SL26,KL1);
130 RIP2(D,E,A,B,C,WL27,SL27,KL1);
131 RIP2(C,D,E,A,B,WL28,SL28,KL1);
132 RIP2(B,C,D,E,A,WL29,SL29,KL1);
133 RIP2(A,B,C,D,E,WL30,SL30,KL1);
134 RIP2(E,A,B,C,D,WL31,SL31,KL1);
135
136 RIP3(D,E,A,B,C,WL32,SL32,KL2);
137 RIP3(C,D,E,A,B,WL33,SL33,KL2);
138 RIP3(B,C,D,E,A,WL34,SL34,KL2);
139 RIP3(A,B,C,D,E,WL35,SL35,KL2);
140 RIP3(E,A,B,C,D,WL36,SL36,KL2);
141 RIP3(D,E,A,B,C,WL37,SL37,KL2);
142 RIP3(C,D,E,A,B,WL38,SL38,KL2);
143 RIP3(B,C,D,E,A,WL39,SL39,KL2);
144 RIP3(A,B,C,D,E,WL40,SL40,KL2);
145 RIP3(E,A,B,C,D,WL41,SL41,KL2);
146 RIP3(D,E,A,B,C,WL42,SL42,KL2);
147 RIP3(C,D,E,A,B,WL43,SL43,KL2);
148 RIP3(B,C,D,E,A,WL44,SL44,KL2);
149 RIP3(A,B,C,D,E,WL45,SL45,KL2);
150 RIP3(E,A,B,C,D,WL46,SL46,KL2);
151 RIP3(D,E,A,B,C,WL47,SL47,KL2);
152
153 RIP4(C,D,E,A,B,WL48,SL48,KL3);
154 RIP4(B,C,D,E,A,WL49,SL49,KL3);
155 RIP4(A,B,C,D,E,WL50,SL50,KL3);
156 RIP4(E,A,B,C,D,WL51,SL51,KL3);
157 RIP4(D,E,A,B,C,WL52,SL52,KL3);
158 RIP4(C,D,E,A,B,WL53,SL53,KL3);
159 RIP4(B,C,D,E,A,WL54,SL54,KL3);
160 RIP4(A,B,C,D,E,WL55,SL55,KL3);
161 RIP4(E,A,B,C,D,WL56,SL56,KL3);
162 RIP4(D,E,A,B,C,WL57,SL57,KL3);
163 RIP4(C,D,E,A,B,WL58,SL58,KL3);
164 RIP4(B,C,D,E,A,WL59,SL59,KL3);
165 RIP4(A,B,C,D,E,WL60,SL60,KL3);
166 RIP4(E,A,B,C,D,WL61,SL61,KL3);
167 RIP4(D,E,A,B,C,WL62,SL62,KL3);
168 RIP4(C,D,E,A,B,WL63,SL63,KL3);
169
170 RIP5(B,C,D,E,A,WL64,SL64,KL4);
171 RIP5(A,B,C,D,E,WL65,SL65,KL4);
172 RIP5(E,A,B,C,D,WL66,SL66,KL4);
173 RIP5(D,E,A,B,C,WL67,SL67,KL4);
174 RIP5(C,D,E,A,B,WL68,SL68,KL4);
175 RIP5(B,C,D,E,A,WL69,SL69,KL4);
176 RIP5(A,B,C,D,E,WL70,SL70,KL4);
177 RIP5(E,A,B,C,D,WL71,SL71,KL4);
178 RIP5(D,E,A,B,C,WL72,SL72,KL4);
179 RIP5(C,D,E,A,B,WL73,SL73,KL4);
180 RIP5(B,C,D,E,A,WL74,SL74,KL4);
181 RIP5(A,B,C,D,E,WL75,SL75,KL4);
182 RIP5(E,A,B,C,D,WL76,SL76,KL4);
183 RIP5(D,E,A,B,C,WL77,SL77,KL4);
184 RIP5(C,D,E,A,B,WL78,SL78,KL4);
185 RIP5(B,C,D,E,A,WL79,SL79,KL4);
186
187 a=A; b=B; c=C; d=D; e=E;
188 /* Do other half */
189 A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E;
190
191 RIP5(A,B,C,D,E,WR00,SR00,KR0);
192 RIP5(E,A,B,C,D,WR01,SR01,KR0);
193 RIP5(D,E,A,B,C,WR02,SR02,KR0);
194 RIP5(C,D,E,A,B,WR03,SR03,KR0);
195 RIP5(B,C,D,E,A,WR04,SR04,KR0);
196 RIP5(A,B,C,D,E,WR05,SR05,KR0);
197 RIP5(E,A,B,C,D,WR06,SR06,KR0);
198 RIP5(D,E,A,B,C,WR07,SR07,KR0);
199 RIP5(C,D,E,A,B,WR08,SR08,KR0);
200 RIP5(B,C,D,E,A,WR09,SR09,KR0);
201 RIP5(A,B,C,D,E,WR10,SR10,KR0);
202 RIP5(E,A,B,C,D,WR11,SR11,KR0);
203 RIP5(D,E,A,B,C,WR12,SR12,KR0);
204 RIP5(C,D,E,A,B,WR13,SR13,KR0);
205 RIP5(B,C,D,E,A,WR14,SR14,KR0);
206 RIP5(A,B,C,D,E,WR15,SR15,KR0);
207
208 RIP4(E,A,B,C,D,WR16,SR16,KR1);
209 RIP4(D,E,A,B,C,WR17,SR17,KR1);
210 RIP4(C,D,E,A,B,WR18,SR18,KR1);
211 RIP4(B,C,D,E,A,WR19,SR19,KR1);
212 RIP4(A,B,C,D,E,WR20,SR20,KR1);
213 RIP4(E,A,B,C,D,WR21,SR21,KR1);
214 RIP4(D,E,A,B,C,WR22,SR22,KR1);
215 RIP4(C,D,E,A,B,WR23,SR23,KR1);
216 RIP4(B,C,D,E,A,WR24,SR24,KR1);
217 RIP4(A,B,C,D,E,WR25,SR25,KR1);
218 RIP4(E,A,B,C,D,WR26,SR26,KR1);
219 RIP4(D,E,A,B,C,WR27,SR27,KR1);
220 RIP4(C,D,E,A,B,WR28,SR28,KR1);
221 RIP4(B,C,D,E,A,WR29,SR29,KR1);
222 RIP4(A,B,C,D,E,WR30,SR30,KR1);
223 RIP4(E,A,B,C,D,WR31,SR31,KR1);
224
225 RIP3(D,E,A,B,C,WR32,SR32,KR2);
226 RIP3(C,D,E,A,B,WR33,SR33,KR2);
227 RIP3(B,C,D,E,A,WR34,SR34,KR2);
228 RIP3(A,B,C,D,E,WR35,SR35,KR2);
229 RIP3(E,A,B,C,D,WR36,SR36,KR2);
230 RIP3(D,E,A,B,C,WR37,SR37,KR2);
231 RIP3(C,D,E,A,B,WR38,SR38,KR2);
232 RIP3(B,C,D,E,A,WR39,SR39,KR2);
233 RIP3(A,B,C,D,E,WR40,SR40,KR2);
234 RIP3(E,A,B,C,D,WR41,SR41,KR2);
235 RIP3(D,E,A,B,C,WR42,SR42,KR2);
236 RIP3(C,D,E,A,B,WR43,SR43,KR2);
237 RIP3(B,C,D,E,A,WR44,SR44,KR2);
238 RIP3(A,B,C,D,E,WR45,SR45,KR2);
239 RIP3(E,A,B,C,D,WR46,SR46,KR2);
240 RIP3(D,E,A,B,C,WR47,SR47,KR2);
241
242 RIP2(C,D,E,A,B,WR48,SR48,KR3);
243 RIP2(B,C,D,E,A,WR49,SR49,KR3);
244 RIP2(A,B,C,D,E,WR50,SR50,KR3);
245 RIP2(E,A,B,C,D,WR51,SR51,KR3);
246 RIP2(D,E,A,B,C,WR52,SR52,KR3);
247 RIP2(C,D,E,A,B,WR53,SR53,KR3);
248 RIP2(B,C,D,E,A,WR54,SR54,KR3);
249 RIP2(A,B,C,D,E,WR55,SR55,KR3);
250 RIP2(E,A,B,C,D,WR56,SR56,KR3);
251 RIP2(D,E,A,B,C,WR57,SR57,KR3);
252 RIP2(C,D,E,A,B,WR58,SR58,KR3);
253 RIP2(B,C,D,E,A,WR59,SR59,KR3);
254 RIP2(A,B,C,D,E,WR60,SR60,KR3);
255 RIP2(E,A,B,C,D,WR61,SR61,KR3);
256 RIP2(D,E,A,B,C,WR62,SR62,KR3);
257 RIP2(C,D,E,A,B,WR63,SR63,KR3);
258
259 RIP1(B,C,D,E,A,WR64,SR64);
260 RIP1(A,B,C,D,E,WR65,SR65);
261 RIP1(E,A,B,C,D,WR66,SR66);
262 RIP1(D,E,A,B,C,WR67,SR67);
263 RIP1(C,D,E,A,B,WR68,SR68);
264 RIP1(B,C,D,E,A,WR69,SR69);
265 RIP1(A,B,C,D,E,WR70,SR70);
266 RIP1(E,A,B,C,D,WR71,SR71);
267 RIP1(D,E,A,B,C,WR72,SR72);
268 RIP1(C,D,E,A,B,WR73,SR73);
269 RIP1(B,C,D,E,A,WR74,SR74);
270 RIP1(A,B,C,D,E,WR75,SR75);
271 RIP1(E,A,B,C,D,WR76,SR76);
272 RIP1(D,E,A,B,C,WR77,SR77);
273 RIP1(C,D,E,A,B,WR78,SR78);
274 RIP1(B,C,D,E,A,WR79,SR79);
275
276 D =ctx->B+c+D;
277 ctx->B=ctx->C+d+E;
278 ctx->C=ctx->D+e+A;
279 ctx->D=ctx->E+a+B;
280 ctx->E=ctx->A+b+C;
281 ctx->A=D;
282
283 }
284 }
285#endif
286
85#ifndef ripemd160_block_data_order 287#ifndef ripemd160_block_data_order
86#ifdef X 288#ifdef X
87#undef X 289#undef X
88#endif 290#endif
89void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, size_t num) 291void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, int num)
90 { 292 {
91 const unsigned char *data=p; 293 const unsigned char *data=p;
92 register unsigned MD32_REG_T A,B,C,D,E; 294 register volatile unsigned MD32_REG_T A,B,C,D,E;
93 unsigned MD32_REG_T a,b,c,d,e,l; 295 unsigned MD32_REG_T a,b,c,d,e,l;
94#ifndef MD32_XARRAY 296#ifndef MD32_XARRAY
95 /* See comment in crypto/sha/sha_locl.h for details. */ 297 /* See comment in crypto/sha/sha_locl.h for details. */
diff --git a/src/lib/libcrypto/ripemd/rmd_locl.h b/src/lib/libcrypto/ripemd/rmd_locl.h
index f14b346e66..7b835dfbd4 100644
--- a/src/lib/libcrypto/ripemd/rmd_locl.h
+++ b/src/lib/libcrypto/ripemd/rmd_locl.h
@@ -72,20 +72,28 @@
72 */ 72 */
73#ifdef RMD160_ASM 73#ifdef RMD160_ASM
74# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) 74# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
75# define ripemd160_block_data_order ripemd160_block_asm_data_order 75# define ripemd160_block_host_order ripemd160_block_asm_host_order
76# endif 76# endif
77#endif 77#endif
78 78
79void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,size_t num); 79void ripemd160_block_host_order (RIPEMD160_CTX *c, const void *p,int num);
80void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,int num);
81
82#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
83#define ripemd160_block_data_order ripemd160_block_host_order
84#endif
80 85
81#define DATA_ORDER_IS_LITTLE_ENDIAN 86#define DATA_ORDER_IS_LITTLE_ENDIAN
82 87
83#define HASH_LONG RIPEMD160_LONG 88#define HASH_LONG RIPEMD160_LONG
89#define HASH_LONG_LOG2 RIPEMD160_LONG_LOG2
84#define HASH_CTX RIPEMD160_CTX 90#define HASH_CTX RIPEMD160_CTX
85#define HASH_CBLOCK RIPEMD160_CBLOCK 91#define HASH_CBLOCK RIPEMD160_CBLOCK
92#define HASH_LBLOCK RIPEMD160_LBLOCK
86#define HASH_UPDATE RIPEMD160_Update 93#define HASH_UPDATE RIPEMD160_Update
87#define HASH_TRANSFORM RIPEMD160_Transform 94#define HASH_TRANSFORM RIPEMD160_Transform
88#define HASH_FINAL RIPEMD160_Final 95#define HASH_FINAL RIPEMD160_Final
96#define HASH_BLOCK_HOST_ORDER ripemd160_block_host_order
89#define HASH_MAKE_STRING(c,s) do { \ 97#define HASH_MAKE_STRING(c,s) do { \
90 unsigned long ll; \ 98 unsigned long ll; \
91 ll=(c)->A; HOST_l2c(ll,(s)); \ 99 ll=(c)->A; HOST_l2c(ll,(s)); \
@@ -94,7 +102,9 @@ void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,size_t num);
94 ll=(c)->D; HOST_l2c(ll,(s)); \ 102 ll=(c)->D; HOST_l2c(ll,(s)); \
95 ll=(c)->E; HOST_l2c(ll,(s)); \ 103 ll=(c)->E; HOST_l2c(ll,(s)); \
96 } while (0) 104 } while (0)
105#if !defined(L_ENDIAN) || defined(ripemd160_block_data_order)
97#define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order 106#define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order
107#endif
98 108
99#include "md32_common.h" 109#include "md32_common.h"
100 110
diff --git a/src/lib/libcrypto/ripemd/rmd_one.c b/src/lib/libcrypto/ripemd/rmd_one.c
index 3efb13758f..b88446b267 100644
--- a/src/lib/libcrypto/ripemd/rmd_one.c
+++ b/src/lib/libcrypto/ripemd/rmd_one.c
@@ -61,7 +61,7 @@
61#include <openssl/ripemd.h> 61#include <openssl/ripemd.h>
62#include <openssl/crypto.h> 62#include <openssl/crypto.h>
63 63
64unsigned char *RIPEMD160(const unsigned char *d, size_t n, 64unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
65 unsigned char *md) 65 unsigned char *md)
66 { 66 {
67 RIPEMD160_CTX c; 67 RIPEMD160_CTX c;
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
66int 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
79static char *test[]={
80 "",
81 "a",
82 "abc",
83 "message digest",
84 "abcdefghijklmnopqrstuvwxyz",
85 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
86 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
87 "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
88 NULL,
89 };
90
91static char *ret[]={
92 "9c1185a5c5e9fc54612808977ee8f548b2258d31",
93 "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe",
94 "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc",
95 "5d0689ef49d2fae572b881b123a85ffa21595f36",
96 "f71c27109c692c1b56bbdceb5b9d2865b3708dbc",
97 "12a053384a9c0c88e405a06c27dcf49ada62eb2b",
98 "b0e20b6e3116640286ed3a87a5713079b21f5189",
99 "9b752e45573d4b39f4dbd3323cab82bf63326bfb",
100 };
101
102static char *pt(unsigned char *md);
103int 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
136static 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