mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-10 10:49:39 +02:00
Rework OnePassSignatureCheck
This commit is contained in:
parent
7f8fc340d8
commit
e7da1bc66a
1 changed files with 16 additions and 9 deletions
|
@ -5,31 +5,38 @@
|
||||||
package org.pgpainless.signature.consumer
|
package org.pgpainless.signature.consumer
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPOnePassSignature
|
import org.bouncycastle.openpgp.PGPOnePassSignature
|
||||||
import org.bouncycastle.openpgp.PGPPublicKeyRing
|
|
||||||
import org.bouncycastle.openpgp.PGPSignature
|
import org.bouncycastle.openpgp.PGPSignature
|
||||||
import org.bouncycastle.openpgp.api.OpenPGPCertificate
|
import org.bouncycastle.openpgp.api.OpenPGPCertificate
|
||||||
|
import org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey
|
||||||
|
import org.pgpainless.bouncycastle.extensions.getSigningKeyFor
|
||||||
import org.pgpainless.key.SubkeyIdentifier
|
import org.pgpainless.key.SubkeyIdentifier
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tuple-class that bundles together a [PGPOnePassSignature] object, a [PGPPublicKeyRing] destined
|
* Tuple-class that bundles together a [PGPOnePassSignature] object, an [OpenPGPCertificate]
|
||||||
* to verify the signature, the [PGPSignature] itself and a record of whether the signature was
|
* destined to verify the signature.
|
||||||
* verified.
|
|
||||||
*
|
*
|
||||||
* @param onePassSignature the one-pass-signature packet
|
* @param onePassSignature the one-pass-signature packet
|
||||||
* @param verificationKeys certificate containing the signing subkey
|
* @param verificationKeys certificate containing the signing subkey
|
||||||
* @param signature the signature packet
|
|
||||||
*/
|
*/
|
||||||
data class OnePassSignatureCheck(
|
data class OnePassSignatureCheck(
|
||||||
val onePassSignature: PGPOnePassSignature,
|
val onePassSignature: PGPOnePassSignature,
|
||||||
val verificationKeys: OpenPGPCertificate,
|
val verificationKeys: OpenPGPCertificate
|
||||||
var signature: PGPSignature? = null
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
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 an identifier for the signing key.
|
||||||
*
|
*
|
||||||
* @return signing key fingerprint
|
* @return signing key fingerprint
|
||||||
*/
|
*/
|
||||||
val signingKey: SubkeyIdentifier
|
val signingKeyIdentifier: SubkeyIdentifier?
|
||||||
get() = SubkeyIdentifier(verificationKeys.pgpPublicKeyRing, onePassSignature.keyID)
|
get() = signingKey?.let { SubkeyIdentifier(it) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue