CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
shash::Digest< digest_size_, algorithm_ > Struct Template Reference

#include <hash.h>

Inheritance diagram for shash::Digest< digest_size_, algorithm_ >:

Classes

class  Hex
 

Public Member Functions

unsigned GetDigestSize () const
 
unsigned GetHexSize () const
 
 Digest ()
 
 Digest (const Algorithms a, const HexPtr hex, const char s=0)
 
 Digest (const Algorithms a, const unsigned char *digest_buffer, const Suffix s=kSuffixNone)
 
void Randomize ()
 
void Randomize (const uint64_t seed)
 
void Randomize (Prng *prng)
 
bool HasSuffix () const
 
void set_suffix (const Suffix s)
 
std::string ToString (const bool with_suffix=false) const
 
std::string ToFingerprint (const bool with_suffix=false) const
 
std::string ToStringWithSuffix () const
 
std::string MakePath () const
 
std::string MakeAlternativePath () const
 
std::string MakePathWithoutSuffix () const
 
std::string MakePathExplicit (const unsigned dir_levels, const unsigned digits_per_level, const Suffix hash_suffix=kSuffixNone) const
 
bool IsNull () const
 
void SetNull ()
 
bool operator== (const Digest< digest_size_, algorithm_ > &other) const
 
bool operator!= (const Digest< digest_size_, algorithm_ > &other) const
 
bool operator< (const Digest< digest_size_, algorithm_ > &other) const
 
bool operator> (const Digest< digest_size_, algorithm_ > &other) const
 

Public Attributes

unsigned char digest [digest_size_]
 
Algorithms algorithm
 
Suffix suffix
 

Detailed Description

template<unsigned digest_size_, Algorithms algorithm_>
struct shash::Digest< digest_size_, algorithm_ >

Holds a hash digest and provides from string / to string conversion and comparison. The kAny algorithm may not be used in functions! The algorithm has to be changed beforehand. This class is not used directly, but used as base clase of Md5, Sha1, ...

Definition at line 121 of file hash.h.

Constructor & Destructor Documentation

template<unsigned digest_size_, Algorithms algorithm_>
shash::Digest< digest_size_, algorithm_ >::Digest ( )
inline

Definition at line 171 of file hash.h.

template<unsigned digest_size_, Algorithms algorithm_>
shash::Digest< digest_size_, algorithm_ >::Digest ( const Algorithms  a,
const HexPtr  hex,
const char  s = 0 
)
inlineexplicit

Definition at line 177 of file hash.h.

template<unsigned digest_size_, Algorithms algorithm_>
shash::Digest< digest_size_, algorithm_ >::Digest ( const Algorithms  a,
const unsigned char *  digest_buffer,
const Suffix  s = kSuffixNone 
)
inline

Definition at line 194 of file hash.h.

Member Function Documentation

template<unsigned digest_size_, Algorithms algorithm_>
unsigned shash::Digest< digest_size_, algorithm_ >::GetHexSize ( ) const
inline

Definition at line 167 of file hash.h.

Referenced by letter::Letter::Sign().

Here is the caller graph for this function:

template<unsigned digest_size_, Algorithms algorithm_>
bool shash::Digest< digest_size_, algorithm_ >::IsNull ( ) const
inline

Definition at line 381 of file hash.h.

Referenced by catalog::WritableCatalogManager::AddFile(), swissknife::CommandEditTag::AddNewTag(), swissknife::CommandReconstructReflog::AddStaticManifestObjects(), catalog::SqlCatalog::BindHashBlob(), swissknife::CommandTag::CloseAndPublishHistory(), MountPoint::CreateCatalogManager(), catalog::SqlDirent::CreateDatabaseFlags(), CatalogDiffTool< RoCatalogMgr >::DiffRec(), publish::DownloadRootObjects(), manifest::Manifest::ExportString(), HttpObjectFetcher< CatalogT, HistoryT, ReflogT >::Fetch(), AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchCatalog(), AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchHistory(), MountPoint::FetchHistory(), swissknife::CommandTag::FetchObject(), AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchReflog(), ServerTool::FetchRemoteManifest(), swissknife::RootChainWalker::FindObjectsAndPopulateReflog(), signature::SignatureManager::FingerprintCertificate(), LibContext::GetExtAttr(), swissknife::Assistant::GetHistory(), swissknife::CommandTag::GetHistory(), MagicXattrManager::GetListString(), swissknife::CommandEditTag::GetTagRootHash(), RepoMetainfoMagicXattr::GetValue(), publish::SyncItem::HasContentHash(), AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::HasHistory(), swissknife::CommandTag::InitializeEnvironment(), catalog::WritableCatalog::InsertNestedCatalog(), swissknife::CommandCheck::InspectReflog(), manifest::Breadcrumb::IsValid(), catalog::SimpleCatalogManager::LoadCatalog(), catalog::ClientCatalogManager::LoadCatalog(), swissknife::CommandMigrate::LoadCatalogs(), glue::PathStore::Lookup(), swissknife::CommandListReflog::Main(), swissknife::CommandCheck::Main(), swissknife::CommandPull::Main(), glue::InodeTracker::NextEntry(), whitelist::Whitelist::ParseWhitelist(), HashMagicXattr::PrepareValueFenced(), LHashMagicXattr::PrepareValueFenced(), RepoMetainfoMagicXattr::PrepareValueFenced(), TaskRegister::Process(), swissknife::CommandPull::PullRecursion(), publish::PushManifest(), swissknife::CatalogTraversalParallel< ObjectFetcherT >::PushPreviousRevision(), swissknife::CatalogTraversal< ObjectFetcherT >::PushPreviousRevision(), SigningTool::Run(), swissknife::CommandListCatalogs::Run(), swissknife::CatalogTraversalParallel< ObjectFetcherT >::Traverse(), swissknife::CatalogTraversal< ObjectFetcherT >::Traverse(), FuseRemounter::TryFinish(), swissknife::CommandTag::UploadCatalogAndUpdateManifest(), whitelist::Whitelist::VerifyLoadedCertificate(), swissknife::RootChainWalker::WalkHistories(), and swissknife::RootChainWalker::WalkRootCatalogs().

template<unsigned digest_size_, Algorithms algorithm_>
std::string shash::Digest< digest_size_, algorithm_ >::MakeAlternativePath ( ) const
inline

The alternative path is used to symlink the root catalog from the webserver root to the data directory. This way, the data directory can be protected while the root catalog remains accessible.

Definition at line 323 of file hash.h.

Referenced by catalog::ClientCatalogManager::LoadCatalog(), manifest::Manifest::MakeCatalogPath(), and manifest::Manifest::MakeCertificatePath().

Here is the caller graph for this function:

template<unsigned digest_size_, Algorithms algorithm_>
std::string shash::Digest< digest_size_, algorithm_ >::MakePath ( ) const
inline
template<unsigned digest_size_, Algorithms algorithm_>
std::string shash::Digest< digest_size_, algorithm_ >::MakePathExplicit ( const unsigned  dir_levels,
const unsigned  digits_per_level,
const Suffix  hash_suffix = kSuffixNone 
) const
inline

Generates an arbitrary path representation of the digest. Both number of directory levels and the hash-digits per level can be customized. Further- more an arbitrary hash suffix can be provided. Note: This method is mainly meant for internal usage but stays public for historical reasons.

Parameters
dir_levelsthe number of namespace splitting directory levels
digits_per_leveleach directory level's number of hex-digits
hash_suffixthe hash suffix character to be appended
Returns
a relative path representation of the digest

Definition at line 349 of file hash.h.

Referenced by posix_get_identifier().

Here is the caller graph for this function:

template<unsigned digest_size_, Algorithms algorithm_>
std::string shash::Digest< digest_size_, algorithm_ >::MakePathWithoutSuffix ( ) const
inline

