security: move shared_ptr<PibImpl> when possible

Also rename m_impl to m_pib, since it's not a pimpl pointer.

Change-Id: I9e10ada54332318154374f61df6e387348ccc60a
diff --git a/src/security/pib/detail/key-impl.cpp b/src/security/pib/detail/key-impl.cpp
index c0cd839..e88bdac 100644
--- a/src/security/pib/detail/key-impl.cpp
+++ b/src/security/pib/detail/key-impl.cpp
@@ -29,15 +29,15 @@
 namespace pib {
 namespace detail {
 
-KeyImpl::KeyImpl(const Name& keyName, const uint8_t* key, size_t keyLen, shared_ptr<PibImpl> impl)
+KeyImpl::KeyImpl(const Name& keyName, const uint8_t* key, size_t keyLen, shared_ptr<PibImpl> pibImpl)
   : m_identity(v2::extractIdentityFromKeyName(keyName))
   , m_keyName(keyName)
   , m_key(key, keyLen)
+  , m_pib(std::move(pibImpl))
+  , m_certificates(keyName, m_pib)
   , m_isDefaultCertificateLoaded(false)
-  , m_certificates(keyName, impl)
-  , m_impl(impl)
 {
-  BOOST_ASSERT(impl != nullptr);
+  BOOST_ASSERT(m_pib != nullptr);
 
   transform::PublicKey publicKey;
   try {
@@ -48,19 +48,19 @@
   }
   m_keyType = publicKey.getKeyType();
 
-  m_impl->addKey(m_identity, m_keyName, key, keyLen);
+  m_pib->addKey(m_identity, m_keyName, key, keyLen);
 }
 
-KeyImpl::KeyImpl(const Name& keyName, shared_ptr<PibImpl> impl)
+KeyImpl::KeyImpl(const Name& keyName, shared_ptr<PibImpl> pibImpl)
   : m_identity(v2::extractIdentityFromKeyName(keyName))
   , m_keyName(keyName)
+  , m_pib(std::move(pibImpl))
+  , m_certificates(keyName, m_pib)
   , m_isDefaultCertificateLoaded(false)
-  , m_certificates(keyName, impl)
-  , m_impl(impl)
 {
-  BOOST_ASSERT(impl != nullptr);
+  BOOST_ASSERT(m_pib != nullptr);
 
-  m_key = m_impl->getKeyBits(m_keyName);
+  m_key = m_pib->getKeyBits(m_keyName);
 
   transform::PublicKey key;
   key.loadPkcs8(m_key.buf(), m_key.size());
@@ -89,7 +89,6 @@
 KeyImpl::getCertificate(const Name& certName) const
 {
   BOOST_ASSERT(m_certificates.isConsistent());
-
   return m_certificates.get(certName);
 }
 
@@ -97,7 +96,6 @@
 KeyImpl::getCertificates() const
 {
   BOOST_ASSERT(m_certificates.isConsistent());
-
   return m_certificates;
 }
 
@@ -107,7 +105,7 @@
   BOOST_ASSERT(m_certificates.isConsistent());
 
   m_defaultCertificate = m_certificates.get(certName);
-  m_impl->setDefaultCertificateOfKey(m_keyName, certName);
+  m_pib->setDefaultCertificateOfKey(m_keyName, certName);
   m_isDefaultCertificateLoaded = true;
   return m_defaultCertificate;
 }
@@ -125,11 +123,10 @@
   BOOST_ASSERT(m_certificates.isConsistent());
 
   if (!m_isDefaultCertificateLoaded) {
-    m_defaultCertificate = m_impl->getDefaultCertificateOfKey(m_keyName);
+    m_defaultCertificate = m_pib->getDefaultCertificateOfKey(m_keyName);
     m_isDefaultCertificateLoaded = true;
   }
-
-  BOOST_ASSERT(m_impl->getDefaultCertificateOfKey(m_keyName).wireEncode() == m_defaultCertificate.wireEncode());
+  BOOST_ASSERT(m_pib->getDefaultCertificateOfKey(m_keyName).wireEncode() == m_defaultCertificate.wireEncode());
 
   return m_defaultCertificate;
 }