1998-01-26 23:09:01 +01:00
|
|
|
/* export.c
|
2002-06-29 15:46:34 +02:00
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
1998-01-26 23:09:01 +01:00
|
|
|
*
|
1998-12-23 13:41:40 +01:00
|
|
|
* This file is part of GnuPG.
|
1998-01-26 23:09:01 +01:00
|
|
|
*
|
1998-12-23 13:41:40 +01:00
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
1998-01-26 23:09:01 +01:00
|
|
|
* 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.
|
|
|
|
*
|
1998-12-23 13:41:40 +01:00
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
1998-01-26 23:09:01 +01:00
|
|
|
* 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 "options.h"
|
|
|
|
#include "packet.h"
|
|
|
|
#include "errors.h"
|
|
|
|
#include "keydb.h"
|
2002-06-29 15:46:34 +02:00
|
|
|
#include "memory.h"
|
1998-01-26 23:09:01 +01:00
|
|
|
#include "util.h"
|
1998-02-13 21:58:50 +01:00
|
|
|
#include "main.h"
|
1998-11-10 13:59:59 +01:00
|
|
|
#include "i18n.h"
|
1998-01-26 23:09:01 +01:00
|
|
|
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
static int do_export( STRLIST users, int secret, unsigned int options );
|
1999-01-19 19:37:41 +01:00
|
|
|
static int do_export_stream( IOBUF out, STRLIST users,
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
int secret, unsigned int options, int *any );
|
|
|
|
|
|
|
|
int
|
|
|
|
parse_export_options(char *str,unsigned int *options)
|
|
|
|
{
|
|
|
|
char *tok;
|
|
|
|
int hit=0;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
unsigned int bit;
|
|
|
|
} export_opts[]=
|
|
|
|
{
|
|
|
|
{"include-non-rfc",EXPORT_INCLUDE_NON_RFC},
|
|
|
|
{"include-local-sigs",EXPORT_INCLUDE_LOCAL_SIGS},
|
|
|
|
{"include-attributes",EXPORT_INCLUDE_ATTRIBUTES},
|
|
|
|
{"include-sensitive-revkeys",EXPORT_INCLUDE_SENSITIVE_REVKEYS},
|
|
|
|
{NULL,0}
|
|
|
|
/* add tags for include revoked and disabled? */
|
|
|
|
};
|
|
|
|
|
|
|
|
while((tok=strsep(&str," ,")))
|
|
|
|
{
|
|
|
|
int i,rev=0;
|
|
|
|
|
2002-09-10 10:40:12 +02:00
|
|
|
if(ascii_strncasecmp("no-",tok,3)==0)
|
2002-07-24 05:37:55 +02:00
|
|
|
{
|
|
|
|
rev=1;
|
|
|
|
tok+=3;
|
|
|
|
}
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
|
|
|
|
for(i=0;export_opts[i].name;i++)
|
|
|
|
{
|
|
|
|
if(ascii_strcasecmp(export_opts[i].name,tok)==0)
|
|
|
|
{
|
|
|
|
if(rev)
|
|
|
|
*options&=~export_opts[i].bit;
|
|
|
|
else
|
|
|
|
*options|=export_opts[i].bit;
|
|
|
|
hit=1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!hit && !export_opts[i].name)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hit;
|
|
|
|
}
|
1998-01-26 23:09:01 +01:00
|
|
|
|
|
|
|
/****************
|
1998-04-14 19:51:16 +02:00
|
|
|
* Export the public keys (to standard out or --output).
|
1998-02-13 21:58:50 +01:00
|
|
|
* Depending on opt.armor the output is armored.
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
* options are defined in main.h.
|
2002-07-17 21:48:19 +02:00
|
|
|
* If USERS is NULL, the complete ring will be exported. */
|
1998-01-26 23:09:01 +01:00
|
|
|
int
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
export_pubkeys( STRLIST users, unsigned int options )
|
1998-06-29 14:30:57 +02:00
|
|
|
{
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
return do_export( users, 0, options );
|
1998-06-29 14:30:57 +02:00
|
|
|
}
|
|
|
|
|
1999-01-19 19:37:41 +01:00
|
|
|
/****************
|
|
|
|
* Export to an already opened stream; return -1 if no keys have
|
|
|
|
* been exported
|
|
|
|
*/
|
|
|
|
int
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
export_pubkeys_stream( IOBUF out, STRLIST users, unsigned int options )
|
1999-01-19 19:37:41 +01:00
|
|
|
{
|
|
|
|
int any, rc;
|
|
|
|
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
rc = do_export_stream( out, users, 0, options, &any );
|
1999-01-19 19:37:41 +01:00
|
|
|
if( !rc && !any )
|
|
|
|
rc = -1;
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
1998-06-29 14:30:57 +02:00
|
|
|
int
|
|
|
|
export_seckeys( STRLIST users )
|
|
|
|
{
|
1998-12-10 20:20:47 +01:00
|
|
|
return do_export( users, 1, 0 );
|
1998-06-29 14:30:57 +02:00
|
|
|
}
|
|
|
|
|
2000-07-14 19:34:53 +02:00
|
|
|
int
|
|
|
|
export_secsubkeys( STRLIST users )
|
|
|
|
{
|
|
|
|
return do_export( users, 2, 0 );
|
|
|
|
}
|
|
|
|
|
1998-06-29 14:30:57 +02:00
|
|
|
static int
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
do_export( STRLIST users, int secret, unsigned int options )
|
1998-01-26 23:09:01 +01:00
|
|
|
{
|
1999-01-19 19:37:41 +01:00
|
|
|
IOBUF out = NULL;
|
|
|
|
int any, rc;
|
1998-02-13 21:58:50 +01:00
|
|
|
armor_filter_context_t afx;
|
2002-06-29 15:46:34 +02:00
|
|
|
compress_filter_context_t zfx;
|
1999-01-19 19:37:41 +01:00
|
|
|
|
|
|
|
memset( &afx, 0, sizeof afx);
|
2002-06-29 15:46:34 +02:00
|
|
|
memset( &zfx, 0, sizeof zfx);
|
1999-01-19 19:37:41 +01:00
|
|
|
|
|
|
|
rc = open_outfile( NULL, 0, &out );
|
|
|
|
if( rc )
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
if( opt.armor ) {
|
|
|
|
afx.what = secret?5:1;
|
|
|
|
iobuf_push_filter( out, armor_filter, &afx );
|
|
|
|
}
|
2002-06-29 15:46:34 +02:00
|
|
|
if( opt.compress_keys && opt.compress )
|
|
|
|
iobuf_push_filter( out, compress_filter, &zfx );
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
rc = do_export_stream( out, users, secret, options, &any );
|
1999-01-19 19:37:41 +01:00
|
|
|
|
|
|
|
if( rc || !any )
|
|
|
|
iobuf_cancel(out);
|
|
|
|
else
|
|
|
|
iobuf_close(out);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
do_export_stream( IOBUF out, STRLIST users, int secret,
|
|
|
|
unsigned int options, int *any )
|
1999-01-19 19:37:41 +01:00
|
|
|
{
|
|
|
|
int rc = 0;
|
1998-02-13 21:58:50 +01:00
|
|
|
PACKET pkt;
|
|
|
|
KBNODE keyblock = NULL;
|
|
|
|
KBNODE kbctx, node;
|
2002-06-29 15:46:34 +02:00
|
|
|
int ndesc;
|
|
|
|
KEYDB_SEARCH_DESC *desc = NULL;
|
|
|
|
KEYDB_HANDLE kdbhd;
|
1998-02-13 21:58:50 +01:00
|
|
|
STRLIST sl;
|
|
|
|
|
1999-01-19 19:37:41 +01:00
|
|
|
*any = 0;
|
1998-02-13 21:58:50 +01:00
|
|
|
init_packet( &pkt );
|
2002-06-29 15:46:34 +02:00
|
|
|
kdbhd = keydb_new (secret);
|
1998-02-13 21:58:50 +01:00
|
|
|
|
2002-06-29 15:46:34 +02:00
|
|
|
if (!users) {
|
|
|
|
ndesc = 1;
|
|
|
|
desc = m_alloc_clear ( ndesc * sizeof *desc);
|
|
|
|
desc[0].mode = KEYDB_SEARCH_MODE_FIRST;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (ndesc=0, sl=users; sl; sl = sl->next, ndesc++)
|
|
|
|
;
|
|
|
|
desc = m_alloc ( ndesc * sizeof *desc);
|
|
|
|
|
|
|
|
for (ndesc=0, sl=users; sl; sl = sl->next) {
|
|
|
|
if (classify_user_id (sl->d, desc+ndesc))
|
|
|
|
ndesc++;
|
|
|
|
else
|
|
|
|
log_error (_("key `%s' not found: %s\n"),
|
|
|
|
sl->d, g10_errstr (G10ERR_INV_USER_ID));
|
|
|
|
}
|
1998-02-13 21:58:50 +01:00
|
|
|
|
2002-06-29 15:46:34 +02:00
|
|
|
/* it would be nice to see which of the given users did
|
|
|
|
actually match one in the keyring. To implement this we
|
|
|
|
need to have a found flag for each entry in desc and to set
|
|
|
|
this we must check all those entries after a match to mark
|
|
|
|
all matched one - currently we stop at the first match. To
|
|
|
|
do this we need an extra flag to enable this feature so */
|
1998-02-13 21:58:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-29 15:46:34 +02:00
|
|
|
while (!(rc = keydb_search (kdbhd, desc, ndesc))) {
|
|
|
|
int sha1_warned=0;
|
|
|
|
u32 sk_keyid[2];
|
|
|
|
|
|
|
|
if (!users)
|
|
|
|
desc[0].mode = KEYDB_SEARCH_MODE_NEXT;
|
|
|
|
|
|
|
|
/* read the keyblock */
|
|
|
|
rc = keydb_get_keyblock (kdbhd, &keyblock );
|
|
|
|
if( rc ) {
|
|
|
|
log_error (_("error reading keyblock: %s\n"), g10_errstr(rc) );
|
|
|
|
goto leave;
|
|
|
|
}
|
1998-12-10 20:20:47 +01:00
|
|
|
|
|
|
|
/* do not export keys which are incompatible with rfc2440 */
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
if( !(options&EXPORT_INCLUDE_NON_RFC) &&
|
2002-07-17 21:48:19 +02:00
|
|
|
(node = find_kbnode( keyblock, PKT_PUBLIC_KEY )) ) {
|
1998-12-10 20:20:47 +01:00
|
|
|
PKT_public_key *pk = node->pkt->pkt.public_key;
|
|
|
|
if( pk->version == 3 && pk->pubkey_algo > 3 ) {
|
|
|
|
log_info(_("key %08lX: not a rfc2440 key - skipped\n"),
|
|
|
|
(ulong)keyid_from_pk( pk, NULL) );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
1998-02-13 21:58:50 +01:00
|
|
|
|
2002-06-29 15:46:34 +02:00
|
|
|
node=find_kbnode( keyblock, PKT_SECRET_KEY );
|
|
|
|
if(node)
|
|
|
|
{
|
|
|
|
PKT_secret_key *sk=node->pkt->pkt.secret_key;
|
|
|
|
|
|
|
|
keyid_from_sk(sk,sk_keyid);
|
|
|
|
|
|
|
|
/* we can't apply GNU mode 1001 on an unprotected key */
|
|
|
|
if( secret == 2 && !sk->is_protected )
|
|
|
|
{
|
|
|
|
log_info(_("key %08lX: not protected - skipped\n"),
|
|
|
|
(ulong)sk_keyid[1]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no v3 keys with GNU mode 1001 */
|
|
|
|
if( secret == 2 && sk->version == 3 )
|
|
|
|
{
|
|
|
|
log_info(_("key %08lX: PGP 2.x style key - skipped\n"),
|
|
|
|
(ulong)sk_keyid[1]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2000-07-14 19:34:53 +02:00
|
|
|
|
1998-02-13 21:58:50 +01:00
|
|
|
/* and write it */
|
|
|
|
for( kbctx=NULL; (node = walk_kbnode( keyblock, &kbctx, 0 )); ) {
|
1998-10-16 18:00:17 +02:00
|
|
|
/* don't export any comment packets but those in the
|
|
|
|
* secret keyring */
|
|
|
|
if( !secret && node->pkt->pkttype == PKT_COMMENT )
|
|
|
|
continue;
|
2002-06-29 15:46:34 +02:00
|
|
|
/* make sure that ring_trust packets never get exported */
|
|
|
|
if (node->pkt->pkttype == PKT_RING_TRUST)
|
|
|
|
continue;
|
|
|
|
|
1998-11-03 20:38:58 +01:00
|
|
|
if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
2002-06-29 15:46:34 +02:00
|
|
|
/* do not export packets which are marked as not exportable */
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
if( !(options&EXPORT_INCLUDE_LOCAL_SIGS) &&
|
|
|
|
!node->pkt->pkt.signature->flags.exportable )
|
2002-06-29 15:46:34 +02:00
|
|
|
continue; /* not exportable */
|
|
|
|
|
|
|
|
/* do not export packets with a "sensitive" revocation
|
|
|
|
key. This will need revisiting when we start
|
|
|
|
supporting creating revocation keys and not just
|
|
|
|
reading them. */
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
if( !(options&EXPORT_INCLUDE_SENSITIVE_REVKEYS) &&
|
|
|
|
node->pkt->pkt.signature->revkey ) {
|
2002-06-29 15:46:34 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0;i<node->pkt->pkt.signature->numrevkeys;i++)
|
|
|
|
if(node->pkt->pkt.signature->revkey[i]->class & 0x40)
|
2002-08-20 14:45:57 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
if(i<node->pkt->pkt.signature->numrevkeys)
|
|
|
|
continue;
|
2002-06-29 15:46:34 +02:00
|
|
|
}
|
1998-11-03 20:38:58 +01:00
|
|
|
}
|
|
|
|
|
2002-07-17 21:48:19 +02:00
|
|
|
/* Don't export attribs? */
|
* options.h, main.h, export.c (parse_export_options, do_export_stream),
g10.c (main): add new --export-options option. Current flags are
"include-non-rfc", "include-local-sigs", "include-attributes", and
"include-sensitive-revkeys".
* options.h, hkp.c (hkp_export), keyserver.c (parse_keyserver_options,
keyserver_spawn): try passing unknown keyserver options to export options,
and if successful, use them when doing a keyserver --send-key.
* build-packet.c (build_sig_subpkt): We do not generate
SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
2002-07-22 21:07:21 +02:00
|
|
|
if( !(options&EXPORT_INCLUDE_ATTRIBUTES) &&
|
2002-07-17 21:48:19 +02:00
|
|
|
node->pkt->pkttype == PKT_USER_ID &&
|
|
|
|
node->pkt->pkt.user_id->attrib_data ) {
|
|
|
|
/* Skip until we get to something that is not an attrib
|
|
|
|
or a signature on an attrib */
|
|
|
|
while(kbctx->next && kbctx->next->pkt->pkttype==PKT_SIGNATURE) {
|
|
|
|
kbctx=kbctx->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2000-07-14 19:34:53 +02:00
|
|
|
if( secret == 2 && node->pkt->pkttype == PKT_SECRET_KEY ) {
|
|
|
|
/* we don't want to export the secret parts of the
|
|
|
|
* primary key, this is done by using GNU protection mode 1001
|
|
|
|
*/
|
|
|
|
int save_mode = node->pkt->pkt.secret_key->protect.s2k.mode;
|
|
|
|
node->pkt->pkt.secret_key->protect.s2k.mode = 1001;
|
|
|
|
rc = build_packet( out, node->pkt );
|
|
|
|
node->pkt->pkt.secret_key->protect.s2k.mode = save_mode;
|
|
|
|
}
|
|
|
|
else {
|
2002-06-29 15:46:34 +02:00
|
|
|
/* Warn the user if the secret key or any of the secret
|
|
|
|
subkeys are protected with SHA1 and we have
|
|
|
|
simple_sk_checksum set. */
|
|
|
|
if(!sha1_warned && opt.simple_sk_checksum &&
|
|
|
|
(node->pkt->pkttype==PKT_SECRET_KEY ||
|
|
|
|
node->pkt->pkttype==PKT_SECRET_SUBKEY) &&
|
|
|
|
node->pkt->pkt.secret_key->protect.sha1chk)
|
|
|
|
{
|
|
|
|
/* I hope this warning doesn't confuse people. */
|
2003-04-27 06:10:04 +02:00
|
|
|
log_info(_("WARNING: secret key %08lX does not have a "
|
|
|
|
"simple SK checksum\n"),(ulong)sk_keyid[1]);
|
2002-06-29 15:46:34 +02:00
|
|
|
|
|
|
|
sha1_warned=1;
|
|
|
|
}
|
|
|
|
|
2000-07-14 19:34:53 +02:00
|
|
|
rc = build_packet( out, node->pkt );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( rc ) {
|
1998-02-13 21:58:50 +01:00
|
|
|
log_error("build_packet(%d) failed: %s\n",
|
2002-06-29 15:46:34 +02:00
|
|
|
node->pkt->pkttype, g10_errstr(rc) );
|
|
|
|
rc = G10ERR_WRITE_FILE;
|
1998-02-13 21:58:50 +01:00
|
|
|
goto leave;
|
|
|
|
}
|
|
|
|
}
|
1999-01-19 19:37:41 +01:00
|
|
|
++*any;
|
1998-02-13 21:58:50 +01:00
|
|
|
}
|
|
|
|
if( rc == -1 )
|
|
|
|
rc = 0;
|
|
|
|
|
|
|
|
leave:
|
2002-06-29 15:46:34 +02:00
|
|
|
m_free(desc);
|
|
|
|
keydb_release (kdbhd);
|
1998-02-13 21:58:50 +01:00
|
|
|
release_kbnode( keyblock );
|
1999-01-19 19:37:41 +01:00
|
|
|
if( !*any )
|
1998-11-10 13:59:59 +01:00
|
|
|
log_info(_("WARNING: nothing exported\n"));
|
1998-02-13 21:58:50 +01:00
|
|
|
return rc;
|
1998-01-26 23:09:01 +01:00
|
|
|
}
|
|
|
|
|