Module Name:    src
Committed By:   agc
Date:           Thu Sep  2 05:58:01 UTC 2010

Modified Files:
        src/crypto/external/bsd/netpgp/dist/src/hkpd: Makefile
Added Files:
        src/crypto/external/bsd/netpgp/dist/src/hkpclient: hkpc.1 hkpc.c hkpc.h
            main.c
        src/crypto/external/bsd/netpgp/dist/src/hkpd: hkpd.1
        src/crypto/external/bsd/netpgp/hkpc: Makefile
        src/crypto/external/bsd/netpgp/hkpd: Makefile
Removed Files:
        src/crypto/external/bsd/netpgp/dist/src/hkpd: hkpd.8

Log Message:
Update hkpd to return its information in JSON (via libmj).

Add a C HKP client.

Provide reachover Makefiles for each, but do not hook them up to the build
just yet.

The HKP client and server can be embedded in other programs.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 \
    src/crypto/external/bsd/netpgp/dist/src/hkpclient/hkpc.1 \
    src/crypto/external/bsd/netpgp/dist/src/hkpclient/hkpc.c \
    src/crypto/external/bsd/netpgp/dist/src/hkpclient/hkpc.h \
    src/crypto/external/bsd/netpgp/dist/src/hkpclient/main.c
cvs rdiff -u -r1.3 -r1.4 \
    src/crypto/external/bsd/netpgp/dist/src/hkpd/Makefile
cvs rdiff -u -r0 -r1.1 src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.1
cvs rdiff -u -r1.2 -r0 src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.8
cvs rdiff -u -r0 -r1.1 src/crypto/external/bsd/netpgp/hkpc/Makefile
cvs rdiff -u -r0 -r1.1 src/crypto/external/bsd/netpgp/hkpd/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/dist/src/hkpd/Makefile
diff -u src/crypto/external/bsd/netpgp/dist/src/hkpd/Makefile:1.3 src/crypto/external/bsd/netpgp/dist/src/hkpd/Makefile:1.4
--- src/crypto/external/bsd/netpgp/dist/src/hkpd/Makefile:1.3	Wed Sep  1 17:25:57 2010
+++ src/crypto/external/bsd/netpgp/dist/src/hkpd/Makefile	Thu Sep  2 05:58:01 2010
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile,v 1.3 2010/09/01 17:25:57 agc Exp $
+# $NetBSD: Makefile,v 1.4 2010/09/02 05:58:01 agc Exp $
 
 PROG=hkpd
 SRCS=hkpd.c main.c
 CPPFLAGS+=-g # -DHAVE_CONFIG_H=1
 LDFLAGS+=-g
 LDADD+= -lnetpgp
-MAN=hkpd.8
+MAN=hkpd.1
 WARNS=0 # anything over 0 will fail at the link stage with IDEA errors
 
 .include <bsd.prog.mk>

Added files:

