diff options
author | Jack Lloyd <[email protected]> | 2015-09-17 17:08:01 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-09-17 17:08:01 -0400 |
commit | e2e0f8f2b595122c1f8acb3b3a46501f96a2b218 (patch) | |
tree | af5e031cb1f83fae45d59fc05c05185de1138f9a /src/lib/mac | |
parent | d83ef010522373a6f8ed3876c812b18b55513103 (diff) |
Handle dependencies re static linking. GH #279
Previously we were hanging on the type destructors to pull in
the relevant objects. However that fails in many simple cases
where the object is never deleted.
For every type involved in the algo registry add static create
and providers functions to access the algo registry. Modify
lookup.h to be inline and call those functions, and move
a few to sub-headers (eg, get_pbkdf going to pbkdf.h). So
accessing the registry involves going through the same file
that handles the initialization, so there is no way to end up
with missing objs.
Diffstat (limited to 'src/lib/mac')
-rw-r--r-- | src/lib/mac/cbc_mac/cbc_mac.cpp | 1 | ||||
-rw-r--r-- | src/lib/mac/cmac/cmac.cpp | 1 | ||||
-rw-r--r-- | src/lib/mac/hmac/hmac.cpp | 1 | ||||
-rw-r--r-- | src/lib/mac/mac.cpp | 11 | ||||
-rw-r--r-- | src/lib/mac/mac.h | 13 | ||||
-rw-r--r-- | src/lib/mac/x919_mac/x919_mac.cpp | 1 |
6 files changed, 28 insertions, 0 deletions
diff --git a/src/lib/mac/cbc_mac/cbc_mac.cpp b/src/lib/mac/cbc_mac/cbc_mac.cpp index 29507f17b..70a7e4116 100644 --- a/src/lib/mac/cbc_mac/cbc_mac.cpp +++ b/src/lib/mac/cbc_mac/cbc_mac.cpp @@ -7,6 +7,7 @@ #include <botan/internal/mac_utils.h> #include <botan/cbc_mac.h> +#include <botan/lookup.h> namespace Botan { diff --git a/src/lib/mac/cmac/cmac.cpp b/src/lib/mac/cmac/cmac.cpp index 85c19c19f..f3f6c6296 100644 --- a/src/lib/mac/cmac/cmac.cpp +++ b/src/lib/mac/cmac/cmac.cpp @@ -7,6 +7,7 @@ #include <botan/internal/mac_utils.h> #include <botan/cmac.h> +#include <botan/lookup.h> namespace Botan { diff --git a/src/lib/mac/hmac/hmac.cpp b/src/lib/mac/hmac/hmac.cpp index 2cd512746..94f455c56 100644 --- a/src/lib/mac/hmac/hmac.cpp +++ b/src/lib/mac/hmac/hmac.cpp @@ -8,6 +8,7 @@ #include <botan/internal/mac_utils.h> #include <botan/hmac.h> +#include <botan/lookup.h> namespace Botan { diff --git a/src/lib/mac/mac.cpp b/src/lib/mac/mac.cpp index af59bd4c6..da94a1daf 100644 --- a/src/lib/mac/mac.cpp +++ b/src/lib/mac/mac.cpp @@ -35,6 +35,17 @@ namespace Botan { +std::unique_ptr<MessageAuthenticationCode> MessageAuthenticationCode::create(const std::string& algo_spec, + const std::string& provider) + { + return std::unique_ptr<MessageAuthenticationCode>(make_a<MessageAuthenticationCode>(algo_spec, provider)); + } + +std::vector<std::string> MessageAuthenticationCode::providers(const std::string& algo_spec) + { + return providers_of<MessageAuthenticationCode>(MessageAuthenticationCode::Spec(algo_spec)); + } + MessageAuthenticationCode::~MessageAuthenticationCode() {} /* diff --git a/src/lib/mac/mac.h b/src/lib/mac/mac.h index 28894bbcd..6f18fce19 100644 --- a/src/lib/mac/mac.h +++ b/src/lib/mac/mac.h @@ -24,6 +24,19 @@ class BOTAN_DLL MessageAuthenticationCode : public Buffered_Computation, public: typedef SCAN_Name Spec; + /** + * Create an instance based on a name + * Will return a null pointer if the algo/provider combination cannot + * be found. If providers is empty then best available is chosen. + */ + static std::unique_ptr<MessageAuthenticationCode> create(const std::string& algo_spec, + const std::string& provider = ""); + + /** + * Returns the list of available providers for this algorithm, empty if not available + */ + static std::vector<std::string> providers(const std::string& algo_spec); + virtual ~MessageAuthenticationCode(); /** diff --git a/src/lib/mac/x919_mac/x919_mac.cpp b/src/lib/mac/x919_mac/x919_mac.cpp index ce7c38ebb..a58b07248 100644 --- a/src/lib/mac/x919_mac/x919_mac.cpp +++ b/src/lib/mac/x919_mac/x919_mac.cpp @@ -7,6 +7,7 @@ #include <botan/internal/mac_utils.h> #include <botan/x919_mac.h> +#include <botan/lookup.h> namespace Botan { |