This commit is contained in:
parent
f0c5281697
commit
c69241249e
@ -6,7 +6,7 @@ from Crypto.PublicKey import RSA
|
||||
from authentication import Authetication
|
||||
|
||||
|
||||
def generatePrivateKeyForUser(auth: Authetication,username: str, user_passphrase: str, public_server_key: str) -> bool:
|
||||
def generatePrivateKeyForUser(auth: Authetication,username: str, user_passphrase: str, public_server_key: str,address: str) -> bool:
|
||||
if auth.checkUserExists(username):
|
||||
with open(auth.CONFIG_FILE_LOCATION) as json_file:
|
||||
data = json.load(json_file)
|
||||
@ -17,7 +17,8 @@ def generatePrivateKeyForUser(auth: Authetication,username: str, user_passphrase
|
||||
public_key_value = bytes.hex(public_key.exportKey('DER', pkcs=8))
|
||||
|
||||
##Save private key in separate file
|
||||
user_privatekey = {'privateClientKey': private_key_value,
|
||||
user_privatekey = {'address': address,
|
||||
'privateClientKey': private_key_value,
|
||||
'publicServerKey': public_server_key}
|
||||
with open(auth.PRIVATE_KEY_DIRECTORY_LOCATION + os.path.sep + str(data['index']) + '.txt',
|
||||
'w+') as outfile:
|
||||
@ -54,11 +55,17 @@ def generatePrivateKeyForServer(auth: Authetication,passphrase: str) -> str:
|
||||
return public_key_value
|
||||
|
||||
|
||||
def generateSourceAddress(index: str) -> chr:
|
||||
return chr(ord(index[0]) + 17)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
auth = Authetication()
|
||||
auth.initConfig()
|
||||
serverPublicKey = generatePrivateKeyForServer(auth, 'admin')
|
||||
auth.saveUser('alma', 'alma')
|
||||
generatePrivateKeyForUser(auth, 'alma', 'amla', serverPublicKey)
|
||||
homeDir = auth.login('alma', 'alma')
|
||||
generatePrivateKeyForUser(auth, 'alma', 'amla', serverPublicKey, generateSourceAddress(homeDir))
|
||||
auth.saveUser('citrom', 'citrom')
|
||||
generatePrivateKeyForUser(auth, 'citrom', 'mortic', serverPublicKey)
|
||||
homeDir = auth.login('citrom', 'citrom')
|
||||
generatePrivateKeyForUser(auth, 'citrom', 'mortic', serverPublicKey, generateSourceAddress(homeDir))
|
||||
|
Loading…
Reference in New Issue
Block a user