-
Notifications
You must be signed in to change notification settings - Fork 220
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
B2CA-1566: Dynamic network management #635
Draft
cedelavergne-ledger
wants to merge
9
commits into
develop
Choose a base branch
from
cev/B2CA-1566_networks
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+577
−63
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cedelavergne-ledger
force-pushed
the
cev/B2CA-1566_networks
branch
11 times, most recently
from
September 4, 2024 16:03
0234a1b
to
3d35b44
Compare
cedelavergne-ledger
force-pushed
the
cev/B2CA-1566_networks
branch
from
September 9, 2024 17:45
3d35b44
to
4a598e0
Compare
src/network.c
Outdated
Comment on lines
242
to
405
case TAG_STRUCTURE_VERSION: | ||
if (field_len != 1) { | ||
PRINTF("STRUCTURE_VERSION Size mismatch!\n"); | ||
return APDU_RESPONSE_INVALID_DATA; | ||
} | ||
if (g_network_payload.buf[offset] != NETWORK_TLV_VERSION) { | ||
PRINTF("TLV Version mismatch!\n"); | ||
return APDU_RESPONSE_INVALID_DATA; | ||
} | ||
break; | ||
case TAG_CHAIN_ID: | ||
// Get Chain ID | ||
if (field_len != sizeof(uint64_t)) { | ||
PRINTF("CHAIN_ID Size mismatch!\n"); | ||
return APDU_RESPONSE_INVALID_DATA; | ||
} | ||
DYNAMIC_NETWORK_INFO.chain_id = | ||
u64_from_BE(g_network_payload.buf + offset, field_len); | ||
break; | ||
case TAG_NETWORK_NAME: | ||
// Get Name | ||
if (field_len >= sizeof(DYNAMIC_NETWORK_INFO.name)) { | ||
PRINTF("NETWORK_NAME Size mismatch!\n"); | ||
return APDU_RESPONSE_INSUFFICIENT_MEMORY; | ||
} | ||
memmove((void *) DYNAMIC_NETWORK_INFO.name, | ||
g_network_payload.buf + offset, | ||
field_len); | ||
break; | ||
case TAG_NETWORK_TICKER: | ||
// Get Ticker | ||
if (field_len >= sizeof(DYNAMIC_NETWORK_INFO.ticker)) { | ||
PRINTF("NETWORK_TICKER Size mismatch!\n"); | ||
return APDU_RESPONSE_INSUFFICIENT_MEMORY; | ||
} | ||
memmove((void *) DYNAMIC_NETWORK_INFO.ticker, | ||
g_network_payload.buf + offset, | ||
field_len); | ||
break; | ||
case TAG_NETWORK_ICON: | ||
// Get Icon | ||
#ifdef HAVE_NBGL | ||
// Image information header: | ||
// - Width (2 Bytes) | ||
// - Height (2 Bytes) | ||
// - BPP (1 Byte) | ||
// - Img buffer size (3 Bytes) | ||
if (field_len < 8) { | ||
PRINTF("NETWORK_ICON header length mismatch (%d)!\n", field_len); | ||
return APDU_RESPONSE_INVALID_DATA; | ||
} | ||
uint32_t img_len = g_network_payload.buf[offset + 5] + | ||
(g_network_payload.buf[offset + 6] << 8) + | ||
(g_network_payload.buf[offset + 7] << 16); | ||
if (field_len != (8 + img_len)) { | ||
PRINTF("NETWORK_ICON length mismatch (%d/%d)!\n", field_len, (8 + img_len)); | ||
return APDU_RESPONSE_INVALID_DATA; | ||
} | ||
// Offset 5 to skip the image information header | ||
if ((DYNAMIC_NETWORK_INFO.icon.bitmap = mem_alloc(field_len)) == NULL) { | ||
PRINTF("NETWORK_ICON Size mismatch!\n"); | ||
return APDU_RESPONSE_INSUFFICIENT_MEMORY; | ||
} | ||
allocated_size += field_len; | ||
DYNAMIC_NETWORK_INFO.icon.width = U2LE(g_network_payload.buf, offset); | ||
DYNAMIC_NETWORK_INFO.icon.height = U2LE(g_network_payload.buf, offset + 2); | ||
DYNAMIC_NETWORK_INFO.icon.bpp = g_network_payload.buf[offset + 4] >> 4; | ||
DYNAMIC_NETWORK_INFO.icon.isFile = true; | ||
memmove((void *) DYNAMIC_NETWORK_INFO.icon.bitmap, | ||
g_network_payload.buf + offset, | ||
field_len); | ||
#endif | ||
break; | ||
case TAG_SIGNATURE: | ||
// TODO | ||
break; | ||
} | ||
offset += field_len; |
Check notice
Code scanning / CodeQL
Long switch case Note
Switch has at least one case that is too long: .
TAG_NETWORK_ICON (34 lines)
Error loading related location
Loading
cedelavergne-ledger
force-pushed
the
cev/B2CA-1566_networks
branch
2 times, most recently
from
September 16, 2024 09:24
61a3ea3
to
17acc05
Compare
cedelavergne-ledger
force-pushed
the
cev/B2CA-1566_networks
branch
from
September 16, 2024 15:19
ee67ea0
to
22083ab
Compare
cedelavergne-ledger
force-pushed
the
cev/B2CA-1566_networks
branch
from
September 16, 2024 17:05
22083ab
to
720b679
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Add feature (new APDU) to inject a network config at runtime.
This configuration is not stored on the device, just used for the running session
Changes include