Re: CVS commit: src/crypto/external/bsd/netpgp/dist/src/hkpd

2010-03-01 Thread Joerg Sonnenberger
Why do we want to have another ad-hoc HTTP implementation? Wouldn't a
small *CGI script be good enough?

Joerg

On Mon, Mar 01, 2010 at 07:41:57AM +, Alistair G. Crooks wrote:
 Module Name:  src
 Committed By: agc
 Date: Mon Mar  1 07:41:57 UTC 2010
 
 Added Files:
   src/crypto/external/bsd/netpgp/dist/src/hkpd: Makefile hkpd.c hkpd.h
   main.c
 
 Log Message:
 add an embryonic httpd key server (hkpd) to netpgp. this is based on the
 discontinued draft for hkp servers, in lieu of any official rfc.
 
 the post method for adding keys to the server has not been implemented.
 not until i've gone through all of the implications, anyway.
 
 hkp servers serve up pgp public keys over http. the default port is 11371,
 but it can be any port, specifiable at run time. whilst this hkpd will
 return valid html to browsers, it is aimed at the ''machine readable''
 side, using the ''options=mr'' option to the http get string.
 
 this hkpd server will get hooked into the build at a later date.
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r0 -r1.1 src/crypto/external/bsd/netpgp/dist/src/hkpd/Makefile \
 src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.c \
 src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.h \
 src/crypto/external/bsd/netpgp/dist/src/hkpd/main.c
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


Re: CVS commit: src/crypto/external/bsd/netpgp/dist/src/hkpd

2010-03-01 Thread Alistair Crooks
not really, i tried to shoehorn all of this into bozo, and it wasn't
willing to do it, and its cgi subsystem doesn't lend itself to this
kind of thing.  i'm fairly intimate with most of bozo's internals,
too.

the server itself is not that large.  if there's a common server-side
library that can be used, great, show me it, and i'll convert the hkpd
to use it.  libfetch certainly isn't up to the task.

regards,
alistair

On Mon, Mar 01, 2010 at 10:35:20PM +0100, Joerg Sonnenberger wrote:
 Why do we want to have another ad-hoc HTTP implementation? Wouldn't a
 small *CGI script be good enough?
 
 Joerg
 
 On Mon, Mar 01, 2010 at 07:41:57AM +, Alistair G. Crooks wrote:
  Module Name:src
  Committed By:   agc
  Date:   Mon Mar  1 07:41:57 UTC 2010
  
  Added Files:
  src/crypto/external/bsd/netpgp/dist/src/hkpd: Makefile hkpd.c hkpd.h
  main.c
  
  Log Message:
  add an embryonic httpd key server (hkpd) to netpgp. this is based on the
  discontinued draft for hkp servers, in lieu of any official rfc.
  
  the post method for adding keys to the server has not been implemented.
  not until i've gone through all of the implications, anyway.
  
  hkp servers serve up pgp public keys over http. the default port is 11371,
  but it can be any port, specifiable at run time. whilst this hkpd will
  return valid html to browsers, it is aimed at the ''machine readable''
  side, using the ''options=mr'' option to the http get string.
  
  this hkpd server will get hooked into the build at a later date.
  
  
  To generate a diff of this commit:
  cvs rdiff -u -r0 -r1.1 
  src/crypto/external/bsd/netpgp/dist/src/hkpd/Makefile \
  src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.c \
  src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.h \
  src/crypto/external/bsd/netpgp/dist/src/hkpd/main.c
  
  Please note that diffs are not public domain; they are subject to the
  copyright notices on the relevant files.


Re: CVS commit: src/crypto/external/bsd/netpgp/dist/src/hkpd

2010-03-01 Thread Thomas E. Spanjaard
Joerg Sonnenberger wrote:
 Why do we want to have another ad-hoc HTTP implementation? Wouldn't a
 small *CGI script be good enough?

Argument for a separate implementation: it runs as a standalone daemon
on a different port than the default for HTTP, as a decoupled service
from your normal httpd. Argument against: a CGI script would allow you
too hook it into your favourite httpd, which could do all sorts of
advanced stuff to requests before they hit the CGI script, like
aliasing, rewriting, filtering, caching, etc..

Personally, I'd prefer a CGI script; though I do not at present desire
to run a HKP server. I am satisfied with the various SKS servers out there.

Cheers,
-- 
Thomas E. Spanjaard
t...@netphreax.net
t...@deepbone.net



signature.asc
Description: OpenPGP digital signature


CVS commit: src/crypto/external/bsd/netpgp/dist/src/hkpd

2010-02-28 Thread Alistair G. Crooks
Module Name:src
Committed By:   agc
Date:   Mon Mar  1 07:41:57 UTC 2010

Added Files:
src/crypto/external/bsd/netpgp/dist/src/hkpd: Makefile hkpd.c hkpd.h
main.c

Log Message:
add an embryonic httpd key server (hkpd) to netpgp. this is based on the
discontinued draft for hkp servers, in lieu of any official rfc.

