|
@@ -14,6 +14,7 @@ import os
|
|
|
from cryptography.hazmat.backends import default_backend
|
|
from cryptography.hazmat.backends import default_backend
|
|
|
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
|
from cryptography.hazmat.primitives import serialization
|
|
from cryptography.hazmat.primitives import serialization
|
|
|
|
|
+from cryptography.fernet import Fernet
|
|
|
|
|
|
|
|
def make_keys(contract_name):
|
|
def make_keys(contract_name):
|
|
|
#(pubkey,privkey)=rsa.newkeys(2048)
|
|
#(pubkey,privkey)=rsa.newkeys(2048)
|
|
@@ -43,7 +44,13 @@ def make_keys(contract_name):
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
with open(path + 'privatekey.key','wb') as f:
|
|
with open(path + 'privatekey.key','wb') as f:
|
|
|
- f.write(pem)
|
|
|
|
|
|
|
+ f.write(pem)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ symmetric_key = Fernet.generate_key()
|
|
|
|
|
+
|
|
|
|
|
+ with open(path + 'symmetric.key','wb') as f:
|
|
|
|
|
+ f.write(symmetric_key)
|
|
|
|
|
|
|
|
def get_keys(contract_name):
|
|
def get_keys(contract_name):
|
|
|
path = 'contract_keys\\' + contract_name + '\\publickey.key'
|
|
path = 'contract_keys\\' + contract_name + '\\publickey.key'
|
|
@@ -55,6 +62,12 @@ def get_keys(contract_name):
|
|
|
)
|
|
)
|
|
|
return public_key
|
|
return public_key
|
|
|
|
|
|
|
|
|
|
+def get_symmetric_key(contract_name):
|
|
|
|
|
+ path = 'contract_keys\\' + contract_name + '\\symmetric.key'
|
|
|
|
|
+
|
|
|
|
|
+ with open(path, 'rb') as f:
|
|
|
|
|
+ return f.read()
|
|
|
|
|
+
|
|
|
def get_private_key(contract_name):
|
|
def get_private_key(contract_name):
|
|
|
path = 'contract_keys\\' + contract_name + '\\privatekey.key'
|
|
path = 'contract_keys\\' + contract_name + '\\privatekey.key'
|
|
|
|
|
|