Module Name: src Committed By: apb Date: Fri May 1 20:16:23 UTC 2009
Modified Files: src/usr.bin/xinstall: install.1 xinstall.c Log Message: Add support for writing sha256, sha384, and sha512 digests to a metalog. mtree(8) has supported these for a long time. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/usr.bin/xinstall/install.1 cvs rdiff -u -r1.108 -r1.109 src/usr.bin/xinstall/xinstall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xinstall/install.1 diff -u src/usr.bin/xinstall/install.1:1.42 src/usr.bin/xinstall/install.1:1.43 --- src/usr.bin/xinstall/install.1:1.42 Thu Jan 29 11:17:37 2004 +++ src/usr.bin/xinstall/install.1 Fri May 1 20:16:23 2009 @@ -1,4 +1,4 @@ -.\" $NetBSD: install.1,v 1.42 2004/01/29 11:17:37 wiz Exp $ +.\" $NetBSD: install.1,v 1.43 2009/05/01 20:16:23 apb Exp $ .\" .\" Copyright (c) 1987, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -249,6 +249,18 @@ The RMD-160 cryptographic message digest. .It Sy sha1 The SHA-1 cryptographic message digest. +.It Sy sha256 +The 256-bits +.Tn SHA-2 +cryptographic message digest of the file. +.It Sy sha384 +The 384-bits +.Tn SHA-2 +cryptographic message digest of the file. +.It Sy sha512 +The 512-bits +.Tn SHA-2 +cryptographic message digest of the file. .El .It Fl l Ar linkflags Instead of copying the file make a link to the source. Index: src/usr.bin/xinstall/xinstall.c diff -u src/usr.bin/xinstall/xinstall.c:1.108 src/usr.bin/xinstall/xinstall.c:1.109 --- src/usr.bin/xinstall/xinstall.c:1.108 Fri Apr 17 06:09:08 2009 +++ src/usr.bin/xinstall/xinstall.c Fri May 1 20:16:23 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: xinstall.c,v 1.108 2009/04/17 06:09:08 apb Exp $ */ +/* $NetBSD: xinstall.c,v 1.109 2009/05/01 20:16:23 apb Exp $ */ /* * Copyright (c) 1987, 1993 @@ -46,7 +46,7 @@ #if 0 static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93"; #else -__RCSID("$NetBSD: xinstall.c,v 1.108 2009/04/17 06:09:08 apb Exp $"); +__RCSID("$NetBSD: xinstall.c,v 1.109 2009/05/01 20:16:23 apb Exp $"); #endif #endif /* not lint */ @@ -75,6 +75,7 @@ #include <md5.h> #include <rmd160.h> #include <sha1.h> +#include <sha2.h> #include "pathnames.h" #include "mtree.h" @@ -102,6 +103,9 @@ DIGEST_MD5, DIGEST_RMD160, DIGEST_SHA1, + DIGEST_SHA256, + DIGEST_SHA384, + DIGEST_SHA512, } digesttype = DIGEST_NONE; char *digest; @@ -294,6 +298,12 @@ digesttype = DIGEST_RMD160; } else if (strcmp(digest, "sha1") == 0) { digesttype = DIGEST_SHA1; + } else if (strcmp(digest, "sha256") == 0) { + digesttype = DIGEST_SHA256; + } else if (strcmp(digest, "sha384") == 0) { + digesttype = DIGEST_SHA384; + } else if (strcmp(digest, "sha512") == 0) { + digesttype = DIGEST_SHA512; } else { warnx("unknown digest `%s'", digest); usage(); @@ -509,6 +519,15 @@ case DIGEST_SHA1: dres = SHA1File(from_name, NULL); break; + case DIGEST_SHA256: + dres = SHA256_File(from_name, NULL); + break; + case DIGEST_SHA384: + dres = SHA384_File(from_name, NULL); + break; + case DIGEST_SHA512: + dres = SHA512_File(from_name, NULL); + break; default: dres = NULL; } @@ -793,6 +812,9 @@ MD5_CTX ctxMD5; RMD160_CTX ctxRMD160; SHA1_CTX ctxSHA1; + SHA256_CTX ctxSHA256; + SHA384_CTX ctxSHA384; + SHA512_CTX ctxSHA512; switch (digesttype) { case DIGEST_MD5: @@ -804,6 +826,15 @@ case DIGEST_SHA1: SHA1Init(&ctxSHA1); break; + case DIGEST_SHA256: + SHA256_Init(&ctxSHA256); + break; + case DIGEST_SHA384: + SHA384_Init(&ctxSHA384); + break; + case DIGEST_SHA512: + SHA512_Init(&ctxSHA512); + break; case DIGEST_NONE: if (to_fd < 0) return NULL; /* no need to do anything */ @@ -850,6 +881,15 @@ case DIGEST_SHA1: SHA1Update(&ctxSHA1, p, size); break; + case DIGEST_SHA256: + SHA256_Update(&ctxSHA256, p, size); + break; + case DIGEST_SHA384: + SHA384_Update(&ctxSHA384, p, size); + break; + case DIGEST_SHA512: + SHA512_Update(&ctxSHA512, p, size); + break; default: break; } @@ -874,6 +914,15 @@ case DIGEST_SHA1: SHA1Update(&ctxSHA1, buf, nr); break; + case DIGEST_SHA256: + SHA256_Update(&ctxSHA256, buf, nr); + break; + case DIGEST_SHA384: + SHA384_Update(&ctxSHA384, buf, nr); + break; + case DIGEST_SHA512: + SHA512_Update(&ctxSHA512, buf, nr); + break; default: break; } @@ -892,6 +941,12 @@ return RMD160End(&ctxRMD160, NULL); case DIGEST_SHA1: return SHA1End(&ctxSHA1, NULL); + case DIGEST_SHA256: + return SHA256_End(&ctxSHA256, NULL); + case DIGEST_SHA384: + return SHA384_End(&ctxSHA384, NULL); + case DIGEST_SHA512: + return SHA512_End(&ctxSHA512, NULL); default: return NULL; }