From 5541bd2d1f06e2634936779ce9e23e3e3404e77f Mon Sep 17 00:00:00 2001 From: Edouard Tisserant Date: Fri, 20 Nov 2015 21:45:00 +0100 Subject: [PATCH] Fixed wrong format for seckey packet (s2k was missing if no conversion) --- dist/src/lib/create.c | 6 +++--- dist/src/lib/keyring.c | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dist/src/lib/create.c b/dist/src/lib/create.c index 40c111e..1086e3f 100644 --- a/dist/src/lib/create.c +++ b/dist/src/lib/create.c @@ -301,14 +301,14 @@ write_seckey_body(const pgp_seckey_t *key, if (!write_pubkey_body(&key->pubkey, output)) { return 0; } + if (!pgp_write_scalar(output, (unsigned)key->s2k_usage, 1)) { + return 0; + } if (key->s2k_usage != PGP_S2KU_NONE) { if (key->s2k_usage != PGP_S2KU_ENCRYPTED_AND_HASHED) { (void) fprintf(stderr, "write_seckey_body: s2k usage\n"); return 0; } - if (!pgp_write_scalar(output, (unsigned)key->s2k_usage, 1)) { - return 0; - } if (key->alg != PGP_SA_CAST5) { (void) fprintf(stderr, "write_seckey_body: algorithm\n"); diff --git a/dist/src/lib/keyring.c b/dist/src/lib/keyring.c index 2888755..4cbdc96 100644 --- a/dist/src/lib/keyring.c +++ b/dist/src/lib/keyring.c @@ -857,12 +857,13 @@ pgp_add_selfsigned_userid(pgp_key_t *skey, pgp_key_t *pkey, uint8_t *userid, uin /* create sig for this pkt */ sig = pgp_create_sig_new(); pgp_sig_start_key_sig(sig, &skey->key.seckey.pubkey, userid, PGP_CERT_POSITIVE); + pgp_add_creation_time(sig, (uint64_t)time(NULL)); pgp_add_key_expiration_time(sig, (uint64_t)duration); - pgp_add_key_flags(sig, PGP_KEYFLAG_SIGN_DATA|PGP_KEYFLAG_ENC_COMM); - pgp_add_issuer_keyid(sig, skey->pubkeyid); pgp_add_primary_userid(sig, 1); + pgp_add_key_flags(sig, PGP_KEYFLAG_SIGN_DATA|PGP_KEYFLAG_ENC_COMM); + pgp_end_hashed_subpkts(sig); pgp_setup_memory_write(&sigoutput, &mem_sig, 128);