Skip to content

Commit f9f28d4

Browse files
committed
keystore: call rust keystore_unlock from C
Small fix: since keystore.rs::lock() does more than just call the C function since a recent commit, C invocations to lock must call the Rust function instead.
1 parent 8db607a commit f9f28d4

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/keystore.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ keystore_error_t keystore_encrypt_and_store_seed(
336336
if (memory_is_initialized()) {
337337
return KEYSTORE_ERR_MEMORY;
338338
}
339-
keystore_lock();
339+
rust_keystore_lock();
340340
if (!_validate_seed_length(seed_length)) {
341341
return KEYSTORE_ERR_SEED_SIZE;
342342
}

src/reset.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "memory/smarteeprom.h"
2323
#include "system.h"
2424
#include "uart.h"
25+
#include <rust/rust.h>
2526
#include <screen.h>
2627

2728
#ifndef TESTING
@@ -64,7 +65,7 @@ void reset_ble(void)
6465

6566
void reset_reset(bool status)
6667
{
67-
keystore_lock();
68+
rust_keystore_lock();
6869
#if !defined(TESTING)
6970
bool sc_result_reset_keys = false;
7071
for (int retries = 0; retries < 5; retries++) {

src/rust/bitbox02-rust/src/keystore.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ pub fn stretch_retained_seed_encryption_key(
255255
Ok(zeroize::Zeroizing::new(stretched.to_vec()))
256256
}
257257

258+
#[unsafe(no_mangle)]
259+
pub extern "C" fn rust_keystore_lock() {
260+
lock()
261+
}
262+
258263
/// # Safety
259264
///
260265
/// `encryption_key` must refer to a 32-byte buffer and `out` must have space for 32 bytes.

0 commit comments

Comments
 (0)