Index: src/crypto/external/bsd/netpgp/dist/src/hkpclient/hkpc.1
diff -u /dev/null src/crypto/external/bsd/netpgp/dist/src/hkpclient/hkpc.1:1.1
--- /dev/null	Thu Sep  2 05:58:01 2010
+++ src/crypto/external/bsd/netpgp/dist/src/hkpclient/hkpc.1	Thu Sep  2 05:58:01 2010
@@ -0,0 +1,123 @@
+.\" $NetBSD: hkpc.1,v 1.1 2010/09/02 05:58:01 agc Exp $
+.\"
+.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This manual page is derived from software contributed to
+.\" The NetBSD Foundation by Alistair Crooks (a...@netbsd.org).
+.\"
+.\" 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``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 FOUNDATION OR CONTRIBUTORS
+.\" 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.
+.\"
+.Dd September 1, 2010
+.Dt HKPC 1
+.Os
+.Sh NAME
+.Nm hkpc
+.Nd retrieve public key information via HKP
+.Sh SYNOPSIS
+.Nm
+.Op Fl f address-family
+.Op Fl h hostname
+.Op Fl p port
+.Cm [get|index|vindex]
+userid...
+.Sh DESCRIPTION
+The
+.Nm
+command retrieves public key information from the key server daemon
+using the HKP protocol.
+The
+.Xr hkpd 8
+is normally used to retrieve public key information.
+.Pp
+Three types of information can be retrieved from the server:
+.Bl -tag -width vindex
+.It get
+The public key, base64-encoded, corresponding to the given userid
+is returned.
+The userid can be a numeric value, a unique part of the human
+identifier, or left blank.
+The first matching key will be returned, in a format suitable for
+importing to a keyring via the
+.Xr netpgpkeys 1
+command.
+.It index
+the information returned from this command is the same as
+provided by the
+.Xr netpgpkeys 1
+command, using the
+.Dv --list-keys
+modifier.
+.It vindex
+the information returned from this command is the same as
+provided by the
+.Xr netpgpkeys 1
+command, using the
+.Dv --list-sigs
+modifier.
+.El
+.Pp
+For this utility to provide the correct results, an hkpd
+server must be listening using the correct protocol family,
+on the provided port on the appropriate server.
+The default port for the HKP server is
+.Dv 11371 ,
+whilst the hostname defaults to
+.Dv localhost .
+.Pp
+The
+.Dv netpgp
+suite of libraries and commands provides a copnvenient client
+in
+.Xr hkpd 1 .
+.Pp
+The information is sent to the server in the form of
+an HTTP
+.Dv GET
+command, and is returned as a JSON-encoded
+HKP packet.
+.Xr libmj 3
+is used to decode the JSON in the returned HKP packet.
+.Sh EXIT STATUS
+The
+.Nm
+utility will return 0 for success,
+or 1 for failure.
+Output will be printed on stdout.
+.Sh SEE ALSO
+.Xr hkpd 1 ,
+.Xr netpgpkeys 1 ,
+.Xr ssh 1 ,
+.\" .Xr libbz2 3 ,
+.Xr libmj 3 ,
+.Xr libnetpgp 3
+.Sh STANDARDS
+The
+.Nm
+utility is designed to conform to IETF RFC 4880.
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Nx 6.0 .
+.Sh AUTHORS
+.An Alistair Crooks Aq a...@netbsd.org .
Index: src/crypto/external/bsd/netpgp/dist/src/hkpclient/hkpc.c
diff -u /dev/null src/crypto/external/bsd/netpgp/dist/src/hkpclient/hkpc.c:1.1
--- /dev/null	Thu Sep  2 05:58:01 2010
+++ src/crypto/external/bsd/netpgp/dist/src/hkpclient/hkpc.c	Thu Sep  2 05:58:01 2010
@@ -0,0 +1,135 @@
+/*-
+ * Copyright (c) 2010 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.
+ */
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+
+#include <errno.h>
+#include <inttypes.h>
+#include <netdb.h>
+#include <netpgp.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "hkpc.h"
+
+/* get a socket and connect it to the server */
+int
+hkpc_connect(const char *hostname, const int port, const int fam)
+{
+        struct addrinfo  hints;
+        struct addrinfo *res;
+        char             portstr[32];
+	int		 sock;
+        int              rc = 0;
+
+        (void) memset(&hints, 0, sizeof(hints));
+        hints.ai_family = (fam == 4) ? PF_INET : PF_INET6;
+        hints.ai_socktype = SOCK_STREAM;
+        (void) snprintf(portstr, sizeof(portstr), "%d", port);
+        if ((rc = getaddrinfo(hostname, portstr, &hints, &res)) != 0) {
+                hints.ai_flags = 0;
+                if ((rc = getaddrinfo(hostname, "hkp", &hints, &res)) != 0) {
+                        (void) fprintf(stderr, "getaddrinfo: %s",
+					gai_strerror(rc));
+                        return -1;
+                }
+        }
+	if ((sock = socket((fam == 4) ? AF_INET : AF_INET6, SOCK_STREAM, 0)) < 0) {
+                (void) fprintf(stderr, "socket failed %d\n", errno);
+                freeaddrinfo(res);
+                return -1;
+	}
+        if ((rc = connect(sock, res->ai_addr, res->ai_addrlen)) < 0) {
+                (void) fprintf(stderr, "connect failed %d\n", errno);
+                freeaddrinfo(res);
+                return -1;
+        }
+        freeaddrinfo(res);
+        if (rc < 0) {
+                (void) fprintf(stderr, "bind() to %s:%d failed (rc %d)\n",
+				hostname, port, rc);
+        }
+        return sock;
+}
+
+#define MB(x)	((x) * 1024 * 1024)
+
+/* get required info from the server */
+int
+hkpc_get(char **info, const char *server, const int port, const int family, const char *type, const char *userid)
+{
+	char	buf[MB(1)];
+	int	sock;
+	int	cc;
+	int	rc;
+
+	if ((sock = hkpc_connect(server, port, family)) < 0) {
+		(void) fprintf(stderr, "hkpc_get: can't connect to server '%s'\n", server);
+		return -1;
+	}
+	cc = snprintf(buf, sizeof(buf), "GET /pks/lookup?op=%s&search=%s&options=json", type, userid);
+	if (write(sock, buf, cc) != cc) {
+		(void) fprintf(stderr, "hkpc_get: short write\n");
+		return -1;
+	}
+	for (cc = 0 ; (rc = read(sock, &buf[cc], sizeof(buf) - cc)) > 0 ; cc += rc) {
+	}
+	*info = calloc(1, cc + 1);
+	(void) memcpy(*info, buf, cc);
+	(*info)[cc] = 0x0;
+	(void) close(sock);
+	return cc;
+}
+
+/* jump over http header, then pass the json to the key-formatting function */
+int
+hkpc_print_key(FILE *fp, const char *op, const char *res)
+{
+	static regex_t	text;
+	static int	compiled;
+	regmatch_t	matches[10];
+	int	 	ret;
+
+	if (!compiled) {
+		compiled = 1;
+		(void) regcomp(&text, "\r\n\r\n", REG_EXTENDED);
+	}
+	if (regexec(&text, res, 10, matches, 0) != 0) {
+		return 0;
+	}
+	if (strcmp(op, "index") == 0 || strcmp(op, "vindex") == 0) {
+		ret = netpgp_format_json(fp, &res[(int)matches[0].rm_eo], 1);
+	} else {
+		(void) fprintf(fp, "%s\n", &res[(int)matches[0].rm_eo + 1]);
+		ret = 1;
+	}
+	return ret;
+}
Index: src/crypto/external/bsd/netpgp/dist/src/hkpclient/hkpc.h
diff -u /dev/null src/crypto/external/bsd/netpgp/dist/src/hkpclient/hkpc.h:1.1
--- /dev/null	Thu Sep  2 05:58:01 2010
+++ src/crypto/external/bsd/netpgp/dist/src/hkpclient/hkpc.h	Thu Sep  2 05:58:01 2010
@@ -0,0 +1,34 @@
+/*-
+ * Copyright (c) 2010 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.
+ */
+#ifndef HKPC_H_
+#define HKPC_H_	20100820
+
+#include <stdio.h>
+
+int hkpc_connect(const char *, const int, const int);
+int hkpc_get(char **, const char *, const int, const int, const char *, const char *);
+int hkpc_print_key(FILE *, const char *, const char *);
+
+#endif
Index: src/crypto/external/bsd/netpgp/dist/src/hkpclient/main.c
diff -u /dev/null src/crypto/external/bsd/netpgp/dist/src/hkpclient/main.c:1.1
--- /dev/null	Thu Sep  2 05:58:01 2010
+++ src/crypto/external/bsd/netpgp/dist/src/hkpclient/main.c	Thu Sep  2 05:58:01 2010
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2010 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.
+ */
+#include <sys/types.h>
+
+#include <inttypes.h>
+#include <netpgp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "hkpc.h"
+
+int
+main(int argc, char **argv)
+{
+	char	*res;
+	char	 server[BUFSIZ];
+	int	 family;
+	int	 port;
+	int	 i;
+
+	port = 11371;
+	family = 4;
+	(void) snprintf(server, sizeof(server), "localhost");
+	while ((i = getopt(argc, argv, "f:h:p:")) != -1) {
+		switch(i) {
+		case 'f':
+			family = atoi(optarg);
+			break;
+		case 'h':
+			(void) snprintf(server, sizeof(server), optarg);
+			break;
+		case 'p':
+			port = atoi(optarg);
+			break;
+		default:
+			break;
+		}
+	}
+	for (i = optind + 1 ; i < argc ; i++) {
+		if (hkpc_get(&res, server, port, family, argv[optind], argv[i])) {
+			hkpc_print_key(stdout, argv[optind], res);
+		}
+	}
+	exit(EXIT_SUCCESS);
+}

