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:
parent
a230c48393
commit
0196e3ce65
2 changed files with 11 additions and 4 deletions
|
@ -70,10 +70,15 @@ fun PGPSecretKeyRing.getSecretKeyFor(signature: PGPSignature): PGPSecretKey? =
|
|||
|
||||
/** Return the [PGPSecretKey] that matches the key-ID of the given [PGPOnePassSignature] packet. */
|
||||
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? =
|
||||
when (pkesk.version) {
|
||||
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.")
|
||||
}
|
||||
|
|
|
@ -684,7 +684,8 @@ class OpenPgpMessageInputStream(
|
|||
PGPainless.inspectKeyRing(it).decryptionSubkeys.any { subkey ->
|
||||
when (pkesk.version) {
|
||||
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 ->
|
||||
when (pkesk.version) {
|
||||
3 -> pkesk.keyID == subkey.keyID
|
||||
else -> throw NotImplementedError("Version 6 PKESK not yet supported.")
|
||||
6 -> pkesk.fingerprint.contentEquals(subkey.fingerprint)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue