summaryrefslogtreecommitdiff
path: root/src/hash
Commit message (Collapse)AuthorAgeFilesLines
* sha1: win32: fix compilation due to unknown typePatrick Steinhardt2019-07-181-1/+1
| | | | | | | | | | In commit bbf034ab9 (hash: move `git_hash_prov` into Win32 backend, 2019-02-22), the `git_hash_prov`'s structure name has been removed in favour of its typedef'ed name. But as we have no CI that compiles with the WinHTTPS hashing backend right now, it wasn't noticed that the implementation that uses this struct wasn't changed correctly. Fix the struct type to make it compile again.
* hash: move SHA1 implementations to its own hashing contextPatrick Steinhardt2019-06-2413-67/+65
| | | | | | | | | Create a separate `git_hash_sha1_ctx` structure that is specific to the SHA1 implementation and move all SHA1 functions over to use that one instead of the generic `git_hash_ctx`. The `git_hash_ctx` for now simply has a union containing this single SHA1 implementation, only, without any mechanism to distinguish between different algortihms.
* hash: split into generic and SHA1-specific interfacePatrick Steinhardt2019-06-247-43/+52
| | | | | | | | | | | As a preparatory step to allow multiple hashing APIs to exist at the same time, split the hashing functions into one layer for generic hashing and one layer for SHA1-specific hashing. Right now, this is simply an additional indirection layer that doesn't yet serve any purpose. In the future, the generic API will be extended to allow for choosing which hash to use, though, by simply passing an enum to the hash context initialization function. This is necessary as a first step to be ready for Git's move to SHA256.
* hash: move SHA1 implementations into 'sha1/' folderPatrick Steinhardt2019-06-2417-19/+44
| | | | | | | | | | | As we will include additional hash algorithms in the future due to upstream git discussing a move away from SHA1, we should accomodate for that and prepare for the move. As a first step, move all SHA1 implementations into a common subdirectory. Also, create a SHA1-specific header file that lives inside the hash folder. This header will contain the SHA1-specific header includes, function declarations and the SHA1 context structure.
* hash: introduce source files to break include circlesPatrick Steinhardt2019-06-2412-155/+207
| | | | | | | | | | | | | | | The hash source files have circular include dependencies right now, which shows by our broken generic hash implementation. The "hash.h" header declares two functions and the `git_hash_ctx` typedef before actually including the hash backend header and can only declare the remaining hash functions after the include due to possibly static function declarations inside of the implementation includes. Let's break this cycle and help maintainability by creating a real implementation file for each of the hash implementations. Instead of relying on the exact include order, we now especially avoid the use of `GIT_INLINE` for function declarations.
* hash: move `git_hash_prov` into Win32 backendPatrick Steinhardt2019-06-241-2/+2
| | | | | | | | The structure `git_hash_prov` is only ever used by the Win32 SHA1 backend. As such, it doesn't make much sense to expose it via the generic "hash.h" header, as it is an implementation detail of the Win32 backend only. Move the typedef of `git_hash_prov` into "hash/sha1/win32.h" to fix this.
* sha1dc: update to fix endianess issues on AIX/HP-UXPatrick Steinhardt2019-06-111-3/+14
| | | | | | | Update our copy of sha1dc to the upstream commit 855827c (Detect endianess on HP-UX, 2019-05-09). Changes include fixes to endian detection on AIX and HP-UX systems as well as a define that allows us to force aligned access, which we're not using yet.
* sha1: don't inline `git_hash_global_init` for win32ethomson/win32_hashEdward Thomson2019-04-042-14/+16
| | | | | Users of the Win32 hash cannot be inlined, as it uses a static struct. Don't inline it, but continue to declare the function in the header.
* Each hash implementation should define `git_hash_global_init`Aaron Patterson2019-03-222-15/+15
| | | | | | This means the forward declaration isn't necessary. The forward declaration can cause compilation errors as it conflicts with the `GIT_INLINE` declaration (the signatures are different).
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-223-17/+17
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* hash: convert `global_init` macros to real functionPatrick Steinhardt2019-01-025-5/+25
| | | | | | | | | | | | | | | | | The `git_hash_global_init` function is simply defined as a macro to zero for most of the different hash implementations. This makes it impossible to treat it like a function pointer, which is required for a later commit where we want to improve the way global initialization works. Fix the issue by converting all no-op macros to an inline function returning zero. There's a small gotcha here, though: as most hash implementations only have a header file, but not a corresponding implementation file, we cannot declare the function as non-static. But declaring it as `static inline` fails, too, as there is a previous declaration as non-static. So we have to move the function declaration after the include that brings in the function definition, as it is allowed to have a non-static declaration after a static definition, but not the other way round.
* mbedtls: use libmbedcrypto for hashingEtienne Samson2018-04-112-0/+58
|
* sha1dc: update to fix errors with endianessbgermann2018-03-281-23/+67
| | | | This updates the version of SHA1DC to c3e1304ea3.
* hash: win32: fix missing comma in `giterr_set`Patrick Steinhardt2018-02-091-1/+1
|
* hash: set error messages on failureethomson/odb_alloc_errorEdward Thomson2018-02-091-8/+33
|
* consistent header guardsethomson/header_guardsEdward Thomson2018-02-015-15/+15
| | | | use consistent names for the #include / #define header guard pattern.
* Merge pull request #4437 from pks-t/pks/openssl-hash-errorsEdward Thomson2018-01-031-3/+18
|\ | | | | hash: openssl: check return values of SHA1_* functions
| * hash: openssl: check return values of SHA1_* functionsPatrick Steinhardt2018-01-031-3/+18
| | | | | | | | | | | | The OpenSSL functions `SHA1_Init`, `SHA1_Update` and `SHA1_Final` all return 1 for success and 0 otherwise, but we never check their return values. Do so.
* | hash: commoncrypto hash should support large filesEdward Thomson2017-12-201-2/+15
| | | | | | | | | | | | | | Teach the CommonCrypto hash mechanisms to support large files. The hash primitives take a `CC_LONG` (aka `uint32_t`) at a time. So loop to give the hash function at most an unsigned 32 bit's worth of bytes until we have hashed the entire file.
* | hash: win32 hash mechanism should support large filesEdward Thomson2017-12-201-6/+24
|/ | | | | | | Teach the win32 hash mechanisms to support large files. The hash primitives take at most `ULONG_MAX` bytes at a time. Loop, giving the hash function the maximum supported number of bytes, until we have hashed the entire file.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-034-4/+7
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* sha1dc: update to fix errors with endianess and unaligned accessPatrick Steinhardt2017-06-074-52/+136
| | | | | This updates our version of SHA1DC to e139984 (Merge pull request #35 from lidl/master, 2017-05-30).
* sha1dc: `SHA1DCUpdate` now takes a `size_t`ethomson/enfasten_sha1Edward Thomson2017-03-231-11/+1
|
* sha1dc: perf improvements from upstreamEdward Thomson2017-03-234-219/+886
| | | | | Update SHA-1 collision detection code (cr-marcstevens/sha1collisiondetection) to master to include performance improvements.
* hash: include sha1collisiondetectionEdward Thomson2017-03-035-0/+1696
| | | | | Include the SHA1 collision attack detection library from https://github.com/cr-marcstevens/sha1collisiondetection
* hash_generic: __extension__ keyword for pedantryEdward Thomson2015-02-041-1/+1
|
* Rename git_threads_ to git_libgit2_Carlos Martín Nieto2014-11-081-1/+1
| | | | | | This describes their purpose better, as we now initialize ssl and some other global stuff in there. Calling the init function is not something which has been optional for a while now.
* hash: use CommonCrypto on OSX for SHA-1cmn/common-cryptoCarlos Martín Nieto2014-10-241-0/+44
| | | | | OSX has its own cryptographic library, let's make use of it instead of calling out to OpenSSL.
* Add simple global shutdown hooksRussell Belfer2013-09-173-11/+11
| | | | | | | | | | Increasingly there are a number of components that want to do some cleanup at global shutdown time (at least if there are not going to be memory leaks). This creates a very simple system of shutdown hooks that will be invoked by git_threads_shutdown. Right now, the maximum number of hooks is hardcoded, but since adding a hook is not a public API, it should be fine and I thought it was better to start off with really simple code.
* Merge pull request #1805 from libgit2/threading-packed-loadVicent Martí2013-08-281-1/+2
|\ | | | | Thread safety for the refdb_fs
| * Load SRWLock APIs at runtimeRussell Belfer2013-08-261-1/+2
| | | | | | | | | | | | This loads SRWLock APIs at runtime and in their absence (i.e. on Windows before Vista) falls back on a regular CRITICAL_SECTION that will not permit concurrent readers.
* | Improve win32 version check, no ipv6 tests on XPEdward Thomson2013-08-271-19/+1
|/
* Unify whitespaces to tabsLinquize2013-05-152-7/+7
|
* Revert "hash: remove git_hash_init from internal api"Michael Schubert2013-02-263-3/+4
| | | | | This reverts commit efe7fad6c96a3d6197a218aeaa561ec676794499, except for the indentation fixes.
* hash: remove git_hash_init from internal apiMichael Schubert2013-02-263-5/+4
| | | | Along with that, fix indentation in tests-clar/object/raw/hash.c
* update copyrightsEdward Thomson2013-01-085-5/+5
|
* remove ppc sha1 asmEdward Thomson2013-01-083-326/+0
|
* Fix warnings on Win64 buildRussell Belfer2012-11-271-2/+2
|
* unload dll / destroy hash ctxs at shutdownEdward Thomson2012-11-134-0/+28
|
* move hash library func ptrs to global globalEdward Thomson2012-11-134-43/+49
|
* Remove git_hash_ctx_new - callers now _ctx_init()Edward Thomson2012-11-136-86/+30
|
* Win32 CryptoAPI and CNG support for SHA1Edward Thomson2012-11-138-0/+1136