From c75936768087a4ec4c780da99922b1d734da06ef Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 28 Aug 2023 16:18:41 +0200 Subject: [PATCH] Add PGPSignatureExtensions file --- .../extensions/PGPSignatureExtensions.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pgpainless-core/src/main/kotlin/org/bouncycastle/extensions/PGPSignatureExtensions.kt diff --git a/pgpainless-core/src/main/kotlin/org/bouncycastle/extensions/PGPSignatureExtensions.kt b/pgpainless-core/src/main/kotlin/org/bouncycastle/extensions/PGPSignatureExtensions.kt new file mode 100644 index 00000000..657abba9 --- /dev/null +++ b/pgpainless-core/src/main/kotlin/org/bouncycastle/extensions/PGPSignatureExtensions.kt @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: 2023 Paul Schaub +// +// 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.* + +fun PGPSignature.getKeyExpirationDate(keyCreationDate: Date): Date? = + SignatureUtils.getKeyExpirationDate(keyCreationDate, this) + +fun PGPSignature.getSignatureExpirationDate(): Date? = + SignatureUtils.getSignatureExpirationDate(this) + +fun PGPSignature.isExpired(referenceTime: Date = Date()) = + SignatureUtils.isSignatureExpired(this, referenceTime) + +fun PGPSignature.getIssuerKeyId() = SignatureUtils.determineIssuerKeyId(this) + +fun PGPSignature.wasIssuedBy(fingerprint: OpenPgpFingerprint) = SignatureUtils.wasIssuedBy(fingerprint, this)