Update to SSHJ 0.31.0 (#1314)

Co-authored-by: Fabian Henneke <fabian@hen.ne.ke>
This commit is contained in:
Harsh Shandilya 2021-02-10 13:00:30 +05:30 committed by GitHub
parent f7189c0e0a
commit 7fbe4be711
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 19 deletions

View file

@ -26,5 +26,15 @@
<option name="name" value="Google" /> <option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" /> <option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository> </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> </component>
</project> </project>

View file

@ -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>

View file

@ -8,15 +8,18 @@ import android.app.PendingIntent
import android.content.Intent import android.content.Intent
import androidx.activity.result.IntentSenderRequest import androidx.activity.result.IntentSenderRequest
import androidx.core.content.edit import androidx.core.content.edit
import androidx.lifecycle.lifecycleScope
import com.github.ajalt.timberkt.d import com.github.ajalt.timberkt.d
import dev.msfjarvis.aps.util.extensions.OPENPGP_PROVIDER import dev.msfjarvis.aps.util.extensions.OPENPGP_PROVIDER
import dev.msfjarvis.aps.util.extensions.sharedPrefs import dev.msfjarvis.aps.util.extensions.sharedPrefs
import dev.msfjarvis.aps.util.settings.PreferenceKeys import dev.msfjarvis.aps.util.settings.PreferenceKeys
import java.io.Closeable import java.io.Closeable
import java.security.PublicKey import java.security.PublicKey
import java.security.interfaces.ECKey
import kotlin.coroutines.resume import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine import kotlin.coroutines.suspendCoroutine
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import net.schmizz.sshj.common.DisconnectReason import net.schmizz.sshj.common.DisconnectReason
import net.schmizz.sshj.common.KeyType import net.schmizz.sshj.common.KeyType
@ -175,11 +178,16 @@ class OpenKeychainKeyProvider private constructor(val activity: ContinuationCont
} }
override fun getAlgorithm() = publicKey!!.algorithm override fun getAlgorithm() = publicKey!!.algorithm
override fun getParams() = (publicKey as? ECKey)?.params
} }
} }
override fun close() { override fun close() {
activity.lifecycleScope.launch {
withContext(Dispatchers.Main) {
activity.continueAfterUserInteraction.unregister() activity.continueAfterUserInteraction.unregister()
}
}
sshServiceConnection.disconnect() sshServiceConnection.disconnect()
} }
@ -187,5 +195,5 @@ class OpenKeychainKeyProvider private constructor(val activity: ContinuationCont
override fun getPublic() = publicKey override fun getPublic() = publicKey
override fun getType() = KeyType.fromKey(publicKey) override fun getType(): KeyType = KeyType.fromKey(publicKey)
} }

View file

