CernVM-FS
2.12.0
|
Classes | |
struct | HexPtr |
struct | AsciiPtr |
struct | Digest |
struct | Md5 |
struct | Sha1 |
struct | Rmd160 |
struct | Shake128 |
struct | Any |
class | ContextPtr |
Typedefs | |
typedef char | Suffix |
Enumerations | |
enum | Algorithms { kMd5 = 0, kSha1, kRmd160, kShake128, kAny } |
Functions | |
Algorithms | ParseHashAlgorithm (const string &algorithm_option) |
Any | MkFromHexPtr (const HexPtr hex, const char suffix) |
Any | MkFromSuffixedHexPtr (const HexPtr hex) |
unsigned | GetContextSize (const Algorithms algorithm) |
void | Init (ContextPtr context) |
void | Update (const unsigned char *buffer, const unsigned buffer_length, ContextPtr context) |
void | Final (ContextPtr context, Any *any_digest) |
void | HashMem (const unsigned char *buffer, const unsigned buffer_size, Any *any_digest) |
void | HashString (const std::string &content, Any *any_digest) |
void | Hmac (const string &key, const unsigned char *buffer, const unsigned buffer_size, Any *any_digest) |
bool | HashFd (int fd, Any *any_digest) |
bool | HashFile (const std::string &filename, Any *any_digest) |
static string | HexFromSha256 (unsigned char digest[SHA256_DIGEST_LENGTH]) |
string | Sha256File (const string &filename) |
string | Sha256Mem (const unsigned char *buffer, const unsigned buffer_size) |
string | Sha256String (const string &content) |
std::string | Hmac256 (const std::string &key, const std::string &content, bool raw_output) |
CVMFS_EXPORT void | Hmac (const std::string &key, const unsigned char *buffer, const unsigned buffer_size, Any *any_digest) |
void | HmacString (const std::string &key, const std::string &content, Any *any_digest) |
CVMFS_EXPORT std::string | Sha256File (const std::string &filename) |
CVMFS_EXPORT std::string | Sha256String (const std::string &content) |
CVMFS_EXPORT Algorithms | ParseHashAlgorithm (const std::string &algorithm_option) |
Variables | |
const char * | kAlgorithmIds [] |
const char | kSuffixNone = 0 |
const char | kSuffixCatalog = 'C' |
const char | kSuffixHistory = 'H' |
const char | kSuffixMicroCatalog = 'L' |
const char | kSuffixPartial = 'P' |
const char | kSuffixTemporary = 'T' |
const char | kSuffixCertificate = 'X' |
const char | kSuffixMetainfo = 'M' |
const unsigned | kDigestSizes [] |
const unsigned | kMaxDigestSize = 20 |
const unsigned | kMaxContextSize = 256 |
const unsigned | kAlgorithmIdSizes [] |
const unsigned | kMaxAlgorithmIdentifierSize = 9 |
const unsigned | kBlockSizes [] |
This file is part of the CernVM File System.
This file is part of the CernVM File System.
Provides a bit syntactic sugar around the hash algorithms. In particular, hashes can easily be created by constructors. Also, we have a little to-string-from-string conversion.
The complexity is due to the need to avoid dynamically allocated memory for the hashes. Almost everything happens on the stack.
typedef char shash::Suffix |
enum shash::Algorithms |
CVMFS_EXPORT void shash::Final | ( | ContextPtr | context, |
Any * | any_digest | ||
) |
Definition at line 221 of file hash.cc.
Referenced by CacheManager::ChecksumFd(), swissknife::CommandGraft::ChecksumFdWithChunks(), zlib::CompressFd2Null(), zlib::CompressFile2File(), zlib::CompressFile2Null(), zlib::CompressMem2File(), receiver::PayloadProcessor::ConsumerEventCallback(), upload::GatewayUploader::DoUpload(), FileChunkReflist::HashChunkList(), HashFd(), HashMem(), Hmac(), catalog::Catalog::NormalizePath(), TaskHash::Process(), and download::DownloadManager::VerifyAndFinalize().
CVMFS_EXPORT unsigned shash::GetContextSize | ( | const Algorithms | algorithm | ) |
Allows the caller to create the context on the stack.
Actual operations on digests, like "hash a file", "hash a buffer", or iterative operations.
Definition at line 148 of file hash.cc.
Referenced by ChunkItem::ChunkItem(), and download::DownloadManager::Fetch().
CVMFS_EXPORT bool shash::HashFd | ( | int | fd, |
Any * | any_digest | ||
) |
Definition at line 321 of file hash.cc.
Referenced by HashFile(), and publish::CmdHash::Main().
CVMFS_EXPORT bool shash::HashFile | ( | const std::string & | filename, |
Any * | any_digest | ||
) |
Definition at line 342 of file hash.cc.
Referenced by HasDirtabChanged(), manifest::Reflog::HashDatabase(), and MainCheck().
CVMFS_EXPORT void shash::HashMem | ( | const unsigned char * | buffer, |
const unsigned | buffer_size, | ||
Any * | any_digest | ||
) |
Definition at line 255 of file hash.cc.
Referenced by catalog::VirtualCatalog::CreateNestedCatalogMarker(), signature::SignatureManager::HashCertificate(), HashMeta(), HashString(), Hmac(), catalog::CatalogBalancer< CatalogMgrT >::MakeEmptyDirectoryEntryBase(), s3fanout::S3FanoutManager::MkPayloadHash(), publish::PushManifest(), SigningTool::Run(), letter::Letter::Sign(), cipher::MemoryKeyDatabase::StoreNew(), and signature::SignatureManager::VerifyLetter().
CVMFS_EXPORT void shash::HashString | ( | const std::string & | content, |
Any * | any_digest | ||
) |
Definition at line 268 of file hash.cc.
Referenced by ObjectPackConsumer::ConsumeNext(), whitelist::Whitelist::CreateString(), ObjectPackProducer::GetDigest(), publish::CmdHash::Main(), and download::DownloadManager::UpdateProxiesUnlocked().
|
static |
Definition at line 399 of file hash.cc.
Referenced by Hmac256(), Sha256File(), and Sha256Mem().
void shash::Hmac | ( | const string & | key, |
const unsigned char * | buffer, | ||
const unsigned | buffer_size, | ||
Any * | any_digest | ||
) |
Definition at line 274 of file hash.cc.
Referenced by cipher::CipherAes256Cbc::GenerateIv(), HmacString(), and s3fanout::S3FanoutManager::MkV2Authz().
CVMFS_EXPORT void shash::Hmac | ( | const std::string & | key, |
const unsigned char * | buffer, | ||
const unsigned | buffer_size, | ||
Any * | any_digest | ||
) |
CVMFS_EXPORT std::string shash::Hmac256 | ( | const std::string & | key, |
const std::string & | content, | ||
bool | raw_output = false |
||
) |
Only used for AWS4 signature.
Adding SHA-256 to the standard hash infrastructure would generally bloat the digets size to 32 bytes and require client data structure transformation during hotpatch.
Definition at line 458 of file hash.cc.
Referenced by s3fanout::S3FanoutManager::GetAwsV4SigningKey(), s3fanout::S3FanoutManager::MkAzureAuthz(), and s3fanout::S3FanoutManager::MkV4Authz().
|
inline |
Definition at line 527 of file hash.h.
Referenced by upload::SessionContext::DoUpload(), MakeAcquireRequest(), anonymous_namespace{repository_session.cc}::MakeAcquireRequest(), anonymous_namespace{repository_session.cc}::MakeDropRequest(), and MakeEndRequest().
CVMFS_EXPORT void shash::Init | ( | ContextPtr | context | ) |
Definition at line 164 of file hash.cc.
Referenced by CacheManager::ChecksumFd(), swissknife::CommandGraft::ChecksumFdWithChunks(), ChunkItem::ChunkItem(), zlib::CompressFd2Null(), zlib::CompressFile2File(), zlib::CompressFile2Null(), zlib::CompressMem2File(), upload::GatewayUploader::DoUpload(), receiver::FileInfo::FileInfo(), FileChunkReflist::HashChunkList(), download::DownloadManager::InitializeRequest(), catalog::Catalog::NormalizePath(), and download::DownloadManager::VerifyAndFinalize().
CVMFS_EXPORT Any shash::MkFromHexPtr | ( | const HexPtr | hex, |
const char | suffix | ||
) |
Definition at line 83 of file hash.cc.
Referenced by manifest::Breadcrumb::Breadcrumb(), publish::SyncItem::CheckGraft(), publish::CheckoutMarker::CreateFrom(), publish::SettingsBuilder::CreateSettingsPublisher(), publish::SettingsBuilder::CreateSettingsPublisherFromSession(), MountPoint::DetermineRootHash(), PosixQuotaManager::DoCleanup(), catalog::SqlNestedCatalogLookup::GetContentHash(), catalog::SqlNestedCatalogListing::GetContentHash(), catalog::SqlOwnNestedCatalogListing::GetContentHash(), catalog::Catalog::GetPreviousRevision(), anonymous_namespace{repository_diff.cc}::GetTag(), swissknife::CommandEditTag::GetTagRootHash(), swissknife::CommandTag::InitializeEnvironment(), manifest::Manifest::Load(), swissknife::CommandListCatalogs::Main(), swissknife::Ingest::Main(), swissknife::CommandFileStats::Main(), swissknife::CommandApplyDirtab::Main(), swissknife::CommandMigrate::Main(), swissknife::CommandSync::Main(), MainCheck(), TalkManager::MainResponder(), signature::SignatureManager::MkFromFingerprint(), posix_get_identifier(), history::SqliteHistory::previous_revision(), receiver::PayloadProcessor::Process(), manifest::Reflog::ReadChecksum(), SqlListReferences::RetrieveHash(), history::SqlGetHashes::RetrieveHash(), history::SqlRecycleBinList::RetrieveHash(), catalog::SqlCatalog::RetrieveHashHex(), history::SqlRetrieveTag< SqlRollback< SqlHistory > >::RetrieveTag(), and signature::SignatureManager::VerifyLetter().
CVMFS_EXPORT Any shash::MkFromSuffixedHexPtr | ( | const HexPtr | hex | ) |
Similar to MkFromHexPtr but the suffix is deducted from the HexPtr string.
Definition at line 105 of file hash.cc.
Referenced by swissknife::CommandScrub::FileCallback(), receiver::Reactor::HandleCommit(), swissknife::CommandScrub::OnFileHashed(), and ObjectPackConsumer::ParseItem().
Algorithms shash::ParseHashAlgorithm | ( | const string & | algorithm_option | ) |
Definition at line 72 of file hash.cc.
Referenced by receiver::GetParamsFromFile(), swissknife::CommandTag::InitializeEnvironment(), publish::CmdHash::Main(), swissknife::CommandLetter::Main(), swissknife::CommandGraft::Main(), swissknife::Ingest::Main(), swissknife::CommandCreate::Main(), swissknife::CommandUpload::Main(), swissknife::CommandSync::Main(), and publish::SettingsTransaction::SetHashAlgorithm().
CVMFS_EXPORT Algorithms shash::ParseHashAlgorithm | ( | const std::string & | algorithm_option | ) |
string shash::Sha256File | ( | const string & | filename | ) |
CVMFS_EXPORT std::string shash::Sha256File | ( | const std::string & | filename | ) |
CVMFS_EXPORT std::string shash::Sha256Mem | ( | const unsigned char * | buffer, |
const unsigned | buffer_size | ||
) |
Definition at line 442 of file hash.cc.
Referenced by s3fanout::S3FanoutManager::MkPayloadHash(), and Sha256String().
string shash::Sha256String | ( | const string & | content | ) |
Definition at line 452 of file hash.cc.
Referenced by s3fanout::S3FanoutManager::MkV4Authz().
CVMFS_EXPORT std::string shash::Sha256String | ( | const std::string & | content | ) |
CVMFS_EXPORT void shash::Update | ( | const unsigned char * | buffer, |
const unsigned | buffer_length, | ||
ContextPtr | context | ||
) |
Definition at line 190 of file hash.cc.
Referenced by download::CallbackCurlData(), swissknife::CommandGraft::ChecksumFdWithChunks(), zlib::CompressFd2Null(), zlib::CompressFile2File(), zlib::CompressFile2Null(), zlib::CompressMem2File(), zlib::CompressZStream2Null(), receiver::PayloadProcessor::ConsumerEventCallback(), upload::GatewayUploader::DoUpload(), FileChunkReflist::HashChunkList(), HashFd(), HashMem(), Hmac(), catalog::Catalog::NormalizePath(), and TaskHash::Process().
CVMFS_EXPORT const char * shash::kAlgorithmIds |
Hex representations of hashes with the same length need a suffix to be distinguished from each other. They should all have one but for backwards compatibility MD5 and SHA-1 have none. Initialized in hash.cc like const char *kAlgorithmIds[] = {"", "", "-rmd160", ...
Definition at line 33 of file hash.cc.
Referenced by shash::Digest< digest_size_, algorithm_ >::Hex::GetAlgorithmIdentifierChar(), and shash::HexPtr::IsValid().
const unsigned shash::kAlgorithmIdSizes[] |
const unsigned shash::kBlockSizes[] |
const unsigned shash::kDigestSizes[] |
Corresponds to Algorithms. "Any" is the maximum of all the other digest sizes. When the maximum digest size changes, the memory layout of DirectoryEntry and PosixQuotaManager::LruCommand changes, too!
Definition at line 69 of file hash.h.
Referenced by CacheTransport::FillMsgHash(), signature::SignatureManager::FingerprintCertificate(), FileChunkReflist::HashChunkList(), publish::CmdHash::Main(), PosixQuotaManager::MainCommandServer(), and CacheTransport::ParseMsgHash().
const unsigned shash::kMaxContextSize = 256 |
The maximum of GetContextSize()
Definition at line 77 of file hash.h.
Referenced by upload::GatewayUploader::DoUpload().
const unsigned shash::kMaxDigestSize = 20 |
Definition at line 72 of file hash.h.
Referenced by PosixQuotaManager::LruCommand::LruCommand(), and ObjectPackProducer::ObjectPackProducer().
const char shash::kSuffixCatalog = 'C' |
Definition at line 54 of file hash.h.
Referenced by manifest::Reflog::AddCatalog(), manifest::Breadcrumb::Breadcrumb(), swissknife::CommandScrub::CheckPathAndExtractHash(), manifest::Reflog::ContainsCatalog(), publish::CheckoutMarker::CreateFrom(), catalog::WritableCatalogManager::CreateRepository(), publish::SettingsBuilder::CreateSettingsPublisher(), publish::SettingsBuilder::CreateSettingsPublisherFromSession(), MountPoint::DetermineRootHash(), AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchCatalog(), catalog::ClientCatalogManager::FetchCatalogByHash(), upload::LocalUploader::FinalizeStreamedUpload(), upload::S3Uploader::FinalizeStreamedUpload(), upload::GatewayUploader::FinalizeStreamedUpload(), swissknife::Assistant::GetCatalog(), swissknife::CommandTag::GetCatalog(), manifest::Reflog::GetCatalogTimestamp(), catalog::SqlNestedCatalogLookup::GetContentHash(), catalog::SqlNestedCatalogListing::GetContentHash(), catalog::SqlOwnNestedCatalogListing::GetContentHash(), catalog::ClientCatalogManager::GetNewRootCatalogContext(), catalog::Catalog::GetPreviousRevision(), anonymous_namespace{repository_diff.cc}::GetTag(), swissknife::CommandEditTag::GetTagRootHash(), swissknife::CommandTag::InitializeEnvironment(), manifest::Manifest::Load(), ExternalCacheManager::LoadBreadcrumb(), catalog::SimpleCatalogManager::LoadCatalogByHash(), swissknife::CommandListCatalogs::Main(), swissknife::Ingest::Main(), swissknife::CommandFileStats::Main(), swissknife::CommandApplyDirtab::Main(), swissknife::CommandMigrate::Main(), swissknife::CommandSync::Main(), TalkManager::MainResponder(), swissknife::CommandPull::Pull(), manifest::Reflog::Remove(), GarbageCollector< CatalogTraversalT, HashFilterT >::RemoveCatalogFromReflog(), history::SqlGetHashes::RetrieveHash(), history::SqlRecycleBinList::RetrieveHash(), history::SqlRetrieveTag< SqlRollback< SqlHistory > >::RetrieveTag(), catalog::WritableCatalogManager::SnapshotCatalogsSerialized(), catalog::ClientCatalogManager::StageNestedCatalogByHash(), and SqlReflog::ToSuffix().
const char shash::kSuffixCertificate = 'X' |
Definition at line 59 of file hash.h.
Referenced by manifest::Reflog::AddCertificate(), swissknife::CommandScrub::CheckPathAndExtractHash(), manifest::Reflog::ContainsCertificate(), manifest::Manifest::Load(), manifest::Reflog::Remove(), and SqlReflog::ToSuffix().
const char shash::kSuffixHistory = 'H' |
Definition at line 55 of file hash.h.
Referenced by manifest::Reflog::AddHistory(), swissknife::CommandScrub::CheckPathAndExtractHash(), manifest::Reflog::ContainsHistory(), AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchHistory(), manifest::Manifest::Load(), history::SqliteHistory::previous_revision(), manifest::Reflog::Remove(), and SqlReflog::ToSuffix().
const char shash::kSuffixMetainfo = 'M' |
Definition at line 60 of file hash.h.
Referenced by manifest::Reflog::AddMetainfo(), swissknife::CommandScrub::CheckPathAndExtractHash(), manifest::Reflog::ContainsMetainfo(), manifest::Manifest::Load(), manifest::Reflog::Remove(), and SqlReflog::ToSuffix().
const char shash::kSuffixMicroCatalog = 'L' |
Definition at line 56 of file hash.h.
Referenced by swissknife::CommandScrub::CheckPathAndExtractHash(), swissknife::CommandCheck::Find(), manifest::Manifest::Load(), and catalog::SqlAllChunks::SqlAllChunks().
const char shash::kSuffixNone = 0 |
NOTE: when adding a suffix here, one must edit cvmfs_swissknife scrub
accordingly, that checks for invalid hash suffixes
Definition at line 53 of file hash.h.
Referenced by AbstractObjectFetcher< LocalObjectFetcher< CatalogT, HistoryT, ReflogT > >::FetchReflog(), compat::shash_v1::MigrateAny(), history::SqlRecycleBinList::RetrieveHash(), and catalog::SqlAllChunks::SqlAllChunks().
const char shash::kSuffixPartial = 'P' |
Definition at line 57 of file hash.h.
Referenced by swissknife::CommandScrub::CheckPathAndExtractHash(), ChunkItem::ChunkItem(), upload::LocalUploader::FinalizeStreamedUpload(), upload::S3Uploader::FinalizeStreamedUpload(), upload::GatewayUploader::FinalizeStreamedUpload(), catalog::SqlChunksListing::GetFileChunk(), catalog::SqlListContentHashes::GetHash(), FileItem::RegisterChunk(), catalog::SqlAllChunks::SqlAllChunks(), and GarbageCollector< CatalogTraversalT, HashFilterT >::Sweep().