aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/cms_enc.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-10-08 03:15:34 +0000
committerlloyd <[email protected]>2008-10-08 03:15:34 +0000
commit8343194ea16297eb3e51627eb3f35c529850c6f8 (patch)
tree22aeac286d2cbbdbe8790b08e4187d369f3c4efb /doc/examples/cms_enc.cpp
parentbe5e48619a63559ad777396d69cc8cc95ef0af15 (diff)
Update examples for recent API changes
Diffstat (limited to 'doc/examples/cms_enc.cpp')
-rw-r--r--doc/examples/cms_enc.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/doc/examples/cms_enc.cpp b/doc/examples/cms_enc.cpp
index 0319925d8..50babc650 100644
--- a/doc/examples/cms_enc.cpp
+++ b/doc/examples/cms_enc.cpp
@@ -1,15 +1,16 @@
+#include <botan/botan.h>
#include <botan/cms_enc.h>
using namespace Botan;
#include <iostream>
#include <fstream>
+#include <memory>
int main()
{
LibraryInitializer init;
try {
- PKCS8_PrivateKey* mykey = PKCS8::load_key("mykey.pem", "cut");
X509_Certificate mycert("mycert.pem");
X509_Certificate mycert2("mycert2.pem");
@@ -17,6 +18,9 @@ int main()
X509_Certificate cacert("cacert.pem");
X509_Certificate int_ca("int_ca.pem");
+ std::auto_ptr<RandomNumberGenerator> rng(
+ RandomNumberGenerator::make_rng());
+
X509_Store store;
store.add_cert(mycert);
store.add_cert(mycert2);
@@ -30,13 +34,17 @@ int main()
encoder.compress("Zlib");
encoder.digest();
- encoder.encrypt(mycert);
+ encoder.encrypt(*rng, mycert);
+
+ /*
+ PKCS8_PrivateKey* mykey = PKCS8::load_key("mykey.pem", *rng, "cut");
encoder.sign(store, *mykey);
+ */
SecureVector<byte> raw = encoder.get_contents();
std::ofstream out("out.der");
- out.write((const char*)raw.ptr(), raw.size());
+ out.write((const char*)raw.begin(), raw.size());
}
catch(std::exception& e)
{