def load_escrow_key_cache(): """ populate escrow key cache with everything in SPIDEROAK_ESCROW_KEYS_PATH """ #print "loading keys in %s" % _ESCROW_KEYS_PATH # TODO perhaps memcache this w/ short (30m?) expire. for name in os.listdir(_ESCROW_KEYS_PATH): if not name.endswith(".key"): continue filename_key_id = name[0:-4] if filename_key_id in _ESCROW_KEYS_CACHE: continue keypath = os.path.join(_ESCROW_KEYS_PATH, name) with open(keypath, "rb") as fobj: key_id, key = load(fobj) assert filename_key_id == key_id # The below is necessary to get around a cerealizer issue in Python 2.7. if getattr(key, '_randfunc', None) is None: key._randfunc = Random.new().read # pylint: disable=W0212 _ESCROW_KEYS_CACHE[key_id] = key #print "Loaded %s" % key_id return True
def load_keypair(key_id): "load and return keypair for key id" key_fn = os.path.join(_ESCROW_KEYS_PATH, "%s.key" % (key_id, )) with open(key_fn, "rb") as fobj: stored_key_id, keypair = load(fobj) assert key_id == stored_key_id return keypair
def load_escrow_key_cache(): """ populate escrow key cache with everything in SPIDEROAK_ESCROW_KEYS_PATH """ #print "loading keys in %s" % _ESCROW_KEYS_PATH # TODO perhaps memcache this w/ short (30m?) expire. for name in os.listdir(_ESCROW_KEYS_PATH): if not name.endswith(".key"): continue filename_key_id = name[0:-4] if filename_key_id in _ESCROW_KEYS_CACHE: continue keypath = os.path.join(_ESCROW_KEYS_PATH, name) with open(keypath, "rb") as fobj: key_id, key = load(fobj) assert filename_key_id == key_id _ESCROW_KEYS_CACHE[key_id] = key #print "Loaded %s" % key_id return True