aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog11
-rw-r--r--g10/Makefile.am4
-rw-r--r--g10/g10.c3
-rw-r--r--g10/hkp.c72
-rw-r--r--g10/hkp.h (renamed from g10/pref.h)26
-rw-r--r--g10/import.c39
-rw-r--r--g10/main.h1
-rw-r--r--g10/mainproc.c5
-rw-r--r--g10/options.h1
-rw-r--r--g10/options.skel8
-rw-r--r--g10/plaintext.c2
-rw-r--r--g10/pref.c81
12 files changed, 137 insertions, 116 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 68255f01b..821e9b305 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,14 @@
+Sat Jan 16 09:27:30 CET 1999 Werner Koch <[email protected]>
+
+ * import.c (import_key_stream): New
+ (import): New, moved most of import_keys here.
+ * g10.c: New option --keyserver
+ * mainproc.c (check_sig_and_print): Hook to import a pubkey.
+
+ * pref.c pref.h : Removed
+
+ * hkp.c hkp.h: New
+
Wed Jan 13 14:10:15 CET 1999 Werner Koch <[email protected]>
* armor.c (radix64_read): Print an error if a bad armor was detected.
diff --git a/g10/Makefile.am b/g10/Makefile.am
index 5920365af..c062d770e 100644
--- a/g10/Makefile.am
+++ b/g10/Makefile.am
@@ -35,8 +35,8 @@ common_source = \
trustdb.h \
tdbio.c \
tdbio.h \
- pref.h \
- pref.c \
+ hkp.h \
+ hkp.c \
packet.h \
parse-packet.c \
passphrase.c \
diff --git a/g10/g10.c b/g10/g10.c
index dd8fddbf3..7e714262f 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -152,6 +152,7 @@ enum cmd_and_opt_values { aNull = 0,
oNotDashEscaped,
oEscapeFrom,
oLockOnce,
+ oKeyServer,
aTest };
@@ -229,6 +230,7 @@ static ARGPARSE_OPTS opts[] = {
{ oKeyring, "keyring" ,2, N_("add this keyring to the list of keyrings")},
{ oSecretKeyring, "secret-keyring" ,2, N_("add this secret keyring to the list")},
{ oDefaultKey, "default-key" ,2, N_("|NAME|use NAME as default secret key")},
+ { oKeyServer, "keyserver",2, N_("|HOST|use this keyserver to lookup keys")},
{ oCharset, "charset" , 2, N_("|NAME|set terminal charset to NAME") },
{ oOptions, "options" , 2, N_("read options from file")},
@@ -785,6 +787,7 @@ main( int argc, char **argv )
case oNotDashEscaped: opt.not_dash_escaped = 1; break;
case oEscapeFrom: opt.escape_from = 1; break;
case oLockOnce: opt.lock_once = 1; break;
+ case oKeyServer: opt.keyserver_name = pargs.r.ret_str; break;
default : pargs.err = configfp? 1:2; break;
}
diff --git a/g10/hkp.c b/g10/hkp.c
new file mode 100644
index 000000000..3d43dbfcf
--- /dev/null
+++ b/g10/hkp.c
@@ -0,0 +1,72 @@
+/* hkp.c - Horrowitz Keyserver Protocol
+ * Copyright (C) 1999 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+
+#include "errors.h"
+#include "util.h"
+#include "ttyio.h"
+#include "i18n.h"
+#include "options.h"
+#include "http.h"
+#include "main.h"
+
+
+/****************
+ * Try to import the key with KEYID from a keyserver but ask the user
+ * before doing so.
+ * Returns: 0 the key was successfully imported
+ * -1 key not found on server or user does not want to
+ * import the key
+ * or other error codes.
+ */
+int
+hkp_ask_import( u32 *keyid )
+{
+ struct http_context hd;
+ char *request;
+ int rc;
+
+ if( !opt.keyserver_name )
+ return -1;
+ log_info("requesting key %08lX from %s ...\n", (ulong)keyid[1],
+ opt.keyserver_name );
+ request = m_alloc( strlen( opt.keyserver_name ) + 100 );
+ sprintf( request, "x-hkp://%s:11371/pks/lookup?op=get&search=0x%08lX%08lX",
+ opt.keyserver_name, (ulong)keyid[0], (ulong)keyid[1] );
+ rc = open_http_document( &hd, request, 0 );
+ if( rc ) {
+ log_info("can't get key from keyserver: %s\n", g10_errstr(rc) );
+ goto leave;
+ }
+ rc = import_keys_stream( hd.fp_read , 0 );
+ close_http_document( &hd );
+
+ leave:
+ m_free( request );
+ return rc;
+}
+
+
diff --git a/g10/pref.h b/g10/hkp.h
index cc827bbc5..6ea555204 100644
--- a/g10/pref.h
+++ b/g10/hkp.h
@@ -1,5 +1,5 @@
-/* pref.h
- * Copyright (C) 1998 Free Software Foundation, Inc.
+/* hkp.h - Horrowitz Keyserver Protocol
+ * Copyright (C) 1999 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -18,25 +18,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-#ifndef G10_PREF_H
-#define G10_PREF_H 1
+#ifndef G10_HKP_H
+#define G10_HKP_H 1
-/* a structure to hold information abopu preferred algorithms */
-typedef struct pref_list_s *PREF_LIST;
-#ifndef DEFINES_PREF_LIST
-struct pref_list_s { char preference_stuff[1]; };
-#endif
+int hkp_ask_import( u32 *keyid );
-PREF_LIST new_pref_list(void);
-void release_pref_list( PREF_LIST pref );
-
-
-
-
-
-
-
-
-#endif /*G10_PREF_H*/
+#endif /*G10_HKP_H*/
diff --git a/g10/import.c b/g10/import.c
index 0b5fdf29b..2167f87d5 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -51,6 +51,7 @@ static struct {
} stats;
+static int import( IOBUF inp, int fast, const char* fname );
static int read_block( IOBUF a, compress_filter_context_t *cfx,
PACKET **pending_pkt, KBNODE *ret_root );
static int import_one( const char *fname, KBNODE keyblock, int fast );
@@ -106,10 +107,35 @@ static int merge_keysigs( KBNODE dst, KBNODE src, int *n_sigs,
int
import_keys( const char *fname, int fast )
{
+ IOBUF inp = NULL;
+ int rc;
+
+ inp = iobuf_open(fname);
+ if( !fname )
+ fname = "[stdin]";
+ if( !inp ) {
+ log_error_f(fname, _("can't open file: %s\n"), strerror(errno) );
+ return G10ERR_OPEN_FILE;
+ }
+
+ rc = import( inp, fast, fname );
+
+ iobuf_close(inp);
+ return rc;
+}
+
+int
+import_keys_stream( IOBUF inp, int fast )
+{
+ return import( inp, fast, "[stream]" );
+}
+
+static int
+import( IOBUF inp, int fast, const char* fname )
+{
armor_filter_context_t afx;
compress_filter_context_t cfx;
PACKET *pending_pkt = NULL;
- IOBUF inp = NULL;
KBNODE keyblock;
int rc = 0;
ulong count=0;
@@ -121,15 +147,6 @@ import_keys( const char *fname, int fast )
/* fixme: don't use static variables */
memset( &stats, 0, sizeof( stats ) );
- /* open file */
- inp = iobuf_open(fname);
- if( !fname )
- fname = "[stdin]";
- if( !inp ) {
- log_error_f(fname, _("can't open file: %s\n"), strerror(errno) );
- return G10ERR_OPEN_FILE;
- }
-
getkey_disable_caches();
@@ -185,8 +202,6 @@ import_keys( const char *fname, int fast )
if( stats.secret_dups )
log_info(_(" secret keys unchanged: %lu\n"), stats.secret_dups );
-
- iobuf_close(inp);
return rc;
}
diff --git a/g10/main.h b/g10/main.h
index b917bae26..94ace8ea2 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -109,6 +109,7 @@ KBNODE make_mpi_comment_node( const char *s, MPI a );
/*-- import.c --*/
int import_keys( const char *filename, int fast );
+int import_keys_stream( IOBUF inp, int fast );
/*-- export.c --*/
int export_pubkeys( STRLIST users, int onlyrfc );
int export_seckeys( STRLIST users );
diff --git a/g10/mainproc.c b/g10/mainproc.c
index 6b69eefa1..2e5575dd8 100644
--- a/g10/mainproc.c
+++ b/g10/mainproc.c
@@ -38,6 +38,7 @@
#include "status.h"
#include "i18n.h"
#include "trustdb.h"
+#include "hkp.h"
/****************
* Structure to hold the context
@@ -840,6 +841,10 @@ check_sig_and_print( CTX c, KBNODE node )
(int)strlen(tstr), tstr, astr? astr: "?", (ulong)sig->keyid[1] );
rc = do_check_sig(c, node, NULL );
+ if( rc == G10ERR_NO_PUBKEY && opt.keyserver_name ) {
+ if( !hkp_ask_import( sig->keyid ) )
+ rc = do_check_sig(c, node, NULL );
+ }
if( !rc || rc == G10ERR_BAD_SIGN ) {
char *us = get_long_user_id_string( sig->keyid );
write_status_text( rc? STATUS_BADSIG : STATUS_GOODSIG, us );
diff --git a/g10/options.h b/g10/options.h
index e6491864e..d7450dba8 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -67,6 +67,7 @@ struct {
int not_dash_escaped;
int escape_from;
int lock_once;
+ const char *keyserver_name;
} opt;
diff --git a/g10/options.skel b/g10/options.skel
index 1ad93b487..4b6a3fce6 100644
--- a/g10/options.skel
+++ b/g10/options.skel
@@ -56,3 +56,11 @@ lock-once
# you probably have to uncomment the next line:
#load-extension rndunix
+
+# GnuPG can import a key from a HKP keyerver if one is missing
+# for sercain operations. Is you set this option to a keyserver
+# you will be asked in such a case whether GnuPG should try to
+# import the key from that server (server do syncronize with each
+# others and DNS Round-Robin may give you a random server each time).
+#keyserver keys.pgp.net
+
diff --git a/g10/plaintext.c b/g10/plaintext.c
index 887b583f6..0dc246939 100644
--- a/g10/plaintext.c
+++ b/g10/plaintext.c
@@ -231,7 +231,7 @@ hash_datafiles( MD_HANDLE md, STRLIST files,
STRLIST sl=NULL;
if( !files ) {
- /* check whether we can opne the signed material */
+ /* check whether we can open the signed material */
fp = open_sigfile( sigfilename );
if( fp ) {
do_hash( md, fp, textmode );
diff --git a/g10/pref.c b/g10/pref.c
deleted file mode 100644
index 53ae41845..000000000
--- a/g10/pref.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/* pref.c
- * Copyright (C) 1998 Free Software Foundation, Inc.
- *
- * This file is part of GnuPG.
- *
- * GnuPG is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GnuPG is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#define DEFINES_PREF_LIST 1
-#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <assert.h>
-
-#include "errors.h"
-#include "memory.h"
-#include "util.h"
-#include "ttyio.h"
-#include "i18n.h"
-#include "pref.h"
-
-
-#define N_CIPHERS 3
-#define N_DIGESTS 4
-#define N_COMPRS 3
-
-struct pref_list_s {
- PREF_LIST *extend; /* if we need more, we link them together */
- byte cipher[N_CIPHERS]; /* cipher algos */
- byte digest[N_DIGESTS]; /* digest algos */
- byte compr [N_COMPRS ]; /* compress algos (a 255 denotes no compression)*/
-};
-
-
-#if 0
-PREF_LIST
-new_pref_list()
-{
- return m_alloc_clear( sizeof(*PREF_LIST) );
-}
-
-void
-release_pref_list( PREF_LIST pref )
-{
- while( pref ) {
- PREF_LIST tmp = pref->extend;
- m_free( pref );
- pref = tmp;
- }
-}
-
-PREF_LIST
-copy_pref_list( PREF_LIST s )
-{
- PREF_LIST ss, ss, d = new_pref_list();
- *d = *s;
- for( ss = s->extend; ss; ss = ss->extend ) {
-
- WORK WORK WORK
- d->extend = new_pref_list();
-
- *d->extend = *ss;
- }
- return d;
-}
-#endif
-