Encrypt databases used by the Rust SDK.

The passphrase is stored in the SessionData, so that a Session created by Element Android can be restored.
Existing sessions will have a null passphrase and will continue to work.
New session will use a passphrase, only on Nightly and Debug build for now.
This commit is contained in:
Benoit Marty 2024-01-18 11:48:17 +01:00
parent f9c1892f2f
commit 3a91f830da
9 changed files with 123 additions and 3 deletions

View file

@ -55,7 +55,9 @@ class MainActivity : ComponentActivity() {
sessionStore = sessionStore,
userAgentProvider = userAgentProvider,
clock = DefaultSystemClock(),
)
),
passphraseGenerator = NullPassphraseGenerator(),
buildMeta = Singleton.buildMeta,
)
}

View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2024 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.samples.minimal
import io.element.android.libraries.matrix.impl.keys.PassphraseGenerator
class NullPassphraseGenerator : PassphraseGenerator {
override fun generatePassphrase(): String? = null
}

View file

@ -29,7 +29,7 @@ import kotlinx.coroutines.MainScope
import kotlinx.coroutines.plus
object Singleton {
private val buildMeta = BuildMeta(
val buildMeta = BuildMeta(
isDebuggable = true,
buildType = BuildType.DEBUG,
applicationName = "EAX-Minimal",