keys-on-cli
quadrismegistus 4 years ago
parent 10f2b620ff
commit 0020b38d18

@ -113,27 +113,58 @@ cv = {cv}
'pubkey':cv,
'name':name,
}
if not success:
res['status']=self.status(f"{OPERATOR_INTRO}I'm sorry, but I can't register the name of {name}.")
self.log('Operator returning result:',dict_format(res,tab=2))
return res
# generate these admin keys?
admin_keys = self.forge_new_keys(
name=name,
passphrase=passphrase,
keys_to_gen = [
'adminkey',
'adminkey_encr',
'adminkey_decr'
],
keys_to_save=[
'adminkey_encr'
],
keys_to_return = [
'adminkey_decr'
],
key_types = {
'adminkey':KomradeSymmetricKeyWithoutPassphrase(),
'adminkey_encr':ENCRYPTED_KEY,
'adminkey_decr':KomradeSymmetricKeyWithPassphrase()
}
)
self.log('generated admin keys:',admin_keys)
if not admin_keys:
res['res']=False
res['status']=self.status(f"{OPERATOR_INTRO}I'm sorry, but I couldn't register {name} right now.")
return res
for key,val in admin_keys.items():
res[key]=val
## success msg
if success:
cvb64=b64encode(cv).decode()
qrstr=self.qr_str(cvb64)
self.status(f'''{OPERATOR_INTRO}I have successfully registered Komrade {name}.
If you're interested, here's what I did. I stored the public key you gave me, {cvb64}, under the name of "{name}". However, I never save that name directly, but record it only in a disguised, "hashed" form: {ck}. I scrambled "{name}" by running it through a 1-way hashing function, which will always yield the same result: provided you know which function I'm using, and what the secret "salt" is that I add to all the input, a string of text which I keep protected and encrypted on my local hard drive.
The content of your data will therefore not only be encrypted, but its location in my database is obscured even to me. There's no way for me to reverse-engineer the name of {name} from the record I stored it under, {ck}. Unless you explictly ask me for the public key of {name}, I will have no way of accessing that information.
Your name ({name}) and your public key ({cvb64}) are the first two pieces of information you've given me about yourself. Your public key is your 'address' in Komrade: in order for anyone to write to you, or for them to receive messages from you, they'll need to know your public key (and vise versa). The Komrade app should store your public key on your device as a QR code, under ~/.komrade/.contacts/{name}.png. It will look something like this:{qrstr}You can then send this image to anyone by a secure channel (Signal, IRL, etc), or tell them the code directly ({cvb64}).
By default, if anyone asks me what your public key is, I won't tell them--though I won't be able to avoid hinting that a user exists under this name should someone try to register under that name and I deny them). Instead, if the person who requested your public key insists, I will send you a message (encrypted end-to-end so only you can read it) that the user who met someone would like to introduce themselves to you; I will then send you their name and public key. It's now your move: up to you whether to save them back your public key.
If you'd like to change this default behavior, e.g. by instead allowing anyone to request your public key, except for those whom you explcitly block, I have also created a super secret administrative record for you to change various settings on your account. This is protected by a separate encryption key which I have generated for you; and this key which is itself encrypted with the password you entered earlier. Don't worry: I never saw that password you typed, since it was given to me already hashed and disguised (as something {len(passphrase)} characters long, ending in "{passphrase[:10]}"). Without that hashed passphrase, no one will be able to unlock the administration key; and without the administration key, they won't be able to find the hashed record I stored your user settings under, since I also salted that hash with your own hashed passphrase. Even if someone found the record I stored them under, they wouldn't be able to decrypt the existing settings; and if they can't do that, I won't let them overwrite the record.''')
else:
self.status(f"{OPERATOR_INTRO}I'm sorry, but I can't register the name of {name}.")
self.log('Operator returning result:',dict_format(res,tab=2))
return res
#
cvb64=b64encode(cv).decode()
qrstr=self.qr_str(cvb64)
res['status']=self.status(f'''{OPERATOR_INTRO}I have successfully registered Komrade {name}.
If you're interested, here's what I did. I stored the public key you gave me, {cvb64}, under the name of "{name}". However, I never save that name directly, but record it only in a disguised, "hashed" form: {ck}. I scrambled "{name}" by running it through a 1-way hashing function, which will always yield the same result: provided you know which function I'm using, and what the secret "salt" is that I add to all the input, a string of text which I keep protected and encrypted on my local hard drive.
The content of your data will therefore not only be encrypted, but its location in my database is obscured even to me. There's no way for me to reverse-engineer the name of {name} from the record I stored it under, {ck}. Unless you explictly ask me for the public key of {name}, I will have no way of accessing that information.
Your name ({name}) and your public key ({cvb64}) are the first two pieces of information you've given me about yourself. Your public key is your 'address' in Komrade: in order for anyone to write to you, or for them to receive messages from you, they'll need to know your public key (and vise versa). The Komrade app should store your public key on your device as a QR code, under ~/.komrade/.contacts/{name}.png. It will look something like this:{qrstr}You can then send this image to anyone by a secure channel (Signal, IRL, etc), or tell them the code directly ({cvb64}).
By default, if anyone asks me what your public key is, I won't tell them--though I won't be able to avoid hinting that a user exists under this name should someone try to register under that name and I deny them). Instead, if the person who requested your public key insists, I will send you a message (encrypted end-to-end so only you can read it) that the user who met someone would like to introduce themselves to you; I will then send you their name and public key. It's now your move: up to you whether to save them back your public key.
If you'd like to change this default behavior, e.g. by instead allowing anyone to request your public key, except for those whom you explcitly block, I have also created a super secret administrative record for you to change various settings on your account. This is protected by a separate encryption key which I have generated for you; and this key which is itself encrypted with the password you entered earlier. Don't worry: I never saw that password you typed, since it was given to me already hashed and disguised (as something {len(passphrase)} characters long, ending in "{passphrase[:10]}"). Without that hashed passphrase, no one will be able to unlock the administration key; and without the administration key, they won't be able to find the hashed record I stored your user settings under, since I also salted that hash with your own hashed passphrase. Even if someone found the record I stored them under, they wouldn't be able to decrypt the existing settings; and if they can't do that, I won't let them overwrite the record.''')
self.log('Operator returning result:',dict_format(res,tab=2))

@ -62,8 +62,11 @@ class Logger(object):
exit()
def status(self,status_msg):
paras=[]
for para in status_msg.split('\n\n'):
self.log(para.strip())
paras.append(para)
return paras
import binascii,base64
def isBase64(sb):

Loading…
Cancel
Save