Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump org.connectbot:sshlib from 2.2.9 to 2.2.23 #1902

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'me.toptas.fancyshowcase:fancyshowcaseview:1.3.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.connectbot:sshlib:2.2.9'
implementation 'org.connectbot:sshlib:2.2.23'
implementation 'net.i2p.crypto:eddsa:0.3.0'
implementation "androidx.core:core-splashscreen:1.0.1"

def lifecycle_version = "2.8.7"
Expand All @@ -109,6 +110,6 @@ repositories {
maven { url "https://maven.aliyun.com/repository/jcenter" }
}

android.sourceSets.all {
android.sourceSets.configureEach {
java.srcDir("src/$name/kotlin")
}
8 changes: 8 additions & 0 deletions app/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Fri Dec 13 17:45:08 EAT 2024
sdk.dir=/Users/gideonokuro/Library/Android/sdk
21 changes: 12 additions & 9 deletions app/src/main/kotlin/io/treehouses/remote/bases/BaseSSH.kt
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ open class BaseSSH : ConnectionMonitor, InteractiveCallback, AuthAgentCallback {

private fun onHostKeyChanged(algorithmName: String, fingerprint: String) {
val header = String.format("@ %s @",
manager!!.res!!.getString(R.string.host_verification_failure_warning_header))
manager!!.res!!.getString(R.string.host_verification_failure_warning_header))
val atsigns = CharArray(header.length)
Arrays.fill(atsigns, '@')
val border = String(atsigns)
Expand Down Expand Up @@ -439,6 +439,10 @@ open class BaseSSH : ConnectionMonitor, InteractiveCallback, AuthAgentCallback {
return responses
}

fun setUseAuthAgent(useAuthAgent: String) {
this.useAuthAgent = useAuthAgent
}

// fun createHost(uri: Uri): HostBean {
// val host = HostBean()
// host.protocol = protocolName
Expand All @@ -457,20 +461,19 @@ open class BaseSSH : ConnectionMonitor, InteractiveCallback, AuthAgentCallback {
// return host
// }

fun setUseAuthAgent(useAuthAgent: String) {
this.useAuthAgent = useAuthAgent
}

override fun retrieveIdentities(): Map<String, ByteArray> {
val pubKeys: MutableMap<String, ByteArray> = HashMap(manager!!.loadedKeypairs.size)
for ((key, value) in manager!!.loadedKeypairs) {
val pair = value?.pair
try {
pubKeys[key] = when (pair?.private) {
is RSAPrivateKey -> RSASHA1Verify.encodeSSHRSAPublicKey(pair.public as RSAPublicKey)
is DSAPrivateKey -> DSASHA1Verify.encodeSSHDSAPublicKey(pair.public as DSAPublicKey)
is ECPrivateKey -> ECDSASHA2Verify.encodeSSHECDSAPublicKey(pair.public as ECPublicKey)
is EdDSAPrivateKey -> Ed25519Verify.encodeSSHEd25519PublicKey(pair.public as EdDSAPublicKey)
is RSAPrivateKey -> RSASHA1Verify.get().encodePublicKey(pair.public as RSAPublicKey)
is DSAPrivateKey -> DSASHA1Verify.get().encodePublicKey(pair.public as DSAPublicKey)
is ECPrivateKey -> {
val verifier = ECDSASHA2Verify.getVerifierForKey(pair.public as ECPublicKey)
verifier.encodePublicKey(pair.public as ECPublicKey)
}
is EdDSAPrivateKey -> Ed25519Verify.get().encodePublicKey(pair.public as EdDSAPublicKey)
else -> ByteArray(0)
}
} catch (e: IOException) {
Expand Down
33 changes: 21 additions & 12 deletions app/src/main/kotlin/io/treehouses/remote/ssh/PubKeyUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,26 @@ object PubKeyUtils {
/*
* OpenSSH compatibility methods
*/
fun convertToOpenSSHFormat(pk: PublicKey, nickName: String) : String {
val rsaKey = if (pk is RSAPublicKey) String(Base64.encode(RSASHA1Verify.encodeSSHRSAPublicKey(pk))) else ""
fun convertToOpenSSHFormat(pk: PublicKey, nickName: String): String {
return when (pk) {
is RSAPublicKey -> "ssh-rsa $rsaKey $nickName"
is DSAPublicKey -> "ssh-dss ${String(Base64.encode(DSASHA1Verify.encodeSSHDSAPublicKey(pk)))} $nickName"
is RSAPublicKey -> {
val rsaKey = String(Base64.encode(RSASHA1Verify.get().encodePublicKey(pk)))
"ssh-rsa $rsaKey $nickName"
}
is DSAPublicKey -> {
val dsaKey = String(Base64.encode(DSASHA1Verify.get().encodePublicKey(pk)))
"ssh-dss $dsaKey $nickName"
}
is ECPublicKey -> {
val keyType = ECDSASHA2Verify.getCurveName(pk.params.curve.field.fieldSize)
val data = String(Base64.encode(ECDSASHA2Verify.encodeSSHECDSAPublicKey(pk)))
"${ECDSASHA2Verify.ECDSA_SHA2_PREFIX} $keyType $data $nickName"
val verifier = ECDSASHA2Verify.getVerifierForKey(pk)
val keyType = verifier.keyFormat
val data = String(Base64.encode(verifier.encodePublicKey(pk)))
"$keyType $data $nickName"
}
is EdDSAPublicKey -> {
val edKey = String(Base64.encode(Ed25519Verify.get().encodePublicKey(pk)))
"${Ed25519Verify.get().keyFormat} $edKey $nickName"
}
is EdDSAPublicKey -> "${Ed25519Verify.ED25519_ID} ${String(Base64.encode(Ed25519Verify.encodeSSHEd25519PublicKey(pk)))} $nickName"
else -> throw InvalidKeyException("Unknown Key Type")
}
}
Expand All @@ -256,10 +265,10 @@ object PubKeyUtils {
fun extractOpenSSHPublic(pair: KeyPair?): ByteArray? {
return try {
when (val pubKey = pair?.public) {
is RSAPublicKey -> RSASHA1Verify.encodeSSHRSAPublicKey(pubKey)
is DSAPublicKey -> DSASHA1Verify.encodeSSHDSAPublicKey(pubKey)
is ECPublicKey -> ECDSASHA2Verify.encodeSSHECDSAPublicKey(pubKey)
is EdDSAPublicKey -> Ed25519Verify.encodeSSHEd25519PublicKey(pubKey)
is RSAPublicKey -> RSASHA1Verify.get().encodePublicKey(pubKey)
is DSAPublicKey -> DSASHA1Verify.get().encodePublicKey(pubKey)
is ECPublicKey -> ECDSASHA2Verify.getVerifierForKey(pubKey).encodePublicKey(pubKey)
is EdDSAPublicKey -> Ed25519Verify.get().encodePublicKey(pubKey)
else -> null
}
} catch (e: IOException) {
Expand Down
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
buildscript {
ext.kotlin_version = '2.1.0'
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.7.2'
Expand All @@ -24,8 +24,7 @@ allprojects {
repositories {
google()
maven { url "https://jitpack.io" }
jcenter()

mavenCentral()
}
}

Expand Down