src: Improving consistency and correcting code style

As of this commit, all data structures can be directly constructed from
wire format.

This commit excludes full correction of code style in security/ and
tools/ndnsec*, which will be part of a different commit.

Change-Id: I121ac1f81948bc7468990df52cdefeb2988d91a1
Refs: #1403
diff --git a/src/security/identity-certificate.cpp b/src/security/identity-certificate.cpp
index b4d5cb5..75693b0 100644
--- a/src/security/identity-certificate.cpp
+++ b/src/security/identity-certificate.cpp
@@ -20,21 +20,21 @@
   string idString("ID-CERT");
   int i = name.size() - 1;
   for (; i >= 0; i--) {
-    if(name.get(i).toEscapedString() == idString)
+    if (name.get(i).toEscapedString() == idString)
       break;
   }
 
   if (i < 0)
     return false;
-  
-  size_t keyIdx = 0;
+
   string keyString("KEY");
-  for (; keyIdx < name.size(); keyIdx++) {
-    if(name.get(keyIdx).toEscapedString() == keyString)
+  size_t keyIndex = 0;
+  for (; keyIndex < name.size(); keyIndex++) {
+    if (name.get(keyIndex).toEscapedString() == keyString)
       break;
   }
 
-  if (keyIdx >= name.size())
+  if (keyIndex >= name.size())
     return false;
 
   return true;
@@ -45,7 +45,7 @@
 {
   if (!isCorrectName(getName()))
     throw Error("Wrong Identity Certificate Name!");
-  
+
   publicKeyName_ = certificateNameToPublicKeyName(getName());
 }
 
@@ -69,9 +69,9 @@
       }
   }
 
-  if(!foundIdString)
+  if (!foundIdString)
     throw Error("Incorrect identity certificate name " + certificateName.toUri());
-    
+
   Name tmpName = certificateName.getSubName(0, idCertComponentIndex);
   string keyString("KEY");
   bool foundKeyString = false;
@@ -84,7 +84,7 @@
       }
   }
 
-  if(!foundKeyString)
+  if (!foundKeyString)
     throw Error("Incorrect identity certificate name " + certificateName.toUri());
 
   return tmpName