1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-09 18:29:39 +02:00

Rework OnePassSignatureCheck

This commit is contained in:
Paul Schaub 2025-02-28 13:08:15 +01:00
parent 6e2d097a00
commit 62d6b7d5ab
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -5,31 +5,38 @@
package org.pgpainless.signature.consumer
import org.bouncycastle.openpgp.PGPOnePassSignature
import org.bouncycastle.openpgp.PGPPublicKeyRing
import org.bouncycastle.openpgp.PGPSignature
import org.bouncycastle.openpgp.api.OpenPGPCertificate
import org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey
import org.pgpainless.bouncycastle.extensions.getSigningKeyFor
import org.pgpainless.key.SubkeyIdentifier
/**
* Tuple-class that bundles together a [PGPOnePassSignature] object, a [PGPPublicKeyRing] destined
* to verify the signature, the [PGPSignature] itself and a record of whether the signature was
* verified.
* Tuple-class that bundles together a [PGPOnePassSignature] object, an [OpenPGPCertificate]
* destined to verify the signature.
*
* @param onePassSignature the one-pass-signature packet
* @param verificationKeys certificate containing the signing subkey
* @param signature the signature packet
*/
data class OnePassSignatureCheck(
val onePassSignature: PGPOnePassSignature,
val verificationKeys: OpenPGPCertificate,
var signature: PGPSignature? = null
val verificationKeys: OpenPGPCertificate
) {
var signature: PGPSignature? = null
constructor(
onePassSignature: PGPOnePassSignature,
verificationKey: OpenPGPComponentKey
) : this(onePassSignature, verificationKey.certificate)
val signingKey: OpenPGPComponentKey? = verificationKeys.getSigningKeyFor(onePassSignature)
/**
* Return an identifier for the signing key.
*
* @return signing key fingerprint
*/
val signingKey: SubkeyIdentifier
get() = SubkeyIdentifier(verificationKeys.pgpPublicKeyRing, onePassSignature.keyID)
val signingKeyIdentifier: SubkeyIdentifier?
get() = signingKey?.let { SubkeyIdentifier(it) }
}