Module Name:    src
Committed By:   agc
Date:           Mon Apr 17 19:50:28 UTC 2017

Modified Files:
        src/crypto/external/bsd/netpgp/bin/netpgpverify: Makefile
        src/crypto/external/bsd/netpgp/dist/src/netpgpverify: Makefile.bsd
            Makefile.in Makefile.lib.in Makefile.libtool.in array.h bignum.c
            digest.c digest.h libnetpgpverify.3 libverify.c main.c
            netpgpverify.1 pgpsum.c verify.h
        src/crypto/external/bsd/netpgp/lib/verify: Makefile
Removed Files:
        src/crypto/external/bsd/netpgp/dist/src/netpgpverify: tiger.c tiger.h

Log Message:
Update netpgpverify sources in base from 20160617 to 20170201 (i.e. bring
over changes from master sources in pkgsrc/security/netpgpverify, version 
20170201):

Changes:

Update netpgpverify (and libnetpgpverify) to 20160614
        + handle signatures created by gpg with "--no-emit-version", don't 
assume
        there will always be a version string.
        + add a test for above
        Fixes security PR  51240.
        Thanks to [email protected] for reporting the error

Update netpgpverify and libnetpgpverify to 20160615:
        Simplify the method of finding the end of the versioning information
        in the signature - back up to the "\n" character at the end of the
        signature start:

                "-----BEGIN PGP SIGNATURE-----\n"

        and then find the "\n\n" character sequence to denote the start of the
        signature itself. The previous version worked, but this is more 
efficient.

Update netpgpverify and libnetpgpverify to 20160616
        + bring over joerg's printflike change from the netpgpverify
        version in src/crypto
        + add a test for cleartext signatures with version information
        to complement the one with no version information

Update netpgpverify and libnetpgpverify to 20160622 during freeze to fix PR  
51262
        + take a bit of a step backwards, and don't use stdbool.h, just to 
appease
        Solaris 10 compiler

Update netpgpverify and libnetpgpverify to 20160623
        + remove use of asprintf and vasprintf from libverify. Inspired
        by work from Dimitri John Ledkov. Should allow building on Linux
        without superfluous definitions.
        + also free the BIGNUM struct in PGPV_BN_clear() - from Dimitri
        John Ledkov

Update netpgpverify and libnetpgpverify to 20160626
        + make the pgpv_t and pgpv_cursor_t structures opaque
        + add new accessor functions for fields in the pgpv_cursor_t struct
        + add new creation functions for the pgpv_t and pgpv_cursor_t structs

Update netpgpverify and libnetpgpverify to 20160704
        + get rid of redundant PGPV_ARRAY definition in libverify.c, brought in 
when
        the definitions moved from verify.h
        + fix obuf_add_mem() to use a const void *, as any struct can be
        dumped using it
        + remove redundant NO_SUBKEYS definition - unused
        + add an (unused as yet) ARRAY_FREE() macro

Update netpgpverify and libnetpgpverify to 20160705
        External API changes
        ====================
        + add a pgpv_cursor_close() function to free resources associated with
        a cursor
        Better memory management
        ========================
        + restructure the way dynamic arrays are used, to avoid memory
        corruption issues and memory leaks - keep all dynamic arrays in the 
global
        data structure, and use indices in the other data structures to index 
them.
        Means lack of data localisation, but avoids stale pointers, and leaks.
        + make signer field of signature a uint8_t array, rather than a pointer
        + use our own version of strdup(3) - don't depend on it being
        available in standard library
        + keep track of whether litdata filenames and userid were allocated or 
not,
        and free memory in pgpv_close() if it was allocated
        + free up allocated resources which were allocated in pgpv_close()

Update netpgpverify and libnetpgpverify to 20160706
        + 20160705 introduced a bug whereby a key subid would match and verify
        fine, but, if formatted, would not display the correct subkey
        information.  Fix to show the correct information in this case.

Update netpgpverify and libnetpgpverify to 20160707 to fix some
        unusual build errors shown by old gcc versions (works fine for
        gcc-5.2.1 on ubuntu and gcc-5.3.0 on NetBSD 7.99.32)
        + use ULL suffix on unsigned 64bit constants, not UL
        + don't typedef the public structs twice - second time just define it
        without the typedef
        Fixes PR   51327

Update netpgpverify and libnetpgpverify to 20160708
        + clear and free bignums properly - helps immensely with plugging
        memory leaks

Update netpgpverify and libnetpgpverify to 20160828
        + bring over change from christos in src/crypto to check for
        the end of an ASCII-armored signature
        + no need for namespace protection in array.h any more, now
        that netpgp/verify.h now contains opaque structures
        + minor typo clean-up in a definition (benign, ignored by compiler)

update netpgpverify and libnetpgpverify to 20170201
        + make sure howmany() macro is defined
        pointed out by cube - thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 \
    src/crypto/external/bsd/netpgp/bin/netpgpverify/Makefile
cvs rdiff -u -r1.6 -r1.7 \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.bsd
cvs rdiff -u -r1.10 -r1.11 \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.in \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/netpgpverify.1
cvs rdiff -u -r1.1 -r1.2 \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.lib.in \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.libtool.in \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/array.h
cvs rdiff -u -r1.3 -r1.4 \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/bignum.c \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/libnetpgpverify.3
cvs rdiff -u -r1.2 -r1.3 \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/digest.c \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/digest.h \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/pgpsum.c
cvs rdiff -u -r1.12 -r1.13 \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/libverify.c
cvs rdiff -u -r1.7 -r1.8 \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/main.c
cvs rdiff -u -r1.3 -r0 \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/tiger.c
cvs rdiff -u -r1.2 -r0 \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/tiger.h
cvs rdiff -u -r1.9 -r1.10 \
    src/crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.h
cvs rdiff -u -r1.8 -r1.9 src/crypto/external/bsd/netpgp/lib/verify/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/crypto/external/bsd/netpgp/bin/netpgpverify/Makefile
diff -u src/crypto/external/bsd/netpgp/bin/netpgpverify/Makefile:1.14 src/crypto/external/bsd/netpgp/bin/netpgpverify/Makefile:1.15
--- src/crypto/external/bsd/netpgp/bin/netpgpverify/Makefile:1.14	Tue Jun 14 20:47:43 2016
+++ src/crypto/external/bsd/netpgp/bin/netpgpverify/Makefile	Mon Apr 17 19:50:27 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.14 2016/06/14 20:47:43 agc Exp $
+#	$NetBSD: Makefile,v 1.15 2017/04/17 19:50:27 agc Exp $
 
 PROG=netpgpverify
 BINDIR=		/usr/bin
@@ -9,7 +9,7 @@ SRCS+= pgpsum.c rsa.c
 
 SRCS+= bzlib.c zlib.c
 
-SRCS+= md5c.c rmd160.c sha1.c sha2.c tiger.c
+SRCS+= md5c.c rmd160.c sha1.c sha2.c
 
 CPPFLAGS+=-I${.CURDIR} -I${EXTDIST}/src/netpgpverify
 COPTS.libverify.c+= -Wno-format-nonliteral

Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.bsd
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.bsd:1.6 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.bsd:1.7
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.bsd:1.6	Wed Jun 15 16:51:46 2016
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.bsd	Mon Apr 17 19:50:28 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.bsd,v 1.6 2016/06/15 16:51:46 agc Exp $
+# $NetBSD: Makefile.bsd,v 1.7 2017/04/17 19:50:28 agc Exp $
 
 PROG=netpgpverify
 
@@ -8,7 +8,7 @@ SRCS+= pgpsum.c rsa.c
 
 SRCS+= bzlib.c zlib.c
 
-SRCS+= md5c.c rmd160.c sha1.c sha2.c tiger.c
+SRCS+= md5c.c rmd160.c sha1.c sha2.c
 
 CPPFLAGS+=-I.
 
@@ -47,3 +47,5 @@ tst:
 	./${PROG} -k pubring.gpg version.asc
 	@echo "testing signatures with no version"
 	./${PROG} -k pubring.gpg noversion.asc
+	@echo "testing dash-escaped text"
+	./${PROG} -k pubring.gpg dash-escaped-text.asc

Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.in
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.in:1.10 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.in:1.11
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.in:1.10	Wed Jun 15 16:51:46 2016
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.in	Mon Apr 17 19:50:28 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.in,v 1.10 2016/06/15 16:51:46 agc Exp $
+# $NetBSD: Makefile.in,v 1.11 2017/04/17 19:50:28 agc Exp $
 
 PROG=netpgpverify
 
@@ -8,7 +8,7 @@ OBJS+= pgpsum.o rsa.o
 
 OBJS+= bzlib.o zlib.o
 
-OBJS+= sha1.o sha2.o md5c.o rmd160.o tiger.o
+OBJS+= sha1.o sha2.o md5c.o rmd160.o
 
 PREFIX=@PREFIX@
 MANDIR=@MANDIR@
@@ -47,6 +47,8 @@ tst:
 	./${PROG} -k pubring.gpg version.asc
 	@echo "testing signatures with no version"
 	./${PROG} -k pubring.gpg noversion.asc
+	@echo "testing dash-escaped text"
+	./${PROG} -k pubring.gpg dash-escaped-text.asc
 
 clean:
 	rm -rf *.core ${OBJS} ${PROG}
Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/netpgpverify.1
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/netpgpverify.1:1.10 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/netpgpverify.1:1.11
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/netpgpverify.1:1.10	Mon Sep 12 16:54:31 2016
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/netpgpverify.1	Mon Apr 17 19:50:28 2017
@@ -1,4 +1,4 @@
-.\" $NetBSD: netpgpverify.1,v 1.10 2016/09/12 16:54:31 abhinav Exp $
+.\" $NetBSD: netpgpverify.1,v 1.11 2017/04/17 19:50:28 agc Exp $
 .\"
 .\" Copyright (c) 2013,2014,2015 Alistair Crooks <[email protected]>
 .\" All rights reserved.
@@ -42,9 +42,9 @@ The
 implements digital signature verification.
 It is designed to be simple and standalone; no external libraries, except
 for
-.Xr libz 3
+.Xr libz
 and
-.Xr libbz2 3
+.Xr libbz2
 are used, in order to ensure maximum portability.
 .Pp
 It is completely rewritten from the version of the program that appeared in
@@ -128,7 +128,7 @@ Verification of a file's signature is be
 % netpgpverify -k pubring.gpg NetBSD-6.0_RC1_hashes.asc
 Good signature for NetBSD-6.0_RC1_hashes.asc made Thu Aug 23 11:47:50 2012
 signature     4096/RSA (Encrypt or Sign) 064973ac4c4a706e 2009-06-23
-fingerprint   ddee 2bdb 9c98 a0d1 d4fb dbf7 0649 73ac 4c4a 706e
+fingerprint   ddee 2bdb 9c98 a0d1 d4fb dbf7 0649 73ac 4c4a 706e 
 uid           NetBSD Security Officer <[email protected]>
 %
 .Ed

Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.lib.in
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.lib.in:1.1 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.lib.in:1.2
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.lib.in:1.1	Sun Mar  9 00:15:45 2014
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.lib.in	Mon Apr 17 19:50:28 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.lib.in,v 1.1 2014/03/09 00:15:45 agc Exp $
+# $NetBSD: Makefile.lib.in,v 1.2 2017/04/17 19:50:28 agc Exp $
 
 LIB=	libnetpgpverify.a
 
@@ -8,7 +8,7 @@ OBJS+= pgpsum.o rsa.o
 
 OBJS+= bzlib.o zlib.o
 
-OBJS+= sha1.o sha2.o md5c.o rmd160.o tiger.o
+OBJS+= sha1.o sha2.o md5c.o rmd160.o
 
 PREFIX=@PREFIX@
 MANDIR=@MANDIR@
Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.libtool.in
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.libtool.in:1.1 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.libtool.in:1.2
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.libtool.in:1.1	Sun Mar  9 00:15:45 2014
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/Makefile.libtool.in	Mon Apr 17 19:50:28 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.libtool.in,v 1.1 2014/03/09 00:15:45 agc Exp $
+# $NetBSD: Makefile.libtool.in,v 1.2 2017/04/17 19:50:28 agc Exp $
 
 LIB=	libnetpgpverify.a
 
