Skip to content

Commit

Permalink
Temporarily add support for GOST algorithms for RPM5->RPM4 transition
Browse files Browse the repository at this point in the history
Temporarily use the same OIDs for GOST as we used in RPM 5 to ensure RPM 5
is able to install those packages from rpm5 to boostrap rosa2019.05 based on
packages from rosa2019.0.

This needs to be reworked before upstream inclusion.

Cf. rpm-software-management#1082
  • Loading branch information
mikhailnov committed Oct 11, 2020
1 parent d61ef24 commit 1593b04
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,11 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc)
rpmlibNeedsFeature(pkg, "FileDigests", "4.6.0-1");
}

if (digestalgo == PGPHASHALGO_GOST12_256 || digestalgo == PGPHASHALGO_GOST12_512) {
headerPutUint32(h, RPMTAG_FILEDIGESTALGO, &digestalgo, 1);
rpmlibNeedsFeature(pkg, "FileDigestsGOST12", "4.15.0-1");
}

if (fl->haveCaps) {
rpmlibNeedsFeature(pkg, "FileCaps", "4.6.1-1");
}
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ if test "$with_crypto" = libgcrypt ; then
AC_MSG_ERROR([libgcrypt not found])
fi
fi
AC_DEFINE(WITH_LIBGCRYPT, 1, [Build with libgcrypt?])
fi

AM_CONDITIONAL([WITH_LIBGCRYPT],[test "$with_crypto" = libgcrypt])
Expand Down
11 changes: 11 additions & 0 deletions lib/rpmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,17 @@ static const struct rpmlibProvides_s rpmlibProvides[] = {
{ "rpmlib(FileDigests)", "4.6.0-1",
( RPMSENSE_EQUAL),
N_("file digest algorithm is per package configurable") },
#ifdef WITH_LIBGCRYPT
/*
* As rpmlib(FileDigestsGOST12) is available only when RPM is built with libcgrypt,
* to avoid other versions of RPM from misunderatanding hashes
* (see e.g. https://github.com/rpm-software-management/rpm/issues/959),
* require FileDigestsGOST12 separately
*/
{ "rpmlib(FileDigestsGOST12)", "4.15.0-1",
( RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
N_("file digest can be GOST R 34.11 2012 (STREEBOG256, STREEBOG512)") },
#endif
#ifdef WITH_CAP
{ "rpmlib(FileCaps)", "4.6.1-1",
( RPMSENSE_EQUAL),
Expand Down
6 changes: 6 additions & 0 deletions rpmio/digest_libgcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ size_t rpmDigestLength(int hashalgo)
return 20;
case PGPHASHALGO_SHA224:
return 28;
case PGPHASHALGO_GOST12_256:
case PGPHASHALGO_SHA256:
return 32;
case PGPHASHALGO_SHA384:
return 48;
case PGPHASHALGO_GOST12_512:
case PGPHASHALGO_SHA512:
return 64;
default:
Expand All @@ -66,6 +68,10 @@ static int hashalgo2gcryalgo(int hashalgo)
return GCRY_MD_SHA384;
case PGPHASHALGO_SHA512:
return GCRY_MD_SHA512;
case PGPHASHALGO_GOST12_256:
return GCRY_MD_STRIBOG256;
case PGPHASHALGO_GOST12_512:
return GCRY_MD_STRIBOG512;
default:
return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions rpmio/rpmpgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ static struct pgpValTbl_s const pgpHashTbl[] = {
{ PGPHASHALGO_SHA384, "SHA384" },
{ PGPHASHALGO_SHA512, "SHA512" },
{ PGPHASHALGO_SHA224, "SHA224" },
{ PGPHASHALGO_GOST12_256, "MD_GOST12_256" },
{ PGPHASHALGO_GOST12_512, "MD_GOST12_512" },
{ -1, "Unknown hash algorithm" },
};

Expand Down
2 changes: 2 additions & 0 deletions rpmio/rpmpgp.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ typedef enum pgpHashAlgo_e {
PGPHASHALGO_SHA384 = 9, /*!< SHA384 */
PGPHASHALGO_SHA512 = 10, /*!< SHA512 */
PGPHASHALGO_SHA224 = 11, /*!< SHA224 */
PGPHASHALGO_GOST12_256 = 99, /*!< GOST R 34.11-2012 256 */
PGPHASHALGO_GOST12_512 = 100, /*!< GOST R 34.11-2012 512 */
} pgpHashAlgo;

/** \ingroup rpmpgp
Expand Down
2 changes: 2 additions & 0 deletions sign/rpmsignfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ static const char *hash_algo_name[] = {
[PGPHASHALGO_SHA384] = "sha384",
[PGPHASHALGO_SHA512] = "sha512",
[PGPHASHALGO_SHA224] = "sha224",
[PGPHASHALGO_GOST12_256] = "streebog256",
[PGPHASHALGO_GOST12_512] = "streebog512",
};

#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
Expand Down

0 comments on commit 1593b04

Please sign in to comment.