From 633cbe271460980ff18a350fb6b7864a424ec83a Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 29 Oct 2022 04:36:00 +0530 Subject: feat(crypto-common): support passing arbitrary crypto options --- .../src/main/kotlin/app/passwordstore/crypto/CryptoHandler.kt | 4 +++- .../src/main/kotlin/app/passwordstore/crypto/CryptoOptions.kt | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 crypto-common/src/main/kotlin/app/passwordstore/crypto/CryptoOptions.kt (limited to 'crypto-common/src') diff --git a/crypto-common/src/main/kotlin/app/passwordstore/crypto/CryptoHandler.kt b/crypto-common/src/main/kotlin/app/passwordstore/crypto/CryptoHandler.kt index ea42af6d..898cf058 100644 --- a/crypto-common/src/main/kotlin/app/passwordstore/crypto/CryptoHandler.kt +++ b/crypto-common/src/main/kotlin/app/passwordstore/crypto/CryptoHandler.kt @@ -11,7 +11,7 @@ import java.io.InputStream import java.io.OutputStream /** Generic interface to implement cryptographic operations on top of. */ -public interface CryptoHandler { +public interface CryptoHandler { /** * Decrypt the given [ciphertextStream] using a set of potential [keys] and [passphrase], and @@ -24,6 +24,7 @@ public interface CryptoHandler { passphrase: String, ciphertextStream: InputStream, outputStream: OutputStream, + options: DecryptOpts, ): Result /** @@ -35,6 +36,7 @@ public interface CryptoHandler { keys: List, plaintextStream: InputStream, outputStream: OutputStream, + options: EncOpts, ): Result /** Given a [fileName], return whether this instance can handle it. */ diff --git a/crypto-common/src/main/kotlin/app/passwordstore/crypto/CryptoOptions.kt b/crypto-common/src/main/kotlin/app/passwordstore/crypto/CryptoOptions.kt new file mode 100644 index 00000000..1e60cdba --- /dev/null +++ b/crypto-common/src/main/kotlin/app/passwordstore/crypto/CryptoOptions.kt @@ -0,0 +1,8 @@ +package app.passwordstore.crypto + +/** Defines the contract for a grab-bag of options for individual cryptographic operations. */ +public interface CryptoOptions { + + /** Returns a [Boolean] indicating if the [option] is enabled for this operation. */ + public fun isOptionEnabled(option: String): Boolean +} -- cgit v1.2.3