mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-10 22:31:09 +01:00
Fix: Respect user requested keyflags when adding a subkey.
This commit is contained in:
parent
8fffa3079a
commit
548bfff93f
4 changed files with 18 additions and 4 deletions
|
|
@ -42,7 +42,7 @@ public class KeySpec {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
PGPSignatureSubpacketVector getSubpackets() {
|
||||
public PGPSignatureSubpacketVector getSubpackets() {
|
||||
return subpacketGenerator != null ? subpacketGenerator.generate() : null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -167,12 +167,16 @@ public class SecretKeyRingEditor implements SecretKeyRingEditorInterface {
|
|||
PGPSecretKey secretSubKey = generateSubKey(keySpec, subKeyPassphrase);
|
||||
SecretKeyRingProtector subKeyProtector = PasswordBasedSecretKeyRingProtector
|
||||
.forKey(secretSubKey, subKeyPassphrase);
|
||||
PGPSignatureSubpacketVector hashedSubpackets = keySpec.getSubpackets();
|
||||
PGPSignatureSubpacketVector unhashedSubpackets = null;
|
||||
|
||||
return addSubKey(secretSubKey, subKeyProtector, secretKeyRingProtector);
|
||||
return addSubKey(secretSubKey, hashedSubpackets, unhashedSubpackets, subKeyProtector, secretKeyRingProtector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecretKeyRingEditorInterface addSubKey(PGPSecretKey secretSubKey,
|
||||
PGPSignatureSubpacketVector hashedSubpackets,
|
||||
PGPSignatureSubpacketVector unhashedSubpackets,
|
||||
SecretKeyRingProtector subKeyProtector,
|
||||
SecretKeyRingProtector keyRingProtector)
|
||||
throws PGPException {
|
||||
|
|
@ -196,7 +200,7 @@ public class SecretKeyRingEditor implements SecretKeyRingEditorInterface {
|
|||
PGPKeyRingGenerator keyRingGenerator = new PGPKeyRingGenerator(
|
||||
secretKeyRing, ringDecryptor, digestCalculator, contentSignerBuilder, subKeyEncryptor);
|
||||
|
||||
keyRingGenerator.addSubKey(subKeyPair);
|
||||
keyRingGenerator.addSubKey(subKeyPair, hashedSubpackets, unhashedSubpackets);
|
||||
secretKeyRing = keyRingGenerator.generateSecretKeyRing();
|
||||
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.openpgp.PGPSignatureSubpacketVector;
|
||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
import org.pgpainless.key.generation.KeySpec;
|
||||
import org.pgpainless.key.protection.KeyRingProtectionSettings;
|
||||
|
|
@ -99,7 +100,10 @@ public interface SecretKeyRingEditorInterface {
|
|||
SecretKeyRingProtector secretKeyRingProtector)
|
||||
throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException;
|
||||
|
||||
SecretKeyRingEditorInterface addSubKey(PGPSecretKey subKey, SecretKeyRingProtector subKeyProtector, SecretKeyRingProtector keyRingProtector)
|
||||
SecretKeyRingEditorInterface addSubKey(PGPSecretKey subKey,
|
||||
PGPSignatureSubpacketVector hashedSubpackets,
|
||||
PGPSignatureSubpacketVector unhashedSubpackets,
|
||||
SecretKeyRingProtector subKeyProtector, SecretKeyRingProtector keyRingProtector)
|
||||
throws PGPException;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue