aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmd/pkcs10.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-01-10 00:08:13 +0000
committerlloyd <[email protected]>2014-01-10 00:08:13 +0000
commit57789bdfc55061002b2727d0b32587612829a37c (patch)
tree99f36631b4ec50c5187a1b0a7c256b99182373ad /src/cmd/pkcs10.cpp
parent94968c917407a63d888fd3eb4d02491f60de6ebc (diff)
Split up test vectors into per-algo files and app into botan-test for
the tests and botan for everything else.
Diffstat (limited to 'src/cmd/pkcs10.cpp')
-rw-r--r--src/cmd/pkcs10.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/cmd/pkcs10.cpp b/src/cmd/pkcs10.cpp
new file mode 100644
index 000000000..cb1d44436
--- /dev/null
+++ b/src/cmd/pkcs10.cpp
@@ -0,0 +1,48 @@
+#include "apps.h"
+#include <botan/x509self.h>
+#include <botan/rsa.h>
+#include <botan/dsa.h>
+using namespace Botan;
+
+#include <iostream>
+#include <fstream>
+#include <memory>
+
+int pkcs10_main(int argc, char* argv[])
+ {
+ if(argc != 6)
+ {
+ std::cout << "Usage: " << argv[0]
+ << " passphrase name country_code organization email" << std::endl;
+ return 1;
+ }
+
+ try
+ {
+ AutoSeeded_RNG rng;
+
+ RSA_PrivateKey priv_key(rng, 1024);
+
+ std::ofstream key_file("private.pem");
+ key_file << PKCS8::PEM_encode(priv_key, rng, argv[1]);
+
+ X509_Cert_Options opts;
+
+ opts.common_name = argv[2];
+ opts.country = argv[3];
+ opts.organization = argv[4];
+ opts.email = argv[5];
+
+ PKCS10_Request req = X509::create_cert_req(opts, priv_key,
+ "SHA-256", rng);
+
+ std::ofstream req_file("req.pem");
+ req_file << req.PEM_encode();
+ }
+ catch(std::exception& e)
+ {
+ std::cout << e.what() << std::endl;
+ return 1;
+ }
+ return 0;
+ }