Commit Graph

22 Commits

Author SHA1 Message Date
Edward Thomson
4546929e00 cmake: case insensitive options
It's hard to remember whether it's `-DUSE_HTTPS=mbedTLS` or
`-DUSE_HTTPS=mbedtls`. Even worse for things like `builtin` which we may
have been inconsistent about. Allow for case insensitive options.
2025-01-02 12:36:46 +00:00
Edward Thomson
c4c284e46f cmake: standardize HTTPS backend definitions
There were a few oddities around HTTPS provider selection: namely,
`GIT_OPENSSL_DYNAMIC` implied `GIT_OPENSSL`, which made a bit of sense,
until we added FIPS support. In addition, dynamic OpenSSL for _hashes_
and dynamic OpenSSL for HTTPS was conflated in a few places.

Untangle these, and make `GIT_HTTPS_*` the define, for consistency with
other feature provider selection.
2025-01-02 12:36:11 +00:00
Edward Thomson
c4a65c34c2 cmake: standardize builtin sha1dc selection
All `USE_*` options are now `builtin`. Use that for the builtin sha1dc
implementation, keeping `CollisionDetection` for backward compatibility.
2025-01-02 11:45:47 +00:00
Edward Thomson
550cf62021 cmake: warn for not using sha1dc
git's hash algorithm is sha1dc, it is not sha1. Per Linus:

> Honestly, git has effectively already moved from SHA1 to SHA1DC.
>
> So the actual known attack and weakness of SHA1 should simply not be
> part of the discussion for the next hash. You can basically say "we're
> _already_ on the second hash, we just picked one that was so
> compatible with SHA1 that nobody even really noticed.

Warn users who try to compile with SHA1 instead of SHA1DC.
2024-12-28 09:52:42 +00:00
Edward Thomson
e536b2c50c cmake: enforce USE_SHA1 and USE_SHA256 validity 2024-10-22 11:45:58 +01:00
Edward Thomson
3d268285f9 sha: support FIPS-compliant OpenSSL for SHA1 2024-10-10 00:01:16 +01:00
Marcin Dabrowski
7f7dfe71cc Add OpenSSL-FIPS CMake flag
Usage of the deprecated 'SHA256_*' OpenSSL API in a FIPS compliant
environment results in OpenSSL's assertion failure with the following
description:
"OpenSSL internal error, assertion failed: Low level API call to
 digest SHA256 forbidden in FIPS mode!"

This commit adds a possibility to use the OpenSSL's 'EVP_MD*' API instead
of the deprecated 'SHA256_*' API, by extending the optional CMake flag
'USE_SHA256' with the new option called 'OpenSSL-FIPS'.
The new option is used to choose a hashing backend used by libgit2 to
calculate SHA256 hashes, in a similar way that currently existing
options like 'OpenSSL', 'OpenSSL-Dynamic', 'mbedTLS' etc do.

'OpenSSL-FIPS' is a fully opt-in option which is purposely not
interfering with the existing options, because, after running some
benchmarks, it's been discovered that using the 'EVP_MD*' API causes
hashing to be a bit slower in comparison to using the deprecated
'SHA256_*' API.

Another change introduced in this commit is the enhancement of the
Nightly workflow (nightly.yml) which will cause libgit2 to be
automatically built with '-DUSE_SHA256="OpenSSL-FIPS"' CMake flag,
on Linux, macOS and Windows.
2024-10-09 14:53:44 +02:00
Edward Thomson
f68f542eb6 http: introduce schannel streams for windows
Provide a stream interface for Schannel - the native crypto APIs - on
Windows. This allows Windows to use the same HTTP transport that all the
other platforms use, with its own native crypto.

Ultimately this allows us to deprecate WinHTTP and we need not add
support for our socket changes in two places (our HTTP stack and the
WinHTTP stack).
2023-03-21 09:09:48 +00:00
Edward Thomson
3bd9bb8d77 sha256: support dynamically loaded openssl 2022-04-04 13:29:19 -04:00
Edward Thomson
6a7d5d23c7 sha: support Win32 for SHA256
Adding SHA256 support prompted an overdue refactoring of some of the
unnecessary complexity around the CNG/CryptoAPI abstraction.
2022-03-23 08:39:19 -04:00
Edward Thomson
6b4a6faab3 sha: support OpenSSL for SHA256 2022-03-23 08:39:19 -04:00
Edward Thomson
b3e3fa10ea sha: support mbedTLS for SHA256 2022-03-23 08:39:19 -04:00
Edward Thomson
83c2778611 sha: support CommonCrypto for SHA256 2022-03-23 08:39:19 -04:00
Edward Thomson
b900981cf7 sha: add sha256 algorithm
Add support for a SHA256 hash algorithm, and add the "builtin" SHA256
hash engine (from RFC 6234).
2022-03-23 08:39:19 -04:00
Edward Thomson
8bc998f481 sha1: remove generic implementation
Remove the "generic" implementation; it should never be used; it only
existed for a no-dependencies configuration, and our bundled sha1dc
satisfies that requirement _and_ is correct.
2022-03-23 08:39:19 -04:00
Edward Thomson
c3b7ace9cf refactor: make util an object library
Instead of simply including the utility files directly, make them a
cmake object library for easy reusability between other projects within
libgit2.

Now the top-level `src` is responsible for platform selection, while the
next-level `libgit2` and `util` configurations are responsible for
identifying what objects they include.
2022-02-22 22:07:44 -05:00
Edward Thomson
2c154145a8 cmake: move sha1 source selection into CMakeLists.txt
The select hashes module selects the hash; the CMakeLists.txt selects
the files to implement it.
2021-11-14 07:25:41 -05:00
Edward Thomson
395b3dc403 cmake: refactor global variables
Update the global variables `LIBGIT2_OBJECTS` to
`LIBGIT2_DEPENDENCY_OBJECTS` for clarity and consistency.
2021-11-14 07:25:41 -05:00
Edward Thomson
c3fec45645 cmake: reformat modules
Apply the standard project cmake formatting to the modules.
2021-11-14 07:25:41 -05:00
Dmitry Lobanov
4c0ea9f06d cmake: select hashes umbrella variable has been removed.
Co-authored-by: Edward Thomson <ethomson@github.com>
2021-08-28 20:18:38 +03:00
Dmitry Lobanov
08b3ee2f83 cmake: select hashes missing umbrella header has been added. 2021-08-28 16:17:50 +03:00
Patrick Steinhardt
bc02bcd920 cmake: move modules into the "cmake/" top level dir
Our custom CMake module currently live in "cmake/Modules". As the
"cmake/" directory doesn't contain anything except the "Modules"
directory, it doesn't really make sense to have the additional
intermediate directory. So let's instead move the modules one level up
into the "cmake/" top level directory.
2020-06-01 14:06:20 +02:00