Skip to content

Commit 5972663

Browse files
authored
Merge pull request #254 from LedgerHQ/y333/delay_lock_from_app
Y333/delay lock from app
2 parents 13ede06 + 91144dd commit 5972663

File tree

7 files changed

+45
-28
lines changed

7 files changed

+45
-28
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ledger_device_sdk/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ledger_device_sdk"
3-
version = "1.22.1"
3+
version = "1.22.2"
44
authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"]
55
edition = "2021"
66
license.workspace = true
@@ -21,7 +21,7 @@ rand_core = { version = "0.6.3", default-features = false }
2121
zeroize = { version = "1.6.0", default-features = false }
2222
numtoa = "0.2.4"
2323
const-zero = "0.1.1"
24-
ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.8.0" }
24+
ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.8.1" }
2525

2626
[features]
2727
debug = []

ledger_device_sdk/src/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl Comm {
397397
seph::Events::BleReceive => ble::receive(&mut self.apdu_buffer, spi_buffer),
398398

399399
seph::Events::TickerEvent => {
400-
#[cfg(any(target_os = "stax", target_os = "flex"))]
400+
#[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))]
401401
unsafe {
402402
ux_process_ticker_event();
403403
}

ledger_device_sdk/src/seph.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,12 @@ pub fn handle_event(apdu_buffer: &mut [u8], spi_buffer: &[u8]) {
201201
#[cfg(any(target_os = "nanox", target_os = "stax", target_os = "flex"))]
202202
Events::BleReceive => ble::receive(apdu_buffer, spi_buffer),
203203
Events::CAPDUEvent => handle_capdu_event(apdu_buffer, spi_buffer),
204-
Events::TickerEvent => { /* unsafe{ G_io_app.ms += 100; } */ }
204+
Events::TickerEvent => {
205+
#[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))]
206+
unsafe {
207+
ux_process_ticker_event();
208+
}
209+
}
205210
_ => (),
206211
}
207212
}

ledger_device_sdk/src/uxapp.rs

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ pub use ledger_secure_sdk_sys::BOLOS_UX_IGNORE;
1111
pub use ledger_secure_sdk_sys::BOLOS_UX_OK;
1212
pub use ledger_secure_sdk_sys::BOLOS_UX_REDRAW;
1313

14-
fn os_ux_rs(params: &bolos_ux_params_t) {
15-
unsafe { os_ux(params as *const bolos_ux_params_t as *mut bolos_ux_params_t) };
14+
unsafe extern "C" {
15+
pub unsafe static mut G_ux_params: bolos_ux_params_t;
1616
}
1717

1818
#[repr(u8)]
@@ -21,31 +21,43 @@ pub enum UxEvent {
2121
Keyboard = BOLOS_UX_KEYBOARD,
2222
WakeUp = BOLOS_UX_WAKE_UP,
2323
ValidatePIN = BOLOS_UX_VALIDATE_PIN,
24-
LastID = BOLOS_UX_VALIDATE_PIN + 1,
24+
DelayLock = BOLOS_UX_DELAY_LOCK,
25+
LastID = BOLOS_UX_DELAY_LOCK + 1,
2526
}
2627

2728
impl UxEvent {
29+
#[allow(unused)]
2830
pub fn request(&self) -> u32 {
29-
let mut params = bolos_ux_params_t::default();
30-
params.ux_id = match self {
31-
Self::Event => Self::Event as u8,
32-
Self::Keyboard => Self::Keyboard as u8,
33-
Self::WakeUp => Self::WakeUp as u8,
34-
Self::ValidatePIN => {
35-
// Perform pre-wake up
36-
params.ux_id = Self::WakeUp as u8;
37-
os_ux_rs(&params);
31+
unsafe {
32+
//let mut params = bolos_ux_params_t::default();
33+
G_ux_params.ux_id = match self {
34+
Self::Event => Self::Event as u8,
35+
Self::Keyboard => Self::Keyboard as u8,
36+
Self::WakeUp => Self::WakeUp as u8,
37+
Self::ValidatePIN => {
38+
// Perform pre-wake up
39+
G_ux_params.ux_id = Self::WakeUp as u8;
40+
os_ux(&raw mut G_ux_params as *mut bolos_ux_params_t);
3841

39-
Self::ValidatePIN as u8
40-
}
41-
Self::LastID => panic!("Unknown UX Event"),
42-
};
42+
Self::ValidatePIN as u8
43+
}
44+
Self::DelayLock => {
45+
#[cfg(any(target_os = "stax", target_os = "flex", feature = "nano_nbgl"))]
46+
{
47+
G_ux_params.u.lock_delay.delay_ms = 10000;
48+
}
4349

44-
os_ux_rs(&params);
50+
Self::DelayLock as u8
51+
}
52+
Self::LastID => panic!("Unknown UX Event"),
53+
};
4554

46-
match self {
47-
Self::ValidatePIN => Self::block(),
48-
_ => unsafe { os_sched_last_status(TASK_BOLOS_UX as u32) as u32 },
55+
os_ux(&raw mut G_ux_params as *mut bolos_ux_params_t);
56+
57+
match self {
58+
Self::ValidatePIN => Self::block(),
59+
_ => os_sched_last_status(TASK_BOLOS_UX as u32) as u32,
60+
}
4961
}
5062
}
5163

ledger_secure_sdk_sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ledger_secure_sdk_sys"
3-
version = "1.8.0"
3+
version = "1.8.1"
44
authors = ["yhql", "agrojean-ledger", "yogh333"]
55
edition = "2021"
66
license.workspace = true

ledger_secure_sdk_sys/src/c/src.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void c_reset_bss() {
251251
memset(bss, 0, bss_len);
252252
}
253253

254-
bolos_ux_params_t G_ux_params;
254+
bolos_ux_params_t G_ux_params = {0};
255255

256256
void c_boot_std() {
257257
// below is a 'manual' implementation of `io_seproxyhal_init`

0 commit comments

Comments
 (0)