1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

* keyedit.c (menu_expire): Don't lose key flags when changing the

expiration date of a subkey.  This is not the most optimal solution, but
it is minimal change on the stable branch.

* main.h, keygen.c (do_copy_key_flags): New function to copy key flags, if
any, from one sig to another. (do_add_key_expire): New function to add key
expiration to a sig. (keygen_copy_flags_add_expire): New version of
keygen_add_key_expire that also copies key flags.
(keygen_add_key_flags_and_expire): Use do_add_key_expire.

* import.c (fix_hkp_corruption): Comment.
This commit is contained in:
David Shaw 2002-12-01 20:59:04 +00:00
parent 98708e1770
commit db9195c10b
5 changed files with 72 additions and 21 deletions

View file

@ -143,34 +143,56 @@ do_add_key_flags (PKT_signature *sig, unsigned int use)
build_sig_subpkt (sig, SIGSUBPKT_KEY_FLAGS, buf, 1);
}
static void
do_copy_key_flags (PKT_signature *sig, PKT_signature *oldsig)
{
const byte *f;
size_t n;
/* Note that this will make any key flags in the unhashed area
disappear. This may be good or bad, depending on your point of
view. */
f=parse_sig_subpkt(oldsig->hashed,SIGSUBPKT_KEY_FLAGS,&n);
if(f)
build_sig_subpkt(sig,SIGSUBPKT_KEY_FLAGS,f,n);
}
static void
do_add_key_expire( PKT_signature *sig, PKT_public_key *pk )
{
if( pk->expiredate )
{
byte buf[4];
u32 u;
u = pk->expiredate > pk->timestamp? pk->expiredate - pk->timestamp
: pk->timestamp;
buf[0] = (u >> 24) & 0xff;
buf[1] = (u >> 16) & 0xff;
buf[2] = (u >> 8) & 0xff;
buf[3] = u & 0xff;
build_sig_subpkt( sig, SIGSUBPKT_KEY_EXPIRE, buf, 4 );
}
}
int
keygen_add_key_expire( PKT_signature *sig, void *opaque )
keygen_copy_flags_add_expire( PKT_signature *sig, void *opaque )
{
PKT_public_key *pk = opaque;
byte buf[8];
u32 u;
struct flags_expire *fe=opaque;
do_add_key_expire(sig,fe->pk);
do_copy_key_flags(sig,fe->sig);
if( pk->expiredate ) {
u = pk->expiredate > pk->timestamp? pk->expiredate - pk->timestamp
: pk->timestamp;
buf[0] = (u >> 24) & 0xff;
buf[1] = (u >> 16) & 0xff;
buf[2] = (u >> 8) & 0xff;
buf[3] = u & 0xff;
build_sig_subpkt( sig, SIGSUBPKT_KEY_EXPIRE, buf, 4 );
}
return 0;
return 0;
}
static int
keygen_add_key_flags_and_expire (PKT_signature *sig, void *opaque)
{
struct opaque_data_usage_and_pk *oduap = opaque;
struct opaque_data_usage_and_pk *oduap = opaque;
do_add_key_flags (sig, oduap->usage);
return keygen_add_key_expire (sig, oduap->pk);
do_add_key_flags (sig, oduap->usage);
do_add_key_expire(sig,oduap->pk);
return 0;
}
static int
@ -489,7 +511,7 @@ keygen_add_std_prefs( PKT_signature *sig, void *opaque )
byte buf[8];
do_add_key_flags (sig, pk->pubkey_usage);
keygen_add_key_expire( sig, opaque );
do_add_key_expire (sig, pk);
keygen_upd_std_prefs (sig, opaque);
buf[0] = 0x80; /* no modify - It is reasonable that a key holder