2010-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added sha-224, sha-384, sha-512 hash function support.
	* m4/openssl.m4
	* src/MessageDigest.cc
	* src/LibgcryptMessageDigestImpl.cc
	* src/LibsslMessageDigestImpl.cc
This commit is contained in:
Tatsuhiro Tsujikawa 2010-11-11 03:23:08 +00:00
parent 89f997ec0d
commit 1946b3341f
7 changed files with 78 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2010-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added sha-224, sha-384, sha-512 hash function support.
* m4/openssl.m4
* src/MessageDigest.cc
* src/LibgcryptMessageDigestImpl.cc
* src/LibsslMessageDigestImpl.cc
2010-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Replaced MessageDigestContext with MessageDigest. Cleaned up

View File

@ -123,9 +123,18 @@
/* Define to 1 if you have the `EVP_DigestInit_ex' function. */
#undef HAVE_EVP_DIGESTINIT_EX
/* Define to 1 if you have the `EVP_sha224' function. */
#undef HAVE_EVP_SHA224
/* Define to 1 if you have the `EVP_sha256' function. */
#undef HAVE_EVP_SHA256
/* Define to 1 if you have the `EVP_sha384' function. */
#undef HAVE_EVP_SHA384
/* Define to 1 if you have the `EVP_sha512' function. */
#undef HAVE_EVP_SHA512
/* Define to 1 if you have the `fallocate' function. */
#undef HAVE_FALLOCATE

36
configure vendored
View File

@ -6940,6 +6940,18 @@ $as_echo "#define HAVE_OLD_LIBSSL 1" >>confdefs.h
fi
# search for sha224 support
for ac_func in EVP_sha224
do :
ac_fn_cxx_check_func "$LINENO" "EVP_sha224" "ac_cv_func_EVP_sha224"
if test "x$ac_cv_func_EVP_sha224" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_EVP_SHA224 1
_ACEOF
fi
done
# search for sha256 support
for ac_func in EVP_sha256
do :
@ -6949,6 +6961,30 @@ if test "x$ac_cv_func_EVP_sha256" = x""yes; then :
#define HAVE_EVP_SHA256 1
_ACEOF
fi
done
# search for sha384 support
for ac_func in EVP_sha384
do :
ac_fn_cxx_check_func "$LINENO" "EVP_sha384" "ac_cv_func_EVP_sha384"
if test "x$ac_cv_func_EVP_sha384" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_EVP_SHA384 1
_ACEOF
fi
done
# search for sha512 support
for ac_func in EVP_sha512
do :
ac_fn_cxx_check_func "$LINENO" "EVP_sha512" "ac_cv_func_EVP_sha512"
if test "x$ac_cv_func_EVP_sha512" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_EVP_SHA512 1
_ACEOF
fi
done

View File

@ -57,8 +57,14 @@ if test "x$have_openssl" = "xyes"; then
fi
AC_SUBST(OPENSSL_LIBS)
AC_SUBST(OPENSSL_CFLAGS)
# search for sha224 support
AC_CHECK_FUNCS([EVP_sha224])
# search for sha256 support
AC_CHECK_FUNCS([EVP_sha256])
# search for sha384 support
AC_CHECK_FUNCS([EVP_sha384])
# search for sha512 support
AC_CHECK_FUNCS([EVP_sha512])
fi
LIBS=$LIBS_save

View File

@ -62,7 +62,10 @@ typedef FindHashFunc<int> CFindHashFunc;
namespace {
CHashFuncEntry hashFuncs[] = {
CHashFuncEntry("sha-1", GCRY_MD_SHA1),
CHashFuncEntry("sha-224", GCRY_MD_SHA224),
CHashFuncEntry("sha-256", GCRY_MD_SHA256),
CHashFuncEntry("sha-384", GCRY_MD_SHA384),
CHashFuncEntry("sha-512", GCRY_MD_SHA512),
CHashFuncEntry("md5", GCRY_MD_MD5)
};
} // namespace

View File

@ -64,9 +64,18 @@ typedef FindHashFunc<const EVP_MD*> CFindHashFunc;
namespace {
CHashFuncEntry hashFuncs[] = {
CHashFuncEntry("sha-1", EVP_sha1()),
#ifdef HAVE_EVP_SHA224
CHashFuncEntry("sha-224", EVP_sha224()),
#endif // HAVE_EVP_SHA224
#ifdef HAVE_EVP_SHA256
CHashFuncEntry("sha-256", EVP_sha256()),
#endif // HAVE_EVP_SHA256
#ifdef HAVE_EVP_SHA384
CHashFuncEntry("sha-384", EVP_sha384()),
#endif // HAVE_EVP_SHA384
#ifdef HAVE_EVP_SHA512
CHashFuncEntry("sha-512", EVP_sha512()),
#endif // HAVE_EVP_SHA512
CHashFuncEntry("md5", EVP_md5())
};
} // namespace

View File

@ -51,7 +51,10 @@ struct HashTypeEntry {
namespace {
HashTypeEntry hashTypes[] = {
HashTypeEntry("sha-1", 1),
HashTypeEntry("sha-256", 2),
HashTypeEntry("sha-224", 2),
HashTypeEntry("sha-256", 3),
HashTypeEntry("sha-384", 4),
HashTypeEntry("sha-512", 5),
HashTypeEntry("md5", 0)
};
} // namespace aria2
@ -137,6 +140,9 @@ bool MessageDigest::isValidHash
std::string MessageDigest::getCanonicalHashType(const std::string& hashType)
{
// This is really backward compatibility for Metalink3. aria2 only
// supported sha-1, sha-256 and md5 at Metalink3 era. So we don't
// add alias for sha-224, sha-384 and sha-512.
if("sha1" == hashType) {
return "sha-1";
} else if("sha256" == hashType) {