aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-08-04 16:51:00 -0400
committerJack Lloyd <[email protected]>2019-08-04 16:51:00 -0400
commite0082fa9f0ddb40170987d68424a2e10685454d8 (patch)
tree6febca5b4981ebb5179334c6a5a124cc4ddfb951
parentc4ee3ce67906c1e3aa2f03079c32c7687486ad2c (diff)
Update padding code
-rwxr-xr-xsrc/scripts/oids.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/scripts/oids.py b/src/scripts/oids.py
index 5e8368980..a4e40f074 100755
--- a/src/scripts/oids.py
+++ b/src/scripts/oids.py
@@ -219,30 +219,36 @@ def format_pads_as_map(sig_dict):
*/
#include <botan/internal/padding.h>
-#include <map>
+#include <unordered_map>
#include <vector>
#include <string>
#include <algorithm>
namespace Botan {
-const std::map<const std::string, std::vector<std::string>> allowed_signature_paddings =
+namespace {
+
+const std::unordered_map<const std::string, std::vector<std::string>> allowed_signature_paddings =
{
%s
};
-__attribute__((visibility("default"))) const std::vector<std::string> get_sig_paddings(const std::string algo)
+}
+
+const std::vector<std::string> get_sig_paddings(const std::string algo)
{
- if(allowed_signature_paddings.count(algo) > 0)
- return allowed_signature_paddings.at(algo);
+ auto i = allowed_signature_paddings.find(algo);
+ if(i != allowed_signature_paddings.end())
+ return i->second;
return {};
}
bool sig_algo_and_pad_ok(const std::string algo, std::string padding)
{
- std::vector<std::string> pads = get_sig_paddings(algo);
+ const std::vector<std::string> pads = get_sig_paddings(algo);
return std::find(pads.begin(), pads.end(), padding) != pads.end();
}
+
}
""" % (sys.argv[0], datetime.date.today().strftime("%Y-%m-%d"),
format_set_map(sig_dict))
@@ -321,6 +327,8 @@ def main(args = None):
print(format_dn_ub_as_map(dn_ub,oid2str))
elif args[1] == "pads":
print(format_pads_as_map(sig2pads))
+ else:
+ print("Unknown command")
return 0