aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli/hash.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-12-19 15:36:40 -0500
committerJack Lloyd <[email protected]>2015-12-19 15:36:40 -0500
commitb48e6fb097c62bb246629ee7a182c57e497e4130 (patch)
tree0cb8ea2d05a89f5e90467f323ae56268d4d3480e /src/cli/hash.cpp
parentd774a9edc46ffcebb28205a678058f083ea75c28 (diff)
CLI rewrite
The command line tools' origin as a collection of examples and test programs glued together led to some unfortunate problems; lots of hardcoded values, missing parameters, and obsolete crypto. Adds a small library for writing command line programs of the sort needed here (cli.h), which cuts the length of many of the commands in half and makes commands more pleasant to write and extend. Generalizes a lot of the commands also, eg previously only signing/verification with DSA/SHA-1 was included! Removes the fuzzer entry point since that's fairly useless outside of an instrumented build. Removes the in-library API for benchmarking.
Diffstat (limited to 'src/cli/hash.cpp')
-rw-r--r--src/cli/hash.cpp63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/cli/hash.cpp b/src/cli/hash.cpp
deleted file mode 100644
index 9dd07d488..000000000
--- a/src/cli/hash.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-* (C) 2009 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#include "apps.h"
-
-#if defined(BOTAN_HAS_CODEC_FILTERS)
-
-#include <botan/filters.h>
-#include <iostream>
-#include <fstream>
-
-using namespace Botan;
-
-namespace {
-
-int hash(const std::vector<std::string> &args)
- {
- if(args.size() < 3)
- {
- std::cout << "Usage: " << args[0] << " algorithm filename [filename ...]" << std::endl;
- return 1;
- }
-
- std::string hash = args[1];
- /* a couple of special cases, kind of a crock */
- if(hash == "sha1") hash = "SHA-1";
- if(hash == "md5") hash = "MD5";
-
- try {
- Pipe pipe(new Hash_Filter(hash), new Hex_Encoder);
-
- int skipped = 0;
- for(int j = 2; j < args.size(); j++)
- {
- std::ifstream file(args[j], std::ios::binary);
- if(!file)
- {
- std::cout << "ERROR: could not open " << args[j] << std::endl;
- skipped++;
- continue;
- }
- pipe.start_msg();
- file >> pipe;
- pipe.end_msg();
- pipe.set_default_msg(j-2-skipped);
- std::cout << pipe << " " << args[j] << std::endl;
- }
- }
- catch(std::exception& e)
- {
- std::cout << "Exception caught: " << e.what() << std::endl;
- }
- return 0;
- }
-
-REGISTER_APP(hash);
-
-}
-
-#endif // BOTAN_HAS_CODEC_FILTERS