Cloud password has to be MD5

This commit is contained in:
Davide Depau 2020-12-01 00:55:26 +01:00
parent 5d438daf83
commit 37fa225d95
2 changed files with 15 additions and 3 deletions

View File

@ -62,4 +62,6 @@ fun InputStream.readNBytesCompat(len: Int): ByteArray? {
@Throws(IOException::class)
fun InputStream.readAllBytesCompat(): ByteArray? {
return readNBytesCompat(Int.MAX_VALUE)
}
}
fun ByteArray.toHexString() = joinToString("") { "%02X".format(it) }

View File

@ -3,6 +3,8 @@ import com.xenomachina.argparser.default
import com.xenomachina.argparser.mainBody
import org.fusesource.jansi.internal.CLibrary.STDIN_FILENO
import org.fusesource.jansi.internal.CLibrary.isatty
import java.nio.charset.Charset
import java.security.MessageDigest
import kotlin.system.exitProcess
class Args(parser: ArgParser) {
@ -44,10 +46,18 @@ fun main(args: Array<String>) = mainBody {
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) {
StreamAesUtils.generateFromExchangeKeyAndSuperSecretKey(keyExchange, cloudPassword)
StreamAesUtils.generateFromExchangeKeyAndSuperSecretKey(keyExchange, hashedPassword)
} else {
StreamAesUtils.fromUserNonceSuperSecretKey(username, nonce, cloudPassword)
StreamAesUtils.fromUserNonceSuperSecretKey(username, nonce, hashedPassword)
}
val output = if (encrypt) {