Skip to content

Commit

Permalink
fix some warnings and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
z4yx committed Jun 1, 2024
1 parent 0afb6fc commit 5a1b8bf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions applets/ctap/ctap.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ static uint8_t ctap_make_credential(CborEncoder *encoder, uint8_t *params, size_
sha256_update(mc.client_data_hash, sizeof(mc.client_data_hash));
sha256_final(data_buf);
len = sign_with_device_key(data_buf, PRIVATE_KEY_LENGTH[SECP256R1], data_buf);
if (!len) return CTAP2_ERR_UNHANDLED_REQUEST;
ret = cbor_encode_byte_string(&att_map, data_buf, len);
CHECK_CBOR_RET(ret);

Expand Down Expand Up @@ -1154,6 +1155,7 @@ static uint8_t ctap_get_assertion(CborEncoder *encoder, uint8_t *params, size_t
DBG_MSG("Message: ");
PRINT_HEX(data_buf, len + CLIENT_DATA_HASH_SIZE);
len = sign_with_private_key(dc.credential_id.alg_type, &key, data_buf, len + CLIENT_DATA_HASH_SIZE, data_buf);
if (len < 0) return CTAP2_ERR_UNHANDLED_REQUEST;
DBG_MSG("Signature: ");
PRINT_HEX(data_buf, len);
ret = cbor_encode_byte_string(&map, data_buf, len);
Expand Down
2 changes: 1 addition & 1 deletion applets/ctap/secret.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ int verify_key_handle(const credential_id *kh, ecc_key_t *key) {
size_t sign_with_device_key(const uint8_t *input, size_t input_len, uint8_t *sig) {
ecc_key_t key;
int ret = read_device_pri_key(key.pri);
if (ret < 0) return ret;
if (ret < 0) return 0;
ecc_sign(SECP256R1, &key, input, input_len, sig);
memzero(&key, sizeof(key));
return ecdsa_sig2ansi(PRI_KEY_SIZE, sig, sig);
Expand Down
2 changes: 2 additions & 0 deletions interfaces/NFC/fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ uint8_t fm_read_reg(uint16_t reg) {
fm_csn_high();
#elif NFC_CHIP == NFC_CHIP_FM11NT
fm11nt_read(reg, &val, 1);
#else
val = 0;
#endif
return val;
}
Expand Down
2 changes: 1 addition & 1 deletion interfaces/USB/class/webusb/webusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ uint8_t USBD_WEBUSB_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req) {
break;

case WEBUSB_REQ_STAT:
USBD_CtlSendData(pdev, &state, 1, WEBUSB_EP0_SENDER);
USBD_CtlSendData(pdev, (uint8_t*)&state, 1, WEBUSB_EP0_SENDER);
break;

default:
Expand Down

0 comments on commit 5a1b8bf

Please sign in to comment.