summaryrefslogtreecommitdiff
path: root/crypto-pgpainless/src/main/kotlin
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-06-15 15:49:32 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-06-15 16:17:59 +0530
commit5dac84c3c882ee42bc541042684de18d7166fdd3 (patch)
tree227d2cec4c494be13bb942b70ab913b90325e452 /crypto-pgpainless/src/main/kotlin
parentc168ce2e8643b86eb9fd25339d79a9a070005f83 (diff)
refactor: consistently adopt PGP over GPG for naming
PGP is the standard, GPG is an implementation of it. We're adhering to PGP, and not using GPG.
Diffstat (limited to 'crypto-pgpainless/src/main/kotlin')
-rw-r--r--crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/KeyUtils.kt4
-rw-r--r--crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPIdentifier.kt (renamed from crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/GpgIdentifier.kt)16
-rw-r--r--crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPKeyManager.kt12
3 files changed, 16 insertions, 16 deletions
diff --git a/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/KeyUtils.kt b/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/KeyUtils.kt
index da77bf33..3c36060f 100644
--- a/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/KeyUtils.kt
+++ b/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/KeyUtils.kt
@@ -5,8 +5,8 @@
package app.passwordstore.crypto
-import app.passwordstore.crypto.GpgIdentifier.KeyId
-import app.passwordstore.crypto.GpgIdentifier.UserId
+import app.passwordstore.crypto.PGPIdentifier.KeyId
+import app.passwordstore.crypto.PGPIdentifier.UserId
import com.github.michaelbull.result.get
import com.github.michaelbull.result.runCatching
import org.bouncycastle.openpgp.PGPKeyRing
diff --git a/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/GpgIdentifier.kt b/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPIdentifier.kt
index 96b9cc88..98a1de2e 100644
--- a/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/GpgIdentifier.kt
+++ b/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPIdentifier.kt
@@ -8,11 +8,11 @@ package app.passwordstore.crypto
import java.util.Locale
import java.util.regex.Pattern
-/** Supertype for valid identifiers of GPG keys. */
-public sealed class GpgIdentifier {
+/** Supertype for valid identifiers of PGP keys. */
+public sealed class PGPIdentifier {
- /** A [GpgIdentifier] that represents either a long key ID or a fingerprint. */
- public data class KeyId(val id: Long) : GpgIdentifier() {
+ /** A [PGPIdentifier] that represents either a long key ID or a fingerprint. */
+ public data class KeyId(val id: Long) : PGPIdentifier() {
override fun toString(): String {
return convertKeyIdToHex(id)
}
@@ -36,10 +36,10 @@ public sealed class GpgIdentifier {
}
/**
- * A [GpgIdentifier] that represents the textual name/email combination corresponding to a key.
+ * A [PGPIdentifier] that represents the textual name/email combination corresponding to a key.
* Despite the [email] property in this class, the value is not guaranteed to be a valid email.
*/
- public data class UserId(val email: String) : GpgIdentifier() {
+ public data class UserId(val email: String) : PGPIdentifier() {
override fun toString(): String {
return email
}
@@ -53,10 +53,10 @@ public sealed class GpgIdentifier {
private const val TRUNCATED_FINGERPRINT_LENGTH = 16
/**
- * Attempts to parse an untyped String identifier into a concrete subtype of [GpgIdentifier].
+ * Attempts to parse an untyped String identifier into a concrete subtype of [PGPIdentifier].
*/
@Suppress("ReturnCount")
- public fun fromString(identifier: String): GpgIdentifier? {
+ public fun fromString(identifier: String): PGPIdentifier? {
if (identifier.isEmpty()) return null
// Match long key IDs:
// FF22334455667788 or 0xFF22334455667788
diff --git a/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPKeyManager.kt b/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPKeyManager.kt
index f6ef50b3..a34d0379 100644
--- a/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPKeyManager.kt
+++ b/crypto-pgpainless/src/main/kotlin/app/passwordstore/crypto/PGPKeyManager.kt
@@ -32,7 +32,7 @@ public class PGPKeyManager
constructor(
filesDir: String,
private val dispatcher: CoroutineDispatcher,
-) : KeyManager<PGPKey, GpgIdentifier> {
+) : KeyManager<PGPKey, PGPIdentifier> {
private val keyDir = File(filesDir, KEY_DIR_NAME)
@@ -74,7 +74,7 @@ constructor(
}
/** @see KeyManager.removeKey */
- override suspend fun removeKey(identifier: GpgIdentifier): Result<Unit, Throwable> =
+ override suspend fun removeKey(identifier: PGPIdentifier): Result<Unit, Throwable> =
withContext(dispatcher) {
runSuspendCatching {
if (!keyDirExists()) throw KeyDirectoryUnavailableException
@@ -87,7 +87,7 @@ constructor(
}
/** @see KeyManager.getKeyById */
- override suspend fun getKeyById(id: GpgIdentifier): Result<PGPKey, Throwable> =
+ override suspend fun getKeyById(id: PGPIdentifier): Result<PGPKey, Throwable> =
withContext(dispatcher) {
runSuspendCatching {
if (!keyDirExists()) throw KeyDirectoryUnavailableException
@@ -97,14 +97,14 @@ constructor(
val matchResult =
when (id) {
- is GpgIdentifier.KeyId -> {
+ is PGPIdentifier.KeyId -> {
val keyIdMatch =
keys
.map { key -> key to tryGetId(key) }
.firstOrNull { (_, keyId) -> keyId?.id == id.id }
keyIdMatch?.first
}
- is GpgIdentifier.UserId -> {
+ is PGPIdentifier.UserId -> {
val selector = SelectUserId.byEmail(id.email)
val userIdMatch =
keys
@@ -134,7 +134,7 @@ constructor(
}
/** @see KeyManager.getKeyById */
- override suspend fun getKeyId(key: PGPKey): GpgIdentifier? = tryGetId(key)
+ override suspend fun getKeyId(key: PGPKey): PGPIdentifier? = tryGetId(key)
/** Checks if [keyDir] exists and attempts to create it if not. */
private fun keyDirExists(): Boolean {