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

Commit 14e3754

Browse files
Update sshj to 0.30.0 and improve algorithm order (#1026)
Updates sshj to 0.30.0, which brings support for rsa-sha2-* key types and bugfixes related to RSA certificates and Android Keystore backed keys. Along the way, this improves the algorithm preferences to be consistent with the Mozilla Intermediate SSH configuration (as far as possible, given that most certificate types and some encryption algorithms are not yet supported). We also add "ext-info-c" to the kex algorithm proposal to work around certain kinds of "user agent sniffing" that limits the support of rsa-sha2-* key types.
1 parent 82ae0a8 commit 14e3754

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

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

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ package com.zeapo.pwdstore.git.config
66

77
import com.github.ajalt.timberkt.Timber
88
import com.github.ajalt.timberkt.d
9-
import com.hierynomus.sshj.signature.SignatureEdDSA
9+
import com.hierynomus.sshj.key.KeyAlgorithms
1010
import com.hierynomus.sshj.transport.cipher.BlockCiphers
11+
import com.hierynomus.sshj.transport.kex.ExtInfoClientFactory
1112
import com.hierynomus.sshj.transport.mac.Macs
1213
import com.hierynomus.sshj.userauth.keyprovider.OpenSSHKeyV1KeyFile
1314
import java.security.Security
1415
import net.schmizz.keepalive.KeepAliveProvider
1516
import net.schmizz.sshj.ConfigImpl
1617
import net.schmizz.sshj.common.LoggerFactory
17-
import net.schmizz.sshj.signature.SignatureECDSA
18-
import net.schmizz.sshj.signature.SignatureRSA
19-
import net.schmizz.sshj.signature.SignatureRSA.FactoryCERT
2018
import net.schmizz.sshj.transport.compression.NoneCompression
2119
import net.schmizz.sshj.transport.kex.Curve25519SHA256
2220
import net.schmizz.sshj.transport.kex.Curve25519SHA256.FactoryLibSsh
@@ -202,7 +200,7 @@ class SshjConfig : ConfigImpl() {
202200
version = "OpenSSH_8.2p1 Ubuntu-4ubuntu0.1"
203201

204202
initKeyExchangeFactories()
205-
initSignatureFactories()
203+
initKeyAlgorithms()
206204
initRandomFactory()
207205
initFileKeyProviderFactories()
208206
initCipherFactories()
@@ -218,17 +216,22 @@ class SshjConfig : ConfigImpl() {
218216
ECDHNistP.Factory384(),
219217
ECDHNistP.Factory256(),
220218
DHGexSHA256.Factory(),
219+
// Sends "ext-info-c" with the list of key exchange algorithms. This is needed to get
220+
// rsa-sha2-* key types to work with some servers (e.g. GitHub).
221+
ExtInfoClientFactory(),
221222
)
222223
}
223224

224-
private fun initSignatureFactories() {
225-
signatureFactories = listOf(
226-
SignatureEdDSA.Factory(),
227-
SignatureECDSA.Factory256(),
228-
SignatureECDSA.Factory384(),
229-
SignatureECDSA.Factory521(),
230-
SignatureRSA.Factory(),
231-
FactoryCERT(),
225+
private fun initKeyAlgorithms() {
226+
keyAlgorithms = listOf(
227+
KeyAlgorithms.SSHRSACertV01(),
228+
KeyAlgorithms.EdDSA25519(),
229+
KeyAlgorithms.RSASHA512(),
230+
KeyAlgorithms.RSASHA256(),
231+
KeyAlgorithms.ECDSASHANistp521(),
232+
KeyAlgorithms.ECDSASHANistp384(),
233+
KeyAlgorithms.ECDSASHANistp256(),
234+
KeyAlgorithms.SSHRSA(),
232235
)
233236
}
234237

@@ -249,18 +252,18 @@ class SshjConfig : ConfigImpl() {
249252

250253
private fun initCipherFactories() {
251254
cipherFactories = listOf(
252-
BlockCiphers.AES128CTR(),
253-
BlockCiphers.AES192CTR(),
254255
BlockCiphers.AES256CTR(),
256+
BlockCiphers.AES192CTR(),
257+
BlockCiphers.AES128CTR(),
255258
)
256259
}
257260

258261
private fun initMACFactories() {
259262
macFactories = listOf(
260-
Macs.HMACSHA2256(),
263+
Macs.HMACSHA2512Etm(),
261264
Macs.HMACSHA2256Etm(),
262265
Macs.HMACSHA2512(),
263-
Macs.HMACSHA2512Etm(),
266+
Macs.HMACSHA2256(),
264267
)
265268
}
266269

buildSrc/src/main/java/Dependencies.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ object Dependencies {
5959
const val jgit_java7 = "org.eclipse.jgit:org.eclipse.jgit.java7:3.7.1.201504261725-r"
6060
const val leakcanary = "com.squareup.leakcanary:leakcanary-android:2.4"
6161
const val plumber = "com.squareup.leakcanary:plumber-android:2.4"
62-
const val sshj = "com.hierynomus:sshj:0.29.0"
62+
const val sshj = "com.hierynomus:sshj:0.30.0"
6363
const val ssh_auth = "org.sufficientlysecure:sshauthentication-api:1.0"
6464
const val timber = "com.jakewharton.timber:timber:4.7.1"
6565
const val timberkt = "com.github.ajalt:timberkt:1.5.1"

0 commit comments

Comments
 (0)