diff options
author | Jack Lloyd <[email protected]> | 2018-09-04 19:30:16 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-09-04 19:30:16 -0400 |
commit | 3b336f2a80053d472380b29aab06ad0acb66d3f1 (patch) | |
tree | 04ab9a62e4d06095376faa6f983bda1627cb2f9a /src/lib/hash/hash.cpp | |
parent | ad2cad62e0fcd186d489e56a136e376c0fa3a8f0 (diff) | |
parent | c81c5281eef4bc467cc1e101bd99438198b703c7 (diff) |
Merge GH #1667 Add hashing with CommonCrypto
Diffstat (limited to 'src/lib/hash/hash.cpp')
-rw-r--r-- | src/lib/hash/hash.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/lib/hash/hash.cpp b/src/lib/hash/hash.cpp index e30d00080..ad1a1bf0c 100644 --- a/src/lib/hash/hash.cpp +++ b/src/lib/hash/hash.cpp @@ -101,11 +101,27 @@ #include <botan/internal/openssl.h> #endif +#if defined(BOTAN_HAS_COMMONCRYPTO) + #include <botan/internal/commoncrypto.h> +#endif + namespace Botan { std::unique_ptr<HashFunction> HashFunction::create(const std::string& algo_spec, const std::string& provider) { + +#if defined(BOTAN_HAS_COMMONCRYPTO) + if(provider.empty() || provider == "commoncrypto") + { + if(auto hash = make_commoncrypto_hash(algo_spec)) + return hash; + + if(!provider.empty()) + return nullptr; + } +#endif + #if defined(BOTAN_HAS_OPENSSL) if(provider.empty() || provider == "openssl") { @@ -128,8 +144,6 @@ std::unique_ptr<HashFunction> HashFunction::create(const std::string& algo_spec, } #endif - // TODO: CommonCrypto hashes - if(provider.empty() == false && provider != "base") return nullptr; // unknown provider @@ -354,7 +368,7 @@ HashFunction::create_or_throw(const std::string& algo, std::vector<std::string> HashFunction::providers(const std::string& algo_spec) { - return probe_providers_of<HashFunction>(algo_spec, {"base", "bearssl", "openssl"}); + return probe_providers_of<HashFunction>(algo_spec, {"base", "bearssl", "openssl", "commoncrypto"}); } } |