aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-28 21:07:57 +0000
committerlloyd <[email protected]>2008-09-28 21:07:57 +0000
commit98ef58194ce6b954b44acfa218c1aa49c6234aad (patch)
tree564dbab31e2c527953d36f67d238cacc64db4c6c /src
parent3948d38e2bef3f42169f96a17cc5daa6e03fb575 (diff)
Drop old Makefile. Move tests to examples directory.
Diffstat (limited to 'src')
-rw-r--r--src/cms/Makefile12
-rw-r--r--src/cms/tests/cms_dec.cpp111
-rw-r--r--src/cms/tests/cms_enc.cpp46
3 files changed, 0 insertions, 169 deletions
diff --git a/src/cms/Makefile b/src/cms/Makefile
deleted file mode 100644
index 143c0d741..000000000
--- a/src/cms/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-
-SRCS=cms_algo.cpp cms_comp.cpp cms_dalg.cpp cms_dec.cpp cms_ealg.cpp cms_enc.cpp
-OBJS=cms_algo.o cms_comp.o cms_dalg.o cms_dec.o cms_ealg.o cms_enc.o
-
-libcms.a: $(OBJS)
- ar libcms.a $(OBJS)
-
-%.o: %.cpp
- g++ -I. $(shell botan-config --cflags) -c $? -o $@
-
-clean:
- rm -f *.o
diff --git a/src/cms/tests/cms_dec.cpp b/src/cms/tests/cms_dec.cpp
deleted file mode 100644
index 593cf2e09..000000000
--- a/src/cms/tests/cms_dec.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-#include <botan/cms_dec.h>
-using namespace Botan;
-
-#include <iostream>
-
-int main(int argc, char* argv[])
- {
- if(argc != 2)
- {
- printf("Usage: %s <filename>\n", argv[0]);
- return 1;
- }
-
- LibraryInitializer init;
-
- try {
- X509_Certificate mycert("mycert.pem");
- PKCS8_PrivateKey* mykey = PKCS8::load_key("mykey.pem", "cut");
-
- 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(yourcert);
- store.add_cert(cacert, true);
- store.add_cert(int_ca);
-
- DataSource_Stream message(argv[1]);
-
- User_Interface ui;
-
- CMS_Decoder decoder(message, store, ui, mykey);
-
- while(decoder.layer_type() != CMS_Decoder::DATA)
- {
- CMS_Decoder::Status status = decoder.layer_status();
- CMS_Decoder::Content_Type content = decoder.layer_type();
-
- if(status == CMS_Decoder::FAILURE)
- {
- std::cout << "Failure reading CMS data" << std::endl;
- break;
- }
-
- if(content == CMS_Decoder::DIGESTED)
- {
- std::cout << "Digested data, hash = " << decoder.layer_info()
- << std::endl;
- std::cout << "Hash is "
- << ((status == CMS_Decoder::GOOD) ? "good" : "bad")
- << std::endl;
- }
-
- if(content == CMS_Decoder::SIGNED)
- {
- // how to handle multiple signers? they can all exist within a
- // single level...
-
- std::cout << "Signed by " << decoder.layer_info() << std::endl;
- //std::cout << "Sign time: " << decoder.xxx() << std::endl;
- std::cout << "Signature is ";
- if(status == CMS_Decoder::GOOD)
- std::cout << "valid";
- else if(status == CMS_Decoder::BAD)
- std::cout << "bad";
- else if(status == CMS_Decoder::NO_KEY)
- std::cout << "(cannot check, no known cert)";
- std::cout << std::endl;
- }
- if(content == CMS_Decoder::ENVELOPED ||
- content == CMS_Decoder::COMPRESSED ||
- content == CMS_Decoder::AUTHENTICATED)
- {
- if(content == CMS_Decoder::ENVELOPED)
- std::cout << "Enveloped";
- if(content == CMS_Decoder::COMPRESSED)
- std::cout << "Compressed";
- if(content == CMS_Decoder::AUTHENTICATED)
- std::cout << "MACed";
-
- std::cout << ", algo = " << decoder.layer_info() << std::endl;
-
- if(content == CMS_Decoder::AUTHENTICATED)
- {
- std::cout << "MAC status is ";
- if(status == CMS_Decoder::GOOD)
- std::cout << "valid";
- else if(status == CMS_Decoder::BAD)
- std::cout << "bad";
- else if(status == CMS_Decoder::NO_KEY)
- std::cout << "(cannot check, no key)";
- std::cout << std::endl;
- }
- }
- decoder.next_layer();
- }
-
- if(decoder.layer_type() == CMS_Decoder::DATA)
- std::cout << "Message is \"" << decoder.get_data()
- << '"' << std::endl;
- else
- std::cout << "No data anywhere?" << std::endl;
- }
- catch(std::exception& e)
- {
- std::cerr << e.what() << std::endl;
- }
- return 0;
- }
diff --git a/src/cms/tests/cms_enc.cpp b/src/cms/tests/cms_enc.cpp
deleted file mode 100644
index 0319925d8..000000000
--- a/src/cms/tests/cms_enc.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-#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;
- }