svn commit: trunk/busybox: coreutils libbb

vda at busybox.net vda at busybox.net
Thu Sep 28 00:29:01 UTC 2006


Author: vda
Date: 2006-09-27 17:29:00 -0700 (Wed, 27 Sep 2006)
New Revision: 16244

Log:
Tried to find sha1_crypt - nope... ok, save few bytes in md5_sha1_sum.c
(time to sleep, 02:28 in the morning)...


Modified:
   trunk/busybox/coreutils/md5_sha1_sum.c
   trunk/busybox/libbb/sha1.c


Changeset:
Modified: trunk/busybox/coreutils/md5_sha1_sum.c
===================================================================
--- trunk/busybox/coreutils/md5_sha1_sum.c	2006-09-27 23:31:59 UTC (rev 16243)
+++ trunk/busybox/coreutils/md5_sha1_sum.c	2006-09-28 00:29:00 UTC (rev 16244)
@@ -16,7 +16,7 @@
 
 /* This might be useful elsewhere */
 static unsigned char *hash_bin_to_hex(unsigned char *hash_value,
-									  unsigned char hash_length)
+				unsigned char hash_length)
 {
 	int x, len, max;
 	unsigned char *hex_value;
@@ -86,11 +86,9 @@
 	int return_value = EXIT_SUCCESS;
 	uint8_t *hash_value;
 	unsigned int flags;
-	hash_algo_t hash_algo = ENABLE_MD5SUM ?
-								(ENABLE_SHA1SUM ?
-									(**argv=='m' ? HASH_MD5 : HASH_SHA1)
-								: HASH_MD5)
-							: HASH_SHA1;
+	hash_algo_t hash_algo = ENABLE_MD5SUM
+		? (ENABLE_SHA1SUM ? (**argv=='m' ? HASH_MD5 : HASH_SHA1) : HASH_MD5)
+		: HASH_SHA1;
 
 	if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
 		flags = bb_getopt_ulflags(argc, argv, "scw");
@@ -99,10 +97,10 @@
 	if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && !(flags & FLAG_CHECK)) {
 		if (flags & FLAG_SILENT) {
 			bb_error_msg_and_die
-				("the -s option is meaningful only when verifying checksums");
+				("-%c is meaningful only when verifying checksums", 's');
 		} else if (flags & FLAG_WARN) {
 			bb_error_msg_and_die
-				("the -w option is meaningful only when verifying checksums");
+				("-%c is meaningful only when verifying checksums", 'w');
 		}
 	}
 
@@ -135,7 +133,7 @@
 			filename_ptr = strstr(line, "  ");
 			if (filename_ptr == NULL) {
 				if (flags & FLAG_WARN) {
-					bb_error_msg("Invalid format");
+					bb_error_msg("invalid format");
 				}
 				count_failed++;
 				return_value = EXIT_FAILURE;
@@ -165,7 +163,7 @@
 						 count_failed, count_total);
 		}
 		if (bb_fclose_nonstdin(pre_computed_stream) == EOF) {
-			bb_perror_msg_and_die("Couldnt close file %s", file_ptr);
+			bb_perror_msg_and_die("cannot close file %s", file_ptr);
 		}
 	} else {
 		while (optind < argc) {
@@ -180,5 +178,5 @@
 			}
 		}
 	}
-	return (return_value);
+	return return_value;
 }

Modified: trunk/busybox/libbb/sha1.c
===================================================================
--- trunk/busybox/libbb/sha1.c	2006-09-27 23:31:59 UTC (rev 16243)
+++ trunk/busybox/libbb/sha1.c	2006-09-28 00:29:00 UTC (rev 16244)
@@ -26,28 +26,29 @@
 
 #include "libbb.h"
 
-# define SHA1_BLOCK_SIZE  64
-# define SHA1_DIGEST_SIZE 20
-# define SHA1_HASH_SIZE   SHA1_DIGEST_SIZE
-# define SHA2_GOOD        0
-# define SHA2_BAD         1
+#define SHA1_BLOCK_SIZE  64
+#define SHA1_DIGEST_SIZE 20
+#define SHA1_HASH_SIZE   SHA1_DIGEST_SIZE
+#define SHA2_GOOD        0
+#define SHA2_BAD         1
 
-# define rotl32(x,n) (((x) << n) | ((x) >> (32 - n)))
+#define rotl32(x,n)      (((x) << n) | ((x) >> (32 - n)))
 
-# define SHA1_MASK   (SHA1_BLOCK_SIZE - 1)
+#define SHA1_MASK        (SHA1_BLOCK_SIZE - 1)
 
 /* reverse byte order in 32-bit words   */
-#define ch(x,y,z)       ((z) ^ ((x) & ((y) ^ (z))))
-#define parity(x,y,z)   ((x) ^ (y) ^ (z))
-#define maj(x,y,z)      (((x) & (y)) | ((z) & ((x) | (y))))
+#define ch(x,y,z)        ((z) ^ ((x) & ((y) ^ (z))))
+#define parity(x,y,z)    ((x) ^ (y) ^ (z))
+#define maj(x,y,z)       (((x) & (y)) | ((z) & ((x) | (y))))
 
 /* A normal version as set out in the FIPS. This version uses   */
 /* partial loop unrolling and is optimised for the Pentium 4    */
-# define rnd(f,k)    \
-    t = a; a = rotl32(a,5) + f(b,c,d) + e + k + w[i]; \
-    e = d; d = c; c = rotl32(b, 30); b = t
+#define rnd(f,k) \
+	do { \
+		t = a; a = rotl32(a,5) + f(b,c,d) + e + k + w[i]; \
+		e = d; d = c; c = rotl32(b, 30); b = t; \
+	} while(0)
 
-
 static void sha1_compile(sha1_ctx_t *ctx)
 {
 	uint32_t w[80], i, a, b, c, d, e, t;
@@ -160,7 +161,7 @@
 		ctx->wbuf[cnt++] = 0;
 
 	/* assemble the eight byte counter in the buffer in big-endian  */
-	/* format					               */
+	/* format					                */
 
 	ctx->wbuf[14] = htonl((ctx->count[1] << 3) | (ctx->count[0] >> 29));
 	ctx->wbuf[15] = htonl(ctx->count[0] << 3);
@@ -175,5 +176,3 @@
 
 	return resbuf;
 }
-
-




More information about the busybox-cvs mailing list