Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dynamic networks #725

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src_features/provideDynamicNetwork/network_dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ static uint16_t handle_get_config(void) {
}

static bool handle_dyn_net_struct(const s_tlv_data *data, s_sig_ctx *context) {
bool ret;
uint16_t ret = APDU_RESPONSE_INTERNAL_ERROR;

switch (data->tag) {
case TAG_STRUCTURE_TYPE:
Expand All @@ -529,20 +529,20 @@ static bool handle_dyn_net_struct(const s_tlv_data *data, s_sig_ctx *context) {
#ifdef HAVE_NBGL
ret = parse_icon_hash(data->value, data->length);
#else
ret = true;
ret = APDU_RESPONSE_OK;
#endif
break;
case TAG_DER_SIGNATURE:
ret = parse_signature(data->value, data->length, context);
break;
default:
PRINTF(TLV_TAG_ERROR_MSG, data->tag);
ret = false;
ret = APDU_RESPONSE_OK;
}
if (ret && (data->tag != TAG_DER_SIGNATURE)) {
if ((ret == APDU_RESPONSE_OK) && (data->tag != TAG_DER_SIGNATURE)) {
hash_nbytes(data->raw, data->raw_size, (cx_hash_t *) &context->hash_ctx);
}
return ret;
return (ret == APDU_RESPONSE_OK);
}

static bool handle_tlv_payload(const uint8_t *payload, uint16_t size) {
Expand Down
4 changes: 1 addition & 3 deletions tools/gen_dynamic_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import subprocess
import sys
import struct
import logging
import re
from hashlib import sha256
Expand Down Expand Up @@ -202,8 +201,7 @@ def generate_tlv_payload(name: str,
# Network Icon Hash
payload += format_tlv(NetworkInfoTag.NETWORK_ICON_HASH, sha256(icon).digest())
# Append the data Signature
payload += format_tlv(NetworkInfoTag.DER_SIGNATURE,
sign_data(Key.CAL, payload))
payload += format_tlv(NetworkInfoTag.DER_SIGNATURE, sign_data(Key.NETWORK, payload))

# Return the constructed TLV payload as bytes
return payload
Expand Down
Loading