1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-22 20:32:05 +01:00

Fix some minor code issues

This commit is contained in:
Paul Schaub 2024-10-14 15:18:49 +02:00
parent fb71ef2193
commit 52b6d5c3f7
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
3 changed files with 7 additions and 7 deletions

View file

@ -92,7 +92,7 @@ class DecryptImpl : Decrypt {
} }
override fun verifyWithCert(cert: InputStream): Decrypt = apply { override fun verifyWithCert(cert: InputStream): Decrypt = apply {
KeyReader.readPublicKeys(cert, true)?.let { consumerOptions.addVerificationCerts(it) } KeyReader.readPublicKeys(cert, true).let { consumerOptions.addVerificationCerts(it) }
} }
override fun withKey(key: InputStream): Decrypt = apply { override fun withKey(key: InputStream): Decrypt = apply {
@ -107,10 +107,10 @@ class DecryptImpl : Decrypt {
} }
override fun withPassword(password: String): Decrypt = apply { override fun withPassword(password: String): Decrypt = apply {
consumerOptions.addDecryptionPassphrase(Passphrase.fromPassword(password)) consumerOptions.addMessagePassphrase(Passphrase.fromPassword(password))
password.trimEnd().let { password.trimEnd().let {
if (it != password) { if (it != password) {
consumerOptions.addDecryptionPassphrase(Passphrase.fromPassword(it)) consumerOptions.addMessagePassphrase(Passphrase.fromPassword(it))
} }
} }
} }

View file

@ -136,7 +136,7 @@ class EncryptImpl : Encrypt {
} }
override fun withPassword(password: String): Encrypt = apply { override fun withPassword(password: String): Encrypt = apply {
encryptionOptions.addPassphrase(Passphrase.fromPassword(password)) encryptionOptions.addMessagePassphrase(Passphrase.fromPassword(password))
} }
private fun modeToStreamEncoding(mode: EncryptAs): StreamEncoding { private fun modeToStreamEncoding(mode: EncryptAs): StreamEncoding {

View file

@ -34,7 +34,7 @@ class InlineDetachImpl : InlineDetach {
private val sigOut = ByteArrayOutputStream() private val sigOut = ByteArrayOutputStream()
override fun writeTo(messageOutputStream: OutputStream): Signatures { override fun writeTo(outputStream: OutputStream): Signatures {
var pgpIn = OpenPgpInputStream(messageInputStream) var pgpIn = OpenPgpInputStream(messageInputStream)
if (pgpIn.isNonOpenPgp) { if (pgpIn.isNonOpenPgp) {
throw SOPGPException.BadData("Data appears to be non-OpenPGP.") throw SOPGPException.BadData("Data appears to be non-OpenPGP.")
@ -50,7 +50,7 @@ class InlineDetachImpl : InlineDetach {
try { try {
signatures = signatures =
ClearsignedMessageUtil.detachSignaturesFromInbandClearsignedMessage( ClearsignedMessageUtil.detachSignaturesFromInbandClearsignedMessage(
armorIn, messageOutputStream) armorIn, outputStream)
if (signatures.isEmpty) { if (signatures.isEmpty) {
throw SOPGPException.BadData( throw SOPGPException.BadData(
"Data did not contain OpenPGP signatures.") "Data did not contain OpenPGP signatures.")
@ -86,7 +86,7 @@ class InlineDetachImpl : InlineDetach {
if (next is PGPLiteralData) { if (next is PGPLiteralData) {
// Write out contents of Literal Data packet // Write out contents of Literal Data packet
val literalIn = (next as PGPLiteralData).dataStream val literalIn = (next as PGPLiteralData).dataStream
Streams.pipeAll(literalIn, messageOutputStream) Streams.pipeAll(literalIn, outputStream)
literalIn.close() literalIn.close()
continue continue
} }