summaryrefslogtreecommitdiff
path: root/rpmio
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2007-11-26 14:19:38 +0200
committerPanu Matilainen <pmatilai@redhat.com>2007-11-26 14:19:38 +0200
commit399dca5c05440350c39008b9e682b95945bc35ff (patch)
tree38a835819d4cebd32d37f216fdb42db5664ef88a /rpmio
parent7ac39db1f4117442b49e4717c79f04295886d9be (diff)
downloadrpm-399dca5c05440350c39008b9e682b95945bc35ff.tar.gz
rpm-399dca5c05440350c39008b9e682b95945bc35ff.tar.bz2
rpm-399dca5c05440350c39008b9e682b95945bc35ff.zip
Define and use pgpKeyID_t for pgp key id's
Diffstat (limited to 'rpmio')
-rw-r--r--rpmio/rpmpgp.c10
-rw-r--r--rpmio/rpmpgp.h20
2 files changed, 16 insertions, 14 deletions
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index a188a99dc..7b38a3db3 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -888,7 +888,7 @@ int pgpPrtComment(pgpTag tag, const uint8_t *h, unsigned int hlen)
}
int pgpPubkeyFingerprint(const uint8_t * pkt, unsigned int pktlen,
- uint8_t * keyid)
+ pgpKeyID_t keyid)
{
const uint8_t *s = pkt;
DIGEST_CTX ctx;
@@ -907,7 +907,7 @@ int pgpPubkeyFingerprint(const uint8_t * pkt, unsigned int pktlen,
switch (v->pubkey_algo) {
case PGPPUBKEYALGO_RSA:
s += (pgpMpiLen(s) - 8);
- memmove(keyid, s, 8);
+ memmove(keyid, s, sizeof(keyid));
rc = 0;
break;
default: /* TODO: md5 of mpi bodies (i.e. no length) */
@@ -936,7 +936,7 @@ int pgpPubkeyFingerprint(const uint8_t * pkt, unsigned int pktlen,
(void) rpmDigestFinal(ctx, (void **)&SHA1, NULL, 0);
s = SHA1 + 12;
- memmove(keyid, s, 8);
+ memmove(keyid, s, sizeof(keyid));
rc = 0;
if (SHA1) free(SHA1);
@@ -945,7 +945,7 @@ int pgpPubkeyFingerprint(const uint8_t * pkt, unsigned int pktlen,
return rc;
}
-int pgpExtractPubkeyFingerprint(const char * b64pkt, uint8_t * keyid)
+int pgpExtractPubkeyFingerprint(const char * b64pkt, pgpKeyID_t keyid)
{
const uint8_t * pkt;
size_t pktlen;
@@ -954,7 +954,7 @@ int pgpExtractPubkeyFingerprint(const char * b64pkt, uint8_t * keyid)
return -1; /* on error */
(void) pgpPubkeyFingerprint(pkt, pktlen, keyid);
pkt = _free(pkt);
- return 8; /* no. of bytes of pubkey signid */
+ return sizeof(keyid); /* no. of bytes of pubkey signid */
}
int pgpPrtPkt(const uint8_t *pkt, unsigned int pleft)
diff --git a/rpmio/rpmpgp.h b/rpmio/rpmpgp.h
index 1d6f515c4..cffeac9fb 100644
--- a/rpmio/rpmpgp.h
+++ b/rpmio/rpmpgp.h
@@ -30,6 +30,8 @@ typedef struct pgpDig_s * pgpDig;
*/
typedef struct pgpDigParams_s * pgpDigParams;
+typedef uint8_t pgpKeyID_t[8];
+
/**
*/
typedef const struct pgpValTbl_s {
@@ -110,7 +112,7 @@ extern struct pgpValTbl_s pgpTagTbl[];
*/
typedef struct pgpPktPubkey_s {
uint8_t version; /*!< version number (generate 3, accept 2). */
- uint8_t keyid[8]; /*!< key ID of the public key for session key. */
+ pgpKeyID_t keyid; /*!< key ID of the public key for session key. */
uint8_t algo; /*!< public key algorithm used. */
} pgpPktPubkey;
@@ -319,7 +321,7 @@ typedef struct pgpPktSigV3_s {
uint8_t hashlen; /*!< length of following hashed material. MUST be 5. */
uint8_t sigtype; /*!< signature type. */
uint8_t time[4]; /*!< 4 byte creation time. */
- uint8_t signid[8]; /*!< key ID of signer. */
+ pgpKeyID_t signid; /*!< key ID of signer. */
uint8_t pubkey_algo; /*!< public key algorithm. */
uint8_t hash_algo; /*!< hash algorithm. */
uint8_t signhash16[2]; /*!< left 16 bits of signed hash value. */
@@ -559,7 +561,7 @@ typedef struct pgpPktOnepass_s {
uint8_t sigtype; /*!< signature type. */
uint8_t hash_algo; /*!< hash algorithm. */
uint8_t pubkey_algo; /*!< public key algorithm. */
- uint8_t signid[8]; /*!< key ID of signer. */
+ pgpKeyID_t signid; /*!< key ID of signer. */
uint8_t nested;
} * pgpPktOnepass;
@@ -1169,20 +1171,20 @@ int pgpPrtComment(pgpTag tag, const uint8_t *h, unsigned int hlen);
* @todo V3 non-RSA public keys not implemented.
* @param pkt OpenPGP packet (i.e. PGPTAG_PUBLIC_KEY)
* @param pktlen OpenPGP packet length (no. of bytes)
- * @retval keyid publick key fingerprint
+ * @retval keyid public key fingerprint
* @return 0 on sucess, else -1
*/
int pgpPubkeyFingerprint(const uint8_t * pkt, unsigned int pktlen,
- uint8_t * keyid);
+ pgpKeyID_t keyid);
/**
* Extract OpenPGP public key fingerprint from base64 encoded packet.
* @todo V3 non-RSA public keys not implemented.
-* @param b64pkt base64 encoded openpgp packet
-* @retval keyid[8] public key fingerprint
-* @return 8 (no. of bytes) on success, < 0 on error
+* @param b64pkt base64 encoded openpgp packet
+* @retval keyid public key fingerprint
+* @return 8 (no. of bytes) on success, < 0 on error
*/
-int pgpExtractPubkeyFingerprint(const char * b64pkt, uint8_t * keyid);
+int pgpExtractPubkeyFingerprint(const char * b64pkt, pgpKeyID_t keyid);
/**