@@ -8,7 +8,7 @@ OBJS+= pgpsum.o rsa.o
 
 OBJS+= bzlib.o zlib.o
 
-OBJS+= sha1.o sha2.o md5c.o rmd160.o tiger.o
+OBJS+= sha1.o sha2.o md5c.o rmd160.o
 
 PREFIX=@PREFIX@
 MANDIR=@MANDIR@
Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/array.h
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/array.h:1.1 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/array.h:1.2
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/array.h:1.1	Sun Mar  9 00:15:45 2014
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/array.h	Mon Apr 17 19:50:28 2017
@@ -25,10 +25,10 @@
 #ifndef ARRAY_H_
 #define ARRAY_H_	20120921
 
-#ifndef PGPV_ARRAY
+#ifndef ARRAY
 /* creates 2 unsigned vars called "name"c and "name"size in current scope */
 /* also creates an array called "name"s in current scope */
-#define PGPV_ARRAY(type, name)						\
+#define ARRAY(type, name)						\
 	unsigned name##c; unsigned name##vsize; type *name##s
 #endif
 
@@ -67,6 +67,8 @@
 #define ARRAY_SIZE(name)		name##vsize
 #define ARRAY_ARRAY(name)		name##s
 
+#define ARRAY_FREE(name)		free(name##s)
+
 #define ARRAY_APPEND(name, newel) do {					\
 	ARRAY_EXPAND(name);						\
 	ARRAY_COUNT(name) += 1;						\

Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/bignum.c
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/bignum.c:1.3 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/bignum.c:1.4
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/bignum.c:1.3	Tue Jun 14 20:47:08 2016
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/bignum.c	Mon Apr 17 19:50:28 2017
@@ -5438,6 +5438,7 @@ PGPV_BN_free(PGPV_BIGNUM *a)
 {
 	if (a) {
 		mp_clear(a);
+		free(a);
 	}
 }
 
@@ -5452,9 +5453,8 @@ PGPV_BN_clear(PGPV_BIGNUM *a)
 void
 PGPV_BN_clear_free(PGPV_BIGNUM *a)
 {
-	if (a) {
-		mp_clear(a);
-	}
+	PGPV_BN_clear(a);
+	free(a);
 }
 
 int
Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/libnetpgpverify.3
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/libnetpgpverify.3:1.3 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/libnetpgpverify.3:1.4
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/libnetpgpverify.3:1.3	Thu Feb  5 01:26:54 2015
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/libnetpgpverify.3	Mon Apr 17 19:50:28 2017
@@ -1,6 +1,6 @@
-.\" $NetBSD: libnetpgpverify.3,v 1.3 2015/02/05 01:26:54 agc Exp $
+.\" $NetBSD: libnetpgpverify.3,v 1.4 2017/04/17 19:50:28 agc Exp $
 .\"
-.\" Copyright (c) 2014 Alistair Crooks <[email protected]>
+.\" Copyright (c) 2014,2015,2016 Alistair Crooks <[email protected]>
 .\" 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 January 15, 2015
+.Dd June 26, 2016
 .Dt LIBNETPGPVERIFY 3
 .Os
 .Sh NAME
@@ -34,6 +34,14 @@
 .Sh SYNOPSIS
 .In netpgp/verify.h
 .Ft int
+.Fo pgpv_new
+.Fa "void"
+.Fc
+.Ft int
+.Fo pgpv_new_cursor
+.Fa "void"
+.Fc
+.Ft int
 .Fo pgpv_read_pubring
 .Fa "pgpv_t *pgp" "const void *keyring" "ssize_t size"
 .Fc
@@ -61,6 +69,14 @@
 .Fo pgpv_get_entry
 .Fa "pgpv_t *pgp" "unsigned ent" "char **ret" "const char *modifiers"
 .Fc
+.Ft int64_t
+.Fo pgpv_get_cursor_num
+.Fa "pgpv_t *pgp" "const char *field"
+.Fc
+.Ft char *
+.Fo pgpv_get_cursor_str
+.Fa "pgpv_t *pgp" "const char *field"
+.Fc
 .Ft int
 .Fo pgpv_close
 .Fa "pgpv_t *pgp"

Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/digest.c
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/digest.c:1.2 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/digest.c:1.3
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/digest.c:1.2	Tue Jun 14 20:47:08 2016
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/digest.c	Mon Apr 17 19:50:28 2017
@@ -64,12 +64,6 @@ static uint8_t prefix_sha256[] = {
 	0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20
 };
 
-static uint64_t	prefix_tiger[] = {
-	0x0123456789ABCDEFLL,
-	0xFEDCBA9876543210LL,
-	0xF096A5B4C3B2E187LL
-};
-
 static uint8_t prefix_rmd160[] = {
 	0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24,
 	0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14
@@ -99,9 +93,6 @@ digest_alg_size(unsigned alg)
 		return 32;
 	case SHA512_HASH_ALG:
 		return 64;
-	case TIGER_HASH_ALG:
-	case TIGER2_HASH_ALG:
-		return TIGER_DIGEST_LENGTH;
 	default:
 		printf("hash_any: bad algorithm\n");
 		return 0;
@@ -151,20 +142,6 @@ digest_init(digest_t *hash, const uint32
 		hash->len = sizeof(prefix_sha512);
 		hash->ctx = &hash->u.sha512ctx;
 		return 1;
-	case TIGER_HASH_ALG:
-		netpgpv_TIGER_Init(&hash->u.tigerctx);
-		hash->size = TIGER_DIGEST_LENGTH;
-		hash->prefix = prefix_tiger;
-		hash->len = sizeof(prefix_tiger);
-		hash->ctx = &hash->u.tigerctx;
-		return 1;
-	case TIGER2_HASH_ALG:
-		netpgpv_TIGER2_Init(&hash->u.tigerctx);
-		hash->size = TIGER_DIGEST_LENGTH;
-		hash->prefix = prefix_tiger;
-		hash->len = sizeof(prefix_tiger);
-		hash->ctx = &hash->u.tigerctx;
-		return 1;
 	default:
 		printf("hash_any: bad algorithm\n");
 		return 0;
@@ -182,8 +159,6 @@ static rec_t	hashalgs[] = {
 	{	"ripemd",	RIPEMD_HASH_ALG	},
 	{	"sha256",	SHA256_HASH_ALG	},
 	{	"sha512",	SHA512_HASH_ALG	},
-	{	"tiger",	TIGER_HASH_ALG	},
-	{	"tiger2",	TIGER2_HASH_ALG	},
 	{	NULL,		0		}
 };
 
@@ -223,10 +198,6 @@ digest_update(digest_t *hash, const uint
 	case SHA512_HASH_ALG:
 		netpgpv_SHA512_Update(hash->ctx, data, length);
 		return 1;
-	case TIGER_HASH_ALG:
-	case TIGER2_HASH_ALG:
-		netpgpv_TIGER_Update(hash->ctx, data, length);
-		return 1;
 	default:
 		printf("hash_any: bad algorithm\n");
 		return 0;
@@ -255,9 +226,6 @@ digest_final(uint8_t *out, digest_t *has
 	case SHA512_HASH_ALG:
 		netpgpv_SHA512_Final(out, hash->ctx);
 		break;
-	case TIGER_HASH_ALG:
-		netpgpv_TIGER_Final(out, hash->ctx);
-		break;
 	default:
 		printf("hash_any: bad algorithm\n");
 		return 0;
Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/digest.h
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/digest.h:1.2 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/digest.h:1.3
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/digest.h:1.2	Tue Jun 14 20:47:08 2016
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/digest.h	Mon Apr 17 19:50:28 2017
@@ -33,7 +33,6 @@
 #include "sha1.h"
 #include "sha2.h"
 #include "rmd160.h"
-#include "tiger.h"
 
 #ifndef __BEGIN_DECLS
 #  if defined(__cplusplus)
@@ -50,12 +49,10 @@ __BEGIN_DECLS
 #define MD5_HASH_ALG		1
 #define SHA1_HASH_ALG		2
 #define RIPEMD_HASH_ALG		3
-#define TIGER_HASH_ALG		6	/* from rfc2440 */
 #define SHA256_HASH_ALG		8
 #define SHA384_HASH_ALG		9
 #define SHA512_HASH_ALG		10
 #define SHA224_HASH_ALG		11
-#define TIGER2_HASH_ALG		100	/* private/experimental from rfc4880 */
 
 /* structure to describe digest methods */
 typedef struct digest_t {
@@ -67,7 +64,6 @@ typedef struct digest_t {
 		NETPGPV_RMD160_CTX	 rmd160ctx;	/* RIPEMD */
 		NETPGPV_SHA256_CTX	 sha256ctx;	/* SHA256 */
 		NETPGPV_SHA512_CTX	 sha512ctx;	/* SHA512 */
-		NETPGPV_TIGER_CTX	 tigerctx;	/* TIGER/TIGER2 */
 	} u;
 	void			*prefix;	/* points to specific prefix */
 	uint32_t		 len;		/* prefix length */
Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/pgpsum.c
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/pgpsum.c:1.2 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/pgpsum.c:1.3
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/pgpsum.c:1.2	Tue Jun 14 20:47:08 2016
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/pgpsum.c	Mon Apr 17 19:50:28 2017
@@ -44,6 +44,18 @@
 #undef swap16
 #undef swap32
 
+/* ignore any dash-escape at the start of a line */
+static void
+dash_escaped_update(digest_t *hash, uint8_t *in, size_t insize)
+{
+	if (insize >= 2 && memcmp(in, "- ", 2) == 0) {
+		in += 2;
+		insize -= 2;
+	}
+	digest_update(hash, in, insize);
+
+}
+
 /* add the ascii armor line endings (except for last line) */
 static size_t
 don_armor(digest_t *hash, uint8_t *in, size_t insize, int doarmor)
@@ -61,10 +73,10 @@ don_armor(digest_t *hash, uint8_t *in, s
 				break;
 			}
 		}
-		digest_update(hash, from, (size_t)(newp - from));
+		dash_escaped_update(hash, from, (size_t)(newp - from));
 		digest_update(hash, dos_line_end, sizeof(dos_line_end));
 	}
-	digest_update(hash, from, insize - (size_t)(from - in));
+	dash_escaped_update(hash, from, insize - (size_t)(from - in));
 	return 1;
 }
 

Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/libverify.c
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/libverify.c:1.12 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/libverify.c:1.13
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/libverify.c:1.12	Sat Sep  3 09:31:22 2016
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/libverify.c	Mon Apr 17 19:50:28 2017
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2012,2013,2014,2015 Alistair Crooks <[email protected]>
+ * Copyright (c) 2012,2013,2014,2015,2016 Alistair Crooks <[email protected]>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -33,7 +33,6 @@
 
 #include <inttypes.h>
 #include <limits.h>
-#include <stdbool.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -54,6 +53,243 @@
 #include "rsa.h"
 #include "verify.h"
 
+/* 64bit key ids */
+#define PGPV_KEYID_LEN		8
+#define PGPV_STR_KEYID_LEN	(PGPV_KEYID_LEN + PGPV_KEYID_LEN + 1)
+
+/* bignum structure */
+typedef struct pgpv_bignum_t {
+	void			*bn;	/* hide the implementation details */
+	uint16_t		 bits;	/* cached number of bits */
+} pgpv_bignum_t;
+
+/* right now, our max binary digest length is 20 bytes */
+#define PGPV_MAX_HASH_LEN	64
+
+/* fingerprint */
+typedef struct pgpv_fingerprint_t {
+	uint8_t			hashalg;	/* algorithm for digest */
+	uint8_t			v[PGPV_MAX_HASH_LEN];	/* the digest */
+	uint32_t		len;		/* its length */
+} pgpv_fingerprint_t;
+
+/* specify size for array of bignums */
+#define PGPV_MAX_PUBKEY_BN	4
+
+/* public key */
+typedef struct pgpv_pubkey_t {
+	pgpv_fingerprint_t	 fingerprint;	/* key fingerprint i.e. digest */
+	uint8_t			 keyid[PGPV_KEYID_LEN];	/* last 8 bytes of v4 keys */
+	int64_t		 	 birth;		/* creation time */
+	int64_t			 expiry;	/* expiry time */
+	pgpv_bignum_t		 bn[PGPV_MAX_PUBKEY_BN]; /* bignums */
+	uint8_t			 keyalg;	/* key algorithm */
+	uint8_t			 hashalg;	/* hash algorithm */
+	uint8_t			 version;	/* key version */
+} pgpv_pubkey_t;
+
+#define PGPV_MAX_SESSKEY_BN	2
+
+/* a (size, byte array) string */
+typedef struct pgpv_string_t {
+	size_t			 size;
+	uint8_t			*data;
+	uint8_t			 allocated;
+} pgpv_string_t;
+
+typedef struct pgpv_ref_t {
+	void			*vp;
+	size_t			 offset;
+	unsigned		 mem;
+} pgpv_ref_t;
+
+#define PGPV_MAX_SECKEY_BN	4
+
+typedef struct pgpv_compress_t {
+	pgpv_string_t		 s;
+	uint8_t			 compalg;
+} pgpv_compress_t;
+
+/* a packet dealing with trust */
+typedef struct pgpv_trust_t {
+	uint8_t			level;
+	uint8_t			amount;
+} pgpv_trust_t;
+
+/* a signature sub packet */
+typedef struct pgpv_sigsubpkt_t {
+	pgpv_string_t		 s;
+	uint8_t			 tag;
+	uint8_t			 critical;
+} pgpv_sigsubpkt_t;
+
+#define PGPV_MAX_SIG_BN		2
+
+typedef struct pgpv_signature_t {
+	uint8_t			 signer[PGPV_KEYID_LEN]; /* key id of signer */
+	pgpv_ref_t		 hashstart;
+	uint8_t			*hash2;
+	uint8_t			*mpi;
+	int64_t			 birth;
+	int64_t			 keyexpiry;
+	int64_t			 expiry;
+	uint32_t		 hashlen;
+	uint8_t			 version;
+	uint8_t			 type;
+	uint8_t			 keyalg;
+	uint8_t			 hashalg;
+	uint8_t			 trustlevel;
+	uint8_t			 trustamount;
+	pgpv_bignum_t		 bn[PGPV_MAX_SIG_BN];
+	char			*regexp;
+	char			*pref_key_server;
+	char			*policy;
+	char			*features;
+	char			*why_revoked;
+	uint8_t			*revoke_fingerprint;
+	uint8_t			 revoke_alg;
+	uint8_t			 revoke_sensitive;
+	uint8_t			 trustsig;
+	uint8_t			 revocable;
+	uint8_t			 pref_symm_alg;
+	uint8_t			 pref_hash_alg;
+	uint8_t			 pref_compress_alg;
+	uint8_t			 key_server_modify;
+	uint8_t			 notation;
+	uint8_t			 type_key;
+	uint8_t			 primary_userid;
+	uint8_t			 revoked;	/* subtract 1 to get real reason, 0 == not revoked */
+} pgpv_signature_t;
+
+/* a signature packet */
+typedef struct pgpv_sigpkt_t {
+	pgpv_signature_t	 sig;
+	uint16_t		 subslen;
+	uint16_t		 unhashlen;
+	ARRAY(uint64_t,	 	 subpackets);
+} pgpv_sigpkt_t;
+
+/* a one-pass signature packet */
+typedef struct pgpv_onepass_t {
+	uint8_t			 keyid[PGPV_KEYID_LEN];
+	uint8_t			 version;
+	uint8_t			 type;
+	uint8_t			 hashalg;
+	uint8_t			 keyalg;
+	uint8_t			 nested;
+} pgpv_onepass_t;
+
+/* a literal data packet */
+typedef struct pgpv_litdata_t {
+	pgpv_string_t		 filename;
+	pgpv_string_t		 s;
+	uint32_t		 secs;
+	uint8_t			 namelen;
+	char			 format;
+	unsigned		 mem;
+	size_t			 offset;
+	size_t			 len;
+} pgpv_litdata_t;
+
+/* user attributes - images */
+typedef struct pgpv_userattr_t {
+	size_t 			 len;
+	ARRAY(pgpv_string_t, 	 subattrs);
+} pgpv_userattr_t;
+
+/* a general PGP packet */
+typedef struct pgpv_pkt_t {
+	uint8_t			 tag;
+	uint8_t			 newfmt;
+	uint8_t			 allocated;
+	uint8_t			 mement;
+	size_t			 offset;
+	pgpv_string_t		 s;
+	union {
+		pgpv_sigpkt_t	sigpkt;
+		pgpv_onepass_t	onepass;
+		pgpv_litdata_t	litdata;
+		pgpv_compress_t	compressed;
+		pgpv_trust_t	trust;
+		pgpv_pubkey_t	pubkey;
+		pgpv_string_t	userid;
+		pgpv_userattr_t	userattr;
+	} u;
+} pgpv_pkt_t;
+
+/* a memory structure */
+typedef struct pgpv_mem_t {
+	size_t			 size;
+	size_t			 cc;
+	uint8_t			*mem;
+	FILE			*fp;
+	uint8_t			 dealloc;
+	const char		*allowed;	/* the types of packet that are allowed */
+} pgpv_mem_t;
+
+/* packet parser */
+
+typedef struct pgpv_signed_userid_t {
+	pgpv_string_t	 	 userid;
+	ARRAY(uint64_t, 	 signatures);
+	uint8_t			 primary_userid;
+	uint8_t			 revoked;
+} pgpv_signed_userid_t;
+
+typedef struct pgpv_signed_userattr_t {
+	pgpv_userattr_t	 	 userattr;
+	ARRAY(uint64_t, 	 signatures);
+	uint8_t			 revoked;
+} pgpv_signed_userattr_t;
+
+typedef struct pgpv_signed_subkey_t {
+	pgpv_pubkey_t	 	 subkey;
+	pgpv_signature_t 	 revoc_self_sig;
+	ARRAY(uint64_t, 	 signatures);
+} pgpv_signed_subkey_t;
+
+typedef struct pgpv_primarykey_t {
+	pgpv_pubkey_t 		 primary;
+	pgpv_signature_t 	 revoc_self_sig;
+	ARRAY(uint64_t, 	 signatures);
+	ARRAY(uint64_t, 	 signed_userids);
+	ARRAY(uint64_t, 	 signed_userattrs);
+	ARRAY(uint64_t, 	 signed_subkeys);
+	size_t			 fmtsize;
+	uint8_t			 primary_userid;
+} pgpv_primarykey_t;
+
+/* everything stems from this structure */
+struct pgpv_t {
+	ARRAY(pgpv_pkt_t, 	 pkts);		/* packet array */
+	ARRAY(pgpv_primarykey_t, primaries);	/* array of primary keys */
+	ARRAY(pgpv_mem_t,	 areas);	/* areas we read packets from */
+	ARRAY(size_t,	 	 datastarts);	/* starts of data packets */
+	ARRAY(pgpv_signature_t,	 signatures);	/* all signatures */
+	ARRAY(pgpv_signed_userid_t, signed_userids); /* all signed userids */
+	ARRAY(pgpv_signed_userattr_t, signed_userattrs); /* all signed user attrs */
+	ARRAY(pgpv_signed_subkey_t, signed_subkeys); /* all signed subkeys */
+	ARRAY(pgpv_sigsubpkt_t,	 subpkts);	/* all sub packets */
+	size_t		 	 pkt;		/* when parsing, current pkt number */
+	const char		*op;		/* the operation we're doing */
+	unsigned		 ssh;		/* using ssh keys */
+};
+
+#define PGPV_REASON_LEN		128
+
+/* when searching, we define a cursor, and fill in an array of subscripts */
+struct pgpv_cursor_t {
+	pgpv_t			*pgp;			/* pointer to pgp tree */
+	char			*field;			/* field we're searching on */
+	char			*op;			/* operation we're doing */
+	char			*value;			/* value we're searching for */
+	void			*ptr;			/* for regexps etc */
+	ARRAY(uint32_t,	 	 found);		/* array of matched pimary key subscripts */
+	ARRAY(size_t,	 	 datacookies);		/* cookies to retrieve matched data */
+	int64_t			 sigtime;		/* time of signature */
+	char			 why[PGPV_REASON_LEN];	/* reason for bad signature */
+};
+
 #ifndef USE_ARG
 #define USE_ARG(x)	/*LINTED*/(void)&(x)
 #endif
@@ -70,6 +306,10 @@
 #define MIN(a,b)			(((a)<(b))?(a):(b))
 #endif
 
+#ifndef howmany
+#define howmany(x, y)   		(((x)+((y)-1))/(y))
+#endif
+
 #define BITS_TO_BYTES(b)		(((b) + (CHAR_BIT - 1)) / CHAR_BIT)
 
 /* packet types */
@@ -98,7 +338,7 @@
 #define PUBKEY_RSA_SIGN			3
 #define PUBKEY_ELGAMAL_ENCRYPT		16
 #define PUBKEY_DSA			17
-#define PUBKEY_ELLIPTIC_CURVE		18
+#define PUBKEY_ECDH			18
 #define PUBKEY_ECDSA			19
 #define PUBKEY_ELGAMAL_ENCRYPT_OR_SIGN	20
 
@@ -177,7 +417,7 @@ typedef struct obuf_t {
 } obuf_t;
 
 /* grow the buffer, if needed */
-static bool
+static int
 growbuf(obuf_t *obuf, size_t cc)
 {
 	size_t	 newalloc;
@@ -187,51 +427,27 @@ growbuf(obuf_t *obuf, size_t cc)
 		newalloc = howmany(obuf->alloc + cc, 128) * 128;
 		newv = realloc(obuf->v, newalloc);
 		if (newv == NULL) {
-			return false;
+			return 0;
 		}
 		obuf->v = newv;
 		obuf->alloc = newalloc;
 	}
-	return true;
+	return 1;
 }
 
 /* add a fixed-length area of memory */
-static bool
-obuf_add_mem(obuf_t *obuf, const char *s, size_t len)
+static int
+obuf_add_mem(obuf_t *obuf, const void *s, size_t len)
 {
 	if (obuf && s && len > 0) {
 		if (!growbuf(obuf, len)) {
-			return false;
+			return 0;
 		}
 		memcpy(&obuf->v[obuf->c], s, len);
 		obuf->c += len;
-		return true;
-	}
-	return false;
-}
-
-/* varargs-based printf to string */
-__printflike(2, 3)
-static bool
-obuf_printf(obuf_t *obuf, const char *fmt, ...)
-{
-	va_list	 args;
-	char	*cp;
-	bool	 ret;
-	int	 cc;
-
-	if (obuf && fmt) {
-		ret = true;
-		va_start(args, fmt);
-		cc = vasprintf(&cp, fmt, args);
-		va_end(args);
-		if (cc > 0) {
-			ret = obuf_add_mem(obuf, cp, (size_t)cc);
-			free(cp);
-		}
-		return ret;
+		return 1;
 	}
-	return false;
+	return 0;
 }
 
 /* read a file into the pgpv_mem_t struct */
@@ -287,7 +503,7 @@ static uint8_t *
 get_ref(pgpv_ref_t *ref)
 {
 	pgpv_mem_t	*mem;
-	pgpv_t		*pgp = (pgpv_t *)ref->vp;;
+	pgpv_t		*pgp = (pgpv_t *)ref->vp;
 
 	mem = &ARRAY_ELEMENT(pgp->areas, ref->mem);
 	return &mem->mem[ref->offset];
@@ -485,13 +701,15 @@ static size_t
 fmt_binary(obuf_t *obuf, const uint8_t *bin, unsigned len)
 {
 	unsigned	i;
+	char		newbuf[3];
 
 	for (i = 0 ; i < len ; i++) {
-		if (!obuf_printf(obuf, "%02hhx", bin[i])) {
-			return false;
+		snprintf(newbuf, sizeof(newbuf), "%02hhx", bin[i]);
+		if (!obuf_add_mem(obuf, newbuf, 2)) {
+			return 0;
 		}
 	}
-	return true;
+	return 1;
 }
 
 /* format an mpi into memory */
@@ -620,21 +838,28 @@ pgpv_calc_fingerprint(pgpv_fingerprint_t
 }
 
 /* format a fingerprint into memory */
-static bool
+static int
 fmt_fingerprint(obuf_t *obuf, pgpv_fingerprint_t *fingerprint, const char *name)
 {
 	unsigned	i;
+	char		newbuf[3];
+	int		cc;
 
-	if (!obuf_printf(obuf, "%s ", name)) {
-		return false;
+	if (!obuf_add_mem(obuf, name, strlen(name)) ||
+	    !obuf_add_mem(obuf, " ", 1)) {
+		return 0;
 	}
 	for (i = 0 ; i < fingerprint->len ; i++) {
-		if (!obuf_printf(obuf, "%02hhx%s",
-			fingerprint->v[i], (i % 2 == 1) ? " " : "")) {
-				return false;
+		cc = snprintf(newbuf, sizeof(newbuf), "%02hhx",
+			fingerprint->v[i]);
+		if (!obuf_add_mem(obuf, newbuf, cc)) {
+			return 0;
+		}
+		if (i % 2 == 1 && !obuf_add_mem(obuf, " ", 1)) {
+			return 0;
 		}
 	}
-	return obuf_printf(obuf, "\n");
+	return obuf_add_mem(obuf, "\n", 1);
 }
 
 /* calculate keyid from a pubkey */
@@ -650,18 +875,18 @@ calc_keyid(pgpv_pubkey_t *key, const cha
 static void
 str_to_keyid(const char *s, uint8_t *keyid)
 {
-	uint64_t	u64;
+	uint64_t	u;
 
-	u64 = (uint64_t)strtoull(s, NULL, 16);
-	u64 =   ((u64 & 0x00000000000000FFUL) << 56) | 
-		((u64 & 0x000000000000FF00UL) << 40) | 
-		((u64 & 0x0000000000FF0000UL) << 24) | 
-		((u64 & 0x00000000FF000000UL) <<  8) | 
-		((u64 & 0x000000FF00000000UL) >>  8) | 
-		((u64 & 0x0000FF0000000000UL) >> 24) | 
-		((u64 & 0x00FF000000000000UL) >> 40) | 
-		((u64 & 0xFF00000000000000UL) >> 56);
-	memcpy(keyid, &u64, PGPV_KEYID_LEN);
+	u = (uint64_t)strtoull(s, NULL, 16);
+	u =     ((u & 0x00000000000000FFULL) << 56) | 
+		((u & 0x000000000000FF00ULL) << 40) | 
+		((u & 0x0000000000FF0000ULL) << 24) | 
+		((u & 0x00000000FF000000ULL) <<  8) | 
+		((u & 0x000000FF00000000ULL) >>  8) | 
+		((u & 0x0000FF0000000000ULL) >> 24) | 
+		((u & 0x00FF000000000000ULL) >> 40) | 
+		((u & 0xFF00000000000000ULL) >> 56);
+	memcpy(keyid, &u, PGPV_KEYID_LEN);
 }
 
 #define PKT_ALWAYS_ON			0x80
@@ -735,26 +960,32 @@ fmt_time(obuf_t *obuf, const char *heade
 	time_t		elapsed;
 	time_t		now;
 	time_t		t;
+	char		newbuf[128];
+	int		cc;
 
 	t = (time_t)n;
 	now = time(NULL);
 	elapsed = now - t;
 	gmtime_r(&t, &tm);            
-	if (!obuf_printf(obuf, "%s%04d-%02d-%02d", header,
-		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday)) {
-			return false;
+	cc = snprintf(newbuf, sizeof(newbuf), "%04d-%02d-%02d",
+		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
+	if (!obuf_add_mem(obuf, header, strlen(header)) ||
+	    !obuf_add_mem(obuf, newbuf, cc)) {
+		return 0;
 	}
 	if (relative) {
-		if (!obuf_printf(obuf, " (%lldy %lldm %lldd %lldh %s)",
+		cc = snprintf(newbuf, sizeof(newbuf),
+			" (%lldy %lldm %lldd %lldh %s)",
 			llabs((long long)elapsed / YEARSECS),
 			llabs(((long long)elapsed % YEARSECS) / MONSECS),
 			llabs(((long long)elapsed % MONSECS) / DAYSECS),
 			llabs(((long long)elapsed % DAYSECS) / HOURSECS),
-			(now > t) ? "ago" : "ahead")) {
-				return false;
+			(now > t) ? "ago" : "ahead");
+		if (!obuf_add_mem(obuf, newbuf, cc)) {
+			return 0;
 		}
 	}
-	return obuf_printf(obuf, "%s", trailer);
+	return (*trailer) ? obuf_add_mem(obuf, trailer, strlen(trailer)) : 1;
 }
 
 /* dump key mpis to stdout */
@@ -844,7 +1075,7 @@ read_signature_mpis(pgpv_sigpkt_t *sigpk
 
 /* add the signature sub packet to the signature packet */
 static int
-add_subpacket(pgpv_sigpkt_t *sigpkt, uint8_t tag, uint8_t *p, uint16_t len)
+add_subpacket(pgpv_t *pgp, pgpv_sigpkt_t *sigpkt, uint8_t tag, uint8_t *p, uint16_t len)
 {
 	pgpv_sigsubpkt_t	subpkt;
 
@@ -853,13 +1084,14 @@ add_subpacket(pgpv_sigpkt_t *sigpkt, uin
 	subpkt.critical = 0;
 	subpkt.tag = tag;
 	subpkt.s.data = p;
-	ARRAY_APPEND(sigpkt->subpkts, subpkt);
+	ARRAY_APPEND(sigpkt->subpackets, ARRAY_COUNT(pgp->subpkts));
+	ARRAY_APPEND(pgp->subpkts, subpkt);
 	return 1;
 }
 
 /* read the subpackets in the signature */
 static int
-read_sig_subpackets(pgpv_sigpkt_t *sigpkt, uint8_t *p, size_t pktlen)
+read_sig_subpackets(pgpv_t *pgp, pgpv_sigpkt_t *sigpkt, uint8_t *p, size_t pktlen)
 {
 	pgpv_sigsubpkt_t	 subpkt;
 	const int		 is_subpkt = 0;
@@ -891,10 +1123,10 @@ read_sig_subpackets(pgpv_sigpkt_t *sigpk
 			sigpkt->sig.keyexpiry = (int64_t)get_32(p);
 			break;
 		case SUBPKT_ISSUER:
-			sigpkt->sig.signer = p;
+			memcpy(sigpkt->sig.signer, p, sizeof(sigpkt->sig.signer));
 			break;
 		case SUBPKT_SIGNER_ID:
-			sigpkt->sig.signer = p;
+			memcpy(sigpkt->sig.signer, p, sizeof(sigpkt->sig.signer));
 			break;
 		case SUBPKT_TRUST_SIG:
 			sigpkt->sig.trustsig = *p;
@@ -950,7 +1182,8 @@ read_sig_subpackets(pgpv_sigpkt_t *sigpk
 		}
 		subpkt.s.data = p;
 		p += subpkt.s.size - 1;
-		ARRAY_APPEND(sigpkt->subpkts, subpkt);
+		ARRAY_APPEND(sigpkt->subpackets, ARRAY_COUNT(pgp->subpkts));
+		ARRAY_APPEND(pgp->subpkts, subpkt);
 	}
 	return 1;
 }
@@ -974,11 +1207,11 @@ read_sigpkt(pgpv_t *pgp, uint8_t mement,
 		sigpkt->sig.hashlen = lenlen;
 		/* put birthtime into a subpacket */
 		sigpkt->sig.type = *p++;
-		add_subpacket(sigpkt, SUBPKT_SIG_BIRTH, p, sizeof(uint32_t));
+		add_subpacket(pgp, sigpkt, SUBPKT_SIG_BIRTH, p, sizeof(uint32_t));
 		sigpkt->sig.birth = (int64_t)get_32(p);
 		p += sizeof(uint32_t);
-		sigpkt->sig.signer = p;
-		add_subpacket(sigpkt, SUBPKT_SIGNER_ID, p, PGPV_KEYID_LEN);
+		memcpy(sigpkt->sig.signer, p, sizeof(sigpkt->sig.signer));
+		add_subpacket(pgp, sigpkt, SUBPKT_SIGNER_ID, p, PGPV_KEYID_LEN);
 		p += PGPV_KEYID_LEN;
 		sigpkt->sig.keyalg = *p++;
 		sigpkt->sig.hashalg = *p++;
@@ -994,12 +1227,14 @@ read_sigpkt(pgpv_t *pgp, uint8_t mement,
 		sigpkt->sig.hashalg = *p++;
 		sigpkt->subslen = get_16(p);
 		p += sizeof(sigpkt->subslen);
-		if (!read_sig_subpackets(sigpkt, p, pktlen)) {
+		if (!read_sig_subpackets(pgp, sigpkt, p, pktlen)) {
 			printf("read_sigpkt: can't read sig subpackets, v4\n");
 			return 0;
 		}
-		if (!sigpkt->sig.signer) {
-			sigpkt->sig.signer = get_ref(&sigpkt->sig.hashstart) + 16;
+		if (sigpkt->sig.signer[0] == 0x0) {
+			memcpy(sigpkt->sig.signer,
+				get_ref(&sigpkt->sig.hashstart) + 16,
+				sizeof(sigpkt->sig.signer));
 		}
 		p += sigpkt->subslen;
 		sigpkt->sig.hashlen = (unsigned)(p - base);
@@ -1223,8 +1458,9 @@ read_litdata(pgpv_t *pgp, pgpv_litdata_t
 		printf("weird litdata format %u\n", litdata->format);
 		break;
 	}
-	litdata->namelen = p[cc++];
-	litdata->filename = &p[cc];
+	litdata->filename.size = litdata->namelen = p[cc++];
+	litdata->filename.data = &p[cc];
+	litdata->filename.allocated = 0;
 	cc += litdata->namelen;
 	litdata->secs = get_32(&p[cc]);
 	cc += 4;
@@ -1296,6 +1532,7 @@ read_pkt(pgpv_t *pgp, pgpv_mem_t *mem)
 	case USERID_PKT:
 		pkt.u.userid.size = pkt.s.size;
 		pkt.u.userid.data = pkt.s.data;
+		pkt.u.userid.allocated = 0;
 		break;
 	case COMPRESSED_DATA_PKT:
 		read_compressed(pgp, &pkt.u.compressed, pkt.s.data, pkt.s.size);
@@ -1379,13 +1616,15 @@ recog_userid(pgpv_t *pgp, pgpv_signed_us
 	pkt = &ARRAY_ELEMENT(pgp->pkts, pgp->pkt);
 	userid->userid.size = pkt->s.size;
 	userid->userid.data = pkt->s.data;
+	userid->userid.allocated = 0;
 	pgp->pkt += 1;
 	while (pkt_is(pgp, SIGNATURE_PKT)) {
 		if (!recog_signature(pgp, &signature)) {
 			printf("recog_userid: can't recognise signature/trust\n");
 			return 0;
 		}
-		ARRAY_APPEND(userid->sigs, signature);
+		ARRAY_APPEND(userid->signatures, ARRAY_COUNT(pgp->signatures));
+		ARRAY_APPEND(pgp->signatures, signature);
 		if (signature.primary_userid) {
 			userid->primary_userid = signature.primary_userid;
 		}
@@ -1414,7 +1653,8 @@ recog_userattr(pgpv_t *pgp, pgpv_signed_
 			printf("recog_userattr: can't recognise signature/trust\n");
 			return 0;
 		}
-		ARRAY_APPEND(userattr->sigs, signature);
+		ARRAY_APPEND(userattr->signatures, ARRAY_COUNT(pgp->signatures));
+		ARRAY_APPEND(pgp->signatures, signature);
 		if (signature.revoked) {
 			userattr->revoked = signature.revoked;
 		}
@@ -1448,7 +1688,8 @@ recog_subkey(pgpv_t *pgp, pgpv_signed_su
 			printf("recog_subkey: bad signature/trust at %zu\n", pgp->pkt);
 			return 0;
 		}
-		ARRAY_APPEND(subkey->sigs, signature);
+		ARRAY_APPEND(subkey->signatures, ARRAY_COUNT(pgp->signatures));
+		ARRAY_APPEND(pgp->signatures, signature);
 		if (signature.keyexpiry) {
 			/* XXX - check it's a good key expiry */
 			subkey->subkey.expiry = signature.keyexpiry;
@@ -1503,25 +1744,31 @@ numkeybits(const pgpv_pubkey_t *pubkey)
 }
 
 /* print a public key */
-static bool
+static int
 fmt_pubkey(obuf_t *obuf, pgpv_pubkey_t *pubkey, const char *leader)
 {
-	if (!obuf_printf(obuf, "%s %u/%s ", leader, numkeybits(pubkey), fmtkeyalg(pubkey->keyalg))) {
-		return false;
+	char	newbuf[128];
+	int	cc;
+
+	cc = snprintf(newbuf, sizeof(newbuf), " %u/%s ",
+		numkeybits(pubkey), fmtkeyalg(pubkey->keyalg));
+	if (!obuf_add_mem(obuf, leader, strlen(leader)) ||
+	    !obuf_add_mem(obuf, newbuf, cc)) {
+		return 0;
 	}
 	if (!fmt_binary(obuf, pubkey->keyid, PGPV_KEYID_LEN)) {
-		return false;
+		return 0;
 	}
 	if (!fmt_time(obuf, " ", pubkey->birth, "", 0)) {
-		return false;
+		return 0;
 	}
 	if (pubkey->expiry) {
 		if (!fmt_time(obuf, " [Expiry ", pubkey->birth + pubkey->expiry, "]", 0)) {
-			return false;
+			return 0;
 		}
 	}
-	if (!obuf_printf(obuf, "\n")) {
-		return false;
+	if (!obuf_add_mem(obuf, "\n", 1)) {
+		return 0;
 	}
 	return fmt_fingerprint(obuf, &pubkey->fingerprint, "fingerprint  ");
 }
@@ -1530,60 +1777,68 @@ fmt_pubkey(obuf_t *obuf, pgpv_pubkey_t *
 #define COMPROMISED	(0x02 + 1)
 
 /* format a userid - used to order the userids when formatting */
-static bool
-fmt_userid(obuf_t *obuf, pgpv_primarykey_t *primary, uint8_t u)
+static int
+fmt_userid(obuf_t *obuf, pgpv_t *pgp, pgpv_primarykey_t *primary, uint8_t u)
 {
 	pgpv_signed_userid_t	*userid;
+	const char		*s;
+	uint64_t		 id;
 
-	userid = &ARRAY_ELEMENT(primary->signed_userids, u);
-	return obuf_printf(obuf, "uid           %.*s%s\n",
-			(int)userid->userid.size, userid->userid.data,
-			(userid->revoked == COMPROMISED) ? " [COMPROMISED AND REVOKED]" :
-			(userid->revoked) ? " [REVOKED]" : "");
+	id = ARRAY_ELEMENT(primary->signed_userids, u);
+	userid = &ARRAY_ELEMENT(pgp->signed_userids, id);
+	s = (userid->revoked == COMPROMISED) ? " [COMPROMISED AND REVOKED]\n" :
+		(userid->revoked) ? " [REVOKED]\n" : "\n";
+	return obuf_add_mem(obuf, "uid           ", 14) &&
+		obuf_add_mem(obuf, userid->userid.data, userid->userid.size) &&
+		obuf_add_mem(obuf, s, strlen(s));
 }
 
 /* format a trust sig - used to order the userids when formatting */
-static bool
-fmt_trust(obuf_t *obuf, pgpv_signed_userid_t *userid, uint32_t u)
+static int
+fmt_trust(obuf_t *obuf, pgpv_signature_t *sig)
 {
-	pgpv_signature_t	*sig;
-
-	sig = &ARRAY_ELEMENT(userid->sigs, u);
-	if (!obuf_printf(obuf, "trust          ")) {
-		return false;
-	}
-	if (!fmt_binary(obuf, sig->signer, 8)) {
-		return false;
+	if (!obuf_add_mem(obuf, "trust          ", 15) ||
+	    !fmt_binary(obuf, sig->signer, PGPV_KEYID_LEN)) {
+		return 0;
 	}
-	return obuf_printf(obuf, "\n");
+	return obuf_add_mem(obuf, "\n", 1);
 }
 
 /* print a primary key, per RFC 4880 */
-static bool
-fmt_primary(obuf_t *obuf, pgpv_primarykey_t *primary, unsigned subkey, const char *modifiers)
+static int
+fmt_primary(obuf_t *obuf, pgpv_t *pgp, pgpv_primarykey_t *primary, unsigned subkey, const char *modifiers)
 {
 	pgpv_signed_userid_t	*userid;
+	pgpv_signed_subkey_t	*signed_subkey;
 	pgpv_pubkey_t		*pubkey;
 	unsigned		 i;
 	unsigned		 j;
+	uint64_t		 id;
 
-	pubkey = (subkey == 0) ? &primary->primary : &ARRAY_ELEMENT(primary->signed_subkeys, subkey - 1).subkey;
+	if (subkey == 0) {
+		pubkey = &primary->primary;
+	} else {
+		id = ARRAY_ELEMENT(primary->signed_subkeys, subkey);
+		pubkey = &ARRAY_ELEMENT(pgp->signed_subkeys, id).subkey;
+	}
 	if (!fmt_pubkey(obuf, pubkey, "signature    ")) {
-		return false;
+		return 0;
 	}
-	if (!fmt_userid(obuf, primary, primary->primary_userid)) {
-		return false;
+	if (!fmt_userid(obuf, pgp, primary, primary->primary_userid)) {
+		return 0;
 	}
 	for (i = 0 ; i < ARRAY_COUNT(primary->signed_userids) ; i++) {
 		if (i != primary->primary_userid) {
-			if (!fmt_userid(obuf, primary, i)) {
-				return false;
+			if (!fmt_userid(obuf, pgp, primary, i)) {
+				return 0;
 			}
 			if (strcasecmp(modifiers, "trust") == 0) {
-				userid = &ARRAY_ELEMENT(primary->signed_userids, i);
-				for (j = 0 ; j < ARRAY_COUNT(userid->sigs) ; j++) {
-					if (!fmt_trust(obuf, userid, j)) {
-						return false;
+				id = ARRAY_ELEMENT(primary->signed_userids, i);
+				userid = &ARRAY_ELEMENT(pgp->signed_userids, id);
+				for (j = 0 ; j < ARRAY_COUNT(userid->signatures) ; j++) {
+					if (!fmt_trust(obuf, &ARRAY_ELEMENT(pgp->signatures,
+							ARRAY_ELEMENT(userid->signatures, j)))) {
+						return 0;
 					}
 				}
 			}
@@ -1591,12 +1846,14 @@ fmt_primary(obuf_t *obuf, pgpv_primaryke
 	}
 	if (strcasecmp(modifiers, "subkeys") == 0) {
 		for (i = 0 ; i < ARRAY_COUNT(primary->signed_subkeys) ; i++) {
-			if (!fmt_pubkey(obuf, &ARRAY_ELEMENT(primary->signed_subkeys, i).subkey, "encryption")) {
-				return false;
+			id = ARRAY_ELEMENT(primary->signed_subkeys, i);
+			signed_subkey = &ARRAY_ELEMENT(pgp->signed_subkeys, id);
+			if (!fmt_pubkey(obuf, &signed_subkey->subkey, "encryption")) {
+				return 0;
 			}
 		}
 	}
-	return obuf_printf(obuf, "\n");
+	return obuf_add_mem(obuf, "\n", 1);
 }
 
 
@@ -1675,8 +1932,8 @@ lowlevel_rsa_public_check(const uint8_t 
 		printf("rsa r padding check failed\n");
 	}
 err:
-	PGPV_BN_free(encbn);
-	PGPV_BN_free(decbn);
+	PGPV_BN_clear_free(encbn);
+	PGPV_BN_clear_free(decbn);
 	if (decbuf != NULL) {
 		(void) memset(decbuf, 0x0, nbytes);
 		free(decbuf);
@@ -1699,8 +1956,8 @@ rsa_public_decrypt(int enclen, const uns
 	pub.n = PGPV_BN_dup(rsa->n);
 	pub.e = PGPV_BN_dup(rsa->e);
 	ret = lowlevel_rsa_public_check(enc, enclen, dec, &pub);
-	PGPV_BN_free(pub.n);
-	PGPV_BN_free(pub.e);
+	PGPV_BN_clear_free(pub.n);
+	PGPV_BN_clear_free(pub.e);
 	return ret;
 }
 
@@ -1793,12 +2050,12 @@ bignum_is_bad(PGPV_BIGNUM *bn)
 static int
 verify_dsa_sig(uint8_t *calculated, unsigned calclen, pgpv_bignum_t *sig, pgpv_pubkey_t *pubkey)
 {
+	PGPV_BIGNUM	 *M;
+	PGPV_BIGNUM	 *W;
+	PGPV_BIGNUM	 *t1;
 	unsigned	  qbits;
 	uint8_t		  calcnum[128];
 	uint8_t		  signum[128];
-	PGPV_BIGNUM		 *M;
-	PGPV_BIGNUM		 *W;
-	PGPV_BIGNUM		 *t1;
 	int		  ret;
 
 	if (pubkey->bn[DSA_P].bn == NULL ||
@@ -1850,13 +2107,13 @@ verify_dsa_sig(uint8_t *calculated, unsi
 	ret = memcmp(calcnum, signum, BITS_TO_BYTES(qbits)) == 0;
 done:
 	if (M) {
-		PGPV_BN_free(M);
+		PGPV_BN_clear_free(M);
 	}
 	if (W) {
-		PGPV_BN_free(W);
+		PGPV_BN_clear_free(W);
 	}
 	if (t1) {
-		PGPV_BN_free(t1);
+		PGPV_BN_clear_free(t1);
 	}
 	return ret;
 }
@@ -1983,6 +2240,20 @@ find_bin_string(const void *blockarg, si
 	return NULL;
 }
 
+/* store string in allocated memory */
+static uint8_t *
+pgpv_strdup(const char *s)
+{
+	uint8_t	*cp;
+	size_t	 len;
+
+	len = strlen(s);
+	if ((cp = calloc(len + 1, 1)) != NULL) {
+		memcpy(cp, s, len);
+	}
+	return cp;
+}
+
 #define SIGSTART	"-----BEGIN PGP SIGNATURE-----\n"
 #define SIGEND		"-----END PGP SIGNATURE-----\n"
 
@@ -2015,7 +2286,8 @@ read_ascii_armor(pgpv_cursor_t *cursor, 
 	litdata.tag = LITDATA_PKT;
 	litdata.s.data = p;
 	litdata.u.litdata.offset = (size_t)(p - mem->mem);
-	litdata.u.litdata.filename = (uint8_t *)strdup(filename);
+	litdata.u.litdata.filename.data = pgpv_strdup(filename);
+	litdata.u.litdata.filename.allocated = 1;
 	if ((p = find_bin_string(datastart = p, mem->size - litdata.offset, SIGSTART, sizeof(SIGSTART) - 1)) == NULL) {
 		snprintf(cursor->why, sizeof(cursor->why),
 			"malformed armor - no sig - at %zu", (size_t)(p - mem->mem));
@@ -2085,10 +2357,8 @@ setup_data(pgpv_cursor_t *cursor, pgpv_t
 {
 	FILE		*fp;
 	char		 buf[BUFSIZ];
-	int		 rv;
 
 	if (cursor == NULL || pgp == NULL || p == NULL) {
-		snprintf(cursor->why, sizeof(cursor->why), "No input data");
 		return 0;
 	}
 	memset(cursor, 0x0, sizeof(*cursor));
@@ -2106,19 +2376,19 @@ setup_data(pgpv_cursor_t *cursor, pgpv_t
 			return 0;
 		}
 		if (is_armored(buf, sizeof(buf))) {
-			rv = read_ascii_armor_file(cursor, p);
+			read_ascii_armor_file(cursor, p);
 		} else {
-			rv = read_binary_file(pgp, "signature", "%s", (const char *)p);
+			read_binary_file(pgp, "signature", "%s", (const char *)p);
 		}
 		fclose(fp);
 	} else {
 		if (is_armored(p, (size_t)size)) {
-			rv = read_ascii_armor_memory(cursor, p, (size_t)size);
+			read_ascii_armor_memory(cursor, p, (size_t)size);
 		} else {
-			rv = read_binary_memory(pgp, "signature", p, (size_t)size);
+			read_binary_memory(pgp, "signature", p, (size_t)size);
 		}
 	}
-	return rv;
+	return 1;
 }
 
 /* get the data and size from litdata packet */
@@ -2196,7 +2466,8 @@ recog_primary_key(pgpv_t *pgp, pgpv_prim
 			/* XXX - check it's a good key expiry */
 			primary->primary.expiry = signature.keyexpiry;
 		}
-		ARRAY_APPEND(primary->direct_sigs, signature);
+		ARRAY_APPEND(primary->signatures, ARRAY_COUNT(pgp->signatures));
+		ARRAY_APPEND(pgp->signatures, signature);
 	}
 	/* some keys out there have user ids where they shouldn't */
 	do {
@@ -2204,7 +2475,8 @@ recog_primary_key(pgpv_t *pgp, pgpv_prim
 			printf("recog_primary_key: not userid\n");
 			return 0;
 		}
-		ARRAY_APPEND(primary->signed_userids, userid);
+		ARRAY_APPEND(primary->signed_userids, ARRAY_COUNT(pgp->signed_userids));
+		ARRAY_APPEND(pgp->signed_userids, userid);
 		if (userid.primary_userid) {
 			primary->primary_userid = ARRAY_COUNT(primary->signed_userids) - 1;
 		}
@@ -2213,7 +2485,8 @@ recog_primary_key(pgpv_t *pgp, pgpv_prim
 				printf("recog_primary_key: not signed secondary userid\n");
 				return 0;
 			}
-			ARRAY_APPEND(primary->signed_userids, userid);
+			ARRAY_APPEND(primary->signed_userids, ARRAY_COUNT(pgp->signed_userids));
+			ARRAY_APPEND(pgp->signed_userids, userid);
 			if (userid.primary_userid) {
 				primary->primary_userid = ARRAY_COUNT(primary->signed_userids) - 1;
 			}
@@ -2223,7 +2496,8 @@ recog_primary_key(pgpv_t *pgp, pgpv_prim
 				printf("recog_primary_key: not signed user attribute\n");
 				return 0;
 			}
-			ARRAY_APPEND(primary->signed_userattrs, userattr);
+			ARRAY_APPEND(primary->signed_userattrs, ARRAY_COUNT(pgp->signed_userattrs));
+			ARRAY_APPEND(pgp->signed_userattrs, userattr);
 		}
 		while (pkt_is(pgp, PUB_SUBKEY_PKT)) {
 			if (!recog_subkey(pgp, &subkey)) {
@@ -2231,7 +2505,8 @@ recog_primary_key(pgpv_t *pgp, pgpv_prim
 				return 0;
 			}
 			calc_keyid(&subkey.subkey, "sha1");
-			ARRAY_APPEND(primary->signed_subkeys, subkey);
+			ARRAY_APPEND(primary->signed_subkeys, ARRAY_COUNT(pgp->signed_subkeys));
+			ARRAY_APPEND(pgp->signed_subkeys, subkey);
 		}
 	} while (pgp->pkt < ARRAY_COUNT(pgp->pkts) && pkt_is(pgp, USERID_PKT));
 	primary->fmtsize = estimate_primarykey_size(primary);
@@ -2351,6 +2626,7 @@ read_ssh_file(pgpv_t *pgp, pgpv_primaryk
 	char			*space;
 	char		 	*buf;
 	char		 	*bin;
+	char			 newbuf[2048];
 	char			 f[1024];
 	int			 ok;
 	int			 cc;
@@ -2466,13 +2742,18 @@ read_ssh_file(pgpv_t *pgp, pgpv_primaryk
 				space + 1);
 		}
 		calc_keyid(pubkey, "sha1");
-		userid.userid.size = asprintf((char **)(void *)&userid.userid.data,
-						"%s (%s) %s",
-						hostname,
-						f,
-						owner);
-		ARRAY_APPEND(primary->signed_userids, userid);
-		primary->fmtsize = estimate_primarykey_size(primary) + 1024;
+		cc = snprintf(newbuf, sizeof(newbuf), "%s (%s) %s",
+			hostname, f, owner);
+		userid.userid.size = cc;
+		userid.userid.allocated = 1;
+		if ((userid.userid.data = calloc(1, cc + 1)) == NULL) {
+			ok = 0;
+		} else {
+			memcpy(userid.userid.data, newbuf, cc);
+			ARRAY_APPEND(primary->signed_userids, ARRAY_COUNT(pgp->signed_userids));
+			ARRAY_APPEND(pgp->signed_userids, userid);
+			primary->fmtsize = estimate_primarykey_size(primary) + 1024;
+		}
 	}
 	(void) free(bin);
 	(void) free(buf);
@@ -2533,7 +2814,8 @@ fixup_detached(pgpv_cursor_t *cursor, co
 	litdata.s.data = mem->mem;
 	litdata.u.litdata.format = LITDATA_BINARY;
 	litdata.u.litdata.offset = 0;
-	litdata.u.litdata.filename = (uint8_t *)strdup(original);
+	litdata.u.litdata.filename.data = pgpv_strdup(original);
+	litdata.u.litdata.filename.allocated = 1;
 	litdata.u.litdata.mem = ARRAY_COUNT(cursor->pgp->areas) - 1;
 	litdata.u.litdata.len = litdata.s.size = mem->size;
 	ARRAY_APPEND(cursor->pgp->pkts, litdata);
@@ -2592,63 +2874,6 @@ match_sig(pgpv_cursor_t *cursor, pgpv_si
 	return 1;
 }
 
-/* check return value from getenv */
-static const char *
-nonnull_getenv(const char *key)
-{
-	char	*value;
-
-	return ((value = getenv(key)) == NULL) ? "" : value;
-}
-
-/************************************************************************/
-/* start of exported functions */
-/************************************************************************/
-
-/* close all stuff */
-int
-pgpv_close(pgpv_t *pgp)
-{
-	unsigned	i;
-
-	if (pgp == NULL) {
-		return 0;
-	}
-	for (i = 0 ; i < ARRAY_COUNT(pgp->areas) ; i++) {
-		if (ARRAY_ELEMENT(pgp->areas, i).size > 0) {
-			closemem(&ARRAY_ELEMENT(pgp->areas, i));
-		}
-	}
-	return 1;
-}
-
-#define NO_SUBKEYS	0
-
-/* return the formatted entry for the primary key desired */
-size_t
-pgpv_get_entry(pgpv_t *pgp, unsigned ent, char **s, const char *modifiers)
-{
-	unsigned	subkey;
-	unsigned	prim;
-	obuf_t		obuf;
-
-	prim = ((ent >> 8) & 0xffffff);
-	subkey = (ent & 0xff);
-	if (s == NULL || pgp == NULL || prim >= ARRAY_COUNT(pgp->primaries)) {
-		return 0;
-	}
-	*s = NULL;
-	if (modifiers == NULL || (strcasecmp(modifiers, "trust") != 0 && strcasecmp(modifiers, "subkeys") != 0)) {
-		modifiers = "no-subkeys";
-	}
-	memset(&obuf, 0x0, sizeof(obuf));
-	if (!fmt_primary(&obuf, &ARRAY_ELEMENT(pgp->primaries, prim), subkey, modifiers)) {
-		return 0;
-	}
-	*s = (char *)obuf.v;
-	return obuf.c;
-}
-
 /* fixup key id, with birth, keyalg and hashalg value from signature */
 static int
 fixup_ssh_keyid(pgpv_t *pgp, pgpv_signature_t *signature, const char *hashtype)
@@ -2672,6 +2897,7 @@ find_keyid(pgpv_t *pgp, const char *strk
 	pgpv_primarykey_t	*prim;
 	unsigned		 i;
 	unsigned		 j;
+	uint64_t		 n;
 	uint8_t			 binkeyid[PGPV_KEYID_LEN];
 	size_t			 off;
 	size_t			 cmp;
@@ -2694,7 +2920,8 @@ find_keyid(pgpv_t *pgp, const char *strk
 			return i;
 		}
 		for (j = 0 ; j < ARRAY_COUNT(prim->signed_subkeys) ; j++) {
-			subkey = &ARRAY_ELEMENT(prim->signed_subkeys, j);
+			n = ARRAY_ELEMENT(prim->signed_subkeys, j);
+			subkey = &ARRAY_ELEMENT(pgp->signed_subkeys, n);
 			if (memcmp(&subkey->subkey.keyid[off], &binkeyid[off], cmp) == 0) {
 				*sub = j + 1;
 				return i;
@@ -2707,10 +2934,11 @@ find_keyid(pgpv_t *pgp, const char *strk
 
 /* match the signature with the id indexed by 'primary' */
 static int
-match_sig_id(pgpv_cursor_t *cursor, pgpv_signature_t *signature, pgpv_litdata_t *litdata, unsigned primary, unsigned sub)
+match_sig_id(pgpv_cursor_t *cursor, pgpv_t *pgp, pgpv_signature_t *signature, pgpv_litdata_t *litdata, unsigned primary, unsigned sub)
 {
 	pgpv_primarykey_t	*prim;
 	pgpv_pubkey_t		*pubkey;
+	uint64_t		 n;
 	uint8_t			*data;
 	size_t			 insize;
 
@@ -2722,7 +2950,8 @@ match_sig_id(pgpv_cursor_t *cursor, pgpv
 		return match_sig(cursor, signature, pubkey, data, insize);
 	}
 	prim = &ARRAY_ELEMENT(cursor->pgp->primaries, primary);
-	pubkey = &ARRAY_ELEMENT(prim->signed_subkeys, sub - 1).subkey;
+	n = ARRAY_ELEMENT(prim->signed_subkeys, sub - 1);
+	pubkey = &ARRAY_ELEMENT(pgp->signed_subkeys, n).subkey;
 	return match_sig(cursor, signature, pubkey, data, insize);
 }
 
@@ -2756,6 +2985,153 @@ get_packet_type(uint8_t tag)
 	}
 }
 
+/* check return value from getenv */
+static const char *
+nonnull_getenv(const char *key)
+{
+	char	*value;
+
+	return ((value = getenv(key)) == NULL) ? "" : value;
+}
+
+/* free an array of bignums */
+static void
+free_bn_array(pgpv_bignum_t *v, unsigned n)
+{
+	unsigned	i;
+
+	for (i = 0 ; i < n ; i++) {
+		PGPV_BN_clear_free(v[i].bn);
+		v[i].bn = NULL;
+	}
+}
+
+/************************************************************************/
+/* start of exported functions */
+/************************************************************************/
+
+/* close all stuff */
+int
+pgpv_close(pgpv_t *pgp)
+{
+	pgpv_primarykey_t	*primary;
+	pgpv_pkt_t		*pkt;
+	uint64_t		 n;
+	unsigned		 i;
+	unsigned		 j;
+
+	if (pgp == NULL) {
+		return 0;
+	}
+	for (i = 0 ; i < ARRAY_COUNT(pgp->areas) ; i++) {
+		if (ARRAY_ELEMENT(pgp->areas, i).size > 0) {
+			closemem(&ARRAY_ELEMENT(pgp->areas, i));
+		}
+	}
+        ARRAY_FREE(pgp->areas);
+        for (i = 0 ; i < ARRAY_COUNT(pgp->pkts) ; i++) {
+                pkt = &ARRAY_ELEMENT(pgp->pkts, i);
+                switch(pkt->tag) {
+                case SIGNATURE_PKT:
+                        ARRAY_FREE(pkt->u.sigpkt.subpackets);
+                        break;
+                case LITDATA_PKT:
+			if (pkt->u.litdata.filename.allocated) {
+				free(pkt->u.litdata.filename.data);
+			}
+                        break;
+		case PUBKEY_PKT:
+			free_bn_array(pkt->u.pubkey.bn, PGPV_MAX_PUBKEY_BN);
+			break;
+                case USERID_PKT:
+			if (pkt->u.userid.allocated) {
+				free(pkt->u.userid.data);
+			}
+                        break;
+                case USER_ATTRIBUTE_PKT:
+                        ARRAY_FREE(pkt->u.userattr.subattrs);
+                        break;
+                }
+        }
+        ARRAY_FREE(pgp->pkts);
+	for (i = 0 ; i < ARRAY_COUNT(pgp->primaries) ; i++) {
+		primary = &ARRAY_ELEMENT(pgp->primaries, i);
+		free_bn_array(primary->primary.bn, PGPV_MAX_PUBKEY_BN);
+		ARRAY_FREE(primary->signatures);
+		for (j = 0 ; j < ARRAY_COUNT(primary->signed_userids) ; j++) {
+			n = ARRAY_ELEMENT(primary->signed_userids, j);
+			ARRAY_FREE(ARRAY_ELEMENT(pgp->signed_userids, n).signatures);
+		}
+		ARRAY_FREE(primary->signed_userids);
+		ARRAY_FREE(primary->signed_userattrs);
+		ARRAY_FREE(primary->signed_subkeys);
+	}
+	for (i = 0 ; i < ARRAY_COUNT(pgp->signatures) ; i++) {
+		free_bn_array(ARRAY_ELEMENT(pgp->signatures, i).bn, PGPV_MAX_SIG_BN);
+	}
+	for (i = 0 ; i < ARRAY_COUNT(pgp->signed_subkeys) ; i++) {
+		free_bn_array(ARRAY_ELEMENT(pgp->signed_subkeys, i).subkey.bn, PGPV_MAX_SIG_BN);
+	}
+	ARRAY_FREE(pgp->primaries);
+	ARRAY_FREE(pgp->datastarts);
+	ARRAY_FREE(pgp->signatures);
+	ARRAY_FREE(pgp->signed_userids);
+	ARRAY_FREE(pgp->signed_userattrs);
+	ARRAY_FREE(pgp->signed_subkeys);
+	ARRAY_FREE(pgp->subpkts);
+	return 1;
+}
+
+/* free resources attached to cursor */
+int
+pgpv_cursor_close(pgpv_cursor_t *cursor)
+{
+	if (cursor) {
+		ARRAY_FREE(cursor->datacookies);
+		ARRAY_FREE(cursor->found);
+	}
+	return 0;
+}
+
+/* return the formatted entry for the primary key desired */
+size_t
+pgpv_get_entry(pgpv_t *pgp, unsigned ent, char **s, const char *modifiers)
+{
+	unsigned	subkey;
+	unsigned	prim;
+	obuf_t		obuf;
+
+	prim = ((ent >> 8) & 0xffffff);
+	subkey = (ent & 0xff);
+	if (s == NULL || pgp == NULL || prim >= ARRAY_COUNT(pgp->primaries)) {
+		return 0;
+	}
+	*s = NULL;
+	if (modifiers == NULL || (strcasecmp(modifiers, "trust") != 0 && strcasecmp(modifiers, "subkeys") != 0)) {
+		modifiers = "no-subkeys";
+	}
+	memset(&obuf, 0x0, sizeof(obuf));
+	if (!fmt_primary(&obuf, pgp, &ARRAY_ELEMENT(pgp->primaries, prim), subkey, modifiers)) {
+		return 0;
+	}
+	*s = (char *)obuf.v;
+	return obuf.c;
+}
+
+/* make a new pgpv struct */
+pgpv_t *
+pgpv_new(void)
+{
+	return calloc(1, sizeof(pgpv_t));
+}
+
+/* make a new pgpv_cursor struct */
+pgpv_cursor_t *
+pgpv_new_cursor(void)
+{
+	return calloc(1, sizeof(pgpv_cursor_t));
+}
+
 /* get an element from the found array */
 int
 pgpv_get_cursor_element(pgpv_cursor_t *cursor, size_t element)
@@ -2782,6 +3158,7 @@ pgpv_verify(pgpv_cursor_t *cursor, pgpv_
 		return 0;
 	}
 	if (!setup_data(cursor, pgp, p, size)) {
+		snprintf(cursor->why, sizeof(cursor->why), "No input data");
 		return 0;
 	}
 	if (ARRAY_COUNT(cursor->pgp->pkts) == ARRAY_LAST(cursor->pgp->datastarts) + 1) {
@@ -2844,7 +3221,7 @@ pgpv_verify(pgpv_cursor_t *cursor, pgpv_
 			(int)obuf.c, (char *)obuf.v);
 		return 0;
 	}
-	if (!match_sig_id(cursor, signature, litdata, (unsigned)j, sub)) {
+	if (!match_sig_id(cursor, pgp, signature, litdata, (unsigned)j, sub)) {
 		snprintf(cursor->why, sizeof(cursor->why),
 			"Signature does not match %.*s",
 			(int)obuf.c, (char *)obuf.v);
@@ -2959,3 +3336,27 @@ pgpv_dump(pgpv_t *pgp, char **data)
 	}
 	return cc;
 }
+
+/* return cursor field as a number */
+int64_t
+pgpv_get_cursor_num(pgpv_cursor_t *cursor, const char *field)
+{
+	if (cursor && field) {
+		if (strcmp(field, "sigtime") == 0) {
+			return cursor->sigtime;
+		}
+	}
+	return 0;
+}
+
+/* return cursor field as a string */
+char *
+pgpv_get_cursor_str(pgpv_cursor_t *cursor, const char *field)
+{
+	if (cursor && field) {
+		if (strcmp(field, "why") == 0) {
+			return cursor->why;
+		}
+	}
+	return 0;
+}

Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/main.c
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/main.c:1.7 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/main.c:1.8
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/main.c:1.7	Wed Jun 15 20:34:28 2016
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/main.c	Mon Apr 17 19:50:28 2017
@@ -89,41 +89,46 @@ getstdin(ssize_t *cc, size_t *size)
 static int
 verify_data(pgpv_t *pgp, const char *cmd, const char *inname, char *in, ssize_t cc)
 {
-	pgpv_cursor_t	 cursor;
+	pgpv_cursor_t	*cursor;
 	const char	*modifiers;
 	size_t		 size;
 	size_t		 cookie;
 	char		*data;
 	int		 el;
+	int		 ok;
 
-	memset(&cursor, 0x0, sizeof(cursor));
+	cursor = pgpv_new_cursor();
+	ok = 0;
 	if (strcasecmp(cmd, "cat") == 0) {
-		if ((cookie = pgpv_verify(&cursor, pgp, in, cc)) != 0) {
-			if ((size = pgpv_get_verified(&cursor, cookie, &data)) > 0) {
+		if ((cookie = pgpv_verify(cursor, pgp, in, cc)) != 0) {
+			if ((size = pgpv_get_verified(cursor, cookie, &data)) > 0) {
 				write(STDOUT_FILENO, data, size);
 			}
-			return 1;
+			ok = 1;
 		}
 	} else if (strcasecmp(cmd, "dump") == 0) {
-		if ((cookie = pgpv_verify(&cursor, pgp, in, cc)) != 0) {
+		if ((cookie = pgpv_verify(cursor, pgp, in, cc)) != 0) {
 			size = pgpv_dump(pgp, &data);
 			write(STDOUT_FILENO, data, size);
-			return 1;
+			ok = 1;
 		}
 	} else if (strcasecmp(cmd, "verify") == 0 || strcasecmp(cmd, "trust") == 0) {
 		modifiers = (strcasecmp(cmd, "trust") == 0) ? "trust" : NULL;
-		if (pgpv_verify(&cursor, pgp, in, cc)) {
+		if (pgpv_verify(cursor, pgp, in, cc)) {
 			printf("Good signature for %s made ", inname);
-			ptime(cursor.sigtime);
-			el = pgpv_get_cursor_element(&cursor, 0);
+			ptime(pgpv_get_cursor_num(cursor, "sigtime"));
+			el = pgpv_get_cursor_element(cursor, 0);
 			pentry(pgp, el, modifiers);
-			return 1;
+			ok = 1;
+		} else {
+			fprintf(stderr, "Signature did not match contents -- %s\n",
+				pgpv_get_cursor_str(cursor, "why"));
 		}
-		fprintf(stderr, "Signature did not match contents -- %s\n", cursor.why);
 	} else {
 		fprintf(stderr, "unrecognised command \"%s\"\n", cmd);
 	}
-	return 0;
+	pgpv_cursor_close(cursor);
+	return ok;
 }
 
 int
@@ -133,13 +138,13 @@ main(int argc, char **argv)
 	const char	*cmd;
 	ssize_t		 cc;
 	size_t		 size;
-	pgpv_t		 pgp;
+	pgpv_t		*pgp;
 	char		*in;
 	int		 ssh;
 	int		 ok;
 	int		 i;
 
-	memset(&pgp, 0x0, sizeof(pgp));
+	pgp = pgpv_new();
 	keyring = NULL;
 	ssh = 0;
 	ok = 1;
@@ -164,24 +169,24 @@ main(int argc, char **argv)
 		}
 	}
 	if (ssh) {
-		if (!pgpv_read_ssh_pubkeys(&pgp, keyring, -1)) {
+		if (!pgpv_read_ssh_pubkeys(pgp, keyring, -1)) {
 			fprintf(stderr, "can't read ssh keyring\n");
 			exit(EXIT_FAILURE);
 		}
-	} else if (!pgpv_read_pubring(&pgp, keyring, -1)) {
+	} else if (!pgpv_read_pubring(pgp, keyring, -1)) {
 		fprintf(stderr, "can't read keyring\n");
 		exit(EXIT_FAILURE);
 	}
 	if (optind == argc) {
 		in = getstdin(&cc, &size);
-		ok = verify_data(&pgp, cmd, "[stdin]", in, cc);
+		ok = verify_data(pgp, cmd, "[stdin]", in, cc);
 	} else {
 		for (ok = 1, i = optind ; i < argc ; i++) {
-			if (!verify_data(&pgp, cmd, argv[i], argv[i], -1)) {
+			if (!verify_data(pgp, cmd, argv[i], argv[i], -1)) {
 				ok = 0;
 			}
 		}
 	}
-	pgpv_close(&pgp);
+	pgpv_close(pgp);
 	exit((ok) ? EXIT_SUCCESS : EXIT_FAILURE);
 }

Index: src/crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.h
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.h:1.9 src/crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.h:1.10
--- src/crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.h:1.9	Wed Jun 15 20:34:28 2016
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.h	Mon Apr 17 19:50:28 2017
@@ -23,251 +23,19 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #ifndef NETPGP_VERIFY_H_
-#define NETPGP_VERIFY_H_	20160617
+#define NETPGP_VERIFY_H_	20170201
 
-#define NETPGPVERIFY_VERSION	"netpgpverify portable 20160617"
+#define NETPGPVERIFY_VERSION	"netpgpverify portable 20170201"
 
 #include <sys/types.h>
 
 #include <inttypes.h>
 
-#ifndef PGPV_ARRAY
-/* creates 2 unsigned vars called "name"c and "name"size in current scope */
-/* also creates an array called "name"s in current scope */
-#define PGPV_ARRAY(type, name)						\
-	unsigned name##c; unsigned name##vsize; type *name##s
-#endif
+struct pgpv_t;
+typedef struct pgpv_t	pgpv_t;
 
-/* 64bit key ids */
-#define PGPV_KEYID_LEN		8
-#define PGPV_STR_KEYID_LEN	(PGPV_KEYID_LEN + PGPV_KEYID_LEN + 1)
-
-/* bignum structure */
-typedef struct pgpv_bignum_t {
-	void			*bn;	/* hide the implementation details */
-	uint16_t		 bits;	/* cached number of bits */
-} pgpv_bignum_t;
-
-/* right now, our max binary digest length is 20 bytes */
-#define PGPV_MAX_HASH_LEN	64
-
-/* fingerprint */
-typedef struct pgpv_fingerprint_t {
-	uint8_t			hashalg;	/* algorithm for digest */
-	uint8_t			v[PGPV_MAX_HASH_LEN];	/* the digest */
-	uint32_t		len;		/* its length */
-} pgpv_fingerprint_t;
-
-/* specify size for array of bignums */
-#define PGPV_MAX_PUBKEY_BN	4
-
-/* public key */
-typedef struct pgpv_pubkey_t {
-	pgpv_fingerprint_t	 fingerprint;	/* key fingerprint i.e. digest */
-	uint8_t			 keyid[PGPV_KEYID_LEN];	/* last 8 bytes of v4 keys */
-	int64_t		 	 birth;		/* creation time */
-	int64_t			 expiry;	/* expiry time */
-	pgpv_bignum_t		 bn[PGPV_MAX_PUBKEY_BN];	/* bignums */
-	uint8_t			 keyalg;	/* key algorithm */
-	uint8_t			 hashalg;	/* hash algorithm */
-	uint8_t			 version;	/* key version */
-} pgpv_pubkey_t;
-
-#define PGPV_MAX_SESSKEY_BN	2
-
-/* a (size, byte array) string */
-typedef struct pgpv_string_t {
-	size_t			 size;
-	uint8_t			*data;
-} pgpv_string_t;
-
-typedef struct pgpv_ref_t {
-	void			*vp;
-	size_t			 offset;
-	unsigned		 mem;
-} pgpv_ref_t;
-
-#define PGPV_MAX_SECKEY_BN	4
-
-typedef struct pgpv_compress_t {
-	pgpv_string_t		 s;
-	uint8_t			 compalg;
-} pgpv_compress_t;
-
-/* a packet dealing with trust */
-typedef struct pgpv_trust_t {
-	uint8_t			level;
-	uint8_t			amount;
-} pgpv_trust_t;
-
-/* a signature sub packet */
-typedef struct pgpv_sigsubpkt_t {
-	pgpv_string_t		 s;
-	uint8_t			 tag;
-	uint8_t			 critical;
-} pgpv_sigsubpkt_t;
-
-#define PGPV_MAX_SIG_BN		2
-
-typedef struct pgpv_signature_t {
-	uint8_t			*signer;		/* key id of signer */
-	pgpv_ref_t		 hashstart;
-	uint8_t			*hash2;
-	uint8_t			*mpi;
-	int64_t			 birth;
-	int64_t			 keyexpiry;
-	int64_t			 expiry;
-	uint32_t		 hashlen;
-	uint8_t			 version;
-	uint8_t			 type;
-	uint8_t			 keyalg;
-	uint8_t			 hashalg;
-	uint8_t			 trustlevel;
-	uint8_t			 trustamount;
-	pgpv_bignum_t		 bn[PGPV_MAX_SIG_BN];
-	char			*regexp;
-	char			*pref_key_server;
-	char			*policy;
-	char			*features;
-	char			*why_revoked;
-	uint8_t			*revoke_fingerprint;
-	uint8_t			 revoke_alg;
-	uint8_t			 revoke_sensitive;
-	uint8_t			 trustsig;
-	uint8_t			 revocable;
-	uint8_t			 pref_symm_alg;
-	uint8_t			 pref_hash_alg;
-	uint8_t			 pref_compress_alg;
-	uint8_t			 key_server_modify;
-	uint8_t			 notation;
-	uint8_t			 type_key;
-	uint8_t			 primary_userid;
-	uint8_t			 revoked;	/* subtract 1 to get real reason, 0 == not revoked */
-} pgpv_signature_t;
-
-/* a signature packet */
-typedef struct pgpv_sigpkt_t {
-	pgpv_signature_t	 sig;
-	uint16_t		 subslen;
-	uint16_t		 unhashlen;
-	PGPV_ARRAY(pgpv_sigsubpkt_t, subpkts);
-} pgpv_sigpkt_t;
-
-/* a one-pass signature packet */
-typedef struct pgpv_onepass_t {
-	uint8_t			 keyid[PGPV_KEYID_LEN];
-	uint8_t			 version;
-	uint8_t			 type;
-	uint8_t			 hashalg;
-	uint8_t			 keyalg;
-	uint8_t			 nested;
-} pgpv_onepass_t;
-
-/* a literal data packet */
-typedef struct pgpv_litdata_t {
-	uint8_t			*filename;
-	pgpv_string_t		 s;
-	uint32_t		 secs;
-	uint8_t			 namelen;
-	char			 format;
-	unsigned		 mem;
-	size_t			 offset;
-	size_t			 len;
-} pgpv_litdata_t;
-
-/* user attributes - images */
-typedef struct pgpv_userattr_t {
-	size_t 			 len;
-	PGPV_ARRAY(pgpv_string_t, subattrs);
-} pgpv_userattr_t;
-
-/* a general PGP packet */
-typedef struct pgpv_pkt_t {
-	uint8_t			 tag;
-	uint8_t			 newfmt;
-	uint8_t			 allocated;
-	uint8_t			 mement;
-	size_t			 offset;
-	pgpv_string_t		 s;
-	union {
-		pgpv_sigpkt_t	sigpkt;
-		pgpv_onepass_t	onepass;
-		pgpv_litdata_t	litdata;
-		pgpv_compress_t	compressed;
-		pgpv_trust_t	trust;
-		pgpv_pubkey_t	pubkey;
-		pgpv_string_t	userid;
-		pgpv_userattr_t	userattr;
-	} u;
-} pgpv_pkt_t;
-
-/* a memory structure */
-typedef struct pgpv_mem_t {
-	size_t			 size;
-	size_t			 cc;
-	uint8_t			*mem;
-	FILE			*fp;
-	uint8_t			 dealloc;
-	const char		*allowed;	/* the types of packet that are allowed */
-} pgpv_mem_t;
-
-/* packet parser */
-
-typedef struct pgpv_signed_userid_t {
-	pgpv_string_t	 	 userid;
-	PGPV_ARRAY(pgpv_signature_t, sigs);
-	uint8_t			 primary_userid;
-	uint8_t			 revoked;
-} pgpv_signed_userid_t;
-
-typedef struct pgpv_signed_userattr_t {
-	pgpv_userattr_t	 	 userattr;
-	PGPV_ARRAY(pgpv_signature_t, sigs);
-	uint8_t			 revoked;
-} pgpv_signed_userattr_t;
-
-typedef struct pgpv_signed_subkey_t {
-	pgpv_pubkey_t	 	 subkey;
-	pgpv_signature_t 	 revoc_self_sig;
-	PGPV_ARRAY(pgpv_signature_t, sigs);
-} pgpv_signed_subkey_t;
-
-typedef struct pgpv_primarykey_t {
-	pgpv_pubkey_t 		 primary;
-	pgpv_signature_t 	 revoc_self_sig;
-	PGPV_ARRAY(pgpv_signature_t, direct_sigs);
-	PGPV_ARRAY(pgpv_signed_userid_t, signed_userids);
-	PGPV_ARRAY(pgpv_signed_userattr_t, signed_userattrs);
-	PGPV_ARRAY(pgpv_signed_subkey_t, signed_subkeys);
-	size_t			 fmtsize;
-	uint8_t			 primary_userid;
-} pgpv_primarykey_t;
-
-/* everything stems from this structure */
-typedef struct pgpv_t {
-	PGPV_ARRAY(pgpv_pkt_t, 	 pkts);		/* packet array */
-	PGPV_ARRAY(pgpv_primarykey_t,	 primaries);	/* array of primary keys */
-	PGPV_ARRAY(pgpv_mem_t,	 areas);	/* areas we read packets from */
-	PGPV_ARRAY(size_t,	 datastarts);	/* starts of data packets */
-	size_t		 	 pkt;		/* when parsing, current pkt number */
-	const char		*op;		/* the operation we're doing */
-	unsigned		 ssh;		/* using ssh keys */
-} pgpv_t;
-
-#define PGPV_REASON_LEN		128
-
-/* when searching, we define a cursor, and fill in an array of subscripts */
-typedef struct pgpv_cursor_t {
-	pgpv_t			*pgp;			/* pointer to pgp tree */
-	char			*field;			/* field we're searching on */
-	char			*op;			/* operation we're doing */
-	char			*value;			/* value we're searching for */
-	void			*ptr;			/* for regexps etc */
-	PGPV_ARRAY(uint32_t,	 found);		/* array of matched pimary key subscripts */
-	PGPV_ARRAY(size_t,	 datacookies);		/* cookies to retrieve matched data */
-	int64_t			 sigtime;		/* time of signature */
-	char			 why[PGPV_REASON_LEN];	/* reason for bad signature */
-} pgpv_cursor_t;
+struct pgpv_cursor_t;
+typedef struct pgpv_cursor_t	pgpv_cursor_t;
 
 #ifndef __BEGIN_DECLS
 #  if defined(__cplusplus)
@@ -281,17 +49,24 @@ typedef struct pgpv_cursor_t {
 
 __BEGIN_DECLS
 
+pgpv_t *pgpv_new(void);
+pgpv_cursor_t *pgpv_new_cursor(void);
+
 int pgpv_read_pubring(pgpv_t */*pgp*/, const void */*keyringfile/mem*/, ssize_t /*size*/);
 int pgpv_read_ssh_pubkeys(pgpv_t */*pgp*/, const void */*keyring*/, ssize_t /*size*/);
 
 size_t pgpv_verify(pgpv_cursor_t */*cursor*/, pgpv_t */*pgp*/, const void */*mem/file*/, ssize_t /*size*/);
 size_t pgpv_get_verified(pgpv_cursor_t */*cursor*/, size_t /*cookie*/, char **/*ret*/);
-int pgpv_get_cursor_element(pgpv_cursor_t */*cursor*/, size_t /*element*/);
 size_t pgpv_dump(pgpv_t */*pgp*/, char **/*data*/);
 
 size_t pgpv_get_entry(pgpv_t */*pgp*/, unsigned /*ent*/, char **/*ret*/, const char */*modifiers*/);
 
+int64_t pgpv_get_cursor_num(pgpv_cursor_t */*cursor*/, const char */*field*/);
+char *pgpv_get_cursor_str(pgpv_cursor_t */*cursor*/, const char */*field*/);
+int pgpv_get_cursor_element(pgpv_cursor_t */*cursor*/, size_t /*element*/);
+
 int pgpv_close(pgpv_t */*pgp*/);
+int pgpv_cursor_close(pgpv_cursor_t */*cursor*/);
 
 __END_DECLS
 

Index: src/crypto/external/bsd/netpgp/lib/verify/Makefile
diff -u src/crypto/external/bsd/netpgp/lib/verify/Makefile:1.8 src/crypto/external/bsd/netpgp/lib/verify/Makefile:1.9
--- src/crypto/external/bsd/netpgp/lib/verify/Makefile:1.8	Wed Apr 15 19:13:46 2015
+++ src/crypto/external/bsd/netpgp/lib/verify/Makefile	Mon Apr 17 19:50:28 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.8 2015/04/15 19:13:46 mrg Exp $
+# $NetBSD: Makefile,v 1.9 2017/04/17 19:50:28 agc Exp $
 
 LIB=netpgpverify
 SRCS+=b64.c
@@ -15,7 +15,6 @@ SRCS+=sha1.c
 SRCS+=sha2.c
 SRCS+=md5c.c
 SRCS+=rmd160.c
-SRCS+=tiger.c
 CPPFLAGS+=-I${.CURDIR} -I${EXTDIST}/src/netpgpverify
 MAN=libnetpgpverify.3
 WARNS=5

Reply via email to