Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 8d13ce5

Browse files
msfjarvisfmeum
andcommitted
Update to SSHJ 0.31.0 (#1314)
Co-authored-by: Fabian Henneke <[email protected]> (cherry picked from commit 7fbe4be)
1 parent b19d4fb commit 8d13ce5

File tree

6 files changed

+34
-19
lines changed

6 files changed

+34
-19
lines changed

.idea/jarRepositories.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

app/src/main/java/com/zeapo/pwdstore/git/sshj/OpenKeychainKeyProvider.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ import android.app.PendingIntent
88
import android.content.Intent
99
import androidx.activity.result.IntentSenderRequest
1010
import androidx.core.content.edit
11+
import androidx.lifecycle.lifecycleScope
1112
import com.github.ajalt.timberkt.d
1213
import com.zeapo.pwdstore.utils.OPENPGP_PROVIDER
1314
import com.zeapo.pwdstore.utils.PreferenceKeys
1415
import com.zeapo.pwdstore.utils.sharedPrefs
1516
import java.io.Closeable
1617
import java.security.PublicKey
18+
import java.security.interfaces.ECKey
1719
import kotlin.coroutines.resume
1820
import kotlin.coroutines.suspendCoroutine
1921
import kotlinx.coroutines.Dispatchers
22+
import kotlinx.coroutines.launch
2023
import kotlinx.coroutines.withContext
2124
import net.schmizz.sshj.common.DisconnectReason
2225
import net.schmizz.sshj.common.KeyType
@@ -175,17 +178,22 @@ class OpenKeychainKeyProvider private constructor(val activity: ContinuationCont
175178
}
176179

177180
override fun getAlgorithm() = publicKey!!.algorithm
181+
override fun getParams() = (publicKey as? ECKey)?.params
178182
}
179183
}
180184

181185
override fun close() {
182-
activity.continueAfterUserInteraction.unregister()
186+
activity.lifecycleScope.launch {
187+
withContext(Dispatchers.Main) {
188+
activity.continueAfterUserInteraction.unregister()
189+
}
190+
}
183191
sshServiceConnection.disconnect()
184192
}
185193

186194
override fun getPrivate() = privateKey
187195

188196
override fun getPublic() = publicKey
189197

190-
override fun getType() = KeyType.fromKey(publicKey)
198+
override fun getType(): KeyType = KeyType.fromKey(publicKey)
191199
}

app/src/main/java/com/zeapo/pwdstore/git/sshj/OpenKeychainWrappedKeyAlgorithmFactory.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ package com.zeapo.pwdstore.git.sshj
77
import com.hierynomus.sshj.key.KeyAlgorithm
88
import java.io.ByteArrayOutputStream
99
import java.security.PrivateKey
10+
import java.security.interfaces.ECKey
11+
import java.security.interfaces.ECPrivateKey
12+
import java.security.spec.ECParameterSpec
1013
import kotlinx.coroutines.runBlocking
1114
import net.schmizz.sshj.common.Buffer
1215
import net.schmizz.sshj.common.Factory
1316
import net.schmizz.sshj.signature.Signature
1417
import org.openintents.ssh.authentication.SshAuthenticationApi
1518

16-
interface OpenKeychainPrivateKey : PrivateKey {
19+
interface OpenKeychainPrivateKey : PrivateKey, ECKey {
1720

1821
suspend fun sign(challenge: ByteArray, hashAlgorithm: Int): ByteArray
1922

app/src/main/java/com/zeapo/pwdstore/git/sshj/SshjConfig.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.github.ajalt.timberkt.d
99
import com.github.michaelbull.result.runCatching
1010
import com.hierynomus.sshj.key.KeyAlgorithms
1111
import com.hierynomus.sshj.transport.cipher.BlockCiphers
12+
import com.hierynomus.sshj.transport.cipher.GcmCiphers
1213
import com.hierynomus.sshj.transport.kex.ExtInfoClientFactory
1314
import com.hierynomus.sshj.transport.mac.Macs
1415
import com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile
@@ -214,6 +215,9 @@ class SshjConfig : ConfigImpl() {
214215
keyExchangeFactories = listOf(
215216
Curve25519SHA256.Factory(),
216217
FactoryLibSsh(),
218+
ECDHNistP.Factory521(),
219+
ECDHNistP.Factory384(),
220+
ECDHNistP.Factory256(),
217221
DHGexSHA256.Factory(),
218222
// Sends "ext-info-c" with the list of key exchange algorithms. This is needed to get
219223
// rsa-sha2-* key types to work with some servers (e.g. GitHub).
@@ -225,12 +229,12 @@ class SshjConfig : ConfigImpl() {
225229
keyAlgorithms = listOf(
226230
KeyAlgorithms.SSHRSACertV01(),
227231
KeyAlgorithms.EdDSA25519(),
228-
KeyAlgorithms.RSASHA512(),
229-
KeyAlgorithms.RSASHA256(),
230-
KeyAlgorithms.SSHRSA(),
231232
KeyAlgorithms.ECDSASHANistp521(),
232233
KeyAlgorithms.ECDSASHANistp384(),
233234
KeyAlgorithms.ECDSASHANistp256(),
235+
KeyAlgorithms.RSASHA512(),
236+
KeyAlgorithms.RSASHA256(),
237+
KeyAlgorithms.SSHRSA(),
234238
).map {
235239
OpenKeychainWrappedKeyAlgorithmFactory(it)
236240
}
@@ -253,6 +257,8 @@ class SshjConfig : ConfigImpl() {
253257

254258
private fun initCipherFactories() {
255259
cipherFactories = listOf(
260+
GcmCiphers.AES128GCM(),
261+
GcmCiphers.AES256GCM(),
256262
BlockCiphers.AES256CTR(),
257263
BlockCiphers.AES192CTR(),
258264
BlockCiphers.AES128CTR(),

buildSrc/src/main/java/Dependencies.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object Dependencies {
5656
const val kotlin_result = "com.michael-bull.kotlin-result:kotlin-result:1.1.9"
5757
const val leakcanary = "com.squareup.leakcanary:leakcanary-android:2.5"
5858
const val plumber = "com.squareup.leakcanary:plumber-android:2.5"
59-
const val sshj = "com.hierynomus:sshj:0.30.0"
59+
const val sshj = "com.hierynomus:sshj:0.31.0"
6060
const val ssh_auth = "org.sufficientlysecure:sshauthentication-api:1.0"
6161
const val timber = "com.jakewharton.timber:timber:4.7.1"
6262
const val timberkt = "com.github.ajalt:timberkt:1.5.1"

0 commit comments

Comments
 (0)