Index: src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.1
diff -u /dev/null src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.1:1.1
--- /dev/null	Thu Sep  2 05:58:01 2010
+++ src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.1	Thu Sep  2 05:58:01 2010
@@ -0,0 +1,129 @@
+.\" $NetBSD: hkpd.1,v 1.1 2010/09/02 05:58:01 agc Exp $
+.\"
+.\" Copyright (c) 2009,2010 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This manual page is derived from software contributed to
+.\" The NetBSD Foundation by Alistair Crooks (a...@netbsd.org).
+.\"
+.\" 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``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 FOUNDATION OR CONTRIBUTORS
+.\" 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.
+.\"
+.Dd September 1, 2010
+.Dt HKPD 1
+.Os
+.Sh NAME
+.Nm hkpd
+.Nd HTTP key protocol daemon
+.Sh SYNOPSIS
+.Nm
+.Op Fl DV
+.Op Fl f families
+.Op Fl H homedir
+.Op Fl h hostname
+.Op Fl p port
+.Op Fl S keyfilename
+.Op Fl v filename
+.Sh DESCRIPTION
+The
+.Nm
+daemon is used to provide public key information on
+a socket to client programs.
+The client can request the information in two separate ways,
+.Dq human
+and
+.Dq machine readable .
+.Pp
+The following options can be used to modify the behaviour
+of the daemon:
+.Bl -tag -width protocol-families
+.It Fl D
+Do not detach the daemon from the controlling tty, and keep the
+.Nm
+process running in the foreground.
+.It Fl f Ar protocol-families
+allows the address families for sockets to be selected.
+The argument is the string concatenating the families,
+with
+.Dq 4
+representing
+.Dv INET4 ,
+and
+.Dq 6
+representing
+.Dv INET6 .
+The default value for this parameter is
+.Dq 46
+which means that both INET4 and INET6 protocol
+families are used when setting up the sockets.
+.It Fl H Ar homedir
+Use the setting of
+.Dv homedir
+as the directory for the public key keyrings.
+.It Fl h Ar hostname
+Set the hostname (for use in binding sockets).
+.It Fl p Ar port
+Set the port number (for use in binding sockets).
+The default port number is the
+.Dq hkp
+service, defined as port
+.Dv 11371 .
+.It Fl S Ar sshkeyfile
+Serve the ssh public keys found in the key file.
+The default file for the ssh key is
+.Pa $HOME/.ssh/id_rsa.pub .
+.It Fl V
+Display the version number of the daemon and exit.
+.It Fl v Ar filename
+Produce extra debugging output from the internal file named
+.Dv filename .
+.El
+.Pp
+The
+.Nm
+daemon is built on
+.Xr libnetpgp 3
+and returns public key information as held in the
+public keyring of the user running the
+.Nm
+daemon utility by default.
+.Pp
+The information returned to the HKP client is encoded
+in JSON using the
+.Xr libmj 3
+library.
+.Sh EXIT STATUS
+In normal operation, the
+.Nm
+daemon will not return.
+.Sh SEE ALSO
+.Xr hkpc 1 ,
+.Xr netpgpkeys 1 ,
+.Xr ssh 1 ,
+.Xr libmj 3
+.Xr libnetpgp 3
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Nx 6.0 .
+.Sh AUTHORS
+.An Alistair Crooks Aq a...@netbsd.org .

