diff options
author | Damien Miller <djm@mindrot.org> | 2015-01-15 02:21:31 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-01-15 02:28:36 +1100 |
commit | 72ef7c148c42db7d5632a29f137f8b87b579f2d9 (patch) | |
tree | 47954a387f4260cc8b1e0ff33bbbaf22fd6f11fc /openbsd-compat/sha2.c | |
parent | 4f38c61c68ae7e3f9ee4b3c38bc86cd39f65ece9 (diff) |
support --without-openssl at configure time
Disables and removes dependency on OpenSSL. Many features don't
work and the set of crypto options is greatly restricted. This
will only work on system with native arc4random or /dev/urandom.
Considered highly experimental for now.
Diffstat (limited to 'openbsd-compat/sha2.c')
-rw-r--r-- | openbsd-compat/sha2.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/openbsd-compat/sha2.c b/openbsd-compat/sha2.c index f5bf74d1f..737935d46 100644 --- a/openbsd-compat/sha2.c +++ b/openbsd-compat/sha2.c | |||
@@ -38,13 +38,18 @@ | |||
38 | 38 | ||
39 | #include "includes.h" | 39 | #include "includes.h" |
40 | 40 | ||
41 | #include <openssl/opensslv.h> | 41 | #ifdef WITH_OPENSSL |
42 | # include <openssl/opensslv.h> | ||
43 | # if !defined(HAVE_EVP_SHA256) && (OPENSSL_VERSION_NUMBER >= 0x00907000L) | ||
44 | # define _NEED_SHA2 1 | ||
45 | # endif | ||
46 | #else | ||
47 | # define _NEED_SHA2 1 | ||
48 | #endif | ||
49 | |||
50 | #if defined(_NEED_SHA2) && !defined(HAVE_SHA256_UPDATE) | ||
42 | 51 | ||
43 | #if !defined(HAVE_EVP_SHA256) && !defined(HAVE_SHA256_UPDATE) && \ | ||
44 | (OPENSSL_VERSION_NUMBER >= 0x00907000L) | ||
45 | #include <sys/types.h> | ||
46 | #include <string.h> | 52 | #include <string.h> |
47 | #include "sha2.h" | ||
48 | 53 | ||
49 | /* | 54 | /* |
50 | * UNROLLED TRANSFORM LOOP NOTE: | 55 | * UNROLLED TRANSFORM LOOP NOTE: |
@@ -838,7 +843,6 @@ SHA512_Final(u_int8_t digest[SHA512_DIGEST_LENGTH], SHA512_CTX *context) | |||
838 | } | 843 | } |
839 | 844 | ||
840 | 845 | ||
841 | #if 0 | ||
842 | /*** SHA-384: *********************************************************/ | 846 | /*** SHA-384: *********************************************************/ |
843 | void | 847 | void |
844 | SHA384_Init(SHA384_CTX *context) | 848 | SHA384_Init(SHA384_CTX *context) |
@@ -851,9 +855,29 @@ SHA384_Init(SHA384_CTX *context) | |||
851 | context->bitcount[0] = context->bitcount[1] = 0; | 855 | context->bitcount[0] = context->bitcount[1] = 0; |
852 | } | 856 | } |
853 | 857 | ||
858 | #if 0 | ||
854 | __weak_alias(SHA384_Transform, SHA512_Transform); | 859 | __weak_alias(SHA384_Transform, SHA512_Transform); |
855 | __weak_alias(SHA384_Update, SHA512_Update); | 860 | __weak_alias(SHA384_Update, SHA512_Update); |
856 | __weak_alias(SHA384_Pad, SHA512_Pad); | 861 | __weak_alias(SHA384_Pad, SHA512_Pad); |
862 | #endif | ||
863 | |||
864 | void | ||
865 | SHA384_Transform(u_int64_t state[8], const u_int8_t data[SHA512_BLOCK_LENGTH]) | ||
866 | { | ||
867 | return SHA512_Transform(state, data); | ||
868 | } | ||
869 | |||
870 | void | ||
871 | SHA384_Update(SHA512_CTX *context, const u_int8_t *data, size_t len) | ||
872 | { | ||
873 | SHA512_Update(context, data, len); | ||
874 | } | ||
875 | |||
876 | void | ||
877 | SHA384_Pad(SHA512_CTX *context) | ||
878 | { | ||
879 | SHA512_Pad(context); | ||
880 | } | ||
857 | 881 | ||
858 | void | 882 | void |
859 | SHA384_Final(u_int8_t digest[SHA384_DIGEST_LENGTH], SHA384_CTX *context) | 883 | SHA384_Final(u_int8_t digest[SHA384_DIGEST_LENGTH], SHA384_CTX *context) |
@@ -876,7 +900,5 @@ SHA384_Final(u_int8_t digest[SHA384_DIGEST_LENGTH], SHA384_CTX *context) | |||
876 | /* Zero out state data */ | 900 | /* Zero out state data */ |
877 | memset(context, 0, sizeof(*context)); | 901 | memset(context, 0, sizeof(*context)); |
878 | } | 902 | } |
879 | #endif | ||
880 | 903 | ||
881 | #endif /* !defined(HAVE_EVP_SHA256) && !defined(HAVE_SHA256_UPDATE) && \ | 904 | #endif /* defined(_NEED_SHA2) && !defined(HAVE_SHA256_UPDATE) */ |
882 | (OPENSSL_VERSION_NUMBER >= 0x00907000L) */ | ||