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

Integrate KeyIdentifier with SubkeyIdentifier

This commit is contained in:
Paul Schaub 2025-01-30 12:08:55 +01:00
parent eb9efec7c9
commit d4b16971d5
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -5,6 +5,7 @@
package org.pgpainless.key package org.pgpainless.key
import openpgp.openPgpKeyId import openpgp.openPgpKeyId
import org.bouncycastle.bcpg.KeyIdentifier
import org.bouncycastle.openpgp.PGPKeyRing import org.bouncycastle.openpgp.PGPKeyRing
import org.bouncycastle.openpgp.PGPPublicKey import org.bouncycastle.openpgp.PGPPublicKey
@ -38,13 +39,17 @@ class SubkeyIdentifier(
subkeyFingerprint: OpenPgpFingerprint subkeyFingerprint: OpenPgpFingerprint
) : this(OpenPgpFingerprint.of(keys), subkeyFingerprint) ) : this(OpenPgpFingerprint.of(keys), subkeyFingerprint)
val keyId = subkeyFingerprint.keyId val keyIdentifier = KeyIdentifier(subkeyFingerprint.bytes)
val subkeyIdentifier = keyIdentifier
val primaryKeyIdentifier = KeyIdentifier(primaryKeyFingerprint.bytes)
@Deprecated("Use of key-ids is discouraged.") val keyId = keyIdentifier.keyId
val fingerprint = subkeyFingerprint val fingerprint = subkeyFingerprint
val subkeyId = subkeyFingerprint.keyId @Deprecated("Use of key-ids is discouraged.") val subkeyId = subkeyIdentifier.keyId
val primaryKeyId = primaryKeyFingerprint.keyId @Deprecated("Use of key-ids is discouraged.") val primaryKeyId = primaryKeyIdentifier.keyId
val isPrimaryKey = primaryKeyId == subkeyId val isPrimaryKey = primaryKeyIdentifier == subkeyIdentifier
fun matches(fingerprint: OpenPgpFingerprint) = fun matches(fingerprint: OpenPgpFingerprint) =
primaryKeyFingerprint == fingerprint || subkeyFingerprint == fingerprint primaryKeyFingerprint == fingerprint || subkeyFingerprint == fingerprint