crypto: Correctly decode the byte array when importing keys

This commit is contained in:
Damir Jelić 2021-04-19 18:03:52 +02:00
parent 0afdcb35f1
commit 91d28658fc

View file

@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.crypto
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import java.io.File import java.io.File
import java.nio.charset.Charset
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@ -388,7 +389,7 @@ internal class OlmMachine(user_id: String, device_id: String, path: File, device
*/ */
@Throws(CryptoStoreErrorException::class) @Throws(CryptoStoreErrorException::class)
suspend fun importKeys(keys: ByteArray, passphrase: String, listener: ProgressListener?): ImportRoomKeysResult = withContext(Dispatchers.IO) { suspend fun importKeys(keys: ByteArray, passphrase: String, listener: ProgressListener?): ImportRoomKeysResult = withContext(Dispatchers.IO) {
var decodedKeys = keys.toString() val decodedKeys = String(keys, Charset.defaultCharset())
var rustListener = CryptoProgressListener(listener) var rustListener = CryptoProgressListener(listener)