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

BC2A-1408: Remove duplicate apdu_parser #1

Merged
merged 3 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions src/apdu/dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#pragma once

#include "../types.h"
#include "parser.h"

/**
* Parameter 2 for last APDU to receive.
Expand Down
46 changes: 0 additions & 46 deletions src/apdu/parser.c

This file was deleted.

45 changes: 0 additions & 45 deletions src/apdu/parser.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "io.h"
#include "sw.h"
#include "ui/menu.h"
#include "apdu/parser.h"
#include "parser.h"
#include "apdu/dispatcher.h"

global_ctx_t G_context;
Expand Down
12 changes: 0 additions & 12 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,6 @@ typedef enum {
SIGN_MESSAGE = 0x07 /// sign a personal message with BIP32 path
} command_e;

/**
* Structure with fields of APDU command.
*/
typedef struct {
uint8_t cla; /// Instruction class
command_e ins; /// Instruction code
uint8_t p1; /// Instruction parameter 1
uint8_t p2; /// Instruction parameter 2
uint8_t lc; /// Length of command data
uint8_t *data; /// Command data
} command_t;

/**
* Enumeration with parsing state.
*/
Expand Down
2 changes: 1 addition & 1 deletion unit-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ add_library(sighash SHARED ../src/sighash.c)
add_library(personal_message SHARED ../src/personal_message.c)
add_library(write SHARED /opt/ledger-secure-sdk/lib_standard_app/write.c)
add_library(format_local SHARED ../src/common/format_local.c)
add_library(apdu_parser SHARED ../src/apdu/parser.c)
add_library(apdu_parser SHARED /opt/ledger-secure-sdk/lib_standard_app/parser.c)
add_library(transaction_deserialize ../src/transaction/deserialize.c)
add_library(transaction_serialize ../src/transaction/serialize.c)
add_library(transaction_utils ../src/transaction/utils.c)
Expand Down
7 changes: 4 additions & 3 deletions unit-tests/test_apdu_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <cmocka.h>

#include "types.h"
#include "apdu/parser.h"
#include "parser.h"

static void test_apdu_parser(void **state) {
(void) state;
Expand All @@ -42,10 +42,11 @@ static void test_apdu_parser(void **state) {
command_t cmd;

memset(&cmd, 0, sizeof(cmd));
assert_false(apdu_parser(&cmd, apdu_bad_min_len, sizeof(apdu_bad_min_len)));
assert_true(apdu_parser(&cmd, apdu_bad_min_len, sizeof(apdu_bad_min_len)));
assert_int_equal(cmd.lc, 0);

memset(&cmd, 0, sizeof(cmd));
assert_false(apdu_parser(&cmd, apdu_bad_lc, sizeof(apdu_bad_min_len)));
assert_false(apdu_parser(&cmd, apdu_bad_lc, sizeof(apdu_bad_lc)));

memset(&cmd, 0, sizeof(cmd));
assert_true(apdu_parser(&cmd, apdu, sizeof(apdu)));
Expand Down