diff options
author | lloyd <[email protected]> | 2009-10-06 16:03:33 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-10-06 16:03:33 +0000 |
commit | c86253042f0dab70fcf15030b25fcbc1a00dde76 (patch) | |
tree | 27159084e5f56768eff838d61ce13c2930c37ed4 /src/libstate/scan_name.cpp | |
parent | f05bf5994ae8955501e2355b63ec35e575125374 (diff) |
Extensions to SCAN_Name for dealing with cipher mode names
Diffstat (limited to 'src/libstate/scan_name.cpp')
-rw-r--r-- | src/libstate/scan_name.cpp | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/src/libstate/scan_name.cpp b/src/libstate/scan_name.cpp index 88992d66e..13792720c 100644 --- a/src/libstate/scan_name.cpp +++ b/src/libstate/scan_name.cpp @@ -44,10 +44,50 @@ SCAN_Name::SCAN_Name(const std::string& algo_spec) { orig_algo_spec = algo_spec; - name = parse_and_deref_aliases(algo_spec); + try + { + name = parse_and_deref_aliases(algo_spec); + if(name.size() == 0) + throw Decoding_Error("Bad SCAN name " + algo_spec); + } + catch(Invalid_Algorithm_Name) + { + name.clear(); + } + + if(name.size() == 0 && algo_spec.find('/') != std::string::npos) + { + std::vector<std::string> algo_parts = split_on(algo_spec, '/'); + + name = parse_and_deref_aliases(algo_parts[0]); + if(name.size() == 0) + throw Decoding_Error("Bad SCAN name " + algo_spec); + + for(size_t i = 1; i != algo_parts.size(); ++i) + mode_str.push_back(algo_parts[i]); + } + } - if(name.size() == 0) - throw Decoding_Error("Bad SCAN name " + algo_spec); +std::string SCAN_Name::algo_name_and_args() const + { + std::string out; + + out = name[0]; + + if(arg_count()) + { + out += '('; + for(u32bit i = 0; i != arg_count(); ++i) + { + out += arg(i); + if(i != arg_count() - 1) + out += ','; + } + out += ')'; + + } + + return out; } std::string SCAN_Name::arg(u32bit i) const |