security: Adding supports to signed interest
refs: #1161
Change-Id: I042381b171d44417f296397d872cd639935a89e9
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index f881c8e..bad73a2 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -245,4 +245,27 @@
Tlv::readVarNumber(m_value_begin, m_value_end);
}
+Block
+Block::blockFromValue() const
+{
+ if (value_size()==0)
+ throw Error("Underlying value buffer is empty");
+
+ Buffer::const_iterator begin = value_begin(),
+ end = value_end();
+
+ Buffer::const_iterator element_begin = begin;
+
+ uint32_t type = Tlv::readType(begin, end);
+ uint64_t length = Tlv::readVarNumber(begin, end);
+
+ if (end-begin != length)
+ throw Tlv::Error("TLV length mismatches buffer length");
+
+ return Block(m_buffer,
+ type,
+ element_begin, end,
+ begin, end);
+}
+
} // namespace ndn