From 9045c0ca3edeb428ff156c10bd3984c186d9ea3f Mon Sep 17 00:00:00 2001 From: Conor Patrick Date: Tue, 20 Aug 2019 21:06:37 +0800 Subject: [PATCH] speed up public key derivation slightly for nfc --- fido2/ctap.c | 4 ++++ targets/stm32l432/src/nfc.c | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fido2/ctap.c b/fido2/ctap.c index c364005..9302e1d 100644 --- a/fido2/ctap.c +++ b/fido2/ctap.c @@ -256,7 +256,9 @@ static int ctap_generate_cose_key(CborEncoder * cose_key, uint8_t * hmac_input, switch(algtype) { case COSE_ALG_ES256: + if (device_is_nfc() == NFC_IS_ACTIVE) device_set_clock_rate(DEVICE_LOW_POWER_FAST); crypto_ecc256_derive_public_key(hmac_input, len, x, y); + if (device_is_nfc() == NFC_IS_ACTIVE) device_set_clock_rate(DEVICE_LOW_POWER_IDLE); break; default: printf2(TAG_ERR,"Error, COSE alg %d not supported\n", algtype); @@ -1969,7 +1971,9 @@ int8_t ctap_load_key(uint8_t index, uint8_t * key) static void ctap_reset_key_agreement() { + if (device_is_nfc() == NFC_IS_ACTIVE) device_set_clock_rate(DEVICE_LOW_POWER_FAST); crypto_ecc256_make_key_pair(KEY_AGREEMENT_PUB, KEY_AGREEMENT_PRIV); + if (device_is_nfc() == NFC_IS_ACTIVE) device_set_clock_rate(DEVICE_LOW_POWER_IDLE); } void ctap_reset() diff --git a/targets/stm32l432/src/nfc.c b/targets/stm32l432/src/nfc.c index 3b42d79..726c47e 100644 --- a/targets/stm32l432/src/nfc.c +++ b/targets/stm32l432/src/nfc.c @@ -629,10 +629,8 @@ void nfc_process_iblock(uint8_t * buf, int len) // WTX_on(WTX_TIME_DEFAULT); request_from_nfc(true); - // if (device_is_nfc() == NFC_IS_ACTIVE) device_set_clock_rate(DEVICE_LOW_POWER_FAST); ctap_response_init(&ctap_resp); status = ctap_request(apdu.data, apdu.lc, &ctap_resp); - // if (device_is_nfc() == NFC_IS_ACTIVE) device_set_clock_rate(DEVICE_LOW_POWER_IDLE); request_from_nfc(false); // if (!WTX_off()) // return;