From 25ba52f32245a1624cbf5dcd3ca748b7f09d9ab2 Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 10 Nov 2008 19:39:38 +0000 Subject: Fix parsing of nested + aliased names like TLS.Digest.0 in SCAN_Name --- src/utils/scan_name.cpp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'src/utils') diff --git a/src/utils/scan_name.cpp b/src/utils/scan_name.cpp index 4949a8ee8..f0df99bde 100644 --- a/src/utils/scan_name.cpp +++ b/src/utils/scan_name.cpp @@ -8,17 +8,45 @@ SCAN Name Abstraction #include #include +#include + namespace Botan { +namespace { + +std::vector +parse_and_deref_aliases(const std::string& algo_spec) + { + std::vector parts = parse_algorithm_name(algo_spec); + std::vector out; + + for(size_t i = 0; i != parts.size(); ++i) + { + std::string part_i = global_state().deref_alias(parts[i]); + + if(i == 0 && part_i.find_first_of(",()") != std::string::npos) + { + std::vector parts_i = parse_and_deref_aliases(part_i); + + for(size_t j = 0; j != parts_i.size(); ++j) + out.push_back(parts_i[j]); + } + else + out.push_back(part_i); + } + + return out; + } + +} + SCAN_Name::SCAN_Name(const std::string& algo_spec, const std::string& prov_names) { orig_algo_spec = algo_spec; orig_providers = prov_names; - name = parse_algorithm_name(algo_spec); - for(u32bit i = 0; i != name.size(); ++i) - name[i] = global_state().deref_alias(name[i]); + name = parse_and_deref_aliases(algo_spec); if(prov_names.find(',') != std::string::npos) { -- cgit v1.2.3