예제 #1
0
def build_handshake_packet(data):
    packet = HandshakePacket(*data.splitlines())

    assert len(a2b(packet.identity_key)) == KEY_LEN
    assert len(a2b(packet.handshake_key)) == KEY_LEN
    assert len(a2b(packet.ratchet_key)) == KEY_LEN

    return packet
예제 #2
0
def build_request_packet(data):
    packet = RequestPacket(*data.splitlines())

    assert len(a2b(packet.handshake_packet_hash)) == HASH_LEN
    assert len(a2b(packet.request_key)) == KEY_LEN
    a2b(packet.handshake_packet)

    return packet
예제 #3
0
def build_reply_packet(data):
    packet = RegularPacket(*data.splitlines())

    check_payload(packet)
    assert len(a2b(packet.handshake_key)) == ENC_KEY_LEN

    return packet
예제 #4
0
def build_regular_packet(data):
    packet = RegularPacket(*data.splitlines())

    check_payload(packet)
    assert not len(a2b(packet.handshake_key))

    return packet
예제 #5
0
def check_payload(packet):
    assert len(a2b(packet.payload_hash)) == HASH_LEN
    a2b(packet.payload)
예제 #6
0
def check_iv(packet):
    assert len(a2b(packet.iv)) == IV_LEN
    assert len(a2b(packet.iv_hash)) == HASH_LEN