aboutsummaryrefslogtreecommitdiffstats
path: root/crypto-common/src/main/kotlin/dev/msfjarvis/aps/data/crypto/CryptoException.kt
diff options
context:
space:
mode:
authorAditya Wasan <adityawasan55@gmail.com>2021-08-17 04:14:43 +0530
committerGitHub <noreply@github.com>2021-08-17 04:14:43 +0530
commitb7abd561f561af451ec717746e198a8686d10868 (patch)
tree16af9397d205d6501624ba4e98389e21764d9dd3 /crypto-common/src/main/kotlin/dev/msfjarvis/aps/data/crypto/CryptoException.kt
parent9982562dc4e1ab4dbd058cf9d3c3c46fc598dec8 (diff)
downloadHardenedPass-b7abd561f561af451ec717746e198a8686d10868.tar.gz
HardenedPass-b7abd561f561af451ec717746e198a8686d10868.zip
Add `KeyPair` and `KeyManager` to manage keys in the app (#1487)
Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'crypto-common/src/main/kotlin/dev/msfjarvis/aps/data/crypto/CryptoException.kt')
-rw-r--r--crypto-common/src/main/kotlin/dev/msfjarvis/aps/data/crypto/CryptoException.kt19
1 files changed, 19 insertions, 0 deletions
diff --git a/crypto-common/src/main/kotlin/dev/msfjarvis/aps/data/crypto/CryptoException.kt b/crypto-common/src/main/kotlin/dev/msfjarvis/aps/data/crypto/CryptoException.kt
new file mode 100644
index 00000000..6a73d381
--- /dev/null
+++ b/crypto-common/src/main/kotlin/dev/msfjarvis/aps/data/crypto/CryptoException.kt
@@ -0,0 +1,19 @@
+package dev.msfjarvis.aps.data.crypto
+
+public sealed class CryptoException(message: String? = null) : Exception(message)
+
+public sealed class KeyPairException(message: String? = null) : CryptoException(message) {
+ public object PrivateKeyUnavailableException :
+ KeyPairException("Key object does not have a private sub-key")
+}
+
+public sealed class KeyManagerException(message: String? = null) : CryptoException(message) {
+ public object NoKeysAvailableException : KeyManagerException("No keys were found")
+ public object KeyDirectoryUnavailableException :
+ KeyManagerException("Key directory does not exist")
+ public object KeyDeletionFailedException : KeyManagerException("Couldn't delete the key file")
+ public class KeyNotFoundException(keyId: String) :
+ KeyManagerException("No key found with id: $keyId")
+ public class KeyAlreadyExistsException(keyId: String) :
+ KeyManagerException("Pre-existing key was found for $keyId but 'replace' is set to false")
+}