FileListRec flp;
char buf[BUFSIZ];
int i;
+ pgpHashAlgo defaultalgo = PGPHASHALGO_MD5, digestalgo;
+
+ /*
+ * See if non-md5 file checksum algorithm is requested. If not
+ * specified, quietly assume md5. Otherwise check if supported type.
+ */
+ digestalgo = rpmExpandNumeric(isSrc ? "%{_source_filedigest_algorithm}" :
+ "%{_binary_filedigest_algorithm}");
+ if (digestalgo == 0) {
+ digestalgo = defaultalgo;
+ }
+
+ if (rpmDigestLength(digestalgo) == 0) {
+ rpmlog(RPMLOG_WARNING,
+ _("Unknown file digest algorithm %u, falling back to MD5\n"),
+ digestalgo);
+ digestalgo = defaultalgo;
+ }
/* Sort the big list */
qsort(fl->fileList, fl->fileListRecsUsed,
buf[0] = '\0';
if (S_ISREG(flp->fl_mode))
- (void) rpmDoDigest(PGPHASHALGO_MD5, flp->diskPath, 1,
+ (void) rpmDoDigest(digestalgo, flp->diskPath, 1,
(unsigned char *)buf, NULL);
s = buf;
(void) headerAddOrAppendEntry(h, RPMTAG_FILEDIGESTS,
(void) headerAddEntry(h, RPMTAG_SIZE, RPM_INT32_TYPE,
&(fl->totalFileSize), 1);
+ if (digestalgo != defaultalgo) {
+ headerAddEntry(h, RPMTAG_FILEDIGESTALGO, RPM_INT32_TYPE,
+ &digestalgo, 1);
+ rpmlibNeedsFeature(h, "FileDigests", "4.4.90-1");
+ }
+
if (_addDotSlash)
(void) rpmlibNeedsFeature(h, "PayloadFilesHavePrefix", "4.0-1");
#%_source_payload w9.gzdio
#%_binary_payload w9.gzdio
+# Algorithm to use for generating file checksum digests on build.
+# If not specified or 0, MD5 is used.
+# WARNING: non-MD5 is backwards incompatible, don't enable lightly!
+# The supported algorithms may depend on NSS version, as of NSS
+# 3.11.99.5 the following are supported:
+# 1 MD5 (default)
+# 2 SHA1
+# 8 SHA256
+# 9 SHA384
+# 10 SHA512
+#
+#%_source_filedigest_algorithm 1
+#%_binary_filedigest_algorithm 1
+
# The signature to use and the location of configuration files for
# signing packages with PGP.
#