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