示例#1
0
#!/usr/bin/env python3
import base
import WLSK_Keygen, WLSK_Init, WLSK_Resp, WLSK_S

if __name__ == '__main__':
    print('Generating keys')
    WLSK_Keygen.init()(base.get_hostname())
    print('  enc_key = {}\n  mac_key = {}\b  table   = {}'.format(
        base.read_file('wlsk_enc_key'), base.read_file('wlsk_mac_key'),
        base.read_file('keytbl')))

    print('\x1b[31m[A1]\x1b[0m')
    (a3, idA) = WLSK_Init.init()(base.get_hostname())
    print('  idA = {}'.format(idA))

    print('\x1b[34m[B2]\x1b[0m')
    (b4, n) = WLSK_Resp.init()(idA)
    print('  n = {}'.format(n))

    print('\x1b[31m[A3]\x1b[0m')
    (_, iv1, e, m) = a3(n)
    print('  e = {}\n  m = {}'.format(e, m))

    print('\x1b[34m[B4]\x1b[0m')
    (b6, idA_, idB_, iv2, e_, m_) = b4(iv1, e, m)
    print('  idA\' = {}\n  idB\' = {}\n  e\'   = {}\n  m\'   = {}'.format(
        idA_, idB_, e_, m_))

    print('\x1b[33m[S5]\x1b[0m')
    (_, iv3, e__, m__) = WLSK_S.init()(idA_, idB_, iv2, e_, m_)
    print('  e\'\' = {}\n  m\'\' = {}'.format(e__, m__))
示例#2
0
#!/usr/bin/env python3
import base, WLSK_Keygen
from common import *

if __name__ == '__main__':
    my_hostname = base.get_hostname()

    print('Generating keys for {}...'.format(my_hostname))
    WLSK_Keygen.init()(my_hostname)
    print('Done')
    debug('enc_key = {}\nmac_key = {}\ntable   = {}'.format(
        base.read_file('wlsk_enc_key'), base.read_file('wlsk_mac_key'),
        base.read_file('keytbl')))
示例#3
0
#!/usr/bin/env python3
import base, WLSK_Keygen
from common import *

if __name__ == '__main__':
    my_hostname = base.get_hostname()

    print('Generating keys for {}...'.format(my_hostname))
    WLSK_Keygen.init()(my_hostname)
    print('Done')
    debug('enc_key = {}\nmac_key = {}\ntable   = {}'.format(base.read_file('wlsk_enc_key'),
        base.read_file('wlsk_mac_key'), base.read_file('keytbl')))

示例#4
0
#!/usr/bin/env python3
import base, WLSK_Init
from common import *
import socket

BUFFER_SIZE = 1024

if __name__ == '__main__':
    my_addr = get_local_address()

    (a3, idA) = WLSK_Init.init()(base.get_hostname())
    print('Running on \x1b[1m{}\x1b[0m as an {}\nMy identity: {}\n'.format(my_addr, INITIATOR, idA))
    resp_addr = input('Enter {} address: '.format(RESPONDER))

    print('Connecting to the {}...'.format(RESPONDER))
    delay()
    with socket.create_connection((resp_addr, RESP_PORT)) as rsock:
        print('Sending my identity to the {}...'.format(RESPONDER))
        rsock.send(idA)

        n = rsock.recv(BUFFER_SIZE)
        delay()
        print('Received nonce')
        debug('n = {}'.format(n))

        (_, iv1, e, m) = a3(n)
        print('Sending encrypted data...')
        debug('e = {}\nm = {}'.format(e, m))
        delay()
        rsock.send(base.compose([iv1, e, m]))