Skip to content

Commit

Permalink
Merge pull request #725 from LedgerHQ/cev/fix_dynamic_networks
Browse files Browse the repository at this point in the history
Fix dynamic networks
  • Loading branch information
cedelavergne-ledger authored Jan 29, 2025
2 parents 9b0a5c9 + 46c3784 commit 8ddcdd5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
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

0 comments on commit 8ddcdd5

Please sign in to comment.