Index: src/crypto/external/bsd/netpgp/hkpc/Makefile
diff -u /dev/null src/crypto/external/bsd/netpgp/hkpc/Makefile:1.1
--- /dev/null	Thu Sep  2 05:58:01 2010
+++ src/crypto/external/bsd/netpgp/hkpc/Makefile	Thu Sep  2 05:58:00 2010
@@ -0,0 +1,25 @@
+# $NetBSD: Makefile,v 1.1 2010/09/02 05:58:00 agc Exp $
+
+.include <bsd.own.mk>
+
+PROG=hkpc
+BINDIR=/usr/bin
+SRCS=hkpc.c main.c
+
+LIBNETPGPDIR!=	cd ${.CURDIR}/../lib && ${PRINTOBJDIR}
+LDADD+=		-L${LIBNETPGPDIR} -lnetpgp
+DPADD+=		${LIBNETPGPDIR}/libnetpgp.a
+
+LIBMJDIR!=	cd ${.CURDIR}/../libmj && ${PRINTOBJDIR}
+LDADD+=		-L${LIBMJDIR} -lmj
+DPADD+=		${LIBMJDIR}/libmj.a
+
+LDADD+=		-lcrypto -lz -lbz2
+DPADD+=		${LIBCRYPTO} ${LIBZ} ${LIBBZ2}
+
+WARNS=0
+MAN=hkpc.1
+
+.PATH: ${.CURDIR}/../dist/src/hkpclient
+
+.include <bsd.prog.mk>

