signature: Add ValidityPeriod into SignatureInfo

Change-Id: I02571a4876e2f0ccd8cc088ecc6477d20dd701cb
Refs: #2868
diff --git a/src/signature-info.cpp b/src/signature-info.cpp
index 9c1f0de..e48482e 100644
--- a/src/signature-info.cpp
+++ b/src/signature-info.cpp
@@ -91,6 +91,32 @@
 }
 
 void
+SignatureInfo::setValidityPeriod(const security::ValidityPeriod& validityPeriod)
+{
+  unsetValidityPeriod();
+  m_otherTlvs.push_front(validityPeriod.wireEncode());
+}
+
+void
+SignatureInfo::unsetValidityPeriod()
+{
+  m_wire.reset();
+  if (!m_otherTlvs.empty() && m_otherTlvs.front().type() == tlv::ValidityPeriod) {
+    m_otherTlvs.erase(m_otherTlvs.begin());
+  }
+}
+
+security::ValidityPeriod
+SignatureInfo::getValidityPeriod() const
+{
+  if (m_otherTlvs.empty() || m_otherTlvs.front().type() != tlv::ValidityPeriod) {
+    throw Error("SignatureInfo does not contain the requested ValidityPeriod field");
+  }
+
+  return security::ValidityPeriod(m_otherTlvs.front());
+}
+
+void
 SignatureInfo::appendTypeSpecificTlv(const Block& block)
 {
   m_otherTlvs.push_back(block);