aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmd/dsa_ver.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-11-12 01:23:55 +0000
committerlloyd <[email protected]>2014-11-12 01:23:55 +0000
commit8b0cbccc7b11e545ed27bc6d7bda04b5cf632e60 (patch)
tree7ea9368d6ccaa85337a63b55e8bd15efa46fd357 /src/cmd/dsa_ver.cpp
parent67161b91163afad417f9483cb557b26c5f5f4bc0 (diff)
Command line prog cleanup
Diffstat (limited to 'src/cmd/dsa_ver.cpp')
-rw-r--r--src/cmd/dsa_ver.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/cmd/dsa_ver.cpp b/src/cmd/dsa_ver.cpp
index a5d0ca271..dddf34dbf 100644
--- a/src/cmd/dsa_ver.cpp
+++ b/src/cmd/dsa_ver.cpp
@@ -1,28 +1,17 @@
#include "apps.h"
-#include <iostream>
-#include <iomanip>
-#include <fstream>
-#include <cstdlib>
-#include <string>
-#include <memory>
+#if defined(BOTAN_HAS_DSA)
+
+#include <fstream>
#include <botan/pubkey.h>
#include <botan/dsa.h>
-#include <botan/b64_filt.h>
+#include <botan/base64.h>
+
using namespace Botan;
namespace {
-secure_vector<byte> b64_decode(const std::string& in)
- {
- Pipe pipe(new Base64_Decoder);
- pipe.process_msg(in);
- return pipe.read_all();
- }
-
-}
-
-int dsa_verify_main(int argc, char* argv[])
+int dsa_verify(int argc, char* argv[])
{
if(argc != 4)
{
@@ -59,7 +48,7 @@ int dsa_verify_main(int argc, char* argv[])
return 1;
}
- secure_vector<byte> sig = b64_decode(sigstr);
+ secure_vector<byte> sig = base64_decode(sigstr);
PK_Verifier ver(*dsakey, "EMSA1(SHA-1)");
@@ -71,14 +60,26 @@ int dsa_verify_main(int argc, char* argv[])
const bool ok = ver.check_signature(sig);
if(ok)
+ {
std::cout << "Signature verified\n";
+ return 0;
+ }
else
+ {
std::cout << "Signature did NOT verify\n";
+ return 1;
+ }
}
catch(std::exception& e)
{
std::cout << "Exception caught: " << e.what() << std::endl;
- return 1;
+ return 2;
}
- return 0;
}
+
+REGISTER_APP(dsa_verify);
+
+}
+
+#endif
+