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

Add OpenPGPSecretKey.unlock(Passphrase) extension method

This commit is contained in:
Paul Schaub 2025-04-02 20:50:03 +02:00
parent e2d8db6796
commit a8a09b7db7
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -7,10 +7,15 @@ package org.pgpainless.bouncycastle.extensions
import org.bouncycastle.openpgp.PGPPublicKeyEncryptedData import org.bouncycastle.openpgp.PGPPublicKeyEncryptedData
import org.bouncycastle.openpgp.PGPSignature import org.bouncycastle.openpgp.PGPSignature
import org.bouncycastle.openpgp.api.OpenPGPKey import org.bouncycastle.openpgp.api.OpenPGPKey
import org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPPrivateKey
import org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPSecretKey import org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPSecretKey
import org.pgpainless.util.Passphrase
fun OpenPGPKey.getSecretKeyFor(pkesk: PGPPublicKeyEncryptedData): OpenPGPSecretKey? = fun OpenPGPKey.getSecretKeyFor(pkesk: PGPPublicKeyEncryptedData): OpenPGPSecretKey? =
this.getSecretKey(pkesk.keyIdentifier) this.getSecretKey(pkesk.keyIdentifier)
fun OpenPGPKey.getSecretKeyFor(signature: PGPSignature): OpenPGPSecretKey? = fun OpenPGPKey.getSecretKeyFor(signature: PGPSignature): OpenPGPSecretKey? =
this.getSecretKey(signature.fingerprint!!.keyIdentifier) this.getSecretKey(signature.fingerprint!!.keyIdentifier)
fun OpenPGPKey.OpenPGPSecretKey.unlock(passphrase: Passphrase): OpenPGPPrivateKey =
this.unlock(passphrase.getChars())