2
0
mirror of https://github.com/ComradCollective/Comrad synced 2024-11-05 21:20:51 +00:00
This commit is contained in:
quadrismegistus 2020-09-13 13:27:45 +01:00
parent a5cbc85528
commit 2fc9bf3fbc
2 changed files with 22 additions and 4 deletions

View File

@ -321,7 +321,7 @@ class Keymaker(Logger):
return (name,pubkey)
def keychain(self,look_for=KEYMAKER_DEFAULT_ALL_KEY_NAMES):
def keychain(self,look_for=KEYMAKER_DEFAULT_ALL_KEY_NAMES,passphrase=None):
# load existing keychain
keys = self._keychain
@ -341,7 +341,7 @@ class Keymaker(Logger):
if key: keys[keyname]=get_key_obj(keyname,key)
# try to assemble
keys = self.assemble(self.assemble(keys))
keys = self.assemble(self.assemble(keys,passphrase=passphrase),passphrase=passphrase)
#store to existing set
self._keychain = keys

View File

@ -147,6 +147,11 @@ class Komrade(Caller):
b64enc(sec_login),
prefix='/secret_login/'
)
self.crypt_keys.set(
uri_id,
privkey_encr_obj.data,
prefix='/privkey_encr/'
)
self.log(f'''Now saving name and public key on local device:''')
@ -167,11 +172,24 @@ class Komrade(Caller):
prefix='/secret/'
)
def login(self):
def login(self,passphrase=None):
# check hardware
if not self.pubkey:
self.log('''Login impossible. I do not have this komrade's public key, much less private one.''')
return
if not self.privkey:
if not self.privkey_encr:
self.log('''Login impossible. I do not have this komrade's private key on this hardware.''')
return
# check password
if not passphrase: passphrase=self.passphrase
while not passphrase:
from getpass import getpass
passphrase = getpass('@Keymaker: Enter password for {self} in order to decrypt the encrypted private key:\n\n')
# assemble privkey?
privkey = self.keychain(passphrase=passphrase).get('privkey')
if not privkey:
self.log('''Login impossible. I do not have this komrade's private key on this hardware.''')
return