mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-09-03 07:45:08 +00:00
fix: remove NoKeysProvided error
We're making this invariant impossible in the code paths that hit it
This commit is contained in:
@@ -37,8 +37,5 @@ public sealed class CryptoHandlerException(message: String? = null, cause: Throw
|
|||||||
/** The passphrase provided for decryption was incorrect. */
|
/** The passphrase provided for decryption was incorrect. */
|
||||||
public class IncorrectPassphraseException(cause: Throwable) : CryptoHandlerException(null, cause)
|
public class IncorrectPassphraseException(cause: Throwable) : CryptoHandlerException(null, cause)
|
||||||
|
|
||||||
/** No keys were provided for encryption. */
|
|
||||||
public class NoKeysProvided(message: String?) : CryptoHandlerException(message, null)
|
|
||||||
|
|
||||||
/** An unexpected error that cannot be mapped to a known type. */
|
/** An unexpected error that cannot be mapped to a known type. */
|
||||||
public class UnknownError(cause: Throwable) : CryptoHandlerException(null, cause)
|
public class UnknownError(cause: Throwable) : CryptoHandlerException(null, cause)
|
||||||
|
@@ -7,7 +7,6 @@ package app.passwordstore.crypto
|
|||||||
|
|
||||||
import app.passwordstore.crypto.errors.CryptoHandlerException
|
import app.passwordstore.crypto.errors.CryptoHandlerException
|
||||||
import app.passwordstore.crypto.errors.IncorrectPassphraseException
|
import app.passwordstore.crypto.errors.IncorrectPassphraseException
|
||||||
import app.passwordstore.crypto.errors.NoKeysProvided
|
|
||||||
import app.passwordstore.crypto.errors.UnknownError
|
import app.passwordstore.crypto.errors.UnknownError
|
||||||
import com.github.michaelbull.result.Result
|
import com.github.michaelbull.result.Result
|
||||||
import com.github.michaelbull.result.mapError
|
import com.github.michaelbull.result.mapError
|
||||||
@@ -38,7 +37,7 @@ public class PGPainlessCryptoHandler @Inject constructor() :
|
|||||||
options: PGPDecryptOptions,
|
options: PGPDecryptOptions,
|
||||||
): Result<Unit, CryptoHandlerException> =
|
): Result<Unit, CryptoHandlerException> =
|
||||||
runCatching {
|
runCatching {
|
||||||
if (keys.isEmpty()) throw NoKeysProvided("No keys provided for encryption")
|
require(keys.isNotEmpty())
|
||||||
val keyringCollection =
|
val keyringCollection =
|
||||||
keys
|
keys
|
||||||
.map { key -> PGPainless.readKeyRing().secretKeyRing(key.contents) }
|
.map { key -> PGPainless.readKeyRing().secretKeyRing(key.contents) }
|
||||||
@@ -68,7 +67,7 @@ public class PGPainlessCryptoHandler @Inject constructor() :
|
|||||||
options: PGPEncryptOptions,
|
options: PGPEncryptOptions,
|
||||||
): Result<Unit, CryptoHandlerException> =
|
): Result<Unit, CryptoHandlerException> =
|
||||||
runCatching {
|
runCatching {
|
||||||
if (keys.isEmpty()) throw NoKeysProvided("No keys provided for encryption")
|
require(keys.isNotEmpty())
|
||||||
val publicKeyRings =
|
val publicKeyRings =
|
||||||
keys.mapNotNull(KeyUtils::tryParseKeyring).mapNotNull { keyRing ->
|
keys.mapNotNull(KeyUtils::tryParseKeyring).mapNotNull { keyRing ->
|
||||||
when (keyRing) {
|
when (keyRing) {
|
||||||
|
Reference in New Issue
Block a user