diff options
author | David Shaw <[email protected]> | 2002-12-01 20:59:04 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2002-12-01 20:59:04 +0000 |
commit | db9195c10b611e4f79a93ebe7139b4d24c4dd510 (patch) | |
tree | b6ae0374ee13aaedb22a55b9863ca4108faf424f /g10/keygen.c | |
parent | * NEWS: Add notes about notation names and '@', the --trust-model option, (diff) | |
download | gnupg-db9195c10b611e4f79a93ebe7139b4d24c4dd510.tar.gz gnupg-db9195c10b611e4f79a93ebe7139b4d24c4dd510.zip |
* 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.
Diffstat (limited to 'g10/keygen.c')
-rw-r--r-- | g10/keygen.c | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/g10/keygen.c b/g10/keygen.c index e2eb91bc5..aa30b4d6b 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -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); +} -int -keygen_add_key_expire( PKT_signature *sig, void *opaque ) +static void +do_add_key_expire( PKT_signature *sig, PKT_public_key *pk ) { - PKT_public_key *pk = opaque; - byte buf[8]; - u32 u; + if( pk->expiredate ) + { + byte buf[4]; + u32 u; - 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 ); + 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; +int +keygen_copy_flags_add_expire( PKT_signature *sig, void *opaque ) +{ + struct flags_expire *fe=opaque; + do_add_key_expire(sig,fe->pk); + do_copy_key_flags(sig,fe->sig); + + 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 |