File: use-libbz2-and-mhash.patch

package info (click to toggle)
wit 3.01a-5.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,468 kB
  • sloc: ansic: 109,416; pascal: 2,205; sh: 1,972; makefile: 770
file content (183 lines) | stat: -rw-r--r-- 5,122 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
Description: Use libbz2 and mhash
 The upstream tarball comes with a bundled version of libbz2 and uses OpenSSL
 for SHA1. In accordance with Debian policy (“Convenience copies of code”),
 the Debian tarball ships without libbz2. Also, due to licensing, we use mhash
 instead of OpenSSL.
Author: Michael Stapelberg <stapelberg@debian.org>
Last-Update: 2013-07-11

---

Index: wit/Makefile
===================================================================
--- wit.orig/Makefile
+++ wit/Makefile
@@ -207,7 +207,7 @@ endif
 
 # lib summary
 LIB_LIST	+= libbz2 lzma
-LIB_OBJECTS	+= $(LIBBZ2_OBJ) $(LZMA_OBJ)
+LIB_OBJECTS	+= $(LZMA_OBJ)
 RM_FILES	+= $(foreach l,$(LIB_LIST),src/$(l)/*.{d,o})
 
 
@@ -251,7 +251,7 @@ WIT_O		:= lib-std.o lib-file.o lib-sf.o
 		   lib-wdf.o lib-wia.o lib-ciso.o lib-gcz.o \
 		   iso-interface.o wbfs-interface.o patch.o \
 		   titles.o match-pattern.o dclib-utf8.o \
-		   sha1dgst.o sha1_one.o \
+		   wit-sha1.o \
 		   $(DCLIB_O)
 
 LIBWBFS_O	:= tools.o file-formats.o libwbfs.o wiidisc.o cert.o rijndael.o
@@ -264,7 +264,7 @@ endif
 UI_OBJECTS	:= $(sort $(MAIN_TOOLS_OBJ))
 #C_OBJECTS	:= $(sort $(OTHER_TOOLS_OBJ) $(WIT_O) $(LIBWBFS_O) $(LZMA_O) $(TOBJ_ALL))
 C_OBJECTS	:= $(sort $(OTHER_TOOLS_OBJ) $(WIT_O) $(LIBWBFS_O) $(TOBJ_ALL))
-ASM_OBJECTS	:= ssl-asm.o
+ASM_OBJECTS	:=
 
 # all objects + sources
 #ALL_OBJECTS	= $(sort $(WIT_O) $(LIBWBFS_O) $(LZMA_O) $(ASM_OBJECTS) $(LIB_OBJECTS))
@@ -316,6 +316,7 @@ ifeq ($(HAVE_ZLIB),1)
  LIBS		+= -lz
 endif
 LIBS		+= -lm $(XLIBS)
+LIBS		+= -lbz2 -lmhash
 
 DISTRIB_RM	= ./wit-v$(VERSION)-r
 DISTRIB_BASE	= wit-v$(VERSION)-r$(REVISION_NEXT)
Index: wit/src/iso-interface.c
===================================================================
--- wit.orig/src/iso-interface.c
+++ wit/src/iso-interface.c
@@ -52,6 +52,8 @@
 #include "dirent.h"
 #include "crypt.h"
 
+#include <mutils/mhash.h>
+
 //
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////			 dump helpers			///////////////
@@ -5776,11 +5778,11 @@ enumError Skeletonize
     const enumOFT oft = CalcOFT(output_file_type,0,0,OFT__WDF_DEF);
 
     {
-	WIT_SHA_CTX ctx;
-	if (!WIT_SHA1_Init(&ctx))
+	MHASH td;
+	if ((td = mhash_init(MHASH_SHA1)) == MHASH_FAILED)
 	{
 	    ASSERT(0);
-	    exit(0);
+	    exit(1);
 	}
 
 	int i;
@@ -5788,10 +5790,10 @@ enumError Skeletonize
 	{
 	    wd_memmap_item_t * mi = mm.item + i;
 	    noPRINT("### %p %9llx %6llx\n",mi->data,mi->offset,mi->size);
-	    WIT_SHA1_Update(&ctx,mi->data,mi->size);
+	    mhash(td, mi->data, mi->size);
 	}
 	u8 h[WII_HASH_SIZE];
-	WIT_SHA1_Final(h,&ctx);
+	mhash_deinit(td, h);
 
 	snprintf(fname,sizeof(fname),
 		"%s/%.6s-%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
Index: wit/src/crypt.h
===================================================================
--- wit.orig/src/crypt.h
+++ wit/src/crypt.h
@@ -37,7 +37,8 @@
 #ifndef WIT_CRYPT_H
 #define WIT_CRYPT_H 1
 
-#include "crypto/wit-sha.h"
+//#include "crypto/wit-sha.h"
+unsigned char *WIT_SHA1(const unsigned char *d, size_t n, unsigned char *md);
 #define SHA1 WIT_SHA1
 
 // random functions
Index: wit/src/lib-bzip2.c
===================================================================
--- wit.orig/src/lib-bzip2.c
+++ wit/src/lib-bzip2.c
@@ -40,8 +40,7 @@
   #ifndef NO_BZIP2
 /******************/
 
-//#include <bzlib.h>
-#include "libbz2/bzlib.h"
+#include <bzlib.h>
 #include "lib-bzip2.h"
 
 /************************************************************************
Index: wit/src/wit-sha1.c
===================================================================
--- /dev/null
+++ wit/src/wit-sha1.c
@@ -0,0 +1,41 @@
+#include <stdio.h>
+#include <string.h>
+#include <mhash.h>
+
+#if 0
+#include <openssl/sha.h>
+unsigned char *WIT_SHA1_ssl(const unsigned char *d, size_t n, unsigned char *md)
+{
+        SHA_CTX c;
+        static unsigned char m[20];
+
+        if (md == NULL) md=m;
+        if (!SHA1_Init(&c))
+                return NULL;
+        SHA1_Update(&c,d,n);
+        SHA1_Final(md,&c);
+        return(md);
+}
+#endif
+
+unsigned char *WIT_SHA1(const unsigned char *d, size_t n, unsigned char *md)
+{
+	MHASH td;
+	if ((td = mhash_init(MHASH_SHA1)) == MHASH_FAILED)
+		return NULL;
+	mhash(td, d, n);
+	mhash_deinit(td, md);
+	return(md);
+}
+
+#if 0
+int main() {
+	char *bleh = "22:40 → fritz09 [~Adium@port-5452.pppoe.wtnet.de] has joined #29c3";
+	char md[1024] = { 0 };
+	WIT_SHA1(bleh, strlen(bleh), md);
+	printf("md = %s\n", md);
+	memset(md, '\0', sizeof(md));
+	WIT_SHA1_ssl(bleh, strlen(bleh), md);
+	printf("md = %s\n", md);
+}
+#endif
Index: wit/src/lib-lzma.c
===================================================================
--- wit.orig/src/lib-lzma.c
+++ wit/src/lib-lzma.c
@@ -37,10 +37,10 @@
 #define _GNU_SOURCE 1
 
 #include "lib-lzma.h"
-#include "lzma/LzmaEnc.h"
-#include "lzma/LzmaDec.h"
-#include "lzma/Lzma2Enc.h"
-#include "lzma/Lzma2Dec.h"
+#include <lzma/LzmaEnc.h>
+#include <lzma/LzmaDec.h>
+#include <lzma/Lzma2Enc.h>
+#include <lzma/Lzma2Dec.h>
 
 /***********************************************
  **  LZMA SDK: http://www.7-zip.org/sdk.html  **