680db86a31d314bfe55c69053a6194588e4403b1
[openwrt.git] / package / isakmpd / patches / 02-openssl_hashes.patch
1 diff -urN isakmpd/GNUmakefile isakmpd.new/GNUmakefile
2 --- isakmpd/GNUmakefile 2006-09-01 19:29:05.000000000 +0200
3 +++ isakmpd.new/GNUmakefile     2006-09-01 19:29:28.000000000 +0200
4 @@ -75,13 +75,14 @@
5                 isakmp_fld.c isakmp_fld.h
6  MAN=           isakmpd.8 isakmpd.conf.5 isakmpd.policy.5
7  
8 -CFLAGS+=       -O2 ${DEBUG} -Wall -DNEED_SYSDEP_APP \
9 +CFLAGS+=       ${DEBUG} -Wall -DNEED_SYSDEP_APP \
10                 -I${.CURDIR} -I${.CURDIR}/sysdep/${OS} -I. \
11  
12  # Different debugging & profiling suggestions
13  
14  # Include symbolic debugging info
15  DEBUG=         -g
16 +CFLAGS+=       -g
17  
18  # Do execution time profiles
19  #CFLAGS+=      -pg
20 @@ -172,6 +173,14 @@
21  CFLAGS+=        -DUSE_RAWKEY
22  endif
23  
24 +ifdef USE_OPENSSL_MD5
25 +CFLAGS+=       -DUSE_OPENSSL_MD5
26 +endif
27 +
28 +ifdef USE_OPENSSL_SHA1
29 +CFLAGS+=       -DUSE_OPENSSL_SHA1
30 +endif
31 +
32  SRCS+=         ${IPSEC_SRCS} ${X509} ${POLICY} ${EC} ${AGGRESSIVE} ${DNSSEC} \
33                 $(ISAKMP_CFG)
34  CFLAGS+=       ${IPSEC_CFLAGS}
35 diff -urN isakmpd/sysdep/common/libsysdep/GNUmakefile isakmpd.new/sysdep/common/libsysdep/GNUmakefile
36 --- isakmpd/sysdep/common/libsysdep/GNUmakefile 2003-06-03 16:52:06.000000000 +0200
37 +++ isakmpd.new/sysdep/common/libsysdep/GNUmakefile     2006-09-01 19:29:28.000000000 +0200
38 @@ -31,10 +31,18 @@
39  .CURDIR:=      $(shell pwd)
40  
41  LIB=           sysdep
42 -SRCS=          arc4random.c blowfish.c cast.c md5.c sha1.c strlcat.c strlcpy.c
43 +SRCS=          arc4random.c blowfish.c cast.c strlcat.c strlcpy.c
44  NOMAN=
45  CFLAGS+=       -I${.CURDIR}/.. -I/usr/include/machine
46  
47 +ifeq (,$(findstring USE_OPENSSL_MD5,$(CFLAGS)))
48 +SRCS+=md5.c
49 +endif
50 +
51 +ifeq (,$(findstring USE_OPENSSL_SHA1,$(CFLAGS)))
52 +SRCS+=sha1.c
53 +endif
54 +
55  lib${LIB}.a: ${SRCS:%.c=%.o}
56         ar cq $@ ${SRCS:%.c=%.o}
57  
58 diff -urN isakmpd/sysdep/common/libsysdep/md5.c isakmpd.new/sysdep/common/libsysdep/md5.c
59 --- isakmpd/sysdep/common/libsysdep/md5.c       2002-06-14 23:34:58.000000000 +0200
60 +++ isakmpd.new/sysdep/common/libsysdep/md5.c   2006-09-01 19:29:28.000000000 +0200
61 @@ -5,6 +5,8 @@
62   * changes to accommodate it in the kernel by ji.
63   */
64  
65 +#ifndef USE_OPENSSL_MD5
66 +
67  /* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
68   */
69  
70 @@ -390,3 +392,4 @@
71  #endif
72  #endif
73  
74 +#endif /* USE_OPENSSL_MD5 */
75 diff -urN isakmpd/sysdep/common/libsysdep/sha1.c isakmpd.new/sysdep/common/libsysdep/sha1.c
76 --- isakmpd/sysdep/common/libsysdep/sha1.c      2001-01-28 23:38:48.000000000 +0100
77 +++ isakmpd.new/sysdep/common/libsysdep/sha1.c  2006-09-01 19:29:28.000000000 +0200
78 @@ -1,5 +1,7 @@
79  /*     $OpenBSD: sha1.c,v 1.2 2001/01/28 22:38:48 niklas Exp $ */
80  
81 +#ifndef USE_OPENSSL_SHA1
82 +
83  /*
84  SHA-1 in C
85  By Steve Reid <steve@edmweb.com>
86 @@ -171,3 +173,5 @@
87      SHA1Transform(context->state, context->buffer);
88  #endif
89  }
90 +
91 +#endif /* USE_OPENSSL_SHA1 */
92 diff -urN isakmpd/sysdep/common/md5.h isakmpd.new/sysdep/common/md5.h
93 --- isakmpd/sysdep/common/md5.h 2001-01-28 23:38:47.000000000 +0100
94 +++ isakmpd.new/sysdep/common/md5.h     2006-09-01 19:29:28.000000000 +0200
95 @@ -1,5 +1,15 @@
96  /*     $OpenBSD: md5.h,v 1.2 2001/01/28 22:38:47 niklas Exp $  */
97  
98 +#ifdef USE_OPENSSL_MD5
99 +
100 +#include <openssl/md5.h>
101 +
102 +#define MD5Init                MD5_Init
103 +#define        MD5Update       MD5_Update
104 +#define        MD5Final        MD5_Final
105 +
106 +#else  /* USE_OPENSSL_MD5 */
107 +
108  /* GLOBAL.H - RSAREF types and constants
109   */
110  
111 @@ -71,3 +81,5 @@
112  void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *));
113  
114  #define _MD5_H_
115 +
116 +#endif /* USE_OPENSSL_MD5 */
117 diff -urN isakmpd/sysdep/common/sha1.h isakmpd.new/sysdep/common/sha1.h
118 --- isakmpd/sysdep/common/sha1.h        2001-01-28 23:38:47.000000000 +0100
119 +++ isakmpd.new/sysdep/common/sha1.h    2006-09-01 19:29:28.000000000 +0200
120 @@ -1,5 +1,16 @@
121  /*     $OpenBSD: sha1.h,v 1.2 2001/01/28 22:38:47 niklas Exp $ */
122  
123 +#ifdef USE_OPENSSL_SHA1
124 +
125 +#include <openssl/sha.h>
126 +
127 +typedef SHA_CTX SHA1_CTX;
128 +#define        SHA1Init        SHA1_Init
129 +#define        SHA1Update      SHA1_Update
130 +#define        SHA1Final       SHA1_Final
131 +
132 +#else  /* USE_OPENSSL_SHA1 */
133 +
134  /*
135  SHA-1 in C
136  By Steve Reid <steve@edmweb.com>
137 @@ -16,3 +27,5 @@
138  void SHA1Init(SHA1_CTX* context);
139  void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len);
140  void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
141 +
142 +#endif /* USE_OPENSSL_SHA1 */
143 diff -urN isakmpd/sysdep/linux/GNUmakefile.sysdep isakmpd.new/sysdep/linux/GNUmakefile.sysdep
144 --- isakmpd/sysdep/linux/GNUmakefile.sysdep     2006-09-01 19:29:05.000000000 +0200
145 +++ isakmpd.new/sysdep/linux/GNUmakefile.sysdep 2006-09-01 19:29:29.000000000 +0200
146 @@ -48,6 +48,8 @@
147  USE_LIBCRYPO=  defined
148  HAVE_DLOPEN=   defined
149  USE_KEYNOTE=   defined
150 +USE_OPENSSL_MD5=       defined
151 +USE_OPENSSL_SHA1=      defined
152  
153  # hack libsysdep.a dependenc
154  ${LIBSYSDEPDIR}/.depend ${LIBSYSDEP}: