def test_keys(): privkey = PrivateKey() pubkey = privkey.public_key() message = "Hello World" sig = privkey.sign(message.encode("utf-8")) pubkey.verify(sig, message.encode("utf-8")) c = pubkey.encrypt(message.encode("utf-8")) m = privkey.decrypt(c).decode("utf-8") assert (m == message) privkey2 = PrivateKey() sig2 = privkey2.sign(message.encode("utf-8")) with pytest.raises(SignatureVerificationError): pubkey.verify(sig2, message.encode("utf-8")) bytes = privkey.bytes("testPass32") PrivateKey.read_bytes(bytes, "testPass32") privkey.write("test.pem", "testPass32") PrivateKey.read("test.pem", "testPass32") bytes = pubkey.bytes() pubkey2 = PublicKey.read_bytes(bytes) assert (bytes == pubkey2.bytes()) long_message = str([random.getrandbits(8) for _ in range(4096)]).encode("utf-8") c = pubkey.encrypt(long_message) m = privkey.decrypt(c) assert (m == long_message) os.unlink("test.pem") data = pubkey.to_data() pubkey2 = PublicKey.from_data(data) assert (pubkey.bytes() == pubkey2.bytes()) data = privkey.to_data("testPass33") privkey2 = PrivateKey.from_data(data, "testPass33") assert (privkey == privkey2)
# Fingerprint for the login keyfile data["fingerprint"] = "5d:ac:65:4c:11:69:5b:e7:e8:5c:04:39:93:f0:cd:c8" # The keyfile itself - we will now read the file and pull it into text keyfile = sys.argv[1] data["key_lines"] = open(sys.argv[1], "r").readlines() # The tenancy in which this user and everything exists! data[ "tenancy"] = "ocid1.tenancy.oc1..aaaaaaaa3eiex6fbfj626uwhs3dg24oygknrhhgfj4khqearluf4i74zdt2a" # The passphrase to unlock the key - VERY SECRET!!! data["pass_phrase"] = sys.argv[2] # Make sure that this is the correct password... privkey = PrivateKey.read(sys.argv[1], sys.argv[2]) # The region for this tenancy data["region"] = "eu-frankfurt-1" secret_config["LOGIN"] = data ## Now create the bucket info so we know where the bucket is ## that will store all data related to logging into accounts data = {} data[ "compartment"] = "ocid1.compartment.oc1..aaaaaaaat33j7w74mdyjenwoinyeawztxe7ri6qkfbm5oihqb5zteamvbpzq" data["bucket"] = "acquire_compute" secret_config["BUCKET"] = data