Skip to content

Commit 1f4be2a

Browse files
committed
Update PicoKeys SDK
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
1 parent dc6007d commit 1f4be2a

5 files changed

Lines changed: 91 additions & 92 deletions

File tree

src/fido/cbor_client_pin.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "mbedtls/ecdh.h"
2121
#include "mbedtls/sha256.h"
2222
#include "mbedtls/hkdf.h"
23+
#include "mbedtls/constant_time.h"
2324
#include "cbor.h"
2425
#include "ctap.h"
2526
#include "ctap2_cbor.h"
@@ -221,10 +222,10 @@ int verify(uint8_t protocol, const uint8_t *key, const uint8_t *data, uint16_t l
221222
return ret;
222223
}
223224
if (protocol == 1) {
224-
return ct_memcmp(sign, hmac, 16);
225+
return mbedtls_ct_memcmp(sign, hmac, 16);
225226
}
226227
else if (protocol == 2) {
227-
return ct_memcmp(sign, hmac, 32);
228+
return mbedtls_ct_memcmp(sign, hmac, 32);
228229
}
229230
return -1;
230231
}
@@ -491,7 +492,7 @@ int cbor_client_pin(const uint8_t *data, size_t len) {
491492
pin_derive_verifier(paddedNewPin, 16, dhash);
492493
}
493494

494-
if (ct_memcmp(dhash, file_get_data(ef_pin) + off, 32) != 0) {
495+
if (mbedtls_ct_memcmp(dhash, file_get_data(ef_pin) + off, 32) != 0) {
495496
regenerate();
496497
mbedtls_platform_zeroize(sharedSecret, sizeof(sharedSecret));
497498
if (retries == 0) {
@@ -569,7 +570,7 @@ int cbor_client_pin(const uint8_t *data, size_t len) {
569570
pin_data[2] = 1; // New format indicator
570571
pin_derive_verifier(dhash, 16, pin_data + 3);
571572

572-
if (file_has_data(ef_minpin) && file_get_data(ef_minpin)[1] == 1 && ct_memcmp(pin_data + 3, file_get_data(ef_pin) + 3, 32) == 0) {
573+
if (file_has_data(ef_minpin) && file_get_data(ef_minpin)[1] == 1 && mbedtls_ct_memcmp(pin_data + 3, file_get_data(ef_pin) + 3, 32) == 0) {
573574
CBOR_ERROR(CTAP2_ERR_PIN_POLICY_VIOLATION);
574575
}
575576
file_put_data(ef_pin, pin_data, sizeof(pin_data));
@@ -652,7 +653,7 @@ int cbor_client_pin(const uint8_t *data, size_t len) {
652653
else {
653654
pin_derive_verifier(paddedNewPin, 16, dhash);
654655
}
655-
if (ct_memcmp(dhash, file_get_data(ef_pin) + off, 32) != 0) {
656+
if (mbedtls_ct_memcmp(dhash, file_get_data(ef_pin) + off, 32) != 0) {
656657
regenerate();
657658
mbedtls_platform_zeroize(sharedSecret, sizeof(sharedSecret));
658659
mbedtls_platform_zeroize(dhash, sizeof(dhash));

src/fido/management.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "apdu.h"
2323
#include "version.h"
2424
#include "files.h"
25-
#include "asn1.h"
25+
#include "tlv.h"
2626
#include "management.h"
2727

2828
bool is_gpg = true;
@@ -64,9 +64,9 @@ bool cap_supported(uint16_t cap) {
6464
uint16_t tag = 0x0;
6565
uint8_t *tag_data = NULL, *p = NULL;
6666
uint16_t tag_len = 0;
67-
asn1_ctx_t ctxi;
68-
asn1_ctx_init(file_get_data(ef), file_get_size(ef), &ctxi);
69-
while (walk_tlv(&ctxi, &p, &tag, &tag_len, &tag_data)) {
67+
tlv_ctx_t ctxi;
68+
tlv_ctx_init(file_get_data(ef), file_get_size(ef), &ctxi);
69+
while (tlv_walk(&ctxi, &p, &tag, &tag_len, &tag_data)) {
7070
if (tag == TAG_USB_ENABLED) {
7171
uint16_t ecaps = tag_data[0];
7272
if (tag_len == 2) {

0 commit comments

Comments
 (0)