Produces a relative path representation of the digest without appending the hash suffix. See Digest<>::MakePath() for more details.

Returns
a relative path representation of the digest without the suffix

Definition at line 333 of file hash.h.

Referenced by PosixQuotaManager::MainCommandServer(), swissknife::MakePath(), and PosixQuotaManager::Remove().

Here is the caller graph for this function:

template<unsigned digest_size_, Algorithms algorithm_>
bool shash::Digest< digest_size_, algorithm_ >::operator!= ( const Digest< digest_size_, algorithm_ > &  other) const
inline

Definition at line 405 of file hash.h.

template<unsigned digest_size_, Algorithms algorithm_>
bool shash::Digest< digest_size_, algorithm_ >::operator< ( const Digest< digest_size_, algorithm_ > &  other) const
inline

Definition at line 409 of file hash.h.

template<unsigned digest_size_, Algorithms algorithm_>
bool shash::Digest< digest_size_, algorithm_ >::operator== ( const Digest< digest_size_, algorithm_ > &  other) const
inline

Definition at line 395 of file hash.h.

template<unsigned digest_size_, Algorithms algorithm_>
bool shash::Digest< digest_size_, algorithm_ >::operator> ( const Digest< digest_size_, algorithm_ > &  other) const
inline

Definition at line 421 of file hash.h.

template<unsigned digest_size_, Algorithms algorithm_>
void shash::Digest< digest_size_, algorithm_ >::Randomize ( )
inline

Generates a purely random hash Only used for testing purposes

Definition at line 206 of file hash.h.

template<unsigned digest_size_, Algorithms algorithm_>
void shash::Digest< digest_size_, algorithm_ >::Randomize ( const uint64_t  seed)
inline

Generates a purely random hash Only used for testing purposes

Parameters
seedrandom number generator seed (for reproducability)

Definition at line 218 of file hash.h.

template<unsigned digest_size_, Algorithms algorithm_>
void shash::Digest< digest_size_, algorithm_ >::Randomize ( Prng prng)
inline

Generates a purely random hash Only used for testing purposes

Parameters
prngrandom number generator object (for external reproducability)

Definition at line 230 of file hash.h.

template<unsigned digest_size_, Algorithms algorithm_>
void shash::Digest< digest_size_, algorithm_ >::set_suffix ( const Suffix  s)
inline

Definition at line 238 of file hash.h.

template<unsigned digest_size_, Algorithms algorithm_>
void shash::Digest< digest_size_, algorithm_ >::SetNull ( )
inline
template<unsigned digest_size_, Algorithms algorithm_>
std::string shash::Digest< digest_size_, algorithm_ >::ToFingerprint ( const bool  with_suffix = false) const
inline

Generates a hexified repesentation of the digest including the identifier string for newly added hashes. Output is in the form of 'openssl x509 fingerprint', e.g. 00:AA:BB:...-SHAKE128

Parameters
with_suffixappend the hash suffix (C,H,X, ...) to the result
Returns
a string representation of the digest

Definition at line 273 of file hash.h.

Referenced by publish::CmdHash::Main().

Here is the caller graph for this function:

template<unsigned digest_size_, Algorithms algorithm_>
std::string shash::Digest< digest_size_, algorithm_ >::ToString ( const bool  with_suffix = false) const
inline

Generates a hexified repesentation of the digest including the identifier string for newly added hashes.

Parameters
with_suffixappend the hash suffix (C,H,X, ...) to the result
Returns
a string representation of the digest

Definition at line 247 of file hash.h.

