コード例 #1
0
def exchange_public_keys(connection):
    keypair = CryptoUtil.generate_keypair()

    # Send department public key to supervisor
    NetworkUtil.send_message(connection, keypair.public_key().exportKey())

    # Receive public key from supervisor
    supervisor_public_key = RSA.importKey(
        NetworkUtil.receive_message(connection))

    return keypair, supervisor_public_key
コード例 #2
0
def exchange_public_keys(department_connection, customer_connection):
    keypair = CryptoUtil.generate_keypair()

    # Send Supervisor Public key to Department and Customer
    NetworkUtil.send_message(department_connection,
                             keypair.public_key().exportKey())  # Department
    NetworkUtil.send_message(customer_connection,
                             keypair.public_key().exportKey())  # Customer

    # Gather Public Keys from Department and Customer
    department_public_key = RSA.importKey(
        NetworkUtil.receive_message(department_connection))
    customer_public_key = RSA.importKey(
        NetworkUtil.receive_message(customer_connection))

    # Send Customer Public key to Department
    NetworkUtil.send_message(department_connection,
                             customer_public_key.exportKey())

    return keypair, department_public_key, customer_public_key