to deliver the hash output to a different location.
ok millert
-.\" $OpenBSD: cksum.1,v 1.25 2013/12/29 21:19:11 jmc Exp $
+.\" $OpenBSD: cksum.1,v 1.26 2014/01/08 14:15:54 deraadt Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)cksum.1 8.2 (Berkeley) 4/28/95
.\"
-.Dd $Mdocdate: December 29 2013 $
+.Dd $Mdocdate: January 8 2014 $
.Dt CKSUM 1
.Os
.Sh NAME
.Op Fl a Ar algorithms
.Op Fl c Op Ar checklist ...
.Op Fl o Ar 1 | 2
+.Op Fl h Ar hashfile
.Op Fl s Ar string
.Op Ar
.Ek
.Op Fl a Ar algorithms
.Op Fl c Op Ar checklist ...
.Op Fl o Ar 1 | 2
+.Op Fl h Ar hashfile
.Op Fl s Ar string
.Op Ar
.Sh DESCRIPTION
.It Fl r
Reverse the format of the hash algorithm output, making
it match the checksum output format.
+.It Fl h Ar hashfile
+Place the checksum into
+.Ar hashfile
+instead of stdout.
.It Fl s Ar string
Prints a checksum of the given
.Ar string .
-.\" $OpenBSD: md5.1,v 1.34 2013/12/29 21:19:11 jmc Exp $
+.\" $OpenBSD: md5.1,v 1.35 2014/01/08 14:15:54 deraadt Exp $
.\"
.\" Copyright (c) 2003, 2004, 2006 Todd C. Miller <Todd.Miller@courtesan.com>
.\"
.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
.\"
-.Dd $Mdocdate: December 29 2013 $
+.Dd $Mdocdate: January 8 2014 $
.Dt MD5 1
.Os
.Sh NAME
.Nm md5
.Op Fl bpqrtx
.Op Fl c Op Ar checklist ...
+.Op Fl h Ar hashfile
.Op Fl s Ar string
.Op Ar
.Sh DESCRIPTION
Reverse the format of the hash algorithm output, making
it match the output format used by
.Xr cksum 1 .
+.It Fl h Ar hashfile
+Place the checksum into
+.Ar hashfile
+instead of stdout.
.It Fl s Ar string
Prints a checksum of the given
.Ar string .
-/* $OpenBSD: md5.c,v 1.58 2013/12/23 23:00:38 tedu Exp $ */
+/* $OpenBSD: md5.c,v 1.59 2014/01/08 14:15:54 deraadt Exp $ */
/*
* Copyright (c) 2001,2003,2005-2006 Todd C. Miller <Todd.Miller@courtesan.com>
extern char *__progname;
int qflag = 0;
+FILE *ofile = NULL;
int
main(int argc, char **argv)
int bflag, cflag, pflag, rflag, tflag, xflag;
static const char *optstr[2] = {
- "bcpqrs:tx",
- "a:bco:pqrs:tx"
+ "bch:pqrs:tx",
+ "a:bch:o:pqrs:tx"
};
TAILQ_INIT(&hl);
if (hftmp == TAILQ_END(&hl))
hash_insert(&hl, hf, 0);
break;
+ case 'h':
+ ofile = fopen(optarg, "w+");
+ if (ofile == NULL)
+ errx(1, "%s", optarg);
+ break;
case 'p':
pflag = 1;
break;
argc -= optind;
argv += optind;
+ if (ofile == NULL)
+ ofile = stdout;
+
/* Most arguments are mutually exclusive */
fl = pflag + (tflag ? 1 : 0) + xflag + cflag + (input_string != NULL);
if (fl > 1 || (fl && argc && cflag == 0) || (rflag && qflag))
{
switch (*hf->style) {
case STYLE_NORMAL:
- (void)printf("%s (%s) = %s\n", hf->name, what, digest);
+ (void)fprintf(ofile, "%s (%s) = %s\n", hf->name, what, digest);
break;
case STYLE_REVERSE:
- (void)printf("%s %s\n", digest, what);
+ (void)fprintf(ofile, "%s %s\n", digest, what);
break;
case STYLE_TERSE:
- (void)printf("%s\n", digest);
+ (void)fprintf(ofile,"%s\n", digest);
break;
}
}
{
switch (*hf->style) {
case STYLE_NORMAL:
- (void)printf("%s (\"%s\") = %s\n", hf->name, what, digest);
+ (void)fprintf(ofile, "%s (\"%s\") = %s\n", hf->name, what, digest);
break;
case STYLE_REVERSE:
- (void)printf("%s %s\n", digest, what);
+ (void)fprintf(ofile, "%s %s\n", digest, what);
break;
case STYLE_TERSE:
- (void)printf("%s\n", digest);
+ (void)fprintf(ofile, "%s\n", digest);
break;
}
}
free(hf->ctx);
hf->ctx = NULL;
if (fp == stdin)
- (void)puts(digest);
+ fprintf(ofile, "%s\n", digest);
else
digest_print(hf, file, digest);
}
switch (pmode) {
case MODE_MD5:
fprintf(stderr, "usage: %s [-bpqrtx] [-c [checklist ...]] "
- "[-s string] [file ...]\n", __progname);
+ "[-h hashfile] [-s string] [file ...]\n", __progname);
break;
case MODE_CKSUM:
fprintf(stderr, "usage: %s [-bpqrtx] [-a algorithms] "
- "[-c [checklist ...]] [-o 1 | 2]\n"
+ "[-c [checklist ...]] [-h hashfile] [-o 1 | 2]\n"
" %*s [-s string] [file ...]\n",
__progname, (int)strlen(__progname), "");
break;
-.\" $OpenBSD: sha1.1,v 1.32 2013/12/29 21:19:11 jmc Exp $
+.\" $OpenBSD: sha1.1,v 1.33 2014/01/08 14:15:54 deraadt Exp $
.\"
.\" Copyright (c) 2003, 2004, 2006 Todd C. Miller <Todd.Miller@courtesan.com>
.\"
.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
.\"
-.Dd $Mdocdate: December 29 2013 $
+.Dd $Mdocdate: January 8 2014 $
.Dt SHA1 1
.Os
.Sh NAME
.Nm sha1
.Op Fl bpqrtx
.Op Fl c Op Ar checklist ...
+.Op Fl h Ar hashfile
.Op Fl s Ar string
.Op Ar
.Sh DESCRIPTION
Reverse the format of the hash algorithm output, making
it match the output format used by
.Xr cksum 1 .
+.It Fl h Ar hashfile
+Place the checksum into
+.Ar hashfile
+instead of stdout.
.It Fl s Ar string
Prints a checksum of the given
.Ar string .
-.\" $OpenBSD: sha256.1,v 1.7 2013/12/29 21:19:11 jmc Exp $
+.\" $OpenBSD: sha256.1,v 1.8 2014/01/08 14:15:54 deraadt Exp $
.\"
.\" Copyright (c) 2003, 2004, 2006 Todd C. Miller <Todd.Miller@courtesan.com>
.\"
.\" Agency (DARPA) and Air Force Research Laboratory, Air Force
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
.\"
-.Dd $Mdocdate: December 29 2013 $
+.Dd $Mdocdate: January 8 2014 $
.Dt SHA256 1
.Os
.Sh NAME
.Nm sha256
.Op Fl bpqrtx
.Op Fl c Op Ar checklist ...
+.Op Fl h Ar hashfile
.Op Fl s Ar string
.Op Ar
.Nm sha512
.Op Fl bpqrtx
.Op Fl c Op Ar checklist ...
+.Op Fl h Ar hashfile
.Op Fl s Ar string
.Op Ar
.Sh DESCRIPTION
Reverse the format of the hash algorithm output, making
it match the output format used by
.Xr cksum 1 .
+.It Fl h Ar hashfile
+Place the checksum into
+.Ar hashfile
+instead of stdout.
.It Fl s Ar string
Prints a checksum of the given
.Ar string .