From 2fc636183357f738f45dbaf44950aab25be3fdca Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Mon, 28 Jan 2019 13:30:46 -0800 Subject: [PATCH] Pad outgoing encrypted messages --- src/websockets.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/websockets.cpp b/src/websockets.cpp index 512e7eb..211551c 100644 --- a/src/websockets.cpp +++ b/src/websockets.cpp @@ -161,6 +161,10 @@ void AppDataServer::saveNonceHex(NonceType nt, QString noncehex) { } QString AppDataServer::encryptOutgoing(QString msg) { + if (msg.length() % 256 > 0) { + msg = msg + QString(" ").repeated(256 - (msg.length() % 256)); + } + QString localNonceHex = getNonceHex(NonceType::LOCAL); unsigned char* noncebin = new unsigned char[crypto_secretbox_NONCEBYTES];