format: ktlint

This commit is contained in:
Andrei Vereha 2021-03-06 11:10:19 +01:00
parent c71433ad1a
commit 4046828567
15 changed files with 37 additions and 37 deletions

View file

@ -86,7 +86,7 @@ class OmnipodDashBleManagerImpl @Inject constructor(
val keys = sessionKeys val keys = sessionKeys
val mIO = msgIO val mIO = msgIO
if (keys == null || mIO == null) { if (keys == null || mIO == null) {
//TODO handle reconnects // TODO handle reconnects
throw Exception("Not connected") throw Exception("Not connected")
} }
emitter.onNext(PodEvent.CommandSending(cmd)) emitter.onNext(PodEvent.CommandSending(cmd))

View file

@ -22,7 +22,8 @@ class EnDecrypt(private val aapsLogger: AAPSLogger, private val nonce: Nonce, pr
aapsLogger.debug(LTag.PUMPBTCOMM, "Decrypt header ${header.toHex()} payload: ${payload.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "Decrypt header ${header.toHex()} payload: ${payload.toHex()}")
aapsLogger.debug(LTag.PUMPBTCOMM, "Decrypt NONCE ${n.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "Decrypt NONCE ${n.toHex()}")
cipher.init( cipher.init(
false, AEADParameters( false,
AEADParameters(
KeyParameter(ck), KeyParameter(ck),
MAC_SIZE * 8, // in bits MAC_SIZE * 8, // in bits
n, n,
@ -44,7 +45,8 @@ class EnDecrypt(private val aapsLogger: AAPSLogger, private val nonce: Nonce, pr
val encryptedPayload = ByteArray(payload.size + MAC_SIZE) val encryptedPayload = ByteArray(payload.size + MAC_SIZE)
cipher.init( cipher.init(
true, AEADParameters( true,
AEADParameters(
KeyParameter(ck), KeyParameter(ck),
MAC_SIZE * 8, // in bits MAC_SIZE * 8, // in bits
n, n,

View file

@ -93,6 +93,5 @@ class Session(
private const val COMMAND_PREFIX = "S0.0=" private const val COMMAND_PREFIX = "S0.0="
private const val COMMAND_SUFFIX = ",G0.0" private const val COMMAND_SUFFIX = ",G0.0"
private const val RESPONSE_PREFIX = "0.0=" private const val RESPONSE_PREFIX = "0.0="
} }
} }

View file

@ -36,12 +36,12 @@ class SessionEstablisher(
fun negotiateSessionKeys(): SessionKeys { fun negotiateSessionKeys(): SessionKeys {
// send EAP-AKA challenge // send EAP-AKA challenge
sequenceNumber++ //TODO: get from pod state. This only works for activating a new pod sequenceNumber++ // TODO: get from pod state. This only works for activating a new pod
var challenge = eapAkaChallenge() var challenge = eapAkaChallenge()
msgIO.sendMessage(challenge) msgIO.sendMessage(challenge)
val challengeResponse = msgIO.receiveMessage() val challengeResponse = msgIO.receiveMessage()
processChallengeResponse(challengeResponse) //TODO: what do we have to answer if challenge response does not validate? processChallengeResponse(challengeResponse) // TODO: what do we have to answer if challenge response does not validate?
sequenceNumber++ sequenceNumber++
var success = eapSuccess() var success = eapSuccess()

View file

@ -18,5 +18,5 @@ sealed class PodEvent {
/* Message exchange events */ /* Message exchange events */
class CommandSending(val command: Command) : PodEvent() class CommandSending(val command: Command) : PodEvent()
class CommandSent(val command: Command) : PodEvent() class CommandSent(val command: Command) : PodEvent()
class ResponseReceived(val response:Response) : PodEvent() class ResponseReceived(val response: Response) : PodEvent()
} }

View file

@ -54,6 +54,5 @@ class EnDecryptTest {
val encrypted = enDecrypt.encrypt(msg) val encrypted = enDecrypt.encrypt(msg)
Assert.assertEquals(encryptedMessage.toHex(), encrypted.asByteArray().toHex()) Assert.assertEquals(encryptedMessage.toHex(), encrypted.asByteArray().toHex())
} }
} }