aboutsummaryrefslogtreecommitdiff
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
parentdcc7d1e0ee0db3f9157d1427f3de2e9a568bca5b (diff)
fix(crypto/age): iniths/age-backend
-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
-rw-r--r--gradle/libs.versions.toml1
-rw-r--r--settings.gradle.kts2
8 files changed, 157 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")
+ }
+}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 898526c1..3353cb4c 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -32,6 +32,7 @@ androidx-recyclerview = "androidx.recyclerview:recyclerview:1.4.0-alpha02"
androidx-recyclerviewSelection = "androidx.recyclerview:recyclerview-selection:1.2.0-alpha01"
androidx-security = "androidx.security:security-crypto-ktx:1.1.0-alpha06"
androidx-swiperefreshlayout = "androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01"
+aps-kage = "com.github.android-password-store:kage:0.2.0"
aps-sublimeFuzzy = "com.github.android-password-store:sublime-fuzzy:2.3.4"
aps-zxingAndroidEmbedded = "com.github.android-password-store:zxing-android-embedded:4.2.1"
build-agp = { module = "com.android.tools.build:gradle", version.ref = "agp" }
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 002fac0c..e6f6c9ca 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -88,6 +88,8 @@ include("coroutine-utils")
include("crypto:common")
+include("crypto:age")
+
include("crypto:pgpainless")
include("format:common")