<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/hash.h, branch v2.21.3</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.21.3</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.21.3'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2018-11-14T07:54:53Z</updated>
<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>
<entry>
<title>Add structure representing hash algorithm</title>
<updated>2017-11-13T04:20:44Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2017-11-12T21:28:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f50e766b7b3dd02fc44ff7d4339c6f62e70fbf60'/>
<id>urn:sha1:f50e766b7b3dd02fc44ff7d4339c6f62e70fbf60</id>
<content type='text'>
Since in the future we want to support an additional hash algorithm, add
a structure that represents a hash algorithm and all the data that must
go along with it.  Add a constant to allow easy enumeration of hash
algorithms.  Implement function typedefs to create an abstract API that
can be used by any hash algorithm, and wrappers for the existing SHA1
functions that conform to this API.

Expose a value for hex size as well as binary size.  While one will
always be twice the other, the two values are both used extremely
commonly throughout the codebase and providing both leads to improved
readability.

Don't include an entry in the hash algorithm structure for the null
object ID.  As this value is all zeros, any suitably sized all-zero
object ID can be used, and there's no need to store a given one on a
per-hash basis.

The current hash function transition plan envisions a time when we will
accept input from the user that might be in SHA-1 or in the NewHash
format.  Since we cannot know which the user has provided, add a
constant representing the unknown algorithm to allow us to indicate that
we must look the correct value up.  Provide dummy API functions that die
in this case.

Finally, include git-compat-util.h in hash.h so that the required types
are available.  This aids people using automated tools their editors.

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>sha1dc: build git plumbing code more explicitly</title>
<updated>2017-08-16T21:43:59Z</updated>
<author>
<name>Takashi Iwai</name>
<email>tiwai@suse.de</email>
</author>
<published>2017-08-15T12:04:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=36f048c5e488005da0a9dfba6b617c7c9951c7cf'/>
<id>urn:sha1:36f048c5e488005da0a9dfba6b617c7c9951c7cf</id>
<content type='text'>
The plumbing code between sha1dc and git is defined in
sha1dc_git.[ch], but these aren't compiled / included directly but
only via the indirect inclusion from sha1dc code.  This is slightly
confusing when you try to trace the build flow.

This patch brings the following changes for simplification:

  - Make sha1dc_git.c stand-alone and build from Makefile

  - sha1dc_git.h is the common header to include further sha1.h
    depending on the build condition

  - Move comments for plumbing codes from the header to definitions

This is also meant as a preliminary work for further plumbing with
external sha1dc shlib.

Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
