diff options
author | lloyd <[email protected]> | 2008-11-10 19:39:38 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-10 19:39:38 +0000 |
commit | 25ba52f32245a1624cbf5dcd3ca748b7f09d9ab2 (patch) | |
tree | 97c774f09e6959f1cba977661867cb7998f63637 /src | |
parent | ce57f888fdea3b136197cd66303b4ab25733c3a3 (diff) |
Fix parsing of nested + aliased names like TLS.Digest.0 in SCAN_Name
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/scan_name.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
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 <botan/libstate.h> #include <stdexcept> +#include <iostream> + namespace Botan { +namespace { + +std::vector<std::string> +parse_and_deref_aliases(const std::string& algo_spec) + { + std::vector<std::string> parts = parse_algorithm_name(algo_spec); + std::vector<std::string> 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<std::string> 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) { |