]> git.ipfire.org Git - thirdparty/git.git/commit
hash.h: scaffolding for _unsafe hashing variants
authorTaylor Blau <me@ttaylorr.com>
Thu, 26 Sep 2024 15:22:47 +0000 (11:22 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Sep 2024 18:27:47 +0000 (11:27 -0700)
commit253ed9ecfffa3e50b95e08bb513fdf9efcc5a85f
treee68c26fee97a5e99e254daca61e73ea7d38bd8b9
parent4c61a1d040b2b0ce4fa88d89e3169f6e766d4134
hash.h: scaffolding for _unsafe hashing variants

Git's default SHA-1 implementation is collision-detecting, which hardens
us against known SHA-1 attacks against Git objects. This makes Git
object writes safer at the expense of some speed when hashing through
the collision-detecting implementation, which is slower than
non-collision detecting alternatives.

Prepare for loading a separate "unsafe" SHA-1 implementation that can be
used for non-cryptographic purposes, like computing the checksum of
files that use the hashwrite() API.

This commit does not actually introduce any new compile-time knobs to
control which implementation is used as the unsafe SHA-1 variant, but
does add scaffolding so that the "git_hash_algo" structure has five new
function pointers which are "unsafe" variants of the five existing
hashing-related function pointers:

  - git_hash_init_fn unsafe_init_fn
  - git_hash_clone_fn unsafe_clone_fn
  - git_hash_update_fn unsafe_update_fn
  - git_hash_final_fn unsafe_final_fn
  - git_hash_final_oid_fn unsafe_final_oid_fn

The following commit will introduce compile-time knobs to specify which
SHA-1 implementation is used for non-cryptographic uses.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
hash.h
object-file.c