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

EncryptImpl: Emit session-key

This commit is contained in:
Paul Schaub 2025-06-16 13:34:37 +02:00
parent fdcdf6270f
commit e611311f2c
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
3 changed files with 17 additions and 2 deletions

View file

@ -26,6 +26,7 @@ import org.pgpainless.util.Passphrase
import sop.EncryptionResult
import sop.Profile
import sop.ReadyWithResult
import sop.SessionKey
import sop.enums.EncryptAs
import sop.exception.SOPGPException
import sop.operation.Encrypt
@ -98,8 +99,10 @@ class EncryptImpl(private val api: PGPainless) : Encrypt {
api.generateMessage().onOutputStream(outputStream).withOptions(options)
Streams.pipeAll(plaintext, encryptionStream)
encryptionStream.close()
// TODO: Extract and emit session key once BC supports that
return EncryptionResult(null)
return EncryptionResult(
encryptionStream.result.sessionKey?.let {
SessionKey(it.algorithm.algorithmId.toByte(), it.key)
})
}
}
} catch (e: PGPException) {