Referenced by RamCacheManager::AbortTxn(), swissknife::CommandEditTag::AddNewTag(), swissknife::CommandReconstructReflog::AddStaticManifestObjects(), SqlInsertReference::BindReference(), SqlRemoveReference::BindReference(), SqlContainsReference::BindReference(), SqlGetTimestamp::BindReference(), history::SqlInsertTag::BindTag(), swissknife::CommandListCatalogs::CatalogCallback(), swissknife::CommandMigrate::CatalogCallback(), catalog::AbstractCatalogManager< CatalogT >::ChangeRoot(), swissknife::CommandTag::CloseAndPublishHistory(), RamCacheManager::CommitToKvStore(), ExternalCacheManager::CommitTxn(), PosixCacheManager::CommitTxn(), swissknife::CommandCheck::CompareEntries(), receiver::PayloadProcessor::ConsumerEventCallback(), whitelist::Whitelist::CreateString(), RamCacheManager::CtrlTxn(), cvmcache_hash_print(), cvmfs::cvmfs_open(), LibContext::CvmfsAttrFromDirent(), swissknife::CommandCheck::DecompressPiece(), MemoryKvStore::DoCommit(), PosixQuotaManager::DoInsert(), upload::SessionContext::DoUpload(), swissknife::CommandCheck::DownloadPiece(), manifest::Manifest::ExportString(), swissknife::CommandCheck::FetchCatalog(), ServerTool::FetchRemoteManifest(), NfsMapsLeveldb::FindInode(), signature::SignatureManager::FingerprintCertificate(), ExternalCacheManager::Flush(), lru::Md5PathCache::Forget(), LibContext::GetExtAttr(), LibContext::GetNestedCatalogAttr(), HashMagicXattr::GetValue(), RepoMetainfoMagicXattr::GetValue(), RootHashMagicXattr::GetValue(), CachePlugin::HandleRefcount(), catalog::ClientCatalogManager::InitFixed(), lru::Md5PathCache::Insert(), catalog::WritableCatalog::InsertBindMountpoint(), catalog::WritableCatalog::InsertNestedCatalog(), catalog::VirtualCatalog::InsertSnapshot(), swissknife::CommandCheck::InspectReflog(), swissknife::CommandCheck::InspectTree(), catalog::ClientCatalogManager::LoadCatalog(), lru::Md5PathCache::Lookup(), publish::CmdHash::Main(), swissknife::CommandPull::Main(), swissknife::CommandRollbackTag::Main(), MainCheck(), PosixQuotaManager::MainCommandServer(), swissknife::MainWorker(), MakeAcquireRequest(), anonymous_namespace{repository_session.cc}::MakeAcquireRequest(), anonymous_namespace{repository_session.cc}::MakeDropRequest(), MakeEndRequest(), swissknife::CommandEditTag::MoveTag(), ObjectPackProducer::ObjectPackProducer(), MemoryKvStore::OnBlockMove(), swissknife::CommandScrub::OnFileHashed(), LibContext::Open(), ExternalCacheManager::OpenFromTxn(), RamCacheManager::OpenFromTxn(), PosixQuotaManager::Pin(), posix_get_identifier(), swissknife::CatalogTraversalBase< ObjectFetcherT >::PrepareCatalog(), ChunkListMagicXattr::PrepareValueFenced(), swissknife::CommandInfoTag::PrintHumanReadableInfo(), swissknife::CommandMigrate::PrintStatusMessage(), swissknife::CommandTag::PrintTagMachineReadable(), TaskRegister::Process(), receiver::CommitProcessor::Process(), PosixQuotaManager::ProcessCommandBunch(), swissknife::CommandGraft::Publish(), publish::SyncMediator::PublishFilesCallback(), publish::SyncMediator::PublishHardlinksCallback(), swissknife::CommandPull::Pull(), swissknife::CommandPull::PullRecursion(), NfsMapsLeveldb::PutPath2Inode(), PosixQuotaManager::Remove(), catalog::VirtualCatalog::RemoveSnapshot(), swissknife::CommandEditTag::RemoveTags(), swissknife::CatalogTraversalBase< ObjectFetcherT >::ReopenCatalog(), RamCacheManager::Reset(), publish::CheckoutMarker::SaveAs(), history::SqliteHistory::SetPreviousRevision(), catalog::WritableCatalog::SetPreviousRevision(), publish::SetRootHash(), MemoryKvStore::ShrinkTo(), letter::Letter::Sign(), swissknife::anonymous_namespace{swissknife_pull.cc}::SpoolerOnUpload(), cipher::MemoryKeyDatabase::StoreNew(), publish::SyncImpl(), PosixQuotaManager::Unpin(), catalog::WritableCatalog::UpdateNestedCatalog(), swissknife::CommandMigrate::AbstractMigrationWorker< DerivedT >::UpdateNestedCatalogReferences(), swissknife::CommandTag::UploadCatalogAndUpdateManifest(), download::DownloadManager::VerifyAndFinalize(), swissknife::RootChainWalker::WalkHistories(), swissknife::RootChainWalker::WalkRootCatalogs(), ExternalCacheManager::Write(), RamCacheManager::Write(), and manifest::Reflog::WriteChecksum().

