aboutsummaryrefslogtreecommitdiff
path: root/crypto/age
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
parentdcc7d1e0ee0db3f9157d1427f3de2e9a568bca5b (diff)
fix(crypto/age): iniths/age-backend
Diffstat (limited to 'crypto/age')
-rw-r--r--crypto/age/build.gradle.kts18
-rw-r--r--crypto/age/lint-baseline.xml59
-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
6 files changed, 154 insertions, 0 deletions
diff --git a/crypto/age/build.gradle.kts b/crypto/age/build.gradle.kts
new file mode 100644
index 00000000..dd44966b
--- /dev/null
+++ b/crypto/age/build.gradle.kts
@@ -0,0 +1,18 @@
+/*
+ * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+plugins { id("com.github.android-password-store.kotlin-jvm-library") }
+
+dependencies {
+ api(projects.crypto.common)
+ implementation(libs.androidx.annotation)
+ implementation(libs.aps.kage)
+ implementation(libs.dagger.hilt.core)
+ implementation(libs.kotlinx.coroutines.core)
+ implementation(libs.thirdparty.kotlinResult)
+ implementation(libs.thirdparty.kotlinResult.coroutines)
+ testImplementation(libs.bundles.testDependencies)
+ testImplementation(libs.kotlinx.coroutines.test)
+ testImplementation(libs.testing.testparameterinjector)
+}
diff --git a/crypto/age/lint-baseline.xml b/crypto/age/lint-baseline.xml
new file mode 100644
index 00000000..73349b64
--- /dev/null
+++ b/crypto/age/lint-baseline.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<issues format="6" by="lint 8.5.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.5.2)" variant="all" version="8.5.2">
+
+ <issue
+ id="StopShip"
+ message="`TODO` call found; points to code which must be fixed prior to release"
+ errorLine1=" TODO(&quot;Not yet implemented&quot;)"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/main/kotlin/app/passwordstore/crypto/AgeKeyManager.kt"
+ line="9"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="StopShip"
+ message="`TODO` call found; points to code which must be fixed prior to release"
+ errorLine1=" TODO(&quot;Not yet implemented&quot;)"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/main/kotlin/app/passwordstore/crypto/AgeKeyManager.kt"
+ line="13"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="StopShip"
+ message="`TODO` call found; points to code which must be fixed prior to release"
+ errorLine1=" TODO(&quot;Not yet implemented&quot;)"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/main/kotlin/app/passwordstore/crypto/AgeKeyManager.kt"
+ line="17"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="StopShip"
+ message="`TODO` call found; points to code which must be fixed prior to release"
+ errorLine1=" TODO(&quot;Not yet implemented&quot;)"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/main/kotlin/app/passwordstore/crypto/AgeKeyManager.kt"
+ line="21"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="StopShip"
+ message="`TODO` call found; points to code which must be fixed prior to release"
+ errorLine1=" TODO(&quot;Not yet implemented&quot;)"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="src/main/kotlin/app/passwordstore/crypto/AgeKeyManager.kt"
+ line="25"
+ column="5"/>
+ </issue>
+
+</issues>
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")
+ }
+}