2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 05:37:43 +00:00

chore: use default signing and key exchange algorithms

This commit is contained in:
ShellWen Chen 2024-06-18 03:40:05 +08:00 committed by Albert Vaca Cintora
parent 0fb6e25682
commit 6513bb1320

View File

@ -10,10 +10,8 @@ import android.content.Context
import android.os.Build
import android.util.Log
import org.apache.sshd.common.file.nativefs.NativeFileSystemFactory
import org.apache.sshd.common.kex.BuiltinDHFactories
import org.apache.sshd.common.keyprovider.AbstractKeyPairProvider
import org.apache.sshd.common.session.SessionContext
import org.apache.sshd.common.signature.BuiltinSignatures
import org.apache.sshd.common.util.io.PathUtils
import org.apache.sshd.common.util.security.SecurityUtils.SECURITY_PROVIDER_REGISTRARS
import org.apache.sshd.scp.server.ScpCommandFactory
@ -21,7 +19,6 @@ import org.apache.sshd.server.ServerBuilder
import org.apache.sshd.server.SshServer
import org.apache.sshd.server.auth.password.PasswordAuthenticator
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator
import org.apache.sshd.server.kex.DHGServer
import org.apache.sshd.server.session.ServerSession
import org.apache.sshd.server.subsystem.SubsystemFactory
import org.apache.sshd.sftp.server.FileHandle
@ -70,26 +67,6 @@ internal class SimpleSftpServer {
@Throws(GeneralSecurityException::class)
fun initialize(context: Context?, device: Device) {
val sshd = ServerBuilder.builder().apply {
signatureFactories(
listOf(
BuiltinSignatures.nistp256,
BuiltinSignatures.nistp384,
BuiltinSignatures.nistp521,
BuiltinSignatures.dsa,
SignatureRSASHA256.Factory,
BuiltinSignatures.rsa // Insecure SHA1, left for backwards compatibility
)
)
keyExchangeFactories(listOf(
BuiltinDHFactories.ecdhp256, // ecdh-sha2-nistp256
BuiltinDHFactories.ecdhp384, // ecdh-sha2-nistp384
BuiltinDHFactories.ecdhp521, // ecdh-sha2-nistp521
DHG14_256Factory, // diffie-hellman-group14-sha256
BuiltinDHFactories.dhg14, // Insecure diffie-hellman-group14-sha1, left for backwards-compatibility.
).map {
DHGServer.newFactory(it)
})
fileSystemFactory(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
NativeFileSystemFactory()