コード例 #1
0
def sk_exchange_robot(ip):
    
    print "Generating and exchanging session key..."

    #SK1
    private_key, public_key = crypto.keypair()

    #SK2#
    port = 21567
    client_public_key = socket_scripts.socket_host(port)

    #SK3#
    session_key = crypto.generate_session_key()

    #SK4#
    encrypted_session_key = crypto.session_key_encrypt(client_public_key, session_key)

    #SK5#
    #ip = "192.168.1.2"
    port = 21568
    socket_scripts.socket_client(ip, port, encrypted_session_key)

    print "Login Session key = ", session_key

    return session_key
コード例 #2
0
def RSA_server(ip, port):

    print "Generating and exchanging session key..."

    #SK1
    private_key, public_key = crypto.keypair()

    #SK2#
    #port = 21566
    client_public_key = socket_scripts.socket_host(port)

    #SK3#
    session_key = crypto.generate_session_key()

    #SK4#
    encrypted_session_key = crypto.session_key_encrypt(client_public_key,
                                                       session_key)

    #SK5#
    #ip = "192.168.1.2"
    #port = 21567
    socket_scripts.socket_client(ip, port, encrypted_session_key)

    print "Session key = ", session_key

    return session_key
コード例 #3
0
def sk_exchange_client(ip):

    print "Generating and exchanging session key..."

    #SK1#
    private_key, public_key = crypto.keypair()

    #SK2#
    #ip = "192.168.1.2"
    #time.sleep(10)
    port = 21567
    socket_scripts.socket_client(ip, port, public_key)

    #SK5#
    port = 21568
    #time.sleep(2)
    encrypted_session_key = socket_scripts.socket_host(port)

    #SK6#
    session_key = crypto.session_key_decrypt(private_key,
                                             encrypted_session_key)

    print "Login Session key = ", session_key

    return session_key
コード例 #4
0
def RSA_client(ip, port):

    print "Generating and exchanging session key..."

    #SK1#
    private_key, public_key = crypto.keypair()

    #SK2#
    #port = 21566
    socket_scripts.socket_client(ip, port, public_key)

    #SK5#
    #port = 21567
    encrypted_session_key = socket_scripts.socket_host(port)

    #SK6#
    session_key = crypto.session_key_decrypt(private_key,
                                             encrypted_session_key)

    print "Session key = ", session_key

    return session_key