template<unsigned digest_size_, Algorithms algorithm_>
std::string shash::Digest< digest_size_, algorithm_ >::ToStringWithSuffix ( ) const
inline

Convenience method to generate a string representation of the digest. See Digest<>::ToString() for details

Returns
a string representation including the hash suffix of the digest

Definition at line 302 of file hash.h.

Referenced by swissknife::CommandTag::FetchObject(), catalog::WritableCatalogManager::FinalizeCatalog(), swissknife::CommandCheck::Find(), GarbageCollector< CatalogTraversalT, HashFilterT >::LogDeletion(), swissknife::CatalogTraversalBase< ObjectFetcherT >::PrepareCatalog(), swissknife::RootChainWalker::ReturnOrAbort(), and GarbageCollectorAux< CatalogTraversalT, HashFilterT >::Sweep().

Here is the caller graph for this function:

Member Data Documentation

template<unsigned digest_size_, Algorithms algorithm_>
Algorithms shash::Digest< digest_size_, algorithm_ >::algorithm

Definition at line 123 of file hash.h.

Referenced by anonymous_namespace{libcvmfs_cache.cc}::Chash2Cpphash(), anonymous_namespace{cvmfs_cache_posix.cc}::Chash2Cpphash(), CacheManager::ChecksumFd(), ChunkItem::ChunkItem(), zlib::CompressFd2Null(), zlib::CompressFile2File(), zlib::CompressFile2Null(), zlib::CompressMem2File(), ObjectPackConsumer::ConsumeNext(), receiver::PayloadProcessor::ConsumerEventCallback(), catalog::SqlDirent::CreateDatabaseFlags(), download::DownloadManager::Fetch(), AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchReflog(), swissknife::CommandScrub::FileCallback(), CacheTransport::FillMsgHash(), shash::Final(), manifest::Manifest::GetHashAlgorithm(), LHashMagicXattr::GetValue(), catalog::DirectoryEntryBase::hash_algorithm(), signature::SignatureManager::HashCertificate(), FileChunkReflist::HashChunkList(), shash::HashFd(), shash::HashMem(), shash::Hmac(), swissknife::CommandCheck::InspectReflog(), publish::CmdHash::Main(), swissknife::CommandPull::Main(), MainCheck(), compat::shash_v1::MigrateAny(), compat::shash_v2::MigrateAny(), s3fanout::S3FanoutManager::MkV2Authz(), shash::Digest< 16, kMd5 >::operator==(), shash::Digest< 16, kMd5 >::operator>(), CacheTransport::ParseMsgHash(), TaskRegister::Process(), SigningTool::Run(), swissknife::CommandListReflog::Run(), PosixQuotaManager::LruCommand::StoreHash(), publish::SyncItem::SyncItem(), signature::SignatureManager::VerifyLetter(), whitelist::Whitelist::VerifyLoadedCertificate(), and swissknife::RootChainWalker::WalkHistories().

template<unsigned digest_size_, Algorithms algorithm_>
Suffix shash::Digest< digest_size_, algorithm_ >::suffix

The documentation for this struct was generated from the following file: