summaryrefslogtreecommitdiff
path: root/crypto-pgpainless/src/main/kotlin
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-03-25 12:16:52 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-03-25 12:26:01 +0530
commit1e7401265676e79afbffb0396a0605726b93509e (patch)
treeec54a8775ad22fbe542192731d52d13f0c344174 /crypto-pgpainless/src/main/kotlin
parente2900c26de9e9c96312ad860bce07383692760d1 (diff)
fix: remove NoKeysProvided error
We're making this invariant impossible in the code paths that hit it
Diffstat (limited to 'crypto-pgpainless/src/main/kotlin')
-rw-r--r--crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt5
1 files changed, 2 insertions, 3 deletions
diff --git a/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt b/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt
index e1084dec..2bf68401 100644
--- a/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt
+++ b/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandler.kt
@@ -7,7 +7,6 @@ package app.passwordstore.crypto
import app.passwordstore.crypto.errors.CryptoHandlerException
import app.passwordstore.crypto.errors.IncorrectPassphraseException
-import app.passwordstore.crypto.errors.NoKeysProvided
import app.passwordstore.crypto.errors.UnknownError
import com.github.michaelbull.result.Result
import com.github.michaelbull.result.mapError
@@ -38,7 +37,7 @@ public class PGPainlessCryptoHandler @Inject constructor() :
options: PGPDecryptOptions,
): Result<Unit, CryptoHandlerException> =
runCatching {
- if (keys.isEmpty()) throw NoKeysProvided("No keys provided for encryption")
+ require(keys.isNotEmpty())
val keyringCollection =
keys
.map { key -> PGPainless.readKeyRing().secretKeyRing(key.contents) }
@@ -68,7 +67,7 @@ public class PGPainlessCryptoHandler @Inject constructor() :
options: PGPEncryptOptions,
): Result<Unit, CryptoHandlerException> =
runCatching {
- if (keys.isEmpty()) throw NoKeysProvided("No keys provided for encryption")
+ require(keys.isNotEmpty())
val publicKeyRings =
keys.mapNotNull(KeyUtils::tryParseKeyring).mapNotNull { keyRing ->
when (keyRing) {