View | Details | Raw Unified | Return to bug 213007
Collapse All | Expand All

(-)b/sbin/md5/md5.1 (-8 / +10 lines)
Lines 7-43 Link Here
7
.Nd calculate a message-digest fingerprint (checksum) for a file
7
.Nd calculate a message-digest fingerprint (checksum) for a file
8
.Sh SYNOPSIS
8
.Sh SYNOPSIS
9
.Nm md5
9
.Nm md5
10
.Op Fl pqrtx
10
.Op Fl Ppqrtx
11
.Op Fl c Ar string
11
.Op Fl c Ar string
12
.Op Fl s Ar string
12
.Op Fl s Ar string
13
.Op Ar
13
.Op Ar
14
.Nm sha1
14
.Nm sha1
15
.Op Fl pqrtx
15
.Op Fl Ppqrtx
16
.Op Fl c Ar string
16
.Op Fl c Ar string
17
.Op Fl s Ar string
17
.Op Fl s Ar string
18
.Op Ar
18
.Op Ar
19
.Nm sha256
19
.Nm sha256
20
.Op Fl pqrtx
20
.Op Fl Ppqrtx
21
.Op Fl c Ar string
21
.Op Fl c Ar string
22
.Op Fl s Ar string
22
.Op Fl s Ar string
23
.Op Ar
23
.Op Ar
24
.Nm sha384
24
.Nm sha384
25
.Op Fl pqrtx
25
.Op Fl Ppqrtx
26
.Op Fl c Ar string
26
.Op Fl c Ar string
27
.Op Fl s Ar string
27
.Op Fl s Ar string
28
.Op Ar
28
.Op Ar
29
.Nm sha512
29
.Nm sha512
30
.Op Fl pqrtx
30
.Op Fl Ppqrtx
31
.Op Fl c Ar string
31
.Op Fl c Ar string
32
.Op Fl s Ar string
32
.Op Fl s Ar string
33
.Op Ar
33
.Op Ar
34
.Nm sha512t256
34
.Nm sha512t256
35
.Op Fl pqrtx
35
.Op Fl Ppqrtx
36
.Op Fl c Ar string
36
.Op Fl c Ar string
37
.Op Fl s Ar string
37
.Op Fl s Ar string
38
.Op Ar
38
.Op Ar
39
.Nm rmd160
39
.Nm rmd160
40
.Op Fl pqrtx
40
.Op Fl Ppqrtx
41
.Op Fl c Ar string
41
.Op Fl c Ar string
42
.Op Fl s Ar string
42
.Op Fl s Ar string
43
.Op Ar
43
.Op Ar
Lines 102-112 The hexadecimal checksum of each file listed on the command line is printed Link Here
102
after the options are processed.
102
after the options are processed.
103
.Bl -tag -width indent
103
.Bl -tag -width indent
104
.It Fl c Ar string
104
.It Fl c Ar string
105
Compare the digest of the file against this string.
105
Compare the digest of the file or stdin against this string.
106
.Pq Note that this option is not yet useful if multiple files are specified.
106
.Pq Note that this option is not yet useful if multiple files are specified.
107
.It Fl s Ar string
107
.It Fl s Ar string
108
Print a checksum of the given
108
Print a checksum of the given
109
.Ar string .
109
.Ar string .
110
.It Fl P
111
Echo stdin to stdout and append the checksum to stderr.
110
.It Fl p
112
.It Fl p
111
Echo stdin to stdout and append the checksum to stdout.
113
Echo stdin to stdout and append the checksum to stdout.
112
.It Fl q
114
.It Fl q
(-)b/sbin/md5/md5.c (-6 / +21 lines)
Lines 45-50 __FBSDID("$FreeBSD$"); Link Here
45
#define TEST_BLOCK_COUNT 100000
45
#define TEST_BLOCK_COUNT 100000
46
#define MDTESTCOUNT 8
46
#define MDTESTCOUNT 8
47
47
48
static int pflag;
48
static int qflag;
49
static int qflag;
49
static int rflag;
50
static int rflag;
50
static int sflag;
51
static int sflag;
Lines 176-188 main(int argc, char *argv[]) Link Here
176
	failed = 0;
177
	failed = 0;
177
	checkAgainst = NULL;
178
	checkAgainst = NULL;
178
	checksFailed = 0;
179
	checksFailed = 0;
179
	while ((ch = getopt(argc, argv, "c:pqrs:tx")) != -1)
180
	pflag = 0;
181
	while ((ch = getopt(argc, argv, "c:Ppqrs:tx")) != -1)
180
		switch (ch) {
182
		switch (ch) {
181
		case 'c':
183
		case 'c':
182
			checkAgainst = optarg;
184
			checkAgainst = optarg;
183
			break;
185
			break;
186
		case 'P':
187
			pflag = STDERR_FILENO;
188
			break;
184
		case 'p':
189
		case 'p':
185
			MDFilter(&Algorithm[digest], 1);
190
			pflag = STDOUT_FILENO;
186
			break;
191
			break;
187
		case 'q':
192
		case 'q':
188
			qflag = 1;
193
			qflag = 1;
Lines 229-236 main(int argc, char *argv[]) Link Here
229
				printf("\n");
234
				printf("\n");
230
			}
235
			}
231
		} while (*++argv);
236
		} while (*++argv);
232
	} else if (!sflag && (optind == 1 || qflag || rflag))
237
	} else if (!sflag && (optind == 1 || qflag || rflag || pflag || checkAgainst))
233
		MDFilter(&Algorithm[digest], 0);
238
		MDFilter(&Algorithm[digest], pflag);
234
239
235
	if (failed != 0)
240
	if (failed != 0)
236
		return (1);
241
		return (1);
Lines 449-455 MDTestSuite(const Algorithm_t *alg) Link Here
449
}
454
}
450
455
451
/*
456
/*
452
 * Digests the standard input and prints the result.
457
 * Digests the standard input and prints the result to stdoud or stderr. In
458
 * any case digested input is either passed to stdout (tee > 0), or not passed
459
 * at all (tee == 0)
453
 */
460
 */
454
static void
461
static void
455
MDFilter(const Algorithm_t *alg, int tee)
462
MDFilter(const Algorithm_t *alg, int tee)
Lines 458-463 MDFilter(const Algorithm_t *alg, int tee) Link Here
458
	unsigned int len;
465
	unsigned int len;
459
	unsigned char buffer[BUFSIZ];
466
	unsigned char buffer[BUFSIZ];
460
	char buf[HEX_DIGEST_LENGTH];
467
	char buf[HEX_DIGEST_LENGTH];
468
	char *p;
461
469
462
	alg->Init(&context);
470
	alg->Init(&context);
463
	while ((len = fread(buffer, 1, BUFSIZ, stdin))) {
471
	while ((len = fread(buffer, 1, BUFSIZ, stdin))) {
Lines 465-471 MDFilter(const Algorithm_t *alg, int tee) Link Here
465
			err(1, "stdout");
473
			err(1, "stdout");
466
		alg->Update(&context, buffer, len);
474
		alg->Update(&context, buffer, len);
467
	}
475
	}
468
	printf("%s\n", alg->End(&context, buf));
476
	p = alg->End(&context, buf);
477
	if (checkAgainst && strcmp(checkAgainst,p))
478
	{
479
		checksFailed++;
480
		if (!qflag)
481
			printf(" [ Failed ]");
482
	} 
483
	fprintf(tee == STDERR_FILENO ? stderr : stdout, "%s\n", p);
469
}
484
}
470
485
471
static void
486
static void

Return to bug 213007