diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2021-07-11 22:52:26 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-11 17:22:26 +0000 |
commit | 6e4ffe290265ef8b3cd82f5ab6a7eb8c0157bf6a (patch) | |
tree | 13739c1079e5cd4ce609cdbb4501450b2eabecb4 /crypto-common | |
parent | 9c388e49748084bdac3fb277ea507b80b9c7c33a (diff) |
Add initial implementation of Gopenpgp-backed PGP (#1441)
Diffstat (limited to 'crypto-common')
-rw-r--r-- | crypto-common/api/crypto-common.api | 6 | ||||
-rw-r--r-- | crypto-common/build.gradle.kts | 8 | ||||
-rw-r--r-- | crypto-common/src/main/kotlin/dev/msfjarvis/aps/data/crypto/CryptoHandler.kt | 25 |
3 files changed, 39 insertions, 0 deletions
diff --git a/crypto-common/api/crypto-common.api b/crypto-common/api/crypto-common.api new file mode 100644 index 00000000..7493379c --- /dev/null +++ b/crypto-common/api/crypto-common.api @@ -0,0 +1,6 @@ +public abstract interface class dev/msfjarvis/aps/data/crypto/CryptoHandler { + public abstract fun canHandle (Ljava/lang/String;)Z + public abstract fun decrypt (Ljava/lang/String;[B[B)[B + public abstract fun encrypt (Ljava/lang/String;[B)[B +} + diff --git a/crypto-common/build.gradle.kts b/crypto-common/build.gradle.kts new file mode 100644 index 00000000..c1f3eef8 --- /dev/null +++ b/crypto-common/build.gradle.kts @@ -0,0 +1,8 @@ +/* + * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. + * SPDX-License-Identifier: GPL-3.0-only + */ +plugins { + kotlin("jvm") + `aps-plugin` +} diff --git a/crypto-common/src/main/kotlin/dev/msfjarvis/aps/data/crypto/CryptoHandler.kt b/crypto-common/src/main/kotlin/dev/msfjarvis/aps/data/crypto/CryptoHandler.kt new file mode 100644 index 00000000..453613a4 --- /dev/null +++ b/crypto-common/src/main/kotlin/dev/msfjarvis/aps/data/crypto/CryptoHandler.kt @@ -0,0 +1,25 @@ +/* + * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. + * SPDX-License-Identifier: GPL-3.0-only + */ + +package dev.msfjarvis.aps.data.crypto + +/** Generic interface to implement cryptographic operations on top of. */ +public interface CryptoHandler { + + /** + * Decrypt the given [ciphertext] using a [privateKey] and [passphrase], returning a [ByteArray] + * corresponding to the decrypted plaintext. + */ + public fun decrypt(privateKey: String, passphrase: ByteArray, ciphertext: ByteArray): ByteArray + + /** + * Encrypt the given [plaintext] to the provided [publicKey], returning the encrypted ciphertext + * as a [ByteArray] + */ + public fun encrypt(publicKey: String, plaintext: ByteArray): ByteArray + + /** Given a [fileName], return whether this instance can handle it. */ + public fun canHandle(fileName: String): Boolean +} |