rpmfileState fstate;
rpm_off_t fsize;
const char * fn;
- char fmd5[32+1];
+ char *fmd5;
const char * fuser;
const char * fgroup;
const char * flink;
fstate = rpmfiFState(fi);
fsize = rpmfiFSize(fi);
fn = rpmfiFN(fi);
- { static char const hex[] = "0123456789abcdef";
- unsigned const char * s = rpmfiMD5(fi);
- char * p = fmd5;
- int j;
- for (j = 0; j < 16; j++) {
- unsigned k = *s++;
- *p++ = hex[ (k >> 4) & 0xf ];
- *p++ = hex[ (k ) & 0xf ];
- }
- *p = '\0';
- }
+ fmd5 = pgpHexStr(rpmfiMD5(fi), rpmDigestLength(PGPHASHALGO_MD5));
fuser = rpmfiFUser(fi);
fgroup = rpmfiFGroup(fi);
flink = rpmfiFLink(fi);
}
}
flushBuffer(&t, &te, 0);
+ free(fmd5);
}
rc = 0;
#include "system.h"
#include <rpm/rpmtag.h>
+#include <rpm/rpmpgp.h>
#include "header-py.h"
#include "rpmfi-py.h"
int VFlags = rpmfiVFlags(s->fi);
const char * FUser = rpmfiFUser(s->fi);
const char * FGroup = rpmfiFGroup(s->fi);
- const unsigned char * MD5 = rpmfiMD5(s->fi), *s = MD5;
- char FMD5[2*16+1], *t = FMD5;
- static const char hex[] = "0123456789abcdef";
- int gotMD5, i;
-
- gotMD5 = 0;
- if (s)
- for (i = 0; i < 16; i++) {
- gotMD5 |= *s;
- *t++ = hex[ (*s >> 4) & 0xf ];
- *t++ = hex[ (*s++ ) & 0xf ];
- }
- *t = '\0';
+ const unsigned char * MD5 = rpmfiMD5(s->fi);
+ char *FMD5 = NULL;
+
+ if (MD5)
+ FMD5 = pgpHexStr(MD5, rpmDigestLength(PGPHASHALGO_MD5));
result = PyTuple_New(13);
if (FN == NULL) {
PyTuple_SET_ITEM(result, 11, Py_None);
} else
PyTuple_SET_ITEM(result, 11, Py_BuildValue("s", FGroup));
- if (!gotMD5) {
+ if (!FMD5) {
Py_INCREF(Py_None);
PyTuple_SET_ITEM(result, 12, Py_None);
} else
#include <rpm/rpmtag.h>
#include <rpm/rpmstring.h>
+#include <rpm/rpmpgp.h>
#include "rpmdb/header_internal.h"
#include "debug.h"
if (val) {
need = strlen(val);
} else {
- val = bin2hex(data, count);
+ val = pgpHexStr(data, count);
need = strlen(val) + tag->pad;
}
break;
}
}
-char * bin2hex(const char *data, size_t size)
-{
- static char const hex[] = "0123456789abcdef";
- const char * s = data;
- char * t, * val;
- val = t = xmalloc(size * 2 + 1);
- while (size-- > 0) {
- unsigned int i;
- i = *s++;
- *t++ = hex[ (i >> 4) & 0xf ];
- *t++ = hex[ (i ) & 0xf ];
- }
- *t = '\0';
-
- return val;
-}
-
-
const struct headerTagTableEntry_s * tags);
#define HEADER_DUMP_INLINE 1
-/** \ingroup header
- * Convert binary blob to printable hex string
- * @param[in] data binary data
- * @param[in] count size of data in bytes
- */
-char * bin2hex(const char *data, size_t count);
-
#ifdef __cplusplus
}
#endif
break;
case RPM_BIN_TYPE:
{
- char * str = bin2hex((const char*) u.ptr, c);
+ char * str = pgpHexStr((const unsigned char*) u.ptr, c);
rc = miregexec(mire, str);
if ((!rc && !mire->notmatch) || (rc && mire->notmatch))
anymatch++;
rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
{
unsigned char * digest;
- char * t;
- size_t i;
size_t digestlen;
if (ctx == NULL)
if (lenp) *lenp = (2*digestlen) + 1;
if (datap) {
const uint8_t * s = (const uint8_t *) digest;
- static const char const hex[] = "0123456789abcdef";
-
- *datap = t = xmalloc((2*digestlen) + 1);
- for (i = 0 ; i < digestlen; i++) {
- *t++ = hex[ (unsigned)((*s >> 4) & 0x0f) ];
- *t++ = hex[ (unsigned)((*s++ ) & 0x0f) ];
- }
- *t = '\0';
+ *datap = pgpHexStr(s, digestlen);
}
}
if (digest) {