CernVM-FS  2.12.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
 
uint32_t Partial32 () 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 123 of file hash.h.

Constructor & Destructor Documentation

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

Definition at line 173 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 179 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 196 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 169 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 383 of file hash.h.

Referenced by catalog::WritableCatalogManager::AddFile(), swissknife::CommandEditTag::AddNewTag(), swissknife::CommandReconstructReflog::AddStaticManifestObjects(), catalog::SqlCatalog::BindHashBlob(), catalog::AbstractCatalogManager< CatalogT >::ChangeRoot(), 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(), RepoMetainfoMagicXattr::FinalizeValue(), swissknife::RootChainWalker::FindObjectsAndPopulateReflog(), signature::SignatureManager::FingerprintCertificate(), LibContext::GetExtAttr(), swissknife::Assistant::GetHistory(), swissknife::CommandTag::GetHistory(), MagicXattrManager::GetListString(), catalog::SimpleCatalogManager::GetNewRootCatalogContext(), catalog::ClientCatalogManager::GetNewRootCatalogContext(), swissknife::CommandEditTag::GetTagRootHash(), publish::SyncItem::HasContentHash(), AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::HasHistory(), swissknife::CommandTag::InitializeEnvironment(), catalog::WritableCatalog::InsertNestedCatalog(), swissknife::CommandCheck::InspectReflog(), glue::PageCacheTracker::IsStale(), manifest::Breadcrumb::IsValid(), StreamingCacheManager::FdInfo::IsValid(), swissknife::CommandMigrate::LoadCatalogs(), catalog::AbstractCatalogManager< CatalogT >::LoadFreeCatalog(), glue::PathStore::Lookup(), swissknife::CommandListReflog::Main(), swissknife::CommandPull::Main(), swissknife::CommandCheck::Main(), catalog::AbstractCatalogManager< CatalogT >::MountCatalog(), 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 325 of file hash.h.

Referenced by catalog::ClientCatalogManager::LoadCatalogByHash(), 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 351 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 335 of file hash.h.

Referenced by catalog::WritableCatalogManager::CopyCatalogToLocalCache(), catalog::SimpleCatalogManager::LoadCatalogByHash(), 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 415 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 419 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 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 431 of file hash.h.

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

Get a partial digest for use when only 32 bits are required

Definition at line 394 of file hash.h.

Referenced by download::DownloadManager::ChooseProxyUnlocked(), and download::DownloadManager::UpdateProxiesUnlocked().

Here is the caller graph for this function:

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 208 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 reproducibility)

Definition at line 220 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 reproducibility)

Definition at line 232 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 240 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 representation 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 275 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 representation 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 249 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(), GarbageCollector< CatalogTraversalT, HashFilterT >::CheckAndSweep(), glue::PageCacheTracker::Close(), 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(), CatalogCountersMagicXattr::FinalizeValue(), HashMagicXattr::FinalizeValue(), RepoMetainfoMagicXattr::FinalizeValue(), RootHashMagicXattr::FinalizeValue(), NfsMapsLeveldb::FindInode(), signature::SignatureManager::FingerprintCertificate(), ExternalCacheManager::Flush(), lru::Md5PathCache::Forget(), catalog::ClientCatalogManager::GetCatalogDescription(), LibContext::GetExtAttr(), LibContext::GetNestedCatalogAttr(), catalog::ClientCatalogManager::GetNewRootCatalogContext(), CachePlugin::HandleRefcount(), catalog::ClientCatalogManager::InitFixed(), lru::Md5PathCache::Insert(), catalog::WritableCatalog::InsertBindMountpoint(), catalog::WritableCatalog::InsertNestedCatalog(), catalog::VirtualCatalog::InsertSnapshot(), swissknife::CommandCheck::InspectReflog(), swissknife::CommandCheck::InspectTree(), lru::Md5PathCache::Lookup(), catalog::AbstractCatalogManager< CatalogT >::LookupCounters(), 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(), glue::PageCacheTracker::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(), receiver::CommitProcessor::Process(), TaskRegister::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::Sync(), 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 304 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 125 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(), LHashMagicXattr::FinalizeValue(), manifest::Manifest::GetHashAlgorithm(), 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: