2023-08-28 16:18:41 +02:00
|
|
|
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
package org.bouncycastle.extensions
|
|
|
|
|
|
|
|
import org.bouncycastle.openpgp.PGPSignature
|
|
|
|
import org.pgpainless.key.OpenPgpFingerprint
|
|
|
|
import org.pgpainless.signature.SignatureUtils
|
|
|
|
import java.util.*
|
|
|
|
|
2023-08-28 16:26:52 +02:00
|
|
|
/**
|
|
|
|
* Return the value of the KeyExpirationDate subpacket, or null, if the signature does not carry
|
|
|
|
* such a subpacket.
|
|
|
|
*/
|
2023-08-28 16:18:41 +02:00
|
|
|
fun PGPSignature.getKeyExpirationDate(keyCreationDate: Date): Date? =
|
|
|
|
SignatureUtils.getKeyExpirationDate(keyCreationDate, this)
|
|
|
|
|
2023-08-28 16:26:52 +02:00
|
|
|
/**
|
|
|
|
* Return the value of the signature ExpirationTime subpacket, or null, if the signature
|
|
|
|
* does not carry such a subpacket.
|
|
|
|
*/
|
2023-08-28 16:18:41 +02:00
|
|
|
fun PGPSignature.getSignatureExpirationDate(): Date? =
|
|
|
|
SignatureUtils.getSignatureExpirationDate(this)
|
|
|
|
|
2023-08-28 16:26:52 +02:00
|
|
|
/**
|
|
|
|
* Return true, if the signature is expired at the given reference time.
|
|
|
|
*/
|
2023-08-28 16:18:41 +02:00
|
|
|
fun PGPSignature.isExpired(referenceTime: Date = Date()) =
|
|
|
|
SignatureUtils.isSignatureExpired(this, referenceTime)
|
|
|
|
|
2023-08-28 16:26:52 +02:00
|
|
|
/**
|
|
|
|
* Return the key-ID of the issuer, determined by examining the IssuerKeyId and IssuerFingerprint
|
|
|
|
* subpackets of the signature.
|
|
|
|
*/
|
2023-08-28 16:18:41 +02:00
|
|
|
fun PGPSignature.getIssuerKeyId() = SignatureUtils.determineIssuerKeyId(this)
|
|
|
|
|
2023-08-28 16:26:52 +02:00
|
|
|
/**
|
|
|
|
* Return true, if the signature was likely issued by the key with the given fingerprint.
|
|
|
|
*/
|
2023-08-28 16:18:41 +02:00
|
|
|
fun PGPSignature.wasIssuedBy(fingerprint: OpenPgpFingerprint) = SignatureUtils.wasIssuedBy(fingerprint, this)
|
2023-08-28 16:26:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true, if this signature is a hard revocation.
|
|
|
|
*/
|
|
|
|
fun PGPSignature.isHardRevocation() = SignatureUtils.isHardRevocation(this)
|