From d618eb87c7eb3c4a5e1362241ce2e0ebdece5873 Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Sun, 25 Jul 2021 16:01:06 +0200 Subject: [PATCH] Update to PSEC v0.4 --- .../java/sushi/hardcore/aira/background_service/Session.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/sushi/hardcore/aira/background_service/Session.kt b/app/src/main/java/sushi/hardcore/aira/background_service/Session.kt index ff2b560..700ba00 100644 --- a/app/src/main/java/sushi/hardcore/aira/background_service/Session.kt +++ b/app/src/main/java/sushi/hardcore/aira/background_service/Session.kt @@ -188,7 +188,7 @@ class Session(private val socket: SocketChannel, val outgoing: Boolean): Selecta fun encrypt(plainText: ByteArray, usePadding: Boolean): ByteArray { val padded = pad(plainText, usePadding) - val rawMsgLen = ByteBuffer.allocate(MESSAGE_LEN_LEN).putInt(padded.size).array() + val rawMsgLen = ByteBuffer.allocate(MESSAGE_LEN_LEN).putInt(padded.size+AES_TAG_LEN).array() val nonce = ivToNonce(applicationKeys.localIv, localCounter) localCounter++ localCipher.init(Cipher.ENCRYPT_MODE, SecretKeySpec(applicationKeys.localKey, "AES"), GCMParameterSpec(AES_TAG_LEN*8, nonce)) @@ -219,7 +219,7 @@ class Session(private val socket: SocketChannel, val outgoing: Boolean): Selecta val rawMessageLen = ByteBuffer.allocate(MESSAGE_LEN_LEN) if (readAll(rawMessageLen)) { rawMessageLen.position(0) - val messageLen = rawMessageLen.int + AES_TAG_LEN + val messageLen = rawMessageLen.int if (messageLen in 1..MAX_RECV_SIZE) { val cipherText = ByteBuffer.allocate(messageLen) if (readAll(cipherText)) {