From ce3120dcd1a60ef584f8f62d1274a064bbe6bf38 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Tue, 2 Jun 2020 01:56:28 +0200 Subject: [PATCH] we use seedbytes --- src/chatmodel.cpp | 13 +++++++------ src/controller.cpp | 19 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 69751ad..5df7693 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -429,8 +429,9 @@ Tx MainWindow::createTxFromChatPage() { ////////////////Generate the secretkey for our message encryption - const QByteArray ba2 = QByteArray::fromHex(hashEncryptionKey.toLatin1()); - const unsigned char *hashEncryptionKeyraw = reinterpret_cast(ba2.constData()); + char *hashEncryptionKeyraw = NULL; + hashEncryptionKeyraw = new char[length+1]; + strncpy(hashEncryptionKeyraw, hashEncryptionKey.toLocal8Bit(), length +1); #define MESSAGEAS1 ((const unsigned char *) hashEncryptionKeyraw) #define MESSAGEAS1_LEN length @@ -732,15 +733,15 @@ Tx MainWindow::createTxForSafeContactRequest() QString memo = contactRequest.getMemo(); // QString privkey = rpc->fetchPrivKey(myAddr); QString passphrase = this->getPassword(); - QString hashEncryptionKey = passphrase; + QString hashEncryptionKey = "Test"; int length = hashEncryptionKey.length(); qDebug()<<"Encryption String :"<(ba2.constData()); + char *hashEncryptionKeyraw = NULL; + hashEncryptionKeyraw = new char[length+1]; + strncpy(hashEncryptionKeyraw, hashEncryptionKey.toLocal8Bit(), length +1); #define MESSAGEAS1 ((const unsigned char *) hashEncryptionKeyraw) #define MESSAGEAS1_LEN length diff --git a/src/controller.cpp b/src/controller.cpp index 66b7823..6ca80cd 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -993,8 +993,9 @@ void Controller::refreshTransactions() { ////////////////Generate the secretkey for our message encryption - const QByteArray ba2 = QByteArray::fromHex(hashEncryptionKey.toLatin1()); - const unsigned char *hashEncryptionKeyraw = reinterpret_cast(ba2.constData()); + char *hashEncryptionKeyraw = NULL; + hashEncryptionKeyraw = new char[length+1]; + strncpy(hashEncryptionKeyraw, hashEncryptionKey.toLocal8Bit(), length +1); const QByteArray pubkeyBobArray = QByteArray::fromHex(publickey.toLatin1()); const unsigned char *pubkeyBob = reinterpret_cast(pubkeyBobArray.constData()); @@ -1006,7 +1007,7 @@ void Controller::refreshTransactions() { #define MESSAGEAS1_LEN length - unsigned char hash1[crypto_kx_SECRETKEYBYTES]; + unsigned char hash1[crypto_kx_SEEDBYTES]; crypto_hash_sha256(hash1,MESSAGEAS1, MESSAGEAS1_LEN); unsigned char sk[crypto_kx_SECRETKEYBYTES]; @@ -1266,15 +1267,15 @@ void Controller::refreshTransactions() { qDebug()<<"Encryption String :"< 0)) { - const QByteArray ba2 = QByteArray::fromHex(hashEncryptionKey.toLatin1()); - const unsigned char *hashEncryptionKeyraw = reinterpret_cast(ba2.constData()); + //const QByteArray ba2 = QByteArray::fromHex(hashEncryptionKey.toLatin1()); + // const unsigned char *hashEncryptionKeyraw = reinterpret_cast(ba2.constData()); const QByteArray pubkeyBobArray = QByteArray::fromHex(publickey.toLatin1()); const unsigned char *pubkeyBob = reinterpret_cast(pubkeyBobArray.constData()); @@ -1284,7 +1285,7 @@ void Controller::refreshTransactions() { #define MESSAGEAS1_LEN length - unsigned char hash1[crypto_kx_SECRETKEYBYTES]; + unsigned char hash1[crypto_kx_SEEDBYTES]; crypto_hash_sha256(hash1,MESSAGEAS1, MESSAGEAS1_LEN); unsigned char sk[crypto_kx_SECRETKEYBYTES];