Replace ByteArrayInputStream with inputStream()

This commit is contained in:
Paul Schaub 2023-10-31 14:22:12 +01:00
parent 8df4a520bd
commit 9283f81c56
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
3 changed files with 5 additions and 9 deletions

View file

@ -4,7 +4,6 @@
package sop.operation package sop.operation
import java.io.ByteArrayInputStream
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
import sop.exception.SOPGPException.BadData import sop.exception.SOPGPException.BadData
@ -31,6 +30,5 @@ interface DetachedVerify : AbstractVerify<DetachedVerify>, VerifySignatures {
* @throws IOException in case of an IO error * @throws IOException in case of an IO error
*/ */
@Throws(BadData::class, IOException::class) @Throws(BadData::class, IOException::class)
fun signatures(signatures: ByteArray): VerifySignatures = fun signatures(signatures: ByteArray): VerifySignatures = signatures(signatures.inputStream())
signatures(ByteArrayInputStream(signatures))
} }

View file

@ -4,7 +4,6 @@
package sop.operation package sop.operation
import java.io.ByteArrayInputStream
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
import sop.Profile import sop.Profile
@ -57,7 +56,7 @@ interface Encrypt {
*/ */
@Throws( @Throws(
KeyCannotSign::class, UnsupportedAsymmetricAlgo::class, BadData::class, IOException::class) KeyCannotSign::class, UnsupportedAsymmetricAlgo::class, BadData::class, IOException::class)
fun signWith(key: ByteArray): Encrypt = signWith(ByteArrayInputStream(key)) fun signWith(key: ByteArray): Encrypt = signWith(key.inputStream())
/** /**
* Provide the password for the secret key used for signing. * Provide the password for the secret key used for signing.
@ -125,7 +124,7 @@ interface Encrypt {
UnsupportedAsymmetricAlgo::class, UnsupportedAsymmetricAlgo::class,
BadData::class, BadData::class,
IOException::class) IOException::class)
fun withCert(cert: ByteArray): Encrypt = withCert(ByteArrayInputStream(cert)) fun withCert(cert: ByteArray): Encrypt = withCert(cert.inputStream())
/** /**
* Pass in a profile. * Pass in a profile.
@ -162,5 +161,5 @@ interface Encrypt {
* @throws KeyIsProtected if at least one signing key cannot be unlocked * @throws KeyIsProtected if at least one signing key cannot be unlocked
*/ */
@Throws(IOException::class, KeyIsProtected::class) @Throws(IOException::class, KeyIsProtected::class)
fun plaintext(plaintext: ByteArray): Ready = plaintext(ByteArrayInputStream(plaintext)) fun plaintext(plaintext: ByteArray): Ready = plaintext(plaintext.inputStream())
} }

View file

@ -4,7 +4,6 @@
package sop.operation package sop.operation
import java.io.ByteArrayInputStream
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
import sop.Ready import sop.Ready
@ -38,5 +37,5 @@ interface ExtractCert {
* @throws BadData if the byte array does not contain an OpenPGP key * @throws BadData if the byte array does not contain an OpenPGP key
*/ */
@Throws(IOException::class, BadData::class) @Throws(IOException::class, BadData::class)
fun key(key: ByteArray): Ready = key(ByteArrayInputStream(key)) fun key(key: ByteArray): Ready = key(key.inputStream())
} }