Cloud password has to be MD5
This commit is contained in:
parent
5d438daf83
commit
37fa225d95
2 changed files with 15 additions and 3 deletions
|
@ -63,3 +63,5 @@ fun InputStream.readNBytesCompat(len: Int): ByteArray? {
|
||||||
fun InputStream.readAllBytesCompat(): ByteArray? {
|
fun InputStream.readAllBytesCompat(): ByteArray? {
|
||||||
return readNBytesCompat(Int.MAX_VALUE)
|
return readNBytesCompat(Int.MAX_VALUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun ByteArray.toHexString() = joinToString("") { "%02X".format(it) }
|
|
@ -3,6 +3,8 @@ import com.xenomachina.argparser.default
|
||||||
import com.xenomachina.argparser.mainBody
|
import com.xenomachina.argparser.mainBody
|
||||||
import org.fusesource.jansi.internal.CLibrary.STDIN_FILENO
|
import org.fusesource.jansi.internal.CLibrary.STDIN_FILENO
|
||||||
import org.fusesource.jansi.internal.CLibrary.isatty
|
import org.fusesource.jansi.internal.CLibrary.isatty
|
||||||
|
import java.nio.charset.Charset
|
||||||
|
import java.security.MessageDigest
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
class Args(parser: ArgParser) {
|
class Args(parser: ArgParser) {
|
||||||
|
@ -44,10 +46,18 @@ fun main(args: Array<String>) = mainBody {
|
||||||
exitProcess(1)
|
exitProcess(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val hashedPassword: String? = cloudPassword?.let {
|
||||||
|
MessageDigest
|
||||||
|
.getInstance("MD5")
|
||||||
|
.apply { update(it.toByteArray(Charset.forName("UTF-8"))) }
|
||||||
|
.digest()
|
||||||
|
.toHexString()
|
||||||
|
}
|
||||||
|
|
||||||
val aes = if (keyExchange != null) {
|
val aes = if (keyExchange != null) {
|
||||||
StreamAesUtils.generateFromExchangeKeyAndSuperSecretKey(keyExchange, cloudPassword)
|
StreamAesUtils.generateFromExchangeKeyAndSuperSecretKey(keyExchange, hashedPassword)
|
||||||
} else {
|
} else {
|
||||||
StreamAesUtils.fromUserNonceSuperSecretKey(username, nonce, cloudPassword)
|
StreamAesUtils.fromUserNonceSuperSecretKey(username, nonce, hashedPassword)
|
||||||
}
|
}
|
||||||
|
|
||||||
val output = if (encrypt) {
|
val output = if (encrypt) {
|
||||||
|
|
Loading…
Reference in a new issue