Skip to content

Commit 8c0a731

Browse files
committed
add a build option: ENABLE_DUMB_DONGLE
1 parent a758796 commit 8c0a731

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ project(canokey-core C)
55
option(ENABLE_TESTS "Perform unit tests after build" OFF)
66
option(ENABLE_FUZZING "Build for fuzzing" OFF)
77
option(ENABLE_DEBUG_OUTPUT "Print debug messages" ON)
8+
option(ENABLE_DUMB_DONGLE "Skip all user-presence test (USE AT YOUR OWN RISK)" OFF)
89
option(VIRTCARD "Virt Card" OFF)
910

1011
set(CMAKE_C_STANDARD 11)
@@ -21,6 +22,9 @@ if (ENABLE_TESTS OR ENABLE_FUZZING)
2122
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-usage")
2223
endif ()
2324
endif ()
25+
if (ENABLE_DUMB_DONGLE)
26+
add_definitions(-DDUMB_DONGLE)
27+
endif (ENABLE_DUMB_DONGLE)
2428

2529
add_subdirectory(canokey-crypto EXCLUDE_FROM_ALL)
2630

src/device.c

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ uint8_t wait_for_user_presence(uint8_t entry) {
6666
uint32_t last = start;
6767
DBG_MSG("start %u\n", start);
6868
while (get_touch_result() == TOUCH_NO) {
69+
#ifdef DUMB_DONGLE
70+
break;
71+
#endif
6972
// Keep blinking, in case other applet stops it
7073
start_blinking(0);
7174
// Nested CCID processing is not allowed
@@ -102,6 +105,9 @@ int send_keepalive_during_processing(uint8_t entry) {
102105
}
103106

104107
__attribute__((weak)) int strong_user_presence_test(void) {
108+
#ifdef DUMB_DONGLE
109+
return 0;
110+
#endif
105111
for (int i = 0; i < 5; i++) {
106112
const uint8_t wait_sec = 2;
107113
start_blinking_interval(wait_sec, (i & 1) ? 200 : 50);

0 commit comments

Comments
 (0)