def test_reencryption(self): encrypted = "aN21B3h43kOLKWuOiGT60I5vfcsKlYH3zYIooM+J2pibn6hP7jLt1iIV8hcrhPy6oqGjwHxIa80hZOi6Ft+14Z1Cx1obQg41EQXKumEdtdMQQRU83E/5BlSj5FazlPL0hw5Eq9jHPD0jjKQKGyweffR1KoutdKw9eckvgsdVzmE=" modulus = "41152522433320028391414260781121497823282123701983808635098754820396967694895340897354177567517177955359187927090779247132253" exponent = 65537 client_key = [modulus, exponent] private_modulus = "142726703398204652638983205261056701155333711876208792179823725379405391177226233307493985630102928083443969675569314017341101313742878761646666945060512448216012474295251166957446341076584025136192653321034456686250636705163190125533995791546789620904080575419998483165635991043375407234471039627424868630751" private_exponent = "72318318503199443065485379207225077059755047839743432899208179328835845779058417831788955564319818314340355845043718976667316955696168195645221313832254086569715579154289054303717394893568550659258684584880193477360716438016938382963649944129554410505344022913436211714770421462926877446557028989632059973473" server_key = RSAPair(private_modulus, exponent, private_exponent) new_encrypted = KeyOperation.re_encryption(server_key, client_key, encrypted) print(new_encrypted)
def __process_new_key(self,user_id, key, key_mod, key_exp): """ Process key passing down to the new authorized device with provided key from the root device and encrypt the key with provided public key from the device """ device = DeviceList.get_root_device(user_id) #get root device by user_id if not device: #if root device does not exist return CommonResponseObject.fail_response( 'Some errors occured, please try again') encrypted_key = KeyOperation.re_encryption(key, [key_mod,key_exp], device.encrypted_key) if not encrypted_key: return CommonResponseObject.fail_response( 'Some errors occured, please try again') data = json.dumps(dict(key=encrypted_key)) return CommonResponseObject.success_response(data)