Beispiel #1
0
def test_invalid_nacl_keys(alice_bob_boxes, invalid_pubkey):
    with pytest.raises(NaclError) as e_info:
        x = init_pubkey(invalid_pubkey)
    with pytest.raises(NaclError) as e_info:
        alice_kp = init_keypair()
        box = as_init_encryption(alice_kp, invalid_pubkey)
    #also try when using the wrong object type as a keypair
    with pytest.raises(NaclError) as e_info:
        alice_bad_kp = init_pubkey("02"*32)
        box = as_init_encryption(alice_bad_kp, alice_bad_kp)
    #try to load a pubkey from a non-keypair object
    with pytest.raises(NaclError) as e_info:
        pk = get_pubkey(invalid_pubkey)
def test_invalid_nacl_keys(alice_bob_boxes, invalid_pubkey):
    with pytest.raises(NaclError) as e_info:
        x = init_pubkey(invalid_pubkey)
    with pytest.raises(NaclError) as e_info:
        alice_kp = init_keypair()
        box = as_init_encryption(alice_kp, invalid_pubkey)
    #also try when using the wrong object type as a keypair
    with pytest.raises(NaclError) as e_info:
        alice_bad_kp = init_pubkey("02" * 32)
        box = as_init_encryption(alice_bad_kp, alice_bad_kp)
    #try to load a pubkey from a non-keypair object
    with pytest.raises(NaclError) as e_info:
        pk = get_pubkey(invalid_pubkey)
def alice_bob_boxes():
    alice_kp = init_keypair()
    bob_kp = init_keypair()

    # this is the DH key exchange part
    bob_otwpk = get_pubkey(bob_kp, True)
    alice_otwpk = get_pubkey(alice_kp, True)

    bob_pk = init_pubkey(bob_otwpk)
    alice_box = as_init_encryption(alice_kp, bob_pk)
    alice_pk = init_pubkey(alice_otwpk)
    bob_box = as_init_encryption(bob_kp, alice_pk)

    # now Alice and Bob can use their 'box'
    # constructs (both of which utilise the same
    # shared secret) to perform encryption/decryption
    # to test the encryption functionality
    return (alice_box, bob_box)
Beispiel #4
0
def alice_bob_boxes():
    alice_kp = init_keypair()
    bob_kp = init_keypair()

    # this is the DH key exchange part
    bob_otwpk = get_pubkey(bob_kp, True)
    alice_otwpk = get_pubkey(alice_kp, True)

    bob_pk = init_pubkey(bob_otwpk)
    alice_box = as_init_encryption(alice_kp, bob_pk)
    alice_pk = init_pubkey(alice_otwpk)
    bob_box = as_init_encryption(bob_kp, alice_pk)

    # now Alice and Bob can use their 'box'
    # constructs (both of which utilise the same
    # shared secret) to perform encryption/decryption
    # to test the encryption functionality
    return (alice_box, bob_box)