- avoid several copies of the same thing...
- there are valid reasons for wanting to know header magic outside librpm,
export it as rpm_header_magic
/** \ingroup header
*/
-static unsigned char const header_magic[8] = {
+const unsigned char rpm_header_magic[8] = {
0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
};
switch (magicp) {
case HEADER_MAGIC_YES:
- size += sizeof(header_magic);
+ size += sizeof(rpm_header_magic);
break;
case HEADER_MAGIC_NO:
break;
if (magicp == HEADER_MAGIC_YES) {
magic = block[i++];
- if (memcmp(&magic, header_magic, sizeof(magic)))
+ if (memcmp(&magic, rpm_header_magic, sizeof(magic)))
goto exit;
reserved = block[i++];
}
return 1;
switch (magicp) {
case HEADER_MAGIC_YES:
- nb = Fwrite(header_magic, sizeof(char), sizeof(header_magic), fd);
- if (nb != sizeof(header_magic))
+ nb = Fwrite(rpm_header_magic, sizeof(uint8_t), sizeof(rpm_header_magic), fd);
+ if (nb != sizeof(rpm_header_magic))
goto exit;
break;
case HEADER_MAGIC_NO:
extern "C" {
#endif
+/** \ingroup header
+ * Header magic value
+ */
+extern const unsigned char rpm_header_magic[8];
+
/** \ingroup header
* Include calculation for 8 bytes of (magic, 0)?
*/
static unsigned int nextkeyid = 0;
static unsigned int * keyids;
-/* XXX FIXME: these are doubled here and header.c and .. */
-static unsigned char const header_magic[8] = {
- 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
-};
-
void headerMergeLegacySigs(Header h, const Header sigh)
{
HeaderIterator hi;
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DIGEST), 0);
dig->hdrmd5ctx = rpmDigestInit(dig->signature.hash_algo, RPMDIGEST_NONE);
- b = (unsigned char *) header_magic;
- nb = sizeof(header_magic);
+ b = (unsigned char *) rpm_header_magic;
+ nb = sizeof(rpm_header_magic);
(void) rpmDigestUpdate(dig->hdrmd5ctx, b, nb);
dig->nbytes += nb;
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DIGEST), 0);
dig->hdrsha1ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
- b = (unsigned char *) header_magic;
- nb = sizeof(header_magic);
+ b = (unsigned char *) rpm_header_magic;
+ nb = sizeof(rpm_header_magic);
(void) rpmDigestUpdate(dig->hdrsha1ctx, b, nb);
dig->nbytes += nb;
_("hdr size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx);
goto exit;
}
- if (memcmp(block, header_magic, sizeof(header_magic))) {
+ if (memcmp(block, rpm_header_magic, sizeof(rpm_header_magic))) {
rasprintf(&buf, _("hdr magic: BAD\n"));
goto exit;
}
break;
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DIGEST), 0);
dig->hdrmd5ctx = rpmDigestInit(dig->signature.hash_algo, RPMDIGEST_NONE);
- (void) rpmDigestUpdate(dig->hdrmd5ctx, header_magic, sizeof(header_magic));
- dig->nbytes += sizeof(header_magic);
+ (void) rpmDigestUpdate(dig->hdrmd5ctx, rpm_header_magic, sizeof(rpm_header_magic));
+ dig->nbytes += sizeof(rpm_header_magic);
(void) rpmDigestUpdate(dig->hdrmd5ctx, utd.data, utd.count);
dig->nbytes += utd.count;
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_DIGEST), dig->nbytes);
break;
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_DIGEST), 0);
dig->hdrsha1ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
- (void) rpmDigestUpdate(dig->hdrsha1ctx, header_magic, sizeof(header_magic));
- dig->nbytes += sizeof(header_magic);
+ (void) rpmDigestUpdate(dig->hdrsha1ctx, rpm_header_magic, sizeof(rpm_header_magic));
+ dig->nbytes += sizeof(rpm_header_magic);
(void) rpmDigestUpdate(dig->hdrsha1ctx, utd.data, utd.count);
dig->nbytes += utd.count;
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_DIGEST), dig->nbytes);
return res;
}
-static unsigned char const header_magic[8] = {
- 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
-};
-
/**
* @todo If the GPG key was known available, the md5 digest could be skipped.
*/
goto exit;
}
dig->hdrsha1ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
- (void) rpmDigestUpdate(dig->hdrsha1ctx, header_magic, sizeof(header_magic));
+ (void) rpmDigestUpdate(dig->hdrsha1ctx, rpm_header_magic, sizeof(rpm_header_magic));
(void) rpmDigestUpdate(dig->hdrsha1ctx, utd.data, utd.count);
dig->hdrmd5ctx = rpmDigestInit(dig->signature.hash_algo, RPMDIGEST_NONE);
- (void) rpmDigestUpdate(dig->hdrmd5ctx, header_magic, sizeof(header_magic));
+ (void) rpmDigestUpdate(dig->hdrmd5ctx, rpm_header_magic, sizeof(rpm_header_magic));
(void) rpmDigestUpdate(dig->hdrmd5ctx, utd.data, utd.count);
rpmtdFreeData(&utd);
}
return RPMRC_OK;
}
-/* XXX sigh yet another duplicate.. */
-static unsigned char const header_magic[8] = {
- 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
-};
-
rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg)
{
char *buf = NULL;
(int)sizeof(block), xx);
goto exit;
}
- if (memcmp(block, header_magic, sizeof(header_magic))) {
+ if (memcmp(block, rpm_header_magic, sizeof(rpm_header_magic))) {
rasprintf(&buf, _("sigh magic: BAD\n"));
goto exit;
}
goto exit;
}
ctx = rpmDigestInit(PGPHASHALGO_SHA1, RPMDIGEST_NONE);
- (void) rpmDigestUpdate(ctx, header_magic, sizeof(header_magic));
+ (void) rpmDigestUpdate(ctx, rpm_header_magic, sizeof(rpm_header_magic));
(void) rpmDigestUpdate(ctx, utd.data, utd.count);
(void) rpmDigestFinal(ctx, (void **)&SHA1, NULL, 1);
rpmtdFreeData(&utd);