diff options
author | lloyd <[email protected]> | 2008-11-09 22:28:13 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-09 22:28:13 +0000 |
commit | 4a98fe659be80c8688e2022aa070456eb2688ad0 (patch) | |
tree | 40abf60342b37444bf475fac7319c20f898c1b1c /src/utils/scan_name.h | |
parent | 90ef5e309f5fa1772906d65bca7557ac5686114e (diff) |
Add a SCAN_Name class that encapsulates operations currently done repeatedly
all over the engine code.
Diffstat (limited to 'src/utils/scan_name.h')
-rw-r--r-- | src/utils/scan_name.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/utils/scan_name.h b/src/utils/scan_name.h new file mode 100644 index 000000000..37c9ffc1b --- /dev/null +++ b/src/utils/scan_name.h @@ -0,0 +1,55 @@ +/** +SCAN Name Abstraction +(C) 2008 Jack Lloyd +*/ + +#ifndef BOTAN_SCAN_NAME_H__ +#define BOTAN_SCAN_NAME_H__ + +#include <botan/types.h> +#include <string> +#include <vector> + +namespace Botan { + +/** +A class encapsulating a SCAN name (similar to JCE conventions) +http://www.users.zetnet.co.uk/hopwood/crypto/scan/ +*/ +class SCAN_Name + { + public: + /** + @param algo_spec A SCAN name + */ + SCAN_Name(const std::string& algo_spec); + + /** + @return the algorithm name + */ + std::string algo_name() const { return name[0]; } + + /** + @return the number of arguments + */ + u32bit arg_count() const { return name.size() - 1; } + + /** + @param i which argument + @return the ith argument + */ + std::string argument(u32bit i); + + /** + @param i which argument + @return the ith argument as a u32bit, or a default value + */ + u32bit argument_as_u32bit(u32bit i, u32bit def_value); + + private: + std::vector<std::string> name; + }; + +} + +#endif |