- changed Sha1CheckSum from hand-made class to instance of t_GenericIdType<> (should be backward compatible)

- updated ft/, p3msgservice and p3chatservice accordingly
- added a new class for Sha1Sum in t_GeneridIdType<>, and an additional template argument to make ids of identical size 
	incompatible.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7082 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-02-01 19:10:45 +00:00
parent 10bf083ca3
commit 235280399f
19 changed files with 67 additions and 441 deletions

View file

@ -66,7 +66,7 @@ static const time_t LOBBY_LIST_AUTO_UPDATE_TIME = 121 ; // regularly as
static const time_t DISTANT_CHAT_CLEANING_PERIOD = 60 ; // clean distant chat caches every 60 secs (remove old invites)
static const time_t DISTANT_CHAT_KEEP_ALIVE_PERIOD = 10 ; // sens keep alive distant chat packets every 10 secs.
static const uint32_t DISTANT_CHAT_AES_KEY_SIZE = 16 ; // size of AES encryption key for distant chat.
static const uint32_t DISTANT_CHAT_HASH_SIZE = 20 ; // This is sha1 size in bytes.
static const uint32_t DISTANT_CHAT_HASH_SIZE = Sha1CheckSum::SIZE_IN_BYTES ; // This is sha1 size in bytes.
static const uint32_t MAX_AVATAR_JPEG_SIZE = 32767; // Maximum size in bytes for an avatar. Too large packets
// don't transfer correctly and can kill the system.
@ -3394,7 +3394,7 @@ bool p3ChatService::createDistantChatInvite(const std::string& pgp_id,time_t tim
unsigned char hash_bytes[DISTANT_CHAT_HASH_SIZE] ;
RAND_bytes( hash_bytes, DISTANT_CHAT_HASH_SIZE) ;
std::string hash = t_RsGenericIdType<DISTANT_CHAT_HASH_SIZE>(hash_bytes).toStdString(false) ;
std::string hash = Sha1CheckSum(hash_bytes).toStdString(false) ;
#ifdef DEBUG_DISTANT_CHAT
std::cerr << "Created new distant chat invite: " << std::endl;
@ -3513,7 +3513,7 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
#ifdef DEBUG_DISTANT_CHAT
std::cerr << "Signature successfuly verified!" << std::endl;
#endif
hash = t_RsGenericIdType<DISTANT_CHAT_HASH_SIZE>(data).toStdString(false) ;
hash = Sha1CheckSum(data).toStdString(false) ;
startClientDistantChatConnection(hash,pgp_id.toStdString(),data+DISTANT_CHAT_HASH_SIZE) ;

View file

@ -1840,7 +1840,7 @@ void p3IdService::CacheArbitrationDone(uint32_t mode)
//const int SHA_DIGEST_LENGTH = 20;
typedef t_RsGenericIdType<SHA_DIGEST_LENGTH> GxsIdPgpHash;
typedef Sha1CheckSum GxsIdPgpHash;
static void calcPGPHash(const RsGxsId &id, const PGPFingerprintType &pgp, GxsIdPgpHash &hash);

View file

@ -59,7 +59,7 @@ const int msgservicezone = 54319;
static const uint32_t RS_DISTANT_MSG_STATUS_TUNNEL_OK = 0x0001 ;
static const uint32_t RS_DISTANT_MSG_STATUS_TUNNEL_DN = 0x0000 ;
static const uint32_t DISTANT_MSG_HASH_SIZE = 20 ;
static const uint32_t DISTANT_MSG_HASH_SIZE = Sha1CheckSum::SIZE_IN_BYTES ;
static const uint8_t ENCRYPTED_MSG_PROTOCOL_VERSION_01 = 0x37 ;
@ -2101,7 +2101,7 @@ bool p3MsgService::createDistantOfflineMessengingInvite(time_t time_of_validity,
unsigned char hash_bytes[DISTANT_MSG_HASH_SIZE] ;
RSRandom::random_bytes( hash_bytes, DISTANT_MSG_HASH_SIZE) ;
hash = t_RsGenericIdType<DISTANT_MSG_HASH_SIZE>(hash_bytes).toStdString(false) ;
hash = Sha1CheckSum(hash_bytes).toStdString(false) ;
DistantMessengingInvite invite ;
invite.time_of_validity = time_of_validity + time(NULL);