major change: Add security support & Adjust GUI
Change-Id: I7abef37169dec1ef4b68e760dee5214c147c1915
diff --git a/debug-tools/create-cert.cc b/debug-tools/create-cert.cc
new file mode 100644
index 0000000..36765a6
--- /dev/null
+++ b/debug-tools/create-cert.cc
@@ -0,0 +1,57 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Yingdi Yu <yingdi@cs.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#include <ndn-cpp-dev/security/key-chain.hpp>
+
+using namespace ndn;
+
+int
+main()
+{
+ KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
+ std::vector<CertificateSubjectDescription> subjectDescription;
+
+ Name root("/ndn");
+ Name rootCertName = keyChain.createIdentity(root);
+
+ Name test("/ndn/test");
+ Name testKeyName = keyChain.generateRSAKeyPairAsDefault(test, true);
+ shared_ptr<IdentityCertificate> testCert =
+ keyChain.prepareUnsignedIdentityCertificate(testKeyName, root, getNow(), getNow() + 630720000, subjectDescription);
+ keyChain.signByIdentity(*testCert, root);
+ keyChain.addCertificateAsIdentityDefault(*testCert);
+
+ Name alice("/ndn/test/alice");
+ if(!keyChain.doesIdentityExist(alice))
+ {
+ Name aliceKeyName = keyChain.generateRSAKeyPairAsDefault(alice, true);
+ shared_ptr<IdentityCertificate> aliceCert =
+ keyChain.prepareUnsignedIdentityCertificate(aliceKeyName, test, getNow(), getNow() + 630720000, subjectDescription);
+ keyChain.signByIdentity(*aliceCert, test);
+ keyChain.addCertificateAsIdentityDefault(*aliceCert);
+ }
+
+ Name bob("/ndn/test/bob");
+ if(!keyChain.doesIdentityExist(bob))
+ {
+ Name bobKeyName = keyChain.generateRSAKeyPairAsDefault(bob, true);
+ shared_ptr<IdentityCertificate> bobCert =
+ keyChain.prepareUnsignedIdentityCertificate(bobKeyName, test, getNow(), getNow() + 630720000, subjectDescription);
+ keyChain.signByIdentity(*bobCert, test);
+ keyChain.addCertificateAsIdentityDefault(*bobCert);
+ }
+
+ Name cathy("/ndn/test/cathy");
+ if(!keyChain.doesIdentityExist(cathy))
+ {
+ Name cathyKeyName = keyChain.generateRSAKeyPairAsDefault(cathy, true);
+ shared_ptr<IdentityCertificate> cathyCert =
+ keyChain.prepareUnsignedIdentityCertificate(cathyKeyName, test, getNow(), getNow() + 630720000, subjectDescription);
+ keyChain.signByIdentity(*cathyCert, test);
+ keyChain.addCertificateAsIdentityDefault(*cathyCert);
+ }
+}
diff --git a/debug-tools/dump-cert.cc b/debug-tools/dump-cert.cc
new file mode 100644
index 0000000..6022940
--- /dev/null
+++ b/debug-tools/dump-cert.cc
@@ -0,0 +1,41 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Yingdi Yu <yingdi@cs.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#include <ndn-cpp-dev/security/key-chain.hpp>
+#include <ndn-cpp-dev/face.hpp>
+
+using namespace ndn;
+
+int
+main()
+{
+ Name root("/ndn");
+ Name test("/ndn/test");
+ Name alice("/ndn/test/alice");
+ Name bob("/ndn/test/bob");
+ Name cathy("/ndn/test/cathy");
+
+ KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
+
+ if(!keyChain.doesIdentityExist(root)
+ || !keyChain.doesIdentityExist(test)
+ || !keyChain.doesIdentityExist(alice)
+ || !keyChain.doesIdentityExist(bob)
+ || !keyChain.doesIdentityExist(cathy))
+ return 1;
+
+ shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>();
+ shared_ptr<Face> face = shared_ptr<Face>(new Face(ioService));
+ // shared_ptr<Face> face = make_shared<Face>();
+
+ face->put(*keyChain.getCertificate(keyChain.getDefaultCertificateNameForIdentity(test)));
+ face->put(*keyChain.getCertificate(keyChain.getDefaultCertificateNameForIdentity(alice)));
+ face->put(*keyChain.getCertificate(keyChain.getDefaultCertificateNameForIdentity(bob)));
+ face->put(*keyChain.getCertificate(keyChain.getDefaultCertificateNameForIdentity(cathy)));
+
+ ioService->run();
+}