signature-info: Fix encoding of type-specific TLV

This commit also introduces operator<< for SignatureInfo

Change-Id: Iddf5b77d9dab9f7b1764500726e6d5b1e13aedbb
Refs: #3914
diff --git a/src/signature-info.cpp b/src/signature-info.cpp
index 821d5a7..3d789dc 100644
--- a/src/signature-info.cpp
+++ b/src/signature-info.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -145,7 +145,7 @@
 
   for (std::list<Block>::const_reverse_iterator i = m_otherTlvs.rbegin();
        i != m_otherTlvs.rend(); i++) {
-    totalLength += encoder.appendBlock(*i);
+    totalLength += encoder.prependBlock(*i);
   }
 
   if (m_hasKeyLocator)
@@ -230,4 +230,21 @@
           m_otherTlvs == rhs.m_otherTlvs);
 }
 
+std::ostream&
+operator<<(std::ostream& os, const SignatureInfo& info)
+{
+  os << static_cast<tlv::SignatureTypeValue>(info.getSignatureType());
+  if (info.hasKeyLocator()) {
+    os << " " << info.getKeyLocator();
+  }
+  if (!info.m_otherTlvs.empty()) {
+    os << " { ";
+    for (const auto& block : info.m_otherTlvs) {
+      os << block.type() << " ";
+    }
+    os << "}";
+  }
+  return os;
+}
+
 } // namespace ndn