mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-09 18:29:39 +02:00
Clean up KeyAccessor class
This commit is contained in:
parent
e53e4f5f3c
commit
22a1f54a9b
1 changed files with 10 additions and 20 deletions
|
@ -41,6 +41,7 @@ abstract class KeyAccessor(protected val info: KeyRingInfo, protected val key: S
|
||||||
get() =
|
get() =
|
||||||
SignatureSubpacketsUtil.parsePreferredCompressionAlgorithms(signatureWithPreferences)
|
SignatureSubpacketsUtil.parsePreferredCompressionAlgorithms(signatureWithPreferences)
|
||||||
|
|
||||||
|
/** Preferred AEAD algorithm suites. */
|
||||||
val preferredAEADCipherSuites: Set<AEADCipherMode>
|
val preferredAEADCipherSuites: Set<AEADCipherMode>
|
||||||
get() = SignatureSubpacketsUtil.parsePreferredAEADCipherSuites(signatureWithPreferences)
|
get() = SignatureSubpacketsUtil.parsePreferredAEADCipherSuites(signatureWithPreferences)
|
||||||
|
|
||||||
|
@ -64,30 +65,19 @@ abstract class KeyAccessor(protected val info: KeyRingInfo, protected val key: S
|
||||||
class ViaKeyId(info: KeyRingInfo, key: SubkeyIdentifier) : KeyAccessor(info, key) {
|
class ViaKeyId(info: KeyRingInfo, key: SubkeyIdentifier) : KeyAccessor(info, key) {
|
||||||
override val signatureWithPreferences: PGPSignature
|
override val signatureWithPreferences: PGPSignature
|
||||||
get() {
|
get() {
|
||||||
// If the key is located by Key ID, the algorithm of the primary User ID of the key
|
if (key.isPrimaryKey) {
|
||||||
// provides the
|
// If the key is located by Key ID, the algorithm of the primary User ID of the
|
||||||
// preferred symmetric algorithm.
|
// key
|
||||||
info.primaryUserId?.let { userId ->
|
// provides the
|
||||||
info.getLatestUserIdCertification(userId).let { if (it != null) return it }
|
// preferred symmetric algorithm.
|
||||||
|
info.primaryUserId?.let { userId ->
|
||||||
|
info.getLatestUserIdCertification(userId).let { if (it != null) return it }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return info.getCurrentSubkeyBindingSignature(key.subkeyId)
|
return info.getCurrentSubkeyBindingSignature(key.keyIdentifier)
|
||||||
?: throw NoSuchElementException(
|
?: throw NoSuchElementException(
|
||||||
"Key does not carry acceptable self-signature signature.")
|
"Key does not carry acceptable self-signature signature.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SubKey(info: KeyRingInfo, key: SubkeyIdentifier) : KeyAccessor(info, key) {
|
|
||||||
override val signatureWithPreferences: PGPSignature
|
|
||||||
get() =
|
|
||||||
checkNotNull(
|
|
||||||
if (key.isPrimaryKey) {
|
|
||||||
info.latestDirectKeySelfSignature
|
|
||||||
?: info.primaryUserId?.let { info.getLatestUserIdCertification(it) }
|
|
||||||
} else {
|
|
||||||
info.getCurrentSubkeyBindingSignature(key.subkeyId)
|
|
||||||
}) {
|
|
||||||
"No valid signature found."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue