Module Name: othersrc Committed By: agc Date: Tue Mar 4 02:12:58 UTC 2014
Modified Files: othersrc/external/bsd/multigest/dist: blake2.c libmultigest.3 multigest.c multigest.h Added Files: othersrc/external/bsd/multigest/dist: Makefile.in configure Log Message: Minor changes to multigest Introduce a new multigest_format_raw() function to the multigest library, which can be used to format a raw multigest value into a formatted hexadecimal number. Add a new multigest_algs_rawsize() function, which will return the space needed (in bytes) to hold a raw multigest for the algorithms specified. The multigest_get_rawsize() function continues to work on a multigest_t structure which has already been initialised. Make blake2 compile without a c99 compiler. Add faux-autoconf infrastructure for packaging purposes. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/multigest/dist/Makefile.in \ othersrc/external/bsd/multigest/dist/configure cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/multigest/dist/blake2.c cvs rdiff -u -r1.5 -r1.6 othersrc/external/bsd/multigest/dist/libmultigest.3 cvs rdiff -u -r1.7 -r1.8 othersrc/external/bsd/multigest/dist/multigest.c cvs rdiff -u -r1.6 -r1.7 othersrc/external/bsd/multigest/dist/multigest.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: othersrc/external/bsd/multigest/dist/blake2.c diff -u othersrc/external/bsd/multigest/dist/blake2.c:1.2 othersrc/external/bsd/multigest/dist/blake2.c:1.3 --- othersrc/external/bsd/multigest/dist/blake2.c:1.2 Sat Aug 17 18:29:35 2013 +++ othersrc/external/bsd/multigest/dist/blake2.c Tue Mar 4 02:12:58 2014 @@ -254,8 +254,10 @@ blake2b_param_set_personal(blake2b_param static inline int blake2b_init0(BLAKE2_CTX *S) { + int i; + memset(S, 0, sizeof(*S)); - for (int i = 0; i < 8; ++i) { + for (i = 0; i < 8; ++i) { S->h[i] = blake2b_IV[i]; } return 0; @@ -266,11 +268,12 @@ static int blake2b_init_param(BLAKE2_CTX *S, const blake2b_param *P) { const uint8_t *p; + size_t i; blake2b_init0(S); p = (const uint8_t *)(const void *)(P); /* IV XOR ParamBlock */ - for (size_t i = 0; i < 8; ++i) { + for (i = 0; i < 8; ++i) { S->h[i] ^= load64(p + sizeof(S->h[i]) * i); } return 0; @@ -395,6 +398,7 @@ int blake2b_final(BLAKE2_CTX *S, uint8_t *out, uint8_t outlen) { uint8_t buffer[BLAKE2B_OUTBYTES]; + int i; if (S->buflen > BLAKE2B_BLOCKBYTES) { blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES); @@ -406,7 +410,7 @@ blake2b_final(BLAKE2_CTX *S, uint8_t *ou blake2b_set_lastblock(S); memset(S->buf + S->buflen, 0, 2 * BLAKE2B_BLOCKBYTES - S->buflen); /* Padding */ blake2b_compress(S, S->buf); - for (int i = 0; i < 8; ++i) { + for (i = 0; i < 8; ++i) { /* Output full hash to temp buffer */ store64(buffer + sizeof(S->h[i]) * i, S->h[i]); } Index: othersrc/external/bsd/multigest/dist/libmultigest.3 diff -u othersrc/external/bsd/multigest/dist/libmultigest.3:1.5 othersrc/external/bsd/multigest/dist/libmultigest.3:1.6 --- othersrc/external/bsd/multigest/dist/libmultigest.3:1.5 Sun Aug 18 06:03:14 2013 +++ othersrc/external/bsd/multigest/dist/libmultigest.3 Tue Mar 4 02:12:58 2014 @@ -1,6 +1,6 @@ -.\" $NetBSD: libmultigest.3,v 1.5 2013/08/18 06:03:14 agc Exp $ +.\" $NetBSD: libmultigest.3,v 1.6 2014/03/04 02:12:58 agc Exp $ .\" -.\" Copyright (c) 2013 Alistair Crooks <a...@netbsd.org> +.\" Copyright (c) 2013,2014 Alistair Crooks <a...@netbsd.org> .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -23,7 +23,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 17, 2013 +.Dd March 3, 2014 .Dt LIBMULTIGEST 3 .Os .Sh NAME @@ -69,6 +69,10 @@ .Fo multigest_get_rawsize .Fa "multigest_t *mg" .Fc +.Ft uint32_t +.Fo multigest_algs_rawsize +.Fa "const char *algnames" +.Fc .Ft int .Fo multigest_format_hex .Fa "unsigned char *rawinput" "const char *algorithms" @@ -80,6 +84,11 @@ .Fa "const char *outname" "const char *filename" "const char *substregex" .Fa "const char *output_separator" "const char *output_format" .Fc +.Ft char * +.Fo multigest_format_raw +.Fa "const uint8_t *rawinput" "size_t insize" +.Fa "char *fmtoutput" "size_t outsize" +.Fc .Sh DESCRIPTION .Nm is a library interface to calculate multiple digests @@ -167,6 +176,18 @@ using .Fn multigest_format_hex or printed, possible to an output file, by .Fn multigest_print_hex . +To format output without printing to a stream, +the +.Fn multigest_format_raw +function can be used. +To find out the rawsize needed (in bytes) for a multigest, +the +.Fn multigest_algs_rawsize +function can be used, passing the digest algorithm names as +arguments to the function, or the +.Fn multigest_get_rawsize +function can be used if the multigest structure has already +been initialised. .Sh SEE ALSO .Xr md5 3 , .Xr rmd160 3 , Index: othersrc/external/bsd/multigest/dist/multigest.c diff -u othersrc/external/bsd/multigest/dist/multigest.c:1.7 othersrc/external/bsd/multigest/dist/multigest.c:1.8 --- othersrc/external/bsd/multigest/dist/multigest.c:1.7 Wed Feb 5 17:43:17 2014 +++ othersrc/external/bsd/multigest/dist/multigest.c Tue Mar 4 02:12:58 2014 @@ -590,6 +590,22 @@ multigest_get_rawsize(multigest_t *multi return (multigest) ? (uint32_t)multigest->rawsize : 0; } +/* return the size of output array we'll need for the alg names */ +uint32_t +multigest_algs_rawsize(const char *alg) +{ + multigest_t m; + uint32_t size; + + memset(&m, 0x0, sizeof(m)); + if (!multigest_init(&m, alg)) { + return 0; + } + size = multigest_get_rawsize(&m); + multigest_free(&m); + return size; +} + /*****************************************************************/ #ifndef _KERNEL @@ -730,5 +746,20 @@ multigest_free(multigest_t *s) } } } + +/* turn a raw digest into an ascii string */ +char * +multigest_format_raw(const uint8_t *in, size_t insize, char *out, size_t outsize) +{ + const uint8_t *i; + char *o; + + for (o = out, i = in ; (size_t)(i - in) < insize && (size_t)(o - out) < outsize ; i++, o += 2) { + snprintf(o, 3, "%02hhx", *i); + } + *o = 0x0; + return out; +} + #endif Index: othersrc/external/bsd/multigest/dist/multigest.h diff -u othersrc/external/bsd/multigest/dist/multigest.h:1.6 othersrc/external/bsd/multigest/dist/multigest.h:1.7 --- othersrc/external/bsd/multigest/dist/multigest.h:1.6 Thu Aug 22 01:08:10 2013 +++ othersrc/external/bsd/multigest/dist/multigest.h Tue Mar 4 02:12:58 2014 @@ -79,16 +79,18 @@ int multigest_init(multigest_t */*multig int multigest_add_subst(multigest_t */*multigest*/, const char */*from*/, const char */*to*/); void multigest_update(multigest_t */*multigest*/, const char */*data*/, size_t /*len*/); void multigest_final(multigest_t */*multigest*/, uint8_t */*raw*/); +uint32_t multigest_get_rawsize(multigest_t */*multigest*/); /* high-level interface */ uint8_t *multigest_data(const char */*alg*/, const char */*data*/, size_t /*size*/, uint8_t */*raw*/, const char */*pat*/, const char */*repl*/); uint8_t *multigest_file(const char */*alg*/, const char */*f*/, uint8_t */*raw*/, const char */*pat*/, const char */*repl*/); +uint32_t multigest_algs_rawsize(const char */*algs*/); /* output */ void multigest_unpcstring(const char */*in*/, size_t /*isize*/, char */*out*/, size_t /*osize*/); -uint32_t multigest_get_rawsize(multigest_t */*multigest*/); int multigest_format_hex(uint8_t */*raw*/, const char */*algname*/, char */*out*/, size_t /*size*/); int multigest_print_hex(uint8_t */*raw*/, const char */*algname*/, const char */*outname*/, const char */*f*/, const char */*sub*/, const char */*sep*/, const char */*format*/); +char *multigest_format_raw(const uint8_t */*in*/, size_t /*insize*/, char */*out*/, size_t /*outsize*/); __END_DECLS Added files: Index: othersrc/external/bsd/multigest/dist/Makefile.in diff -u /dev/null othersrc/external/bsd/multigest/dist/Makefile.in:1.1 --- /dev/null Tue Mar 4 02:12:58 2014 +++ othersrc/external/bsd/multigest/dist/Makefile.in Tue Mar 4 02:12:58 2014 @@ -0,0 +1,32 @@ +# $NetBSD: Makefile.in,v 1.1 2014/03/04 02:12:58 agc Exp $ + +PROG=multigest + +OBJS+= blake2.o +OBJS+= crc32c.o +OBJS+= keccak.o +OBJS+= main.o +OBJS+= md5c.o +OBJS+= multigest.o +OBJS+= rmd160.o +OBJS+= sha1.o +OBJS+= sha2.o +OBJS+= tiger.o +OBJS+= whirlpool.o + +PREFIX=@PREFIX@ +MANDIR=@MANDIR@ + +all: ${PROG} + +${PROG}: ${OBJS} + ${CC} ${OBJS} -o ${PROG} + +install: + install -c -s ${PROG} ${DESTDIR}${PREFIX}/bin + install -c multigest.1 ${DESTDIR}${MANDIR}/man1 + +clean: + rm -rf *.core ${OBJS} ${PROG} +cleandist: + rm -rf *.core ${OBJS} ${PROG} Makefile Index: othersrc/external/bsd/multigest/dist/configure diff -u /dev/null othersrc/external/bsd/multigest/dist/configure:1.1 --- /dev/null Tue Mar 4 02:12:58 2014 +++ othersrc/external/bsd/multigest/dist/configure Tue Mar 4 02:12:58 2014 @@ -0,0 +1,64 @@ +#! /bin/sh + +# $NetBSD: configure,v 1.1 2014/03/04 02:12:58 agc Exp $ + +# Copyright (c) 2013 Alistair Crooks <a...@netbsd.org> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# set up defs and paths, etc +prefix=/usr/local +mandir=${prefix}/man +while [ $# -gt 0 ]; do + case "$1" in + --prefix=*) prefix=$(echo "$1" | sed -e 's|--prefix=||') ;; + --mandir=*) mandir=$(echo "$1" | sed -e 's|--mandir=||') ;; + --build=*|--host=*|--infodir=*) ;; + *) break ;; + esac + shift +done + +rm -f config.h +echo "#ifndef CONFIG_H_" > config.h +echo "#define CONFIG_H_ $(date '+%Y%m%d')" >> config.h +echo "" >> config.h + +# portability macros +echo "#ifndef __UNCONST" >> config.h +echo "#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))" >> config.h +echo "#endif /* __UNCONST */" >> config.h +echo "" >> config.h +echo "#ifndef USE_ARG" >> config.h +echo "#define USE_ARG(x) /*LINTED*/(void)&(x)" >> config.h +echo "#endif /* USE_ARG */" >> config.h + +echo "" >> config.h +echo "#endif /* CONFIG_H_ */" >> config.h + +for f in Makefile.in; do + sed -e 's|@PREFIX@|'${prefix}'|g' \ + -e 's|@MANDIR@|'${mandir}'|g' $f > $(basename $f .in) +done + +exit 0