From 41e39cba057e5ed5eb9f078efbcf9cb576256282 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 29 Oct 2018 13:47:08 -0400 Subject: Add VarMap::get_req_bin_list --- src/tests/tests.cpp | 30 ++++++++++++++++++++++++++++-- src/tests/tests.h | 2 ++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index 6a1148474..d26ea7b68 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -626,8 +626,34 @@ std::string Test::random_password() return Botan::hex_encode(Test::rng().random_vec(len)); } -std::vector VarMap::get_req_bin( - const std::string& key) const +std::vector> VarMap::get_req_bin_list(const std::string& key) const + { + auto i = m_vars.find(key); + if(i == m_vars.end()) + { + throw Test_Error("Test missing variable " + key); + } + + std::vector> bin_list; + + for(auto&& part : Botan::split_on(i->second, ',')) + { + try + { + bin_list.push_back(Botan::hex_decode(part)); + } + catch(std::exception& e) + { + std::ostringstream oss; + oss << "Bad input '" << part << "'" << " in binary list key " << key << " - " << e.what(); + throw Test_Error(oss.str()); + } + } + + return bin_list; + } + +std::vector VarMap::get_req_bin(const std::string& key) const { auto i = m_vars.find(key); if(i == m_vars.end()) diff --git a/src/tests/tests.h b/src/tests/tests.h index 8b9bc7d0a..2d23f19b5 100644 --- a/src/tests/tests.h +++ b/src/tests/tests.h @@ -528,6 +528,8 @@ class VarMap std::vector get_req_bin(const std::string& key) const; std::vector get_opt_bin(const std::string& key) const; + std::vector> get_req_bin_list(const std::string& key) const; + #if defined(BOTAN_HAS_BIGINT) Botan::BigInt get_req_bn(const std::string& key) const; Botan::BigInt get_opt_bn(const std::string& key, const Botan::BigInt& def_value) const; -- cgit v1.2.3