<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/hash.h, branch v2.25.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.25.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.25.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2019-06-20T17:40:42Z</updated>
<entry>
<title>hash.h: move object_id definition from cache.h</title>
<updated>2019-06-20T17:40:42Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-06-20T07:41:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c0566d78aac1d5f8ff90c75f2d936487bb5a8d84'/>
<id>urn:sha1:c0566d78aac1d5f8ff90c75f2d936487bb5a8d84</id>
<content type='text'>
Our hashmap.h helpfully defines a sha1hash() function. But it cannot
define a similar oidhash() without including all of cache.h, which
itself wants to include hashmap.h! Let's break this circular dependency
by moving the definition to hash.h, along with the remaining RAWSZ
macros, etc. That will put them with the existing git_hash_algo
definition.

One alternative would be to move oidhash() into cache.h, but it's
already quite bloated. We're better off moving things out than in.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hash: add a function to lookup hash algorithm by length</title>
<updated>2019-04-01T02:57:39Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2019-02-19T00:05:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=95399788d158e4628e25db20569d44af21a40906'/>
<id>urn:sha1:95399788d158e4628e25db20569d44af21a40906</id>
<content type='text'>
There are some cases, such as the dumb HTTP transport and bundles, where
we can only determine the hash algorithm in use by the length of the
object IDs. Provide a function that looks up the algorithm by length.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hash: add an SHA-256 implementation using OpenSSL</title>
<updated>2018-11-14T07:54:53Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2018-11-14T04:09:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4b4e2918099600c1eefe7b5a71bf647803905b7e'/>
<id>urn:sha1:4b4e2918099600c1eefe7b5a71bf647803905b7e</id>
<content type='text'>
We already have OpenSSL routines available for SHA-1, so add routines
for SHA-256 as well.

On a Core i7-6600U, this SHA-256 implementation compares favorably to
the SHA1DC SHA-1 implementation:

SHA-1: 157 MiB/s (64 byte chunks); 337 MiB/s (16 KiB chunks)
SHA-256: 165 MiB/s (64 byte chunks); 408 MiB/s (16 KiB chunks)

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sha256: add an SHA-256 implementation using libgcrypt</title>
<updated>2018-11-14T07:54:53Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2018-11-14T04:09:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=27dc04c54506967fcaa87b2d560547ee5633040c'/>
<id>urn:sha1:27dc04c54506967fcaa87b2d560547ee5633040c</id>
<content type='text'>
Generally, one gets better performance out of cryptographic routines
written in assembly than C, and this is also true for SHA-256.  In
addition, most Linux distributions cannot distribute Git linked against
OpenSSL for licensing reasons.

Most systems with GnuPG will also have libgcrypt, since it is a
dependency of GnuPG.  libgcrypt is also faster than the SHA1DC
implementation for messages of a few KiB and larger.

For comparison, on a Core i7-6600U, this implementation processes 16 KiB
chunks at 355 MiB/s while SHA1DC processes equivalent chunks at 337
MiB/s.

In addition, libgcrypt is licensed under the LGPL 2.1, which is
compatible with the GPL.  Add an implementation of SHA-256 that uses
libgcrypt.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Add a base implementation of SHA-256 support</title>
<updated>2018-11-14T07:54:53Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2018-11-14T04:09:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=13eeedb5d17ca3539600b6618d103b652ecc8ab0'/>
<id>urn:sha1:13eeedb5d17ca3539600b6618d103b652ecc8ab0</id>
<content type='text'>
SHA-1 is weak and we need to transition to a new hash function.  For
some time, we have referred to this new function as NewHash.  Recently,
we decided to pick SHA-256 as NewHash.  The reasons behind the choice of
SHA-256 are outlined in the thread starting at [1] and in the commit
history for the hash function transition document.

Add a basic implementation of SHA-256 based off libtomcrypt, which is in
the public domain.  Optimize it and restructure it to meet our coding
standards.  Pull in the update and final functions from the SHA-1 block
implementation, as we know these function correctly with all compilers.
This implementation is slower than SHA-1, but more performant
implementations will be introduced in future commits.

Wire up SHA-256 in the list of hash algorithms, and add a test that the
algorithm works correctly.

Note that with this patch, it is still not possible to switch to using
SHA-256 in Git.  Additional patches are needed to prepare the code to
handle a larger hash algorithm and further test fixes are needed.

[1] https://public-inbox.org/git/20180609224913.GC38834@genre.crustytoothpaste.net/

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sha1-file: add a constant for hash block size</title>
<updated>2018-11-14T07:54:52Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2018-11-14T04:09:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a2ce0a752600a44979da94b19aa1b367c6850bd7'/>
<id>urn:sha1:a2ce0a752600a44979da94b19aa1b367c6850bd7</id>
<content type='text'>
There is one place we need the hash algorithm block size: the HMAC code
for push certs.  Expose this constant in struct git_hash_algo and expose
values for SHA-1 and for the largest value of any hash.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>sha1-file: provide functions to look up hash algorithms</title>
<updated>2018-10-22T03:59:08Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2018-10-22T02:43:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2f90b9d9b4ba1f8e79318853301e8ef19ca02681'/>
<id>urn:sha1:2f90b9d9b4ba1f8e79318853301e8ef19ca02681</id>
<content type='text'>
There are several ways we might refer to a hash algorithm: by name, such
as in the config file; by format ID, such as in a pack; or internally,
by a pointer to the hash_algos array.  Provide functions to look up hash
algorithms based on these various forms and return the internal constant
used for them.  If conversion to another form is necessary, this
internal constant can be used to look up the proper data in the
hash_algos array.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hash: update obsolete reference to SHA1_HEADER</title>
<updated>2018-02-09T17:56:10Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2018-02-08T02:48:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b212c0ca318bc4757b051080f8622796c4524890'/>
<id>urn:sha1:b212c0ca318bc4757b051080f8622796c4524890</id>
<content type='text'>
We moved away from SHA1_HEADER to a preprocessor if chain, but didn't
update the comment discussing the platform defines.  Update this comment
so it reflects the current state of our codebase.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hash: create union for hash context allocation</title>
<updated>2018-02-02T19:28:41Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2018-02-01T02:18:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ac73cedff0db06671e2cab871b84b909b71adbd2'/>
<id>urn:sha1:ac73cedff0db06671e2cab871b84b909b71adbd2</id>
<content type='text'>
In various parts of our code, we want to allocate a structure
representing the internal state of a hash algorithm.  The original
implementation of the hash algorithm abstraction assumed we would do
that using heap allocations, and added a context size element to struct
git_hash_algo.  However, most of the existing code uses stack
allocations and conversion would needlessly complicate various parts of
the code.  Add a union for the purpose of allocating hash contexts on
the stack and a typedef for ease of use.  Use this union for defining
the init, update, and final functions to avoid casts.  Remove the ctxsz
element for struct git_hash_algo, which is no longer very useful.

This does mean that stack allocations will grow slightly as additional
hash functions are added, but this should not be a significant problem,
since we don't allocate many hash contexts.  The improved usability and
benefits from avoiding dynamic allocation outweigh this small downside.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hash: move SHA-1 macros to hash.h</title>
<updated>2018-02-02T19:28:40Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2018-02-01T02:18:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=164e716330a65dc6770cace76110375a20c45dea'/>
<id>urn:sha1:164e716330a65dc6770cace76110375a20c45dea</id>
<content type='text'>
Most of the other code dealing with SHA-1 and other hashes is located in
hash.h, which is in turn loaded by cache.h.  Move the SHA-1 macros to
hash.h as well, so we can use them in additional hash-related items in
the future.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
