summaryrefslogtreecommitdiff
path: root/rpmio
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2002-07-20 21:07:31 +0000
committerjbj <devnull@localhost>2002-07-20 21:07:31 +0000
commit293a81e2590888951a1341341eb3ff034b8a0406 (patch)
tree8487800311da40f2e1e9f57463e78d65b5d39247 /rpmio
parentbfb8488c10a5dfccbcb7c556408b300f8901cd88 (diff)
downloadrpm-293a81e2590888951a1341341eb3ff034b8a0406.tar.gz
rpm-293a81e2590888951a1341341eb3ff034b8a0406.tar.bz2
rpm-293a81e2590888951a1341341eb3ff034b8a0406.zip
- version added to *.la dependency libraries (#69063).
- expose digests in rpmio API, but hide internal beecrypt API (#68999). CVS patchset: 5561 CVS date: 2002/07/20 21:07:31
Diffstat (limited to 'rpmio')
-rw-r--r--rpmio/Makefile.am7
-rw-r--r--rpmio/rpmio.h4
-rw-r--r--rpmio/rpmio_internal.h128
-rw-r--r--rpmio/rpmpgp.c22
-rw-r--r--rpmio/rpmpgp.h140
-rw-r--r--rpmio/tkey.c1
6 files changed, 158 insertions, 144 deletions
diff --git a/rpmio/Makefile.am b/rpmio/Makefile.am
index 6f3ab295a..6c9d8a71c 100644
--- a/rpmio/Makefile.am
+++ b/rpmio/Makefile.am
@@ -6,16 +6,17 @@ EXTRA_DIST = tdigest.c tdir.c tficl.c tfts.c tglob.c tinv.c tkey.c trpmio.c
EXTRA_PROGRAMS = tdigest tdir tfts tglob tinv tkey tring trpmio dumpasn1
-INCLUDES = -I. \
+INCLUDES = -I. -I.. \
-I$(top_srcdir)/beecrypt \
-I$(top_srcdir)/popt \
@INCPATH@
pkgincdir = $(pkgincludedir)
pkginc_HEADERS = \
- rpmio.h rpmurl.h rpmmacro.h rpmlog.h rpmmessages.h rpmerr.h \
+ fts.h \
+ rpmio.h rpmurl.h rpmmacro.h rpmlog.h rpmmessages.h rpmerr.h rpmpgp.h \
ugid.h
-noinst_HEADERS = fts.h rpmio_internal.h rpmpgp.h
+noinst_HEADERS = rpmio_internal.h
BEECRYPTLOBJS = $(shell cat $(top_builddir)/beecrypt/listobjs)
diff --git a/rpmio/rpmio.h b/rpmio/rpmio.h
index 3046185b2..1b7ec8492 100644
--- a/rpmio/rpmio.h
+++ b/rpmio/rpmio.h
@@ -20,6 +20,10 @@
*/
typedef /*@abstract@*/ struct pgpDig_s * pgpDig;
+/**
+ */
+typedef /*@abstract@*/ struct pgpDigParams_s * pgpDigParams;
+
/** \ingroup rpmio
* Hide libio API lossage.
* The libio interface changed after glibc-2.1.3 to pass the seek offset
diff --git a/rpmio/rpmio_internal.h b/rpmio/rpmio_internal.h
index a4845aa16..528991011 100644
--- a/rpmio/rpmio_internal.h
+++ b/rpmio/rpmio_internal.h
@@ -8,8 +8,83 @@
#include <rpmio.h>
#include <rpmurl.h>
+
+#include <beecrypt/types.h>
#include <rpmpgp.h>
+/* Drag in the beecrypt includes. */
+#include <beecrypt/base64.h>
+#include <beecrypt/dsa.h>
+#include <beecrypt/endianness.h>
+#include <beecrypt/mp32.h>
+#include <beecrypt/rsa.h>
+#include <beecrypt/rsapk.h>
+
+/** \ingroup rpmio
+ * Values parsed from OpenPGP signature/pubkey packet(s).
+ */
+struct pgpDigParams_s {
+/*@only@*/ /*@null@*/
+ const char * userid;
+/*@only@*/ /*@null@*/
+ const byte * hash;
+ const char * params[4];
+ byte tag;
+
+ byte version; /*!< version number. */
+ byte time[4]; /*!< time that the key was created. */
+ byte pubkey_algo; /*!< public key algorithm. */
+
+ byte hash_algo;
+ byte sigtype;
+ byte hashlen;
+ byte signhash16[2];
+ byte signid[8];
+ byte saved;
+#define PGPDIG_SAVED_TIME (1 << 0)
+#define PGPDIG_SAVED_ID (1 << 1)
+
+};
+
+/** \ingroup rpmio
+ * Container for values parsed from an OpenPGP signature and public key.
+ */
+struct pgpDig_s {
+ struct pgpDigParams_s signature;
+ struct pgpDigParams_s pubkey;
+
+ size_t nbytes; /*!< No. bytes of plain text. */
+
+/*@only@*/ /*@null@*/
+ DIGEST_CTX sha1ctx; /*!< (dsa) sha1 hash context. */
+/*@only@*/ /*@null@*/
+ DIGEST_CTX hdrsha1ctx; /*!< (dsa) header sha1 hash context. */
+/*@only@*/ /*@null@*/
+ void * sha1; /*!< (dsa) V3 signature hash. */
+ size_t sha1len; /*!< (dsa) V3 signature hash length. */
+
+/*@only@*/ /*@null@*/
+ DIGEST_CTX md5ctx; /*!< (rsa) md5 hash context. */
+/*@only@*/ /*@null@*/
+ void * md5; /*!< (rsa) V3 signature hash. */
+ size_t md5len; /*!< (rsa) V3 signature hash length. */
+
+ /* DSA parameters. */
+ mp32barrett p;
+ mp32barrett q;
+ mp32number g;
+ mp32number y;
+ mp32number hm;
+ mp32number r;
+ mp32number s;
+
+ /* RSA parameters. */
+ rsapk rsa_pk;
+ mp32number m;
+ mp32number c;
+ mp32number rsahm;
+};
+
/** \ingroup rpmio
*/
typedef struct _FDSTACK_s {
@@ -47,13 +122,6 @@ typedef /*@abstract@*/ struct {
} * FDSTAT_t;
/** \ingroup rpmio
- * Bit(s) to control digest operation.
- */
-typedef enum rpmDigestFlags_e {
- RPMDIGEST_NONE = 0
-} rpmDigestFlags;
-
-/** \ingroup rpmio
*/
typedef struct _FDDIGEST_s {
pgpHashAlgo hashalgo;
@@ -61,52 +129,6 @@ typedef struct _FDDIGEST_s {
} * FDDIGEST_t;
/** \ingroup rpmio
- * Duplicate a digest context.
- * @param octx existing digest context
- * @return duplicated digest context
- */
-/*@only@*/
-DIGEST_CTX rpmDigestDup(DIGEST_CTX octx)
- /*@*/;
-
-/** \ingroup rpmio
- * Initialize digest.
- * Set bit count to 0 and buffer to mysterious initialization constants.
- * @param hashalgo type of digest
- * @param flags bit(s) to control digest operation
- * @return digest context
- */
-/*@only@*/
-DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
- /*@*/;
-
-/** \ingroup rpmio
- * Update context with next plain text buffer.
- * @param ctx digest context
- * @param data next data buffer
- * @param len no. bytes of data
- * @return 0 on success
- */
-int rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
- /*@modifies ctx @*/;
-
-/** \ingroup rpmio
- * Return digest and destroy context.
- * Final wrapup - pad to 64-byte boundary with the bit pattern
- * 1 0* (64-bit count of bits processed, MSB-first)
- *
- * @param ctx digest context
- * @retval datap address of returned digest
- * @retval lenp address of digest length
- * @param asAscii return digest as ascii string?
- * @return 0 on success
- */
-int rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx,
- /*@null@*/ /*@out@*/ void ** datap,
- /*@null@*/ /*@out@*/ size_t * lenp, int asAscii)
- /*@modifies *datap, *lenp @*/;
-
-/** \ingroup rpmio
* The FD_t File Handle data structure.
*/
struct _FD_s {
diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index 4a585742f..3fa0195d9 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -8,17 +8,20 @@
#include "rpmio_internal.h"
#include "debug.h"
+/*@access pgpDig @*/
+/*@access pgpDigParams @*/
+
/*@unchecked@*/
static int _debug = 0;
/*@unchecked@*/
static int _print = 0;
-/*@unchecked@*/
-/*@null@*/ static struct pgpDig_s * _dig = NULL;
+/*@unchecked@*/ /*@null@*/
+static pgpDig _dig = NULL;
-/*@unchecked@*/
-/*@null@*/ static struct pgpDigParams_s * _digp = NULL;
+/*@unchecked@*/ /*@null@*/
+static pgpDigParams _digp = NULL;
#ifdef DYING
/* This is the unarmored RPM-GPG-KEY public key. */
@@ -1005,14 +1008,14 @@ int pgpPrtPkt(const byte *pkt)
return (rc ? -1 : pktlen);
}
-struct pgpDig_s * pgpNewDig(void)
+pgpDig pgpNewDig(void)
{
- struct pgpDig_s * dig = xcalloc(1, sizeof(*dig));
+ pgpDig dig = xcalloc(1, sizeof(*dig));
return dig;
}
/*@-boundswrite@*/
-void pgpCleanDig(struct pgpDig_s * dig)
+void pgpCleanDig(pgpDig dig)
{
if (dig != NULL) {
int i;
@@ -1047,7 +1050,7 @@ void pgpCleanDig(struct pgpDig_s * dig)
}
/*@=boundswrite@*/
-struct pgpDig_s * pgpFreeDig(/*@only@*/ /*@null@*/ struct pgpDig_s * dig)
+pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig)
/*@modifies dig @*/
{
if (dig != NULL) {
@@ -1092,8 +1095,7 @@ struct pgpDig_s * pgpFreeDig(/*@only@*/ /*@null@*/ struct pgpDig_s * dig)
return dig;
}
-int pgpPrtPkts(const byte * pkts, unsigned int plen,
- struct pgpDig_s * dig, int printing)
+int pgpPrtPkts(const byte * pkts, unsigned int plen, pgpDig dig, int printing)
{
unsigned int val = *pkts;
const byte *p;
diff --git a/rpmio/rpmpgp.h b/rpmio/rpmpgp.h
index 98fa3e286..962a1ce9f 100644
--- a/rpmio/rpmpgp.h
+++ b/rpmio/rpmpgp.h
@@ -10,13 +10,11 @@
* Copyright (C) The Internet Society (1998). All Rights Reserved.
*/
-#include "types.h"
-#include "base64.h"
-#include "dsa.h"
-#include "endianness.h"
-#include "mp32.h"
-#include "rsa.h"
-#include "rsapk.h"
+#if !defined(_BEECRYPT_TYPES_H)
+/*@-redef@*/
+typedef unsigned char byte;
+/*@=redef@*/
+#endif /* _BEECRYPT_TYPES_H */
/**
*/
@@ -953,70 +951,12 @@ typedef enum pgpArmorKey_e {
/*@observer@*/ /*@unchecked@*/ /*@unused@*/
extern struct pgpValTbl_s pgpArmorKeyTbl[];
-/**
- * Values parsed from OpenPGP signature/pubkey packet(s).
- */
-struct pgpDigParams_s {
-/*@only@*/ /*@null@*/
- const char * userid;
-/*@only@*/ /*@null@*/
- const byte * hash;
- const char * params[4];
- byte tag;
-
- byte version; /*!< version number. */
- byte time[4]; /*!< time that the key was created. */
- byte pubkey_algo; /*!< public key algorithm. */
-
- byte hash_algo;
- byte sigtype;
- byte hashlen;
- byte signhash16[2];
- byte signid[8];
- byte saved;
-#define PGPDIG_SAVED_TIME (1 << 0)
-#define PGPDIG_SAVED_ID (1 << 1)
-
-};
-
-/**
- * Container for values parsed from an OpenPGP signature and public key.
+/** \ingroup rpmio
+ * Bit(s) to control digest operation.
*/
-struct pgpDig_s {
- struct pgpDigParams_s signature;
- struct pgpDigParams_s pubkey;
-
- size_t nbytes; /*!< No. bytes of plain text. */
-
-/*@only@*/ /*@null@*/
- DIGEST_CTX sha1ctx; /*!< (dsa) sha1 hash context. */
-/*@only@*/ /*@null@*/
- DIGEST_CTX hdrsha1ctx; /*!< (dsa) header sha1 hash context. */
-/*@only@*/ /*@null@*/
- void * sha1; /*!< (dsa) V3 signature hash. */
- size_t sha1len; /*!< (dsa) V3 signature hash length. */
-
-/*@only@*/ /*@null@*/
- DIGEST_CTX md5ctx; /*!< (rsa) md5 hash context. */
-/*@only@*/ /*@null@*/
- void * md5; /*!< (rsa) V3 signature hash. */
- size_t md5len; /*!< (rsa) V3 signature hash length. */
-
- /* DSA parameters. */
- mp32barrett p;
- mp32barrett q;
- mp32number g;
- mp32number y;
- mp32number hm;
- mp32number r;
- mp32number s;
-
- /* RSA parameters. */
- rsapk rsa_pk;
- mp32number m;
- mp32number c;
- mp32number rsahm;
-};
+typedef enum rpmDigestFlags_e {
+ RPMDIGEST_NONE = 0
+} rpmDigestFlags;
/*@-fcnuse@*/
@@ -1272,7 +1212,7 @@ int pgpPrtPkt(const byte *pkt)
* @param printing should packets be printed?
* @return -1 on error, 0 on success
*/
-int pgpPrtPkts(const byte *pkts, unsigned int plen, struct pgpDig_s *dig, int printing)
+int pgpPrtPkts(const byte *pkts, unsigned int plen, pgpDig dig, int printing)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/;
@@ -1293,14 +1233,14 @@ pgpArmor pgpReadPkts(const char * fn,
* @return container
*/
/*@only@*/
-struct pgpDig_s * pgpNewDig(void)
+pgpDig pgpNewDig(void)
/*@*/;
/**
* Release (malloc'd) data from container.
* @param dig container
*/
-void pgpCleanDig(/*@null@*/ struct pgpDig_s * dig)
+void pgpCleanDig(/*@null@*/ pgpDig dig)
/*@modifies dig @*/;
/**
@@ -1309,8 +1249,8 @@ void pgpCleanDig(/*@null@*/ struct pgpDig_s * dig)
* @return NULL always
*/
/*@only@*/ /*@null@*/
-struct pgpDig_s * pgpFreeDig(/*@only@*/ /*@null@*/ struct pgpDig_s * dig)
- /*@modifies *dig @*/;
+pgpDig pgpFreeDig(/*@only@*/ /*@null@*/ pgpDig dig)
+ /*@modifies dig @*/;
/**
* Is buffer at beginning of an OpenPGP packet?
@@ -1380,10 +1320,10 @@ int pgpIsPkt(const byte * p)
* @return crc of buffer
*/
/*@unused@*/ static inline
-uint32 pgpCRC(const byte *octets, size_t len)
+unsigned int pgpCRC(const byte *octets, size_t len)
/*@*/
{
- uint32 crc = CRC24_INIT;
+ unsigned int crc = CRC24_INIT;
int i;
while (len--) {
@@ -1399,6 +1339,52 @@ uint32 pgpCRC(const byte *octets, size_t len)
return crc & 0xffffff;
}
+/** \ingroup rpmio
+ * Duplicate a digest context.
+ * @param octx existing digest context
+ * @return duplicated digest context
+ */
+/*@only@*/
+DIGEST_CTX rpmDigestDup(DIGEST_CTX octx)
+ /*@*/;
+
+/** \ingroup rpmio
+ * Initialize digest.
+ * Set bit count to 0 and buffer to mysterious initialization constants.
+ * @param hashalgo type of digest
+ * @param flags bit(s) to control digest operation
+ * @return digest context
+ */
+/*@only@*/
+DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
+ /*@*/;
+
+/** \ingroup rpmio
+ * Update context with next plain text buffer.
+ * @param ctx digest context
+ * @param data next data buffer
+ * @param len no. bytes of data
+ * @return 0 on success
+ */
+int rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
+ /*@modifies ctx @*/;
+
+/** \ingroup rpmio
+ * Return digest and destroy context.
+ * Final wrapup - pad to 64-byte boundary with the bit pattern
+ * 1 0* (64-bit count of bits processed, MSB-first)
+ *
+ * @param ctx digest context
+ * @retval datap address of returned digest
+ * @retval lenp address of digest length
+ * @param asAscii return digest as ascii string?
+ * @return 0 on success
+ */
+int rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx,
+ /*@null@*/ /*@out@*/ void ** datap,
+ /*@null@*/ /*@out@*/ size_t * lenp, int asAscii)
+ /*@modifies *datap, *lenp @*/;
+
#ifdef __cplusplus
}
#endif
diff --git a/rpmio/tkey.c b/rpmio/tkey.c
index 6853ae684..12abc58b7 100644
--- a/rpmio/tkey.c
+++ b/rpmio/tkey.c
@@ -7,7 +7,6 @@ static int _debug = 0;
#include "system.h"
#include "rpmio_internal.h"
-#include "rpmpgp.h"
#include "debug.h"
static int doit(const char *sig, pgpDig dig, int printing)