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

Identify key by fingerprint for v6

This commit is contained in:
Paul Schaub 2024-08-11 13:40:05 +02:00
parent a230c48393
commit 0196e3ce65
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 11 additions and 4 deletions

View file

@ -70,10 +70,15 @@ fun PGPSecretKeyRing.getSecretKeyFor(signature: PGPSignature): PGPSecretKey? =
/** Return the [PGPSecretKey] that matches the key-ID of the given [PGPOnePassSignature] packet. */ /** Return the [PGPSecretKey] that matches the key-ID of the given [PGPOnePassSignature] packet. */
fun PGPSecretKeyRing.getSecretKeyFor(onePassSignature: PGPOnePassSignature): PGPSecretKey? = fun PGPSecretKeyRing.getSecretKeyFor(onePassSignature: PGPOnePassSignature): PGPSecretKey? =
this.getSecretKey(onePassSignature.keyID) when (onePassSignature.version) {
3 -> this.getSecretKey(onePassSignature.keyID)
6 -> this.getSecretKey(onePassSignature.fingerprint)
else -> throw NotImplementedError("Version ${onePassSignature.version} OPSs are not yet supported.")
}
fun PGPSecretKeyRing.getSecretKeyFor(pkesk: PGPPublicKeyEncryptedData): PGPSecretKey? = fun PGPSecretKeyRing.getSecretKeyFor(pkesk: PGPPublicKeyEncryptedData): PGPSecretKey? =
when (pkesk.version) { when (pkesk.version) {
3 -> this.getSecretKey(pkesk.keyID) 3 -> this.getSecretKey(pkesk.keyID)
else -> throw NotImplementedError("Version 6 PKESKs are not yet supported.") 6 -> this.getSecretKey(pkesk.fingerprint)
else -> throw NotImplementedError("Version ${pkesk.version} PKESKs are not yet supported.")
} }

View file

@ -684,7 +684,8 @@ class OpenPgpMessageInputStream(
PGPainless.inspectKeyRing(it).decryptionSubkeys.any { subkey -> PGPainless.inspectKeyRing(it).decryptionSubkeys.any { subkey ->
when (pkesk.version) { when (pkesk.version) {
3 -> pkesk.keyID == subkey.keyID 3 -> pkesk.keyID == subkey.keyID
else -> throw NotImplementedError("Version 6 PKESK not yet supported.") 6 -> pkesk.fingerprint.contentEquals(subkey.fingerprint)
else -> false
} }
} }
} }
@ -695,7 +696,8 @@ class OpenPgpMessageInputStream(
PGPainless.inspectKeyRing(it).decryptionSubkeys.any { subkey -> PGPainless.inspectKeyRing(it).decryptionSubkeys.any { subkey ->
when (pkesk.version) { when (pkesk.version) {
3 -> pkesk.keyID == subkey.keyID 3 -> pkesk.keyID == subkey.keyID
else -> throw NotImplementedError("Version 6 PKESK not yet supported.") 6 -> pkesk.fingerprint.contentEquals(subkey.fingerprint)
else -> false
} }
} }
} }