re-enable some usbhid tests
This commit is contained in:
parent
bdf2a47e72
commit
26920551b2
@ -61,6 +61,7 @@ class Tester():
|
||||
self.origin = 'https://examplo.org'
|
||||
|
||||
def find_device(self,):
|
||||
print (list(CtapHidDevice.list_devices()))
|
||||
dev = next(CtapHidDevice.list_devices(), None)
|
||||
if not dev:
|
||||
raise RuntimeError('No FIDO device found')
|
||||
@ -118,7 +119,6 @@ class Tester():
|
||||
|
||||
def test_long_ping(self):
|
||||
amt = 1000
|
||||
while 1 :
|
||||
pingdata = os.urandom(amt)
|
||||
try:
|
||||
t1 = time.time() * 1000
|
||||
@ -140,12 +140,13 @@ class Tester():
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def test_hid(self,):
|
||||
#print('Test idle')
|
||||
#try:
|
||||
#cmd,resp = self.recv_raw()
|
||||
#except socket.timeout:
|
||||
#print('Pass: Idle')
|
||||
def test_hid(self,check_timeouts = False):
|
||||
if check_timeouts:
|
||||
print('Test idle')
|
||||
try:
|
||||
cmd,resp = self.recv_raw()
|
||||
except socket.timeout:
|
||||
print('Pass: Idle')
|
||||
|
||||
print('Test init')
|
||||
r = self.send_data(CTAPHID.INIT, '\x11\x11\x11\x11\x11\x11\x11\x11')
|
||||
@ -216,18 +217,19 @@ class Tester():
|
||||
self.check_error(resp, CtapError.ERR.INVALID_LENGTH)
|
||||
print('PASS: invalid length')
|
||||
|
||||
#r = self.send_data(CTAPHID.PING, '\x44'*200)
|
||||
#print('Sending packets that skip a sequence number.')
|
||||
#self.send_raw('\x81\x04\x90')
|
||||
#self.send_raw('\x00')
|
||||
#self.send_raw('\x01')
|
||||
## skip 2
|
||||
#self.send_raw('\x03')
|
||||
#cmd,resp = self.recv_raw()
|
||||
#self.check_error(resp, CtapError.ERR.INVALID_SEQ)
|
||||
#cmd,resp = self.recv_raw()
|
||||
#assert(cmd == 0xbf) # timeout
|
||||
#print('PASS: invalid sequence')
|
||||
r = self.send_data(CTAPHID.PING, '\x44'*200)
|
||||
print('Sending packets that skip a sequence number.')
|
||||
self.send_raw('\x81\x04\x90')
|
||||
self.send_raw('\x00')
|
||||
self.send_raw('\x01')
|
||||
# skip 2
|
||||
self.send_raw('\x03')
|
||||
cmd,resp = self.recv_raw()
|
||||
self.check_error(resp, CtapError.ERR.INVALID_SEQ)
|
||||
if check_timeouts:
|
||||
cmd,resp = self.recv_raw()
|
||||
assert(cmd == 0xbf) # timeout
|
||||
print('PASS: invalid sequence')
|
||||
|
||||
print('Resync and send ping')
|
||||
try:
|
||||
@ -262,13 +264,13 @@ class Tester():
|
||||
cmd,r = self.recv_raw() # init response
|
||||
assert(cmd == 0x86)
|
||||
self.set_cid(oldcid)
|
||||
if check_timeouts:
|
||||
#print('wait for timeout')
|
||||
#cmd,r = self.recv_raw() # timeout response
|
||||
#assert(cmd == 0xbf)
|
||||
cmd,r = self.recv_raw() # timeout response
|
||||
assert(cmd == 0xbf)
|
||||
|
||||
print('PASS: resync and timeout')
|
||||
|
||||
|
||||
print('Test timeout')
|
||||
self.send_data(CTAPHID.INIT, '\x11\x22\x33\x44\x55\x66\x77\x88')
|
||||
t1 = time.time() * 1000
|
||||
@ -294,13 +296,14 @@ class Tester():
|
||||
assert(r[0] == CtapError.ERR.INVALID_SEQ)
|
||||
print('PASS: Test not cont')
|
||||
|
||||
if check_timeouts:
|
||||
print('Check random cont ignored')
|
||||
#self.send_data(CTAPHID.INIT, '\x11\x22\x33\x44\x55\x66\x77\x88')
|
||||
#self.send_raw('\x01\x10\x00')
|
||||
#try:
|
||||
#cmd,r = self.recv_raw() # timeout response
|
||||
#except socket.timeout:
|
||||
#pass
|
||||
self.send_data(CTAPHID.INIT, '\x11\x22\x33\x44\x55\x66\x77\x88')
|
||||
self.send_raw('\x01\x10\x00')
|
||||
try:
|
||||
cmd,r = self.recv_raw() # timeout response
|
||||
except socket.timeout:
|
||||
pass
|
||||
print('PASS: random cont')
|
||||
|
||||
print('Check busy')
|
||||
@ -336,11 +339,13 @@ class Tester():
|
||||
self.send_raw('\x81\x00\x63')
|
||||
self.send_raw('\x00')
|
||||
|
||||
cmd,r = self.recv_raw() # busy response
|
||||
|
||||
self.set_cid(cid1) # finish 1st channel ping
|
||||
self.send_raw('\x00')
|
||||
|
||||
self.set_cid(cid2)
|
||||
cmd,r = self.recv_raw() # busy response
|
||||
|
||||
assert(cmd == 0xbf)
|
||||
assert(r[0] == CtapError.ERR.CHANNEL_BUSY)
|
||||
|
||||
@ -349,12 +354,13 @@ class Tester():
|
||||
assert(cmd == 0x81)
|
||||
assert(len(r) == 0x63)
|
||||
|
||||
#cmd,r = self.recv_raw() # timeout
|
||||
#assert(cmd == 0xbf)
|
||||
#assert(r[0] == CtapError.ERR.TIMEOUT)
|
||||
if check_timeouts:
|
||||
cmd,r = self.recv_raw() # timeout
|
||||
assert(cmd == 0xbf)
|
||||
assert(r[0] == CtapError.ERR.TIMEOUT)
|
||||
print('PASS: busy interleaved')
|
||||
|
||||
|
||||
if check_timeouts:
|
||||
print('Test idle, wait for timeout')
|
||||
sys.stdout.flush()
|
||||
try:
|
||||
@ -598,7 +604,4 @@ if __name__ == '__main__':
|
||||
t.test_fido2()
|
||||
#test_find_brute_force()
|
||||
#t.test_fido2_simple()
|
||||
t.test_fido2_brute_force()
|
||||
|
||||
|
||||
|
||||
#t.test_fido2_brute_force()
|
||||
|
Loading…
x
Reference in New Issue
Block a user