aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2021-02-10 13:00:30 +0530
committerGitHub <noreply@github.com>2021-02-10 13:00:30 +0530
commit7fbe4be71143e0d57a14d19f66496213d8248b1d (patch)
treea6ebe9dbdb38498899c767be446069ddf123079c
parentf7189c0e0a43421202069cadbba6c5ed3d2554a6 (diff)
Update to SSHJ 0.31.0 (#1314)
Co-authored-by: Fabian Henneke <fabian@hen.ne.ke>
-rw-r--r--.idea/jarRepositories.xml10
-rw-r--r--.idea/runConfigurations.xml12
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainKeyProvider.kt12
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainWrappedKeyAlgorithmFactory.kt5
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshjConfig.kt13
-rw-r--r--buildSrc/src/main/java/Dependencies.kt2
6 files changed, 35 insertions, 19 deletions
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index eb2873e7..730487eb 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -26,5 +26,15 @@
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
+ <remote-repository>
+ <option name="id" value="MavenRepo" />
+ <option name="name" value="MavenRepo" />
+ <option name="url" value="https://repo.maven.apache.org/maven2/" />
+ </remote-repository>
+ <remote-repository>
+ <option name="id" value="MavenLocal" />
+ <option name="name" value="MavenLocal" />
+ <option name="url" value="file:$USER_HOME$/.m2/repository/" />
+ </remote-repository>
</component>
</project> \ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 7f68460d..00000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="RunConfigurationProducerService">
- <option name="ignoredProducers">
- <set>
- <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
- <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
- <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
- </set>
- </option>
- </component>
-</project> \ No newline at end of file
diff --git a/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainKeyProvider.kt b/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainKeyProvider.kt
index 7683a867..6781bac1 100644
--- a/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainKeyProvider.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainKeyProvider.kt
@@ -8,15 +8,18 @@ import android.app.PendingIntent
import android.content.Intent
import androidx.activity.result.IntentSenderRequest
import androidx.core.content.edit
+import androidx.lifecycle.lifecycleScope
import com.github.ajalt.timberkt.d
import dev.msfjarvis.aps.util.extensions.OPENPGP_PROVIDER
import dev.msfjarvis.aps.util.extensions.sharedPrefs
import dev.msfjarvis.aps.util.settings.PreferenceKeys
import java.io.Closeable
import java.security.PublicKey
+import java.security.interfaces.ECKey
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import net.schmizz.sshj.common.DisconnectReason
import net.schmizz.sshj.common.KeyType
@@ -175,11 +178,16 @@ class OpenKeychainKeyProvider private constructor(val activity: ContinuationCont
}
override fun getAlgorithm() = publicKey!!.algorithm
+ override fun getParams() = (publicKey as? ECKey)?.params
}
}
override fun close() {
- activity.continueAfterUserInteraction.unregister()
+ activity.lifecycleScope.launch {
+ withContext(Dispatchers.Main) {
+ activity.continueAfterUserInteraction.unregister()
+ }
+ }
sshServiceConnection.disconnect()
}
@@ -187,5 +195,5 @@ class OpenKeychainKeyProvider private constructor(val activity: ContinuationCont
override fun getPublic() = publicKey
- override fun getType() = KeyType.fromKey(publicKey)
+ override fun getType(): KeyType = KeyType.fromKey(publicKey)
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainWrappedKeyAlgorithmFactory.kt b/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainWrappedKeyAlgorithmFactory.kt
index 272a04dd..b5b64c59 100644
--- a/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainWrappedKeyAlgorithmFactory.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/OpenKeychainWrappedKeyAlgorithmFactory.kt
@@ -7,13 +7,16 @@ package dev.msfjarvis.aps.util.git.sshj
import com.hierynomus.sshj.key.KeyAlgorithm
import java.io.ByteArrayOutputStream
import java.security.PrivateKey
+import java.security.interfaces.ECKey
+import java.security.interfaces.ECPrivateKey
+import java.security.spec.ECParameterSpec
import kotlinx.coroutines.runBlocking
import net.schmizz.sshj.common.Buffer
import net.schmizz.sshj.common.Factory
import net.schmizz.sshj.signature.Signature
import org.openintents.ssh.authentication.SshAuthenticationApi
-interface OpenKeychainPrivateKey : PrivateKey {
+interface OpenKeychainPrivateKey : PrivateKey, ECKey {
suspend fun sign(challenge: ByteArray, hashAlgorithm: Int): ByteArray
diff --git a/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshjConfig.kt b/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshjConfig.kt
index 8402d232..afe61904 100644
--- a/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshjConfig.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/util/git/sshj/SshjConfig.kt
@@ -9,6 +9,7 @@ import com.github.ajalt.timberkt.d
import com.github.michaelbull.result.runCatching
import com.hierynomus.sshj.key.KeyAlgorithms
import com.hierynomus.sshj.transport.cipher.BlockCiphers
+import com.hierynomus.sshj.transport.cipher.GcmCiphers
import com.hierynomus.sshj.transport.kex.ExtInfoClientFactory
import com.hierynomus.sshj.transport.mac.Macs
import com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile
@@ -21,6 +22,7 @@ import net.schmizz.sshj.transport.compression.NoneCompression
import net.schmizz.sshj.transport.kex.Curve25519SHA256
import net.schmizz.sshj.transport.kex.Curve25519SHA256.FactoryLibSsh
import net.schmizz.sshj.transport.kex.DHGexSHA256
+import net.schmizz.sshj.transport.kex.ECDHNistP
import net.schmizz.sshj.transport.random.JCERandom
import net.schmizz.sshj.transport.random.SingletonRandomFactory
import net.schmizz.sshj.userauth.keyprovider.OpenSSHKeyFile
@@ -213,6 +215,9 @@ class SshjConfig : ConfigImpl() {
keyExchangeFactories = listOf(
Curve25519SHA256.Factory(),
FactoryLibSsh(),
+ ECDHNistP.Factory521(),
+ ECDHNistP.Factory384(),
+ ECDHNistP.Factory256(),
DHGexSHA256.Factory(),
// Sends "ext-info-c" with the list of key exchange algorithms. This is needed to get
// rsa-sha2-* key types to work with some servers (e.g. GitHub).
@@ -224,12 +229,12 @@ class SshjConfig : ConfigImpl() {
keyAlgorithms = listOf(
KeyAlgorithms.SSHRSACertV01(),
KeyAlgorithms.EdDSA25519(),
- KeyAlgorithms.RSASHA512(),
- KeyAlgorithms.RSASHA256(),
- KeyAlgorithms.SSHRSA(),
KeyAlgorithms.ECDSASHANistp521(),
KeyAlgorithms.ECDSASHANistp384(),
KeyAlgorithms.ECDSASHANistp256(),
+ KeyAlgorithms.RSASHA512(),
+ KeyAlgorithms.RSASHA256(),
+ KeyAlgorithms.SSHRSA(),
).map {
OpenKeychainWrappedKeyAlgorithmFactory(it)
}
@@ -252,6 +257,8 @@ class SshjConfig : ConfigImpl() {
private fun initCipherFactories() {
cipherFactories = listOf(
+ GcmCiphers.AES128GCM(),
+ GcmCiphers.AES256GCM(),
BlockCiphers.AES256CTR(),
BlockCiphers.AES192CTR(),
BlockCiphers.AES128CTR(),
diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt
index 49d2e7a8..a1c640c7 100644
--- a/buildSrc/src/main/java/Dependencies.kt
+++ b/buildSrc/src/main/java/Dependencies.kt
@@ -65,7 +65,7 @@ object Dependencies {
const val leakcanary = "com.squareup.leakcanary:leakcanary-android:2.6"
const val modern_android_prefs = "de.maxr1998:modernandroidpreferences:2.0"
const val plumber = "com.squareup.leakcanary:plumber-android:2.6"
- const val sshj = "com.hierynomus:sshj:0.30.0"
+ const val sshj = "com.hierynomus:sshj:0.31.0"
const val ssh_auth = "org.sufficientlysecure:sshauthentication-api:1.0"
const val timber = "com.jakewharton.timber:timber:4.7.1"
const val timberkt = "com.github.ajalt:timberkt:1.5.1"