security: Move PIB-related code into security/pib/

Change-Id: I94ea7ce646e66382f7c534ca1c8d6cbeeb87b1a4
diff --git a/tests/unit-tests/security/pib/certificate-container.t.cpp b/tests/unit-tests/security/pib/certificate-container.t.cpp
new file mode 100644
index 0000000..514cc3d
--- /dev/null
+++ b/tests/unit-tests/security/pib/certificate-container.t.cpp
@@ -0,0 +1,82 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "security/pib/certificate-container.hpp"
+#include "security/pib/pib.hpp"
+#include "security/pib/pib-memory.hpp"
+
+#include "boost-test.hpp"
+#include "pib-data-fixture.hpp"
+
+namespace ndn {
+namespace security {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(Security)
+BOOST_AUTO_TEST_SUITE(TestPib)
+BOOST_AUTO_TEST_SUITE(TestCertificateContainer)
+
+BOOST_FIXTURE_TEST_CASE(TestCertificateContainer, PibDataFixture)
+{
+  auto pibImpl = make_shared<PibMemory>();
+  Pib pib("pib-memory", "", pibImpl);
+
+  Identity identity1 = pib.addIdentity(id1);
+  Key key11 = identity1.addKey(id1Key1, id1Key1Name.get(-1));
+  key11.addCertificate(id1Key1Cert1);
+  key11.addCertificate(id1Key1Cert2);
+
+  CertificateContainer container = key11.getCertificates();
+  BOOST_CHECK_EQUAL(container.size(), 2);
+  BOOST_CHECK(container.find(id1Key1Cert1.getName()) != container.end());
+  BOOST_CHECK(container.find(id1Key1Cert2.getName()) != container.end());
+
+  std::set<Name> certNames;
+  certNames.insert(id1Key1Cert1.getName());
+  certNames.insert(id1Key1Cert2.getName());
+
+  CertificateContainer::const_iterator it = container.begin();
+  std::set<Name>::const_iterator testIt = certNames.begin();
+  BOOST_CHECK_EQUAL((*it).getName(), *testIt);
+  it++;
+  testIt++;
+  BOOST_CHECK_EQUAL((*it).getName(), *testIt);
+  ++it;
+  testIt++;
+  BOOST_CHECK(it == container.end());
+
+  size_t count = 0;
+  testIt = certNames.begin();
+  for (const auto& cert : container) {
+    BOOST_CHECK_EQUAL(cert.getName(), *testIt);
+    testIt++;
+    count++;
+  }
+  BOOST_CHECK_EQUAL(count, 2);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestCertificateContainer
+BOOST_AUTO_TEST_SUITE_END() // TestPib
+BOOST_AUTO_TEST_SUITE_END() // Security
+
+} // namespace tests
+} // namespace security
+} // namespace ndn
diff --git a/tests/unit-tests/security/pib/identity-container.t.cpp b/tests/unit-tests/security/pib/identity-container.t.cpp
new file mode 100644
index 0000000..4cf57e9
--- /dev/null
+++ b/tests/unit-tests/security/pib/identity-container.t.cpp
@@ -0,0 +1,80 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "security/pib/identity-container.hpp"
+#include "security/pib/pib.hpp"
+#include "security/pib/pib-memory.hpp"
+
+#include "boost-test.hpp"
+#include "pib-data-fixture.hpp"
+
+namespace ndn {
+namespace security {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(Security)
+BOOST_AUTO_TEST_SUITE(TestPib)
+BOOST_AUTO_TEST_SUITE(TestIdentityContainer)
+
+BOOST_FIXTURE_TEST_CASE(Basic, PibDataFixture)
+{
+  auto pibImpl = make_shared<PibMemory>();
+  Pib pib("pib-memory", "", pibImpl);
+
+  Identity identity1 = pib.addIdentity(id1);
+  Identity identity2 = pib.addIdentity(id2);
+
+  IdentityContainer container = pib.getIdentities();
+  BOOST_CHECK_EQUAL(container.size(), 2);
+  BOOST_CHECK(container.find(id1) != container.end());
+  BOOST_CHECK(container.find(id2) != container.end());
+
+  std::set<Name> idNames;
+  idNames.insert(id1);
+  idNames.insert(id2);
+
+  IdentityContainer::const_iterator it = container.begin();
+  std::set<Name>::const_iterator testIt = idNames.begin();
+  BOOST_CHECK_EQUAL((*it).getName(), *testIt);
+  it++;
+  testIt++;
+  BOOST_CHECK_EQUAL((*it).getName(), *testIt);
+  ++it;
+  testIt++;
+  BOOST_CHECK(it == container.end());
+
+  size_t count = 0;
+  testIt = idNames.begin();
+  for (const auto& identity : container) {
+    BOOST_CHECK_EQUAL(identity.getName(), *testIt);
+    testIt++;
+    count++;
+  }
+  BOOST_CHECK_EQUAL(count, 2);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestIdentityContainer
+BOOST_AUTO_TEST_SUITE_END() // TestPib
+BOOST_AUTO_TEST_SUITE_END() // Security
+
+} // namespace tests
+} // namespace security
+} // namespace ndn
diff --git a/tests/unit-tests/security/pib/identity.t.cpp b/tests/unit-tests/security/pib/identity.t.cpp
new file mode 100644
index 0000000..d31f7c6
--- /dev/null
+++ b/tests/unit-tests/security/pib/identity.t.cpp
@@ -0,0 +1,90 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "security/pib/identity.hpp"
+#include "security/pib/pib.hpp"
+#include "security/pib/pib-memory.hpp"
+
+#include "boost-test.hpp"
+#include "pib-data-fixture.hpp"
+
+namespace ndn {
+namespace security {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(Security)
+BOOST_AUTO_TEST_SUITE(TestPib)
+BOOST_FIXTURE_TEST_SUITE(TestIdentity, PibDataFixture)
+
+BOOST_AUTO_TEST_CASE(ValidityChecking)
+{
+  // identity
+  Identity id;
+
+  BOOST_CHECK_EQUAL(static_cast<bool>(id), false);
+  BOOST_CHECK_EQUAL(!id, true);
+
+  if (id)
+    BOOST_CHECK(false);
+  else
+    BOOST_CHECK(true);
+
+  auto pibImpl = make_shared<PibMemory>();
+  id = Identity(id1, pibImpl, true);
+
+  BOOST_CHECK_EQUAL(static_cast<bool>(id), true);
+  BOOST_CHECK_EQUAL(!id, false);
+
+  if (id)
+    BOOST_CHECK(true);
+  else
+    BOOST_CHECK(false);
+}
+
+BOOST_AUTO_TEST_CASE(KeyOperations)
+{
+  auto pibImpl = make_shared<PibMemory>();
+
+  Identity identity1(id1, pibImpl, true);
+
+  BOOST_CHECK_THROW(identity1.getKey(id1Key1Name.get(-1)), Pib::Error);
+  Key key11 = identity1.addKey(id1Key1, id1Key1Name.get(-1));
+  BOOST_CHECK_NO_THROW(identity1.getKey(id1Key1Name.get(-1)));
+  identity1.removeKey(id1Key1Name.get(-1));
+  BOOST_CHECK_THROW(identity1.getKey(id1Key1Name.get(-1)), Pib::Error);
+
+  BOOST_CHECK_THROW(identity1.getDefaultKey(), Pib::Error);
+  BOOST_REQUIRE_THROW(identity1.setDefaultKey(id1Key1Name.get(-1)), Pib::Error);
+  BOOST_REQUIRE_NO_THROW(identity1.setDefaultKey(id1Key1, id1Key1Name.get(-1)));
+  BOOST_REQUIRE_NO_THROW(identity1.getDefaultKey());
+  BOOST_CHECK_EQUAL(identity1.getDefaultKey().getKeyId(), id1Key1Name.get(-1));
+  identity1.removeKey(id1Key1Name.get(-1));
+  BOOST_CHECK_THROW(identity1.getKey(id1Key1Name.get(-1)), Pib::Error);
+  BOOST_CHECK_THROW(identity1.getDefaultKey(), Pib::Error);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestIdentity
+BOOST_AUTO_TEST_SUITE_END() // TestPib
+BOOST_AUTO_TEST_SUITE_END() // Security
+
+} // namespace tests
+} // namespace security
+} // namespace ndn
diff --git a/tests/unit-tests/security/pib/key-container.t.cpp b/tests/unit-tests/security/pib/key-container.t.cpp
new file mode 100644
index 0000000..ee5bf1c
--- /dev/null
+++ b/tests/unit-tests/security/pib/key-container.t.cpp
@@ -0,0 +1,83 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "security/pib/key-container.hpp"
+#include "security/pib/pib.hpp"
+#include "security/pib/pib-memory.hpp"
+
+#include "boost-test.hpp"
+#include "pib-data-fixture.hpp"
+
+namespace ndn {
+namespace security {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(Security)
+BOOST_AUTO_TEST_SUITE(TestPib)
+BOOST_AUTO_TEST_SUITE(TestKeyContainer)
+
+BOOST_FIXTURE_TEST_CASE(Basic, PibDataFixture)
+{
+  auto pibImpl = make_shared<PibMemory>();
+  Pib pib("pib-memory", "", pibImpl);
+
+  Identity identity1 = pib.addIdentity(id1);
+
+  Key key11 = identity1.addKey(id1Key1, id1Key1Name.get(-1));
+  Key key12 = identity1.addKey(id1Key2, id1Key2Name.get(-1));
+
+  KeyContainer container = identity1.getKeys();
+  BOOST_CHECK_EQUAL(container.size(), 2);
+  BOOST_CHECK(container.find(id1Key1Name.get(-1)) != container.end());
+  BOOST_CHECK(container.find(id1Key2Name.get(-1)) != container.end());
+
+  std::set<name::Component> keyNames;
+  keyNames.insert(id1Key1Name.get(-1));
+  keyNames.insert(id1Key2Name.get(-1));
+
+  KeyContainer::const_iterator it = container.begin();
+  std::set<name::Component>::const_iterator testIt = keyNames.begin();
+  BOOST_CHECK_EQUAL((*it).getKeyId(), *testIt);
+  it++;
+  testIt++;
+  BOOST_CHECK_EQUAL((*it).getKeyId(), *testIt);
+  ++it;
+  testIt++;
+  BOOST_CHECK(it == container.end());
+
+  size_t count = 0;
+  testIt = keyNames.begin();
+  for (const auto& key : container) {
+    BOOST_CHECK_EQUAL(key.getIdentity(), id1);
+    BOOST_CHECK_EQUAL(key.getKeyId(), *testIt);
+    testIt++;
+    count++;
+  }
+  BOOST_CHECK_EQUAL(count, 2);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestKeyContainer
+BOOST_AUTO_TEST_SUITE_END() // TestPib
+BOOST_AUTO_TEST_SUITE_END() // Security
+
+} // namespace tests
+} // namespace security
+} // namespace ndn
diff --git a/tests/unit-tests/security/pib/key.t.cpp b/tests/unit-tests/security/pib/key.t.cpp
new file mode 100644
index 0000000..673c149
--- /dev/null
+++ b/tests/unit-tests/security/pib/key.t.cpp
@@ -0,0 +1,96 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "security/pib/key.hpp"
+#include "security/pib/pib.hpp"
+#include "security/pib/pib-memory.hpp"
+
+#include "boost-test.hpp"
+#include "pib-data-fixture.hpp"
+
+namespace ndn {
+namespace security {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(Security)
+BOOST_AUTO_TEST_SUITE(TestPib)
+BOOST_FIXTURE_TEST_SUITE(TestKey, PibDataFixture)
+
+BOOST_AUTO_TEST_CASE(ValidityChecking)
+{
+  // key
+  Key key;
+
+  BOOST_CHECK_EQUAL(static_cast<bool>(key), false);
+  BOOST_CHECK_EQUAL(!key, true);
+
+  if (key)
+    BOOST_CHECK(false);
+  else
+    BOOST_CHECK(true);
+
+  auto pibImpl = make_shared<PibMemory>();
+  key = Key(id1, id1Key1Name.get(-1), id1Key1, pibImpl);
+
+  BOOST_CHECK_EQUAL(static_cast<bool>(key), true);
+  BOOST_CHECK_EQUAL(!key, false);
+
+  if (key)
+    BOOST_CHECK(true);
+  else
+    BOOST_CHECK(false);
+}
+
+BOOST_AUTO_TEST_CASE(CertificateOperations)
+{
+  auto pibImpl = make_shared<PibMemory>();
+
+  Key key11(id1, id1Key1Name.get(-1), id1Key1, pibImpl);
+
+  BOOST_CHECK_THROW(key11.getCertificate(id1Key1Cert1.getName()), Pib::Error);
+  key11.addCertificate(id1Key1Cert1);
+  BOOST_CHECK_NO_THROW(key11.getCertificate(id1Key1Cert1.getName()));
+  key11.removeCertificate(id1Key1Cert1.getName());
+  BOOST_CHECK_THROW(key11.getCertificate(id1Key1Cert1.getName()), Pib::Error);
+
+  BOOST_CHECK_THROW(key11.getDefaultCertificate(), Pib::Error);
+  BOOST_REQUIRE_THROW(key11.setDefaultCertificate(id1Key1Cert1.getName()), Pib::Error);
+  BOOST_REQUIRE_NO_THROW(key11.setDefaultCertificate(id1Key1Cert1));
+  BOOST_REQUIRE_NO_THROW(key11.getDefaultCertificate());
+
+  const v1::IdentityCertificate& defaultCert = key11.getDefaultCertificate();
+  BOOST_CHECK_EQUAL_COLLECTIONS(defaultCert.wireEncode().wire(),
+                                defaultCert.wireEncode().wire() + defaultCert.wireEncode().size(),
+                                id1Key1Cert1.wireEncode().wire(),
+                                id1Key1Cert1.wireEncode().wire() + id1Key1Cert1.wireEncode().size());
+
+  key11.removeCertificate(id1Key1Cert1.getName());
+  BOOST_CHECK_THROW(key11.getCertificate(id1Key1Cert1.getName()), Pib::Error);
+  BOOST_CHECK_THROW(key11.getDefaultCertificate(), Pib::Error);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestKey
+BOOST_AUTO_TEST_SUITE_END() // TestPib
+BOOST_AUTO_TEST_SUITE_END() // Security
+
+} // namespace tests
+} // namespace security
+} // namespace ndn
diff --git a/tests/unit-tests/security/pib/pib-data-fixture.cpp b/tests/unit-tests/security/pib/pib-data-fixture.cpp
new file mode 100644
index 0000000..25eb83c
--- /dev/null
+++ b/tests/unit-tests/security/pib/pib-data-fixture.cpp
@@ -0,0 +1,343 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "pib-data-fixture.hpp"
+#include "../../identity-management-time-fixture.hpp"
+
+namespace ndn {
+namespace security {
+namespace tests {
+
+/**
+ * The test data can be generated with a TestCertDataGenerator defined as below:
+ *
+ * TestCertDataGenerator g;
+ *
+ * g.printTestDataForId(Name("/pib/interface/id/1"));
+ * g.printTestDataForId(Name("/pib/interface/id/2"));
+ *
+ * class TestCertDataGenerator : public IdentityManagementTimeFixture
+ * {
+ * public:
+ *   void
+ *   printTestDataForId(const Name& id)
+ *   {
+ *     addIdentity(id, EcdsaKeyParams());
+ *
+ *     Name key1Name = m_keyChain.getDefaultKeyNameForIdentity(id);
+ *     shared_ptr<PublicKey> key1 = m_keyChain.getPublicKey(key1Name);
+ *     printBytes(key1->get());
+ *
+ *     Name key1Cert1Name = m_keyChain.getDefaultCertificateNameForKey(key1Name);
+ *     shared_ptr<IdentityCertificate> key1Cert1 = m_keyChain.getCertificate(key1Cert1Name);
+ *     printBytes(key1Cert1->wireEncode());
+ *
+ *     Name key2Name = m_keyChain.generateEcdsaKeyPair(id, true);
+ *     shared_ptr<PublicKey> key2 = m_keyChain.getPublicKey(key2Name);
+ *     printBytes(key2->get());
+ *
+ *     shared_ptr<IdentityCertificate> key2Cert1 = m_keyChain.selfSign(key2Name);
+ *     printBytes(key2Cert1->wireEncode());
+ *
+ *     advanceClocks(time::seconds(20));
+ *
+ *     shared_ptr<IdentityCertificate> key1Cert2 = m_keyChain.selfSign(key1Name);
+ *     printBytes(key1Cert2->wireEncode());
+ *
+ *     shared_ptr<IdentityCertificate> key2Cert2 = m_keyChain.selfSign(key2Name);
+ *     printBytes(key2Cert2->wireEncode());
+ *   }
+ *
+ *   void
+ *   printBytes(const Block& block)
+ *   {
+ *     printBytes(block.wire(), block.size());
+ *   }
+ *
+ *   void
+ *   printBytes(const Buffer& buffer)
+ *   {
+ *     printBytes(buffer.buf(), buffer.size());
+ *   }
+ *
+ *   void
+ *   printBytes(const uint8_t* buf, size_t size)
+ *   {
+ *     using namespace CryptoPP;
+ *
+ *     std::string hex = toHex(buf, size);
+ *
+ *     for (int i = 0; i < hex.size(); i++) {
+ *       if (i % 40 == 0)
+ *         std::cout << std::endl;
+ *
+ *       std::cout << "0x" << hex[i];
+ *       std::cout << hex[++i];
+ *
+ *       if ((i + 1) != hex.size())
+ *         std::cout << ", ";
+ *     }
+ *     std::cout << std::endl;
+ *   }
+ * };
+ */
+
+const uint8_t ID1_KEY1[] = {
+  0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D,
+  0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xFF, 0xF9, 0x1E, 0x85, 0x6C, 0x29, 0x5F, 0x98, 0xB1, 0x2E, 0xD5, 0x3D, 0xCA,
+  0xE2, 0x00, 0x52, 0x7A, 0x55, 0x93, 0x96, 0xD1, 0x7F, 0x03, 0x20, 0x25, 0xA7, 0xE5, 0xB8, 0xF8, 0x5D, 0xF0, 0x2E, 0x3E,
+  0x60, 0x40, 0x19, 0x73, 0x00, 0x4F, 0x5A, 0xA7, 0x66, 0xFB, 0x38, 0xE6, 0xEB, 0xD5, 0xA4, 0x32, 0x1F, 0x5F, 0xC6, 0x7D,
+  0x4B, 0xD4, 0xBB, 0x1E, 0x15, 0x29, 0x3E, 0x40, 0x22, 0x4E, 0xE7
+};
+
+const uint8_t ID1_KEY1_CERT1[] = {
+  0x06, 0xFD, 0x01, 0x88, 0x07, 0x43, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61,
+  0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x31, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B, 0x2D,
+  0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x33, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43, 0x45,
+  0x52, 0x54, 0x08, 0x09, 0xFD, 0x00, 0x00, 0x01, 0x49, 0x9D, 0x59, 0x8C, 0xA0, 0x14, 0x03, 0x18, 0x01, 0x02, 0x15, 0xB2,
+  0x30, 0x81, 0xAF, 0x30, 0x22, 0x18, 0x0F, 0x32, 0x30, 0x31, 0x34, 0x31, 0x31, 0x31, 0x31, 0x30, 0x35, 0x33, 0x35, 0x33,
+  0x32, 0x5A, 0x18, 0x0F, 0x32, 0x30, 0x33, 0x34, 0x31, 0x31, 0x30, 0x36, 0x30, 0x35, 0x33, 0x35, 0x33, 0x32, 0x5A, 0x30,
+  0x2E, 0x30, 0x2C, 0x06, 0x03, 0x55, 0x04, 0x29, 0x13, 0x25, 0x2F, 0x70, 0x69, 0x62, 0x2F, 0x69, 0x6E, 0x74, 0x65, 0x72,
+  0x66, 0x61, 0x63, 0x65, 0x2F, 0x69, 0x64, 0x2F, 0x31, 0x2F, 0x6B, 0x73, 0x6B, 0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38,
+  0x34, 0x31, 0x33, 0x32, 0x30, 0x30, 0x30, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01,
+  0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xFF, 0xF9, 0x1E, 0x85, 0x6C, 0x29,
+  0x5F, 0x98, 0xB1, 0x2E, 0xD5, 0x3D, 0xCA, 0xE2, 0x00, 0x52, 0x7A, 0x55, 0x93, 0x96, 0xD1, 0x7F, 0x03, 0x20, 0x25, 0xA7,
+  0xE5, 0xB8, 0xF8, 0x5D, 0xF0, 0x2E, 0x3E, 0x60, 0x40, 0x19, 0x73, 0x00, 0x4F, 0x5A, 0xA7, 0x66, 0xFB, 0x38, 0xE6, 0xEB,
+  0xD5, 0xA4, 0x32, 0x1F, 0x5F, 0xC6, 0x7D, 0x4B, 0xD4, 0xBB, 0x1E, 0x15, 0x29, 0x3E, 0x40, 0x22, 0x4E, 0xE7, 0x16, 0x3F,
+  0x1B, 0x01, 0x03, 0x1C, 0x3A, 0x07, 0x38, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66,
+  0x61, 0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x31, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B,
+  0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x33, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43,
+  0x45, 0x52, 0x54, 0x17, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xAE, 0x85, 0xB6, 0xDE, 0x1B, 0x3B, 0xC0, 0x46, 0x93, 0xEF,
+  0x49, 0x26, 0x98, 0x4B, 0x20, 0x77, 0xAB, 0xF6, 0x83, 0x41, 0x72, 0x1D, 0x99, 0xBE, 0x85, 0xC9, 0xC8, 0xA6, 0x14, 0x50,
+  0xA6, 0x3E, 0x02, 0x20, 0x5A, 0xC6, 0x1F, 0xF7, 0x72, 0xB4, 0x3A, 0xA1, 0x1D, 0x5E, 0xF7, 0xF3, 0x3C, 0x83, 0xF7, 0xD8,
+  0x27, 0x13, 0x65, 0x4D, 0x5D, 0x1A, 0x23, 0x5F, 0xA9, 0xFC, 0x53, 0x22, 0x86, 0xBD, 0x92, 0x01
+};
+
+const uint8_t ID1_KEY1_CERT2[] = {
+  0x06, 0xFD, 0x01, 0x88, 0x07, 0x43, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61,
+  0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x31, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B, 0x2D,
+  0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x33, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43, 0x45,
+  0x52, 0x54, 0x08, 0x09, 0xFD, 0x00, 0x00, 0x01, 0x49, 0x9D, 0x59, 0xB3, 0xB0, 0x14, 0x03, 0x18, 0x01, 0x02, 0x15, 0xB2,
+  0x30, 0x81, 0xAF, 0x30, 0x22, 0x18, 0x0F, 0x32, 0x30, 0x31, 0x34, 0x31, 0x31, 0x31, 0x31, 0x30, 0x35, 0x33, 0x35, 0x34,
+  0x32, 0x5A, 0x18, 0x0F, 0x32, 0x30, 0x33, 0x34, 0x31, 0x31, 0x30, 0x36, 0x30, 0x35, 0x33, 0x35, 0x34, 0x32, 0x5A, 0x30,
+  0x2E, 0x30, 0x2C, 0x06, 0x03, 0x55, 0x04, 0x29, 0x13, 0x25, 0x2F, 0x70, 0x69, 0x62, 0x2F, 0x69, 0x6E, 0x74, 0x65, 0x72,
+  0x66, 0x61, 0x63, 0x65, 0x2F, 0x69, 0x64, 0x2F, 0x31, 0x2F, 0x6B, 0x73, 0x6B, 0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38,
+  0x34, 0x31, 0x33, 0x32, 0x30, 0x30, 0x30, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01,
+  0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xFF, 0xF9, 0x1E, 0x85, 0x6C, 0x29,
+  0x5F, 0x98, 0xB1, 0x2E, 0xD5, 0x3D, 0xCA, 0xE2, 0x00, 0x52, 0x7A, 0x55, 0x93, 0x96, 0xD1, 0x7F, 0x03, 0x20, 0x25, 0xA7,
+  0xE5, 0xB8, 0xF8, 0x5D, 0xF0, 0x2E, 0x3E, 0x60, 0x40, 0x19, 0x73, 0x00, 0x4F, 0x5A, 0xA7, 0x66, 0xFB, 0x38, 0xE6, 0xEB,
+  0xD5, 0xA4, 0x32, 0x1F, 0x5F, 0xC6, 0x7D, 0x4B, 0xD4, 0xBB, 0x1E, 0x15, 0x29, 0x3E, 0x40, 0x22, 0x4E, 0xE7, 0x16, 0x3F,
+  0x1B, 0x01, 0x03, 0x1C, 0x3A, 0x07, 0x38, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66,
+  0x61, 0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x31, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B,
+  0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x33, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43,
+  0x45, 0x52, 0x54, 0x17, 0x47, 0x30, 0x45, 0x02, 0x20, 0x12, 0xA8, 0xF5, 0x30, 0xE1, 0x57, 0xD1, 0x39, 0xB2, 0x46, 0x0A,
+  0x82, 0x58, 0x8A, 0xCD, 0xB3, 0x6F, 0x2F, 0x1B, 0xB8, 0x6A, 0x99, 0xAB, 0x0C, 0xB2, 0xB7, 0xE2, 0x01, 0xE4, 0xD8, 0xC8,
+  0x9C, 0x02, 0x21, 0x00, 0xDA, 0xCD, 0x11, 0x28, 0x96, 0xC6, 0xB6, 0x31, 0x6E, 0xDF, 0xCA, 0x79, 0xDE, 0x26, 0x44, 0xCA,
+  0x09, 0x74, 0xF1, 0xB1, 0x7C, 0x9B, 0xFA, 0x67, 0x22, 0x55, 0x18, 0xA5, 0x05, 0x48, 0x7D, 0x65
+};
+
+const uint8_t ID1_KEY2[] = {
+  0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D,
+  0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xC2, 0xE0, 0xEC, 0xC7, 0xED, 0x65, 0xDE, 0x0A, 0x46, 0xCE, 0x38, 0xC2, 0x68,
+  0x77, 0x4F, 0xE3, 0xE1, 0xDF, 0x37, 0x7D, 0xA3, 0x56, 0x0D, 0xF9, 0x66, 0x43, 0x37, 0x60, 0x42, 0x7E, 0x96, 0x93, 0x7E,
+  0x35, 0xA0, 0xD5, 0xC8, 0x59, 0x8F, 0x36, 0x85, 0x11, 0xBF, 0xFA, 0x85, 0x1A, 0x7B, 0x61, 0xE6, 0xEB, 0xD1, 0x46, 0x99,
+  0x67, 0x6B, 0xDB, 0x83, 0x26, 0x1F, 0x75, 0x7A, 0x93, 0xA2, 0xAE
+};
+
+const uint8_t ID1_KEY2_CERT1[] = {
+  0x06, 0xFD, 0x01, 0x88, 0x07, 0x43, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61,
+  0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x31, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B, 0x2D,
+  0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x35, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43, 0x45,
+  0x52, 0x54, 0x08, 0x09, 0xFD, 0x00, 0x00, 0x01, 0x49, 0x9D, 0x59, 0xDA, 0xC0, 0x14, 0x03, 0x18, 0x01, 0x02, 0x15, 0xB2,
+  0x30, 0x81, 0xAF, 0x30, 0x22, 0x18, 0x0F, 0x32, 0x30, 0x31, 0x34, 0x31, 0x31, 0x31, 0x31, 0x30, 0x35, 0x33, 0x35, 0x35,
+  0x32, 0x5A, 0x18, 0x0F, 0x32, 0x30, 0x33, 0x34, 0x31, 0x31, 0x30, 0x36, 0x30, 0x35, 0x33, 0x35, 0x35, 0x32, 0x5A, 0x30,
+  0x2E, 0x30, 0x2C, 0x06, 0x03, 0x55, 0x04, 0x29, 0x13, 0x25, 0x2F, 0x70, 0x69, 0x62, 0x2F, 0x69, 0x6E, 0x74, 0x65, 0x72,
+  0x66, 0x61, 0x63, 0x65, 0x2F, 0x69, 0x64, 0x2F, 0x31, 0x2F, 0x6B, 0x73, 0x6B, 0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38,
+  0x34, 0x31, 0x35, 0x32, 0x30, 0x30, 0x30, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01,
+  0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xC2, 0xE0, 0xEC, 0xC7, 0xED, 0x65,
+  0xDE, 0x0A, 0x46, 0xCE, 0x38, 0xC2, 0x68, 0x77, 0x4F, 0xE3, 0xE1, 0xDF, 0x37, 0x7D, 0xA3, 0x56, 0x0D, 0xF9, 0x66, 0x43,
+  0x37, 0x60, 0x42, 0x7E, 0x96, 0x93, 0x7E, 0x35, 0xA0, 0xD5, 0xC8, 0x59, 0x8F, 0x36, 0x85, 0x11, 0xBF, 0xFA, 0x85, 0x1A,
+  0x7B, 0x61, 0xE6, 0xEB, 0xD1, 0x46, 0x99, 0x67, 0x6B, 0xDB, 0x83, 0x26, 0x1F, 0x75, 0x7A, 0x93, 0xA2, 0xAE, 0x16, 0x3F,
+  0x1B, 0x01, 0x03, 0x1C, 0x3A, 0x07, 0x38, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66,
+  0x61, 0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x31, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B,
+  0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x35, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43,
+  0x45, 0x52, 0x54, 0x17, 0x47, 0x30, 0x45, 0x02, 0x20, 0x24, 0x26, 0x28, 0xA1, 0xD2, 0xCA, 0x46, 0xDB, 0x15, 0x5A, 0xB8,
+  0x15, 0x58, 0x3B, 0x1C, 0xEC, 0xDF, 0x9E, 0xF9, 0x35, 0x32, 0x61, 0x0B, 0xC3, 0x9B, 0xA2, 0x1F, 0x05, 0xAA, 0x04, 0xE4,
+  0x40, 0x02, 0x21, 0x00, 0xEA, 0x37, 0xA3, 0x1E, 0xD6, 0x20, 0x73, 0xD8, 0x55, 0xE6, 0x62, 0xB1, 0x23, 0xBC, 0x32, 0x08,
+  0x1A, 0x0F, 0x4B, 0x94, 0xBE, 0x28, 0xCE, 0xE7, 0x0A, 0x8A, 0xB4, 0xD5, 0xEA, 0x8D, 0x20, 0x95
+};
+
+const uint8_t ID1_KEY2_CERT2[] = {
+  0x06, 0xFD, 0x01, 0x88, 0x07, 0x43, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61,
+  0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x31, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B, 0x2D,
+  0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x35, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43, 0x45,
+  0x52, 0x54, 0x08, 0x09, 0xFD, 0x00, 0x00, 0x01, 0x49, 0x9D, 0x5A, 0x01, 0xD0, 0x14, 0x03, 0x18, 0x01, 0x02, 0x15, 0xB2,
+  0x30, 0x81, 0xAF, 0x30, 0x22, 0x18, 0x0F, 0x32, 0x30, 0x31, 0x34, 0x31, 0x31, 0x31, 0x31, 0x30, 0x35, 0x33, 0x36, 0x30,
+  0x32, 0x5A, 0x18, 0x0F, 0x32, 0x30, 0x33, 0x34, 0x31, 0x31, 0x30, 0x36, 0x30, 0x35, 0x33, 0x36, 0x30, 0x32, 0x5A, 0x30,
+  0x2E, 0x30, 0x2C, 0x06, 0x03, 0x55, 0x04, 0x29, 0x13, 0x25, 0x2F, 0x70, 0x69, 0x62, 0x2F, 0x69, 0x6E, 0x74, 0x65, 0x72,
+  0x66, 0x61, 0x63, 0x65, 0x2F, 0x69, 0x64, 0x2F, 0x31, 0x2F, 0x6B, 0x73, 0x6B, 0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38,
+  0x34, 0x31, 0x35, 0x32, 0x30, 0x30, 0x30, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01,
+  0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xC2, 0xE0, 0xEC, 0xC7, 0xED, 0x65,
+  0xDE, 0x0A, 0x46, 0xCE, 0x38, 0xC2, 0x68, 0x77, 0x4F, 0xE3, 0xE1, 0xDF, 0x37, 0x7D, 0xA3, 0x56, 0x0D, 0xF9, 0x66, 0x43,
+  0x37, 0x60, 0x42, 0x7E, 0x96, 0x93, 0x7E, 0x35, 0xA0, 0xD5, 0xC8, 0x59, 0x8F, 0x36, 0x85, 0x11, 0xBF, 0xFA, 0x85, 0x1A,
+  0x7B, 0x61, 0xE6, 0xEB, 0xD1, 0x46, 0x99, 0x67, 0x6B, 0xDB, 0x83, 0x26, 0x1F, 0x75, 0x7A, 0x93, 0xA2, 0xAE, 0x16, 0x3F,
+  0x1B, 0x01, 0x03, 0x1C, 0x3A, 0x07, 0x38, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66,
+  0x61, 0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x31, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B,
+  0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x35, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43,
+  0x45, 0x52, 0x54, 0x17, 0x47, 0x30, 0x45, 0x02, 0x20, 0x3B, 0x82, 0xAE, 0xFD, 0x8B, 0x6D, 0xBA, 0x1D, 0x77, 0x70, 0x86,
+  0xAB, 0xF1, 0x37, 0x38, 0x90, 0x04, 0x83, 0x33, 0xF8, 0xF2, 0x2C, 0xD6, 0x50, 0x32, 0x19, 0xEA, 0xD6, 0xBB, 0x40, 0x58,
+  0x8F, 0x02, 0x21, 0x00, 0x93, 0x01, 0x54, 0x5C, 0x8C, 0x60, 0x81, 0x89, 0xBE, 0x5E, 0x42, 0x31, 0x39, 0xF8, 0x12, 0xFD,
+  0x31, 0x48, 0xB0, 0x96, 0x41, 0x40, 0x98, 0x68, 0xF9, 0x7C, 0x01, 0x94, 0xD0, 0xA3, 0xF3, 0xC7
+};
+
+const uint8_t ID2_KEY1[] = {
+  0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D,
+  0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xA4, 0x25, 0xDB, 0xB0, 0xD7, 0xC6, 0x0D, 0xC6, 0x95, 0x97, 0x79, 0xFA, 0xE3,
+  0xC7, 0x90, 0xFB, 0x97, 0xAF, 0xCE, 0xDB, 0xC3, 0x50, 0x99, 0x1E, 0x39, 0xF5, 0x9A, 0xB6, 0xC9, 0x37, 0x1A, 0xE5, 0x0A,
+  0x56, 0xE0, 0x0C, 0x0D, 0x81, 0xC7, 0x29, 0xE4, 0x69, 0x06, 0xD1, 0x4A, 0x14, 0x75, 0x05, 0x95, 0xBE, 0xE7, 0x01, 0x45,
+  0x3C, 0xA7, 0x99, 0x09, 0x05, 0x9F, 0x65, 0x9A, 0xA5, 0x9C, 0xD5
+};
+
+const uint8_t ID2_KEY1_CERT1[] = {
+  0x06, 0xFD, 0x01, 0x89, 0x07, 0x43, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61,
+  0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x32, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B, 0x2D,
+  0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x33, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43, 0x45,
+  0x52, 0x54, 0x08, 0x09, 0xFD, 0x00, 0x00, 0x01, 0x49, 0x9D, 0x59, 0x8C, 0xA0, 0x14, 0x03, 0x18, 0x01, 0x02, 0x15, 0xB2,
+  0x30, 0x81, 0xAF, 0x30, 0x22, 0x18, 0x0F, 0x32, 0x30, 0x31, 0x34, 0x31, 0x31, 0x31, 0x31, 0x30, 0x35, 0x33, 0x35, 0x33,
+  0x32, 0x5A, 0x18, 0x0F, 0x32, 0x30, 0x33, 0x34, 0x31, 0x31, 0x30, 0x36, 0x30, 0x35, 0x33, 0x35, 0x33, 0x32, 0x5A, 0x30,
+  0x2E, 0x30, 0x2C, 0x06, 0x03, 0x55, 0x04, 0x29, 0x13, 0x25, 0x2F, 0x70, 0x69, 0x62, 0x2F, 0x69, 0x6E, 0x74, 0x65, 0x72,
+  0x66, 0x61, 0x63, 0x65, 0x2F, 0x69, 0x64, 0x2F, 0x32, 0x2F, 0x6B, 0x73, 0x6B, 0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38,
+  0x34, 0x31, 0x33, 0x32, 0x30, 0x30, 0x30, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01,
+  0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xA4, 0x25, 0xDB, 0xB0, 0xD7, 0xC6,
+  0x0D, 0xC6, 0x95, 0x97, 0x79, 0xFA, 0xE3, 0xC7, 0x90, 0xFB, 0x97, 0xAF, 0xCE, 0xDB, 0xC3, 0x50, 0x99, 0x1E, 0x39, 0xF5,
+  0x9A, 0xB6, 0xC9, 0x37, 0x1A, 0xE5, 0x0A, 0x56, 0xE0, 0x0C, 0x0D, 0x81, 0xC7, 0x29, 0xE4, 0x69, 0x06, 0xD1, 0x4A, 0x14,
+  0x75, 0x05, 0x95, 0xBE, 0xE7, 0x01, 0x45, 0x3C, 0xA7, 0x99, 0x09, 0x05, 0x9F, 0x65, 0x9A, 0xA5, 0x9C, 0xD5, 0x16, 0x3F,
+  0x1B, 0x01, 0x03, 0x1C, 0x3A, 0x07, 0x38, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66,
+  0x61, 0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x32, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B,
+  0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x33, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43,
+  0x45, 0x52, 0x54, 0x17, 0x48, 0x30, 0x46, 0x02, 0x21, 0x00, 0xC4, 0x40, 0x87, 0xA7, 0xAA, 0xA7, 0x12, 0xE2, 0x7C, 0xE2,
+  0xA8, 0x27, 0x66, 0xCF, 0x45, 0x3E, 0x3D, 0xEC, 0x2C, 0x5C, 0x03, 0xD6, 0xB0, 0xD6, 0x5E, 0xE8, 0xB7, 0x03, 0x9C, 0x38,
+  0x75, 0xEA, 0x02, 0x21, 0x00, 0x8D, 0xF3, 0x9E, 0xC0, 0x18, 0xBD, 0xA1, 0x2B, 0xDB, 0x3D, 0xE0, 0x34, 0x14, 0x34, 0x65,
+  0x23, 0x37, 0x6E, 0x3C, 0xC0, 0xC4, 0x2F, 0xED, 0xBB, 0x9B, 0xB2, 0xEC, 0x2A, 0x96, 0xE6, 0xD2, 0x98
+};
+
+const uint8_t ID2_KEY1_CERT2[] = {
+  0x06, 0xFD, 0x01, 0x88, 0x07, 0x43, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61,
+  0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x32, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B, 0x2D,
+  0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x33, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43, 0x45,
+  0x52, 0x54, 0x08, 0x09, 0xFD, 0x00, 0x00, 0x01, 0x49, 0x9D, 0x59, 0xB3, 0xB0, 0x14, 0x03, 0x18, 0x01, 0x02, 0x15, 0xB2,
+  0x30, 0x81, 0xAF, 0x30, 0x22, 0x18, 0x0F, 0x32, 0x30, 0x31, 0x34, 0x31, 0x31, 0x31, 0x31, 0x30, 0x35, 0x33, 0x35, 0x34,
+  0x32, 0x5A, 0x18, 0x0F, 0x32, 0x30, 0x33, 0x34, 0x31, 0x31, 0x30, 0x36, 0x30, 0x35, 0x33, 0x35, 0x34, 0x32, 0x5A, 0x30,
+  0x2E, 0x30, 0x2C, 0x06, 0x03, 0x55, 0x04, 0x29, 0x13, 0x25, 0x2F, 0x70, 0x69, 0x62, 0x2F, 0x69, 0x6E, 0x74, 0x65, 0x72,
+  0x66, 0x61, 0x63, 0x65, 0x2F, 0x69, 0x64, 0x2F, 0x32, 0x2F, 0x6B, 0x73, 0x6B, 0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38,
+  0x34, 0x31, 0x33, 0x32, 0x30, 0x30, 0x30, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01,
+  0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xA4, 0x25, 0xDB, 0xB0, 0xD7, 0xC6,
+  0x0D, 0xC6, 0x95, 0x97, 0x79, 0xFA, 0xE3, 0xC7, 0x90, 0xFB, 0x97, 0xAF, 0xCE, 0xDB, 0xC3, 0x50, 0x99, 0x1E, 0x39, 0xF5,
+  0x9A, 0xB6, 0xC9, 0x37, 0x1A, 0xE5, 0x0A, 0x56, 0xE0, 0x0C, 0x0D, 0x81, 0xC7, 0x29, 0xE4, 0x69, 0x06, 0xD1, 0x4A, 0x14,
+  0x75, 0x05, 0x95, 0xBE, 0xE7, 0x01, 0x45, 0x3C, 0xA7, 0x99, 0x09, 0x05, 0x9F, 0x65, 0x9A, 0xA5, 0x9C, 0xD5, 0x16, 0x3F,
+  0x1B, 0x01, 0x03, 0x1C, 0x3A, 0x07, 0x38, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66,
+  0x61, 0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x32, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B,
+  0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x33, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43,
+  0x45, 0x52, 0x54, 0x17, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xAA, 0xFE, 0x76, 0xBE, 0x2C, 0x4D, 0xDA, 0x41, 0x27, 0x93,
+  0x11, 0x70, 0xEE, 0x33, 0x57, 0x37, 0xA2, 0x54, 0x01, 0x97, 0x82, 0x16, 0xB5, 0x8A, 0xFD, 0xE2, 0x5F, 0x2E, 0x05, 0x0A,
+  0xF5, 0xE6, 0x02, 0x20, 0x4F, 0xEF, 0x85, 0xC6, 0x91, 0xF3, 0x55, 0x2C, 0x4E, 0x98, 0x81, 0xD7, 0xF0, 0x63, 0x36, 0x91,
+  0xB3, 0x88, 0x9D, 0x99, 0x7E, 0x49, 0xD5, 0x72, 0x7F, 0x6F, 0x92, 0xCF, 0x0A, 0x56, 0xA6, 0xF9
+};
+
+const uint8_t ID2_KEY2[] = {
+  0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D,
+  0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x6C, 0x49, 0x20, 0x7E, 0x59, 0xAF, 0x48, 0x1C, 0x9B, 0xCB, 0x67, 0xD4, 0x6F,
+  0x43, 0x9D, 0xD8, 0xB5, 0x36, 0xDB, 0x72, 0xDA, 0x37, 0x55, 0x4B, 0x8C, 0x69, 0x17, 0x87, 0xF6, 0x06, 0xAB, 0x06, 0x70,
+  0x91, 0xBE, 0x02, 0x79, 0xB1, 0x14, 0x9C, 0xD0, 0x0B, 0x92, 0xD5, 0xC4, 0xF1, 0xEC, 0x23, 0x90, 0x95, 0xCB, 0x7D, 0x59,
+  0x62, 0x3B, 0x30, 0xFE, 0xCF, 0x05, 0xBE, 0x04, 0xC9, 0x78, 0x5C
+};
+
+const uint8_t ID2_KEY2_CERT1[] = {
+  0x06, 0xFD, 0x01, 0x89, 0x07, 0x43, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61,
+  0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x32, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B, 0x2D,
+  0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x35, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43, 0x45,
+  0x52, 0x54, 0x08, 0x09, 0xFD, 0x00, 0x00, 0x01, 0x49, 0x9D, 0x59, 0xDA, 0xC0, 0x14, 0x03, 0x18, 0x01, 0x02, 0x15, 0xB2,
+  0x30, 0x81, 0xAF, 0x30, 0x22, 0x18, 0x0F, 0x32, 0x30, 0x31, 0x34, 0x31, 0x31, 0x31, 0x31, 0x30, 0x35, 0x33, 0x35, 0x35,
+  0x32, 0x5A, 0x18, 0x0F, 0x32, 0x30, 0x33, 0x34, 0x31, 0x31, 0x30, 0x36, 0x30, 0x35, 0x33, 0x35, 0x35, 0x32, 0x5A, 0x30,
+  0x2E, 0x30, 0x2C, 0x06, 0x03, 0x55, 0x04, 0x29, 0x13, 0x25, 0x2F, 0x70, 0x69, 0x62, 0x2F, 0x69, 0x6E, 0x74, 0x65, 0x72,
+  0x66, 0x61, 0x63, 0x65, 0x2F, 0x69, 0x64, 0x2F, 0x32, 0x2F, 0x6B, 0x73, 0x6B, 0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38,
+  0x34, 0x31, 0x35, 0x32, 0x30, 0x30, 0x30, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01,
+  0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x6C, 0x49, 0x20, 0x7E, 0x59, 0xAF,
+  0x48, 0x1C, 0x9B, 0xCB, 0x67, 0xD4, 0x6F, 0x43, 0x9D, 0xD8, 0xB5, 0x36, 0xDB, 0x72, 0xDA, 0x37, 0x55, 0x4B, 0x8C, 0x69,
+  0x17, 0x87, 0xF6, 0x06, 0xAB, 0x06, 0x70, 0x91, 0xBE, 0x02, 0x79, 0xB1, 0x14, 0x9C, 0xD0, 0x0B, 0x92, 0xD5, 0xC4, 0xF1,
+  0xEC, 0x23, 0x90, 0x95, 0xCB, 0x7D, 0x59, 0x62, 0x3B, 0x30, 0xFE, 0xCF, 0x05, 0xBE, 0x04, 0xC9, 0x78, 0x5C, 0x16, 0x3F,
+  0x1B, 0x01, 0x03, 0x1C, 0x3A, 0x07, 0x38, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66,
+  0x61, 0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x32, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B,
+  0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x35, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43,
+  0x45, 0x52, 0x54, 0x17, 0x48, 0x30, 0x46, 0x02, 0x21, 0x00, 0xB6, 0x8E, 0x31, 0xFB, 0x08, 0x34, 0xF3, 0x1C, 0xB5, 0x09,
+  0x7D, 0xD4, 0x17, 0x45, 0xC7, 0x6A, 0x81, 0xEE, 0x6F, 0x16, 0x76, 0xEE, 0xDC, 0x44, 0xB4, 0xD7, 0x1A, 0xD5, 0x61, 0x57,
+  0x80, 0xBD, 0x02, 0x21, 0x00, 0xF7, 0xDB, 0xDF, 0x89, 0xBC, 0xE8, 0x28, 0x26, 0xF8, 0xEE, 0x74, 0x2B, 0x9C, 0xF0, 0x7F,
+  0xB8, 0x3A, 0xEE, 0xBF, 0x1F, 0x51, 0x14, 0x6A, 0x8F, 0x2E, 0x5A, 0x60, 0xD8, 0x45, 0x87, 0x62, 0x51
+};
+
+const uint8_t ID2_KEY2_CERT2[] = {
+  0x06, 0xFD, 0x01, 0x89, 0x07, 0x43, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61,
+  0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x32, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B, 0x2D,
+  0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x35, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43, 0x45,
+  0x52, 0x54, 0x08, 0x09, 0xFD, 0x00, 0x00, 0x01, 0x49, 0x9D, 0x5A, 0x01, 0xD0, 0x14, 0x03, 0x18, 0x01, 0x02, 0x15, 0xB2,
+  0x30, 0x81, 0xAF, 0x30, 0x22, 0x18, 0x0F, 0x32, 0x30, 0x31, 0x34, 0x31, 0x31, 0x31, 0x31, 0x30, 0x35, 0x33, 0x36, 0x30,
+  0x32, 0x5A, 0x18, 0x0F, 0x32, 0x30, 0x33, 0x34, 0x31, 0x31, 0x30, 0x36, 0x30, 0x35, 0x33, 0x36, 0x30, 0x32, 0x5A, 0x30,
+  0x2E, 0x30, 0x2C, 0x06, 0x03, 0x55, 0x04, 0x29, 0x13, 0x25, 0x2F, 0x70, 0x69, 0x62, 0x2F, 0x69, 0x6E, 0x74, 0x65, 0x72,
+  0x66, 0x61, 0x63, 0x65, 0x2F, 0x69, 0x64, 0x2F, 0x32, 0x2F, 0x6B, 0x73, 0x6B, 0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38,
+  0x34, 0x31, 0x35, 0x32, 0x30, 0x30, 0x30, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, 0x01,
+  0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x6C, 0x49, 0x20, 0x7E, 0x59, 0xAF,
+  0x48, 0x1C, 0x9B, 0xCB, 0x67, 0xD4, 0x6F, 0x43, 0x9D, 0xD8, 0xB5, 0x36, 0xDB, 0x72, 0xDA, 0x37, 0x55, 0x4B, 0x8C, 0x69,
+  0x17, 0x87, 0xF6, 0x06, 0xAB, 0x06, 0x70, 0x91, 0xBE, 0x02, 0x79, 0xB1, 0x14, 0x9C, 0xD0, 0x0B, 0x92, 0xD5, 0xC4, 0xF1,
+  0xEC, 0x23, 0x90, 0x95, 0xCB, 0x7D, 0x59, 0x62, 0x3B, 0x30, 0xFE, 0xCF, 0x05, 0xBE, 0x04, 0xC9, 0x78, 0x5C, 0x16, 0x3F,
+  0x1B, 0x01, 0x03, 0x1C, 0x3A, 0x07, 0x38, 0x08, 0x03, 0x70, 0x69, 0x62, 0x08, 0x09, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x66,
+  0x61, 0x63, 0x65, 0x08, 0x02, 0x69, 0x64, 0x08, 0x01, 0x32, 0x08, 0x03, 0x4B, 0x45, 0x59, 0x08, 0x11, 0x6B, 0x73, 0x6B,
+  0x2D, 0x31, 0x34, 0x31, 0x35, 0x36, 0x38, 0x34, 0x31, 0x35, 0x32, 0x30, 0x30, 0x30, 0x08, 0x07, 0x49, 0x44, 0x2D, 0x43,
+  0x45, 0x52, 0x54, 0x17, 0x48, 0x30, 0x46, 0x02, 0x21, 0x00, 0x9E, 0xA1, 0x49, 0xCB, 0x99, 0xB8, 0xB9, 0xD0, 0x86, 0x93,
+  0xB1, 0x5A, 0xD5, 0xAE, 0x2D, 0x32, 0xE8, 0xC1, 0x3F, 0x9E, 0x35, 0x7A, 0x45, 0xD7, 0x2F, 0x79, 0xE3, 0x76, 0x04, 0xCD,
+  0x66, 0x70, 0x02, 0x21, 0x00, 0x99, 0x04, 0x0A, 0x35, 0x3B, 0x53, 0x1B, 0x13, 0x14, 0xAC, 0xB5, 0x8E, 0x6F, 0x1A, 0x72,
+  0x2C, 0x3D, 0x86, 0xCF, 0xF6, 0x8D, 0x2F, 0x13, 0x60, 0x28, 0xB1, 0x13, 0xFE, 0x49, 0x3B, 0xA4, 0xAD
+};
+
+PibDataFixture::PibDataFixture()
+  : id1("/pib/interface/id/1")
+  , id2("/pib/interface/id/2")
+  , id1Key1Name("/pib/interface/id/1/ksk-1415684132000")
+  , id1Key2Name("/pib/interface/id/1/ksk-1415684152000")
+  , id2Key1Name("/pib/interface/id/2/ksk-1415684132000")
+  , id2Key2Name("/pib/interface/id/2/ksk-1415684152000")
+  , id1Key1(ID1_KEY1, sizeof(ID1_KEY1))
+  , id1Key2(ID1_KEY2, sizeof(ID1_KEY2))
+  , id2Key1(ID2_KEY1, sizeof(ID2_KEY1))
+  , id2Key2(ID2_KEY2, sizeof(ID2_KEY2))
+  , id1Key1Cert1(Block(ID1_KEY1_CERT1, sizeof(ID1_KEY1_CERT1)))
+  , id1Key1Cert2(Block(ID1_KEY1_CERT2, sizeof(ID1_KEY1_CERT2)))
+  , id1Key2Cert1(Block(ID1_KEY2_CERT1, sizeof(ID1_KEY2_CERT1)))
+  , id1Key2Cert2(Block(ID1_KEY2_CERT2, sizeof(ID1_KEY2_CERT2)))
+  , id2Key1Cert1(Block(ID2_KEY1_CERT1, sizeof(ID2_KEY1_CERT1)))
+  , id2Key1Cert2(Block(ID2_KEY1_CERT2, sizeof(ID2_KEY1_CERT2)))
+  , id2Key2Cert1(Block(ID2_KEY2_CERT1, sizeof(ID2_KEY2_CERT1)))
+  , id2Key2Cert2(Block(ID2_KEY2_CERT2, sizeof(ID2_KEY2_CERT2)))
+{
+}
+
+} // namespace tests
+} // namespace security
+} // namespace ndn
diff --git a/tests/unit-tests/security/pib/pib-data-fixture.hpp b/tests/unit-tests/security/pib/pib-data-fixture.hpp
new file mode 100644
index 0000000..2971cd5
--- /dev/null
+++ b/tests/unit-tests/security/pib/pib-data-fixture.hpp
@@ -0,0 +1,66 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#ifndef NDN_TESTS_SECURITY_PIB_DATA_FIXTURE_HPP
+#define NDN_TESTS_SECURITY_PIB_DATA_FIXTURE_HPP
+
+#include "security/v1/identity-certificate.hpp"
+
+#include "boost-test.hpp"
+
+namespace ndn {
+namespace security {
+namespace tests {
+
+class PibDataFixture
+{
+public:
+  PibDataFixture();
+
+public:
+  Name id1;
+  Name id2;
+
+  Name id1Key1Name;
+  Name id1Key2Name;
+  Name id2Key1Name;
+  Name id2Key2Name;
+
+  v1::PublicKey id1Key1;
+  v1::PublicKey id1Key2;
+  v1::PublicKey id2Key1;
+  v1::PublicKey id2Key2;
+
+  v1::IdentityCertificate id1Key1Cert1;
+  v1::IdentityCertificate id1Key1Cert2;
+  v1::IdentityCertificate id1Key2Cert1;
+  v1::IdentityCertificate id1Key2Cert2;
+  v1::IdentityCertificate id2Key1Cert1;
+  v1::IdentityCertificate id2Key1Cert2;
+  v1::IdentityCertificate id2Key2Cert1;
+  v1::IdentityCertificate id2Key2Cert2;
+};
+
+} // namespace tests
+} // namespace security
+} // namespace ndn
+
+#endif // NDN_TESTS_SECURITY_PIB_DATA_FIXTURE_HPP
diff --git a/tests/unit-tests/security/pib/pib-impl.t.cpp b/tests/unit-tests/security/pib/pib-impl.t.cpp
new file mode 100644
index 0000000..9a0e85f
--- /dev/null
+++ b/tests/unit-tests/security/pib/pib-impl.t.cpp
@@ -0,0 +1,236 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "security/pib/pib-memory.hpp"
+#include "security/pib/pib-sqlite3.hpp"
+#include "security/pib/pib.hpp"
+
+#include "boost-test.hpp"
+#include "pib-data-fixture.hpp"
+
+#include <boost/filesystem.hpp>
+#include <boost/mpl/list.hpp>
+
+namespace ndn {
+namespace security {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(Security)
+BOOST_AUTO_TEST_SUITE(TestPib)
+BOOST_AUTO_TEST_SUITE(TestPibImpl)
+
+class PibMemoryWrapper
+{
+public:
+  PibMemory impl;
+};
+
+class PibSqlite3Wrapper
+{
+public:
+  PibSqlite3Wrapper()
+    : tmpPath(boost::filesystem::path(UNIT_TEST_CONFIG_PATH) / "DbTest")
+    , impl(tmpPath.c_str())
+  {
+  }
+
+  ~PibSqlite3Wrapper()
+  {
+    boost::filesystem::remove_all(tmpPath);
+  }
+
+public:
+  boost::filesystem::path tmpPath;
+  PibSqlite3 impl;
+};
+
+typedef boost::mpl::list<PibMemoryWrapper,
+                         PibSqlite3Wrapper> PibImpls;
+
+BOOST_FIXTURE_TEST_CASE_TEMPLATE(IdentityManagement, T, PibImpls, PibDataFixture)
+{
+  T wrapper;
+  PibImpl& pibImpl = wrapper.impl;
+
+  // no default setting, throw Error
+  BOOST_CHECK_THROW(pibImpl.getDefaultIdentity(), Pib::Error);
+
+  // check id1, which should not exist
+  BOOST_CHECK_EQUAL(pibImpl.hasIdentity(id1), false);
+
+  // add id1, should be default
+  pibImpl.addIdentity(id1);
+  BOOST_CHECK_EQUAL(pibImpl.hasIdentity(id1), true);
+  BOOST_CHECK_NO_THROW(pibImpl.getDefaultIdentity());
+  BOOST_CHECK_EQUAL(pibImpl.getDefaultIdentity(), id1);
+
+  // add id2, should not be default
+  pibImpl.addIdentity(id2);
+  BOOST_CHECK_EQUAL(pibImpl.hasIdentity(id2), true);
+  BOOST_CHECK_EQUAL(pibImpl.getDefaultIdentity(), id1);
+
+  // set id2 explicitly as default
+  pibImpl.setDefaultIdentity(id2);
+  BOOST_CHECK_EQUAL(pibImpl.getDefaultIdentity(), id2);
+
+  // remove id2, should not have default identity
+  pibImpl.removeIdentity(id2);
+  BOOST_CHECK_EQUAL(pibImpl.hasIdentity(id2), false);
+  BOOST_CHECK_THROW(pibImpl.getDefaultIdentity(), Pib::Error);
+
+  // add id2 again, should be default
+  pibImpl.addIdentity(id2);
+  BOOST_CHECK_EQUAL(pibImpl.getDefaultIdentity(), id2);
+
+  // get all identities, should contain id1 and id2
+  std::set<Name> idNames = pibImpl.getIdentities();
+  BOOST_CHECK_EQUAL(idNames.size(), 2);
+  BOOST_CHECK_EQUAL(idNames.count(id1), 1);
+  BOOST_CHECK_EQUAL(idNames.count(id2), 1);
+}
+
+BOOST_FIXTURE_TEST_CASE_TEMPLATE(KeyManagement, T, PibImpls, PibDataFixture)
+{
+  T wrapper;
+  PibImpl& pibImpl = wrapper.impl;
+
+  // no default setting, throw Error
+  BOOST_CHECK_THROW(pibImpl.getDefaultKeyOfIdentity(id1), Pib::Error);
+
+  // check id1Key1, should not exist, neither should id1.
+  BOOST_CHECK_EQUAL(pibImpl.hasKey(id1, id1Key1Name.get(-1)), false);
+  BOOST_CHECK_EQUAL(pibImpl.hasIdentity(id1), false);
+
+  // add id1Key1, should be default, id1 should be added implicitly
+  pibImpl.addKey(id1, id1Key1Name.get(-1), id1Key1);
+  BOOST_CHECK_EQUAL(pibImpl.hasKey(id1, id1Key1Name.get(-1)), true);
+  BOOST_CHECK_EQUAL(pibImpl.hasIdentity(id1), true);
+  const v1::PublicKey& keyBits = pibImpl.getKeyBits(id1, id1Key1Name.get(-1));
+  BOOST_CHECK_EQUAL_COLLECTIONS(keyBits.get().buf(), keyBits.get().buf() + keyBits.get().size(),
+                                id1Key1.get().buf(), id1Key1.get().buf() + id1Key1.get().size());
+  BOOST_CHECK_NO_THROW(pibImpl.getDefaultKeyOfIdentity(id1));
+  BOOST_CHECK_EQUAL(pibImpl.getDefaultKeyOfIdentity(id1), id1Key1Name.get(-1));
+
+  // add id1Key2, should not be default
+  pibImpl.addKey(id1, id1Key2Name.get(-1), id1Key2);
+  BOOST_CHECK_EQUAL(pibImpl.hasKey(id1, id1Key2Name.get(-1)), true);
+  BOOST_CHECK_EQUAL(pibImpl.getDefaultKeyOfIdentity(id1), id1Key1Name.get(-1));
+
+  // set id1Key2 explicitly as default
+  pibImpl.setDefaultKeyOfIdentity(id1, id1Key2Name.get(-1));
+  BOOST_CHECK_EQUAL(pibImpl.getDefaultKeyOfIdentity(id1), id1Key2Name.get(-1));
+
+  // set a non-existing key as default, throw Error
+  BOOST_CHECK_THROW(pibImpl.setDefaultKeyOfIdentity(id1, name::Component("non-existing")),
+                    Pib::Error);
+
+  // remove id1Key2, should not have default key
+  pibImpl.removeKey(id1, id1Key2Name.get(-1));
+  BOOST_CHECK_EQUAL(pibImpl.hasKey(id1, id1Key2Name.get(-1)), false);
+  BOOST_CHECK_THROW(pibImpl.getKeyBits(id1, id1Key2Name.get(-1)), Pib::Error);
+  BOOST_CHECK_THROW(pibImpl.getDefaultKeyOfIdentity(id1), Pib::Error);
+
+  // add id1Key2 back, should be default
+  pibImpl.addKey(id1, id1Key2Name.get(-1), id1Key2);
+  BOOST_CHECK_NO_THROW(pibImpl.getKeyBits(id1, id1Key2Name.get(-1)));
+  BOOST_CHECK_EQUAL(pibImpl.getDefaultKeyOfIdentity(id1), id1Key2Name.get(-1));
+
+  // get all the keys: id1Key1 and id1Key2
+  std::set<name::Component> keyNames = pibImpl.getKeysOfIdentity(id1);
+  BOOST_CHECK_EQUAL(keyNames.size(), 2);
+  BOOST_CHECK_EQUAL(keyNames.count(id1Key1Name.get(-1)), 1);
+  BOOST_CHECK_EQUAL(keyNames.count(id1Key2Name.get(-1)), 1);
+
+  // remove id1, should remove all the keys
+  pibImpl.removeIdentity(id1);
+  keyNames = pibImpl.getKeysOfIdentity(id1);
+  BOOST_CHECK_EQUAL(keyNames.size(), 0);
+}
+
+BOOST_FIXTURE_TEST_CASE_TEMPLATE(CertificateManagement, T, PibImpls, PibDataFixture)
+{
+  T wrapper;
+  PibImpl& pibImpl = wrapper.impl;
+
+  // no default setting, throw Error
+  BOOST_CHECK_THROW(pibImpl.getDefaultCertificateOfKey(id1, id1Key1Name.get(-1)), Pib::Error);
+
+  // check id1Key1Cert1, should not exist, neither should id1 and id1Key1
+  BOOST_CHECK_EQUAL(pibImpl.hasCertificate(id1Key1Cert1.getName()), false);
+  BOOST_CHECK_EQUAL(pibImpl.hasIdentity(id1), false);
+  BOOST_CHECK_EQUAL(pibImpl.hasKey(id1, id1Key1Name.get(-1)), false);
+
+  // add id1Key1Cert1, should be default, id1 and id1Key1 should be added implicitly
+  pibImpl.addCertificate(id1Key1Cert1);
+  BOOST_CHECK_EQUAL(pibImpl.hasCertificate(id1Key1Cert1.getName()), true);
+  BOOST_CHECK_EQUAL(pibImpl.hasIdentity(id1), true);
+  BOOST_CHECK_EQUAL(pibImpl.hasKey(id1, id1Key1Name.get(-1)), true);
+  const v1::IdentityCertificate& cert = pibImpl.getCertificate(id1Key1Cert1.getName());
+  BOOST_CHECK_EQUAL_COLLECTIONS(cert.wireEncode().wire(),
+                                cert.wireEncode().wire() + cert.wireEncode().size(),
+                                id1Key1Cert1.wireEncode().wire(),
+                                id1Key1Cert1.wireEncode().wire() + id1Key1Cert1.wireEncode().size());
+  BOOST_CHECK_NO_THROW(pibImpl.getDefaultCertificateOfKey(id1, id1Key1Name.get(-1)));
+  BOOST_CHECK_EQUAL(pibImpl.getDefaultCertificateOfKey(id1, id1Key1Name.get(-1)), id1Key1Cert1);
+
+  // add id1Key1Cert2, should not be default
+  pibImpl.addCertificate(id1Key1Cert2);
+  BOOST_CHECK_EQUAL(pibImpl.hasCertificate(id1Key1Cert2.getName()), true);
+  BOOST_CHECK_EQUAL(pibImpl.getDefaultCertificateOfKey(id1, id1Key1Name.get(-1)), id1Key1Cert1);
+
+  // set id1Key1Cert2 explicitly as default
+  pibImpl.setDefaultCertificateOfKey(id1, id1Key1Name.get(-1), id1Key1Cert2.getName());
+  BOOST_CHECK_EQUAL(pibImpl.getDefaultCertificateOfKey(id1, id1Key1Name.get(-1)), id1Key1Cert2);
+
+  // set a non-existing cert as default, throw Error
+  BOOST_CHECK_THROW(pibImpl.setDefaultCertificateOfKey(id1, id1Key1Name.get(-1), Name("/non-existing")),
+                    Pib::Error);
+
+  // remove id1Key1Cert2, should not have default cert
+  pibImpl.removeCertificate(id1Key1Cert2.getName());
+  BOOST_CHECK_EQUAL(pibImpl.hasCertificate(id1Key1Cert2.getName()), false);
+  BOOST_CHECK_THROW(pibImpl.getCertificate(id1Key1Cert2.getName()), Pib::Error);
+  BOOST_CHECK_THROW(pibImpl.getDefaultCertificateOfKey(id1, id1Key1Name.get(-1)), Pib::Error);
+
+  // add id1Key1Cert2, should be default
+  pibImpl.addCertificate(id1Key1Cert2);
+  BOOST_CHECK_NO_THROW(pibImpl.getCertificate(id1Key1Cert1.getName()));
+  BOOST_CHECK_EQUAL(pibImpl.getDefaultCertificateOfKey(id1, id1Key1Name.get(-1)), id1Key1Cert2);
+
+  // get all certificates: id1Key1Cert1 and id1Key1Cert2
+  std::set<Name> certNames = pibImpl.getCertificatesOfKey(id1, id1Key1Name.get(-1));
+  BOOST_CHECK_EQUAL(certNames.size(), 2);
+  BOOST_CHECK_EQUAL(certNames.count(id1Key1Cert1.getName()), 1);
+  BOOST_CHECK_EQUAL(certNames.count(id1Key1Cert2.getName()), 1);
+
+  // remove id1Key1, should remove all the certs
+  pibImpl.removeKey(id1, id1Key1Name.get(-1));
+  certNames = pibImpl.getCertificatesOfKey(id1, id1Key1Name.get(-1));
+  BOOST_CHECK_EQUAL(certNames.size(), 0);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestPibImpl
+BOOST_AUTO_TEST_SUITE_END() // TestPib
+BOOST_AUTO_TEST_SUITE_END() // Security
+
+} // namespace tests
+} // namespace security
+} // namespace ndn
diff --git a/tests/unit-tests/security/pib/pib-memory.t.cpp b/tests/unit-tests/security/pib/pib-memory.t.cpp
new file mode 100644
index 0000000..9d2c3f8
--- /dev/null
+++ b/tests/unit-tests/security/pib/pib-memory.t.cpp
@@ -0,0 +1,49 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "security/pib/pib-memory.hpp"
+
+#include "boost-test.hpp"
+
+namespace ndn {
+namespace security {
+namespace tests {
+
+// most functionalities are tested in pib-impl.t.cpp
+BOOST_AUTO_TEST_SUITE(Security)
+BOOST_AUTO_TEST_SUITE(TestPib)
+BOOST_AUTO_TEST_SUITE(TestPibMemory)
+
+BOOST_AUTO_TEST_CASE(TpmLocatorManagement)
+{
+  PibMemory pibImpl;
+
+  BOOST_CHECK_EQUAL(pibImpl.getTpmLocator(), "tpm-memory:");
+  BOOST_CHECK_THROW(pibImpl.setTpmLocator(""), PibImpl::Error);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestPibMemory
+BOOST_AUTO_TEST_SUITE_END() // TestPib
+BOOST_AUTO_TEST_SUITE_END() // Security
+
+} // namespace tests
+} // namespace security
+} // namespace ndn
diff --git a/tests/unit-tests/security/pib/pib-sqlite3.t.cpp b/tests/unit-tests/security/pib/pib-sqlite3.t.cpp
new file mode 100644
index 0000000..7055a37
--- /dev/null
+++ b/tests/unit-tests/security/pib/pib-sqlite3.t.cpp
@@ -0,0 +1,129 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "security/pib/pib-sqlite3.hpp"
+#include "security/pib/pib.hpp"
+
+#include "boost-test.hpp"
+
+#include <boost/filesystem.hpp>
+
+namespace ndn {
+namespace security {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(Security)
+BOOST_AUTO_TEST_SUITE(TestPib)
+
+class PibSqlite3TestFixture
+{
+public:
+  PibSqlite3TestFixture()
+    : m_path(boost::filesystem::path(UNIT_TEST_CONFIG_PATH) / "DbTest")
+    , impl(m_path.c_str())
+  {
+  }
+
+  ~PibSqlite3TestFixture()
+  {
+    boost::filesystem::remove_all(m_path);
+  }
+
+private:
+  boost::filesystem::path m_path;
+
+public:
+  PibSqlite3 impl;
+};
+
+BOOST_FIXTURE_TEST_SUITE(TestPibSqlite3, PibSqlite3TestFixture)
+
+// most functionalities are tested in pib-impl.t.cpp
+
+const uint8_t SELF_SIGNED_ECDSA_CERT[] = {
+0x06, 0xfd, 0x01, 0x5b, 0x07, 0x33, 0x08, 0x05, 0x65, 0x63, 0x64, 0x73, 0x61, 0x08, 0x03,
+0x4b, 0x45, 0x59, 0x08, 0x11, 0x6b, 0x73, 0x6b, 0x2d, 0x31, 0x34, 0x31, 0x36, 0x35, 0x39,
+0x34, 0x35, 0x35, 0x32, 0x38, 0x32, 0x37, 0x08, 0x07, 0x49, 0x44, 0x2d, 0x43, 0x45, 0x52,
+0x54, 0x08, 0x09, 0xfd, 0x00, 0x00, 0x01, 0x49, 0xd3, 0x9d, 0x78, 0x00, 0x14, 0x03, 0x18,
+0x01, 0x02, 0x15, 0xa5, 0x30, 0x81, 0xa2, 0x30, 0x22, 0x18, 0x0f, 0x32, 0x30, 0x31, 0x34,
+0x31, 0x31, 0x32, 0x31, 0x31, 0x38, 0x32, 0x39, 0x31, 0x32, 0x5a, 0x18, 0x0f, 0x32, 0x30,
+0x33, 0x34, 0x31, 0x31, 0x31, 0x36, 0x31, 0x38, 0x32, 0x39, 0x31, 0x32, 0x5a, 0x30, 0x21,
+0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x29, 0x13, 0x18, 0x2f, 0x65, 0x63, 0x64, 0x73, 0x61,
+0x2f, 0x6b, 0x73, 0x6b, 0x2d, 0x31, 0x34, 0x31, 0x36, 0x35, 0x39, 0x34, 0x35, 0x35, 0x32,
+0x38, 0x32, 0x37, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
+0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04,
+0x83, 0xe5, 0x81, 0x19, 0xd9, 0xfa, 0x64, 0x40, 0xad, 0x7c, 0x93, 0xfc, 0x15, 0x90, 0x6b,
+0x38, 0x1e, 0xc5, 0xca, 0xb1, 0x6b, 0x0b, 0x1f, 0x64, 0xbf, 0x48, 0xaa, 0xd0, 0x91, 0x5c,
+0x24, 0xd6, 0x78, 0x40, 0xfd, 0x95, 0x5d, 0x54, 0x64, 0xe1, 0x2d, 0x0e, 0x98, 0x66, 0x1d,
+0x7a, 0xb0, 0x61, 0x17, 0x05, 0x26, 0x13, 0x63, 0x25, 0x7c, 0xda, 0x87, 0x11, 0xc9, 0x67,
+0xcd, 0x12, 0x05, 0xf0, 0x16, 0x2f, 0x1b, 0x01, 0x03, 0x1c, 0x2a, 0x07, 0x28, 0x08, 0x05,
+0x65, 0x63, 0x64, 0x73, 0x61, 0x08, 0x03, 0x4b, 0x45, 0x59, 0x08, 0x11, 0x6b, 0x73, 0x6b,
+0x2d, 0x31, 0x34, 0x31, 0x36, 0x35, 0x39, 0x34, 0x35, 0x35, 0x32, 0x38, 0x32, 0x37, 0x08,
+0x07, 0x49, 0x44, 0x2d, 0x43, 0x45, 0x52, 0x54, 0x17, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00,
+0x9b, 0xae, 0xf4, 0x87, 0x55, 0xaa, 0x78, 0xbf, 0x00, 0xff, 0x1a, 0xbe, 0x90, 0x46, 0x6e,
+0xdd, 0xe6, 0x3b, 0x44, 0xfd, 0x41, 0x04, 0x86, 0xcc, 0x6a, 0x8b, 0x5a, 0x25, 0xbb, 0xf1,
+0x55, 0xcd, 0x02, 0x20, 0x0e, 0x67, 0xd8, 0x86, 0xe8, 0x7c, 0x90, 0x3c, 0x13, 0xfd, 0x36,
+0x9c, 0xbc, 0xa1, 0xc3, 0x7c, 0xe0, 0x0c, 0x6d, 0x64, 0xac, 0xdb, 0x69, 0x99, 0xde, 0x80,
+0x35, 0x3f, 0xf4, 0x6a, 0xcd, 0x6f
+};
+
+BOOST_AUTO_TEST_CASE(TpmTest)
+{
+  Block selfSignedCertBlock(SELF_SIGNED_ECDSA_CERT, sizeof(SELF_SIGNED_ECDSA_CERT));
+  v1::IdentityCertificate cert;
+  cert.wireDecode(selfSignedCertBlock);
+  Name identity = cert.getPublicKeyName().getPrefix(-1);
+  name::Component keyId = cert.getPublicKeyName().get(-1);
+  Name certName = cert.getName();
+
+  // Basic getting and setting
+  BOOST_REQUIRE_THROW(impl.getTpmLocator(), Pib::Error);
+  impl.setTpmLocator("tpmLocator");
+  BOOST_CHECK_EQUAL(impl.getTpmLocator(), "tpmLocator");
+
+  // Add cert, and do not change tpmLocator
+  impl.addCertificate(cert);
+  BOOST_CHECK(impl.hasIdentity(identity));
+  BOOST_CHECK(impl.hasKey(identity, keyId));
+  BOOST_CHECK(impl.hasCertificate(certName));
+
+  // Set tpmLocator with the existing value, nothing should change.
+  impl.setTpmLocator("tpmLocator");
+  BOOST_CHECK(impl.hasIdentity(identity));
+  BOOST_CHECK(impl.hasKey(identity, keyId));
+  BOOST_CHECK(impl.hasCertificate(certName));
+
+  // Change tpmLocator and ensure the pib is reset
+  impl.setTpmLocator("newTpmLocator");
+  BOOST_CHECK_EQUAL(impl.getTpmLocator(), "newTpmLocator");
+
+  BOOST_CHECK_EQUAL(impl.getIdentities().size(), 0);
+  BOOST_CHECK_EQUAL(impl.getKeysOfIdentity(identity).size(), 0);
+  BOOST_CHECK_EQUAL(impl.getCertificatesOfKey(identity, keyId).size(), 0);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestPibSqlite3
+BOOST_AUTO_TEST_SUITE_END() // TestPib
+BOOST_AUTO_TEST_SUITE_END() // Security
+
+} // namespace tests
+} // namespace security
+} // namespace ndn
diff --git a/tests/unit-tests/security/pib/pib.t.cpp b/tests/unit-tests/security/pib/pib.t.cpp
new file mode 100644
index 0000000..7c6b47f
--- /dev/null
+++ b/tests/unit-tests/security/pib/pib.t.cpp
@@ -0,0 +1,89 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2016 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "security/pib/pib.hpp"
+#include "security/pib/pib-memory.hpp"
+
+#include "boost-test.hpp"
+#include "pib-data-fixture.hpp"
+
+namespace ndn {
+namespace security {
+namespace tests {
+
+BOOST_AUTO_TEST_SUITE(Security)
+BOOST_AUTO_TEST_SUITE(TestPib)
+BOOST_FIXTURE_TEST_SUITE(Common, PibDataFixture)
+
+BOOST_AUTO_TEST_CASE(ValidityChecking)
+{
+  auto pibImpl = make_shared<PibMemory>();
+  Pib pib("pib-memory", "", pibImpl);
+
+  Identity id = pib.addIdentity(id1);
+
+  BOOST_CHECK_EQUAL(bool(id), true);
+  BOOST_CHECK_EQUAL(!id, false);
+
+  if (id)
+    BOOST_CHECK(true);
+  else
+    BOOST_CHECK(false);
+
+  // key
+  Key key = id.addKey(id1Key1, id1Key1Name.get(-1));
+
+  BOOST_CHECK_EQUAL(bool(key), true);
+  BOOST_CHECK_EQUAL(!key, false);
+
+  if (key)
+    BOOST_CHECK(true);
+  else
+    BOOST_CHECK(false);
+}
+
+BOOST_AUTO_TEST_CASE(IdentityOperations)
+{
+  auto pibImpl = make_shared<PibMemory>();
+  Pib pib("pib-memory", "", pibImpl);
+
+  BOOST_CHECK_THROW(pib.getIdentity(id1), Pib::Error);
+  Identity identity1 = pib.addIdentity(id1);
+  BOOST_CHECK_NO_THROW(pib.getIdentity(id1));
+  pib.removeIdentity(id1);
+  BOOST_CHECK_THROW(pib.getIdentity(id1), Pib::Error);
+
+  BOOST_CHECK_THROW(pib.getDefaultIdentity(), Pib::Error);
+  BOOST_REQUIRE_NO_THROW(pib.setDefaultIdentity(id1));
+  BOOST_REQUIRE_NO_THROW(pib.getDefaultIdentity());
+  BOOST_CHECK_EQUAL(pib.getDefaultIdentity().getName(), id1);
+  pib.removeIdentity(id1);
+  BOOST_CHECK_THROW(pib.getIdentity(id1), Pib::Error);
+  BOOST_CHECK_THROW(pib.getDefaultIdentity(), Pib::Error);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // Common
+BOOST_AUTO_TEST_SUITE_END() // TestPib
+BOOST_AUTO_TEST_SUITE_END() // Security
+
+} // namespace tests
+} // namespace security
+} // namespace ndn