mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-09 18:29:39 +02:00
Fix addSubkey method
This commit is contained in:
parent
b61ba46d24
commit
0fc9ee716e
1 changed files with 10 additions and 2 deletions
|
@ -12,7 +12,9 @@ import openpgp.openPgpKeyId
|
||||||
import org.bouncycastle.bcpg.KeyIdentifier
|
import org.bouncycastle.bcpg.KeyIdentifier
|
||||||
import org.bouncycastle.bcpg.sig.KeyExpirationTime
|
import org.bouncycastle.bcpg.sig.KeyExpirationTime
|
||||||
import org.bouncycastle.openpgp.*
|
import org.bouncycastle.openpgp.*
|
||||||
|
import org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPSubkey
|
||||||
import org.bouncycastle.openpgp.api.OpenPGPKey
|
import org.bouncycastle.openpgp.api.OpenPGPKey
|
||||||
|
import org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPSecretKey
|
||||||
import org.bouncycastle.openpgp.api.OpenPGPSignature
|
import org.bouncycastle.openpgp.api.OpenPGPSignature
|
||||||
import org.pgpainless.PGPainless
|
import org.pgpainless.PGPainless
|
||||||
import org.pgpainless.PGPainless.Companion.inspectKeyRing
|
import org.pgpainless.PGPainless.Companion.inspectKeyRing
|
||||||
|
@ -302,6 +304,13 @@ class SecretKeyRingEditor(var key: OpenPGPKey, override val referenceTime: Date
|
||||||
ImplementationFactory.getInstance().v4FingerprintCalculator,
|
ImplementationFactory.getInstance().v4FingerprintCalculator,
|
||||||
false,
|
false,
|
||||||
subkeyProtector.getEncryptor(subkey.keyID))
|
subkeyProtector.getEncryptor(subkey.keyID))
|
||||||
|
|
||||||
|
val componentKey =
|
||||||
|
OpenPGPSecretKey(
|
||||||
|
OpenPGPSubkey(subkey.publicKey, key),
|
||||||
|
secretSubkey,
|
||||||
|
PGPainless.getInstance().implementation.pbeSecretKeyDecryptorBuilderProvider())
|
||||||
|
|
||||||
val skBindingBuilder =
|
val skBindingBuilder =
|
||||||
SubkeyBindingSignatureBuilder(key.primarySecretKey, primaryKeyProtector, hashAlgorithm)
|
SubkeyBindingSignatureBuilder(key.primarySecretKey, primaryKeyProtector, hashAlgorithm)
|
||||||
skBindingBuilder.apply {
|
skBindingBuilder.apply {
|
||||||
|
@ -309,8 +318,7 @@ class SecretKeyRingEditor(var key: OpenPGPKey, override val referenceTime: Date
|
||||||
hashedSubpackets.setKeyFlags(flags)
|
hashedSubpackets.setKeyFlags(flags)
|
||||||
if (subkeyAlgorithm.isSigningCapable()) {
|
if (subkeyAlgorithm.isSigningCapable()) {
|
||||||
val pkBindingBuilder =
|
val pkBindingBuilder =
|
||||||
PrimaryKeyBindingSignatureBuilder(
|
PrimaryKeyBindingSignatureBuilder(componentKey, subkeyProtector, hashAlgorithm)
|
||||||
key.primarySecretKey, primaryKeyProtector, hashAlgorithm)
|
|
||||||
pkBindingBuilder.hashedSubpackets.setSignatureCreationTime(referenceTime)
|
pkBindingBuilder.hashedSubpackets.setSignatureCreationTime(referenceTime)
|
||||||
hashedSubpackets.addEmbeddedSignature(pkBindingBuilder.build(primaryKey.publicKey))
|
hashedSubpackets.addEmbeddedSignature(pkBindingBuilder.build(primaryKey.publicKey))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue