Permalink
Browse files

the actual source

  • Loading branch information...
1 parent 96510f2 commit 56c1dd8332a33a4045bdb5e6a9838ca1a8f3eba6 caristat committed Apr 7, 2009
Showing with 6,455 additions and 0 deletions.
  1. +23 −0 Makefile
  2. +6 −0 TODO.txt
  3. +127 −0 bn.c
  4. +294 −0 disc_usage_table.c
  5. +372 −0 ec.c
  6. BIN icon.png
  7. +815 −0 libwbfs/libwbfs.c
  8. +261 −0 libwbfs/libwbfs.h
  9. +130 −0 libwbfs/libwbfs_linux.c
  10. +164 −0 libwbfs/libwbfs_macosx.c
  11. +166 −0 libwbfs/libwbfs_win32.c
  12. +408 −0 libwbfs/rijndael.c
  13. +339 −0 libwbfs/wiidisc.c
  14. +68 −0 libwbfs/wiidisc.h
  15. +49 −0 libwbfs_os.h
  16. +153 −0 libwbfslite/libwbfs.c
  17. +39 −0 libwbfslite/libwbfs.h
  18. +79 −0 macosx/wbfs/wbfs.1
  19. +460 −0 macosx/wbfs/wbfs.xcodeproj/project.pbxproj
  20. +575 −0 negentig.c
  21. +63 −0 readme.txt
  22. +17 −0 readme.win_mod_by_Sorg.txt
  23. +60 −0 scrub.c
  24. +565 −0 tools.c
  25. +70 −0 tools.h
  26. +912 −0 wbfs.c
  27. +205 −0 win32/xgetopt.cpp
  28. +35 −0 win32/xgetopt.h
View
@@ -0,0 +1,23 @@
+PROGS = negentig scrub wbfs
+COMMON = tools.o bn.o ec.o disc_usage_table.o libwbfs.o libwbfs_linux.o wiidisc.o rijndael.o
+DEFINES = -DLARGE_FILES -D_FILE_OFFSET_BITS=64
+LIBS = -lcrypto
+
+CC = gcc
+CFLAGS = -Wall -W -O3 -Ilibwbfs -I.
+#CFLAGS = -Wall -m32 -W -ggdb -Ilibwbfs -I.
+LDFLAGS = -m32
+
+VPATH+=libwbfs
+OBJS = $(patsubst %,%.o,$(PROGS)) $(COMMON)
+
+all: $(PROGS)
+
+$(PROGS): %: %.o $(COMMON) Makefile
+ $(CC) $(CFLAGS) $(LDFLAGS) $< $(COMMON) $(LIBS) -o $@
+
+$(OBJS): %.o: %.c tools.h Makefile
+ $(CC) $(CFLAGS) $(DEFINES) -c $< -o $@
+
+clean:
+ -rm -f $(OBJS) $(PROGS)
View
@@ -0,0 +1,6 @@
+- handle errors more gracefully
+ - if an instance of wbfs is accessing a block device we currently wait forever
+- time estimates are sometimes off by a margin
+ - especially if the image in wbfs is very small and we have to write a lot of filler date to get the extracted iso
+- there should be a way to determine the space an iso is going to take up in wbfs before writing it there
+- We should check if there is enough space available before adding!
View
127 bn.c
@@ -0,0 +1,127 @@
+// Copyright 2007,2008 Segher Boessenkool <segher@kernel.crashing.org>
+// Licensed under the terms of the GNU GPL, version 2
+// http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
+
+#include <string.h>
+#include <stdio.h>
+
+#ifdef WIN32
+#include <tools.h>
+#else
+#include "tools.h"
+#endif
+
+static void bn_print(char *name, u8 *a, u32 n)
+{
+ u32 i;
+
+ printf("%s = ", name);
+
+ for (i = 0; i < n; i++)
+ printf("%02x", a[i]);
+
+ printf("\n");
+}
+
+static void bn_zero(u8 *d, u32 n)
+{
+ memset(d, 0, n);
+}
+
+static void bn_copy(u8 *d, u8 *a, u32 n)
+{
+ memcpy(d, a, n);
+}
+
+int bn_compare(u8 *a, u8 *b, u32 n)
+{
+ u32 i;
+
+ for (i = 0; i < n; i++) {
+ if (a[i] < b[i])
+ return -1;
+ if (a[i] > b[i])
+ return 1;
+ }
+
+ return 0;
+}
+
+void bn_sub_modulus(u8 *a, u8 *N, u32 n)
+{
+ u32 i;
+ u32 dig;
+ u8 c;
+
+ c = 0;
+ for (i = n - 1; i < n; i--) {
+ dig = N[i] + c;
+ c = (a[i] < dig);
+ a[i] -= dig;
+ }
+}
+
+void bn_add(u8 *d, u8 *a, u8 *b, u8 *N, u32 n)
+{
+ u32 i;
+ u32 dig;
+ u8 c;
+
+ c = 0;
+ for (i = n - 1; i < n; i--) {
+ dig = a[i] + b[i] + c;
+ c = (dig >= 0x100);
+ d[i] = dig;
+ }
+
+ if (c)
+ bn_sub_modulus(d, N, n);
+
+ if (bn_compare(d, N, n) >= 0)
+ bn_sub_modulus(d, N, n);
+}
+
+void bn_mul(u8 *d, u8 *a, u8 *b, u8 *N, u32 n)
+{
+ u32 i;
+ u8 mask;
+
+ bn_zero(d, n);
+
+ for (i = 0; i < n; i++)
+ for (mask = 0x80; mask != 0; mask >>= 1) {
+ bn_add(d, d, d, N, n);
+ if ((a[i] & mask) != 0)
+ bn_add(d, d, b, N, n);
+ }
+}
+
+void bn_exp(u8 *d, u8 *a, u8 *N, u32 n, u8 *e, u32 en)
+{
+ u8 t[512];
+ u32 i;
+ u8 mask;
+
+ bn_zero(d, n);
+ d[n-1] = 1;
+ for (i = 0; i < en; i++)
+ for (mask = 0x80; mask != 0; mask >>= 1) {
+ bn_mul(t, d, d, N, n);
+ if ((e[i] & mask) != 0)
+ bn_mul(d, t, a, N, n);
+ else
+ bn_copy(d, t, n);
+ }
+}
+
+// only for prime N -- stupid but lazy, see if I care
+void bn_inv(u8 *d, u8 *a, u8 *N, u32 n)
+{
+ u8 t[512], s[512];
+
+ bn_copy(t, N, n);
+ bn_zero(s, n);
+ s[n-1] = 2;
+ bn_sub_modulus(t, s, n);
+ bn_exp(d, a, N, n, t, n);
+}
Oops, something went wrong.

0 comments on commit 56c1dd8

Please sign in to comment.