mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-05 03:41:07 +01:00
Add OpenPGPComponentKey.getSecretKey() extension method
This commit is contained in:
parent
cd99330a97
commit
8f1fff5403
1 changed files with 8 additions and 0 deletions
|
|
@ -5,6 +5,7 @@
|
|||
package org.pgpainless.bouncycastle.extensions
|
||||
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyEncryptedData
|
||||
import org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey
|
||||
import org.bouncycastle.openpgp.api.OpenPGPKey
|
||||
import org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPPrivateKey
|
||||
import org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPSecretKey
|
||||
|
|
@ -19,6 +20,13 @@ import org.pgpainless.util.Passphrase
|
|||
fun OpenPGPKey.getSecretKeyFor(pkesk: PGPPublicKeyEncryptedData): OpenPGPSecretKey? =
|
||||
this.getSecretKey(pkesk.keyIdentifier)
|
||||
|
||||
fun OpenPGPComponentKey.getSecretKey(): OpenPGPSecretKey? =
|
||||
if (this.certificate is OpenPGPKey) {
|
||||
(this.certificate as OpenPGPKey).getSecretKey(this)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock the [OpenPGPSecretKey], returning the unlocked [OpenPGPPrivateKey].
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue