From 4f7d26d86e2c9b9474d85da3ce45277e9f95ec5e Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Fri, 28 May 2021 12:04:37 +1000 Subject: [PATCH] debug for new encryption --- .../main/java/org/session/libsession/snode/SnodeAPI.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libsession/src/main/java/org/session/libsession/snode/SnodeAPI.kt b/libsession/src/main/java/org/session/libsession/snode/SnodeAPI.kt index abcb132a2d..d46ee4bcca 100644 --- a/libsession/src/main/java/org/session/libsession/snode/SnodeAPI.kt +++ b/libsession/src/main/java/org/session/libsession/snode/SnodeAPI.kt @@ -223,14 +223,12 @@ object SnodeAPI { deferred.reject(Error.HashingFailed) return@success } - val sessionID: String - try { - sessionID = sodium.decrypt(hexEncodedCiphertext, null, nonce, Key.fromBytes(key), AEAD.Method.CHACHA20_POLY1305_IETF) - } catch (e: Exception) { + val sessionIDAsData = ByteArray(sessionIDByteCount) + if (!sodium.cryptoAeadXChaCha20Poly1305IetfDecrypt(sessionIDAsData, null, null, ciphertext, ciphertext.size.toLong(), null, 0, nonce, key)) { deferred.reject(Error.DecryptionFailed) return@success } - sessionIDs.add(sessionID) + sessionIDs.add(Hex.toStringCondensed(sessionIDAsData)) } } else { deferred.reject(Error.Generic)