diff options
author | Jack Lloyd <[email protected]> | 2018-10-29 13:47:08 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-10-29 18:01:15 -0400 |
commit | 41e39cba057e5ed5eb9f078efbcf9cb576256282 (patch) | |
tree | 21e2a98ae50323435b780d1192e7b16c46562308 | |
parent | 759b45c63f0d28a738c5cb913109b6a2711ad1e7 (diff) |
Add VarMap::get_req_bin_list
-rw-r--r-- | src/tests/tests.cpp | 30 | ||||
-rw-r--r-- | 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<uint8_t> VarMap::get_req_bin( - const std::string& key) const +std::vector<std::vector<uint8_t>> 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<std::vector<uint8_t>> 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<uint8_t> 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<uint8_t> get_req_bin(const std::string& key) const; std::vector<uint8_t> get_opt_bin(const std::string& key) const; + std::vector<std::vector<uint8_t>> 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; |