1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-29 07:42:06 +01:00

Fix NPE when sop generate-key --with-key-password is used with multiple uids

Fixes #351
This commit is contained in:
Paul Schaub 2022-12-15 12:25:35 +01:00
parent 980daeca31
commit 3b2d0795f7
2 changed files with 4 additions and 1 deletions

View file

@ -7,6 +7,8 @@ SPDX-License-Identifier: CC0-1.0
## 1.4.2-SNAPSHOT ## 1.4.2-SNAPSHOT
- Properly decrypt messages without MDC packets when `ConsumerOptions.setIgnoreMDCErrors(true)` is set - Properly decrypt messages without MDC packets when `ConsumerOptions.setIgnoreMDCErrors(true)` is set
- Fix crash in `sop generate-key --with-key-password` when more than one user-id is given
## 1.4.1 ## 1.4.1
- Add `UserId.parse()` method to parse user-ids into their components - Add `UserId.parse()` method to parse user-ids into their components

View file

@ -51,6 +51,7 @@ public class GenerateKeyImpl implements GenerateKey {
@Override @Override
public Ready generate() throws SOPGPException.MissingArg, SOPGPException.UnsupportedAsymmetricAlgo { public Ready generate() throws SOPGPException.MissingArg, SOPGPException.UnsupportedAsymmetricAlgo {
Iterator<String> userIdIterator = userIds.iterator(); Iterator<String> userIdIterator = userIds.iterator();
Passphrase passphraseCopy = new Passphrase(passphrase.getChars()); // generateKeyRing clears the original passphrase
PGPSecretKeyRing key; PGPSecretKeyRing key;
try { try {
String primaryUserId = userIdIterator.hasNext() ? userIdIterator.next() : null; String primaryUserId = userIdIterator.hasNext() ? userIdIterator.next() : null;
@ -61,7 +62,7 @@ public class GenerateKeyImpl implements GenerateKey {
SecretKeyRingEditorInterface editor = PGPainless.modifyKeyRing(key); SecretKeyRingEditorInterface editor = PGPainless.modifyKeyRing(key);
while (userIdIterator.hasNext()) { while (userIdIterator.hasNext()) {
editor.addUserId(userIdIterator.next(), SecretKeyRingProtector.unprotectedKeys()); editor.addUserId(userIdIterator.next(), SecretKeyRingProtector.unlockAnyKeyWith(passphraseCopy));
} }
key = editor.done(); key = editor.done();