Skip to content

Commit 81e22c8

Browse files
committed
Merge branch 'deadcode'
2 parents e23827b + 13a1f51 commit 81e22c8

File tree

3 files changed

+0
-121
lines changed

3 files changed

+0
-121
lines changed

src/rust/bitbox02-rust-c/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ mod async_usb;
3232
mod noise;
3333
#[cfg(feature = "firmware")]
3434
mod sha2;
35-
#[cfg(feature = "app-ethereum")]
36-
mod sha3;
3735
#[cfg(feature = "firmware")]
3836
mod workflow;
3937

src/rust/bitbox02-rust-c/src/sha2.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,6 @@ pub unsafe extern "C" fn rust_sha256_finish(ctx: *mut *mut c_void, out: *mut c_u
5050
*ctx = core::ptr::null_mut();
5151
}
5252

53-
/// Safety: ctx must be a pointer to a valid sha256 context produced by `rust_sha256_new()`, or a
54-
/// pointer to NULL.
55-
/// After this, the hasher is dropped and `ctx` is set to NULL and must not be used anymore.
56-
#[no_mangle]
57-
pub unsafe extern "C" fn rust_sha256_free(ctx: *mut *mut c_void) {
58-
if !(*ctx).is_null() {
59-
#[allow(clippy::cast_ptr_alignment)] // ctx is properly aligned, see `Box::into_raw`.
60-
drop(Box::from_raw(*ctx as *mut Sha256));
61-
*ctx = core::ptr::null_mut();
62-
}
63-
}
64-
6553
/// Safety: data must be a valid buffer for `len` bytes. `out` must be 32 bytes long.
6654
#[no_mangle]
6755
pub unsafe extern "C" fn rust_sha256(data: *const c_void, len: usize, out: *mut c_uchar) {
@@ -110,30 +98,6 @@ mod tests {
11098
assert_eq!(result, &Sha256::digest(b"foo abc def xyz bar")[..]);
11199
}
112100

113-
#[test]
114-
fn test_free() {
115-
let mut ctx = rust_sha256_new();
116-
unsafe {
117-
rust_sha256_free(&mut ctx);
118-
assert!(ctx.is_null());
119-
rust_sha256_free(&mut ctx);
120-
}
121-
}
122-
123-
// Technically redundant to the other tests. Check that freeing always works.
124-
#[test]
125-
fn test_free_after_use() {
126-
let mut ctx = rust_sha256_new();
127-
unsafe {
128-
let mut result = [0u8; 32];
129-
// This frees ctx.
130-
rust_sha256_finish(&mut ctx, result.as_mut_ptr());
131-
// ctx is NULL now.
132-
rust_sha256_free(&mut ctx);
133-
assert!(ctx.is_null());
134-
};
135-
}
136-
137101
/// Test that input and output can be the same buffer.
138102
#[test]
139103
fn test_overlapping() {

src/rust/bitbox02-rust-c/src/sha3.rs

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)