def do_client_read(self, client, key): creds = M.credentials.m.get(key=key, client_id=client) if not creds: print 'No such client registered for that key' return keyfile = self._keyfile(client) if keyfile is None: print '<Enc %r>' % creds.enc_creds return with path(keyfile).open() as fp: plaintext = security.decrypt( fp.read(), creds.enc_aes_key, creds.aes_iv, creds.enc_creds) data = json.loads(security.unpad(plaintext)) for k,v in sorted(data.items()): print '%s=%s' % (k,v)
def decrypt_credentials(prikey, client, enc_aes_key, aes_iv, enc_creds): plaintext = security.decrypt( prikey, enc_aes_key, aes_iv, enc_creds) return json.loads(security.unpad(plaintext))