aboutsummaryrefslogtreecommitdiff
path: root/crypto/age/src
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2024-08-14 00:10:22 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2024-08-18 17:15:42 +0530
commitae7487e76f8da04b7da7268980830f3580389926 (patch)
treed210b216083b0a6f442c763237c8b3986a9b8586 /crypto/age/src
parentdcc7d1e0ee0db3f9157d1427f3de2e9a568bca5b (diff)
fix(crypto/age): iniths/age-backend
Diffstat (limited to 'crypto/age/src')
-rw-r--r--crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeDecryptOptions.kt18
-rw-r--r--crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeEncryptOptions.kt18
-rw-r--r--crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeKey.kt14
-rw-r--r--crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeKeyManager.kt27
4 files changed, 77 insertions, 0 deletions
diff --git a/crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeDecryptOptions.kt b/crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeDecryptOptions.kt
new file mode 100644
index 00000000..49a5dbfe
--- /dev/null
+++ b/crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeDecryptOptions.kt
@@ -0,0 +1,18 @@
+package app.passwordstore.crypto
+
+/** [CryptoOptions] implementation for [kage.Age] decryption operations. */
+public class AgeDecryptOptions private constructor(private val values: Map<String, Boolean>) :
+ CryptoOptions {
+
+ override fun isOptionEnabled(option: String): Boolean {
+ return values.getOrDefault(option, false)
+ }
+
+ /** Builder for [AgeDecryptOptions]. */
+ public class Builder {
+ /** Build the final [AgeDecryptOptions] object. */
+ public fun build(): AgeDecryptOptions {
+ return AgeDecryptOptions(emptyMap())
+ }
+ }
+}
diff --git a/crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeEncryptOptions.kt b/crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeEncryptOptions.kt
new file mode 100644
index 00000000..fdac1a72
--- /dev/null
+++ b/crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeEncryptOptions.kt
@@ -0,0 +1,18 @@
+package app.passwordstore.crypto
+
+/** [CryptoOptions] implementation for [kage.Age] encryption operations. */
+public class AgeEncryptOptions private constructor(private val values: Map<String, Boolean>) :
+ CryptoOptions {
+
+ override fun isOptionEnabled(option: String): Boolean {
+ return values.getOrDefault(option, false)
+ }
+
+ /** Builder for [AgeEncryptOptions]. */
+ public class Builder {
+ /** Build the final [AgeEncryptOptions] object. */
+ public fun build(): AgeEncryptOptions {
+ return AgeEncryptOptions(emptyMap())
+ }
+ }
+}
diff --git a/crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeKey.kt b/crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeKey.kt
new file mode 100644
index 00000000..3c3ff9fd
--- /dev/null
+++ b/crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeKey.kt
@@ -0,0 +1,14 @@
+package app.passwordstore.crypto
+
+import kage.Identity
+import kage.Recipient
+
+/** Sealed hierarchy for the types of keys that [kage.Age] expects. */
+public sealed interface AgeKey {
+
+ /** The public key in [kage.Age], wrapping a [kage.Recipient]. */
+ @JvmInline public value class Public(public val recipient: Recipient) : AgeKey
+
+ /** The private key in [kage.Age], wrapping a [kage.Identity]. */
+ @JvmInline public value class Private(public val identity: Identity) : AgeKey
+}
diff --git a/crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeKeyManager.kt b/crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeKeyManager.kt
new file mode 100644
index 00000000..ddf5a469
--- /dev/null
+++ b/crypto/age/src/main/kotlin/app/passwordstore/crypto/AgeKeyManager.kt
@@ -0,0 +1,27 @@
+package app.passwordstore.crypto
+
+import com.github.michaelbull.result.Result
+
+/** [KeyManager] implementation for [kage.Age]-based keys. */
+public class AgeKeyManager : KeyManager<AgeKey, String> {
+
+ override suspend fun addKey(key: AgeKey, replace: Boolean): Result<AgeKey, Throwable> {
+ TODO("Not yet implemented")
+ }
+
+ override suspend fun removeKey(identifier: String): Result<Unit, Throwable> {
+ TODO("Not yet implemented")
+ }
+
+ override suspend fun getKeyById(id: String): Result<AgeKey, Throwable> {
+ TODO("Not yet implemented")
+ }
+
+ override suspend fun getAllKeys(): Result<List<AgeKey>, Throwable> {
+ TODO("Not yet implemented")
+ }
+
+ override suspend fun getKeyId(key: AgeKey): String? {
+ TODO("Not yet implemented")
+ }
+}