Add back AES256 key assignment (from TODO list)

1.2-legacy
geeksville 2020-06-12 20:26:10 -07:00
rodzic 1082ce667f
commit aa3a8bf089
3 zmienionych plików z 17 dodań i 5 usunięć

Wyświetl plik

@ -1,7 +1,6 @@
# Remaining tasks before declaring 1.0
* add a low level settings screen (let user change any of the RadioConfig parameters)
* if user edits the channel, generate a new AES256 key
* add play store link with https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#google-play-url-builder and the play icon
Things for the betaish period.

Wyświetl plik

@ -14,10 +14,12 @@ data class Channel(
val settings: MeshProtos.ChannelSettings = MeshProtos.ChannelSettings.getDefaultInstance()
) {
companion object {
// Note: this string _SHOULD NOT BE LOCALIZED_ because it directly hashes to values used on the device for the default channel name.
val defaultChannelName = "Default"
// Placeholder when emulating
val emulated = Channel(
// Note: this string _SHOULD NOT BE LOCALIZED_ because it directly hashes to values used on the device for the default channel name.
MeshProtos.ChannelSettings.newBuilder().setName("Default")
MeshProtos.ChannelSettings.newBuilder().setName(defaultChannelName)
.setModemConfig(MeshProtos.ChannelSettings.ModemConfig.Bw125Cr45Sf128).build()
)

Wyświetl plik

@ -18,12 +18,15 @@ import com.geeksville.android.GeeksvilleApplication
import com.geeksville.android.Logging
import com.geeksville.android.hideKeyboard
import com.geeksville.mesh.R
import com.geeksville.mesh.model.Channel
import com.geeksville.mesh.model.UIViewModel
import com.geeksville.mesh.service.MeshService
import com.geeksville.util.Exceptions
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.google.protobuf.ByteString
import kotlinx.android.synthetic.main.channel_fragment.*
import java.security.SecureRandom
// Make an image view dim
@ -142,7 +145,15 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
UIViewModel.getChannel(model.radioConfig.value)?.let { old ->
val newSettings = old.settings.toBuilder()
newSettings.name = channelNameEdit.text.toString().trim()
// FIXME, regenerate a new preshared key!
// Generate a new AES256 key (for any channel not named Default)
if (newSettings.name != Channel.defaultChannelName) {
debug("ASSIGNING NEW AES256 KEY")
val random = SecureRandom()
val bytes = ByteArray(32)
random.nextBytes(bytes)
newSettings.psk = ByteString.copyFrom(bytes)
}
// Try to change the radio, if it fails, tell the user why and throw away their redits
try {
@ -150,7 +161,7 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
// Since we are writing to radioconfig, that will trigger the rest of the GUI update (QR code etc)
} catch (ex: RemoteException) {
setGUIfromModel() // Throw away user edits
// Tell the user to try again
Snackbar.make(
editableCheckbox,