Skip to contentSkip to conversation

rpm selftests: use sha256 keys

PATCH New Adam Duskett 1 participant 2 messages Dec 3, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rpm selftests: use sha256 keys

rpm selftests: use sha256 keys
Starting with RHEL9, the SHA-1 algorithm for signatures in general and RPM package signatures specifically has been deprecated. [1]

As such, Yocto should follow suit and replace the ancient selftest signing keys which are currently SHA1 with sequoia-compatible sha256 RSA4096 keys.

If someone runs sq inspect ./key.secret the output shows:

```
Invalid: No binding signature at time 2025-12-02T14:15:19Z: Policy rejected
non-revocation signature (PositiveCertification) requiring second pre-image
resistance, because SHA1 is not considered secure
```

And while there are instructions on how to update SHA1 key files to SHA256[2], unfortuantly, the key files are 10 years old and gnupg refuses to update them.

As such, do the following:

- Add use_sha256=True to the detach_sign call in

     meta/lib/oe/package_manager/rpm/__init__.py.

- Add new keys in meta-selftest/files/signing/ with RSA4096 encryption and SHA256.

The keys are generated with almost the same parameters as commit 6b9d22b:

gpg gpg --expert --full-generate-key the used input was:
- key: (8) RSA (set your own capabilities)
- key-size: 4096
- key-valid: 0
- Real Name: testuser
- Email address: [email protected]
- Comment: nocomment
- passphrase: test123

The public key and secret were then exported in armor format:

```
gpg --armor --export "$KEYID" > key.pub
gpg --output key.secret --armor --export-secret-key "$KEYID"
```

The output of sq inspect key.secret now shows a valid key:

```
key.secret: Transferable Secret Key.

      Fingerprint: A4C381E481817E16C5E41B6A2B910A1E01AF84DE
  Public-key algo: RSA
  Public-key size: 4096 bits
       Secret key: Encrypted
    Creation time: 2025-12-02 09:13:05 UTC
        Key flags: certification, signing, transport encryption, data-at-rest encryption

           UserID: testuser (nocomment) <[email protected]
```

In addition, add a gpg.batch file in case anyone else in the future needs to regenerate the keys.

1: https://www.redhat.com/en/blog/rhel-security-sha-1-package-signatures-distrusted-rhel-9
2: https://www.redhat.com/en/blog/updating-gpg-keys-for-fedora-and-rhel

---
 meta-selftest/files/signing/gpg.batch       |  10 ++
 meta-selftest/files/signing/key.pub         |  53 +++++-----
 meta-selftest/files/signing/key.secret      | 110 ++++++++++----------
 meta/lib/oe/package_manager/rpm/__init__.py |   3 +-
 4 files changed, 92 insertions(+), 84 deletions(-)
 create mode 100644 meta-selftest/files/signing/gpg.batch
meta-selftest/files/signing/gpg.batch new file +10 -0
new file mode 100644
index 0000000000..a6642a2055
@@ -0,0 +1,10 @@
+%echo Generating test signing GPG Keys
+Key-Type: RSA
+Key-Length: 4096
+Name-Real: testuser
+Name-Email: [email protected]
+Name-Comment: nocomment
+Expire-Date: 0
+passphrase: test123
+%commit
+%echo done
meta-selftest/files/signing/key.pub +26 -27

56 lines not on this page · raw message

meta-selftest/files/signing/key.secret +54 -56

113 lines not on this page · raw message

meta/lib/oe/package_manager/rpm/__init__.py +2 -1
index a51057650a..fcd2e0ee6c 100644
@@ -30,7 +30,8 @@ class RpmIndexer(Indexer):
             signer.detach_sign(os.path.join(deploy_dir, 'repodata', 'repomd.xml'),
                                self.d.getVar('PACKAGE_FEED_GPG_NAME'),
                                self.d.getVar('PACKAGE_FEED_GPG_PASSPHRASE_FILE'),
-                               armor=is_ascii_sig)
+                               armor=is_ascii_sig,
+                               use_sha256=True)
 
 class RpmSubdirIndexer(RpmIndexer):
     def write_index(self):
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/1 rpm selftests: use sha256 keys

rpm selftests: use sha256 keys
Starting with RHEL9, the SHA-1 algorithm for signatures in general and RPM package signatures specifically has been deprecated. [1]

As such, Yocto should follow suit and replace the ancient selftest signing keys which are currently SHA1 with sequoia-compatible sha256 RSA4096 keys.

If someone runs sq inspect ./key.secret the output shows:

```
Invalid: No binding signature at time 2025-12-02T14:15:19Z: Policy rejected
non-revocation signature (PositiveCertification) requiring second pre-image
resistance, because SHA1 is not considered secure
```

And while there are instructions on how to update SHA1 key files to SHA256[2], unfortuantly, the key files are 10 years old and gnupg refuses to update them.

As such, do the following:

- Add use_sha256=True to the detach_sign call in

     meta/lib/oe/package_manager/rpm/__init__.py.

- Add new keys in meta-selftest/files/signing/ with RSA4096 encryption and SHA256.

The keys are generated with almost the same parameters as commit 6b9d22b:

gpg gpg --expert --full-generate-key the used input was:
- key: (8) RSA (set your own capabilities)
- key-size: 4096
- key-valid: 0
- Real Name: testuser
- Email address: [email protected]
- Comment: nocomment
- passphrase: test123

The public key and secret were then exported in armor format:

```
gpg --armor --export "$KEYID" > key.pub
gpg --output key.secret --armor --export-secret-key "$KEYID"
```

The output of sq inspect key.secret now shows a valid key:

```
key.secret: Transferable Secret Key.

      Fingerprint: A4C381E481817E16C5E41B6A2B910A1E01AF84DE
  Public-key algo: RSA
  Public-key size: 4096 bits
       Secret key: Encrypted
    Creation time: 2025-12-02 09:13:05 UTC
        Key flags: certification, signing, transport encryption, data-at-rest encryption

           UserID: testuser (nocomment) <[email protected]
```

In addition, add a gpg.batch file in case anyone else in the future needs to regenerate the keys.

1: https://www.redhat.com/en/blog/rhel-security-sha-1-package-signatures-distrusted-rhel-9
2: https://www.redhat.com/en/blog/updating-gpg-keys-for-fedora-and-rhel

---
 meta-selftest/files/signing/gpg.batch       |  10 ++
 meta-selftest/files/signing/key.pub         |  53 +++++-----
 meta-selftest/files/signing/key.secret      | 110 ++++++++++----------
 meta/lib/oe/package_manager/rpm/__init__.py |   3 +-
 4 files changed, 92 insertions(+), 84 deletions(-)
 create mode 100644 meta-selftest/files/signing/gpg.batch
meta-selftest/files/signing/gpg.batch new file +10 -0
new file mode 100644
index 0000000000..a6642a2055
@@ -0,0 +1,10 @@
+%echo Generating test signing GPG Keys
+Key-Type: RSA
+Key-Length: 4096
+Name-Real: testuser
+Name-Email: [email protected]
+Name-Comment: nocomment
+Expire-Date: 0
+passphrase: test123
+%commit
+%echo done
meta-selftest/files/signing/key.pub +26 -27

56 lines not on this page · raw message

meta-selftest/files/signing/key.secret +54 -56

113 lines not on this page · raw message

meta/lib/oe/package_manager/rpm/__init__.py +2 -1
index a51057650a..fcd2e0ee6c 100644
@@ -30,7 +30,8 @@ class RpmIndexer(Indexer):
             signer.detach_sign(os.path.join(deploy_dir, 'repodata', 'repomd.xml'),
                                self.d.getVar('PACKAGE_FEED_GPG_NAME'),
                                self.d.getVar('PACKAGE_FEED_GPG_PASSPHRASE_FILE'),
-                               armor=is_ascii_sig)
+                               armor=is_ascii_sig,
+                               use_sha256=True)
 
 class RpmSubdirIndexer(RpmIndexer):
     def write_index(self):
Signature · 1 line
2.52.0