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 43a29729ad
commit 05ae631a12
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
2 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,9 @@ SPDX-License-Identifier: CC0-1.0
# PGPainless Changelog
## 1.3.15-SNAPSHOT
- Fix crash in `sop generate-key --with-key-password` when more then one user-id is given
## 1.3.14
- Bump `bcpg` to `1.72.3`
- Fix DSA key parameter check

View File

@ -55,6 +55,7 @@ public class GenerateKeyImpl implements GenerateKey {
throw new SOPGPException.MissingArg("Missing user-id.");
}
Passphrase passphraseCopy = new Passphrase(passphrase.getChars()); // generateKeyRing clears the original passphrase
PGPSecretKeyRing key;
try {
key = PGPainless.generateKeyRing()
@ -64,7 +65,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();