@ -7,13 +7,16 @@ package dev.msfjarvis.aps.util.git.sshj
import com.hierynomus.sshj.key.KeyAlgorithm import com.hierynomus.sshj.key.KeyAlgorithm
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.security.PrivateKey import java.security.PrivateKey
import java.security.interfaces.ECKey
import java.security.interfaces.ECPrivateKey
import java.security.spec.ECParameterSpec
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import net.schmizz.sshj.common.Buffer import net.schmizz.sshj.common.Buffer
import net.schmizz.sshj.common.Factory import net.schmizz.sshj.common.Factory
import net.schmizz.sshj.signature.Signature import net.schmizz.sshj.signature.Signature
import org.openintents.ssh.authentication.SshAuthenticationApi import org.openintents.ssh.authentication.SshAuthenticationApi
interface OpenKeychainPrivateKey : PrivateKey { interface OpenKeychainPrivateKey : PrivateKey, ECKey {
suspend fun sign(challenge: ByteArray, hashAlgorithm: Int): ByteArray suspend fun sign(challenge: ByteArray, hashAlgorithm: Int): ByteArray

View file

@ -9,6 +9,7 @@ import com.github.ajalt.timberkt.d
import com.github.michaelbull.result.runCatching import com.github.michaelbull.result.runCatching
import com.hierynomus.sshj.key.KeyAlgorithms import com.hierynomus.sshj.key.KeyAlgorithms
import com.hierynomus.sshj.transport.cipher.BlockCiphers 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.kex.ExtInfoClientFactory
import com.hierynomus.sshj.transport.mac.Macs import com.hierynomus.sshj.transport.mac.Macs
import com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile 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
import net.schmizz.sshj.transport.kex.Curve25519SHA256.FactoryLibSsh import net.schmizz.sshj.transport.kex.Curve25519SHA256.FactoryLibSsh
import net.schmizz.sshj.transport.kex.DHGexSHA256 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.JCERandom
import net.schmizz.sshj.transport.random.SingletonRandomFactory import net.schmizz.sshj.transport.random.SingletonRandomFactory
import net.schmizz.sshj.userauth.keyprovider.OpenSSHKeyFile import net.schmizz.sshj.userauth.keyprovider.OpenSSHKeyFile
@ -213,6 +215,9 @@ class SshjConfig : ConfigImpl() {
keyExchangeFactories = listOf( keyExchangeFactories = listOf(
Curve25519SHA256.Factory(), Curve25519SHA256.Factory(),
FactoryLibSsh(), FactoryLibSsh(),
ECDHNistP.Factory521(),
ECDHNistP.Factory384(),
ECDHNistP.Factory256(),
DHGexSHA256.Factory(), DHGexSHA256.Factory(),
// Sends "ext-info-c" with the list of key exchange algorithms. This is needed to get // 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). // rsa-sha2-* key types to work with some servers (e.g. GitHub).
@ -224,12 +229,12 @@ class SshjConfig : ConfigImpl() {
keyAlgorithms = listOf( keyAlgorithms = listOf(
KeyAlgorithms.SSHRSACertV01(), KeyAlgorithms.SSHRSACertV01(),
KeyAlgorithms.EdDSA25519(), KeyAlgorithms.EdDSA25519(),
KeyAlgorithms.RSASHA512(),
KeyAlgorithms.RSASHA256(),
KeyAlgorithms.SSHRSA(),
KeyAlgorithms.ECDSASHANistp521(), KeyAlgorithms.ECDSASHANistp521(),
KeyAlgorithms.ECDSASHANistp384(), KeyAlgorithms.ECDSASHANistp384(),
KeyAlgorithms.ECDSASHANistp256(), KeyAlgorithms.ECDSASHANistp256(),
KeyAlgorithms.RSASHA512(),
KeyAlgorithms.RSASHA256(),
KeyAlgorithms.SSHRSA(),
).map { ).map {
OpenKeychainWrappedKeyAlgorithmFactory(it) OpenKeychainWrappedKeyAlgorithmFactory(it)
} }
@ -252,6 +257,8 @@ class SshjConfig : ConfigImpl() {
private fun initCipherFactories() { private fun initCipherFactories() {
cipherFactories = listOf( cipherFactories = listOf(
GcmCiphers.AES128GCM(),
GcmCiphers.AES256GCM(),
BlockCiphers.AES256CTR(), BlockCiphers.AES256CTR(),
BlockCiphers.AES192CTR(), BlockCiphers.AES192CTR(),
BlockCiphers.AES128CTR(), BlockCiphers.AES128CTR(),

View file

@ -65,7 +65,7 @@ object Dependencies {
const val leakcanary = "com.squareup.leakcanary:leakcanary-android:2.6" const val leakcanary = "com.squareup.leakcanary:leakcanary-android:2.6"
const val modern_android_prefs = "de.maxr1998:modernandroidpreferences:2.0" const val modern_android_prefs = "de.maxr1998:modernandroidpreferences:2.0"
const val plumber = "com.squareup.leakcanary:plumber-android:2.6" 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 ssh_auth = "org.sufficientlysecure:sshauthentication-api:1.0"
const val timber = "com.jakewharton.timber:timber:4.7.1" const val timber = "com.jakewharton.timber:timber:4.7.1"
const val timberkt = "com.github.ajalt:timberkt:1.5.1" const val timberkt = "com.github.ajalt:timberkt:1.5.1"