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.
This commit is contained in:
parent
054f3ce53c
commit
1e28f6ca75
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue