diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2017-04-13 14:39:12 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2017-04-13 14:44:05 +0300 |
commit | 1e28f6ca7591511c7c0a8a325a01cb3b44e144c6 (patch) | |
tree | 031f1c6fe1d307830dcb95c4e94cfb3adac510c6 | |
parent | 054f3ce53ce71dfdcae5559aa4a7f9cbb1df9bae (diff) | |
download | rpm-1e28f6ca7591511c7c0a8a325a01cb3b44e144c6.tar.gz |
Store signature/key creation time in a saner format internally
The OpenPGP time fields are unsigned four-octet numbers, storing
it as the uint32_t it actually is makes using the value that
little bit saner.
Way too many places to update as we still have no API for this, sigh.
-rw-r--r-- | lib/formats.c | 2 | ||||
-rw-r--r-- | lib/rpmts.c | 6 | ||||
-rw-r--r-- | rpmio/digest.h | 2 | ||||
-rw-r--r-- | rpmio/rpmkeyring.c | 3 | ||||
-rw-r--r-- | rpmio/rpmpgp.c | 6 |
5 files changed, 9 insertions, 10 deletions
diff --git a/lib/formats.c b/lib/formats.c index be7fa1532..fff53d6be 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -359,7 +359,7 @@ static char * pgpsigFormat(rpmtd td, char **emsg) } else { char dbuf[BUFSIZ]; char *keyid = pgpHexStr(sigp->signid, sizeof(sigp->signid)); - unsigned int dateint = pgpGrab(sigp->time, sizeof(sigp->time)); + unsigned int dateint = sigp->time; time_t date = dateint; struct tm * tms = localtime(&date); unsigned int key_algo = pgpDigParamsAlgo(sigp, PGPVAL_PUBKEYALGO); diff --git a/lib/rpmts.c b/lib/rpmts.c index c07f15d90..889be6e4a 100644 --- a/lib/rpmts.c +++ b/lib/rpmts.c @@ -416,12 +416,12 @@ static int makePubkeyHeader(rpmts ts, rpmPubkey key, rpmPubkey *subkeys, /* Build header elements. */ v = pgpHexStr(pubp->signid, sizeof(pubp->signid)); - r = pgpHexStr(pubp->time, sizeof(pubp->time)); userid = pubp->userid ? pubp->userid : "none"; - keytime = pgpGrab(pubp->time, sizeof(pubp->time)); + keytime = pubp->time; rasprintf(&n, "gpg(%s)", v+8); rasprintf(&u, "gpg(%s)", userid); + rasprintf(&r, "%x", keytime); rasprintf(&evr, "%d:%s-%s", pubp->version, v, r); headerPutString(h, RPMTAG_PUBKEYS, enc); @@ -459,9 +459,9 @@ static int makePubkeyHeader(rpmts ts, rpmPubkey key, rpmPubkey *subkeys, pgpkey = rpmPubkeyPgpDigParams(subkeys[i]); v = pgpHexStr(pgpkey->signid, sizeof(pgpkey->signid)); - r = pgpHexStr(pgpkey->time, sizeof(pgpkey->time)); rasprintf(&n, "gpg(%s)", v+8); + rasprintf(&r, "%x", pgpkey->time); rasprintf(&evr, "%d:%s-%s", pubp->version, v, r); headerPutString(h, RPMTAG_PROVIDENAME, n); diff --git a/rpmio/digest.h b/rpmio/digest.h index ee39ee0ce..9e0cde3b9 100644 --- a/rpmio/digest.h +++ b/rpmio/digest.h @@ -27,7 +27,7 @@ struct pgpDigParams_s { uint8_t tag; uint8_t version; /*!< version number. */ - pgpTime_t time; /*!< time that the key was created. */ + uint32_t time; /*!< key/signature creation time. */ uint8_t pubkey_algo; /*!< public key algorithm. */ uint8_t hash_algo; diff --git a/rpmio/rpmkeyring.c b/rpmio/rpmkeyring.c index a5c223e4b..4e14de1e5 100644 --- a/rpmio/rpmkeyring.c +++ b/rpmio/rpmkeyring.c @@ -230,8 +230,7 @@ pgpDig rpmPubkeyDig(rpmPubkey key) if (rc == 0) { pgpDigParams pubp = pgpDigGetParams(dig, PGPTAG_PUBLIC_KEY); if (!pubp || !memcmp(pubp->signid, zeros, sizeof(pubp->signid)) || - !memcmp(pubp->time, zeros, sizeof(pubp->time)) || - pubp->userid == NULL) { + pubp->time == 0 || pubp->userid == NULL) { rc = -1; } } diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c index c14340a2b..b0678a0ed 100644 --- a/rpmio/rpmpgp.c +++ b/rpmio/rpmpgp.c @@ -435,7 +435,7 @@ static int pgpPrtSubType(const uint8_t *h, size_t hlen, pgpSigType sigtype, if (plen-1 != sizeof(_digp->time)) break; _digp->saved |= PGPDIG_SAVED_TIME; - memcpy(_digp->time, p+1, sizeof(_digp->time)); + _digp->time = pgpGrab(p+1, sizeof(_digp->time)); } case PGPSUBTYPE_SIG_EXPIRE_TIME: case PGPSUBTYPE_KEY_EXPIRE_TIME: @@ -587,7 +587,7 @@ static int pgpPrtSig(pgpTag tag, const uint8_t *h, size_t hlen, _digp->hashlen = v->hashlen; _digp->sigtype = v->sigtype; _digp->hash = memcpy(xmalloc(v->hashlen), &v->sigtype, v->hashlen); - memcpy(_digp->time, v->time, sizeof(_digp->time)); + _digp->time = pgpGrab(v->time, sizeof(v->time)); memcpy(_digp->signid, v->signid, sizeof(_digp->signid)); _digp->pubkey_algo = v->pubkey_algo; _digp->hash_algo = v->hash_algo; @@ -738,7 +738,7 @@ static int pgpPrtKey(pgpTag tag, const uint8_t *h, size_t hlen, /* If _digp->hash is not NULL then signature is already loaded */ if (_digp->hash == NULL) { _digp->version = v->version; - memcpy(_digp->time, v->time, sizeof(_digp->time)); + _digp->time = pgpGrab(v->time, sizeof(v->time)); _digp->pubkey_algo = v->pubkey_algo; } |