lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 31 Mar 2013 20:44:02 -0400
From:	Theodore Ts'o <tytso@....edu>
To:	Ext4 Developers List <linux-ext4@...r.kernel.org>
Cc:	john.jolly@...il.com, Theodore Ts'o <tytso@....edu>
Subject: [PATCH 3/4] tests: create crcsum progam to support resizing tests

The only checksum program which we can reliably count upon being
installed on all systems is "sum", which is not a particular robust
checksum.  The problem with using md5sum or sha1sum is it hat it may
not be installed on all systems.  So create a crcsum program which is
used so we can validate that a data file on a resized file system has
not been corrupted.

Signed-off-by: "Theodore Ts'o" <tytso@....edu>
---
 tests/progs/Makefile.in |  6 ++++-
 tests/progs/crcsum.c    | 70 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/test_config       |  1 +
 3 files changed, 76 insertions(+), 1 deletion(-)
 create mode 100644 tests/progs/crcsum.c

diff --git a/tests/progs/Makefile.in b/tests/progs/Makefile.in
index 0e28192..e3c1ef4 100644
--- a/tests/progs/Makefile.in
+++ b/tests/progs/Makefile.in
@@ -13,7 +13,7 @@ INSTALL = @INSTALL@
 
 MK_CMDS=	_SS_DIR_OVERRIDE=../../lib/ss ../../lib/ss/mk_cmds
 
-PROGS=		test_icount
+PROGS=		test_icount crcsum
 
 TEST_REL_OBJS=	test_rel.o test_rel_cmds.o
 
@@ -34,6 +34,10 @@ test_rel: $(TEST_REL_OBJS) $(DEPLIBS)
 	$(E) "	LD $@"
 	$(Q) $(LD) $(ALL_LDFLAGS) -o test_rel $(TEST_REL_OBJS) $(LIBS)
 
+crcsum: crcsum.o $(DEPLIBS)
+	$(E) "	LD $@"
+	$(Q) $(LD) $(ALL_LDFLAGS) -o crcsum crcsum.o $(LIBS)
+
 test_rel_cmds.c: test_rel_cmds.ct
 	$(E) "	MK_CMDS $@"
 	$(Q) $(MK_CMDS) $(srcdir)/test_rel_cmds.ct
diff --git a/tests/progs/crcsum.c b/tests/progs/crcsum.c
new file mode 100644
index 0000000..bee979b
--- /dev/null
+++ b/tests/progs/crcsum.c
@@ -0,0 +1,70 @@
+/*
+ * crcsum.c
+ *
+ * Copyright (C) 2013 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
+#include <fcntl.h>
+
+#include "et/com_err.h"
+#include "ss/ss.h"
+#include "ext2fs/ext2fs.h"
+
+
+int main(int argc, char **argv)
+{
+	int		c;
+	uint32_t	crc = ~0;
+	uint32_t	(*csum_func)(uint32_t crc, unsigned char const *p,
+				     size_t len);
+	FILE		*f;
+
+	csum_func = ext2fs_crc32c_le;
+
+	while ((c = getopt (argc, argv, "B")) != EOF) {
+		switch (c) {
+		case 'B':
+			csum_func = ext2fs_crc32c_be;
+			break;
+		default:
+			com_err(argv[0], 0, "Usage: crcsum [-b] [file]\n");
+			return 1;
+		}
+	}
+
+	if (optind == argc)
+		f = stdin;
+	else {
+		f = fopen(argv[optind], "r");
+		if (!f) {
+			com_err(argv[0], errno, "while trying to open %s\n",
+				argv[optind]);
+			exit(1);
+		}
+	}
+
+	while (!feof(f)) {
+		unsigned char buf[4096];
+
+		int c = fread(buf, 1, sizeof(buf), f);
+
+		if (c)
+			crc = csum_func(crc, buf, c);
+	}
+	printf("%u\n", crc);
+	return 0;
+}
diff --git a/tests/test_config b/tests/test_config
index 0ba8b5e..36b53b7 100644
--- a/tests/test_config
+++ b/tests/test_config
@@ -19,6 +19,7 @@ RESIZE2FS="$USE_VALGRIND $RESIZE2FS_EXE"
 E2UNDO_EXE="../misc/e2undo"
 TEST_REL=../tests/progs/test_rel
 TEST_ICOUNT=../tests/progs/test_icount
+CRCSUM=../tests/progs/crcsum
 LD_LIBRARY_PATH=../lib:../lib/ext2fs:../lib/e2p:../lib/et:../lib/ss
 DYLD_LIBRARY_PATH=../lib:../lib/ext2fs:../lib/e2p:../lib/et:../lib/ss
 export LD_LIBRARY_PATH
-- 
1.7.12.rc0.22.gcdd159b

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