added lots of debugging info. Fixed stupid bug supplying wrong AES key. Distant chat works!

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-GenericTunneling@6325 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-04-21 22:20:11 +00:00
parent 5657ab9796
commit 1e5a7a057c
5 changed files with 19 additions and 10 deletions

View File

@ -2948,6 +2948,8 @@ void p3ChatService::receiveTurtleData( RsTurtleGenericTunnelItem *gitem,const st
std::cerr << " Using IV: " << std::hex << *(uint64_t*)item->data_bytes << std::dec << std::endl;
std::cerr << " Decrypted buffer size: " << decrypted_size << std::endl;
std::cerr << " key : " ; printBinaryData(aes_key,16) ; std::cerr << std::endl;
std::cerr << " data : " ; printBinaryData(item->data_bytes,item->data_size) ; std::cerr << std::endl;
if(!RsAES::aes_decrypt_8_16((uint8_t*)item->data_bytes+8,item->data_size-8,aes_key,(uint8_t*)item->data_bytes,decrypted_data,decrypted_size))
{
@ -3005,7 +3007,7 @@ void p3ChatService::sendTurtleData(RsChatItem *item)
}
it->second.last_contact = time(NULL) ;
virtual_peer_id = it->second.virtual_peer_id ;
memcpy(aes_key,it->second.aes_key,8) ;
memcpy(aes_key,it->second.aes_key,DISTANT_CHAT_AES_KEY_SIZE) ;
}
std::cerr << "p3ChatService::sendTurtleData(): tunnel found. Encrypting data." << std::endl;
@ -3017,6 +3019,7 @@ void p3ChatService::sendTurtleData(RsChatItem *item)
uint64_t IV = RSRandom::random_u64() ; // make a random 8 bytes IV
std::cerr << " Using IV: " << std::hex << IV << std::dec << std::endl;
std::cerr << " Using Key: " ; printBinaryData(aes_key,16) ; std::cerr << std::endl;
if(!RsAES::aes_crypt_8_16(buff,rssize,aes_key,(uint8_t*)&IV,encrypted_data,encrypted_size))
{

View File

@ -9,8 +9,8 @@ OPS_TOP_DIR = ../../../../openpgpsdk/src
include $(RS_TOP_DIR)/tests/scripts/config.mk
###############################################################
TESTOBJ = dirtest.o sha1_test.o aes_test.o
TESTS = dirtest sha1_test aes_test
TESTOBJ = dirtest.o sha1_test.o aes_test.o dchat_decrypt.o
TESTS = dirtest sha1_test aes_test dchat_decrypt
all: tests
@ -20,6 +20,8 @@ dirtest: dirtest.o
$(CC) $(CFLAGS) -o dirtest dirtest.o $(LIBS)
dirtest: aes_test.o
$(CC) $(CFLAGS) -o aes_test aes_test.o $(LIBS)
dchat_decrypt: dchat_decrypt.o
$(CC) $(CFLAGS) -o dchat_decrypt dchat_decrypt.o $(LIBS)
###############################################################
include $(RS_TOP_DIR)/tests/scripts/rules.mk

View File

@ -76,6 +76,9 @@ int main(int argc,char *argv[])
for(int i=0;i<16;++i)
key_data[i] = lrand48() & 0xff ;
std::cerr << "Key: " ; printHex(key_data,16);
std::cerr << std::endl;
for(int i=5;i<source_string.length();++i)
{
for(int j=0;j<8;++j)

View File

@ -71,7 +71,7 @@ static NewsFeed *instance = NULL;
/** Constructor */
NewsFeed::NewsFeed(QWidget *parent)
: MainPage (parent)
: RsAutoUpdatePage(1000,parent)
{
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
@ -83,9 +83,9 @@ NewsFeed::NewsFeed(QWidget *parent)
connect(removeAllButton, SIGNAL(clicked()), this, SLOT(removeAll()));
connect(feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions()));
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateFeed()));
timer->start(1000);
// QTimer *timer = new QTimer(this);
// timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateFeed()));
// timer->start(1000);
}
NewsFeed::~NewsFeed()
@ -95,7 +95,7 @@ NewsFeed::~NewsFeed()
}
}
void NewsFeed::updateFeed()
void NewsFeed::updateDisplay()
{
if (!rsNotify)
return;

View File

@ -26,6 +26,7 @@
#include "ui_NewsFeed.h"
#include "gui/feeds/FeedHolder.h"
#include <retroshare-gui/RsAutoUpdatePage.h>
class RsFeedItem;
class ForumNewItem;
@ -33,7 +34,7 @@ class ChanMsgItem;
class ChatMsgItem;
class FeedNotify;
class NewsFeed : public MainPage, public FeedHolder, private Ui::NewsFeed
class NewsFeed : public RsAutoUpdatePage, public FeedHolder, private Ui::NewsFeed
{
Q_OBJECT
@ -52,6 +53,7 @@ public:
static void testFeeds(uint notifyFlags);
static void testFeed(FeedNotify *feedNotify);
virtual void updateDisplay();
signals:
void newsFeedChanged(int count);
@ -59,7 +61,6 @@ private slots:
// void toggleChanMsgItems(bool on);
void feedoptions();
void updateFeed();
void removeAll();
void itemDestroyed(QObject*);