CHECK_SYMBOL_EXISTS(SHA256_Init "sha2.h" HAVE_SHA256_INIT)
CHECK_SYMBOL_EXISTS(SHA384_Init "sha2.h" HAVE_SHA384_INIT)
CHECK_SYMBOL_EXISTS(SHA512_Init "sha2.h" HAVE_SHA512_INIT)
-ENDIF(HAVE_SHA2_H)
+ELSEIF(HAVE_OPENSSL_SHA_H)
+ CHECK_SYMBOL_EXISTS(SHA256_Init "openssl/sha.h" HAVE_OPENSSL_SHA256_INIT)
+ CHECK_SYMBOL_EXISTS(SHA384_Init "openssl/sha.h" HAVE_OPENSSL_SHA384_INIT)
+ CHECK_SYMBOL_EXISTS(SHA512_Init "openssl/sha.h" HAVE_OPENSSL_SHA512_INIT)
+ENDIF()
SET(CMAKE_REQUIRED_LIBRARIES "")
#
/* Define to 1 if you have the <openssl/sha.h> header file. */
#cmakedefine HAVE_OPENSSL_SHA_H 1
+/* Define to 1 if your openssl has the `SHA256_Init' function. */
+#cmakedefine HAVE_OPENSSL_SHA256_INIT 1
+
+/* Define to 1 if your openssl has the `SHA384_Init' function. */
+#cmakedefine HAVE_OPENSSL_SHA384_INIT 1
+
+/* Define to 1 if your openssl has the `SHA512_Init' function. */
+#cmakedefine HAVE_OPENSSL_SHA512_INIT 1
+
/* Define to 1 if you have the <paths.h> header file. */
#cmakedefine HAVE_PATHS_H 1
test "$ac_cv_func_SHA384_Init" != "yes" ||
test "$ac_cv_func_SHA512_Init" != "yes"; then
AC_CHECK_HEADERS([openssl/sha.h])
+ # TODO: Does AC_SEARCH_LIBS support more than one function at once?
+ # This appears to always fail.
AC_SEARCH_LIBS([SHA256_Init SHA384_Init SHA512_Init], [crypto])
+
+ # TODO: Actually test for these. Previously our C code did not
+ # test for these at all and just assumed availability. Now that
+ # the C code tests these macros we preserve previous behavior
+ # for the autotools build by hard-coding availability.
+ if test "$ac_cv_header_openssl_sha_h" = "yes"; then
+ AC_DEFINE(HAVE_OPENSSL_SHA256_INIT, 1, [Define to 1 if your openssl has the `SHA256_Init' function.])
+ AC_DEFINE(HAVE_OPENSSL_SHA384_INIT, 1, [Define to 1 if your openssl has the `SHA384_Init' function.])
+ AC_DEFINE(HAVE_OPENSSL_SHA512_INIT, 1, [Define to 1 if your openssl has the `SHA512_Init' function.])
+ fi
fi
fi
fi
# define archive_sha256_init(ctx) SHA256Init(ctx)
# define archive_sha256_final(ctx, buf) SHA256Final(buf, ctx)
# define archive_sha256_update(ctx, buf, n) SHA256Update(ctx, buf, n)
-#elif defined(HAVE_OPENSSL_SHA_H)
+#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA256_INIT)
# include <openssl/sha.h>
# define ARCHIVE_HAS_SHA256
typedef SHA256_CTX archive_sha256_ctx;
# define archive_sha384_init(ctx) SHA384Init(ctx)
# define archive_sha384_final(ctx, buf) SHA384Final(buf, ctx)
# define archive_sha384_update(ctx, buf, n) SHA384Update(ctx, buf, n)
-#elif defined(HAVE_OPENSSL_SHA_H)
+#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA384_INIT)
# include <openssl/sha.h>
# define ARCHIVE_HAS_SHA384
typedef SHA512_CTX archive_sha384_ctx;
# define archive_sha512_init(ctx) SHA512Init(ctx)
# define archive_sha512_final(ctx, buf) SHA512Final(buf, ctx)
# define archive_sha512_update(ctx, buf, n) SHA512Update(ctx, buf, n)
-#elif defined(HAVE_OPENSSL_SHA_H)
+#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA512_INIT)
# include <openssl/sha.h>
# define ARCHIVE_HAS_SHA512
typedef SHA512_CTX archive_sha512_ctx;