speed up public key derivation slightly for nfc

This commit is contained in:
Conor Patrick 2019-08-20 21:06:37 +08:00
parent 508f2e1e1c
commit 9045c0ca3e
2 changed files with 4 additions and 2 deletions

View File

@ -256,7 +256,9 @@ static int ctap_generate_cose_key(CborEncoder * cose_key, uint8_t * hmac_input,
switch(algtype) switch(algtype)
{ {
case COSE_ALG_ES256: 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); 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; break;
default: default:
printf2(TAG_ERR,"Error, COSE alg %d not supported\n", algtype); 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() 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); 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() void ctap_reset()

View File

@ -629,10 +629,8 @@ void nfc_process_iblock(uint8_t * buf, int len)
// WTX_on(WTX_TIME_DEFAULT); // WTX_on(WTX_TIME_DEFAULT);
request_from_nfc(true); request_from_nfc(true);
// if (device_is_nfc() == NFC_IS_ACTIVE) device_set_clock_rate(DEVICE_LOW_POWER_FAST);
ctap_response_init(&ctap_resp); ctap_response_init(&ctap_resp);
status = ctap_request(apdu.data, apdu.lc, &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); request_from_nfc(false);
// if (!WTX_off()) // if (!WTX_off())
// return; // return;