the post method for adding keys to the server has not been implemented.
not until i've gone through all of the implications, anyway.

hkp servers serve up pgp public keys over http. the default port is 11371,
but it can be any port, specifiable at run time. whilst this hkpd will
return valid html to browsers, it is aimed at the ''machine readable''
side, using the ''options=mr'' option to the http get string.

this hkpd server will get hooked into the build at a later date.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/crypto/external/bsd/netpgp/dist/src/hkpd/Makefile \
src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.c \
src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.h \
src/crypto/external/bsd/netpgp/dist/src/hkpd/main.c

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

Added files:

Index: src/crypto/external/bsd/netpgp/dist/src/hkpd/Makefile
diff -u /dev/null src/crypto/external/bsd/netpgp/dist/src/hkpd/Makefile:1.1
--- /dev/null	Mon Mar  1 07:41:57 2010
+++ src/crypto/external/bsd/netpgp/dist/src/hkpd/Makefile	Mon Mar  1 07:41:56 2010
@@ -0,0 +1,11 @@
+# $NetBSD: Makefile,v 1.1 2010/03/01 07:41:56 agc Exp $
+
+PROG=hkpd
+SRCS=hkpd.c main.c
+CPPFLAGS+=-g # -DHAVE_CONFIG_H=1
+LDFLAGS+=-g
+LDADD+= -lnetpgp
+MKMAN=no
+WARNS=0 # anything over 0 will fail at the link stage with IDEA errors
+
+.include bsd.prog.mk
Index: src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.c
diff -u /dev/null src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.c:1.1
--- /dev/null	Mon Mar  1 07:41:57 2010
+++ src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.c	Mon Mar  1 07:41:56 2010
@@ -0,0 +1,275 @@
+/*-
+ * Copyright (c) 2009,2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code 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.
+ */
+
+#include sys/types.h
+#include sys/param.h
+#include sys/socket.h
+#include sys/stat.h
+#include sys/param.h
+
+#include netinet/in.h
+
+#include errno.h
+#include netdb.h
+#include netpgp.h
+#include regex.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include unistd.h
+
+#include hkpd.h
+
+/* make the string have %xx - %c */
+static size_t
+frompercent(char *in, size_t insize, char *out, size_t outsize)
+{
+	size_t	 outcc;
+	char	*next;
+	char	*pc;
+
+	outcc = 0;
+	for (pc = in ; (next = strchr(pc, '%')) != NULL ; pc = next + 3) {
+		(void) memcpy(out[outcc], pc, (size_t)(next - pc));
+		outcc += (size_t)(next - pc);
+		out[outcc++] = (char)strtol(next + 1, NULL, 16);
+	}
+	(void) memcpy(out[outcc], pc, insize - (int)(pc - in));
+	outcc += insize - (int)(pc - in);
+	out[outcc] = 0x0;
+	return outcc;
+}
+
+#define HKP_HTTP_LEVEL	HTTP/1.0
+#define HKP_NAME	hkpd
+#define HKP_MIME_GET	application/pgp-keys
+#define HKP_MIME_INDEX	text/plain
+#define HKP_MACHREAD	info:1:1\r\n
+
+#define HKP_SUCCESS	200
+#define HKP_NOT_FOUND	404
+
+/* make into html */
+static int
+htmlify(char *buf, size_t size, const int code, const int get, const char *title, const int mr, const char *body)
+{
+	return snprintf(buf, size,
+		%s %d %s\r\n
+		Server: %s/%d\r\n
+		Content-type: %s\r\n
+		\r\n
+		%s
+		%s,
+		HKP_HTTP_LEVEL, code, (code == HKP_SUCCESS) ? OK : not found,
+		HKP_NAME, 

CVS commit: src/crypto/external/bsd/netpgp/dist/src/hkpd

2010-02-28 Thread Alistair G. Crooks
Module Name:src
Committed By:   agc
Date:   Mon Mar  1 07:41:57 UTC 2010

Added Files:
src/crypto/external/bsd/netpgp/dist/src/hkpd: Makefile hkpd.c hkpd.h
main.c

Log Message:
add an embryonic httpd key server (hkpd) to netpgp. this is based on the
discontinued draft for hkp servers, in lieu of any official rfc.

the post method for adding keys to the server has not been implemented.
not until i've gone through all of the implications, anyway.

hkp servers serve up pgp public keys over http. the default port is 11371,
but it can be any port, specifiable at run time. whilst this hkpd will
return valid html to browsers, it is aimed at the ''machine readable''
side, using the ''options=mr'' option to the http get string.

this hkpd server will get hooked into the build at a later date.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/crypto/external/bsd/netpgp/dist/src/hkpd/Makefile \
src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.c \
src/crypto/external/bsd/netpgp/dist/src/hkpd/hkpd.h \
src/crypto/external/bsd/netpgp/dist/src/hkpd/main.c

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