1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-26 12:58:02 +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
- 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
- Add `UserId.parse()` method to parse user-ids into their components

View file

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