Test Report

Summary

69
64 failed 5 passed

Tests

test_comm.py 645 0:00:01.050261

PASSED test_setup 0:00:00.000482

Setup

Call

Teardown

FAILED test_ping[\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&'()*+,-./0123456789:;<=>?] 0:00:00.248053

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Captured stdout setup
Selecting hardware
Captured stderr setup
* DEBUG    621ms llog.py:45 
Exchange selected: <bound method NKFido2Client.exchange_u2f of <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>>

Captured log setup
*    391ms pcsc.py:212 Error NoCardException('Unable to connect')
*    392ms pcsc.py:212 Error NoCardException('Unable to connect')
*    501ms pcsc.py:101 apdu b'00a4040008a0000006472f0001'
*    508ms pcsc.py:104 response [0x9000] b'5532465f5632'
*    508ms pcsc.py:101 apdu b'80108000010400'
*    576ms pcsc.py:104 response [0x9000] b'00a90183665532465f5632684649444f5f325f306c4649444f5f325f315f50524502826b6372656450726f746563746b686d61632d73656372657403508bc5496807b14d5fb249607f5d527da204a662726bf5627570f564706c6174f468637265644d676d74f569636c69656e7450696ef47563726564656e7469616c4d676d7450726576696577f505190c00068101070a0818ff0982636e666363757362'
*    576ms pcsc.py:101 apdu b'80108000010400'
*    620ms pcsc.py:104 response [0x9000] b'00a90183665532465f5632684649444f5f325f306c4649444f5f325f315f50524502826b6372656450726f746563746b686d61632d73656372657403508bc5496807b14d5fb249607f5d527da204a662726bf5627570f564706c6174f468637265644d676d74f569636c69656e7450696ef47563726564656e7469616c4d676d7450726576696577f505190c00068101070a0818ff0982636e666363757362'
*    621ms llog.py:45 
Exchange selected: <bound method NKFido2Client.exchange_u2f of <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>>

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?'

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa04790ecc0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=5840000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f
Sending data=b'X@\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?'
Send Command.TEST_PING
CBOR encoded data dict (to send): (69) 5840000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f
69 0/1 221 74 010001dd454200015840000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f
Captured log call
*    624ms pcsc.py:101 apdu b'0002030090424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141414f228c2790f6010001dd454200015840000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f00'
*    637ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f] 0:00:00.017417

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f'

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047740590>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=5880000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f
Sending data=b'X\x80\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f'
Send Command.TEST_PING
CBOR encoded data dict (to send): (133) 5880000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f
133 0/1 221 138 010001dd858200015880000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f
Captured log call
*    710ms pcsc.py:101 apdu b'00020300d0424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141418f228c2790f6010001dd858200015880000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f00'
*    727ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[test_data2] 0:00:00.013678

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = {'B': b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?'}

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047844720>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=a161425840000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f
Sending data=b'\xa1aBX@\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?'
Send Command.TEST_PING
CBOR encoded data dict (to send): (72) a161425840000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f
72 0/1 221 77 010001dd48450001a161425840000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f
Captured log call
*    749ms pcsc.py:101 apdu b'00020300934242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414152228c2790f6010001dd48450001a161425840000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f00'
*    762ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[test_data3] 0:00:00.041206

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = {'ABCD': 'BBBBBBBBBB'}

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047767b30>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=a164414243446a42424242424242424242
Sending data=b'\xa1dABCDjBBBBBBBBBB'
Send Command.TEST_PING
CBOR encoded data dict (to send): (20) a164414243446a42424242424242424242
20 0/1 221 25 010001dd14110001a164414243446a42424242424242424242
Captured log call
*    785ms pcsc.py:101 apdu b'000203005f424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141411e228c2790f6010001dd14110001a164414243446a4242424242424242424200'
*    795ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[test_data4] 0:00:00.011934

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = {'cc': b'cc', 'ww': b'ww', 'xx': b'xx'}

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa049f44c20>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=a3627777427777627878427878626363426363
Sending data=b'\xa3bwwBwwbxxBxxbccBcc'
Send Command.TEST_PING
CBOR encoded data dict (to send): (22) a3627777427777627878427878626363426363
22 0/1 221 27 010001dd16130001a3627777427777627878427878626363426363
Captured log call
*    885ms pcsc.py:101 apdu b'00020300614242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414120228c2790f6010001dd16130001a362777742777762787842787862636342636300'
*    896ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[test_data5] 0:00:00.011750

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = {'a': b'AAAAA', 'ww': b'ww'}

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0478afb30>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=a26277774277776161454141414141
Sending data=b'\xa2bwwBwwaaEAAAAA'
Send Command.TEST_PING
CBOR encoded data dict (to send): (18) a26277774277776161454141414141
18 0/1 221 23 010001dd120f0001a26277774277776161454141414141
Captured log call
*    919ms pcsc.py:101 apdu b'000203005d424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141411c228c2790f6010001dd120f0001a2627777427777616145414141414100'
*    929ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[test_data6] 0:00:00.028091

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = {'key': b'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ...ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'}

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047896a90>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=a1636b657958ff5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
Sending data=b'\xa1ckeyX\xffZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'
Send Command.TEST_PING
CBOR encoded data dict (to send): (265) a1636b657958ff5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
265 0/2 221 226 010002dddd060101a1636b657958ff5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
Captured log call
*    952ms pcsc.py:101 apdu b'10020300fa42424242424242424242424242424242424242424242424242424242424242424141414141414141414141414141414141414141414141414141414141414141e7228c2790f6010002dddd060101a1636b657958ff5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a'
*    972ms pcsc.py:104 response [0x9000] b''
*    972ms pcsc.py:101 apdu b'000203002e5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a00'
*    979ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[test_data7] 0:00:00.027897

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = {'key': b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x...1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe'}

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047740f90>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=a1636b657958ff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe
Sending data=b'\xa1ckeyX\xff\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe'
Send Command.TEST_PING
CBOR encoded data dict (to send): (265) a1636b657958ff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe
265 0/2 221 226 010002dddd060101a1636b657958ff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2
Captured log call
*   1002ms pcsc.py:101 apdu b'10020300fa42424242424242424242424242424242424242424242424242424242424242424141414141414141414141414141414141414141414141414141414141414141e7228c2790f6010002dddd060101a1636b657958ff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4'
*   1021ms pcsc.py:104 response [0x9000] b''
*   1021ms pcsc.py:101 apdu b'000203002ea5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d200'
*   1029ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[test_data8] 0:00:00.016855

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = {'Key111': b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'cc': b'cc', 'ww': b'ww', 'xx': b'xx'}

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa049eeacc0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=a4627777427777627878427878626363426363664b6579313131586441414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141
Sending data=b'\xa4bwwBwwbxxBxxbccBccfKey111XdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
Send Command.TEST_PING
CBOR encoded data dict (to send): (131) a4627777427777627878427878626363426363664b6579313131586441414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141
131 0/1 221 136 010001dd83800001a4627777427777627878427878626363426363664b6579313131586441414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141
Captured log call
*   1052ms pcsc.py:101 apdu b'00020300ce424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141418d228c2790f6010001dd83800001a4627777427777627878427878626363426363664b657931313158644141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414100'
*   1068ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[test_data9] 0:00:00.028592

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = {'Key111': b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB', 'cc': b'cc', 'ww': b'ww', ...}

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa04777a180>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=a5627777427777627878427878626363426363664b657931313159012c414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141664b657932323259012c424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242
Sending data=b'\xa5bwwBwwbxxBxxbccBccfKey111Y\x01,AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfKey222Y\x01,BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'
Send Command.TEST_PING
CBOR encoded data dict (to send): (642) a5627777427777627878427878626363426363664b657931313159012c414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141664b657932323259012c424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242
642 0/3 221 226 010003dddd7f0201a5627777427777627878427878626363426363664b657931313159012c414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141
Captured log call
*   1092ms pcsc.py:101 apdu b'10020300fa42424242424242424242424242424242424242424242424242424242424242424141414141414141414141414141414141414141414141414141414141414141e7228c2790f6010003dddd7f0201a5627777427777627878427878626363426363664b657931313159012c4141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141'
*   1112ms pcsc.py:104 response [0x9000] b''
*   1112ms pcsc.py:101 apdu b'000203002e4141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414100'
*   1119ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[test_data10] 0:00:00.027827

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = {'Key111': b'\x08|MeA\xce\x89\x08\x0f\x97fH\x1c\x1c\t\xba]\x0e\x8e$4\xa1~|i\x99\x01\xac\xa3\x13\xa4\x8ay\xb0\x06\xc2\x...be\xee\xe8\xd5'f\x04/\xaa\xff9\xf8\x0c\xcby8'0\xcc\x014\x05\xca3o\xfd\xff\x17\xdd}\x95", 'cc': b'cc', 'ww': b'ww', ...}

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa04773b900>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=a6627777427777627878427878626363426363664b65793131315896087c4d6541ce89080f9766481c1c09ba5d0e8e2434a17e7c699901aca313a48a79b006c2c88d88f007c3bbd7f07cf0c0498056989a5057d188496ced14b0c97a2c0cb369211d4103acacdcc8af1ed975c244b8909aa6b88febb17ab5e49289bbb693aca604a7f07c65d04957ca917bc6cb02071c30c450f0e374522a66df09fe1e70c21f92dcc7879f15e751b713392dca4557cb2304664b657932323258968b86b5f2b568c7518909061a1110e1d53ae2670dac3ee534173b6c5e9575c3202c9ae09cd7f3ddead8c8e607bffedccbc9963370fc24d32f0c8068af6182d134ff9cdd01c015fd2de3d71dd0269b7d1db17e4a00e2c4bbf0289c2900181c2e8a7f780885d113e8b70950f60a2dae3ca7d60bfd57c273b5beeee8d52766042faaff39f80ccb79382730cc013405ca336ffdff17dd7d9563787878581ef199753974b20a7619c5e8e0bd017bb2019fcbe5e8390818858b1da7ba56
Sending data=b"\xa6bwwBwwbxxBxxbccBccfKey111X\x96\x08|MeA\xce\x89\x08\x0f\x97fH\x1c\x1c\t\xba]\x0e\x8e$4\xa1~|i\x99\x01\xac\xa3\x13\xa4\x8ay\xb0\x06\xc2\xc8\x8d\x88\xf0\x07\xc3\xbb\xd7\xf0|\xf0\xc0I\x80V\x98\x9aPW\xd1\x88Il\xed\x14\xb0\xc9z,\x0c\xb3i!\x1dA\x03\xac\xac\xdc\xc8\xaf\x1e\xd9u\xc2D\xb8\x90\x9a\xa6\xb8\x8f\xeb\xb1z\xb5\xe4\x92\x89\xbb\xb6\x93\xac\xa6\x04\xa7\xf0|e\xd0IW\xca\x91{\xc6\xcb\x02\x07\x1c0\xc4P\xf0\xe3tR*f\xdf\t\xfe\x1ep\xc2\x1f\x92\xdc\xc7\x87\x9f\x15\xe7Q\xb7\x139-\xcaEW\xcb#\x04fKey222X\x96\x8b\x86\xb5\xf2\xb5h\xc7Q\x89\t\x06\x1a\x11\x10\xe1\xd5:\xe2g\r\xac>\xe54\x17;l^\x95u\xc3 ,\x9a\xe0\x9c\xd7\xf3\xdd\xea\xd8\xc8\xe6\x07\xbf\xfe\xdc\xcb\xc9\x963p\xfc$\xd3/\x0c\x80h\xafa\x82\xd14\xff\x9c\xdd\x01\xc0\x15\xfd-\xe3\xd7\x1d\xd0&\x9b}\x1d\xb1~J\x00\xe2\xc4\xbb\xf0(\x9c)\x00\x18\x1c.\x8a\x7fx\x08\x85\xd1\x13\xe8\xb7\tP\xf6\n-\xae<\xa7\xd6\x0b\xfdW\xc2s\xb5\xbe\xee\xe8\xd5'f\x04/\xaa\xff9\xf8\x0c\xcby8'0\xcc\x014\x05\xca3o\xfd\xff\x17\xdd}\x95cxxxX\x1e\xf1\x99u9t\xb2\nv\x19\xc5\xe8\xe0\xbd\x01{\xb2\x01\x9f\xcb\xe5\xe89\x08\x18\x85\x8b\x1d\xa7\xbaV"
Send Command.TEST_PING
CBOR encoded data dict (to send): (376) a6627777427777627878427878626363426363664b65793131315896087c4d6541ce89080f9766481c1c09ba5d0e8e2434a17e7c699901aca313a48a79b006c2c88d88f007c3bbd7f07cf0c0498056989a5057d188496ced14b0c97a2c0cb369211d4103acacdcc8af1ed975c244b8909aa6b88febb17ab5e49289bbb693aca604a7f07c65d04957ca917bc6cb02071c30c450f0e374522a66df09fe1e70c21f92dcc7879f15e751b713392dca4557cb2304664b657932323258968b86b5f2b568c7518909061a1110e1d53ae2670dac3ee534173b6c5e9575c3202c9ae09cd7f3ddead8c8e607bffedccbc9963370fc24d32f0c8068af6182d134ff9cdd01c015fd2de3d71dd0269b7d1db17e4a00e2c4bbf0289c2900181c2e8a7f780885d113e8b70950f60a2dae3ca7d60bfd57c273b5beeee8d52766042faaff39f80ccb79382730cc013405ca336ffdff17dd7d9563787878581ef199753974b20a7619c5e8e0bd017bb2019fcbe5e8390818858b1da7ba56
376 0/2 221 226 010002dddd750101a6627777427777627878427878626363426363664b65793131315896087c4d6541ce89080f9766481c1c09ba5d0e8e2434a17e7c699901aca313a48a79b006c2c88d88f007c3bbd7f07cf0c0498056989a5057d188496ced14b0c97a2c0cb369211d4103acacdcc8af1ed975c244b8909aa6b88febb17ab5e49289bbb693aca604a7f07c65d04957ca917bc6cb02071c30c450f0e374522a66df09fe1e70c21f92dcc7879f15e751b713392dca4557cb2304664b657932323258968b86b5f2b568c7518909061a1110e1d53ae2670dac3ee534173b6c5e9575c3
Captured log call
*   1142ms pcsc.py:101 apdu b'10020300fa42424242424242424242424242424242424242424242424242424242424242424141414141414141414141414141414141414141414141414141414141414141e7228c2790f6010002dddd750101a6627777427777627878427878626363426363664b65793131315896087c4d6541ce89080f9766481c1c09ba5d0e8e2434a17e7c699901aca313a48a79b006c2c88d88f007c3bbd7f07cf0c0498056989a5057d188496ced14b0c97a2c0cb369211d4103acacdcc8af1ed975c244b8909aa6b88febb17ab5e49289bbb693aca604a7f07c65d04957ca917bc6cb02071c30c450f0e374522a66df09fe1e70c21f92dcc7879f15e751b713392d'
*   1162ms pcsc.py:104 response [0x9000] b''
*   1162ms pcsc.py:101 apdu b'000203002eca4557cb2304664b657932323258968b86b5f2b568c7518909061a1110e1d53ae2670dac3ee534173b6c5e9575c300'
*   1169ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[test_data11] 0:00:00.028360

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = {'key': b'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ...ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'}

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0477509a0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=a1636b65795901905a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
Sending data=b'\xa1ckeyY\x01\x90ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'
Send Command.TEST_PING
CBOR encoded data dict (to send): (411) a1636b65795901905a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
411 0/2 221 226 010002dddd980101a1636b65795901905a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
Captured log call
*   1193ms pcsc.py:101 apdu b'10020300fa42424242424242424242424242424242424242424242424242424242424242424141414141414141414141414141414141414141414141414141414141414141e7228c2790f6010002dddd980101a1636b65795901905a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a'
*   1212ms pcsc.py:104 response [0x9000] b''
*   1212ms pcsc.py:101 apdu b'000203002e5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a00'
*   1220ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[test_data12] 0:00:00.029833

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = {'key': b'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ...ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'}

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047750360>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=a1636b65795903845a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
Sending data=b'\xa1ckeyY\x03\x84ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'
Send Command.TEST_PING
CBOR encoded data dict (to send): (911) a1636b65795903845a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
911 0/5 221 226 010005dddd8c0301a1636b65795903845a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
Captured log call
*   1243ms pcsc.py:101 apdu b'10020300fa42424242424242424242424242424242424242424242424242424242424242424141414141414141414141414141414141414141414141414141414141414141e7228c2790f6010005dddd8c0301a1636b65795903845a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a'
*   1263ms pcsc.py:104 response [0x9000] b''
*   1263ms pcsc.py:101 apdu b'000203002e5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a00'
*   1271ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping[test_data13] 0:00:00.028202

Sends arbitrary dict structure over the wire, and receives the same data

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_data = {'key': b'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ...ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'}

    @pytest.mark.parametrize("test_data", [
        bytes(range(64)),  # 54 is max what is working
        bytes(range(64 * 2)),  # 54 is max what is working
        dict(B=bytes(range(64))),  # 54 is max what is working
        dict(ABCD='BB' * 5),
        TEST_DATA,
        TEST_DATA_SMALL,
        dict(key=b'Z' * 255),  # 54 is max what is working
        dict(key=bytes(range(255))),  # 54 is max what is working
        fixture_data_medium(),
        fixture_data_big(),
        fixture_data_random(),
        dict(key=b'Z' * 400),  # ping data should be structure independent
        dict(key=b'Z' * 900),  # ping data should be structure independent
        dict(key=b'Z' * (1024 - 71 - 1 - 8)),  # ping data should be structure independent FIXME handle edge case
    ])
    def test_ping(nkfido2_client: NKFido2Client, test_data: dict):
        """Sends arbitrary dict structure over the wire, and receives the same data"""
>       assert device_send(nkfido2_client, test_data, Command.TEST_PING)

test_comm.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047712c70>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
Sending data=a1636b65795903b05a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
Sending data=b'\xa1ckeyY\x03\xb0ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'
Send Command.TEST_PING
CBOR encoded data dict (to send): (955) a1636b65795903b05a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
955 0/5 221 226 010005ddddb80301a1636b65795903b05a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a
Captured log call
*   1326ms pcsc.py:101 apdu b'10020300fa42424242424242424242424242424242424242424242424242424242424242424141414141414141414141414141414141414141414141414141414141414141e7228c2790f6010005ddddb80301a1636b65795903b05a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a'
*   1345ms pcsc.py:104 response [0x9000] b''
*   1345ms pcsc.py:101 apdu b'000203002e5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a00'
*   1353ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping_2[100] 0:00:00.015653

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, ping_len = 100

    @pytest.mark.parametrize("ping_len", [
        # 56,
        # 57,
        100,
        # 512,
        980,
        # 990,
        # *list(range(981, 991, 1)),
    ])
    def test_ping_2(nkfido2_client: NKFido2Client, ping_len: int):
        assert ping_len < 2000
        """Sends arbitrary dict structure over the wire, and receives the same data"""
        d = dict(k=b'A' * ping_len)
>       success, read_data_bytes = send_and_receive(nkfido2_client, Command.TEST_PING, d)

test_comm.py:93: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0477125e0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1376ms communication.py:77 Sending data: {'k': b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'}
Sending data=a1616b586441414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141
Sending data=b'\xa1akXdAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
Send Command.TEST_PING
CBOR encoded data dict (to send): (108) a1616b586441414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141
108 0/1 221 113 010001dd6c690001a1616b586441414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141
Captured log call
*   1376ms communication.py:77 Sending data: {'k': b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'}
*   1376ms pcsc.py:101 apdu b'00020300b74242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414176228c2790f6010001dd6c690001a1616b58644141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414100'
*   1391ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_ping_2[980] 0:00:00.028016

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, ping_len = 980

    @pytest.mark.parametrize("ping_len", [
        # 56,
        # 57,
        100,
        # 512,
        980,
        # 990,
        # *list(range(981, 991, 1)),
    ])
    def test_ping_2(nkfido2_client: NKFido2Client, ping_len: int):
        assert ping_len < 2000
        """Sends arbitrary dict structure over the wire, and receives the same data"""
        d = dict(k=b'A' * ping_len)
>       success, read_data_bytes = send_and_receive(nkfido2_client, Command.TEST_PING, d)

test_comm.py:93: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0477e93b0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1415ms communication.py:77 Sending data: {'k': b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'}
Sending data=a1616b5903d44141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141
Sending data=b'\xa1akY\x03\xd4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
Send Command.TEST_PING
CBOR encoded data dict (to send): (989) a1616b5903d44141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141
989 0/5 221 226 010005ddddda0301a1616b5903d44141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141
Captured log call
*   1415ms communication.py:77 Sending data: {'k': b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'}
*   1416ms pcsc.py:101 apdu b'10020300fa42424242424242424242424242424242424242424242424242424242424242424141414141414141414141414141414141414141414141414141414141414141e7228c2790f6010005ddddda0301a1616b5903d441414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141'
*   1435ms pcsc.py:104 response [0x9000] b''
*   1435ms pcsc.py:101 apdu b'000203002e4141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414100'
*   1442ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_setup_session 0:00:00.011182

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    @functools.lru_cache(maxsize=None)
    def test_setup_session(nkfido2_client):
        log.debug('Setting session')
>       send_and_receive(nkfido2_client, Command.FACTORY_RESET)

test_comm.py:111: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0476f9c20>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* DEBUG   1467ms test_comm.py:110 Setting session
* INFO   1467ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.FACTORY_RESET
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050006a162545040
Captured log call
*   1467ms test_comm.py:110 Setting session
*   1467ms communication.py:77 Sending data: {}
*   1468ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050006a16254504000'
*   1478ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_generate[1-10] 0:00:00.011874

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    @pytest.mark.repeat(10)
    def test_generate(nkfido2_client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY)

test_comm.py:158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0476f9270>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1502ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050012a162545040
Captured log call
*   1502ms communication.py:77 Sending data: {}
*   1502ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050012a16254504000'
*   1513ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_generate[2-10] 0:00:00.011300

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    @pytest.mark.repeat(10)
    def test_generate(nkfido2_client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY)

test_comm.py:158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047700ef0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1552ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050012a162545040
Captured log call
*   1552ms communication.py:77 Sending data: {}
*   1553ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050012a16254504000'
*   1563ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_generate[3-10] 0:00:00.011444

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    @pytest.mark.repeat(10)
    def test_generate(nkfido2_client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY)

test_comm.py:158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa04771f040>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1592ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050012a162545040
Captured log call
*   1592ms communication.py:77 Sending data: {}
*   1592ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050012a16254504000'
*   1602ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_generate[4-10] 0:00:00.011272

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    @pytest.mark.repeat(10)
    def test_generate(nkfido2_client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY)

test_comm.py:158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa04771f810>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1631ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050012a162545040
Captured log call
*   1631ms communication.py:77 Sending data: {}
*   1632ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050012a16254504000'
*   1642ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_generate[5-10] 0:00:00.011365

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    @pytest.mark.repeat(10)
    def test_generate(nkfido2_client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY)

test_comm.py:158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0476d9b80>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1684ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050012a162545040
Captured log call
*   1684ms communication.py:77 Sending data: {}
*   1685ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050012a16254504000'
*   1695ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_generate[6-10] 0:00:00.011438

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    @pytest.mark.repeat(10)
    def test_generate(nkfido2_client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY)

test_comm.py:158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0476d9810>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1730ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050012a162545040
Captured log call
*   1730ms communication.py:77 Sending data: {}
*   1730ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050012a16254504000'
*   1741ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_generate[7-10] 0:00:00.011375

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    @pytest.mark.repeat(10)
    def test_generate(nkfido2_client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY)

test_comm.py:158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0477b44f0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1769ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050012a162545040
Captured log call
*   1769ms communication.py:77 Sending data: {}
*   1769ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050012a16254504000'
*   1779ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_generate[8-10] 0:00:00.011381

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    @pytest.mark.repeat(10)
    def test_generate(nkfido2_client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY)

test_comm.py:158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0476eea90>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1807ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050012a162545040
Captured log call
*   1807ms communication.py:77 Sending data: {}
*   1807ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050012a16254504000'
*   1818ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_generate[9-10] 0:00:00.011408

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    @pytest.mark.repeat(10)
    def test_generate(nkfido2_client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY)

test_comm.py:158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0476ee590>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1846ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050012a162545040
Captured log call
*   1846ms communication.py:77 Sending data: {}
*   1846ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050012a16254504000'
*   1856ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_generate[10-10] 0:00:00.011366

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    @pytest.mark.repeat(10)
    def test_generate(nkfido2_client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY)

test_comm.py:158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047860590>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1884ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050012a162545040
Captured log call
*   1884ms communication.py:77 Sending data: {}
*   1884ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050012a16254504000'
*   1894ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_generate_from_data 0:00:00.012660

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_generate_from_data(nkfido2_client):
        data = {"HASH": sha256(b"test").digest()}
>       read_data = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY_FROM_DATA, data)

test_comm.py:177: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa04783e040>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   1933ms communication.py:77 Sending data: {'HASH': b'\x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08'}
Sending command with temp auth token=
Sending data=a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
Sending data=b'\xa2dHASHX \x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08bTP@'
Send Command.GENERATE_KEY_FROM_DATA
CBOR encoded data dict (to send): (47) a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
47 0/1 221 52 010001dd2f2c0015a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
Captured log call
*   1933ms communication.py:77 Sending data: {'HASH': b'\x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08'}
*   1934ms pcsc.py:101 apdu b'000203007a4242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414139228c2790f6010001dd2f2c0015a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a086254504000'
*   1945ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_sign_bad_keyhandle 0:00:00.014422

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_sign_bad_keyhandle(nkfido2_client):
        # TODO add test like this to every command accepting it
        message = b"test_message"
        hash_data = sha256(message).digest()
        kh = STATE["KEYHANDLE"]
        kh = b'x' + kh[1:]
        data = {'HASH': hash_data, "KEYHANDLE": kh}
        helper_view_data(data)
>       send_and_receive(nkfido2_client, Command.SIGN, data, expected_error=ExecError.ERR_BAD_FORMAT)

test_comm.py:206: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa04783ed60>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* DEBUG   1973ms test_comm.py:126 HASH: 32 3b7491dc016ac1a0b2e02372402c861fafa459294087e7cbe09f704d582d931f
* DEBUG   1973ms test_comm.py:126 KEYHANDLE: 1 78
* INFO   1973ms communication.py:77 Sending data: {'HASH': b';t\x91\xdc\x01j\xc1\xa0\xb2\xe0#r@,\x86\x1f\xaf\xa4Y)@\x87\xe7\xcb\xe0\x9fpMX-\x93\x1f', 'KEYHANDLE': b'x'}
Sending command with temp auth token=
Sending data=a3644841534858203b7491dc016ac1a0b2e02372402c861fafa459294087e7cbe09f704d582d931f694b455948414e444c45417862545040
Sending data=b'\xa3dHASHX ;t\x91\xdc\x01j\xc1\xa0\xb2\xe0#r@,\x86\x1f\xaf\xa4Y)@\x87\xe7\xcb\xe0\x9fpMX-\x93\x1fiKEYHANDLEAxbTP@'
Send Command.SIGN
CBOR encoded data dict (to send): (59) a3644841534858203b7491dc016ac1a0b2e02372402c861fafa459294087e7cbe09f704d582d931f694b455948414e444c45417862545040
59 0/1 221 64 010001dd3b380013a3644841534858203b7491dc016ac1a0b2e02372402c861fafa459294087e7cbe09f704d582d931f694b455948414e444c45417862545040
Captured log call
*   1973ms test_comm.py:126 HASH: 32 3b7491dc016ac1a0b2e02372402c861fafa459294087e7cbe09f704d582d931f
*   1973ms test_comm.py:126 KEYHANDLE: 1 78
*   1973ms communication.py:77 Sending data: {'HASH': b';t\x91\xdc\x01j\xc1\xa0\xb2\xe0#r@,\x86\x1f\xaf\xa4Y)@\x87\xe7\xcb\xe0\x9fpMX-\x93\x1f', 'KEYHANDLE': b'x'}
*   1973ms pcsc.py:101 apdu b'00020300864242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414145228c2790f6010001dd3b380013a3644841534858203b7491dc016ac1a0b2e02372402c861fafa459294087e7cbe09f704d582d931f694b455948414e444c4541786254504000'
*   1986ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_sign[secp256r1-1-10] 0:00:00.000643

AssertionError: test_generate needs to be run first
assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, curve = 'secp256r1'

    @pytest.mark.parametrize("curve", [
        # pytest.param('secp256k1',
        #              marks=pytest.mark.xfail(reason='curve must be enabled in the firmware to work')),
        pytest.param('secp256r1')
        # marks=pytest.mark.xfail(reason='not implemented')),
    ])
    @pytest.mark.repeat(10)
    def test_sign(nkfido2_client, curve):
        global STATE
        assert STATE
>       assert "KEYHANDLE" in STATE and STATE["KEYHANDLE"], "test_generate needs to be run first"
E       AssertionError: test_generate needs to be run first
E       assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

test_comm.py:219: AssertionError

Teardown

FAILED test_sign[secp256r1-2-10] 0:00:00.000686

AssertionError: test_generate needs to be run first
assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, curve = 'secp256r1'

    @pytest.mark.parametrize("curve", [
        # pytest.param('secp256k1',
        #              marks=pytest.mark.xfail(reason='curve must be enabled in the firmware to work')),
        pytest.param('secp256r1')
        # marks=pytest.mark.xfail(reason='not implemented')),
    ])
    @pytest.mark.repeat(10)
    def test_sign(nkfido2_client, curve):
        global STATE
        assert STATE
>       assert "KEYHANDLE" in STATE and STATE["KEYHANDLE"], "test_generate needs to be run first"
E       AssertionError: test_generate needs to be run first
E       assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

test_comm.py:219: AssertionError

Teardown

FAILED test_sign[secp256r1-3-10] 0:00:00.000684

AssertionError: test_generate needs to be run first
assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, curve = 'secp256r1'

    @pytest.mark.parametrize("curve", [
        # pytest.param('secp256k1',
        #              marks=pytest.mark.xfail(reason='curve must be enabled in the firmware to work')),
        pytest.param('secp256r1')
        # marks=pytest.mark.xfail(reason='not implemented')),
    ])
    @pytest.mark.repeat(10)
    def test_sign(nkfido2_client, curve):
        global STATE
        assert STATE
>       assert "KEYHANDLE" in STATE and STATE["KEYHANDLE"], "test_generate needs to be run first"
E       AssertionError: test_generate needs to be run first
E       assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

test_comm.py:219: AssertionError

Teardown

FAILED test_sign[secp256r1-4-10] 0:00:00.000656

AssertionError: test_generate needs to be run first
assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, curve = 'secp256r1'

    @pytest.mark.parametrize("curve", [
        # pytest.param('secp256k1',
        #              marks=pytest.mark.xfail(reason='curve must be enabled in the firmware to work')),
        pytest.param('secp256r1')
        # marks=pytest.mark.xfail(reason='not implemented')),
    ])
    @pytest.mark.repeat(10)
    def test_sign(nkfido2_client, curve):
        global STATE
        assert STATE
>       assert "KEYHANDLE" in STATE and STATE["KEYHANDLE"], "test_generate needs to be run first"
E       AssertionError: test_generate needs to be run first
E       assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

test_comm.py:219: AssertionError

Teardown

FAILED test_sign[secp256r1-5-10] 0:00:00.000643

AssertionError: test_generate needs to be run first
assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, curve = 'secp256r1'

    @pytest.mark.parametrize("curve", [
        # pytest.param('secp256k1',
        #              marks=pytest.mark.xfail(reason='curve must be enabled in the firmware to work')),
        pytest.param('secp256r1')
        # marks=pytest.mark.xfail(reason='not implemented')),
    ])
    @pytest.mark.repeat(10)
    def test_sign(nkfido2_client, curve):
        global STATE
        assert STATE
>       assert "KEYHANDLE" in STATE and STATE["KEYHANDLE"], "test_generate needs to be run first"
E       AssertionError: test_generate needs to be run first
E       assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

test_comm.py:219: AssertionError

Teardown

FAILED test_sign[secp256r1-6-10] 0:00:00.000639

AssertionError: test_generate needs to be run first
assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, curve = 'secp256r1'

    @pytest.mark.parametrize("curve", [
        # pytest.param('secp256k1',
        #              marks=pytest.mark.xfail(reason='curve must be enabled in the firmware to work')),
        pytest.param('secp256r1')
        # marks=pytest.mark.xfail(reason='not implemented')),
    ])
    @pytest.mark.repeat(10)
    def test_sign(nkfido2_client, curve):
        global STATE
        assert STATE
>       assert "KEYHANDLE" in STATE and STATE["KEYHANDLE"], "test_generate needs to be run first"
E       AssertionError: test_generate needs to be run first
E       assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

test_comm.py:219: AssertionError

Teardown

FAILED test_sign[secp256r1-7-10] 0:00:00.000726

AssertionError: test_generate needs to be run first
assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, curve = 'secp256r1'

    @pytest.mark.parametrize("curve", [
        # pytest.param('secp256k1',
        #              marks=pytest.mark.xfail(reason='curve must be enabled in the firmware to work')),
        pytest.param('secp256r1')
        # marks=pytest.mark.xfail(reason='not implemented')),
    ])
    @pytest.mark.repeat(10)
    def test_sign(nkfido2_client, curve):
        global STATE
        assert STATE
>       assert "KEYHANDLE" in STATE and STATE["KEYHANDLE"], "test_generate needs to be run first"
E       AssertionError: test_generate needs to be run first
E       assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

test_comm.py:219: AssertionError

Teardown

FAILED test_sign[secp256r1-8-10] 0:00:00.000620

AssertionError: test_generate needs to be run first
assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, curve = 'secp256r1'

    @pytest.mark.parametrize("curve", [
        # pytest.param('secp256k1',
        #              marks=pytest.mark.xfail(reason='curve must be enabled in the firmware to work')),
        pytest.param('secp256r1')
        # marks=pytest.mark.xfail(reason='not implemented')),
    ])
    @pytest.mark.repeat(10)
    def test_sign(nkfido2_client, curve):
        global STATE
        assert STATE
>       assert "KEYHANDLE" in STATE and STATE["KEYHANDLE"], "test_generate needs to be run first"
E       AssertionError: test_generate needs to be run first
E       assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

test_comm.py:219: AssertionError

Teardown

FAILED test_sign[secp256r1-9-10] 0:00:00.000616

AssertionError: test_generate needs to be run first
assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, curve = 'secp256r1'

    @pytest.mark.parametrize("curve", [
        # pytest.param('secp256k1',
        #              marks=pytest.mark.xfail(reason='curve must be enabled in the firmware to work')),
        pytest.param('secp256r1')
        # marks=pytest.mark.xfail(reason='not implemented')),
    ])
    @pytest.mark.repeat(10)
    def test_sign(nkfido2_client, curve):
        global STATE
        assert STATE
>       assert "KEYHANDLE" in STATE and STATE["KEYHANDLE"], "test_generate needs to be run first"
E       AssertionError: test_generate needs to be run first
E       assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

test_comm.py:219: AssertionError

Teardown

FAILED test_sign[secp256r1-10-10] 0:00:00.000637

AssertionError: test_generate needs to be run first
assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, curve = 'secp256r1'

    @pytest.mark.parametrize("curve", [
        # pytest.param('secp256k1',
        #              marks=pytest.mark.xfail(reason='curve must be enabled in the firmware to work')),
        pytest.param('secp256r1')
        # marks=pytest.mark.xfail(reason='not implemented')),
    ])
    @pytest.mark.repeat(10)
    def test_sign(nkfido2_client, curve):
        global STATE
        assert STATE
>       assert "KEYHANDLE" in STATE and STATE["KEYHANDLE"], "test_generate needs to be run first"
E       AssertionError: test_generate needs to be run first
E       assert ('KEYHANDLE' in {'KEYHANDLE': b'', 'PUBKEY': b''} and b'')

test_comm.py:219: AssertionError

Teardown

PASSED test_helper_round[param0] 0:00:00.000450

Setup

Call

Teardown

PASSED test_helper_round[param1] 0:00:00.000429

Setup

Call

Teardown

PASSED test_helper_round[param2] 0:00:00.000419

Setup

Call

Teardown

PASSED test_helper_round[param3] 0:00:00.000429

Setup

Call

Teardown

FAILED test_decrypt[True] 0:00:00.009235

ecdsa.errors.MalformedPointError: Length of string does not match lengths of any of the enabled (hybrid, raw, compressed, uncompressed) encodings of the curve.

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
send_correct_hmac = True

    @pytest.mark.parametrize("send_correct_hmac", [
        True,
        False,
    ])
    def test_decrypt(nkfido2_client, send_correct_hmac):
        assert "KEYHANDLE" in STATE, "test_generate needs to be run first"
    
        msg = b'Text to be encrypted by ECC public key and ' \
              b'decrypted by its corresponding ECC private key'
        log.debug(f"original msg: {msg}")
    
        ecdh = ECDH(curve=NIST256p)
        ecdh.generate_private_key()
        local_public_key = ecdh.get_public_key()
>       ecdh.load_received_public_key_bytes(STATE["PUBKEY"])

test_comm.py:287: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/ecdsa/ecdh.py:259: in load_received_public_key_bytes
    VerifyingKey.from_string(
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/ecdsa/keys.py:275: in from_string
    point = PointJacobi.from_bytes(
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/ecdsa/ellipticcurve.py:575: in from_bytes
    coord_x, coord_y = super(PointJacobi, cls).from_bytes(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'ecdsa.ellipticcurve.PointJacobi'>
curve = <ecdsa.ellipticcurve.CurveFp object at 0x7fa049fad8b0>, data = <memory at 0x7fa047880880>
validate_encoding = True, valid_encodings = {'compressed', 'hybrid', 'raw', 'uncompressed'}

    @classmethod
    def from_bytes(
        cls, curve, data, validate_encoding=True, valid_encodings=None
    ):
        """
        Initialise the object from byte encoding of a point.
    
        The method does accept and automatically detect the type of point
        encoding used. It supports the :term:`raw encoding`,
        :term:`uncompressed`, :term:`compressed`, and :term:`hybrid` encodings.
    
        Note: generally you will want to call the ``from_bytes()`` method of
        either a child class, PointJacobi or Point.
    
        :param data: single point encoding of the public key
        :type data: :term:`bytes-like object`
        :param curve: the curve on which the public key is expected to lay
        :type curve: ~ecdsa.ellipticcurve.CurveFp
        :param validate_encoding: whether to verify that the encoding of the
            point is self-consistent, defaults to True, has effect only
            on ``hybrid`` encoding
        :type validate_encoding: bool
        :param valid_encodings: list of acceptable point encoding formats,
            supported ones are: :term:`uncompressed`, :term:`compressed`,
            :term:`hybrid`, and :term:`raw encoding` (specified with ``raw``
            name). All formats by default (specified with ``None``).
        :type valid_encodings: :term:`set-like object`
    
        :raises `~ecdsa.errors.MalformedPointError`: if the public point does
            not lay on the curve or the encoding is invalid
    
        :return: x and y coordinates of the encoded point
        :rtype: tuple(int, int)
        """
        if not valid_encodings:
            valid_encodings = set(
                ["uncompressed", "compressed", "hybrid", "raw"]
            )
        if not all(
            i in set(("uncompressed", "compressed", "hybrid", "raw"))
            for i in valid_encodings
        ):
            raise ValueError(
                "Only uncompressed, compressed, hybrid or raw encoding "
                "supported."
            )
        data = normalise_bytes(data)
    
        if isinstance(curve, CurveEdTw):
            return cls._from_edwards(curve, data)
    
        key_len = len(data)
        raw_encoding_length = 2 * orderlen(curve.p())
        if key_len == raw_encoding_length and "raw" in valid_encodings:
            coord_x, coord_y = cls._from_raw_encoding(
                data, raw_encoding_length
            )
        elif key_len == raw_encoding_length + 1 and (
            "hybrid" in valid_encodings or "uncompressed" in valid_encodings
        ):
            if data[:1] in (b"\x06", b"\x07") and "hybrid" in valid_encodings:
                coord_x, coord_y = cls._from_hybrid(
                    data, raw_encoding_length, validate_encoding
                )
            elif data[:1] == b"\x04" and "uncompressed" in valid_encodings:
                coord_x, coord_y = cls._from_raw_encoding(
                    data[1:], raw_encoding_length
                )
            else:
                raise MalformedPointError(
                    "Invalid X9.62 encoding of the public point"
                )
        elif (
            key_len == raw_encoding_length // 2 + 1
            and "compressed" in valid_encodings
        ):
            coord_x, coord_y = cls._from_compressed(data, curve)
        else:
>           raise MalformedPointError(
                "Length of string does not match lengths of "
                "any of the enabled ({0}) encodings of the "
                "curve.".format(", ".join(valid_encodings))
            )
E           ecdsa.errors.MalformedPointError: Length of string does not match lengths of any of the enabled (hybrid, raw, compressed, uncompressed) encodings of the curve.

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/ecdsa/ellipticcurve.py:409: MalformedPointError
Captured stderr call
* DEBUG   2139ms test_comm.py:282 original msg: b'Text to be encrypted by ECC public key and decrypted by its corresponding ECC private key'
Captured log call
*   2139ms test_comm.py:282 original msg: b'Text to be encrypted by ECC public key and decrypted by its corresponding ECC private key'

Teardown

FAILED test_decrypt[False] 0:00:00.001506

ecdsa.errors.MalformedPointError: Length of string does not match lengths of any of the enabled (hybrid, raw, compressed, uncompressed) encodings of the curve.

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
send_correct_hmac = False

    @pytest.mark.parametrize("send_correct_hmac", [
        True,
        False,
    ])
    def test_decrypt(nkfido2_client, send_correct_hmac):
        assert "KEYHANDLE" in STATE, "test_generate needs to be run first"
    
        msg = b'Text to be encrypted by ECC public key and ' \
              b'decrypted by its corresponding ECC private key'
        log.debug(f"original msg: {msg}")
    
        ecdh = ECDH(curve=NIST256p)
        ecdh.generate_private_key()
        local_public_key = ecdh.get_public_key()
>       ecdh.load_received_public_key_bytes(STATE["PUBKEY"])

test_comm.py:287: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/ecdsa/ecdh.py:259: in load_received_public_key_bytes
    VerifyingKey.from_string(
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/ecdsa/keys.py:275: in from_string
    point = PointJacobi.from_bytes(
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/ecdsa/ellipticcurve.py:575: in from_bytes
    coord_x, coord_y = super(PointJacobi, cls).from_bytes(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'ecdsa.ellipticcurve.PointJacobi'>
curve = <ecdsa.ellipticcurve.CurveFp object at 0x7fa049fad8b0>, data = <memory at 0x7fa047880b80>
validate_encoding = True, valid_encodings = {'compressed', 'hybrid', 'raw', 'uncompressed'}

    @classmethod
    def from_bytes(
        cls, curve, data, validate_encoding=True, valid_encodings=None
    ):
        """
        Initialise the object from byte encoding of a point.
    
        The method does accept and automatically detect the type of point
        encoding used. It supports the :term:`raw encoding`,
        :term:`uncompressed`, :term:`compressed`, and :term:`hybrid` encodings.
    
        Note: generally you will want to call the ``from_bytes()`` method of
        either a child class, PointJacobi or Point.
    
        :param data: single point encoding of the public key
        :type data: :term:`bytes-like object`
        :param curve: the curve on which the public key is expected to lay
        :type curve: ~ecdsa.ellipticcurve.CurveFp
        :param validate_encoding: whether to verify that the encoding of the
            point is self-consistent, defaults to True, has effect only
            on ``hybrid`` encoding
        :type validate_encoding: bool
        :param valid_encodings: list of acceptable point encoding formats,
            supported ones are: :term:`uncompressed`, :term:`compressed`,
            :term:`hybrid`, and :term:`raw encoding` (specified with ``raw``
            name). All formats by default (specified with ``None``).
        :type valid_encodings: :term:`set-like object`
    
        :raises `~ecdsa.errors.MalformedPointError`: if the public point does
            not lay on the curve or the encoding is invalid
    
        :return: x and y coordinates of the encoded point
        :rtype: tuple(int, int)
        """
        if not valid_encodings:
            valid_encodings = set(
                ["uncompressed", "compressed", "hybrid", "raw"]
            )
        if not all(
            i in set(("uncompressed", "compressed", "hybrid", "raw"))
            for i in valid_encodings
        ):
            raise ValueError(
                "Only uncompressed, compressed, hybrid or raw encoding "
                "supported."
            )
        data = normalise_bytes(data)
    
        if isinstance(curve, CurveEdTw):
            return cls._from_edwards(curve, data)
    
        key_len = len(data)
        raw_encoding_length = 2 * orderlen(curve.p())
        if key_len == raw_encoding_length and "raw" in valid_encodings:
            coord_x, coord_y = cls._from_raw_encoding(
                data, raw_encoding_length
            )
        elif key_len == raw_encoding_length + 1 and (
            "hybrid" in valid_encodings or "uncompressed" in valid_encodings
        ):
            if data[:1] in (b"\x06", b"\x07") and "hybrid" in valid_encodings:
                coord_x, coord_y = cls._from_hybrid(
                    data, raw_encoding_length, validate_encoding
                )
            elif data[:1] == b"\x04" and "uncompressed" in valid_encodings:
                coord_x, coord_y = cls._from_raw_encoding(
                    data[1:], raw_encoding_length
                )
            else:
                raise MalformedPointError(
                    "Invalid X9.62 encoding of the public point"
                )
        elif (
            key_len == raw_encoding_length // 2 + 1
            and "compressed" in valid_encodings
        ):
            coord_x, coord_y = cls._from_compressed(data, curve)
        else:
>           raise MalformedPointError(
                "Length of string does not match lengths of "
                "any of the enabled ({0}) encodings of the "
                "curve.".format(", ".join(valid_encodings))
            )
E           ecdsa.errors.MalformedPointError: Length of string does not match lengths of any of the enabled (hybrid, raw, compressed, uncompressed) encodings of the curve.

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/ecdsa/ellipticcurve.py:409: MalformedPointError
Captured stderr call
* DEBUG   2193ms test_comm.py:282 original msg: b'Text to be encrypted by ECC public key and decrypted by its corresponding ECC private key'
Captured log call
*   2193ms test_comm.py:282 original msg: b'Text to be encrypted by ECC public key and decrypted by its corresponding ECC private key'

Teardown

FAILED test_status 0:00:00.011528

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_status(nkfido2_client: NKFido2Client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.STATUS)

test_comm.py:332: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0477a5b80>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2252ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.STATUS
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050000a162545040
Captured log call
*   2252ms communication.py:77 Sending data: {}
*   2252ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050000a16254504000'
*   2263ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_initialize_simple 0:00:00.011325

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_initialize_simple(nkfido2_client: NKFido2Client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.INITIALIZE_SEED)

test_comm.py:356: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047589c70>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2291ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.INITIALIZE_SEED
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050010a162545040
Captured log call
*   2291ms communication.py:77 Sending data: {}
*   2291ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050010a16254504000'
*   2301ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_initialize_simple2 0:00:00.011093

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_initialize_simple2(nkfido2_client: NKFido2Client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.INITIALIZE_SEED)

test_comm.py:362: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0475fc8b0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2329ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.INITIALIZE_SEED
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050010a162545040
Captured log call
*   2329ms communication.py:77 Sending data: {}
*   2329ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050010a16254504000'
*   2339ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_initialize 0:00:00.012455

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_initialize(nkfido2_client: NKFido2Client):
        data = {"HASH": sha256(b"test").digest()}
>       key1 = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY_FROM_DATA, data)

test_comm.py:374: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa04760a270>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2366ms communication.py:77 Sending data: {'HASH': b'\x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08'}
Sending command with temp auth token=
Sending data=a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
Sending data=b'\xa2dHASHX \x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08bTP@'
Send Command.GENERATE_KEY_FROM_DATA
CBOR encoded data dict (to send): (47) a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
47 0/1 221 52 010001dd2f2c0015a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
Captured log call
*   2366ms communication.py:77 Sending data: {'HASH': b'\x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08'}
*   2366ms pcsc.py:101 apdu b'000203007a4242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414139228c2790f6010001dd2f2c0015a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a086254504000'
*   2378ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_restore_simple 0:00:00.014433

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_restore_simple(nkfido2_client: NKFido2Client):
        data = {"MASTER": b'1' * 32, "SALT": b'2' * 8}
>       read_data = send_and_receive_cbor(nkfido2_client, Command.RESTORE_FROM_SEED, data)

test_comm.py:386: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa04760abd0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2406ms communication.py:77 Sending data: {'MASTER': b'11111111111111111111111111111111', 'SALT': b'22222222'}
Sending command with temp auth token=
Sending data=a3664d4153544552582031313131313131313131313131313131313131313131313131313131313131316453414c5448323232323232323262545040
Sending data=b'\xa3fMASTERX 11111111111111111111111111111111dSALTH22222222bTP@'
Send Command.RESTORE_FROM_SEED
CBOR encoded data dict (to send): (63) a3664d4153544552582031313131313131313131313131313131313131313131313131313131313131316453414c5448323232323232323262545040
63 0/1 221 68 010001dd3f3c0011a3664d4153544552582031313131313131313131313131313131313131313131313131313131313131316453414c5448323232323232323262545040
Captured log call
*   2406ms communication.py:77 Sending data: {'MASTER': b'11111111111111111111111111111111', 'SALT': b'22222222'}
*   2406ms pcsc.py:101 apdu b'000203008a4242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414149228c2790f6010001dd3f3c0011a3664d4153544552582031313131313131313131313131313131313131313131313131313131313131316453414c544832323232323232326254504000'
*   2419ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_restore[test_input0] 0:00:00.013318

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_input = (b'00000000000000000000000000000000', b'00000000')

    @pytest.mark.parametrize("test_input", [
        # (b'0' * 32, b'0' * 8),  # firstly set all to zero
        # (b'0' * 32, b'1' * 8),  # check if changing only salts changes the generated keys
    
        # do not check SALT changes for now
        (b'0' * 32, b'0' * 8),  # reset all to zero again
        (b'1' * 32, b'0' * 8),  # check if changing only master changes the generated keys
        (b'0' * 32, b'0' * 8),  # reset all to zero again
    ])
    def test_restore(nkfido2_client: NKFido2Client, test_input):
        master, salt = test_input
        data_key = {"HASH": sha256(b"test").digest()}
        data = {"MASTER": master, "SALT": salt}
>       key1 = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY_FROM_DATA, data_key)

test_comm.py:404: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047815220>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2448ms communication.py:77 Sending data: {'HASH': b'\x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08'}
Sending command with temp auth token=
Sending data=a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
Sending data=b'\xa2dHASHX \x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08bTP@'
Send Command.GENERATE_KEY_FROM_DATA
CBOR encoded data dict (to send): (47) a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
47 0/1 221 52 010001dd2f2c0015a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
Captured log call
*   2448ms communication.py:77 Sending data: {'HASH': b'\x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08'}
*   2448ms pcsc.py:101 apdu b'000203007a4242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414139228c2790f6010001dd2f2c0015a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a086254504000'
*   2460ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_restore[test_input1] 0:00:00.013136

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_input = (b'11111111111111111111111111111111', b'00000000')

    @pytest.mark.parametrize("test_input", [
        # (b'0' * 32, b'0' * 8),  # firstly set all to zero
        # (b'0' * 32, b'1' * 8),  # check if changing only salts changes the generated keys
    
        # do not check SALT changes for now
        (b'0' * 32, b'0' * 8),  # reset all to zero again
        (b'1' * 32, b'0' * 8),  # check if changing only master changes the generated keys
        (b'0' * 32, b'0' * 8),  # reset all to zero again
    ])
    def test_restore(nkfido2_client: NKFido2Client, test_input):
        master, salt = test_input
        data_key = {"HASH": sha256(b"test").digest()}
        data = {"MASTER": master, "SALT": salt}
>       key1 = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY_FROM_DATA, data_key)

test_comm.py:404: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0477f9040>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2488ms communication.py:77 Sending data: {'HASH': b'\x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08'}
Sending command with temp auth token=
Sending data=a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
Sending data=b'\xa2dHASHX \x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08bTP@'
Send Command.GENERATE_KEY_FROM_DATA
CBOR encoded data dict (to send): (47) a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
47 0/1 221 52 010001dd2f2c0015a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
Captured log call
*   2488ms communication.py:77 Sending data: {'HASH': b'\x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08'}
*   2489ms pcsc.py:101 apdu b'000203007a4242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414139228c2790f6010001dd2f2c0015a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a086254504000'
*   2501ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_restore[test_input2] 0:00:00.012760

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>
test_input = (b'00000000000000000000000000000000', b'00000000')

    @pytest.mark.parametrize("test_input", [
        # (b'0' * 32, b'0' * 8),  # firstly set all to zero
        # (b'0' * 32, b'1' * 8),  # check if changing only salts changes the generated keys
    
        # do not check SALT changes for now
        (b'0' * 32, b'0' * 8),  # reset all to zero again
        (b'1' * 32, b'0' * 8),  # check if changing only master changes the generated keys
        (b'0' * 32, b'0' * 8),  # reset all to zero again
    ])
    def test_restore(nkfido2_client: NKFido2Client, test_input):
        master, salt = test_input
        data_key = {"HASH": sha256(b"test").digest()}
        data = {"MASTER": master, "SALT": salt}
>       key1 = send_and_receive_cbor(nkfido2_client, Command.GENERATE_KEY_FROM_DATA, data_key)

test_comm.py:404: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0477f9db0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2544ms communication.py:77 Sending data: {'HASH': b'\x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08'}
Sending command with temp auth token=
Sending data=a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
Sending data=b'\xa2dHASHX \x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08bTP@'
Send Command.GENERATE_KEY_FROM_DATA
CBOR encoded data dict (to send): (47) a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
47 0/1 221 52 010001dd2f2c0015a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a0862545040
Captured log call
*   2544ms communication.py:77 Sending data: {'HASH': b'\x9f\x86\xd0\x81\x88L}e\x9a/\xea\xa0\xc5Z\xd0\x15\xa3\xbfO\x1b+\x0b\x82,\xd1]l\x15\xb0\xf0\n\x08'}
*   2544ms pcsc.py:101 apdu b'000203007a4242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414139228c2790f6010001dd2f2c0015a2644841534858209f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a086254504000'
*   2556ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_PIN_attempts_deprecated 0:00:00.011140

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_PIN_attempts_deprecated(nkfido2_client: NKFido2Client):
>       send_and_receive(nkfido2_client, Command.PIN_ATTEMPTS, expected_error=ExecError.ERR_INVALID_COMMAND)

test_comm.py:414: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0476b15e0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2585ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.PIN_ATTEMPTS
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050007a162545040
Captured log call
*   2585ms communication.py:77 Sending data: {}
*   2585ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050007a16254504000'
*   2595ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_resident_keys_generate 0:00:00.011193

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_resident_keys_generate(nkfido2_client: NKFido2Client):
>       read_data = send_and_receive_cbor(nkfido2_client, Command.GENERATE_RESIDENT_KEY)

test_comm.py:418: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0476b1cc0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2620ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_RESIDENT_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050016a162545040
Captured log call
*   2620ms communication.py:77 Sending data: {}
*   2620ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050016a16254504000'
*   2631ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_resident_keys_write 0:00:00.011798

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_resident_keys_write(nkfido2_client: NKFido2Client):
>       helper_login(nkfido2_client, Constants.PIN)

test_comm.py:424: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:98: in helper_login
    s, data = send_and_receive(nkfido2_client, Command.SET_PIN, dict(PIN=PIN), check=False)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0476af2c0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2660ms communication.py:77 Sending data: {'PIN': b'12345678'}
Sending command with temp auth token=
Sending data=a26350494e48313233343536373862545040
Sending data=b'\xa2cPINH12345678bTP@'
Send Command.SET_PIN
CBOR encoded data dict (to send): (21) a26350494e48313233343536373862545040
21 0/1 221 26 010001dd1512000aa26350494e48313233343536373862545040
Captured log call
*   2660ms communication.py:77 Sending data: {'PIN': b'12345678'}
*   2660ms pcsc.py:101 apdu b'0002030060424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141411f228c2790f6010001dd1512000aa26350494e4831323334353637386254504000'
*   2671ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_resident_keys_read_public_key[1] 0:00:00.011409

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, iter = 1

    @pytest.mark.parametrize("iter", [1, 10])
    def test_resident_keys_read_public_key(nkfido2_client: NKFido2Client, iter):
        read_data = []
        for i in range(iter):
>           read_data1 = send_and_receive_cbor(nkfido2_client, Command.GENERATE_RESIDENT_KEY)

test_comm.py:445: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0476afa90>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2699ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_RESIDENT_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050016a162545040
Captured log call
*   2699ms communication.py:77 Sending data: {}
*   2699ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050016a16254504000'
*   2710ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_resident_keys_read_public_key[10] 0:00:00.011622

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>, iter = 10

    @pytest.mark.parametrize("iter", [1, 10])
    def test_resident_keys_read_public_key(nkfido2_client: NKFido2Client, iter):
        read_data = []
        for i in range(iter):
>           read_data1 = send_and_receive_cbor(nkfido2_client, Command.GENERATE_RESIDENT_KEY)

test_comm.py:445: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa04769af90>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2738ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.GENERATE_RESIDENT_KEY
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050016a162545040
Captured log call
*   2738ms communication.py:77 Sending data: {}
*   2738ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050016a16254504000'
*   2748ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_login 0:00:00.011519

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_login(nkfido2_client: NKFido2Client):
        # send PIN and get TP for the FIDO U2F communication
        #   (without the ability to confirm the command with the regular FIDO2 PIN request)
        # WC < PIN
        # WC > TP
>       s, data = send_and_receive(nkfido2_client, Command.SET_PIN, dict(PIN=Constants.PIN), check=False)

test_comm.py:468: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047666d10>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2777ms communication.py:77 Sending data: {'PIN': b'12345678'}
Sending command with temp auth token=
Sending data=a26350494e48313233343536373862545040
Sending data=b'\xa2cPINH12345678bTP@'
Send Command.SET_PIN
CBOR encoded data dict (to send): (21) a26350494e48313233343536373862545040
21 0/1 221 26 010001dd1512000aa26350494e48313233343536373862545040
Captured log call
*   2777ms communication.py:77 Sending data: {'PIN': b'12345678'}
*   2777ms pcsc.py:101 apdu b'0002030060424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141411f228c2790f6010001dd1512000aa26350494e4831323334353637386254504000'
*   2788ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_login_wrong 0:00:00.011689

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_login_wrong(nkfido2_client: NKFido2Client):
        data = {"PIN": Constants.PIN_BAD}
>       send_and_receive(nkfido2_client, Command.LOGIN, data, expected_error=ExecError.INVALID_PIN)

test_comm.py:478: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa047666900>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2812ms communication.py:77 Sending data: {'PIN': b'BAD PIN'}
Sending command with temp auth token=
Sending data=a26350494e474241442050494e62545040
Sending data=b'\xa2cPINGBAD PINbTP@'
Send Command.LOGIN
CBOR encoded data dict (to send): (20) a26350494e474241442050494e62545040
20 0/1 221 25 010001dd14110004a26350494e474241442050494e62545040
Captured log call
*   2812ms communication.py:77 Sending data: {'PIN': b'BAD PIN'}
*   2812ms pcsc.py:101 apdu b'000203005f424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141411e228c2790f6010001dd14110004a26350494e474241442050494e6254504000'
*   2823ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_login_wrong_attempt_counter 0:00:00.011014

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_login_wrong_attempt_counter(nkfido2_client: NKFido2Client):
        # Reset attempt counter
>       send_and_receive(nkfido2_client, Command.FACTORY_RESET)

test_comm.py:483: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0475ed770>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2862ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.FACTORY_RESET
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050006a162545040
Captured log call
*   2862ms communication.py:77 Sending data: {}
*   2862ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050006a16254504000'
*   2872ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_login2 0:00:00.012111

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_login2(nkfido2_client: NKFido2Client):
        # same as test_login, but checks if the generated tokens are different
        data = {"PIN": Constants.PIN}
>       read_data2 = send_and_receive_cbor(nkfido2_client, Command.LOGIN, data)

test_comm.py:503: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:346: in send_and_receive_cbor
    success, read_data_bytes = send_and_receive(*args, **kwargs)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0475edf40>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2897ms communication.py:77 Sending data: {'PIN': b'12345678'}
Sending command with temp auth token=
Sending data=a26350494e48313233343536373862545040
Sending data=b'\xa2cPINH12345678bTP@'
Send Command.LOGIN
CBOR encoded data dict (to send): (21) a26350494e48313233343536373862545040
21 0/1 221 26 010001dd15120004a26350494e48313233343536373862545040
Captured log call
*   2897ms communication.py:77 Sending data: {'PIN': b'12345678'}
*   2897ms pcsc.py:101 apdu b'0002030060424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141411f228c2790f6010001dd15120004a26350494e4831323334353637386254504000'
*   2908ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_logout 0:00:00.011991

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_logout(nkfido2_client: NKFido2Client):
        # check first if we are logged in
>       helper_login(nkfido2_client, Constants.PIN)

test_comm.py:516: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:98: in helper_login
    s, data = send_and_receive(nkfido2_client, Command.SET_PIN, dict(PIN=PIN), check=False)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0476639f0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2936ms communication.py:77 Sending data: {'PIN': b'12345678'}
Sending command with temp auth token=
Sending data=a26350494e48313233343536373862545040
Sending data=b'\xa2cPINH12345678bTP@'
Send Command.SET_PIN
CBOR encoded data dict (to send): (21) a26350494e48313233343536373862545040
21 0/1 221 26 010001dd1512000aa26350494e48313233343536373862545040
Captured log call
*   2936ms communication.py:77 Sending data: {'PIN': b'12345678'}
*   2937ms pcsc.py:101 apdu b'0002030060424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141411f228c2790f6010001dd1512000aa26350494e4831323334353637386254504000'
*   2948ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_factory_reset 0:00:00.011870

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_factory_reset(nkfido2_client: NKFido2Client):
        # Setup. Make sure we are logged in, and we can call commands normally
>       helper_login(nkfido2_client, Constants.PIN)

test_comm.py:544: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:98: in helper_login
    s, data = send_and_receive(nkfido2_client, Command.SET_PIN, dict(PIN=PIN), check=False)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0475b39a0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   2976ms communication.py:77 Sending data: {'PIN': b'12345678'}
Sending command with temp auth token=
Sending data=a26350494e48313233343536373862545040
Sending data=b'\xa2cPINH12345678bTP@'
Send Command.SET_PIN
CBOR encoded data dict (to send): (21) a26350494e48313233343536373862545040
21 0/1 221 26 010001dd1512000aa26350494e48313233343536373862545040
Captured log call
*   2976ms communication.py:77 Sending data: {'PIN': b'12345678'}
*   2976ms pcsc.py:101 apdu b'0002030060424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141411f228c2790f6010001dd1512000aa26350494e4831323334353637386254504000'
*   2987ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_pin_set_wrong_length 0:00:00.011362

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_pin_set_wrong_length(nkfido2_client: NKFido2Client):
        data = {"PIN": Constants.PIN_SHORT}
>       send_and_receive(nkfido2_client, Command.SET_PIN, data, expected_error=ExecError.ERR_NOT_ALLOWED)

test_comm.py:583: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0475b3450>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   3015ms communication.py:77 Sending data: {'PIN': b'aa'}
Sending command with temp auth token=
Sending data=a26350494e42616162545040
Sending data=b'\xa2cPINBaabTP@'
Send Command.SET_PIN
CBOR encoded data dict (to send): (15) a26350494e42616162545040
15 0/1 221 20 010001dd0f0c000aa26350494e42616162545040
Captured log call
*   3015ms communication.py:77 Sending data: {'PIN': b'aa'}
*   3015ms pcsc.py:101 apdu b'000203005a4242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414119228c2790f6010001dd0f0c000aa26350494e4261616254504000'
*   3025ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_pin_set 0:00:00.011097

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_pin_set(nkfido2_client: NKFido2Client):
        # condition: unset PIN (e.g. after a factory reset)
        # should fail due to not set PIN after the factory reset
>       send_and_receive(nkfido2_client, Command.FACTORY_RESET)

test_comm.py:592: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0474cfdb0>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   3050ms communication.py:77 Sending data: {}
Sending command with temp auth token=
Sending data=a162545040
Sending data=b'\xa1bTP@'
Send Command.FACTORY_RESET
CBOR encoded data dict (to send): (8) a162545040
8 0/1 221 13 010001dd08050006a162545040
Captured log call
*   3050ms communication.py:77 Sending data: {}
*   3050ms pcsc.py:101 apdu b'00020300534242424242424242424242424242424242424242424242424242424242424242414141414141414141414141414141414141414141414141414141414141414112228c2790f6010001dd08050006a16254504000'
*   3060ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_pin_change 0:00:00.012256

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_pin_change(nkfido2_client: NKFido2Client):
        # todo check session clearing after PIN change
        # todo DESIGN is TP required for the PIN change, or the current PIN suffices?
    
        # condition: PIN set
        # should fail
        data = {
            "PIN": Constants.PIN_BAD,
            "NEWPIN": Constants.PIN_BAD,
            }
>       send_and_receive(nkfido2_client, Command.CHANGE_PIN, data, expected_error=ExecError.INVALID_PIN)

test_comm.py:617: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0474cfa40>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   3084ms communication.py:77 Sending data: {'PIN': b'BAD PIN', 'NEWPIN': b'BAD PIN'}
Sending command with temp auth token=
Sending data=a36350494e474241442050494e664e455750494e474241442050494e62545040
Sending data=b'\xa3cPINGBAD PINfNEWPINGBAD PINbTP@'
Send Command.CHANGE_PIN
CBOR encoded data dict (to send): (35) a36350494e474241442050494e664e455750494e474241442050494e62545040
35 0/1 221 40 010001dd2320000ba36350494e474241442050494e664e455750494e474241442050494e62545040
Captured log call
*   3084ms communication.py:77 Sending data: {'PIN': b'BAD PIN', 'NEWPIN': b'BAD PIN'}
*   3085ms pcsc.py:101 apdu b'000203006e424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141412d228c2790f6010001dd2320000ba36350494e474241442050494e664e455750494e474241442050494e6254504000'
*   3096ms pcsc.py:104 response [0x9000] b'6a80'

Teardown

FAILED test_configure 0:00:00.012789

Get the current data change it get the current data and compare to previous one WC <> CONFIRMATION

ValueError: Not enough data to read (need: 4, had: 1).

Setup

Call

nkfido2_client = <pynitrokey.fido2.client.NKFido2Client object at 0x7fa04857b220>

    def test_configure(nkfido2_client: NKFido2Client):
        """
        Get the current data
        change it
        get the current data and compare to previous one
        WC <> CONFIRMATION
        """
        # simple read/write test
>       helper_login(nkfido2_client, Constants.PIN)

test_comm.py:657: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_comm.py:98: in helper_login
    s, data = send_and_receive(nkfido2_client, Command.SET_PIN, dict(PIN=PIN), check=False)
webcrypt/communication.py:84: in send_and_receive
    execution_success, err_codes = device_send(nkfido2_client, data, command)
webcrypt/communication.py:259: in device_send
    res = webcrypt_exchange(nkfido2_client, data_to_send, appid=appid)
webcrypt/communication.py:222: in webcrypt_exchange
    res = exchange_u2f(nkfido2_client, WalletWebcrypt, data=data)
webcrypt/communication.py:176: in exchange_u2f
    res = nkfido2_client.ctap1.authenticate(chal, appid, req)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:274: in authenticate
    return SignatureData(response)
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/ctap1.py:162: in __init__
    self.counter = reader.unpack(">I")
../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:132: in unpack
    return s.unpack(self.read(s.size))[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <fido2.utils.ByteBuffer object at 0x7fa0474c5720>, size = 4

    def read(self, size=-1):
        """Like BytesIO.read(), but checks the number of bytes read and raises an error
        if fewer bytes were read than expected.
        """
        data = super(ByteBuffer, self).read(size)
        if size > 0 and len(data) != size:
>           raise ValueError(
                "Not enough data to read (need: %d, had: %d)." % (size, len(data))
            )
E           ValueError: Not enough data to read (need: 4, had: 1).

../../../.local/share/virtualenvs/nitrokey-webcrypt-tests-9V2q4MSs/lib/python3.9/site-packages/fido2/utils.py:140: ValueError
Captured stdout call
Selecting exchange_u2f
Captured stderr call
* INFO   3121ms communication.py:77 Sending data: {'PIN': b'12345678'}
Sending command with temp auth token=
Sending data=a26350494e48313233343536373862545040
Sending data=b'\xa2cPINH12345678bTP@'
Send Command.SET_PIN
CBOR encoded data dict (to send): (21) a26350494e48313233343536373862545040
21 0/1 221 26 010001dd1512000aa26350494e48313233343536373862545040
Captured log call
*   3121ms communication.py:77 Sending data: {'PIN': b'12345678'}
*   3121ms pcsc.py:101 apdu b'0002030060424242424242424242424242424242424242424242424242424242424242424241414141414141414141414141414141414141414141414141414141414141411f228c2790f6010001dd1512000aa26350494e4831323334353637386254504000'
*   3132ms pcsc.py:104 response [0x9000] b'6a80'

Teardown