mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 08:05:18 -04:00
added popup chat window for distant chat, decryption code for private chat links. (W) does not compile
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-GenericTunneling@6310 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
46ec44ceea
commit
dc0193ae66
10 changed files with 207 additions and 2 deletions
|
@ -144,6 +144,15 @@ public:
|
|||
#define RS_CHAT_PRIVATE 0x0002
|
||||
#define RS_CHAT_AVATAR_AVAILABLE 0x0004
|
||||
|
||||
#define RS_DISTANT_CHAT_STATUS_UNKNOWN 0x0001
|
||||
#define RS_DISTANT_CHAT_STATUS_TUNNEL_DN 0x0002
|
||||
#define RS_DISTANT_CHAT_STATUS_TUNNEL_OK 0x0003
|
||||
#define RS_DISTANT_CHAT_STATUS_CAN_TALK 0x0004
|
||||
|
||||
#define RS_DISTANT_CHAT_ERROR_NO_ERROR 0x0000 ;
|
||||
#define RS_DISTANT_CHAT_ERROR_DECRYPTION_FAILED 0x0001 ;
|
||||
#define RS_DISTANT_CHAT_ERROR_SIGNATURE_MISMATCH 0x0002 ;
|
||||
|
||||
class ChatInfo
|
||||
{
|
||||
public:
|
||||
|
@ -301,6 +310,8 @@ virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::str
|
|||
|
||||
virtual bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string) = 0 ;
|
||||
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
|
||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) = 0;
|
||||
virtual uint32_t getDistantChatStatus(const std::string& hash) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -338,4 +338,8 @@ bool p3Msgs::getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invite
|
|||
{
|
||||
return mChatSrv->getDistantChatInviteList(invites) ;
|
||||
}
|
||||
bool p3Msgs::initiateDistantChatConnexion(const std::string& encrypted_str,std::string& hash,uint32_t& error_code)
|
||||
{
|
||||
return mChatSrv->initiateDistantChatConnexion(encrypted_str,hash,error_code) ;
|
||||
}
|
||||
|
||||
|
|
|
@ -185,6 +185,8 @@ class p3Msgs: public RsMsgs
|
|||
|
||||
virtual bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string) ;
|
||||
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
|
||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) ;
|
||||
virtual uint32_t getDistantChatStatus(const std::string& hash) ;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -3016,6 +3016,60 @@ bool p3ChatService::createDistantChatInvite(const std::string& pgp_id,time_t tim
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_str,std::string& hash,uint32_t& error_code)
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
// Un-radix the string.
|
||||
//
|
||||
char *encrypted_data_bin = NULL ;
|
||||
size_t encrypted_data_len ;
|
||||
|
||||
Radix64::decode(encrypted_str,encrypted_data_bin,encrypted_data_len) ;
|
||||
|
||||
// Decrypt it.
|
||||
//
|
||||
unsigned char *data = NULL ;
|
||||
uint32_t data_size ;
|
||||
|
||||
if(!AuthGPG::getAuthGPG()->decryptDataBin((unsigned char *)encrypted_data_bin,encrypted_data_len,data,&data_size))
|
||||
{
|
||||
error_code = RS_DISTANT_CHAT_ERROR_DECRYPTION_FAILED ;
|
||||
return false ;
|
||||
}
|
||||
delete[] encrypted_data_bin ;
|
||||
|
||||
std::cerr << "Chat invite was successfuly decrypted!" << std::endl;
|
||||
|
||||
if(!AuthGPG::VerifySignBin(data,32,data+32,data_size-32,fingerprint))
|
||||
{
|
||||
error_code = RS_DISTANT_CHAT_ERROR_SIGNATURE_MISMATCH ;
|
||||
return false ;
|
||||
}
|
||||
std::cerr << "Signature successfuly verified!" << std::endl;
|
||||
|
||||
hash = t_RsGenericIdType<16>(data).toStdString() ;
|
||||
DistantChatPeerInfo info ;
|
||||
|
||||
info.last_contact = time(NULL) ;
|
||||
memcpy(info.aes_key,data+16,16) ;
|
||||
|
||||
_distant_chat_peers[hash] = info ;
|
||||
|
||||
delete[] data ;
|
||||
|
||||
// Now ask the turtle router to manage a tunnel for that hash.
|
||||
|
||||
std::cerr << "Asking turtle router to monitor tunnels for hash " << hash << std::endl;
|
||||
|
||||
mTurtle->monitorTunnels(hash,this) ;
|
||||
|
||||
// And notify about chatting.
|
||||
|
||||
error_code = RS_DISTANT_CHAT_ERROR_NO_ERROR ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
void p3ChatService::cleanDistantChatInvites()
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
|
|
@ -310,8 +310,9 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
|||
// Om success, stores the invite in the map above, so that we can respond to tunnel requests.
|
||||
//
|
||||
bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,TurtleFileHash& hash) ;
|
||||
|
||||
bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) ;
|
||||
bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) ;
|
||||
virtual uint32_t getDistantChatStatus(const std::string& hash) ;
|
||||
|
||||
private:
|
||||
struct DistantChatInvite
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue