/******************************************************************************* * libretroshare/src/crypto: hashstream.h * * * * libretroshare: retroshare core library * * * * Copyright 2018 by Retroshare Team * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * * published by the Free Software Foundation, either version 3 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see . * * * *******************************************************************************/ #pragma once #include #include namespace librs { namespace crypto { // Forward declare the class class HashStream; // Forward declare the template operator template HashStream& operator<<(HashStream& u, const T&); class HashStream { public: enum HashType { UNKNOWN = 0x00, SHA1 = 0x01 }; HashStream(HashType t); ~HashStream(); Sha1CheckSum hash() ; template friend HashStream& operator<<(HashStream& u, const T&) ; template friend HashStream& operator<<(HashStream& u, const t_RsGenericIdType& r) { EVP_DigestUpdate(u.mdctx, r.toByteArray(), ID_SIZE_IN_BYTES); return u; } private: EVP_MD_CTX *mdctx ; }; } }