From b9ee09a77467d5f7bfa3b1b5bfdc08aa7df1d1e1 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Wed, 26 Feb 2025 16:29:59 +0100 Subject: [PATCH] Add javadoc --- .../kotlin/org/pgpainless/key/SubkeyIdentifier.kt | 11 +++++++++++ .../kotlin/org/pgpainless/sop/VerificationHelper.kt | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pgpainless-core/src/main/kotlin/org/pgpainless/key/SubkeyIdentifier.kt b/pgpainless-core/src/main/kotlin/org/pgpainless/key/SubkeyIdentifier.kt index bc425629..d3e73e65 100644 --- a/pgpainless-core/src/main/kotlin/org/pgpainless/key/SubkeyIdentifier.kt +++ b/pgpainless-core/src/main/kotlin/org/pgpainless/key/SubkeyIdentifier.kt @@ -15,7 +15,13 @@ import org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPPrivateKey * as the component keys fingerprint. */ class SubkeyIdentifier( + /** + * Fingerprint of the certificate. + */ val certificateFingerprint: OpenPgpFingerprint, + /** + * Fingerprint of the target component key. + */ val componentKeyFingerprint: OpenPgpFingerprint ) { @@ -124,8 +130,13 @@ class SubkeyIdentifier( /** Key-ID of the primary key of the certificate the component key belongs to. */ @Deprecated("Use of key-ids is discouraged.") val primaryKeyId = certificateIdentifier.keyId + /** True, if the component key is the primary key. */ val isPrimaryKey = certificateIdentifier.matches(componentKeyIdentifier) + /** + * Return true, if the provided [fingerprint] matches either the [certificateFingerprint] + * or [componentKeyFingerprint]. + */ fun matches(fingerprint: OpenPgpFingerprint) = certificateFingerprint == fingerprint || componentKeyFingerprint == fingerprint diff --git a/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/VerificationHelper.kt b/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/VerificationHelper.kt index 9198e3b7..bc64ecd3 100644 --- a/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/VerificationHelper.kt +++ b/pgpainless-sop/src/main/kotlin/org/pgpainless/sop/VerificationHelper.kt @@ -24,8 +24,8 @@ class VerificationHelper { fun mapVerification(sigVerification: SignatureVerification): Verification = Verification( sigVerification.signature.creationTime, - sigVerification.signingKey.subkeyFingerprint.toString(), - sigVerification.signingKey.primaryKeyFingerprint.toString(), + sigVerification.signingKey.componentKeyFingerprint.toString(), + sigVerification.signingKey.certificateFingerprint.toString(), getMode(sigVerification.signature), null)