aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/hash/hash.cpp
diff options
context:
space:
mode:
authorPatrick Wildt <[email protected]>2017-06-28 16:33:55 +0200
committerPatrick Wildt <[email protected]>2017-07-05 11:05:49 +0200
commit783798ca424fe44b36bdec386da91da75e856cdd (patch)
tree5e4604dc849622960a561ab0cee99b646cc577dd /src/lib/hash/hash.cpp
parent38fe6d3ab3e8a4be2becd5fd0b8c7bb4a8f1e192 (diff)
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.
Diffstat (limited to 'src/lib/hash/hash.cpp')
-rw-r--r--src/lib/hash/hash.cpp17
1 files changed, 16 insertions, 1 deletions
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 <botan/blake2b.h>
#endif
+#if defined(BOTAN_HAS_BEARSSL)
+ #include <botan/internal/bearssl.h>
+#endif
+
#if defined(BOTAN_HAS_OPENSSL)
#include <botan/internal/openssl.h>
#endif
@@ -97,6 +101,17 @@ namespace Botan {
std::unique_ptr<HashFunction> 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<std::string> HashFunction::providers(const std::string& algo_spec)
{
- return probe_providers_of<HashFunction>(algo_spec, {"base", "openssl"});
+ return probe_providers_of<HashFunction>(algo_spec, {"base", "bearssl", "openssl"});
}
}