return partial (fn, params)
+STATE_DEAD = 0
+STATE_LIVE = 1
class Crypto (object):
"""
stats = { "in" : 0
, "out" : 0
, "obj" : 0 }
+ state = STATE_DEAD
def __init__ (self, *al, **akv):
self.cnt = 1
return self.stats ["obj"], self.stats ["in"], self.stats ["out"]
+ def currentstate (self): return self.state
+
+
class Encrypt (Crypto):
curobj = None
self.hdrdum = hdr_make_dummy (filename)
self.stats ["obj"] += 1
+ self.state = STATE_LIVE
return self.hdrdum
self.ctsize, self.aes.tag)
if ok is False:
raise Exception ("XXX error constructing header: %r" % hdr) ## we need to converge on a sensible error handling strategy
+ self.state = STATE_DEAD
return data, hdr
ctsize = 0
ptsize = 0
self.stats ["obj"] += 1
+ self.state = STATE_LIVE
def next_in_source (self, tarinfo, source):
except crypto.cryptography.exceptions.InvalidTag as exn:
return False, repr (exn)
self.stats ["out"] += len (data)
+ self.state = STATE_DEAD
return ret, data
if hasattr(self, "closed") and not self.closed:
self.close()
#if self.encryption is not None:
+ # print("crypto: %s"
+ # % (self.encryption.currentstate () == crypto.STATE_DEAD
+ # and "inactive" or "active"))
# print("crypto: %d objects handled, %d B in, %d B out"
# % self.encryption.counters ())