Browse Source

use blake3 for messages

pull/163/head
DenioD 4 years ago
parent
commit
e0d071296a
  1. 53
      src/chatmodel.cpp
  2. 39
      src/controller.cpp

53
src/chatmodel.cpp

@ -443,43 +443,29 @@ Tx MainWindow::createTxFromChatPage() {
int lengthmemo = memoplain.length();
char *memoplainchar = NULL;
memoplainchar = new char[lengthmemo+1];
strncpy(memoplainchar, memoplain.toLocal8Bit(), lengthmemo +1);
/////////We convert the CID from QString to unsigned char*, so we can encrypt it later
int lengthcid = cid.length();
char *cidchar = NULL;
cidchar = new char[lengthcid+1];
strncpy(cidchar, cid.toLocal8Bit(), lengthcid +1);
QString pubkey = this->getPubkeyByAddress(addr);
QString passphrase = DataStore::getChatDataStore()->getPassword();
QString hashEncryptionKey = passphrase;
int length = hashEncryptionKey.length();
memoplainchar = new char[lengthmemo+1];
strncpy(memoplainchar, memoplain.toUtf8(), lengthmemo +1);
QString pubkey = this->getPubkeyByAddress(addr);
QString passphraseHash = DataStore::getChatDataStore()->getPassword();
int length = passphraseHash.length();
////////////////Generate the secretkey for our message encryption
char *hashEncryptionKeyraw = NULL;
hashEncryptionKeyraw = new char[length+1];
strncpy(hashEncryptionKeyraw, hashEncryptionKey.toLocal8Bit(), length +1);
char *hashEncryptionKeyraw = NULL;
hashEncryptionKeyraw = new char[length+1];
strncpy(hashEncryptionKeyraw, passphraseHash.toUtf8(), length+1);
#define MESSAGEAS1 ((const unsigned char *) hashEncryptionKeyraw)
#define MESSAGEAS1_LEN length
unsigned char hash[crypto_kx_SEEDBYTES];
crypto_hash_sha256(hash,MESSAGEAS1, MESSAGEAS1_LEN);
unsigned char sk[crypto_kx_SECRETKEYBYTES];
unsigned char pk[crypto_kx_PUBLICKEYBYTES];
unsigned char server_rx[crypto_kx_SESSIONKEYBYTES], server_tx[crypto_kx_SESSIONKEYBYTES];
if (crypto_kx_seed_keypair(pk,sk,
hash) !=0) {
MESSAGEAS1) !=0) {
}
////////////////Get the pubkey from Bob, so we can create the share key
@ -784,29 +770,22 @@ Tx MainWindow::createTxForSafeContactRequest()
QString memo = contactRequest.getMemo();
// QString privkey = rpc->fetchPrivKey(myAddr);
QString passphrase = DataStore::getChatDataStore()->getPassword();
QString hashEncryptionKey = passphrase;
int length = hashEncryptionKey.length();
int length = passphrase.length();
////////////////Generate the secretkey for our message encryption
char *hashEncryptionKeyraw = NULL;
hashEncryptionKeyraw = new char[length+1];
strncpy(hashEncryptionKeyraw, hashEncryptionKey.toLocal8Bit(), length +1);
char *hashEncryptionKeyraw = NULL;
hashEncryptionKeyraw = new char[length+1];
strncpy(hashEncryptionKeyraw, passphrase.toUtf8(), length +1);
#define MESSAGEAS1 ((const unsigned char *) hashEncryptionKeyraw)
#define MESSAGEAS1_LEN length
unsigned char hash[crypto_kx_SEEDBYTES];
crypto_hash_sha256(hash,MESSAGEAS1, MESSAGEAS1_LEN);
unsigned char sk[crypto_kx_SECRETKEYBYTES];
unsigned char pk[crypto_kx_PUBLICKEYBYTES];
if (crypto_kx_seed_keypair(pk,sk,
hash) !=0) {
MESSAGEAS1) !=0) {
}
QString publicKey = QByteArray(reinterpret_cast<const char*>(pk), crypto_kx_PUBLICKEYBYTES).toHex();

39
src/controller.cpp

@ -1026,32 +1026,25 @@ void Controller::refreshTransactions() {
{
QString passphrase = DataStore::getChatDataStore()->getPassword();
QString hashEncryptionKey = passphrase;
int length = hashEncryptionKey.length();
int length = passphrase.length();
////////////////Generate the secretkey for our message encryption
char *hashEncryptionKeyraw = NULL;
hashEncryptionKeyraw = new char[length+1];
strncpy(hashEncryptionKeyraw, hashEncryptionKey.toLocal8Bit(), length +1);
strncpy(hashEncryptionKeyraw, passphrase.toUtf8(), length +1);
const QByteArray pubkeyBobArray = QByteArray::fromHex(publickey.toLatin1());
const unsigned char *pubkeyBob = reinterpret_cast<const unsigned char *>(pubkeyBobArray.constData());
#define MESSAGEAS1 ((const unsigned char *) hashEncryptionKeyraw)///////////
#define MESSAGEAS1_LEN length
#define MESSAGEAS1_LEN length
unsigned char hash1[crypto_kx_SEEDBYTES];
crypto_hash_sha256(hash1,MESSAGEAS1, MESSAGEAS1_LEN);
unsigned char sk[crypto_kx_SECRETKEYBYTES];
unsigned char pk[crypto_kx_PUBLICKEYBYTES];
if (crypto_kx_seed_keypair(pk,sk,
hash1) !=0) {
MESSAGEAS1) !=0) {
}
unsigned char server_rx[crypto_kx_SESSIONKEYBYTES], server_tx[crypto_kx_SESSIONKEYBYTES];
@ -1292,32 +1285,24 @@ void Controller::refreshTransactions() {
}else{}
QString passphrase = DataStore::getChatDataStore()->getPassword();
QString hashEncryptionKey = passphrase;
int length = hashEncryptionKey.length();
int length = passphrase.length();
char *hashEncryptionKeyraw = NULL;
hashEncryptionKeyraw = new char[length+1];
strncpy(hashEncryptionKeyraw, hashEncryptionKey.toLocal8Bit(), length +1);
//const QByteArray ba2 = QByteArray::fromHex(hashEncryptionKey.toLatin1());
// const unsigned char *hashEncryptionKeyraw = reinterpret_cast<const unsigned char *>(ba2.constData());
strncpy(hashEncryptionKeyraw, passphrase.toUtf8(), length +1);
const QByteArray pubkeyBobArray = QByteArray::fromHex(publickey.toLatin1());
const unsigned char *pubkeyBob = reinterpret_cast<const unsigned char *>(pubkeyBobArray.constData());
#define MESSAGEAS1 ((const unsigned char *) hashEncryptionKeyraw)///////////
#define MESSAGEAS1_LEN length
unsigned char hash1[crypto_kx_SEEDBYTES];
#define MESSAGEAS1 ((const unsigned char *) hashEncryptionKeyraw)///////////
#define MESSAGEAS1_LEN length
crypto_hash_sha256(hash1,MESSAGEAS1, MESSAGEAS1_LEN);
unsigned char sk[crypto_kx_SECRETKEYBYTES];
unsigned char pk[crypto_kx_PUBLICKEYBYTES];
unsigned char sk[crypto_kx_SECRETKEYBYTES];
unsigned char pk[crypto_kx_PUBLICKEYBYTES];
if (crypto_kx_seed_keypair(pk,sk,
hash1) !=0) {
MESSAGEAS1) !=0) {
}

Loading…
Cancel
Save