-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f6ee88
commit de37b89
Showing
42 changed files
with
3,976 additions
and
4,069 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Run coding style check through reusable workflow | ||
|
||
# This workflow will run linting checks to ensure a level of uniformization among all Ledger applications. | ||
# | ||
# The presence of this workflow is mandatory as a minimal level of linting is required. | ||
# You are however free to modify the content of the .clang-format file and thus the coding style of your application. | ||
# We simply ask you to not diverge too much from the linting of the Boilerplate application. | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
- develop | ||
pull_request: | ||
|
||
jobs: | ||
check_linting: | ||
name: Check linting using the reusable workflow | ||
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_lint.yml@v1 | ||
with: | ||
source: './src' | ||
extensions: 'h,c' | ||
version: 11 |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,66 @@ | ||
/******************************************************************************* | ||
* Ledger App - Bitcoin Wallet | ||
* (c) 2016-2019 Ledger | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
********************************************************************************/ | ||
#include "swap.h" | ||
* Ledger App - Bitcoin Wallet | ||
* (c) 2016-2019 Ledger | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
********************************************************************************/ | ||
#include "io.h" | ||
#include "swap.h" | ||
|
||
#include "context.h" | ||
#include "apdu_constants.h" | ||
#include "context.h" | ||
#include "dispatcher.h" | ||
#include "ui.h" | ||
|
||
|
||
void app_main(void) { | ||
// Structured APDU command | ||
command_t cmd; | ||
// Structured APDU command | ||
command_t cmd; | ||
|
||
io_init(); | ||
io_init(); | ||
|
||
if (!G_called_from_swap) { | ||
ui_idle_flow(); | ||
} | ||
if (!G_called_from_swap) { | ||
ui_idle_flow(); | ||
} | ||
|
||
context_init(); | ||
context_init(); | ||
|
||
for (;;) { | ||
// Length of APDU command received in G_io_apdu_buffer | ||
int input_len = 0; | ||
for (;;) { | ||
// Length of APDU command received in G_io_apdu_buffer | ||
int input_len = 0; | ||
|
||
// Receive command bytes in G_io_apdu_buffer | ||
if ((input_len = io_recv_command()) < 0) { | ||
PRINTF("=> io_recv_command failure\n"); | ||
return; | ||
} | ||
// Receive command bytes in G_io_apdu_buffer | ||
if ((input_len = io_recv_command()) < 0) { | ||
PRINTF("=> io_recv_command failure\n"); | ||
return; | ||
} | ||
|
||
// Parse APDU command from G_io_apdu_buffer | ||
if (!apdu_parser(&cmd, G_io_apdu_buffer, input_len)) { | ||
PRINTF("=> /!\\ BAD LENGTH: %.*H\n", input_len, G_io_apdu_buffer); | ||
io_send_sw(SW_INCORRECT_LENGTH); | ||
continue; | ||
} | ||
// Parse APDU command from G_io_apdu_buffer | ||
if (!apdu_parser(&cmd, G_io_apdu_buffer, input_len)) { | ||
PRINTF("=> /!\\ BAD LENGTH: %.*H\n", input_len, G_io_apdu_buffer); | ||
io_send_sw(SW_INCORRECT_LENGTH); | ||
continue; | ||
} | ||
|
||
PRINTF("=> CLA=%02X | INS=%02X | P1=%02X | P2=%02X | Lc=%02X | CData=%.*H\n", | ||
cmd.cla, | ||
cmd.ins, | ||
cmd.p1, | ||
cmd.p2, | ||
cmd.lc, | ||
cmd.lc, | ||
cmd.data); | ||
PRINTF( | ||
"=> CLA=%02X | INS=%02X | P1=%02X | P2=%02X | Lc=%02X | CData=%.*H\n", | ||
cmd.cla, cmd.ins, cmd.p1, cmd.p2, cmd.lc, cmd.lc, cmd.data); | ||
|
||
context.outLength = 0; | ||
context.outLength = 0; | ||
|
||
// Dispatch structured APDU command to handler | ||
if (apdu_dispatcher(&cmd) < 0) { | ||
PRINTF("=> apdu_dispatcher failure\n"); | ||
return; | ||
} | ||
// Dispatch structured APDU command to handler | ||
if (apdu_dispatcher(&cmd) < 0) { | ||
PRINTF("=> apdu_dispatcher failure\n"); | ||
return; | ||
} | ||
} | ||
} |
Oops, something went wrong.