Index: src/crypto/external/bsd/netpgp/hkpd/Makefile
diff -u /dev/null src/crypto/external/bsd/netpgp/hkpd/Makefile:1.1
--- /dev/null	Thu Sep  2 05:58:01 2010
+++ src/crypto/external/bsd/netpgp/hkpd/Makefile	Thu Sep  2 05:58:00 2010
@@ -0,0 +1,33 @@
+# $NetBSD: Makefile,v 1.1 2010/09/02 05:58:00 agc Exp $
+
+.include <bsd.own.mk>
+
+PROG=hkpd
+BINDIR=/usr/sbin
+SRCS=hkpd.c main.c
+
+LIBNETPGPDIR!=	cd ${.CURDIR}/../lib && ${PRINTOBJDIR}
+LDADD+=		-L${LIBNETPGPDIR} -lnetpgp
+DPADD+=		${LIBNETPGPDIR}/libnetpgp.a
+
+LIBMJDIR!=	cd ${.CURDIR}/../libmj && ${PRINTOBJDIR}
+LDADD+=		-L${LIBMJDIR} -lmj
+DPADD+=		${LIBMJDIR}/libmj.a
+
+LDADD+=		-lcrypto -lz -lbz2
+DPADD+=		${LIBCRYPTO} ${LIBZ} ${LIBBZ2}
+
+MAN=hkpd.1
+WARNS=0 # anything over 0 will fail at the link stage with IDEA errors
+
+.PATH: ${.CURDIR}/../dist/src/hkpd
+
+.include <bsd.prog.mk>
+
+t: ${PROG}
+	./${PROG} -D &
+	sleep 1
+	ftp -o- 'http://localhost:11371/pks/lookup?op=index&search=agc&options=json'
+	ftp -o- 'http://localhost:11371/pks/lookup?op=get&search=agc&options=json'
+	ftp -o- 'http://localhost:11371/pks/lookup?op=get&search=agc&options=mr'
+	pkill hkpd

Reply via email to