mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-25 07:25:36 -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
|
@ -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