diff options
author | lloyd <[email protected]> | 2011-04-08 14:57:49 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-04-08 14:57:49 +0000 |
commit | fc62f7f284387a180e42402e8706965a666efba7 (patch) | |
tree | 9abe74c670993c111bd3a5bf5fb568767f9e75be /doc/examples/cms_enc.cpp | |
parent | 438f3eb73e494fcab82b239452d712bec06f48c9 (diff) |
More pubkey doc updates
Diffstat (limited to 'doc/examples/cms_enc.cpp')
-rw-r--r-- | doc/examples/cms_enc.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/doc/examples/cms_enc.cpp b/doc/examples/cms_enc.cpp new file mode 100644 index 000000000..2cf813987 --- /dev/null +++ b/doc/examples/cms_enc.cpp @@ -0,0 +1,59 @@ +/* +* (C) 2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include <botan/botan.h> +#include <botan/cms_enc.h> +using namespace Botan; + +#include <iostream> +#include <fstream> +#include <memory> + +int main() + { + Botan::LibraryInitializer init; + + try { + + 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"); + + AutoSeeded_RNG rng; + + 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(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.begin(), raw.size()); + } + catch(std::exception& e) + { + std::cerr << e.what() << std::endl; + } + return 0; + } |