From 783798ca424fe44b36bdec386da91da75e856cdd Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Wed, 28 Jun 2017 16:33:55 +0200 Subject: BearSSL: Initial support and hash tests BearSSL is an implementation of the SSL/TLS protocol in C aiming to be correct and secure, small and highly portable. Thus making it nicer to be included in a rather sparse bootloader. This commit adds support for BearSSL's hash routines only, with more stuff coming up in following commits. The goal is to be able to test BearSSL using Botan's extensive testsuite. --- src/lib/hash/hash.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/lib/hash/hash.cpp') diff --git a/src/lib/hash/hash.cpp b/src/lib/hash/hash.cpp index c8dd58a66..cd2b5ad7a 100644 --- a/src/lib/hash/hash.cpp +++ b/src/lib/hash/hash.cpp @@ -88,6 +88,10 @@ #include #endif +#if defined(BOTAN_HAS_BEARSSL) + #include +#endif + #if defined(BOTAN_HAS_OPENSSL) #include #endif @@ -97,6 +101,17 @@ namespace Botan { std::unique_ptr HashFunction::create(const std::string& algo_spec, const std::string& provider) { +#if defined(BOTAN_HAS_BEARSSL) + if(provider.empty() || provider == "bearssl") + { + if(auto hash = make_bearssl_hash(algo_spec)) + return hash; + + if(!provider.empty()) + return nullptr; + } +#endif + #if defined(BOTAN_HAS_OPENSSL) if(provider.empty() || provider == "openssl") { @@ -323,7 +338,7 @@ HashFunction::create_or_throw(const std::string& algo, std::vector HashFunction::providers(const std::string& algo_spec) { - return probe_providers_of(algo_spec, {"base", "openssl"}); + return probe_providers_of(algo_spec, {"base", "bearssl", "openssl"}); } } -- cgit v1.2.3