Lines Matching refs:hash
40 # pkg(7) uses cryptographic hash functions for a number of tasks. We define the
41 # default hash function, along with the hash name here. Note that the use of
49 # Other uses are essentially volatile, and the hash used has no persistence
50 # (e.g. saving the hash to a file in a temporary directory, when the hash gets
62 # support for a certain hash algorithm, but still retain the ability to install
63 # actions using that hash.
67 # the first hash value in the list when using the *old* publication model (ie.
71 # using the "least preferred" hash for maximum backwards compatibility with
77 # using the "most preferred" hash. See get_preferred_hash(..),
81 LEGACY_HASH_ATTRS = ["hash"]
88 if DebugValues["hash"]:
89 _hashes = reversed(DebugValues["hash"].split("+"))
109 DEFAULT_HASH_ATTRS.append("hash")
116 DEFAULT_HASH_ATTRS.append("pkg.content-hash")
117 DEFAULT_CHASH_ATTRS.append("pkg.content-hash")
118 DEFAULT_GELF_HASH_ATTRS.append("pkg.content-hash")
140 # object which must have an 'update(data)' method , used to update the hash
142 # return the hexadecimal value of the hash.
149 # Dictionaries of the pkg(7) hash and content-hash attributes we know about.
150 if DebugValues["hash"] == "sha1":
152 HASH_ALGS = {"hash": hashlib.sha1}
156 "hash": hashlib.sha1,
157 "pkg.hash.sha256": hashlib.sha256,
169 HASH_ALGS["pkg.hash.sha512t_256"] = pkg.sha512_t.SHA512_t
175 # A dictionary of the compressed hash attributes we know about.
178 CHASH_ALGS[key.replace("hash", "chash")] = HASH_ALGS[key]
180 # A dictionary of signature action chain hash attributes we know about.
183 CHAIN_ALGS[key.replace("hash", "chain")] = HASH_ALGS[key]
188 CHAIN_CHASH_ALGS[key.replace("hash", "chain.chashes")] = HASH_ALGS[key]
194 """Tells whether or not the named attribute contains a hash value."""
200 hash attributes from "most preferred" to "least preferred" and a mapping
201 of those attributes to the hash algorithms that are used to
205 preferred hash to most preferred hash.
232 pkg.content-hash
253 where 'hash_attr' is the preferred hash attribute name, 'hash_val'
254 is the the preferred hash value, and 'hash_func' is the function
255 used to compute the preferred hash based on the available
256 pkg.content-hash or pkg.*hash.* attributes declared in the action."""
276 # The corresponding hash attr should be in the
282 if action.hash:
283 return attr, action.hash, hash_dic[attr]
290 # pkg.content-hash.
292 attr = "pkg.content-hash"
301 # The corresponding hash attr should be in the
307 # fallback to the default hash member since it's not in action.attrs
309 return None, action.hash, hashlib.sha1
313 # an action can legitimately have no GELF content-hash if it's not a
326 raise Exception("Error determining the least preferred hash "
329 raise Exception("Error determining the preferred hash for "
334 """Returns a tuple of the least preferred hash attribute name, the hash
335 value that should result when we compute the hash, and the function used
336 to compute the hash based on the available hash and pkg.*hash.*
344 """Returns the most preferred hash attribute of those present
346 action. We return the name of the hash attribute, the new and
348 to compute the hash.
350 The pkg.content-hash attribute may be multi-valued. When
358 this case, the most preferred hash will be selected first, and
359 then we'll check for unsigned versions of that hash on both
360 actions. When both actions have that unsigned hash, its values
364 <Action>.hash member assuming it is not None for the new and
366 'hash' member is set, we return a tuple of None objects.
393 # The corresponding hash attr should be in the
402 # pkg.content-hash.
403 attr = "pkg.content-hash"
421 # Here we've matched a ranked hash type in at
422 # least one of the pkg.content-hash value
424 # we're allowing comparison on unsigned hash
425 # values, and both value sets have this hash
427 # corresponding unsigned hash, swap in those
428 # unsigned hash values.
439 # The corresponding hash attr should be in the
448 if action.hash and old_action.hash:
449 return None, action.hash, old_action.hash, hashlib.sha1