mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix: clear public key when private key edited (#2190)
This commit is contained in:
parent
7acc5ef8e8
commit
b5a503c0cb
2 changed files with 14 additions and 2 deletions
|
|
@ -34,6 +34,7 @@ import androidx.compose.material3.HorizontalDivider
|
|||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
|
|
@ -59,6 +60,7 @@ import com.geeksville.mesh.ui.common.components.SwitchPreference
|
|||
import com.geeksville.mesh.ui.node.NodeActionButton
|
||||
import com.geeksville.mesh.ui.radioconfig.RadioConfigViewModel
|
||||
import com.geeksville.mesh.util.encodeToString
|
||||
import com.geeksville.mesh.util.toByteString
|
||||
import com.google.protobuf.ByteString
|
||||
import java.security.SecureRandom
|
||||
|
||||
|
|
@ -103,6 +105,15 @@ fun SecurityConfigItemList(
|
|||
val focusManager = LocalFocusManager.current
|
||||
var securityInput by rememberSaveable { mutableStateOf(securityConfig) }
|
||||
|
||||
var publicKey by rememberSaveable { mutableStateOf(securityInput.publicKey) }
|
||||
LaunchedEffect(securityInput.privateKey) {
|
||||
if (securityInput.privateKey != securityConfig.privateKey) {
|
||||
publicKey = "".toByteString()
|
||||
} else if (securityInput.privateKey == securityConfig.privateKey) {
|
||||
publicKey = securityConfig.publicKey
|
||||
}
|
||||
}
|
||||
|
||||
val exportConfigLauncher = rememberLauncherForActivityResult(
|
||||
ActivityResultContracts.StartActivityForResult()
|
||||
) {
|
||||
|
|
@ -157,7 +168,7 @@ fun SecurityConfigItemList(
|
|||
item {
|
||||
EditBase64Preference(
|
||||
title = stringResource(R.string.public_key),
|
||||
value = securityInput.publicKey,
|
||||
value = publicKey,
|
||||
enabled = enabled,
|
||||
readOnly = true,
|
||||
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus() }),
|
||||
|
|
@ -314,6 +325,7 @@ fun PrivateKeyRegenerateDialog(
|
|||
onClick = {
|
||||
securityInput = securityInput.copy {
|
||||
clearPrivateKey()
|
||||
clearPublicKey()
|
||||
// Generate a random "f" value
|
||||
val f = ByteArray(32).apply {
|
||||
SecureRandom().nextBytes(this)
|
||||
|
|
|
|||
|
|
@ -689,7 +689,7 @@
|
|||
<string name="client_notification">Client Notification</string>
|
||||
<string name="compromised_keys">Compromised keys detected, select OK to regenerate.</string>
|
||||
<string name="regenerate_private_key">Regenerate Private Key</string>
|
||||
<string name="regenerate_keys_confirmation">Are you sure you want to regenerate your Private Key?</string>
|
||||
<string name="regenerate_keys_confirmation">Are you sure you want to regenerate your Private Key?\n\nNodes that may have previously exchanged keys with this node will need to Remove that node and re-exchange keys in order to resume secure communication.</string>
|
||||
<string name="export_keys">Export Keys</string>
|
||||
<string name="export_keys_confirmation">Exports public and private keys to a file. Please store somewhere securely.</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue