aboutsummaryrefslogtreecommitdiffstats
path: root/misc/cms/tests/cms_enc.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-06-03 06:10:36 +0000
committerlloyd <[email protected]>2006-06-03 06:10:36 +0000
commit25aaeee23fd952525eadabea43b1c4e8a2cf1b02 (patch)
treef39ce2525b73734e289b4b591093c6b2436b7007 /misc/cms/tests/cms_enc.cpp
parent6f75c2fe6e536c0192f3acb00c84edbc762127da (diff)
Add the (very old) CMS | S/MIME support code to misc/cms
Diffstat (limited to 'misc/cms/tests/cms_enc.cpp')
-rw-r--r--misc/cms/tests/cms_enc.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/misc/cms/tests/cms_enc.cpp b/misc/cms/tests/cms_enc.cpp
new file mode 100644
index 000000000..0319925d8
--- /dev/null
+++ b/misc/cms/tests/cms_enc.cpp
@@ -0,0 +1,46 @@
+#include <botan/cms_enc.h>
+using namespace Botan;
+
+#include <iostream>
+#include <fstream>
+
+int main()
+ {
+ LibraryInitializer init;
+
+ try {
+ PKCS8_PrivateKey* mykey = PKCS8::load_key("mykey.pem", "cut");
+
+ X509_Certificate mycert("mycert.pem");
+ X509_Certificate mycert2("mycert2.pem");
+ X509_Certificate yourcert("yourcert.pem");
+ X509_Certificate cacert("cacert.pem");
+ X509_Certificate int_ca("int_ca.pem");
+
+ X509_Store store;
+ store.add_cert(mycert);
+ store.add_cert(mycert2);
+ store.add_cert(yourcert);
+ store.add_cert(int_ca);
+ store.add_cert(cacert, true);
+
+ const std::string msg = "prioncorp: we don't toy\n";
+
+ CMS_Encoder encoder(msg);
+
+ encoder.compress("Zlib");
+ encoder.digest();
+ encoder.encrypt(mycert);
+ encoder.sign(store, *mykey);
+
+ SecureVector<byte> raw = encoder.get_contents();
+ std::ofstream out("out.der");
+
+ out.write((const char*)raw.ptr(), raw.size());
+ }
+ catch(std::exception& e)
+ {
+ std::cerr << e.what() << std::endl;
+ }
+ return 0;
+ }