mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 06:02:41 -04:00
added hashstream class to hash content of RsIdentityUsage and fix duplication of identity usage statistics
This commit is contained in:
parent
1a2def70b5
commit
d631758e8c
10 changed files with 152 additions and 112 deletions
34
libretroshare/src/crypto/hashstream.h
Normal file
34
libretroshare/src/crypto/hashstream.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
|
||||
#include <openssl/evp.h>
|
||||
#include <util/rsdir.h>
|
||||
|
||||
namespace librs
|
||||
{
|
||||
namespace crypto
|
||||
{
|
||||
class HashStream
|
||||
{
|
||||
public:
|
||||
enum HashType { UNKNOWN = 0x00,
|
||||
SHA1 = 0x01
|
||||
};
|
||||
|
||||
HashStream(HashType t);
|
||||
~HashStream();
|
||||
|
||||
Sha1CheckSum hash() ;
|
||||
|
||||
template<class T> friend HashStream& operator<<(HashStream& u, const T&) ;
|
||||
|
||||
template<uint32_t ID_SIZE_IN_BYTES,bool UPPER_CASE,uint32_t UNIQUE_IDENTIFIER>
|
||||
friend HashStream& operator<<(HashStream& u,const t_RsGenericIdType<ID_SIZE_IN_BYTES,UPPER_CASE,UNIQUE_IDENTIFIER>& r)
|
||||
{
|
||||
EVP_DigestUpdate(u.mdctx,r.toByteArray(),ID_SIZE_IN_BYTES);
|
||||
return u;
|
||||
}
|
||||
private:
|
||||
EVP_MD_CTX *mdctx ;
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue