efm8 bridge polled mode is much faster

This commit is contained in:
Conor Patrick 2018-07-07 17:11:13 -04:00
parent a18aa99220
commit fbbf430152
10 changed files with 291 additions and 249 deletions

File diff suppressed because one or more lines are too long

View File

@ -49,6 +49,11 @@
<property object="PC9" propertyId="ports.settings.pinmode" value="Input pull"/>
<property object="PC9" propertyId="ports.settings.pulldirection" value="Pullup"/>
<property object="PC9" propertyId="ports.settings.pullup" value="Enabled"/>
<property object="PD10" propertyId="ports.settings.dout" value="1"/>
<property object="PD10" propertyId="ports.settings.filter" value="Enabled"/>
<property object="PD10" propertyId="ports.settings.pinmode" value="Push-pull"/>
<property object="PD10" propertyId="ports.settings.pulldirection" value="Pullup"/>
<property object="PD10" propertyId="ports.settings.pullup" value="Enabled"/>
<property object="PF4" propertyId="ports.settings.pinmode" value="Push-pull"/>
<property object="PF5" propertyId="ports.settings.pinmode" value="Push-pull"/>
<property object="PORTIO" propertyId="portio.usart0.enable.cts" value="Enabled"/>
@ -69,7 +74,7 @@
<property object="USART1" propertyId="ABPeripheral.included" value="true"/>
<property object="USART1" propertyId="usart.mode.usartmode" value="Synchronous Mode (SPI / I2S)"/>
<property object="USART1" propertyId="usart.outputsettings.clockselect" value="Disabled"/>
<property object="USART1" propertyId="usart.synchronoussettings.baudrate" value="100000"/>
<property object="USART1" propertyId="usart.synchronoussettings.baudrate" value="140000"/>
</mode>
<modeTransition>
<property object="RESET &#x2192; DefaultMode" propertyId="modeTransition.source" value="RESET"/>

View File

