diff --git a/ccnx/ccnx-key.cc b/ccnx/ccnx-key.cc
new file mode 100644
index 0000000..19dc84d
--- /dev/null
+++ b/ccnx/ccnx-key.cc
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+#include "ccnx-key.h"
+#include <tinyxml.h>
+#include <boost/lexical_cast.hpp>
+#include "logging.h"
+
+INIT_LOGGER ("Ccnx.Key");
+
+using namespace std;
+
+namespace Ccnx {
+
+Key::Key()
+    : m_meta("", "",  0, 0)
+{
+}
+
+Key::Key(const PcoPtr &keyObject, const PcoPtr &metaObject = PcoPtr())
+    : m_meta("", "", 0, 0)
+{
+  m_name = keyObject->name();
+  m_raw = keyObject->content();
+  m_hash = *(Hash::FromString(string((const char *)head(m_raw), m_raw.size())));
+  updateMeta(metaObject);
+}
+
+void
+Key::updateMeta(const PcoPtr &metaObject)
+{
+  if (metaObject)
+  {
+    TiXmlDocument doc;
+    Bytes xml = metaObject->content();
+    // just make sure it's null terminated as it's required by TiXmlDocument::parse
+    xml.push_back('\0');
+    doc.Parse((const char *)(head(xml)));
+    if (!doc.Error())
+    {
+      TiXmlElement *root = doc.RootElement();
+      for (TiXmlElement *child = root->FirstChildElement(); child; child = child->NextSiblingElement())
+      {
+        const char *elemName = child->Value();
+        const char *text = child->GetText();
+        if (elemName == "Name")
+        {
+          m_meta.realworldID = text;
+        }
+        else if (elemName == "Affiliation")
+        {
+          m_meta.affiliation = text;
+        }
+        else if (elemName == "Valid_to")
+        {
+          m_meta.validTo = boost::lexical_cast<time_t>(std::string(text));
+        }
+        else if (elemName == "Valid_from")
+        {
+          // this is not included in the key meta yet
+          // but it should eventually be there
+        }
+        else
+        {
+          // ignore known stuff
+        }
+      }
+    }
+    else
+    {
+      _LOG_ERROR("Cannot parse meta info:" << std::string(head(xml), xml.size()));
+    }
+  }
+}
+
+Key::VALIDITY
+Key::validity()
+{
+  if (m_meta.validFrom == 0 && m_meta.validTo == 0)
+  {
+    return OTHER;
+  }
+
+  time_t now = time(NULL);
+  if (now < m_meta.validFrom)
+  {
+    return NOT_YET_VALID;
+  }
+
+  if (now >= m_meta.validTo)
+  {
+    return EXPIRED;
+  }
+
+  return VALID;
+}
+
+} // Ccnx
