From 379c0cd8c72353d7cfa75bfe35eb19d85f4a9e27 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Sun, 14 Mar 2021 15:54:47 +0100 Subject: [PATCH] dash bke tests: fix decrypt test We were trying to use an encryption NONCE for decryption. The fix was to replac data with data from logs. --- .../driver/comm/endecrypt/EnDecryptTest.kt | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt index a85f9c9c1c..15573e1e3f 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/endecrypt/EnDecryptTest.kt @@ -13,21 +13,24 @@ class EnDecryptTest { fun decrypt() { // TODO: add data received from the pod // this test is failing because the way we increment the nonce + val received = + "54,57,11,a1,0c,16,03,00,08,20,2e,a9,08,20,2e,a8,34,7c,b9,7b,38,5d,45,a3,c4,0e,40,4c,55,71,5e,f3,c3,86,50,17,36,7e,62,3c,7d,0b,46,9e,81,cd,fd,9a".replace( + ",", + "" + ) + val decryptedPayload = + "30,2e,30,3d,00,12,08,20,2e,a9,1c,0a,1d,05,00,16,b0,00,00,00,0b,ff,01,fe".replace(",", "") val aapsLogger = AAPSLoggerTest() val enDecrypt = EnDecrypt( aapsLogger, Nonce( - Hex.decode("dda23c090a0a0a0a"), - 0 + Hex.decode("6c,ff,5d,18,b7,61,6c,ae".replace(",", "")), + 22 ), - Hex.decode("ba1283744b6de9fab6d9b77d95a71d6e") + Hex.decode("55,79,9f,d2,66,64,cb,f6,e4,76,52,5e,2d,ee,52,c6".replace(",", "")) ) - val encryptedMessage = Hex.decode( - "54571101070003400242000002420001" + - "e09158bcb0285a81bf30635f3a17ee73f0afbb3286bc524a8a66" + - "fb1bc5b001e56543" - ) - val decrypted = Hex.decode("53302e303d000effffffff00060704ffffffff82b22c47302e30") + val encryptedMessage = Hex.decode(received) + val decrypted = Hex.decode(decryptedPayload) val msg = MessagePacket.parse(encryptedMessage) val decryptedMsg = enDecrypt.decrypt(msg)