@ -334,7 +334,7 @@ extern void USART1_enter_DefaultMode_from_RESET(void) {
USART_InitSync_TypeDef initsync = USART_INITSYNC_DEFAULT;
initsync.enable = usartDisable;
initsync.baudrate = 100000;
initsync.baudrate = 140000;
initsync.databits = usartDatabits8;
initsync.master = 1;
initsync.msbf = 1;
@ -621,6 +621,9 @@ extern void PORTIO_enter_DefaultMode_from_RESET(void) {
// [Port C Configuration]$
// $[Port D Configuration]
/* Pin PD10 is configured to Push-pull */
GPIO_PinModeSet(gpioPortD, 10, gpioModePushPull, 1);
// [Port D Configuration]$
// $[Port E Configuration]

View File

@ -26,7 +26,6 @@ const uint8_t attestation_key[];
const uint16_t attestation_key_size;
static SHA256_CTX sha256_ctx;
mbedtls_sha256_context embed_sha256_ctx;
@ -204,29 +203,29 @@ void crypto_ecc256_sign(uint8_t * data, int len, uint8_t * sig)
// CMU->HFBUSCLKEN0 &= ~CMU_HFBUSCLKEN0_CRYPTO;
// CRYPTO_DISABLE;
// CRYPTO_ENABLE;
mbedtls_ecp_group_init( &grp );
mbedtls_mpi_init( &d );
mbedtls_ecp_group_load(&grp, MBEDTLS_ECP_DP_SECP256R1);
mbedtls_mpi_read_binary(&d, _signing_key, 32);
// mbedtls_ecp_group_init( &grp );
// mbedtls_mpi_init( &d );
// mbedtls_ecp_group_load(&grp, MBEDTLS_ECP_DP_SECP256R1);
// mbedtls_mpi_read_binary(&d, _signing_key, 32);
//
// mbedtls_mpi r,s;
// mbedtls_mpi_init(&r);
// mbedtls_mpi_init(&s);
//
// printf("signing..\n");
// dump_hex(data,len);
// mbedtls_ecdsa_sign_det( &grp, &r, &s, &d,
// data, 32, MBEDTLS_MD_SHA256 );// Issue: this will freeze on 13th iteration..
// printf("signed\n");
//
// mbedtls_mpi_write_binary(&r,sig,32);
// mbedtls_mpi_write_binary(&s,sig+32,32);
mbedtls_mpi r,s;
mbedtls_mpi_init(&r);
mbedtls_mpi_init(&s);
printf("signing..\n");
dump_hex(data,len);
mbedtls_ecdsa_sign_det( &grp, &r, &s, &d,
data, 32, MBEDTLS_MD_SHA256 );// Issue: this will freeze on 13th iteration..
printf("signed\n");
mbedtls_mpi_write_binary(&r,sig,32);
mbedtls_mpi_write_binary(&s,sig+32,32);
// if ( uECC_sign(_signing_key, data, len, sig, _es256_curve) == 0)
// {
// printf("error, uECC failed\n");
// exit(1);
// }
if ( uECC_sign(_signing_key, data, len, sig, _es256_curve) == 0)
{
printf("error, uECC failed\n");
exit(1);
}
}
@ -368,20 +367,20 @@ void generate_private_key(uint8_t * data, int len, uint8_t * data2, int len2, ui
crypto_sha256_update(master_secret, 32);
crypto_sha256_hmac_final(CRYPTO_MASTER_KEY, 0, privkey);
mbedtls_ecp_group grp; /*!< Elliptic curve and base point */
mbedtls_mpi d; /*!< our secret value */
mbedtls_ecp_point Q;
mbedtls_ecp_group_init( &grp );
mbedtls_mpi_init( &d );
mbedtls_ecp_point_init(&Q);
mbedtls_ecp_group_load(&grp, MBEDTLS_ECP_DP_SECP256R1);
// mbedtls_mpi_read_binary(&d, _signing_key, 32);
hmac_vector_func(NULL, NULL, 0);
mbedtls_ecp_gen_privkey(&grp, &grp.G, &d, &Q, hmac_vector_func, privkey);
mbedtls_mpi_write_binary(&d,privkey,32);
// mbedtls_ecp_group grp; /*!< Elliptic curve and base point */
// mbedtls_mpi d; /*!< our secret value */
// mbedtls_ecp_point Q;
//
// mbedtls_ecp_group_init( &grp );
// mbedtls_mpi_init( &d );
// mbedtls_ecp_point_init(&Q);
//
// mbedtls_ecp_group_load(&grp, MBEDTLS_ECP_DP_SECP256R1);
//
//// mbedtls_mpi_read_binary(&d, _signing_key, 32);
// hmac_vector_func(NULL, NULL, 0);
// mbedtls_ecp_gen_privkey(&grp, &grp.G, &d, &Q, hmac_vector_func, privkey);
// mbedtls_mpi_write_binary(&d,privkey,32);
}
@ -400,41 +399,41 @@ void crypto_ecc256_derive_public_key(uint8_t * data, int len, uint8_t * x, uint8
crypto_sha256_update(master_secret, 32);
crypto_sha256_hmac_final(CRYPTO_MASTER_KEY, 0, privkey);
mbedtls_ecp_group grp; /*!< Elliptic curve and base point */
mbedtls_mpi d; /*!< our secret value */
mbedtls_ecp_point Q;
// mbedtls_ecp_group grp; /*!< Elliptic curve and base point */
// mbedtls_mpi d; /*!< our secret value */
// mbedtls_ecp_point Q;
//
// mbedtls_ecp_group_init( &grp );
// mbedtls_mpi_init( &d );
// mbedtls_ecp_point_init(&Q);
//
// mbedtls_ecp_group_load(&grp, MBEDTLS_ECP_DP_SECP256R1);
//
//// mbedtls_mpi_read_binary(&d, _signing_key, 32);
// hmac_vector_func(NULL, NULL, 0);
// ret= mbedtls_ecp_gen_privkey(&grp, &grp.G, &d, &Q, hmac_vector_func, privkey);
// if (ret != 0)
// {
// printf("error with priv key -0x04%x\n", -ret);
// }
//// mbedtls_mpi_write_binary(&d,privkey,32);
//
// memset(pubkey,0,sizeof(pubkey));
//
// ret = mbedtls_ecp_derive_pubkey( &grp, &grp.G,
// &d, &Q, hmac_vector_func, privkey);
//
// if (ret != 0)
// {
// printf("error with public key\n");
// }
//
// mbedtls_mpi_write_binary(&Q.X,x,32);
// mbedtls_mpi_write_binary(&Q.Y,y,32);
mbedtls_ecp_group_init( &grp );
mbedtls_mpi_init( &d );
mbedtls_ecp_point_init(&Q);
mbedtls_ecp_group_load(&grp, MBEDTLS_ECP_DP_SECP256R1);
// mbedtls_mpi_read_binary(&d, _signing_key, 32);
hmac_vector_func(NULL, NULL, 0);
ret= mbedtls_ecp_gen_privkey(&grp, &grp.G, &d, &Q, hmac_vector_func, privkey);
if (ret != 0)
{
printf("error with priv key -0x04%x\n", -ret);
}
// mbedtls_mpi_write_binary(&d,privkey,32);
memset(pubkey,0,sizeof(pubkey));
ret = mbedtls_ecp_derive_pubkey( &grp, &grp.G,
&d, &Q, hmac_vector_func, privkey);
if (ret != 0)
{
printf("error with public key\n");
}
mbedtls_mpi_write_binary(&Q.X,x,32);
mbedtls_mpi_write_binary(&Q.Y,y,32);
// uECC_compute_public_key(privkey, pubkey, _es256_curve);
// memmove(x,pubkey,32);
// memmove(y,pubkey+32,32);
uECC_compute_public_key(privkey, pubkey, _es256_curve);
memmove(x,pubkey,32);
memmove(y,pubkey+32,32);
}
void crypto_ecc256_load_key(uint8_t * data, int len, uint8_t * data2, int len2)

View File

@ -17,6 +17,10 @@
#include "ctaphid.h"
#include "util.h"
#define MSG_AVAIL_PIN gpioPortC,9
#define RDY_PIN gpioPortC,10
#define RW_PIN gpioPortD,11
// Generate @num bytes of random numbers to @dest
// return 1 if success, error otherwise
int ctap_generate_rng(uint8_t * dst, size_t num)
@ -88,20 +92,44 @@ void usbhid_init()
static int msgs_to_recv = 0;
static void wait_for_efm8_ready()
{
// Wait for efm8 to be ready
while (GPIO_PinInGet(RDY_PIN) == 0)
;
}
static void wait_for_efm8_busy()
{
// Wait for efm8 to be ready
while (GPIO_PinInGet(RDY_PIN) != 0)
;
}
int usbhid_recv(uint8_t * msg)
{
int i;
if (msgs_to_recv)
if (GPIO_PinInGet(MSG_AVAIL_PIN) == 0)
{
GPIO_PinOutClear(gpioPortC,10);
GPIO_PinOutClear(RW_PIN); // Drive low to indicate READ
wait_for_efm8_ready();
for (i = 0; i < 64; i++)
{
msg[i] = USART_SpiTransfer(USART1, 0);
msg[i] = USART_SpiTransfer(USART1, 'A');
// delay(1);
}
msgs_to_recv--;
printf(">> ");
dump_hex(msg,64);
GPIO_PinOutSet(RW_PIN);
wait_for_efm8_busy();
// msgs_to_recv--;
// printf(">> ");
// dump_hex(msg,64);
return 64;
}
@ -111,24 +139,17 @@ int usbhid_recv(uint8_t * msg)
void usbhid_send(uint8_t * msg)
{
int i;
uint64_t t1 = millis();
// uint32_t t1 = millis();
USART_SpiTransfer(USART1, *msg++); // Send 1 byte
wait_for_efm8_ready();
GPIO_PinModeSet(gpioPortC, 10, gpioModeInput, 0);
// Wait for efm8 to be ready
while (GPIO_PinInGet(gpioPortC, 10) == 0)
;
GPIO_PinModeSet(gpioPortC, 10, gpioModePushPull, 0);
uint64_t t2 = millis();
// printf("wait time: %ul\n", (uint32_t)(t2-t1));
GPIO_PinOutSet(gpioPortC,10);
for (i = 0; i < HID_MESSAGE_SIZE; i++)
for (i = 1; i < HID_MESSAGE_SIZE; i++)
{
USART_SpiTransfer(USART1, *msg++);
}
GPIO_PinOutClear(gpioPortC,10);
wait_for_efm8_busy();
// uint32_t t2 = millis();
// printf("wait time: %u\n", (uint32_t)(t2-t1));
}
@ -181,12 +202,18 @@ void device_init(void)
gpioModePushPull,
1);
// SPI R/W indicator
GPIO_PinModeSet(gpioPortC, 10, gpioModePushPull, 0);
// EFM8 RDY/BUSY
GPIO_PinModeSet(RDY_PIN, gpioModeInput, 0);
// EFM8 MSG Available
GPIO_PinModeSet(MSG_AVAIL_PIN, gpioModeInput, 0);
// SPI R/w Indicator
GPIO_PinModeSet(RW_PIN, gpioModePushPull, 1);
// USB message rdy ext int
GPIO_ExtIntConfig(gpioPortC, 9, 9, 1, 0,1);
NVIC_EnableIRQ(GPIO_ODD_IRQn);
// GPIO_ExtIntConfig(gpioPortC, 9, 9, 1, 0,1);
// NVIC_EnableIRQ(GPIO_ODD_IRQn);
printing_init();

View File

@ -170,7 +170,7 @@
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="com.silabs.ss.framework.ide.project.core.cpp" project.generation="70" projectCommon.boardIds="brd5000a:0.0.0.A02" projectCommon.buildArtifactType="EXE" projectCommon.importModeId="COPY" projectCommon.partId="mcu.8051.efm8.ub1.efm8ub10f16g-b-qfn28" projectCommon.sdkId="com.silabs.sdk.8051:4.1.1._-963069327"/>
<storageModule moduleId="com.silabs.ss.framework.ide.project.core.cpp" project.generation="6" projectCommon.boardIds="brd5000a:0.0.0.A02" projectCommon.buildArtifactType="EXE" projectCommon.importModeId="COPY" projectCommon.partId="mcu.8051.efm8.ub1.efm8ub10f16g-b-qfn28" projectCommon.sdkId="com.silabs.sdk.8051:4.1.1._-963069327"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="efm8.com.silabs.ss.framework.ide.project.core.cdt.cdtMbsProjectType.972220390" name="SLS CDT Project" projectType="com.silabs.ss.framework.ide.project.core.cdt.cdtMbsProjectType"/>
</storageModule>

View File

@ -3,11 +3,12 @@
#include "efm8_usb.h"
#include "uart_1.h"
#include "printing.h"
#include "eeprom.h"
#define BUFFER_SIZE 12
#define SIGNAL_WRITE_BSY() P1 = P1 & (~(1<<2)) // Set P1 low
#define SIGNAL_WRITE_RDY() P1 = P1 | (1<<2) // Set P1 high
#define SIGNAL_WRITE_BSY() P1_B2 = 0 // Set P1 low
#define SIGNAL_WRITE_RDY() P1_B2 = 1 // Set P1 high
data uint8_t write_ptr = 0;
data uint8_t read_ptr = 0;
@ -34,10 +35,6 @@ void usb_transfer_complete()
{
write_ptr = 0;
}
if (count == 1 && i_ptr == 0)
{
SPI0DAT = (hidmsgbuf+read_ptr*64)[i_ptr++];
}
// MSG_RDY_INT_PIN = 0;
@ -49,95 +46,35 @@ uint16_t USB_TX_COUNT = 0;
void usb_writeback_complete()
{
if (USB_TX_COUNT >= 511/2)
{
USB_TX_COUNT -= 64;
if (USB_TX_COUNT < 511)
{
SIGNAL_WRITE_RDY();
}
}
else
{
USB_TX_COUNT -= 64;
}
// if (USB_TX_COUNT >= 511/2)
// {
// USB_TX_COUNT -= 64;
// if (USB_TX_COUNT < 511)
// {
// SIGNAL_WRITE_RDY();
// }
// }
// else
// {
// USB_TX_COUNT -= 64;
// }
USB_TX_COUNT -= 64;
}
void spi_transfer_complete()
{
count--;
if (count > 0) count--;
i_ptr = 0;
SPI0FCN0 |= (1<<2); // Flush rx fifo buffer
// debugWi = read_ptr;
read_ptr++;
if (read_ptr == BUFFER_SIZE)
{
read_ptr = 0;
}
if (count)
{
SPI0DAT = (hidmsgbuf+read_ptr*64)[i_ptr++];
}
// cprints("sent hid msg\r\n");
}
data int overrun = 0;
SI_INTERRUPT (SPI0_ISR, SPI0_IRQn)
{
data uint8_t byt;
if (SPI0CN0_WCOL == 1)
{
// Write collision occurred
SPI0CN0_WCOL = 0;
// cprints("SPI0CN0_WCOL\r\n");
}
else if(SPI0CN0_RXOVRN == 1)
{
// Receive overrun occurred
SPI0CN0_RXOVRN = 0;
overrun = 1;
// cprints("SPI0CN0_RXOVRN\r\n");
}
else
{
if (EFM32_RW_PIN)
{
if (writebackbuf_count < 64)
{
writebackbuf[writebackbuf_count++] = SPI0DAT;
SIGNAL_WRITE_BSY();
}
else
{
cprints("overflow\r\n");
}
}
else
{
if (count)
{
if (i_ptr < 64)
{
// debugW[i_ptr] = (hidmsgbuf+read_ptr*64)[i_ptr];
// debugW2[i_ptr] = read_ptr;
// if (i_ptr == 63)
// debugW2[i_ptr] = 0xaa;
SPI0DAT = (hidmsgbuf+read_ptr*64)[i_ptr++];
byt = SPI0DAT;
}
else
{
spi_transfer_complete();
}
}
}
SPI0CN0_SPIF = 0;
}
}
void usb_write()
{
data uint8_t errors = 0;
@ -155,7 +92,8 @@ void usb_write()
int main(void) {
uint8_t k;
data uint8_t k;
data uint16_t last_efm32_pin = 0;
uint16_t t1 = 0;
uint8_t lastcount = count;
@ -172,31 +110,104 @@ int main(void) {
MSG_RDY_INT_PIN = 1;
// enable SPI interrupts
SPI0FCN1 = SPI0FCN1 | (1<<4);
// SPI0FCN1 = SPI0FCN1 | (1<<4);
IE_EA = 1;
IE_ESPI0 = 1;
// IE_ESPI0 = 1;
SIGNAL_WRITE_RDY();
SPI0FCN0 = SPI0FCN0 | (1<<2); // flush RX fifo
SPI0FCN0 = SPI0FCN0 | (1<<6); // flush TX fifo
// SPI0FCN0 &= ~3; // FIFO threshold 0x0
SPI0FCN1 |= (1); // Enable RX fifo
cprints("hello,world\r\n");
reset = RSTSRC;
cprintx("reset source: ", 1, reset);
if (reset != 0x10)
{
RSTSRC = (1<<4);
}
// last_efm32_pin = SPI0FCN0;
// cprintx("spi fifo0 cntrl: ", 1, last_efm32_pin);
//
// last_efm32_pin = SPI0FCN1;
// cprintx("spi fifo1 cntrl: ", 1, last_efm32_pin);
MSG_RDY_INT_PIN = 1;
SIGNAL_WRITE_BSY();
while (1) {
// delay(1500);
if (overrun)
if (P2_B3 == 0)
{
cprints("O\r\n");
overrun = 0;
i_ptr = 0;
SPI0FCN0 |= (1<<6); // Flush TX fifo buffer
while (SPI0CN0 & (1 << 1)) // While TX FIFO has room
SPI0DAT = (hidmsgbuf+read_ptr*64)[i_ptr++];
SIGNAL_WRITE_RDY();
while (i_ptr<64)
{
while(! (SPI0CN0 & (1 << 1)))
;
SPI0DAT = (hidmsgbuf+read_ptr*64)[i_ptr++];
}
while(P2_B3 == 0)
{
}
// cprints(">> ");
// dump_hex(hidmsgbuf+read_ptr*64,64);
spi_transfer_complete();
if (count == 0)
{
MSG_RDY_INT_PIN = 1;
}
SPI0FCN0 = SPI0FCN0 | (1<<2); // flush RX fifo
while ((SPI0CFG & (0x1)) == 0)
{
k = SPI0DAT;
}
SIGNAL_WRITE_BSY();
}
else
{
// Did we RX data and have room?
if ((SPI0CFG & (0x1)) == 0 && USB_TX_COUNT < 511/2)
{
writebackbuf[writebackbuf_count++] = SPI0DAT; // void the first byte
SIGNAL_WRITE_RDY();
while(writebackbuf_count < 64)
{
while((SPI0CFG & (0x1)) == 1)
;
writebackbuf[writebackbuf_count++] = SPI0DAT;
}
// cprints("<< ");
// dump_hex(writebackbuf,64);
usb_write();
writebackbuf_count = 0;
SPI0FCN0 = SPI0FCN0 | (1<<2); // flush RX fifo
SIGNAL_WRITE_BSY();
}
}
if (millis() - t1 > 1500)
{
P1_B5 = k++&1;
// if (k&1)
// SIGNAL_WRITE_RDY();
// else
// SIGNAL_WRITE_BSY();
t1 = millis();
}
if (!USBD_EpIsBusy(EP2OUT) && !USBD_EpIsBusy(EP3IN) && lastcount==count)
@ -212,19 +223,7 @@ int main(void) {
}
}
if (writebackbuf_count == 64)
{
// cprints("<< ");
// dump_hex(writebackbuf,64);
// while (USBD_EpIsBusy(EP1IN))
// ;
usb_write();
writebackbuf_count = 0;
if (USB_TX_COUNT < 511/2)
{
SIGNAL_WRITE_RDY();
}
}
if (lastcount != count)
{
@ -232,9 +231,7 @@ int main(void) {
{
// cputd(debugRi); cprints(">> ");
// dump_hex(debugR,64);
MSG_RDY_INT_PIN = 0;
MSG_RDY_INT_PIN = 1;
}
else
{

View File

@ -508,10 +508,11 @@ void ctaphid_handle_packet(uint8_t * pkt_raw)
wb.cid = active_cid;
wb.cmd = CTAPHID_PING;
wb.bcnt = buffer_len();
t1 = millis();
ctaphid_write(&wb, ctap_buffer, buffer_len());
ctaphid_write(&wb, NULL,0);
t2 = millis();
printf1(TAG_TIME,"PING writeback: %d ms\n",(uint32_t)(t2-t1));
break;
case CTAPHID_WINK:

View File

@ -32,7 +32,7 @@ int main(int argc, char * argv[])
// TAG_HID|
/*TAG_U2F|*/
/*TAG_PARSE |*/
TAG_TIME|
// TAG_TIME|
// TAG_DUMP|
/*TAG_GREEN|*/
/*TAG_RED|*/

View File

@ -98,6 +98,26 @@ class Tester():
elif data[0] != err:
raise ValueError('Unexpected error: %02x' % data[0])
def test_long_ping(self):
while 1 :
pingdata = os.urandom(1000)
try:
t1 = time.time() * 1000
r = self.send_data(CTAPHID.PING, pingdata)
t2 = time.time() * 1000
delt = t2 - t1
#if (delt < 140 ):
#raise RuntimeError('Fob is too fast (%d ms)' % delt)
if (delt > 555):
raise RuntimeError('Fob is too slow (%d ms)' % delt)
if (r != pingdata):
raise ValueError('Ping data not echo\'d')
print('1000 byte ping time: %s ms' % delt)
except CtapError as e:
print('7609 byte Ping failed:', e)
raise RuntimeError('ping failed')
print('PASS: 7609 byte ping')
def test_hid(self,):
#print('Test idle')
@ -120,23 +140,7 @@ class Tester():
raise RuntimeError('ping failed')
print('PASS: 100 byte ping')
pingdata = os.urandom(1000)
try:
t1 = time.time() * 1000
r = self.send_data(CTAPHID.PING, pingdata)
t2 = time.time() * 1000
delt = t2 - t1
#if (delt < 140 ):
#raise RuntimeError('Fob is too fast (%d ms)' % delt)
if (delt > 555):
raise RuntimeError('Fob is too slow (%d ms)' % delt)
if (r != pingdata):
raise ValueError('Ping data not echo\'d')
except CtapError as e:
print('7609 byte Ping failed:', e)
raise RuntimeError('ping failed')
print('PASS: 7609 byte ping')
self.test_long_ping()
try:
r = self.send_data(CTAPHID.WINK, '')
@ -410,24 +414,28 @@ class Tester():
exclude_list.append({'id': fake_id1, 'type': 'public-key'})
exclude_list.append({'id': fake_id2, 'type': 'public-key'})
t1 = time.time() * 1000
attest, data = self.client.make_credential(rp, user, challenge, pin = PIN, exclude_list = [])
t2 = time.time() * 1000
attest.verify(data.hash)
print('Register valid (%d ms)' % (t2-t1))
#for i in range(0,2048**2):
for i in range(0,1):
t1 = time.time() * 1000
attest, data = self.client.make_credential(rp, user, challenge, pin = PIN, exclude_list = [])
t2 = time.time() * 1000
attest.verify(data.hash)
print('Register valid (%d ms)' % (t2-t1))
sys.stdout.flush()
cred = attest.auth_data.credential_data
creds.append(cred)
allow_list = [{'id':creds[0].credential_id, 'type': 'public-key'}]
t1 = time.time() * 1000
assertions, client_data = self.client.get_assertion(rp['id'], challenge, allow_list, pin = PIN)
t2 = time.time() * 1000
assertions[0].verify(client_data.hash, creds[0].public_key)
#for i in range(0,2048**2):
for i in range(0,1):
allow_list = [{'id':creds[0].credential_id, 'type': 'public-key'}]
t1 = time.time() * 1000
assertions, client_data = self.client.get_assertion(rp['id'], challenge, allow_list, pin = PIN)
t2 = time.time() * 1000
assertions[0].verify(client_data.hash, creds[0].public_key)
print('Assertion valid (%d ms)' % (t2-t1))
sys.stdout.flush()
print('Assertion valid (%d ms)' % (t2-t1))
sys.stdout.flush()
@ -563,9 +571,11 @@ if __name__ == '__main__':
t = Tester()
t.find_device()
#t.test_hid()
#t.test_long_ping()
#t.test_fido2()
t.test_fido2_simple()
#t.test_fido2_brute_force()
#test_find_brute_force()
#t.test_fido2_simple()
t.test_fido2_brute_force()