sigtarget, Fstrerror(fd));
}
- fdInitSHA1(fd, 0);
+ fdInitDigest(fd, PGPHASHALGO_SHA1, 0);
if (headerWrite(fd, h, HEADER_MAGIC_NO)) {
rc = RPMERR_NOSPACE;
rpmError(RPMERR_NOSPACE, _("Unable to write final header\n"));
}
(void) Fflush(fd);
- fdFiniSHA1(fd, (void **)&sha1, NULL, 1);
+ fdFiniDigest(fd, (void **)&sha1, NULL, 1);
(void) Fclose(fd);
fd = NULL;
fmd5sum = fsm->fmd5sum;
if (st->st_size > 0 && fmd5sum)
- fdInitMD5(fsm->wfd, 0);
+ fdInitDigest(fsm->wfd, PGPHASHALGO_MD5, 0);
while (left) {
const char * md5sum = NULL;
(void) Fflush(fsm->wfd);
- fdFiniMD5(fsm->wfd, (void **)&md5sum, NULL, 1);
+ fdFiniDigest(fsm->wfd, (void **)&md5sum, NULL, 1);
if (md5sum == NULL) {
rc = CPIOERR_MD5SUM_MISMATCH;
return 1;
}
- fdInitMD5(fd, 0);
+ fdInitDigest(fd, PGPHASHALGO_MD5, 0);
while ((rc = Fread(buf, sizeof(buf[0]), sizeof(buf), fd)) > 0)
{};
- fdFiniMD5(fd, (void **)&md5sum, &md5len, asAscii);
+ fdFiniDigest(fd, (void **)&md5sum, &md5len, asAscii);
if (Ferror(fd))
rc = 1;
/*@-type@*/ /* FIX: cast? */
if (dig != NULL) {
- dig->md5ctx = rpmDigestInit(RPMDIGEST_MD5);
- (void) fdInitSHA1(*sfdp, 0);
+ (void) fdInitDigest(*sfdp, PGPHASHALGO_MD5, 0);
+ dig->sha1ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
}
/*@=type@*/
while ((count = Fread(buffer, sizeof(buffer[0]), sizeof(buffer), *sfdp)) > 0) {
/*@-type@*/ /* FIX: cast? */
if (dig)
- rpmDigestUpdate(dig->md5ctx, buffer, count);
+ (void) rpmDigestUpdate(dig->sha1ctx, buffer, count);
/*@=type@*/
if (Fwrite(buffer, sizeof(buffer[0]), count, *tfdp) != count) {
/*@-type@*/ /* FIX: cast? */
if (dig != NULL) {
- dig->sha1ctx = _free(dig->sha1ctx);
- dig->sha1ctx = (*sfdp)->digest;
+ dig->md5ctx = _free(dig->md5ctx);
+ dig->md5ctx = (*sfdp)->digest;
(*sfdp)->digest = NULL;
}
/*@=type@*/
/*@-type@*/ /* FIX: cast? */
{ DIGEST_CTX ctx = rpmDigestDup(dig->md5ctx);
- rpmDigestUpdate(ctx, &dig->sig.v3.sigtype, dig->sig.v3.hashlen);
- rpmDigestFinal(ctx, (void **)&dig->md5, &dig->md5len, 1);
+ (void) rpmDigestUpdate(ctx, &dig->sig.v3.sigtype, dig->sig.v3.hashlen);
+ (void) rpmDigestFinal(ctx, (void **)&dig->md5, &dig->md5len, 1);
/* XXX compare leading 16 bits of digest for quick check. */
}
(void) pgpPrtPkts(ptr, count, dig, rpmIsVerbose());
/*@-type@*/ /* FIX: cast? */
{ DIGEST_CTX ctx = rpmDigestDup(dig->sha1ctx);
- rpmDigestUpdate(ctx, &dig->sig.v3.sigtype, dig->sig.v3.hashlen);
- rpmDigestFinal(ctx, (void **)&dig->sha1, &dig->sha1len, 1);
+ (void) rpmDigestUpdate(ctx, &dig->sig.v3.sigtype, dig->sig.v3.hashlen);
+ (void) rpmDigestFinal(ctx, (void **)&dig->sha1, &dig->sha1len, 1);
mp32nzero(&dig->hm); mp32nsethex(&dig->hm, dig->sha1);
}
/*@=type@*/
(void) unlink(sigtarget);
sigtarget = _free(sigtarget);
}
- dig->sha1ctx = _free(dig->sha1ctx);
- dig->sha1 = _free(dig->sha1);
dig->md5ctx = _free(dig->md5ctx);
dig->md5 = _free(dig->md5);
+ dig->sha1ctx = _free(dig->sha1ctx);
+ dig->sha1 = _free(dig->sha1);
dig->hash_data = _free(dig->hash_data);
mp32nfree(&dig->hm);
}
/*@=branchstate@*/
- dig->sha1ctx = _free(dig->sha1ctx);
- dig->sha1 = _free(dig->sha1);
dig->md5ctx = _free(dig->md5ctx);
dig->md5 = _free(dig->md5);
+ dig->sha1ctx = _free(dig->sha1ctx);
+ dig->sha1 = _free(dig->sha1);
dig->hash_data = _free(dig->hash_data);
mp32bfree(&dig->p);
int_32 uhc;
const char * hdigest;
rpmTagType hdt;
- int flags = RPMDIGEST_SHA1;
int ec = 0; /* assume no problems */
/* Retrieve header digest. */
if (!hge(h, RPMTAG_SHA1HEADER, &hdt, (void **) &hdigest, NULL)
&& !hge(h, RPMTAG_SHA1RHN, &hdt, (void **) &hdigest, NULL))
{
-#ifdef DYING
- if (hge(h, RPMTAG_BADSHA1HEADER, &hdt, (void **) &hdigest, NULL))
- flags |= (RPMDIGEST_REVERSE|RPMDIGEST_BCSWAP);
- else
-#endif
return 0;
}
/* Regenerate original header. */
return 0;
/* Compute header digest. */
- { DIGEST_CTX ctx = rpmDigestInit(flags);
+ { DIGEST_CTX ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
const char * digest;
size_t digestlen;
- rpmDigestUpdate(ctx, uh, uhc);
- rpmDigestFinal(ctx, (void **)&digest, &digestlen, 1);
+ (void) rpmDigestUpdate(ctx, uh, uhc);
+ (void) rpmDigestFinal(ctx, (void **)&digest, &digestlen, 1);
/* XXX can't happen: report NULL malloc return as a digest failure. */
ec = (digest == NULL || strcmp(hdigest, digest)) ? 1 : 0;
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2001-10-18 21:22-0400\n"
+"POT-Creation-Date: 2001-10-18 21:28-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "package lacks both group name and id lists (this should never happen)\n"
msgstr ""
-#: lib/verify.c:404
+#: lib/verify.c:398
#, c-format
msgid "missing %s"
msgstr ""
-#: lib/verify.c:501
+#: lib/verify.c:495
#, c-format
msgid "Unsatisfied dependencies for %s-%s-%s: "
msgstr ""
-#: lib/verify.c:543
+#: lib/verify.c:537
#, c-format
msgid "%s-%s-%s: immutable header region digest check failed\n"
msgstr ""
-#: rpmdb/db1.c:101 rpmdb/db3.c:98
+#: rpmdb/db1.c:101 rpmdb/db3.c:100
#, c-format
msgid "db%d error(%d) from %s: %s\n"
msgstr ""
-#: rpmdb/db1.c:104 rpmdb/db3.c:101
+#: rpmdb/db1.c:104 rpmdb/db3.c:103
#, c-format
msgid "db%d error(%d): %s\n"
msgstr ""
msgid "cannot get %s lock on database\n"
msgstr ""
-#: rpmdb/db1.c:576 rpmdb/db3.c:1209
+#: rpmdb/db1.c:576 rpmdb/db3.c:1211
msgid "exclusive"
msgstr ""
-#: rpmdb/db1.c:576 rpmdb/db3.c:1209
+#: rpmdb/db1.c:576 rpmdb/db3.c:1211
msgid "shared"
msgstr ""
-#: rpmdb/db3.c:129
+#: rpmdb/db3.c:131
#, c-format
msgid "closed db environment %s/%s\n"
msgstr ""
-#: rpmdb/db3.c:147
+#: rpmdb/db3.c:149
#, c-format
msgid "removed db environment %s/%s\n"
msgstr ""
-#: rpmdb/db3.c:188
+#: rpmdb/db3.c:190
#, c-format
msgid "opening db environment %s/%s %s\n"
msgstr ""
-#: rpmdb/db3.c:708
+#: rpmdb/db3.c:710
#, c-format
msgid "closed db index %s/%s\n"
msgstr ""
-#: rpmdb/db3.c:773
+#: rpmdb/db3.c:775
#, c-format
msgid "verified db index %s/%s\n"
msgstr ""
-#: rpmdb/db3.c:986
+#: rpmdb/db3.c:988
#, c-format
msgid "opening db index %s/%s %s mode=0x%x\n"
msgstr ""
-#: rpmdb/db3.c:1207
+#: rpmdb/db3.c:1209
#, c-format
msgid "cannot get %s lock on %s/%s\n"
msgstr ""
-#: rpmdb/db3.c:1213
+#: rpmdb/db3.c:1215
#, c-format
msgid "locked db index %s/%s\n"
msgstr ""
msgid "File %s is smaller than %u bytes\n"
msgstr ""
-#: rpmio/rpmio.c:632
+#: rpmio/rpmio.c:644
msgid "Success"
msgstr ""
-#: rpmio/rpmio.c:635
+#: rpmio/rpmio.c:647
msgid "Bad server response"
msgstr ""
-#: rpmio/rpmio.c:638
+#: rpmio/rpmio.c:650
msgid "Server I/O error"
msgstr ""
-#: rpmio/rpmio.c:641
+#: rpmio/rpmio.c:653
msgid "Server timeout"
msgstr ""
-#: rpmio/rpmio.c:644
+#: rpmio/rpmio.c:656
msgid "Unable to lookup server host address"
msgstr ""
-#: rpmio/rpmio.c:647
+#: rpmio/rpmio.c:659
msgid "Unable to lookup server host name"
msgstr ""
-#: rpmio/rpmio.c:650
+#: rpmio/rpmio.c:662
msgid "Failed to connect to server"
msgstr ""
-#: rpmio/rpmio.c:653
+#: rpmio/rpmio.c:665
msgid "Failed to establish data connection to server"
msgstr ""
-#: rpmio/rpmio.c:656
+#: rpmio/rpmio.c:668
msgid "I/O error to local file"
msgstr ""
-#: rpmio/rpmio.c:659
+#: rpmio/rpmio.c:671
msgid "Error setting remote server to passive mode"
msgstr ""
-#: rpmio/rpmio.c:662
+#: rpmio/rpmio.c:674
msgid "File not found on server"
msgstr ""
-#: rpmio/rpmio.c:665
+#: rpmio/rpmio.c:677
msgid "Abort in progress"
msgstr ""
-#: rpmio/rpmio.c:669
+#: rpmio/rpmio.c:681
msgid "Unknown or unexpected error"
msgstr ""
-#: rpmio/rpmio.c:1341
+#: rpmio/rpmio.c:1353
#, c-format
msgid "logging into %s as %s, pw %s\n"
msgstr ""
-I$(top_srcdir)/lib \
-I$(top_srcdir)/rpmdb \
-I$(top_srcdir)/rpmio \
+ -I$(top_srcdir)/beecrypt \
-I$(top_srcdir)/popt \
-I/usr/include/python${PYVER} \
@INCPATH@
-I$(top_srcdir)/lib \
-I$(top_srcdir)/rpmdb \
-I$(top_srcdir)/rpmio \
+ -I$(top_srcdir)/beecrypt \
-I$(top_srcdir)/popt \
-I/usr/include/python${PYVER} \
@INCPATH@
headerGetEntry(h, RPMTAG_HEADERIMMUTABLE, &uht, (void **)&uh, &uhc);
- ctx = rpmDigestInit(RPMDIGEST_SHA1);
+ ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
rpmDigestUpdate(ctx, uh, uhc);
rpmDigestFinal(ctx, (void **)&digest, &digestlen, 1);
#endif
#if defined(__LCLINT__)
+/*@-redef@*/ /* FIX: rpmio/rpmio.c also declares */
typedef unsigned int u_int32_t;
typedef unsigned short u_int16_t;
typedef unsigned char u_int8_t;
/*@-incondefs@*/ /* LCLint 3.0.0.15 */
typedef int int32_t;
/*@=incondefs@*/
+/*@=redef@*/
#endif
#include <db3/db.h>
*/
struct DIGEST_CTX_s {
rpmDigestFlags flags; /*!< Bit(s) to control digest operation. */
- uint32 digestlen; /*!< No. bytes of digest. */
uint32 datalen; /*!< No. bytes in block of plaintext data. */
+ uint32 paramlen; /*!< No. bytes of digest parameters. */
+ uint32 digestlen; /*!< No. bytes of digest. */
void * param; /*!< Digest parameters. */
int (*Reset) (void * param)
/*@modifies param @*/; /*!< Digest initialize. */
DIGEST_CTX
rpmDigestDup(DIGEST_CTX octx)
{
- DIGEST_CTX nctx = xcalloc(1, sizeof(*nctx));
- memcpy(nctx, octx, sizeof(*nctx));
+ DIGEST_CTX nctx = memcpy(xcalloc(1, sizeof(*nctx)), octx, sizeof(*nctx));
+ nctx->param = memcpy(xcalloc(1, nctx->paramlen), octx->param, nctx->paramlen);
return nctx;
}
DIGEST_CTX
-rpmDigestInit(rpmDigestFlags flags)
+rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
{
DIGEST_CTX ctx = xcalloc(1, sizeof(*ctx));
+ int xx;
ctx->flags = flags;
- if (flags & RPMDIGEST_MD5) {
+ switch (hashalgo) {
+ case PGPHASHALGO_MD5:
ctx->digestlen = 16;
ctx->datalen = 64;
/*@-sizeoftype@*/ /* FIX: union, not void pointer */
- ctx->param = xcalloc(1, sizeof(md5Param));
+ ctx->paramlen = sizeof(md5Param);
/*@=sizeoftype@*/
+ ctx->param = xcalloc(1, ctx->paramlen);
/*@-type@*/ /* FIX: cast? */
ctx->Reset = (void *) md5Reset;
ctx->Update = (void *) md5Update;
ctx->Digest = (void *) md5Digest;
/*@=type@*/
- }
-
- if (flags & RPMDIGEST_SHA1) {
+ break;
+ case PGPHASHALGO_SHA1:
ctx->digestlen = 20;
ctx->datalen = 64;
/*@-sizeoftype@*/ /* FIX: union, not void pointer */
- ctx->param = xcalloc(1, sizeof(sha1Param));
+ ctx->paramlen = sizeof(sha1Param);
/*@=sizeoftype@*/
+ ctx->param = xcalloc(1, ctx->paramlen);
/*@-type@*/ /* FIX: cast? */
ctx->Reset = (void *) sha1Reset;
ctx->Update = (void *) sha1Update;
ctx->Digest = (void *) sha1Digest;
/*@=type@*/
+ break;
+ case PGPHASHALGO_RIPEMD160:
+ case PGPHASHALGO_MD2:
+ case PGPHASHALGO_TIGER192:
+ case PGPHASHALGO_HAVAL_5_160:
+ default:
+ free(ctx);
+ return NULL;
+ /*@notreached@*/ break;
}
- /*@-noeffectuncon@*/ /* FIX: check rc */
- (void) (*ctx->Reset) (ctx->param);
- /*@=noeffectuncon@*/ /* FIX: check rc */
+ xx = (*ctx->Reset) (ctx->param);
DPRINTF((stderr, "*** Init(%x) ctx %p param %p\n", flags, ctx, ctx->param));
return ctx;
}
-void
+/*@-mustmod@*/ /* LCL: ctx->param may be modified, but ctx is abstract @*/
+int
rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
{
DPRINTF((stderr, "*** Update(%p,%p,%d) param %p \"%s\"\n", ctx, data, len, ctx->param, ((char *)data)));
- /*@-noeffectuncon@*/ /* FIX: check rc */
- (void) (*ctx->Update) (ctx->param, data, len);
- /*@=noeffectuncon@*/
+ return (*ctx->Update) (ctx->param, data, len);
}
+/*@=mustmod@*/
/*@unchecked@*/
static int _ie = 0x44332211;
#define IS_BIG_ENDIAN() (_endian->b[0] == '\x44')
#define IS_LITTLE_ENDIAN() (_endian->b[0] == '\x11')
-void
+int
rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx, /*@out@*/ void ** datap,
/*@out@*/ size_t *lenp, int asAscii)
{
memset(digest, 0, ctx->digestlen); /* In case it's sensitive */
free(digest);
}
+ memset(ctx->param, 0, ctx->paramlen); /* In case it's sensitive */
free(ctx->param);
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
free(ctx);
+ return 0;
}
#if HAVE_NETINET_IN_SYSTM_H
# include <sys/types.h>
+
+#if defined(__LCLINT__)
+/*@-redef@*/ /* FIX: rpmdb/db3.c also declares */
+typedef unsigned int u_int32_t;
+typedef unsigned short u_int16_t;
+typedef unsigned char u_int8_t;
+/*@-incondefs@*/ /* LCLint 3.0.0.15 */
+typedef int int32_t;
+/*@=incondefs@*/
+/*@=redef@*/
+#endif
+
# include <netinet/in_systm.h>
#endif
rc = read(fdFileno(fd), buf, (count > fd->bytesRemain ? fd->bytesRemain : count));
fdstat_exit(fd, FDSTAT_READ, rc);
- if (fd->digest && rc > 0) rpmDigestUpdate(fd->digest, buf, rc);
+ if (fd->digest && rc > 0) (void) rpmDigestUpdate(fd->digest, buf, rc);
/*@-modfilesys@*/
DBGIO(fd, (stderr, "==>\tfdRead(%p,%p,%ld) rc %ld %s\n", cookie, buf, (long)count, (long)rc, fdbg(fd)));
if (fd->bytesRemain == 0) return 0; /* XXX simulate EOF */
- if (fd->digest && count > 0) rpmDigestUpdate(fd->digest, buf, count);
+ if (fd->digest && count > 0) (void) rpmDigestUpdate(fd->digest, buf, count);
if (fd->wr_chunked) {
char chunksize[20];
} else if (rc >= 0) {
fdstat_exit(fd, FDSTAT_READ, rc);
/*@-compdef@*/
- if (fd->digest && rc > 0) rpmDigestUpdate(fd->digest, buf, rc);
+ if (fd->digest && rc > 0) (void) rpmDigestUpdate(fd->digest, buf, rc);
/*@=compdef@*/
}
return rc;
if (fd == NULL || fd->bytesRemain == 0) return 0; /* XXX simulate EOF */
- if (fd->digest && count > 0) rpmDigestUpdate(fd->digest, buf, count);
+ if (fd->digest && count > 0) (void) rpmDigestUpdate(fd->digest, buf, count);
gzfile = gzdFileno(fd);
fdstat_enter(fd, FDSTAT_WRITE);
} else if (rc >= 0) {
fdstat_exit(fd, FDSTAT_READ, rc);
/*@-compdef@*/
- if (fd->digest && rc > 0) rpmDigestUpdate(fd->digest, buf, rc);
+ if (fd->digest && rc > 0) (void) rpmDigestUpdate(fd->digest, buf, rc);
/*@=compdef@*/
}
return rc;
if (fd->bytesRemain == 0) return 0; /* XXX simulate EOF */
- if (fd->digest && count > 0) rpmDigestUpdate(fd->digest, buf, count);
+ if (fd->digest && count > 0) (void) rpmDigestUpdate(fd->digest, buf, count);
bzfile = bzdFileno(fd);
fdstat_enter(fd, FDSTAT_WRITE);
#include <rpmio.h>
#include <rpmurl.h>
+#include <rpmpgp.h>
/** \ingroup rpmio
*/
* Bit(s) to control digest operation.
*/
typedef enum rpmDigestFlags_e {
+ RPMDIGEST_NONE = 0,
+#ifdef DYING
RPMDIGEST_MD5 = (1 << 0), /*!< MD5 digest. */
RPMDIGEST_SHA1 = (1 << 1) /*!< SHA1 digest. */
-#ifdef DYING
RPMDIGEST_REVERSE = (1 << 16), /*!< Should bytes be reversed? */
RPMDIGEST_BCSWAP = (1 << 17), /*!< Should bit count be reversed? */
+#define RPMDIGEST_MASK 0xffff
#endif
} rpmDigestFlags;
-#define RPMDIGEST_MASK 0xffff
/**
*/
* @return digest context
*/
/*@only@*/
-DIGEST_CTX rpmDigestInit(rpmDigestFlags flags)
+DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
/*@*/;
/** \ingroup rpmio
* @param ctx digest context
* @param data next data buffer
* @param len no. bytes of data
+ * @return 0 on success
*/
-void rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
+int rpmDigestUpdate(DIGEST_CTX ctx, const void * data, size_t len)
/*@modifies ctx @*/;
/** \ingroup rpmio
* @retval datap address of returned digest
* @retval lenp address of digest length
* @param asAscii return digest as ascii string?
+ * @return 0 on success
*/
-void rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx,
+int rpmDigestFinal(/*@only@*/ DIGEST_CTX ctx,
/*@null@*/ /*@out@*/ void ** datap,
/*@null@*/ /*@out@*/ size_t * lenp, int asAscii)
/*@modifies *datap, *lenp @*/;
/** \ingroup rpmio
*/
/*@unused@*/ static inline
+void fdInitDigest(FD_t fd, pgpHashAlgo hashalgo, int flags)
+ /*@modifies fd @*/
+{
+ fd->digest = rpmDigestInit(hashalgo, flags);
+}
+
+/** \ingroup rpmio
+ */
+/*@unused@*/ static inline
+void fdFiniDigest(FD_t fd,
+ /*@null@*/ /*@out@*/ void ** datap,
+ /*@null@*/ /*@out@*/ size_t * lenp,
+ int asAscii)
+ /*@modifies fd, *datap, *lenp @*/
+{
+ if (fd->digest == NULL) {
+ if (datap) *datap = NULL;
+ if (lenp) *lenp = 0;
+ return;
+ }
+ /*@-mayaliasunique@*/
+ (void) rpmDigestFinal(fd->digest, datap, lenp, asAscii);
+ /*@=mayaliasunique@*/
+ fd->digest = NULL;
+}
+
+#ifdef DYING
+/** \ingroup rpmio
+ */
+/*@unused@*/ static inline
void fdInitMD5(FD_t fd, int flags)
/*@modifies fd @*/
{
#ifdef DYING
if (flags) flags = RPMDIGEST_REVERSE;
-#endif
flags |= RPMDIGEST_MD5;
- fd->digest = rpmDigestInit(flags);
+#endif
+ fd->digest = rpmDigestInit(PGPHASHALGO_MD5, flags);
}
/** \ingroup rpmio
{
#ifdef DYING
if (flags) flags = RPMDIGEST_REVERSE;
-#endif
flags |= RPMDIGEST_SHA1;
- fd->digest = rpmDigestInit(flags);
+#endif
+ fd->digest = rpmDigestInit(PGPHASHALGO_SHA1, flags);
}
/** \ingroup rpmio
return;
}
/*@-mayaliasunique@*/
- rpmDigestFinal(fd->digest, datap, lenp, asAscii);
+ (void) rpmDigestFinal(fd->digest, datap, lenp, asAscii);
/*@=mayaliasunique@*/
fd->digest = NULL;
}
return;
}
/*@-mayaliasunique@*/
- rpmDigestFinal(fd->digest, datap, lenp, asAscii);
+ (void) rpmDigestFinal(fd->digest, datap, lenp, asAscii);
/*@=mayaliasunique@*/
fd->digest = NULL;
}
+#endif
/*@-shadow@*/
/** \ingroup rpmio
#include "debug.h"
-static rpmDigestFlags flags = RPMDIGEST_MD5;
+static pgpHashAlgo hashalgo = PGPHASHALGO_MD5;
+static rpmDigestFlags flags = RPMDIGEST_NONE;
extern int _rpmio_debug;
static int fips = 0;
const char * FIPSCdigest = "34aa973cd4c4daa4f61eeb2bdbad27316534016f";
static struct poptOption optionsTable[] = {
- { "md5", '\0', POPT_BIT_SET, &flags, RPMDIGEST_MD5, NULL, NULL },
- { "sha1",'\0', POPT_BIT_SET, &flags, RPMDIGEST_SHA1, NULL, NULL },
+ { "md5", '\0', POPT_ARG_VAL, &hashalgo, PGPHASHALGO_MD5, NULL, NULL },
+ { "sha1",'\0', POPT_ARG_VAL, &hashalgo, PGPHASHALGO_SHA1, NULL, NULL },
#ifdef DYING
{ "reverse",'\0', POPT_BIT_SET, &flags, RPMDIGEST_REVERSE, NULL, NULL },
#endif
- { "fipsa",'\0', POPT_BIT_SET, &fips, 1, NULL, NULL },
- { "fipsb",'\0', POPT_BIT_SET, &fips, 2, NULL, NULL },
- { "fipsc",'\0', POPT_BIT_SET, &fips, 3, NULL, NULL },
+ { "fipsa",'\0', POPT_ARG_VAL, &fips, 1, NULL, NULL },
+ { "fipsb",'\0', POPT_ARG_VAL, &fips, 2, NULL, NULL },
+ { "fipsc",'\0', POPT_ARG_VAL, &fips, 3, NULL, NULL },
{ "debug",'d', POPT_ARG_VAL, &_rpmio_debug, -1, NULL, NULL },
POPT_AUTOHELP
POPT_TABLEEND
while ((rc = poptGetNextOpt(optCon)) > 0)
;
- if (flags & RPMDIGEST_SHA1) flags &= ~RPMDIGEST_MD5;
#ifdef DYING
reverse = (flags & RPMDIGEST_REVERSE);
#endif
if (fips) {
- flags &= ~RPMDIGEST_MD5;
- flags |= RPMDIGEST_SHA1;
- ctx = rpmDigestInit(flags);
+ ctx = rpmDigestInit(PGPHASHALGO_SHA1, flags);
ifn = NULL;
appendix = ' ';
sdigest = NULL;
se = buf;
*se = '\0';
- se = stpcpy(se, ((flags & RPMDIGEST_SHA1) ? SHA1_CMD : MD5_CMD));
+ se = stpcpy(se, ((hashalgo == PGPHASHALGO_SHA1) ? SHA1_CMD : MD5_CMD));
*se++ = ' ';
se = stpcpy(se, ifn);
if ((sfp = popen(buf, "r")) != NULL) {
continue;
}
idigest = NULL;
- (flags & RPMDIGEST_SHA1) ? fdInitSHA1(ifd, reverse) : fdInitMD5(ifd, reverse);
+ fdInitDigest(ifd, hashalgo, reverse);
ofd = Fopen(ofn, "w.ufdio");
if (ofd == NULL || Ferror(ofd)) {
continue;
}
odigest = NULL;
- (flags & RPMDIGEST_SHA1) ? fdInitSHA1(ofd, reverse) : fdInitMD5(ofd, reverse);
+ fdInitDigest(ofd, hashalgo, reverse);
- ctx = rpmDigestInit(flags);
+ ctx = rpmDigestInit(hashalgo, flags);
while ((nb = Fread(buf, 1, sizeof(buf), ifd)) > 0) {
rpmDigestUpdate(ctx, buf, nb);
(void) Fwrite(buf, 1, nb, ofd);
}
- (flags & RPMDIGEST_SHA1)
- ? fdFiniSHA1(ifd, (void **)&idigest, NULL, asAscii)
- : fdFiniMD5(ifd, (void **)&idigest, NULL, asAscii);
+ fdFiniDigest(ifd, (void **)&idigest, NULL, asAscii);
Fclose(ifd);
Fflush(ofd);
- (flags & RPMDIGEST_SHA1)
- ? fdFiniSHA1(ofd, (void **)&odigest, NULL, asAscii)
- : fdFiniMD5(ofd, (void **)&odigest, NULL, asAscii);
+ fdFiniDigest(ofd, (void **)&odigest, NULL, asAscii);
Fclose(ofd);
rpmDigestFinal(ctx, (void **)&digest, &digestlen, asAscii);
if ((rc = doit(abcSignatureDSA, dig, printing)) != 0)
fprintf(stderr, "==> FAILED: rc %d\n", rc);
- { DIGEST_CTX ctx = rpmDigestInit(RPMDIGEST_SHA1);
+ { DIGEST_CTX ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
const char * digest = NULL;
size_t digestlen = 0;
const char * txt = "abc";
- ctx = rpmDigestInit(RPMDIGEST_SHA1);
-
rpmDigestUpdate(ctx, txt, strlen(txt));
rpmDigestUpdate(ctx, &dig->sig.v3.sigtype, dig->sig.v3.hashlen);
rpmDigestFinal(ctx, (void **)&digest, &digestlen, 1);