mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
* keygen.c (start_tree): New function to "prime" a KBNODE list.
(do_generate_keypair): Use it here rather than creating and deleting a comment packet. * keygen.c (gen_elg, gen_dsa): Do not put public factors in secret key as a comment. * options.h, encode.c (encode_simple, encode_crypt), keygen.c (do_create): Remove disabled comment packet code.
This commit is contained in:
parent
08bd93f7dc
commit
da0c60a987
4 changed files with 34 additions and 46 deletions
|
@ -1,5 +1,15 @@
|
||||||
2005-05-05 David Shaw <dshaw@jabberwocky.com>
|
2005-05-05 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* keygen.c (start_tree): New function to "prime" a KBNODE list.
|
||||||
|
(do_generate_keypair): Use it here rather than creating and
|
||||||
|
deleting a comment packet.
|
||||||
|
|
||||||
|
* keygen.c (gen_elg, gen_dsa): Do not put public factors in secret
|
||||||
|
key as a comment.
|
||||||
|
|
||||||
|
* options.h, encode.c (encode_simple, encode_crypt), keygen.c
|
||||||
|
(do_create): Remove disabled comment packet code.
|
||||||
|
|
||||||
* keygen.c (keygen_set_std_prefs): Add SHA256 and BZip2 to default
|
* keygen.c (keygen_set_std_prefs): Add SHA256 and BZip2 to default
|
||||||
preferences.
|
preferences.
|
||||||
|
|
||||||
|
|
22
g10/encode.c
22
g10/encode.c
|
@ -1,6 +1,6 @@
|
||||||
/* encode.c - encode data
|
/* encode.c - encode data
|
||||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||||
* 2004 Free Software Foundation, Inc.
|
* 2005 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
|
@ -248,14 +248,7 @@ encode_simple( const char *filename, int mode, int use_seskey )
|
||||||
|
|
||||||
if( opt.armor )
|
if( opt.armor )
|
||||||
iobuf_push_filter( out, armor_filter, &afx );
|
iobuf_push_filter( out, armor_filter, &afx );
|
||||||
#ifdef ENABLE_COMMENT_PACKETS
|
|
||||||
else {
|
|
||||||
write_comment( out, "#created by GNUPG v" VERSION " ("
|
|
||||||
PRINTABLE_OS_NAME ")");
|
|
||||||
if( opt.comment_string )
|
|
||||||
write_comment( out, opt.comment_string );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if( s2k && !RFC1991 ) {
|
if( s2k && !RFC1991 ) {
|
||||||
PKT_symkey_enc *enc = m_alloc_clear( sizeof *enc + seskeylen + 1 );
|
PKT_symkey_enc *enc = m_alloc_clear( sizeof *enc + seskeylen + 1 );
|
||||||
enc->version = 4;
|
enc->version = 4;
|
||||||
|
@ -504,14 +497,7 @@ encode_crypt( const char *filename, STRLIST remusr, int use_symkey )
|
||||||
|
|
||||||
if( opt.armor )
|
if( opt.armor )
|
||||||
iobuf_push_filter( out, armor_filter, &afx );
|
iobuf_push_filter( out, armor_filter, &afx );
|
||||||
#ifdef ENABLE_COMMENT_PACKETS
|
|
||||||
else {
|
|
||||||
write_comment( out, "#created by GNUPG v" VERSION " ("
|
|
||||||
PRINTABLE_OS_NAME ")");
|
|
||||||
if( opt.comment_string )
|
|
||||||
write_comment( out, opt.comment_string );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* create a session key */
|
/* create a session key */
|
||||||
cfx.dek = m_alloc_secure_clear (sizeof *cfx.dek);
|
cfx.dek = m_alloc_secure_clear (sizeof *cfx.dek);
|
||||||
if( !opt.def_cipher_algo ) { /* try to get it from the prefs */
|
if( !opt.def_cipher_algo ) { /* try to get it from the prefs */
|
||||||
|
|
44
g10/keygen.c
44
g10/keygen.c
|
@ -990,7 +990,6 @@ gen_elg(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||||
STRING2KEY *s2k, PKT_secret_key **ret_sk, u32 expireval, int is_subkey)
|
STRING2KEY *s2k, PKT_secret_key **ret_sk, u32 expireval, int is_subkey)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int i;
|
|
||||||
PACKET *pkt;
|
PACKET *pkt;
|
||||||
PKT_secret_key *sk;
|
PKT_secret_key *sk;
|
||||||
PKT_public_key *pk;
|
PKT_public_key *pk;
|
||||||
|
@ -1060,9 +1059,6 @@ gen_elg(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||||
pkt->pkttype = is_subkey ? PKT_SECRET_SUBKEY : PKT_SECRET_KEY;
|
pkt->pkttype = is_subkey ? PKT_SECRET_SUBKEY : PKT_SECRET_KEY;
|
||||||
pkt->pkt.secret_key = sk;
|
pkt->pkt.secret_key = sk;
|
||||||
add_kbnode(sec_root, new_kbnode( pkt ));
|
add_kbnode(sec_root, new_kbnode( pkt ));
|
||||||
for(i=0; factors[i]; i++ )
|
|
||||||
add_kbnode( sec_root,
|
|
||||||
make_mpi_comment_node("#:ELG_factor:", factors[i] ));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1076,7 +1072,6 @@ gen_dsa(unsigned int nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||||
STRING2KEY *s2k, PKT_secret_key **ret_sk, u32 expireval, int is_subkey)
|
STRING2KEY *s2k, PKT_secret_key **ret_sk, u32 expireval, int is_subkey)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int i;
|
|
||||||
PACKET *pkt;
|
PACKET *pkt;
|
||||||
PKT_secret_key *sk;
|
PKT_secret_key *sk;
|
||||||
PKT_public_key *pk;
|
PKT_public_key *pk;
|
||||||
|
@ -1150,9 +1145,6 @@ gen_dsa(unsigned int nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
||||||
pkt->pkttype = is_subkey ? PKT_SECRET_SUBKEY : PKT_SECRET_KEY;
|
pkt->pkttype = is_subkey ? PKT_SECRET_SUBKEY : PKT_SECRET_KEY;
|
||||||
pkt->pkt.secret_key = sk;
|
pkt->pkt.secret_key = sk;
|
||||||
add_kbnode(sec_root, new_kbnode( pkt ));
|
add_kbnode(sec_root, new_kbnode( pkt ));
|
||||||
for(i=1; factors[i]; i++ ) /* the first one is q */
|
|
||||||
add_kbnode( sec_root,
|
|
||||||
make_mpi_comment_node("#:DSA_factor:", factors[i] ));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1916,16 +1908,6 @@ do_create( int algo, unsigned int nbits, KBNODE pub_root, KBNODE sec_root,
|
||||||
else
|
else
|
||||||
BUG();
|
BUG();
|
||||||
|
|
||||||
#ifdef ENABLE_COMMENT_PACKETS
|
|
||||||
if( !rc ) {
|
|
||||||
add_kbnode( pub_root,
|
|
||||||
make_comment_node("#created by GNUPG v" VERSION " ("
|
|
||||||
PRINTABLE_OS_NAME ")"));
|
|
||||||
add_kbnode( sec_root,
|
|
||||||
make_comment_node("#created by GNUPG v" VERSION " ("
|
|
||||||
PRINTABLE_OS_NAME ")"));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2732,6 +2714,17 @@ generate_raw_key (int algo, unsigned int nbits, u32 created_at,
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_CARD_SUPPORT */
|
#endif /* ENABLE_CARD_SUPPORT */
|
||||||
|
|
||||||
|
/* Create and delete a dummy packet to start off a list of kbnodes. */
|
||||||
|
static void
|
||||||
|
start_tree(KBNODE *tree)
|
||||||
|
{
|
||||||
|
PACKET *pkt;
|
||||||
|
|
||||||
|
pkt=m_alloc_clear(sizeof(*pkt));
|
||||||
|
pkt->pkttype=PKT_NONE;
|
||||||
|
*tree=new_kbnode(pkt);
|
||||||
|
delete_kbnode(*tree);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_generate_keypair( struct para_data_s *para,
|
do_generate_keypair( struct para_data_s *para,
|
||||||
|
@ -2745,12 +2738,12 @@ do_generate_keypair( struct para_data_s *para,
|
||||||
int rc;
|
int rc;
|
||||||
int did_sub = 0;
|
int did_sub = 0;
|
||||||
|
|
||||||
if( outctrl->dryrun ) {
|
if( outctrl->dryrun )
|
||||||
|
{
|
||||||
log_info("dry-run mode - key generation skipped\n");
|
log_info("dry-run mode - key generation skipped\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( outctrl->use_files ) {
|
if( outctrl->use_files ) {
|
||||||
if( outctrl->pub.newfname ) {
|
if( outctrl->pub.newfname ) {
|
||||||
iobuf_close(outctrl->pub.stream);
|
iobuf_close(outctrl->pub.stream);
|
||||||
|
@ -2821,13 +2814,14 @@ do_generate_keypair( struct para_data_s *para,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* we create the packets as a tree of kbnodes. Because the structure
|
/* we create the packets as a tree of kbnodes. Because the
|
||||||
* we create is known in advance we simply generate a linked list
|
* structure we create is known in advance we simply generate a
|
||||||
* The first packet is a dummy comment packet which we flag
|
* linked list. The first packet is a dummy packet which we flag
|
||||||
* as deleted. The very first packet must always be a KEY packet.
|
* as deleted. The very first packet must always be a KEY packet.
|
||||||
*/
|
*/
|
||||||
pub_root = make_comment_node("#"); delete_kbnode(pub_root);
|
|
||||||
sec_root = make_comment_node("#"); delete_kbnode(sec_root);
|
start_tree(&pub_root);
|
||||||
|
start_tree(&sec_root);
|
||||||
|
|
||||||
if (!card)
|
if (!card)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
|
|
||||||
#undef ENABLE_COMMENT_PACKETS /* don't create comment packets */
|
|
||||||
|
|
||||||
#ifndef EXTERN_UNLESS_MAIN_MODULE
|
#ifndef EXTERN_UNLESS_MAIN_MODULE
|
||||||
/* Norcraft can't cope with common symbols */
|
/* Norcraft can't cope with common symbols */
|
||||||
#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
|
#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue