format. do not log keys

This commit is contained in:
Andrei Vereha 2021-11-28 15:58:56 +01:00
parent 7374ff2eb1
commit 4aa67dedb5
4 changed files with 85 additions and 82 deletions

View file

@ -80,13 +80,11 @@ class KeyExchange(
pdmNonce + pdmNonce +
podNonce podNonce
aesCmac(confKey, pdmConfData, pdmConf) aesCmac(confKey, pdmConfData, pdmConf)
aapsLogger.debug(LTag.PUMPBTCOMM, "pdmConf: ${pdmConf.toHex()}")
val podConfData = POD_CONF_MAGIC_PREFIX + val podConfData = POD_CONF_MAGIC_PREFIX +
podNonce + podNonce +
pdmNonce pdmNonce
aesCmac(confKey, podConfData, podConf) aesCmac(confKey, podConfData, podConf)
aapsLogger.debug(LTag.PUMPBTCOMM, "podConf: ${podConf.toHex()}")
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
aapsLogger.debug(LTag.PUMPBTCOMM, "pdmPrivate: ${pdmPrivate.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "pdmPrivate: ${pdmPrivate.toHex()}")
@ -94,6 +92,8 @@ class KeyExchange(
aapsLogger.debug(LTag.PUMPBTCOMM, "podPublic: ${podPublic.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "podPublic: ${podPublic.toHex()}")
aapsLogger.debug(LTag.PUMPBTCOMM, "pdmNonce: ${pdmNonce.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "pdmNonce: ${pdmNonce.toHex()}")
aapsLogger.debug(LTag.PUMPBTCOMM, "podNonce: ${podNonce.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "podNonce: ${podNonce.toHex()}")
aapsLogger.debug(LTag.PUMPBTCOMM, "podConf: ${podConf.toHex()}")
aapsLogger.debug(LTag.PUMPBTCOMM, "pdmConf: ${pdmConf.toHex()}")
aapsLogger.debug(LTag.PUMPBTCOMM, "LTK, donna key: ${curveLTK.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "LTK, donna key: ${curveLTK.toHex()}")
aapsLogger.debug(LTag.PUMPBTCOMM, "Intermediate key: ${intermediateKey.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "Intermediate key: ${intermediateKey.toHex()}")

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
import info.nightscout.androidaps.extensions.toHex import info.nightscout.androidaps.extensions.toHex
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.pump.omnipod.dash.BuildConfig
import org.spongycastle.util.encoders.Hex import org.spongycastle.util.encoders.Hex
import java.security.SecureRandom import java.security.SecureRandom
import javax.crypto.Cipher import javax.crypto.Cipher
@ -102,6 +103,7 @@ class Milenage(
val receivedMacS = auts.copyOfRange(6, 14) val receivedMacS = auts.copyOfRange(6, 14)
init { init {
if (BuildConfig.DEBUG) {
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage K: ${k.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage K: ${k.toHex()}")
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage RAND: ${rand.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage RAND: ${rand.toHex()}")
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage SQN: ${sqn.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage SQN: ${sqn.toHex()}")
@ -118,6 +120,7 @@ class Milenage(
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage synchronizationSqn: ${synchronizationSqn.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage synchronizationSqn: ${synchronizationSqn.toHex()}")
aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage receivedMacS: ${receivedMacS.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "Milenage receivedMacS: ${receivedMacS.toHex()}")
} }
}
companion object { companion object {

View file

@ -677,7 +677,8 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
private fun store() { private fun store() {
try { try {
val serialized = Gson().toJson(podState) val cleanPodState = podState.copy(ltk = byteArrayOf()) // do not log ltk
val serialized = Gson().toJson(cleanPodState)
logger.debug(LTag.PUMP, "Storing Pod state: $serialized") logger.debug(LTag.PUMP, "Storing Pod state: $serialized")
sharedPreferences.putString(R.string.key_omnipod_dash_pod_state, serialized) sharedPreferences.putString(R.string.key_omnipod_dash_pod_state, serialized)
} catch (ex: Exception) { } catch (ex: Exception) {
@ -699,56 +700,55 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
return PodState() return PodState()
} }
class PodState : Serializable { data class PodState(
var activationProgress: ActivationProgress = ActivationProgress.NOT_STARTED,
var activationProgress: ActivationProgress = ActivationProgress.NOT_STARTED var lastUpdatedSystem: Long = 0,
var lastUpdatedSystem: Long = 0 var lastStatusResponseReceived: Long = 0,
var lastStatusResponseReceived: Long = 0
var bluetoothConnectionState: OmnipodDashPodStateManager.BluetoothConnectionState = var bluetoothConnectionState: OmnipodDashPodStateManager.BluetoothConnectionState =
OmnipodDashPodStateManager.BluetoothConnectionState.DISCONNECTED OmnipodDashPodStateManager.BluetoothConnectionState.DISCONNECTED,
var connectionAttempts = 0 var connectionAttempts: Int = 0,
var successfulConnections = 0 var successfulConnections: Int = 0,
var successfulConnectionAttemptsAfterRetries = 0 var successfulConnectionAttemptsAfterRetries: Int = 0,
var failedConnectionsAfterRetries = 0 var failedConnectionsAfterRetries: Int = 0,
var messageSequenceNumber: Short = 0 var messageSequenceNumber: Short = 0,
var sequenceNumberOfLastProgrammingCommand: Short? = null var sequenceNumberOfLastProgrammingCommand: Short? = null,
var activationTime: Long? = null var activationTime: Long? = null,
var uniqueId: Long? = null var uniqueId: Long? = null,
var bluetoothAddress: String? = null var bluetoothAddress: String? = null,
var ltk: ByteArray? = null var ltk: ByteArray? = null,
var eapAkaSequenceNumber: Long = 1 var eapAkaSequenceNumber: Long = 1,
var timeZone: String? = null // TimeZone ID (e.g. "Europe/Amsterdam") var timeZone: String? = null, // TimeZone ID (e.g. "Europe/Amsterdam")
var timeZoneOffset: Int? = null var timeZoneOffset: Int? = null,
var timeZoneUpdated: Long? = null var timeZoneUpdated: Long? = null,
var alarmSynced: Boolean = false var alarmSynced: Boolean = false,
var suspendAlertsEnabled: Boolean = false var suspendAlertsEnabled: Boolean = false,
var bleVersion: SoftwareVersion? = null var bleVersion: SoftwareVersion? = null,
var firmwareVersion: SoftwareVersion? = null var firmwareVersion: SoftwareVersion? = null,
var lotNumber: Long? = null var lotNumber: Long? = null,
var podSequenceNumber: Long? = null var podSequenceNumber: Long? = null,
var pulseRate: Short? = null var pulseRate: Short? = null,
var primePulseRate: Short? = null var primePulseRate: Short? = null,
var podLifeInHours: Short? = null var podLifeInHours: Short? = null,
var firstPrimeBolusVolume: Short? = null var firstPrimeBolusVolume: Short? = null,
var secondPrimeBolusVolume: Short? = null var secondPrimeBolusVolume: Short? = null,
var expirationReminderEnabled: Boolean? = null var expirationReminderEnabled: Boolean? = null,
var expirationHours: Int? = null var expirationHours: Int? = null,
var lowReservoirAlertEnabled: Boolean? = null var lowReservoirAlertEnabled: Boolean? = null,
var lowReservoirAlertUnits: Int? = null var lowReservoirAlertUnits: Int? = null,
var pulsesDelivered: Short? = null var pulsesDelivered: Short? = null,
var pulsesRemaining: Short? = null var pulsesRemaining: Short? = null,
var podStatus: PodStatus? = null var podStatus: PodStatus? = null,
var deliveryStatus: DeliveryStatus? = null var deliveryStatus: DeliveryStatus? = null,
var minutesSinceActivation: Short? = null var minutesSinceActivation: Short? = null,
var activeAlerts: EnumSet<AlertType>? = null var activeAlerts: EnumSet<AlertType>? = null,
var alarmType: AlarmType? = null var alarmType: AlarmType? = null,
var basalProgram: BasalProgram? = null var basalProgram: BasalProgram? = null,
var tempBasal: OmnipodDashPodStateManager.TempBasal? = null var tempBasal: OmnipodDashPodStateManager.TempBasal? = null,
var activeCommand: OmnipodDashPodStateManager.ActiveCommand? = null var activeCommand: OmnipodDashPodStateManager.ActiveCommand? = null,
var lastBolus: OmnipodDashPodStateManager.LastBolus? = null var lastBolus: OmnipodDashPodStateManager.LastBolus? = null
} ) : Serializable
} }