mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
See ChangeLog: Sat Jan 16 09:27:30 CET 1999 Werner Koch
This commit is contained in:
parent
e99e43cd53
commit
29c08419db
23 changed files with 203 additions and 122 deletions
|
@ -1,3 +1,14 @@
|
|||
Sat Jan 16 09:27:30 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
|
||||
|
||||
* 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 <wk@isil.d.shuttle.de>
|
||||
|
||||
* armor.c (radix64_read): Print an error if a bad armor was detected.
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
72
g10/hkp.c
Normal file
72
g10/hkp.c
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
|
||||
/* 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
|
||||
#ifndef G10_HKP_H
|
||||
#define G10_HKP_H 1
|
||||
|
||||
|
||||
PREF_LIST new_pref_list(void);
|
||||
void release_pref_list( PREF_LIST pref );
|
||||
int hkp_ask_import( u32 *keyid );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /*G10_PREF_H*/
|
||||
#endif /*G10_HKP_H*/
|
39
g10/import.c
39
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 );
|
||||
|
@ -105,11 +106,36 @@ 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -67,6 +67,7 @@ struct {
|
|||
int not_dash_escaped;
|
||||
int escape_from;
|
||||
int lock_once;
|
||||
const char *keyserver_name;
|
||||
} opt;
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
81
g10/pref.c
81
g10/pref.c
|
@ -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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue