diff options
| author | Harsh Shandilya <me@msfjarvis.dev> | 2022-04-27 22:32:36 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-27 17:02:36 +0000 |
| commit | d4a4ac06ed419221d3a1f967ca3a66b1e163ddb8 (patch) | |
| tree | 8f501a3443e4fb422a213fc169f198f23e4fc511 /crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoHandler.kt | |
| parent | b8b069364289421a875bdc6227c8554161e26183 (diff) | |
| download | HardenedPass-d4a4ac06ed419221d3a1f967ca3a66b1e163ddb8.tar.gz HardenedPass-d4a4ac06ed419221d3a1f967ca3a66b1e163ddb8.zip | |
crypto-pgpainless: prepare for error handling (#1877)
Diffstat (limited to 'crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoHandler.kt')
| -rw-r--r-- | crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoHandler.kt | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoHandler.kt b/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoHandler.kt index fc4c500d..e8e9f995 100644 --- a/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoHandler.kt +++ b/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/CryptoHandler.kt @@ -5,6 +5,8 @@ package dev.msfjarvis.aps.crypto +import com.github.michaelbull.result.Result +import dev.msfjarvis.aps.crypto.errors.CryptoHandlerException import java.io.InputStream import java.io.OutputStream @@ -13,24 +15,27 @@ public interface CryptoHandler<Key> { /** * Decrypt the given [ciphertextStream] using a [privateKey] and [passphrase], and writes the - * resultant plaintext to [outputStream]. + * resultant plaintext to [outputStream]. The returned [Result] should be checked to ensure it is + * **not** an instance of [com.github.michaelbull.result.Err] before the contents of + * [outputStream] are used. */ public fun decrypt( privateKey: Key, passphrase: String, ciphertextStream: InputStream, outputStream: OutputStream, - ) + ): Result<Unit, CryptoHandlerException> /** * Encrypt the given [plaintextStream] to the provided [keys], and writes the encrypted ciphertext - * to [outputStream]. + * to [outputStream]. The returned [Result] should be checked to ensure it is **not** an instance + * of [com.github.michaelbull.result.Err] before the contents of [outputStream] are used. */ public fun encrypt( keys: List<Key>, plaintextStream: InputStream, outputStream: OutputStream, - ) + ): Result<Unit, CryptoHandlerException> /** Given a [fileName], return whether this instance can handle it. */ public fun canHandle(fileName: String): Boolean |
