1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-26 22:32:07 +01:00

V6 sigs do not contain IssuerKeyId packet

This commit is contained in:
Paul Schaub 2024-08-11 13:41:17 +02:00
parent 4911816b7d
commit 8677646780
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
3 changed files with 20 additions and 3 deletions

View file

@ -97,7 +97,7 @@ class KeyRingBuilder : KeyRingBuilderInterface<KeyRingBuilder> {
val signatureGenerator = PGPSignatureGenerator(signer, certKey.publicKey) val signatureGenerator = PGPSignatureGenerator(signer, certKey.publicKey)
val hashedSubPacketGenerator = primaryKeySpec!!.subpacketGenerator val hashedSubPacketGenerator = primaryKeySpec!!.subpacketGenerator
hashedSubPacketGenerator.setIssuerFingerprintAndKeyId(certKey.publicKey) hashedSubPacketGenerator.setIssuer(certKey.publicKey)
expirationDate?.let { hashedSubPacketGenerator.setKeyExpirationTime(certKey.publicKey, it) } expirationDate?.let { hashedSubPacketGenerator.setKeyExpirationTime(certKey.publicKey, it) }
if (userIds.isNotEmpty()) { if (userIds.isNotEmpty()) {
hashedSubPacketGenerator.setPrimaryUserId() hashedSubPacketGenerator.setPrimaryUserId()

View file

@ -17,6 +17,15 @@ interface BaseSignatureSubpackets {
interface Callback : SignatureSubpacketCallback<BaseSignatureSubpackets> interface Callback : SignatureSubpacketCallback<BaseSignatureSubpackets>
/**
* Depending on the key version, set appropriate issuer information (issuer key-id / issuer
* fingerprint).
*
* @param key issuer key
* @return signature subpackets
*/
fun setIssuer(key: PGPPublicKey): BaseSignatureSubpackets
/** /**
* Add both an [IssuerKeyID] and [IssuerFingerprint] subpacket pointing to the given key. * Add both an [IssuerKeyID] and [IssuerFingerprint] subpacket pointing to the given key.
* *

View file

@ -72,7 +72,7 @@ class SignatureSubpackets :
issuer: PGPPublicKey, issuer: PGPPublicKey,
base: PGPSignatureSubpacketVector base: PGPSignatureSubpacketVector
): SignatureSubpackets { ): SignatureSubpackets {
return createSubpacketsFrom(base).apply { setIssuerFingerprintAndKeyId(issuer) } return createSubpacketsFrom(base).apply { setIssuer(issuer) }
} }
@JvmStatic @JvmStatic
@ -82,7 +82,7 @@ class SignatureSubpackets :
@JvmStatic @JvmStatic
fun createHashedSubpackets(issuer: PGPPublicKey): SignatureSubpackets { fun createHashedSubpackets(issuer: PGPPublicKey): SignatureSubpackets {
return createEmptySubpackets().setIssuerFingerprintAndKeyId(issuer) return createEmptySubpackets().setIssuer(issuer)
} }
@JvmStatic @JvmStatic
@ -352,6 +352,14 @@ class SignatureSubpackets :
this.featuresSubpacket = features this.featuresSubpacket = features
} }
override fun setIssuer(key: PGPPublicKey): SignatureSubpackets = apply {
if (key.version == 6) {
setIssuerFingerprint(key)
} else {
setIssuerFingerprintAndKeyId(key)
}
}
override fun setIssuerFingerprintAndKeyId(key: PGPPublicKey): SignatureSubpackets = apply { override fun setIssuerFingerprintAndKeyId(key: PGPPublicKey): SignatureSubpackets = apply {
setIssuerKeyId(key.keyID) setIssuerKeyId(key.keyID)
setIssuerFingerprint(key) setIssuerFingerprint(key)