PyNDN: Fixing bug in Data, and adding compatibility tricks to Key and SignedInfo
diff --git a/PyNDN/Data.py b/PyNDN/Data.py
index 7e8dd56..5369380 100644
--- a/PyNDN/Data.py
+++ b/PyNDN/Data.py
@@ -101,7 +101,7 @@
# ?
pass
if value.freshnessSeconds:
- self._data.SetFreshness (ns.core.Seconds (value))
+ self._data.SetFreshness (ns.core.Seconds (value.freshnessSeconds))
if value.keyLocator:
self._data.SetKeyLocator (value._name)
else:
diff --git a/PyNDN/Key.py b/PyNDN/Key.py
index 2dc562a..842024b 100644
--- a/PyNDN/Key.py
+++ b/PyNDN/Key.py
@@ -23,8 +23,8 @@
class Key (object):
def __init__ (self):
- # self.publicKeyID = None # SHA256 hash
- self.fakeKey = None
+ self.publicKeyID = None # SHA256 hash
+ self.fakeKey = 0
def generateRSA(self, numbits):
randVar = ns.core.UniformVariable ()
@@ -49,19 +49,19 @@
def fromDER(self, private = None, public = None):
if private:
- self.fakeKey = private
+ self.fakeKey = hash(private)
elif public:
- self.fakeKey = public
+ self.fakeKey = hash(public)
def fromPEM(self, filename = None, private = None, public = None, password = None):
if filename:
f = open(filename, 'r')
- self.fakeKey = f.read ()
+ self.fakeKey = hash(f.read ())
f.close()
elif private:
- self.fakeKey = private
+ self.fakeKey = hash(private)
elif public:
- self.fakeKey = public
+ self.fakeKey = hash(public)
@staticmethod
def createFromDER (private = None, public = None):
diff --git a/PyNDN/SignedInfo.py b/PyNDN/SignedInfo.py
index cadf1e7..84941ad 100644
--- a/PyNDN/SignedInfo.py
+++ b/PyNDN/SignedInfo.py
@@ -30,13 +30,16 @@
CONTENT_NACK = ContentType.new_flag('CONTENT_NACK', 0x34008A)
class SignedInfo (object):
- def __init__(self, keyLocator = None, freshness = None, timestamp = None, type = CONTENT_DATA):
+ def __init__(self, keyLocator = None, freshness = None,
+ timestamp = None, type = CONTENT_DATA, *kw, **kwargs):
self.timestamp = timestamp
self.freshnessSeconds = freshness
self.keyLocator = keyLocator
self.type = type
+ # all other parameters are silently ignored
+
def __repr__(self):
args = []