19 Commits

Author SHA1 Message Date
Kirill Shakirov a6e64f4d3d Added CPU optimized client variant. 2026-04-27 14:06:28 +02:00
Kirill Shakirov d6fa6093cb Remove FreeBSD build action. 2026-04-06 23:08:30 +02:00
Kirill Shakirov b99926e0b0 More fixes. 2026-04-06 23:02:11 +02:00
Kirill Shakirov e1a7fdba0b Fix build on FreeBSD action. 2026-04-06 22:52:09 +02:00
Kirill Shakirov f8a0c6d5cd Add build on FreeBSD action. 2026-04-06 22:47:18 +02:00
Kirill Shakirov 0345542a52 Server cargo update. 2026-04-06 22:27:06 +02:00
Kirill Shakirov 9761004c23 Bump version. 2026-04-04 15:37:04 +02:00
Kirill Shakirov 172ab78e6b Merge branch 'main' of https://github.com/Nyanraltotlapun/nyash-aes-xts256-plain64
I have no idea
2026-04-04 15:29:39 +02:00
Kirill Shakirov 8288930872 Fixes and rework to some ocl code, using u32 for batch size. 2026-04-04 15:27:29 +02:00
Kirill Shakirov 80f748870d Update rust.yml 2026-03-28 06:51:26 +01:00
Kirill Shakirov ac731d5094 Update rust.yml 2026-03-28 06:45:45 +01:00
Kirill Shakirov 75e493bf5c Update rust.yml 2026-03-28 06:39:06 +01:00
Kirill Shakirov 755bb84b68 Update rust.yml 2026-03-28 06:36:47 +01:00
Kirill Shakirov 6bff55fdfe Update rust.yml 2026-03-28 06:25:48 +01:00
Kirill Shakirov eeb54aad50 Update rust.yml 2026-03-28 06:20:16 +01:00
Kirill Shakirov f253673edd Update rust.yml 2026-03-28 06:13:18 +01:00
Kirill Shakirov 52c2f3ae35 Create rust.yml 2026-03-28 06:09:17 +01:00
Kirill Shakirov 6297474142 Small changes. 2026-03-28 00:28:25 +01:00
Kirill Shakirov 21fff99a55 Readme edit and romoving unneccesary parts of Cargo.toml 2026-03-14 23:55:13 +01:00
30 changed files with 3411 additions and 262 deletions
+35
View File
@@ -0,0 +1,35 @@
name: Rust
on:
workflow_dispatch:
inputs:
build_type:
description: 'Build configuration'
required: true
default: 'release'
type: choice
options:
- debug
- release
env:
CARGO_TERM_COLOR: always
jobs:
build-m1:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin
- run: cargo build --manifest-path nyash_client/Cargo.toml --target aarch64-apple-darwin --release
- name: Upload Binary
uses: actions/upload-artifact@v4
with:
name: nyash-client-aarch64-apple-darwin
path: nyash_client/target/aarch64-apple-darwin/release/nyash-client
+6
View File
@@ -1,2 +1,8 @@
# nyash-aes-xts256-plain64
Utility for GPU distributed brute-force search of aes-xts256 encryption key
There is no DOCS!
Its mostly educational project that can serve as code examples.
But pull requests are still welcome, as well as reasonable questions.
+43 -50
View File
@@ -226,9 +226,9 @@ dependencies = [
[[package]]
name = "fastrand"
version = "2.3.0"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
checksum = "a043dc74da1e37d6afe657061213aa6f425f855399a11d3463c6ecccc4dfda1f"
[[package]]
name = "fixedbitset"
@@ -403,9 +403,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]]
name = "hyper"
version = "1.8.1"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11"
checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca"
dependencies = [
"atomic-waker",
"bytes",
@@ -418,7 +418,6 @@ dependencies = [
"httpdate",
"itoa",
"pin-project-lite",
"pin-utils",
"smallvec",
"tokio",
"want",
@@ -465,9 +464,9 @@ checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
[[package]]
name = "indexmap"
version = "2.13.0"
version = "2.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
checksum = "45a8a2b9cb3e0b0c1803dbb0758ffac5de2f425b23c28f518faabd9d805342ff"
dependencies = [
"equivalent",
"hashbrown 0.16.1",
@@ -486,9 +485,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "1.0.17"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "lazy_static"
@@ -504,15 +503,15 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
[[package]]
name = "libc"
version = "0.2.178"
version = "0.2.184"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af"
[[package]]
name = "linux-raw-sys"
version = "0.11.0"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
[[package]]
name = "log"
@@ -528,9 +527,9 @@ checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
[[package]]
name = "memchr"
version = "2.7.6"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
[[package]]
name = "mime"
@@ -550,9 +549,9 @@ dependencies = [
[[package]]
name = "mio"
version = "1.1.1"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc"
checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1"
dependencies = [
"libc",
"wasi",
@@ -600,7 +599,7 @@ dependencies = [
[[package]]
name = "nyash_client"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"flate2",
"ocl",
@@ -665,9 +664,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.21.3"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "percent-encoding"
@@ -712,12 +711,6 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "prettyplease"
version = "0.2.37"
@@ -730,9 +723,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.103"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
dependencies = [
"unicode-ident",
]
@@ -792,9 +785,9 @@ dependencies = [
[[package]]
name = "pulldown-cmark"
version = "0.13.1"
version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83c41efbf8f90ac44de7f3a868f0867851d261b56291732d0cbf7cceaaeb55a6"
checksum = "7c3a14896dfa883796f1cb410461aef38810ea05f2b2c33c5aded3649095fdad"
dependencies = [
"bitflags 2.11.0",
"memchr",
@@ -812,9 +805,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.42"
version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
dependencies = [
"proc-macro2",
]
@@ -875,9 +868,9 @@ dependencies = [
[[package]]
name = "rustix"
version = "1.1.3"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34"
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
dependencies = [
"bitflags 2.11.0",
"errno",
@@ -888,9 +881,9 @@ dependencies = [
[[package]]
name = "semver"
version = "1.0.27"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
[[package]]
name = "serde"
@@ -947,9 +940,9 @@ dependencies = [
[[package]]
name = "simd-adler32"
version = "0.3.8"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2"
checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214"
[[package]]
name = "slab"
@@ -975,9 +968,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.111"
version = "2.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87"
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
dependencies = [
"proc-macro2",
"quote",
@@ -992,9 +985,9 @@ checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
[[package]]
name = "tempfile"
version = "3.25.0"
version = "3.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0136791f7c95b1f6dd99f9cc786b91bb81c3800b639b3478e561ddb7be95e5f1"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
"getrandom",
@@ -1025,9 +1018,9 @@ dependencies = [
[[package]]
name = "tokio"
version = "1.50.0"
version = "1.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d"
checksum = "2bd1c4c0fc4a7ab90fc15ef6daaa3ec3b893f004f915f2392557ed23237820cd"
dependencies = [
"bytes",
"libc",
@@ -1041,9 +1034,9 @@ dependencies = [
[[package]]
name = "tokio-macros"
version = "2.6.1"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c"
checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496"
dependencies = [
"proc-macro2",
"quote",
@@ -1218,9 +1211,9 @@ checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
[[package]]
name = "unicode-ident"
version = "1.0.22"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "unicode-xid"
@@ -1400,6 +1393,6 @@ dependencies = [
[[package]]
name = "zmij"
version = "1.0.13"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac93432f5b761b22864c774aac244fa5c0fd877678a4c37ebf6cf42208f9c9ec"
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
+1 -7
View File
@@ -1,6 +1,6 @@
[package]
name = "nyash_client"
version = "0.1.0"
version = "0.2.0"
edition = "2024"
build = "build.rs"
@@ -23,9 +23,3 @@ tonic-prost-build = "0.14.5"
ocl-include = "0.6"
flate2 = "1.1.9"
[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
ar = "x86_64-w64-mingw32-ar"
rustflags = ["-L", "/usr/x86_64-w64-mingw32/lib"]
+13 -9
View File
@@ -100,7 +100,7 @@ async fn commit_work(
return Ok(response.into_inner());
}
fn benchmark(exec_context: &mut ocl_utils::ExecContext) -> (u64, usize) {
fn benchmark(exec_context: &mut ocl_utils::ExecContext) -> (u32, usize) {
let mut nyan_exec_dat = ocl_utils::ExecData {
start_key: vec![1u32; 4],
tweak_key: vec![2u32; 4],
@@ -113,21 +113,23 @@ fn benchmark(exec_context: &mut ocl_utils::ExecContext) -> (u64, usize) {
work_size: 128,
};
let total_work: u64 = 1280000000;
let total_work: u64 = 128000000;
let work_sizes: [usize; 8] = [128, 256, 512, 1024, 2048, 4096, 8192, 16384];
let mut work_time = [0f64; 8];
ocl_utils::set_target_data(exec_context, &mut nyan_exec_dat).expect("Error set target data!");
let mut preffered_work_size: usize = work_sizes[0];
let mut preffered_batch_size: u64 = 0;
let mut preffered_batch_size: u32 = 0;
for i in 0..8 {
let test_work_s = work_sizes[i];
let batch_size: u64 = total_work / test_work_s as u64;
let batch_size: u32 = (total_work / test_work_s as u64) as u32;
nyan_exec_dat.work_size = test_work_s;
nyan_exec_dat.batch_size = batch_size;
println!("Benchmarking work size {}", test_work_s);
for _j in 0..3 {
println!("Run number {}", _j);
//exec_context.reinit_kernel(test_work_s).expect("Error reinit kernel!");
let (_, exec_time) =
ocl_utils::do_work(exec_context, &mut nyan_exec_dat).expect("Error running tests!");
work_time[i] += exec_time;
@@ -142,7 +144,8 @@ fn benchmark(exec_context: &mut ocl_utils::ExecContext) -> (u64, usize) {
}
preffered_work_size = work_sizes[i];
// calculate batch size so it correspond to 30 sec job
preffered_batch_size = (batch_size as f64 * (20.0 / work_time[i])) as u64;
let p_b_u64 = (batch_size as f64 * (10.0 / work_time[i])) as u64;
preffered_batch_size = p_b_u64.min(u32::MAX as u64) as u32;
println!("batch_size {}, work_time {}, preffered_batch_size {}, preffered_work_size {}",
batch_size,
work_time[i],
@@ -202,7 +205,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
nyash_dev_cfg.work_size, nyash_dev_cfg.batch_size
);
let (_, _, encrypted_data) = search_params::get_params();
let encrypted_data = search_params::get_params();
//setting data
let mut nyan_exec_dat = ocl_utils::ExecData {
start_key: Vec::new(),
@@ -290,7 +293,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
]))
.to_vec();
let mut batch_size = work_data.work_size / nyan_exec_dat.work_size as u64;
let bs_u64 = work_data.work_size / nyan_exec_dat.work_size as u64;
let mut batch_size = bs_u64.min(u32::MAX as u64) as u32;
if (work_data.work_size % nyan_exec_dat.work_size as u64) != 0 {
batch_size += 1;
}
@@ -298,6 +302,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
nyan_exec_dat.batch_size = batch_size;
println!("Crunching numbers...");
//exec_context.reinit_kernel(nyan_exec_dat.work_size).expect("Error reinit kernel!");
match ocl_utils::do_work(&mut exec_context, &mut nyan_exec_dat) {
Err(_) => println!("Error doing work!"),
Ok((k_f, work_time)) => {
@@ -308,8 +313,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let g_k_p_s = (work_data.work_size as f64 / work_time) / 1000000000.0;
if giga_keys_per_second != 0f64 {
giga_keys_per_second -= giga_keys_per_second / 10.0;
giga_keys_per_second += g_k_p_s / 10.0;
giga_keys_per_second = giga_keys_per_second*0.9 + g_k_p_s*0.1;
} else {
giga_keys_per_second = g_k_p_s;
}
+1 -1
View File
@@ -10,7 +10,7 @@ pub struct DevConf {
pub platform_name: String,
pub id: usize,
pub work_size: usize,
pub batch_size: u64,
pub batch_size: u32,
}
impl DevConf {
+28 -6
View File
@@ -7,7 +7,7 @@ use crate::num_utils;
pub struct CtxBuffers {
tweak_params: Buffer<u32>,
batch_size: Buffer<u64>,
batch_size: Buffer<u32>,
start_key: Buffer<u32>,
tweak_key: Buffer<u32>,
uenc_data: Buffer<u32>,
@@ -23,7 +23,7 @@ pub struct ExecData {
pub tweak_i: u64,
pub tweak_j: u32,
pub key_found: Vec<u32>,
pub batch_size: u64,
pub batch_size: u32,
pub work_size: usize,
}
impl ExecData {
@@ -99,11 +99,11 @@ pub fn init_buffers(cl_queue: &Queue) -> Result<CtxBuffers, ocl::Error> {
.fill_val(0u32)
.build()?;
let cl_buffer_batch_size = Buffer::<u64>::builder()
let cl_buffer_batch_size = Buffer::<u32>::builder()
.queue(cl_queue.clone())
.flags(flags::MEM_READ_ONLY)
.len(1)
.fill_val(0u64)
.fill_val(0u32)
.build()?;
let cl_buffer_start_key = Buffer::<u32>::builder()
@@ -201,6 +201,16 @@ impl ExecContext {
buffers: nya_cl_buffers,
})
}
pub fn reinit_kernel(&mut self, global_work_size: usize) -> Result<(), ocl::Error> {
self.kernel = init_kernel(
global_work_size,
&self._prog,
&self.queue,
&self.buffers,
)?;
Ok(())
}
}
pub fn set_target_data(ex_ctx: &mut ExecContext, ex_data: &mut ExecData) -> Result<(), ocl::Error> {
@@ -235,7 +245,7 @@ pub fn set_target_data(ex_ctx: &mut ExecContext, ex_data: &mut ExecData) -> Resu
.write(&ex_data.target_data)
.enq()?;
ex_ctx.queue.finish()?;
//ex_ctx.queue.finish()?;
return Ok(());
}
@@ -246,6 +256,7 @@ pub fn do_work(ex_ctx: &mut ExecContext, ex_data: &mut ExecData) -> Result<(bool
let start_time = std::time::Instant::now();
//println!("Copy batch_size buffer...");
// tranfer batch_size
ex_ctx
.buffers
@@ -257,6 +268,7 @@ pub fn do_work(ex_ctx: &mut ExecContext, ex_data: &mut ExecData) -> Result<(bool
.enq()?;
//println!("Copy start_key buffer...");
// transfer start key to device
ex_ctx
.buffers
@@ -267,6 +279,7 @@ pub fn do_work(ex_ctx: &mut ExecContext, ex_data: &mut ExecData) -> Result<(bool
.write(&ex_data.start_key)
.enq()?;
//println!("Copy tweak_key buffer...");
// transfet tweak key
ex_ctx
.buffers
@@ -287,7 +300,9 @@ pub fn do_work(ex_ctx: &mut ExecContext, ex_data: &mut ExecData) -> Result<(bool
// .fill(0u32, None)
// .enq()?;
//println!("Copy data to GPU...");
//ex_ctx.queue.finish()?;
//println!("Run kernel...");
// (4) Run the kernel
unsafe {
ex_ctx
@@ -298,6 +313,10 @@ pub fn do_work(ex_ctx: &mut ExecContext, ex_data: &mut ExecData) -> Result<(bool
.enq()?;
}
//println!("Waiting for kernel to finish work...");
//ex_ctx.queue.finish()?;
//println!("Copy data back from GPU...");
// read key_foun buffer
ex_ctx
.buffers
@@ -308,6 +327,9 @@ pub fn do_work(ex_ctx: &mut ExecContext, ex_data: &mut ExecData) -> Result<(bool
.read(&mut ex_data.key_found)
.enq()?;
//println!("Copy results back...");
//ex_ctx.queue.finish()?;
let exec_duration = start_time.elapsed().as_secs_f64();
//ex_ctx.queue.finish()?;
+19
View File
@@ -45,6 +45,25 @@ inline uint add_one_to_bigint4_(uint *_n)
return t.i[1];
}
inline uint add_ulong_to_bigint4_ (uint* _n, const ulong b)
{
ul_ui_union bu = {b};
ul_ui_union t;
t.l = (ulong)_n[0] + (ulong)bu.i[0];
_n[0] = t.i[0];
t.l = (ulong)t.i[1] + (ulong)_n[1] + (ulong)bu.i[1];
_n[1] = t.i[0];
t.l = (ulong)_n[2] + (ulong)t.i[1];
_n[2] = t.i[0];
t.l = (ulong)_n[3] + (ulong)t.i[1];
_n[3] = t.i[0];
return t.i[1];
}
inline uint add_uint_to_bigint4_ (uint* _n, const uint b)
{
ul_ui_union t;
@@ -41,7 +41,7 @@
// g_params[1-2] - ulong g_Ti
// g_params[3] - g_Tj
__kernel void search_key(__global const uint* g_tweak_params,
__global const ulong* g_batch_size,
__global const uint* g_batch_size,
__global const uint4* g_start_enc_key,
__global const uint4* g_tweak_key,
__global const uint4* g_uenc_data,
@@ -59,7 +59,7 @@ __kernel void search_key(__global const uint* g_tweak_params,
uint t_ks[44]; // tweak expanded key
//set batch_size
ulong batch_size = g_batch_size[0];
uint batch_size = g_batch_size[0];
// set disk sector number
uint sec_n[4] = {0};
@@ -73,7 +73,8 @@ __kernel void search_key(__global const uint* g_tweak_params,
vstore4(*g_tweak_key, 0, tweak);
// Set initial start key for every work thread
uint k_data_carry = add_uint_to_bigint4_ (enc_key, (g_id*batch_size));
ulong th_shift = (ulong)g_id * (ulong)batch_size;
uint k_data_carry = add_ulong_to_bigint4_ (enc_key, th_shift);
if (k_data_carry != 0u) return; // if reached max key value exit thread
// Generate tweak
@@ -81,7 +82,7 @@ __kernel void search_key(__global const uint* g_tweak_params,
aes_xts256_gen_tweak (t_ks, sec_n, Tj, tweak);
//if (g_id == 0) g_key_found[1] = 1;
for (ulong batch_id = 0ul; batch_id < batch_size; batch_id++)
for (uint batch_id = 0u; batch_id < batch_size; batch_id++)
{
//if (g_id == 0) g_key_found[1] = 2;
// Set encrypt key
@@ -22,6 +22,3 @@ __kernel void test_add(__global const uint* g_num_to_add,
}
+2 -17
View File
@@ -1,29 +1,14 @@
pub fn get_params() -> ([u32; 4], [u32; 4], [u32; 4]) {
use crate::num_utils;
pub fn get_params() -> [u32; 4] {
const ENCRYPTED_DATA: [u8; 16] = [
10, 51, 110, 227, 194, 181, 104, 65, 151, 47, 69, 37, 66, 223, 71, 137,
];
const KEY_DATA: [u8; 32] = [
206, 193, 83, 54, 46, 234, 185, 41, 146, 244, 130, 6, 212, 68, 106, 162, 165, 97, 188, 218,
39, 111, 141, 236, 67, 159, 157, 157, 166, 79, 89, 134,
];
// let key_bytes_reversed: Vec<u8> = KEY_DATA.iter().rev().map(|e| *e).collect();
// let data_bytes_reversed: Vec<u8> = ENCRYPTED_DATA.iter().rev().map(|e| *e).collect();
let mut tweak_key_b: [u8; 16] = [0u8; 16];
let mut data_key_b: [u8; 16] = [0u8; 16];
data_key_b.copy_from_slice(&KEY_DATA[0..16]);
tweak_key_b.copy_from_slice(&KEY_DATA[16..32]);
// getting keys
let data_key = u128::from_le_bytes(data_key_b);
let tweak_key = u128::from_le_bytes(tweak_key_b);
let data_key = num_utils::u128_to_u32arr(data_key);
let tweak_key = num_utils::u128_to_u32arr(tweak_key);
// converting bytes raw data to u32 arr
let mut encrypted_data: [u32; 4] = [0u32; 4];
@@ -32,5 +17,5 @@ pub fn get_params() -> ([u32; 4], [u32; 4], [u32; 4]) {
encrypted_data[i] = u32::from_le_bytes(enc_dat_bytes_chunks[i]);
}
return (data_key, tweak_key, encrypted_data);
return encrypted_data;
}
+154
View File
@@ -0,0 +1,154 @@
Need to pass into CMD for opt
```
RUSTFLAGS='--cfg aes_backend="avx512" -Ctarget-feature=+aes,+avx512f,+vaes' cargo build --release
```
```
Passing RUSTFLAGS=-Ctarget-feature=+aes,+ssse3 explicitly at compile-time will override runtime detection and ensure that AES-NI is used or passing RUSTFLAGS=-Ctarget-feature=+aes,+avx512f,+ssse3,+vaes will ensure that AESNI and VAES are always used.
```
# Building nyash_client
Cross-compilation guide for **Ubuntu 24.04 LTS** — produces native Linux binary and Windows `.exe` from a single build server.
## Requirements
- Ubuntu 24.04 LTS (Noble Numbat)
- Internet access on the build server
- No GPU required — OpenCL CPU runtime is provided by the user at runtime
---
## Step 1 — System packages
```bash
sudo apt update && sudo apt install -y \
curl wget git unzip build-essential pkg-config \
gcc-mingw-w64-x86-64 mingw-w64 mingw-w64-tools \
ocl-icd-opencl-dev opencl-headers pocl-opencl-icd \
protobuf-compiler
```
---
## Step 2 — Rust
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Select: 1 (default)
source $HOME/.cargo/env
rustup target add x86_64-pc-windows-gnu
```
Verify:
```bash
rustc --version
protoc --version
```
---
## Step 3 — OpenCL Windows stub
The build server does not need a GPU or OpenCL runtime. Only a linker stub (`libOpenCL.a`) is required at compile time. The actual OpenCL runtime is provided by the user's OS/drivers at runtime.
```bash
cd ~
wget https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v2023.12.14/OpenCL-SDK-v2023.12.14-Win-x64.zip
unzip OpenCL-SDK-v2023.12.14-Win-x64.zip -d opencl-sdk
SDK=~/opencl-sdk/OpenCL-SDK-v2023.12.14-Win-x64
# Generate .def from DLL
cd $SDK/bin
gendef OpenCL.dll
# Generate libOpenCL.a from .def
x86_64-w64-mingw32-dlltool \
-D OpenCL.dll \
-d OpenCL.def \
-l libOpenCL.a
# Install into MinGW sysroot
sudo cp libOpenCL.a /usr/x86_64-w64-mingw32/lib/
sudo cp -r $SDK/include/CL /usr/x86_64-w64-mingw32/include/
```
Verify:
```bash
ls /usr/x86_64-w64-mingw32/lib/libOpenCL.a
ls /usr/x86_64-w64-mingw32/include/CL/cl.h
```
---
## Step 4 — Clone the repository
```bash
cd ~
git clone https://github.com/Nyanraltotlapun/nyash-aes-xts256-plain64.git
cd nyash-aes-xts256-plain64/nyash_client
```
---
## Step 5 — Cargo config
Create `.cargo/config.toml` in the `nyash_client` directory:
```bash
mkdir -p .cargo
cat > .cargo/config.toml << 'EOF'
[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
ar = "x86_64-w64-mingw32-ar"
rustflags = ["-L", "/usr/x86_64-w64-mingw32/lib"]
[target.x86_64-unknown-linux-gnu]
linker = "gcc"
[env]
PROTOC = "/usr/bin/protoc"
EOF
```
---
## Step 6 — Build
```bash
rustup target add x86_64-pc-windows-gnu
# Linux
cargo build --release
# Windows
cargo build --release --target x86_64-pc-windows-gnu
```
---
## Output
| Platform | Path |
|----------|------|
| Linux | `target/release/nyash-client` |
| Windows | `target/x86_64-pc-windows-gnu/release/nyash-client.exe` |
---
## Runtime requirements for end users
The `.exe` does **not** bundle an OpenCL runtime — it is loaded dynamically from the user's system.
| OS | OpenCL source |
|---------|----------------------------------------------------|
| Windows | Intel CPU Runtime for OpenCL — installed automatically with Intel drivers, or download from [intel.com](https://www.intel.com/content/www/us/en/developer/articles/tool/opencl-drivers.html) |
| Linux | `sudo apt install pocl-opencl-icd` (CPU) or vendor GPU driver |
+1231
View File
File diff suppressed because it is too large Load Diff
+31
View File
@@ -0,0 +1,31 @@
[package]
name = "nyash_client"
version = "0.2.0"
edition = "2024"
build = "build.rs"
[[bin]] # Bin to run the HelloWorld gRPC client
name = "nyash-client"
path = "src/client.rs"
[dependencies]
aes = { version = "0.9" }
prost = "0.14.3"
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.149"
threadpool = "1.8.1"
tokio = { version = "1.50.0", features = ["rt", "macros", "signal"] }
tonic = "0.14.5"
tonic-prost = "0.14.5"
[build-dependencies]
tonic-prost-build = "0.14.5"
[profile.release]
lto = true
codegen-units = 1
opt-level = 3
strip = true
+26
View File
@@ -0,0 +1,26 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
//compile gRPC
tonic_prost_build::compile_protos("proto/nyash.proto")?;
//******************* compile ocl into spirv64 *********
// let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
// let ocl_src_dir = Path::new(&manifest_dir).join("src/open_cl");
// let spirv_build_script = ocl_src_dir.clone().join("build_spirv.sh");
// let out_dir = env::var("OUT_DIR").unwrap();
// let spirv_bin_path = Path::new(&out_dir).join("nyash_aes_xts256_plain.spv");
// let str_spirv_bit_p = spirv_bin_path.to_str().expect("Error converting spirv out path to str!");
// let _output = Command::new(spirv_build_script)
// .current_dir(ocl_src_dir)
// .arg(str_spirv_bit_p)
// .output()
// .expect("Failed to execute spirv build script!");
// ***************** concat ocl sources to one file and zip it **********************
Ok(())
}
+80
View File
@@ -0,0 +1,80 @@
syntax = "proto3";
package nyash_proto;
// serving key brutforcing for aes xts
service NyashLuks {
// Requesting work, gettin in response work data, error, or message that there is no work currently awaylable.
rpc RequestWork (WorkRequest) returns (WorkReply);
// Commiting work, with work ID. If key was found, sending also discowered key
rpc CommitWork (WorkCommit) returns (CommitReply);
// Request owerall key search progress
rpc RequestProgress (ProgressRequest) returns (ProgressReply);
}
message WorkRequest {
// Request work from server
// Preffered work size in number of keys
uint64 pref_work_size = 1;
}
message WorkReply {
oneof result {
WorkData work_data = 1;
bool no_work = 2;
string error = 3;
}
}
message WorkData {
// work id
uint64 work_id =1;
// work size - number of keys to check
uint64 work_size= 2;
// tweak key is 128 bit. We send it as two uint64 values
uint64 tweak_key0 =3;
uint64 tweak_key1 =4;
// start key is 128 bit. We send it as two uint64 values
uint64 start_key0 =5;
uint64 start_key1 =6;
}
message WorkCommit {
// work id
uint64 work_id =1;
oneof result {
bool no_key = 2;
KeyData found_key = 3;
}
}
message KeyData {
// tweak key is 128 bit. We send it as two uint64 values
uint64 tweak_key0 =3;
uint64 tweak_key1 =4;
// start key is 128 bit. We send it as two uint64 values
uint64 start_key0 =5;
uint64 start_key1 =6;
}
message CommitReply {
// Status code
// 0 - means ok
// 1 - something went wrong on server
// 2 - something wrong with request
uint32 status_code = 1;
// Brutforce progress as ratio from 0 to 1(completed)
double progress = 2;
}
// request total progress
message ProgressRequest {
}
message ProgressReply {
// Brutforce progress as ratio from 0 to 1(completed)
bool key_found = 1;
double progress = 2;
}
+189
View File
@@ -0,0 +1,189 @@
use aes;
use aes::Aes128;
use aes::cipher::array::sizes;
use aes::cipher::{Array, BlockCipherEncrypt, KeyInit};
use std::sync::mpsc;
use threadpool::ThreadPool;
/// Galois field multiplication
/// Multiplies a 128-bit block by x in GF(2^128) for AES-XTS.
/// The irreducible polynomial used is x^128 + x^7 + x^2 + x + 1 (0x87).
// #[inline]
// fn gf128_mul_by_x(block: &mut Array<u8, sizes::U16>) {
// let mut carry = 0u8;
// // Process bytes from most significant (15) to least significant (0)
// for byte in block.iter_mut().rev() {
// let temp = *byte;
// *byte = (*byte << 1) | carry;
// carry = temp >> 7; // The bit that was shifted out
// }
// // If the most significant bit of the original block was 1, apply reduction
// if carry != 0 {
// block[15] ^= 0x87; // XOR with the reduction polynomial
// }
// }
// #[inline]
// fn aes_xts256_gen_tweak(
// tweak_key: &Array<u8, sizes::U16>,
// sector_number: &Array<u8, sizes::U16>,
// block_number: u32,
// tweak_buff: &mut Array<u8, sizes::U16>,
// ) {
// let cipher = Aes128::new(tweak_key);
// cipher.encrypt_block_b2b(sector_number, tweak_buff);
// //Double the tweak value block_n-1 times (since first block is 0)
// for _ in 0..block_number {
// gf128_mul_by_x(tweak_buff);
// }
// }
#[inline]
fn gen_tweak_zero_block(tweak_key: &Array<u8, sizes::U16>) -> Array<u8, sizes::U16> {
let cipher = Aes128::new(tweak_key);
let mut res: Array<u8, sizes::U16> = Array([0u8;16]);
cipher.encrypt_block(&mut res);
res
}
#[inline]
fn add_one_to_block_(block: &mut Array<u8, sizes::U16>) -> bool {
let mut carry = false;
(block[0], carry) = block[0].carrying_add(1u8, carry);
for i in 1..16 {
if carry == false {
break;
}
(block[i], carry) = block[i].carrying_add(0u8, carry);
}
carry
}
#[inline]
fn xor_arrays(
a_arr: &Array<u8, sizes::U16>,
b_arr: &Array<u8, sizes::U16>,
out_arr: &mut Array<u8, sizes::U16>,
) {
out_arr
.iter_mut()
.zip(a_arr.iter().zip(b_arr.iter()))
.for_each(|(o, (a, b))| *o = a ^ b);
}
#[inline]
fn xor_array_(a_arr: &mut Array<u8, sizes::U16>, b_arr: &Array<u8, sizes::U16>) {
a_arr
.iter_mut()
.zip(b_arr.iter())
.for_each(|(o, a)| *o ^= a);
}
// fn add_u64_to_arr_u8(arr: &Array<u8, sizes::U16>, b: u64) -> Array<u8, sizes::U16> {
// let mut res: Array<u8, sizes::U16> = Array([0u8; 16]);
// let b_bytes = b.to_le_bytes();
// let mut carry: bool = false;
// for i in 0..8 {
// (res[i], carry) = arr[i].carrying_add(b_bytes[i], carry);
// }
// for i in 8..16 {
// (res[i], carry) = arr[i].carrying_add(0u8, carry);
// }
// res
// }
fn add_u64_to_arr_u8_(arr: &mut Array<u8, sizes::U16>, b: u64) -> bool {
let b_bytes = b.to_le_bytes();
let mut carry: bool = false;
for i in 0..8 {
(arr[i], carry) = arr[i].carrying_add(b_bytes[i], carry);
}
for i in 8..16 {
(arr[i], carry) = arr[i].carrying_add(0u8, carry);
}
carry
}
pub fn encrypt_and_check(
start_key: &Array<u8, sizes::U16>,
tweak: &Array<u8, sizes::U16>,
batch_size: u64,
in_block: &Array<u8, sizes::U16>,
search_block: &Array<u8, sizes::U16>,
) -> Option<Array<u8, sizes::U16>> {
let mut current_key = start_key.clone();
let mut out_block: Array<u8, sizes::U16> = Array::from([0u8; 16]);
for _b_num in 0..batch_size {
// Initialize cipher
let cipher = Aes128::new(&current_key);
xor_arrays(in_block, tweak, &mut out_block);
// Encrypt block in-place
cipher.encrypt_block(&mut out_block);
xor_array_(&mut out_block, tweak);
if out_block.eq(search_block) {
return Some(current_key);
}
let _ = add_one_to_block_(&mut current_key);
}
return None;
}
pub fn do_work(
pool: &ThreadPool,
batch_size: u64,
start_key: &[u8; 16],
tweak_key: &[u8; 16],
data_block: &[u8; 16],
search_block: &[u8; 16],
) -> Option<Array<u8, sizes::U16>> {
let (tx, rx) = mpsc::channel();
let th_num = pool.max_count();
let mut a_start_key: Array<u8, sizes::U16> = Array::from(start_key.clone());
let a_tweak_key: Array<u8, sizes::U16> = Array::from(tweak_key.clone());
let a_data_block: Array<u8, sizes::U16> = Array::from(data_block.clone());
let a_search_block: Array<u8, sizes::U16> = Array::from(search_block.clone());
let tweak = gen_tweak_zero_block(&a_tweak_key);
for _ in 0..th_num {
let th_start_key = a_start_key.clone();
let tx = tx.clone();
pool.execute(move || {
let result = encrypt_and_check(
&th_start_key,
&tweak,
batch_size,
&a_data_block,
&a_search_block,
);
tx.send(result).unwrap();
});
add_u64_to_arr_u8_(&mut a_start_key, batch_size);
}
drop(tx); // Close the sending end
// Collect all results
let results = rx.iter()
.find(|x| x.is_some())
.unwrap_or(None);
return results;
}
+281
View File
@@ -0,0 +1,281 @@
use std::time::Duration;
use tokio;
use tonic;
use tonic::transport::Channel;
//use tonic::{Request, Response, Status};
pub mod nyash_proto {
tonic::include_proto!("nyash_proto"); // The string specified here must match the proto package name
}
use nyash_proto::nyash_luks_client::NyashLuksClient;
use nyash_proto::{
CommitReply, KeyData, ProgressReply, ProgressRequest, WorkCommit, WorkReply, WorkRequest,
work_commit, work_reply,
};
use std::sync::Arc;
use threadpool::ThreadPool;
use tokio::sync::RwLock as AsyncRwLock;
mod aes_cpu;
pub mod num_utils;
mod search_params;
//mod test_cl;
const S_ADDR: &str = "http://93.113.25.180:37939";
async fn shutdown_signal() {
let ctrl_c = async {
tokio::signal::ctrl_c()
.await
.expect("Failed to install Ctrl+C handler");
};
#[cfg(unix)]
let terminate = async {
tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())
.expect("Failed to install SIGTERM handler")
.recv()
.await;
};
#[cfg(not(unix))]
let terminate = std::future::pending::<()>();
tokio::select! {
_ = ctrl_c => println!("Received Ctrl+C, initiating shutdown"),
_ = terminate => println!("Received SIGTERM, initiating shutdown"),
}
}
// fn key_dat_from_exec_dat(ex_dat: &ExecData) -> KeyData {
// let t_k = num_utils::u128_to_u64arr(num_utils::u32arr_to_u128(num_utils::vec_to_u32_4arr(
// &ex_dat.tweak_key,
// 0,
// )));
// let e_k = num_utils::u128_to_u64arr(ex_dat.get_found_key());
// KeyData {
// start_key0: e_k[0],
// start_key1: e_k[1],
// tweak_key0: t_k[0],
// tweak_key1: t_k[1],
// }
// }
async fn get_progress(chanel: Channel) -> Result<ProgressReply, tonic::Status> {
let mut client = NyashLuksClient::new(chanel);
let request = tonic::Request::new(ProgressRequest {});
let response = client.request_progress(request).await?;
return Ok(response.into_inner());
}
async fn get_work(chanel: Channel, work_size: u64) -> Result<WorkReply, tonic::Status> {
let mut client = NyashLuksClient::new(chanel);
println!("Requesting work {} keys...", work_size);
let request = tonic::Request::new(WorkRequest {
pref_work_size: work_size,
});
let response = client.request_work(request).await?;
return Ok(response.into_inner());
}
async fn commit_work(
chanel: Channel,
commit_data: WorkCommit,
) -> Result<CommitReply, tonic::Status> {
let mut client = NyashLuksClient::new(chanel);
let request = tonic::Request::new(commit_data);
let response = client.commit_work(request).await?;
return Ok(response.into_inner());
}
fn benchmark() -> (u64, usize) {
let total_work: u64 = 1280000000;
let thread_num_list: [usize; 9] = [4, 6, 8, 10, 16, 20, 32, 64, 128];
let mut work_time = [0f64; 9];
let mut preffered_th_num: usize = thread_num_list[0];
let mut preffered_batch_size: u64 = 0;
let start_key = [1u8; 16];
let tweak_key = [2u8; 16];
let data_block = [3u8; 16];
let search_block = [4u8; 16];
for i in 0..9 {
let test_th_num = thread_num_list[i];
let pool = ThreadPool::new(test_th_num);
let batch_size: u64 = total_work / test_th_num as u64;
println!("Benchmarking thread num: {}", test_th_num);
for _j in 0..3 {
println!("Run number {}", _j);
let start_time = std::time::Instant::now();
let res = aes_cpu::do_work(
&pool,
batch_size,
&start_key,
&tweak_key,
&data_block,
&search_block,
);
if res.is_some() {
println!("Key found!")
}
let exec_duration = start_time.elapsed().as_secs_f64();
work_time[i] += exec_duration;
}
work_time[i] = work_time[i] / 3.0;
println!("Average time {}", work_time[i]);
if i > 0 {
//giving 2% error for speed mesure
if (work_time[i] * 1.02) > work_time[i - 1] {
break;
}
}
preffered_th_num = test_th_num;
// calculate batch size so it correspond to 30 sec job
preffered_batch_size = (batch_size as f64 * (10.0 / work_time[i])) as u64;
println!(
"batch_size {}, work_time {}, preffered_batch_size {}, preffered_th_num {}",
batch_size, work_time[i], preffered_batch_size, preffered_th_num
);
}
return (preffered_batch_size, preffered_th_num);
}
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Performing banchmark to determine optimal parameters...");
let (pref_batch_size, th_num) = benchmark();
println!("batch_size {}, th_num {}", pref_batch_size, th_num);
let encrypted_data = search_params::get_encrypted_data();
let unencrypt_data = [0u8; 16];
let th_pool = ThreadPool::new(th_num);
// Don't keep connection alive when idle
let nya_channel: tonic::transport::Channel = tonic::transport::Endpoint::from_static(S_ADDR)
.keep_alive_while_idle(false)
.keep_alive_timeout(Duration::from_secs(10))
.connect_timeout(Duration::from_secs(10))
.connect()
.await
.expect("Error connecting to server!");
let key_found = match get_progress(nya_channel.clone()).await {
Err(_) => {
println!("Error getting progress!");
false
}
Ok(p_r) => {
println!("Current progress {:.8}%", p_r.progress * 100.0);
p_r.key_found
}
};
let mut giga_keys_per_second: f64 = 0f64;
let req_work_size: u64 = pref_batch_size * th_num as u64;
let shared_key_found = Arc::new(AsyncRwLock::new(key_found));
// handling program termination
let sh_k_f_clone = shared_key_found.clone();
tokio::spawn(async move {
shutdown_signal().await;
//signaling that we should stop
let mut guard = sh_k_f_clone.write().await;
*guard = true;
});
while *shared_key_found.read().await == false {
let mut work = get_work(nya_channel.clone(), req_work_size).await;
while work.is_err() {
println!("Error getting work, waiting 15 seconds and trying again...");
tokio::time::sleep(Duration::from_secs(15)).await;
work = get_work(nya_channel.clone(), req_work_size).await;
}
let work = work.expect("Error getting work!");
let work_data = match work.result.expect("Error! Expected WorkResult!") {
work_reply::Result::NoWork(_) => {
println!("No work right now, try again later...");
continue;
}
work_reply::Result::Error(ex) => {
println!("Erro getting work: {}", ex);
continue;
}
work_reply::Result::WorkData(wd) => wd,
};
println!("Got work, {} keys...", work_data.work_size);
let start_key = num_utils::u64arr_to_u8arr([work_data.start_key0, work_data.start_key1]);
let tweak_key = num_utils::u64arr_to_u8arr([work_data.tweak_key0, work_data.tweak_key1]);
let mut batch_size = work_data.work_size / th_num as u64;
if (work_data.work_size % th_num as u64) != 0 {
batch_size += 1;
}
println!("Setting batch size to {}", batch_size);
println!("Crunching numbers...");
let start_time = std::time::Instant::now();
let work_res = aes_cpu::do_work(
&th_pool,
batch_size,
&start_key,
&tweak_key,
&unencrypt_data,
&encrypted_data,
);
let exec_duration = start_time.elapsed().as_secs_f64();
let g_k_p_s = (work_data.work_size as f64 / exec_duration) / 1000000000.0;
if giga_keys_per_second != 0f64 {
giga_keys_per_second = giga_keys_per_second * 0.9 + g_k_p_s * 0.1;
} else {
giga_keys_per_second = g_k_p_s;
}
println!("Average speed: {:.3}GigaKeys/Sec", giga_keys_per_second);
let work_c = match work_res {
Some(found_key) => {
println!("We found the key! {:?} {:?}", found_key, tweak_key);
//signaling that key found
let mut guard = shared_key_found.write().await;
*guard = true;
let found_key_u64 = num_utils::u8arr_to_u64arr(found_key.into());
WorkCommit {
work_id: work_data.work_id,
result: Some(work_commit::Result::FoundKey(KeyData {
tweak_key0: work_data.tweak_key0,
tweak_key1: work_data.tweak_key1,
start_key0: found_key_u64[0],
start_key1: found_key_u64[0],
})),
}
}
None => WorkCommit {
work_id: work_data.work_id,
result: Some(work_commit::Result::NoKey(true)),
},
};
let resp = commit_work(nya_channel.clone(), work_c).await;
match resp {
Ok(c_r) => println!("Work commited. Progress: {:.8}%", c_r.progress * 100.0),
Err(_) => println!("Error commiting work..."),
};
}
println!("Exiting!");
Ok(())
}
+356
View File
@@ -0,0 +1,356 @@
// union U64orU32 {
// l: u64,
// i: [u32; 2],
// }
pub fn vec_to_u32_4arr(in_v: &Vec<u32>, start_idx: usize) -> [u32; 4] {
let mut u32_arr_k = [0u32; 4];
for i in 0..4 {
u32_arr_k[0] = in_v[start_idx + i];
}
return u32_arr_k;
}
pub fn u128_to_u64arr(a: u128) -> [u64; 2] {
let mut res = [0u64; 2];
let a_bytes = a.to_le_bytes();
let chunks = a_bytes.as_chunks::<8>().0;
for i in 0..2 {
res[i] = u64::from_le_bytes(chunks[i]);
}
return res;
}
pub fn u64arr_to_u128(a: [u64; 2]) -> u128 {
let mut bytes_data: [u8; 16] = [0u8; 16];
bytes_data[0..8].copy_from_slice(a[0].to_le_bytes().as_slice());
bytes_data[8..].copy_from_slice(a[1].to_le_bytes().as_slice());
return u128::from_le_bytes(bytes_data);
}
pub fn u64arr_to_u8arr(a: [u64; 2]) -> [u8; 16] {
let mut bytes_data: [u8; 16] = [0u8; 16];
bytes_data[0..8].copy_from_slice(a[0].to_le_bytes().as_slice());
bytes_data[8..].copy_from_slice(a[1].to_le_bytes().as_slice());
return bytes_data;
}
pub fn u8arr_to_u64arr(a_bytes: [u8; 16]) -> [u64; 2] {
let mut res = [0u64; 2];
let chunks = a_bytes.as_chunks::<8>().0;
for i in 0..2 {
res[i] = u64::from_le_bytes(chunks[i]);
}
return res;
}
pub fn u128_to_u32arr(a: u128) -> [u32; 4] {
let mut res = [0u32; 4];
let a_bytes = a.to_le_bytes();
let chunks = a_bytes.as_chunks::<4>().0;
for i in 0..4 {
res[i] = u32::from_le_bytes(chunks[i]);
}
return res;
}
pub fn u32arr_to_u128(a: [u32; 4]) -> u128 {
let mut bytes_data: [u8; 16] = [0u8; 16];
bytes_data[0..4].copy_from_slice(a[0].to_le_bytes().as_slice());
bytes_data[4..8].copy_from_slice(a[1].to_le_bytes().as_slice());
bytes_data[8..12].copy_from_slice(a[2].to_le_bytes().as_slice());
bytes_data[12..16].copy_from_slice(a[3].to_le_bytes().as_slice());
return u128::from_le_bytes(bytes_data);
}
// fn add_u32_to_u256(a: &[u32; 8], b: u32) -> ([u32; 8], bool) {
// let mut res: [u32; 8] = [0; 8];
// let mut carry = false;
// (res[0], carry) = a[0].carrying_add(b, carry);
// for idx in 1..8 {
// (res[idx], carry) = a[idx].carrying_add(0, carry);
// }
// return (res, carry);
// }
// fn add_u32_to_u256_(a: &mut [u32; 8], b: u32) -> bool {
// let mut carry = false;
// (a[0], carry) = a[0].carrying_add(b, carry);
// for idx in 1..8 {
// (a[idx], carry) = a[idx].carrying_add(0, carry);
// }
// return carry;
// }
// fn bytes_from_chars(chars_chunk: &[char]) -> [u8; 4] {
// let mut res: [u8; 4] = [0; 4];
// let mut idx: usize = 0;
// chars_chunk.chunks_exact(2).for_each(|b_c| {
// if idx < 4 {
// match u8::from_str_radix(&b_c.iter().collect::<String>(), 16) {
// Ok(n) => res[idx] = n,
// Err(_) => (),
// }
// idx += 1;
// }
// });
// return res;
// }
// fn bignum_from_hex(hex: &str) -> [u32; 8] {
// let mut res: [u32; 8] = [0; 8];
// let mut idx: usize = 0;
// let chars_hex = hex.chars().collect::<Vec<char>>();
// chars_hex
// .chunks_exact(8)
// .rev()
// .map(|chunk| bytes_from_chars(chunk))
// .for_each(|b_arr| {
// if idx < 8 {
// res[idx] = u32::from_be_bytes(b_arr);
// idx += 1;
// }
// });
// return res;
// }
// fn hex_fmt_byte(n: u32) -> String {
// let res: String = n
// .to_be_bytes()
// .iter()
// .map(|b| format!("{:02x}", b))
// .collect();
// return res;
// }
// fn bignum_to_hex(a: &[u32; 8]) -> String {
// let res: String = a
// .iter()
// .rev()
// .map(|n| hex_fmt_byte(*n))
// .collect::<Vec<String>>()
// .join("");
// return res;
// }
// #[cfg(test)]
// mod num_utils_tests {
// use std::io::Read;
// use super::*;
// #[test]
// fn test_add() {
// use std::io::{BufRead, BufReader};
// use std::process::{Command, Stdio};
// let test_gen_cmd = "/home/kira/Development/Rust/nyash-aes-xts256-plain64/nyash_client/src/tests/gen_test_data.py";
// let mut child = Command::new(test_gen_cmd)
// .stdout(Stdio::piped())
// .spawn()
// .unwrap();
// let gen_stdout = child
// .stdout
// .take()
// .ok_or("Failed to capture stdout")
// .unwrap();
// let gen_reader = BufReader::new(gen_stdout);
// for r_line in gen_reader.lines() {
// let test_line: String = r_line.unwrap(); // Handle any I/O errors
// let test_data_line = test_line.split(' ').collect::<Vec<&str>>();
// let num_to_add = u32::from_str_radix(test_data_line[0], 10).unwrap();
// let t0 = bignum_from_hex(test_data_line[1]);
// let t1_test = add_u32_to_u256(&t0, 1).0;
// let t2_test = add_u32_to_u256(&t0, num_to_add).0;
// let res_actual = format!(
// "{} {} {} {}",
// num_to_add,
// bignum_to_hex(&t0),
// bignum_to_hex(&t1_test),
// bignum_to_hex(&t2_test)
// );
// assert_eq!(test_line, res_actual);
// }
// let _ = child.wait().unwrap();
// }
// #[test]
// fn test_cl_add() {
// extern crate ocl;
// use ocl::{Buffer, Context, Device, Kernel, Platform, Program, Queue, flags};
// use std::fs::File;
// use std::io::{BufRead, BufReader};
// use std::process::{Command, Stdio};
// let cl_test_path = "/home/kira/Development/Rust/nyash-aes-xts256-plain64/nyash_client/src/open_cl/test_num_utils.cl";
// let cl_include_opt =
// "-I /home/kira/Development/Rust/nyash-aes-xts256-plain64/nyash_client/src/open_cl";
// let mut cl_src = String::new();
// // read ocl source
// BufReader::new(File::open(cl_test_path).unwrap())
// .read_to_string(&mut cl_src)
// .expect("Error reading cl_src!");
// const G_WORK_SIZE: usize = 4096;
// let cl_platform = Platform::default();
// let cl_device = Device::first(cl_platform).unwrap();
// let cl_context = Context::builder()
// .platform(cl_platform)
// .devices(cl_device.clone())
// .build()
// .unwrap();
// let cl_program = Program::builder()
// .devices(cl_device)
// .src(cl_src)
// .cmplr_opt(cl_include_opt)
// .build(&cl_context)
// .unwrap();
// let cl_queue = Queue::new(&cl_context, cl_device, None).unwrap();
// let cl_buffer_num = Buffer::<u32>::builder()
// .queue(cl_queue.clone())
// .flags(flags::MEM_READ_ONLY)
// .len(G_WORK_SIZE)
// .fill_val(0u32)
// .build()
// .unwrap();
// let cl_buffer_t0 = Buffer::<u32>::builder()
// .queue(cl_queue.clone())
// .flags(flags::MEM_READ_ONLY)
// .len(G_WORK_SIZE * 8)
// .fill_val(0u32)
// .build()
// .unwrap();
// let cl_buffer_t1 = Buffer::<u32>::builder()
// .queue(cl_queue.clone())
// .flags(flags::MEM_WRITE_ONLY)
// .len(G_WORK_SIZE * 8)
// .fill_val(0u32)
// .build()
// .unwrap();
// let cl_buffer_t2 = Buffer::<u32>::builder()
// .queue(cl_queue.clone())
// .flags(flags::MEM_WRITE_ONLY)
// .len(G_WORK_SIZE * 8)
// .fill_val(0u32)
// .build()
// .unwrap();
// // (3) Create a kernel with arguments matching those in the source above:
// let kernel = Kernel::builder()
// .program(&cl_program)
// .name("test_add")
// .queue(cl_queue.clone())
// .global_work_size(G_WORK_SIZE)
// .arg(&cl_buffer_num)
// .arg(&cl_buffer_t0)
// .arg(&cl_buffer_t1)
// .arg(&cl_buffer_t2)
// .build()
// .unwrap();
// let test_gen_cmd = "/home/kira/Development/Rust/nyash-aes-xts256-plain64/nyash_client/src/tests/gen_test_data.py";
// let mut child = Command::new(test_gen_cmd)
// .stdout(Stdio::piped())
// .spawn()
// .unwrap();
// let gen_stdout = child
// .stdout
// .take()
// .ok_or("Failed to capture stdout")
// .unwrap();
// let gen_reader = BufReader::new(gen_stdout);
// let mut buffer_num: Vec<u32> = vec![0u32; G_WORK_SIZE];
// let mut buffer_t0: Vec<u32> = vec![0u32; G_WORK_SIZE * 8];
// let mut exp_buffer_t1: Vec<u32> = vec![0u32; G_WORK_SIZE * 8];
// let mut exp_buffer_t2: Vec<u32> = vec![0u32; G_WORK_SIZE * 8];
// let mut act_buffer_t1: Vec<u32> = vec![0u32; G_WORK_SIZE * 8];
// let mut act_buffer_t2: Vec<u32> = vec![0u32; G_WORK_SIZE * 8];
// let mut w_id: usize = 0;
// for r_line in gen_reader.lines() {
// let test_line: String = r_line.unwrap(); // Handle any I/O errors
// let test_data_line = test_line.split(' ').collect::<Vec<&str>>();
// let num_to_add = u32::from_str_radix(test_data_line[0], 10).unwrap();
// buffer_num[w_id] = num_to_add;
// let slise_id = w_id * 8;
// buffer_t0[slise_id..slise_id + 8].copy_from_slice(&bignum_from_hex(test_data_line[1]));
// exp_buffer_t1[slise_id..slise_id + 8]
// .copy_from_slice(&bignum_from_hex(test_data_line[2]));
// exp_buffer_t2[slise_id..slise_id + 8]
// .copy_from_slice(&bignum_from_hex(test_data_line[3]));
// w_id += 1;
// if w_id >= G_WORK_SIZE {
// w_id = 0; // reset counter
// cl_buffer_num
// .cmd()
// .queue(&cl_queue)
// .offset(0)
// .write(&buffer_num)
// .enq()
// .unwrap();
// cl_buffer_t0
// .cmd()
// .queue(&cl_queue)
// .offset(0)
// .write(&buffer_t0)
// .enq()
// .unwrap();
// // (4) Run the kernel
// unsafe {
// kernel
// .cmd()
// .queue(&cl_queue)
// .global_work_size(G_WORK_SIZE)
// .enq()
// .unwrap();
// }
// cl_buffer_t1
// .cmd()
// .queue(&cl_queue)
// .offset(0)
// .read(&mut act_buffer_t1)
// .enq()
// .unwrap();
// cl_buffer_t2
// .cmd()
// .queue(&cl_queue)
// .offset(0)
// .read(&mut act_buffer_t2)
// .enq()
// .unwrap();
// assert_eq!(exp_buffer_t1, act_buffer_t1);
// assert_eq!(exp_buffer_t2, act_buffer_t2);
// }
// }
// let _ = child.wait().unwrap();
// }
// }
+399
View File
@@ -0,0 +1,399 @@
extern crate ocl;
use ocl::{
Buffer, Context, Device, DeviceType, Kernel, Platform, Program, Queue, SpatialDims, flags,
};
use serde::de::value::Error;
use std::{
io,
str::{self, FromStr},
};
use crate::client_config::{AppConfig, DevConf};
mod client_config;
mod num_utils;
fn dev_type_from_str(s: &str) -> Result<flags::DeviceType, ()> {
match s {
"CPU" => Ok(flags::DeviceType::CPU),
"GPU" => Ok(flags::DeviceType::GPU),
"ALL" => Ok(flags::DeviceType::ALL),
"CUSTOM" => Ok(flags::DeviceType::CUSTOM),
"ACCELERATOR" => Ok(flags::DeviceType::ACCELERATOR),
"DEFAULT" => Ok(flags::DeviceType::DEFAULT),
_ => Err(()),
}
}
fn str_or_empty(r: ocl::error::Result<String>) -> String {
match r {
Ok(s) => s,
Err(_) => "".to_string(),
}
}
fn print_devices(dev_list: &Vec<(Device, Platform)>) {
let mut i = 0;
for (dev, plt) in dev_list.iter() {
let dev_name = str_or_empty(dev.name());
let plt_name = str_or_empty(plt.name());
println!("({i}) device: \"{dev_name}\" ----- platorm: \"{plt_name}\"");
i += 1;
}
}
fn choose_devices(devices_num: usize) -> Result<Vec<usize>, String> {
println!("Please input desired devices to use as a white space separated list of numbers.");
let mut result: Vec<usize> = Vec::new();
let mut s_devs_nums = String::new();
io::stdin()
.read_line(&mut s_devs_nums)
.expect("Failed to read line");
for s_dev_num in s_devs_nums.split(' ') {
let dev_num: usize = match s_dev_num.trim().parse() {
Ok(num) => num,
Err(_) => return Err("You must input a number from device list.".to_string()),
};
if dev_num >= devices_num {
return Err("You must input a number from device list.".to_string());
};
result.push(dev_num);
}
return Ok(result);
}
fn list_devices(dev_type: DeviceType) -> Vec<(Device, Platform)> {
let platforms = Platform::list();
let mut devices: Vec<(Device, Platform)> = Vec::new();
for plt in platforms.iter() {
//let plat_name = str_or_empty(plt.name());
let list_res = Device::list(plt, Some(dev_type));
match list_res {
Ok(dev_l) => devices.extend(dev_l.iter().map(|dev| (*dev, plt.clone()))),
Err(_) => {}
}
}
return devices;
}
// fn init_devices(
// devices: Vec<(Device, Platform, DevConfig)>,
// kern_name: String,
// prog_src: String,
// inc_dirs: Vec<String>,
// ) -> Vec<ExecContext> {
// let mut contexts: Vec<ExecContext> = Vec::with_capacity(devices.len());
// for (dev, plt, dev_cfg) in devices {
// let ctx = match Context::builder()
// .platform(plt)
// .devices(dev.clone())
// .build()
// {
// Ok(c) => c,
// Err(_) => continue,
// };
// let prg = match Program::builder().devices(dev).src(&prog_src).build(&ctx) {
// Ok(p) => p,
// Err(_) => continue,
// };
// let queue = match Queue::new(&ctx, dev, None) {
// Ok(q) => q,
// Err(_) => continue,
// };
// // Create Buffers:
// let start_key_b = match Buffer::<u32>::builder()
// .queue(queue.clone())
// .flags(flags::MEM_READ_ONLY)
// .len(8)
// .fill_val(0u32)
// .build()
// {
// Ok(buf) => buf,
// Err(_) => continue,
// };
// let u_data_b = match Buffer::<u32>::builder()
// .queue(queue.clone())
// .flags(flags::MEM_READ_ONLY)
// .len(4)
// .fill_val(0u32)
// .build()
// {
// Ok(buf) => buf,
// Err(_) => continue,
// };
// let enc_data_b = match Buffer::<u32>::builder()
// .queue(queue.clone())
// .flags(flags::MEM_READ_ONLY)
// .len(4)
// .fill_val(0u32)
// .build()
// {
// Ok(buf) => buf,
// Err(_) => continue,
// };
// let key_found_b = match Buffer::<u32>::builder()
// .queue(queue.clone())
// .flags(flags::MEM_WRITE_ONLY)
// .len(1)
// .fill_val(0u32)
// .build()
// {
// Ok(buf) => buf,
// Err(_) => continue,
// };
// // (3) Create a kernel with arguments matching those in the source above:
// let kernel = match Kernel::builder()
// .program(&prg)
// .name(&kern_name)
// .queue(queue.clone())
// .global_work_size(dev_cfg.global_work_size)
// .arg(&start_key_b)
// .arg(&u_data_b)
// .arg(&enc_data_b)
// .arg(&key_found_b)
// .build()
// {
// Ok(kern) => kern,
// Err(_) => continue,
// };
// contexts.push(ExecContext {
// cfg: dev_cfg,
// ctx: ctx,
// kernel: kernel,
// prog: prg,
// queue: queue,
// buffers: CtxBuffers {
// start_key: start_key_b,
// u_data: u_data_b,
// enc_data: enc_data_b,
// key_found: key_found_b,
// },
// });
// }
// return contexts;
// }
fn dev_sel_dialog(all_devices: &Vec<(Device, Platform)>) -> Vec<usize> {
let devs_nums = loop {
print_devices(&all_devices);
match choose_devices(all_devices.len()) {
Ok(value) => break value,
Err(exc) => {
println!("Error! {exc}\n")
}
}
};
return devs_nums;
}
fn get_devices_conf(file_name: &str) -> Result<(Vec<(Device, Platform)>, AppConfig), String> {
let dev_type = dev_type_from_str("GPU").expect("Unexpected device type!");
// Get devices to be used for key search
let all_devices: Vec<(Device, Platform)> = list_devices(dev_type);
if all_devices.len() == 0 {
return Err("Cannot find any usable devices.".to_string());
};
let app_conf = match client_config::load_config(file_name) {
Ok(readed_config) => {
let dev_found = all_devices
.iter()
.filter(|dp| readed_config.device_exist(&dp.0))
.count();
if dev_found < readed_config.devices.len() {
println!("Devices from config not found in the system!");
let devs_nums = dev_sel_dialog(&all_devices);
let res = AppConfig::from_dev_list(&all_devices, devs_nums);
client_config::save_config(file_name, &res);
res
} else {
readed_config
}
}
Err(_) => {
println!("Cannot find config file {}", file_name);
let devs_nums = dev_sel_dialog(&all_devices);
AppConfig::from_dev_list(&all_devices, devs_nums)
}
};
let selected_devs = all_devices
.iter()
.filter(|dp| app_conf.device_exist(&dp.0))
.cloned()
.collect();
return Ok((selected_devs, app_conf));
}
struct CtxBuffers {
batch_size: u32,
tweak_i: u64,
tweak_j: u32,
start_key: Buffer<u32>,
uenc_data: Buffer<u32>,
target_data: Buffer<u32>,
key_found: Buffer<u32>,
}
struct ExecData {
start_key: Vec<u32>,
uenc_data: Vec<u32>,
target_data: Vec<u32>,
key_found: Vec<u32>,
batch_size: u32,
work_size: usize,
}
struct ExecContext {
ctx: Context,
kernel: Kernel,
prog: Program,
queue: Queue,
buffers: CtxBuffers,
exec_data: ExecData,
}
fn init_program(
cl_device: Device,
cl_platform: Platform,
cl_src: &str,
cl_cmplr_opt: &str,
) -> Result<(Context, Program, Queue), ocl::Error> {
let cl_context = Context::builder()
.platform(cl_platform)
.devices(cl_device.clone())
.build()?;
let cl_program = Program::builder()
.devices(cl_device)
.src(cl_src)
.cmplr_opt(cl_cmplr_opt)
.build(&cl_context)
.unwrap();
let cl_queue: Queue = Queue::new(&cl_context, cl_device, None)?;
return Ok((cl_context, cl_program, cl_queue));
}
fn init_buffers(cl_queue: Queue) -> Result<CtxBuffers, ocl::Error> {
let cl_buffer_start_key = Buffer::<u32>::builder()
.queue(cl_queue.clone())
.flags(flags::MEM_READ_ONLY)
.len(8)
.fill_val(0u32)
.build()?;
let cl_buffer_uenc_data = Buffer::<u32>::builder()
.queue(cl_queue.clone())
.flags(flags::MEM_READ_ONLY)
.len(4)
.fill_val(0u32)
.build()?;
let cl_buffer_target_data = Buffer::<u32>::builder()
.queue(cl_queue.clone())
.flags(flags::MEM_READ_ONLY)
.len(4)
.fill_val(0u32)
.build()?;
let cl_buffer_key_found = Buffer::<u32>::builder()
.queue(cl_queue.clone())
.flags(flags::MEM_WRITE_ONLY)
.len(9)
.fill_val(0u32)
.build()?;
Ok(CtxBuffers {
batch_size: 0,
tweak_i: 0,
tweak_j: 0,
start_key: cl_buffer_start_key,
uenc_data: cl_buffer_uenc_data,
target_data: cl_buffer_target_data,
key_found: cl_buffer_key_found,
})
}
fn init_kernel(
work_size: usize,
cl_program: Program,
cl_queue: Queue,
buffs: &CtxBuffers,
) -> Result<Kernel, ocl::Error> {
Kernel::builder()
.program(&cl_program)
.name("search_key")
.queue(cl_queue.clone())
.global_work_size(work_size)
.arg(&buffs.batch_size)
.arg(&buffs.tweak_i)
.arg(&buffs.tweak_j)
.arg(&buffs.start_key)
.arg(&buffs.uenc_data)
.arg(&buffs.target_data)
.arg(&buffs.key_found)
.build()
}
fn do_work(ex_ctx: &mut ExecContext) -> Result<bool, ocl::Error> {
ex_ctx.buffers.batch_size = ex_ctx.exec_data.batch_size;
ex_ctx
.buffers
.start_key
.cmd()
.queue(&ex_ctx.queue)
.offset(0)
.write(&ex_ctx.exec_data.start_key)
.enq()?;
// (4) Run the kernel
unsafe {
ex_ctx
.kernel
.cmd()
.queue(&ex_ctx.queue)
.global_work_size(ex_ctx.exec_data.work_size)
.enq()?;
}
ex_ctx
.buffers
.key_found
.cmd()
.queue(&ex_ctx.queue)
.offset(0)
.read(&mut ex_ctx.exec_data.key_found)
.enq()?;
if ex_ctx.exec_data.key_found[0] == 0{Ok(false)}
else {Ok(true)}
}
fn main() {
println!("Hello, world nya!");
//use ocl::{Buffer, Context, Device, Kernel, Platform, Program, Queue, flags};
let devices = get_devices_conf("test.json");
println!("{:?}", devices);
// let devices: Vec<_> = platforms.iter().flat_map(|p| Device::list(p, Some(dev_type)).iter()).collect();
// let device = Device::first(platform)?;
// let context = Context::builder()
// .platform(platform)
// .devices(device.clone())
// .build()?;
}
+8
View File
@@ -0,0 +1,8 @@
pub fn get_encrypted_data() -> [u8; 16] {
let enc_data: [u8; 16] = [
10, 51, 110, 227, 194, 181, 104, 65, 151, 47, 69, 37, 66, 223, 71, 137,
];
return enc_data;
}
+79
View File
@@ -0,0 +1,79 @@
#[cfg(test)]
mod test_cl {
#[test]
fn test_encryption() {
use ocl::{Device, Platform};
use crate::ocl_utils;
use crate::num_utils;
const SRC_PATH: &str = "src/open_cl/nyash_aes_xts256_plain.cl";
const OCL_COMP_OPT: &str = "-I src/open_cl";
const ENCRYPTED_DATA: [u8; 16] = [
198, 255, 55, 185, 15, 226, 223, 174, 119, 8, 36, 239, 242, 89, 126, 230
];
const KEY_DATA: [u8; 32] = [
206, 193, 83, 54, 46, 234, 185, 41, 146, 244, 130, 6, 212, 68, 106, 162, 165, 97, 188,
218, 39, 111, 141, 236, 67, 159, 157, 157, 166, 79, 89, 134
];
// let key_bytes_reversed: Vec<u8> = KEY_DATA.iter().rev().map(|e| *e).collect();
// let data_bytes_reversed: Vec<u8> = ENCRYPTED_DATA.iter().rev().map(|e| *e).collect();
let mut tweak_key_b: [u8;16] = [0u8;16];
let mut data_key_b: [u8;16] = [0u8;16];
data_key_b.copy_from_slice(&KEY_DATA[0..16]);
tweak_key_b.copy_from_slice(&KEY_DATA[16..32]);
// getting keys
let data_key = u128::from_le_bytes(data_key_b);
let tweak_key = u128::from_le_bytes(tweak_key_b);
let data_key = num_utils::u128_to_u32arr(data_key);
let tweak_key = num_utils::u128_to_u32arr(tweak_key);
// converting bytes raw data to u32 arr
let mut encrypted_data: [u32; 4] = [0u32; 4];
let (enc_dat_bytes_chunks, _) = ENCRYPTED_DATA.as_chunks::<4>();
for i in 0..4 {
encrypted_data[i] = u32::from_le_bytes(enc_dat_bytes_chunks[i]);
}
// init devices
let platform = Platform::first().expect("Error getting platform!");
let device = Device::first(platform).expect("Error getting device!");
println!("Platform: {:?}, Device: {:?}", platform.name().unwrap(), device.name().unwrap());
// reading ocl program sources
let prog_src = std::fs::read_to_string(SRC_PATH).expect("Error reading program sources!");
let mut nyan_context =
ocl_utils::ExecContext::new(device, platform, prog_src.as_str(), OCL_COMP_OPT, 256)
.expect("Error creating execution nyan context!");
//setting data
let mut nyan_exec_dat = ocl_utils::ExecData {
start_key: data_key.to_vec(),
tweak_key: tweak_key.to_vec(),
uenc_data: vec![0u32;4],
target_data: encrypted_data.to_vec(),
tweak_i: 0,
tweak_j: 0,
key_found: vec![0u32;5],
batch_size: 1000000,
work_size: 256,
};
println!("Set target data");
ocl_utils::set_target_data(&mut nyan_context, &mut nyan_exec_dat).expect("Error set target data!");
let found_flag = ocl_utils::do_work(&mut nyan_context, &mut nyan_exec_dat).expect("Error do work!");
println!("Found?: {}", found_flag);
println!("Key found: {:?}", nyan_exec_dat.key_found);
assert_eq!(true, found_flag);
}
}
@@ -0,0 +1,16 @@
#!/bin/bash
truncate -s 255M test_btrfs.img
dd if=/dev/urandom of=master.key bs=32 count=1
cryptsetup luksFormat --type=luks2 --sector-size 512 --pbkdf=pbkdf2 --pbkdf-force-iterations=1000 --hash=sha256 --key-size=256 --cipher=aes-xts-plain64 --master-key-file ./test_master.key ./test.img
cryptsetup luksFormat --type=luks2 --pbkdf=pbkdf2 --pbkdf-force-iterations=1000 --hash=sha256 --key-size=256 --cipher=aes-xts-plain64 ./luks-container.img
sudo cryptsetup luksOpen ./test.img luks-container-crypt
sudo mkfs.btrfs /dev/mapper/luks-container-crypt
sudo dd if=/dev/mapper/luks-container-crypt of=./test_btrfs_luks_unencrypt.img bs=1M count=255
sudo cryptsetup close luks-container-crypt
@@ -0,0 +1,42 @@
from utils import read_metadata
# Init logger
LUKS_FILE_NAME = "vg1-volume_1.img"
KEY_FILE_NAME = "master.key"
def main():
metadat = read_metadata(LUKS_FILE_NAME)
print(f"metadata:\n{metadat}")
segments_offset_bytes = int(metadat["segments"]["0"]["offset"])
superblock_start_bytes = 0x00010000
superblock_start_sector = superblock_start_bytes//512
magic_offset = 0x40
superblock_lenght_bytes = 0x1000
sector_size = 512
with open(LUKS_FILE_NAME, 'rb') as luks_file:
luks_file.seek(segments_offset_bytes)
enc_data = luks_file.read(16)
print("ENC DATA:")
print("[" + ",".join([format(a, 'd') for a in enc_data])+"]")
#
# print()
# print("KEY DATA:")
# with open(KEY_FILE_NAME, 'rb') as key_file:
# key_data = key_file.read(32)
# print("[" + ",".join([format(a, 'd') for a in key_data])+"]")
if __name__ == '__main__':
main()
+25
View File
@@ -0,0 +1,25 @@
import subprocess
import json
def read_metadata(file_name: str) -> dict:
#cryptsetup luksDump --dump-json-metadata /dev/loop0
luks_cmd: list[str] = ["cryptsetup", "luksDump", "--dump-json-metadata", file_name]
result = subprocess.run(luks_cmd, capture_output=True, encoding="UTF-8")
if result.returncode == 0 and result.stdout is not None:
metadata = json.loads(result.stdout)
return metadata
else:
raise Exception(f"Error executing 'cryptsetup' binary! {result.stderr}")
def read_encrypted_key(f_name: str, metadata: dict, keyslot: int) -> bytes:
stripes = metadata["keyslots"][str(keyslot)]["af"]["stripes"]
offset = int(metadata["keyslots"][str(keyslot)]["area"]["offset"])
# size = int(metadata["keyslots"][str(keyslot)]["area"]["size"])
key_size = metadata["keyslots"][str(keyslot)]["area"]["key_size"]
with open(f_name, 'rb') as luks_file:
luks_file.seek(offset)
data = luks_file.read(key_size*stripes)
return data
+47
View File
@@ -0,0 +1,47 @@
#[cfg(test)]
mod cl_num_utils_tests {
use super::*;
#[test]
fn test_add() {
use std::io::{BufRead, BufReader};
use std::process::{Command, Stdio};
let test_gen_cmd = "/home/kira/Development/Rust/nyash-aes-xts256-plain64/nyash_client/src/tests/gen_test_data.py";
let mut child = Command::new(test_gen_cmd)
.stdout(Stdio::piped())
.spawn()
.unwrap();
let gen_stdout = child
.stdout
.take()
.ok_or("Failed to capture stdout")
.unwrap();
let gen_reader = BufReader::new(gen_stdout);
for r_line in gen_reader.lines() {
let test_line: String = r_line.unwrap(); // Handle any I/O errors
let test_data_line = test_line.split(' ').collect::<Vec<&str>>();
let num_to_add = u32::from_str_radix(test_data_line[0], 10).unwrap();
let t0 = bignum_from_hex(test_data_line[1]);
let t1_test = add_u32_to_u256(&t0, 1).0;
let t2_test = add_u32_to_u256(&t0, num_to_add).0;
let res_actual = format!(
"{} {} {} {}",
num_to_add,
bignum_to_hex(&t0),
bignum_to_hex(&t1_test),
bignum_to_hex(&t2_test)
);
assert_eq!(test_line, res_actual);
}
let _ = child.wait().unwrap();
}
}
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/python
import random
def main(iters: int):
for i in range(iters):
rand_u32 = random.randint(1,0xffffffff)
t0 = int.from_bytes(random.randbytes(32))
t1 = t0 + 1
t2 = t0 + rand_u32
print(f"{rand_u32} {t0.to_bytes(32).hex()} {t1.to_bytes(32).hex()} {t2.to_bytes(32).hex()}")
if __name__ == '__main__':
main(1000000)
+272 -164
View File
@@ -13,9 +13,9 @@ dependencies = [
[[package]]
name = "anstream"
version = "0.6.21"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a"
checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
dependencies = [
"anstyle",
"anstyle-parse",
@@ -28,15 +28,15 @@ dependencies = [
[[package]]
name = "anstyle"
version = "1.0.13"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
[[package]]
name = "anstyle-parse"
version = "0.2.7"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
dependencies = [
"utf8parse",
]
@@ -47,7 +47,7 @@ version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys 0.61.2",
"windows-sys",
]
[[package]]
@@ -58,7 +58,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys 0.61.2",
"windows-sys",
]
[[package]]
@@ -162,9 +162,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "clap"
version = "4.5.58"
version = "4.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63be97961acde393029492ce0be7a1af7e323e6bae9511ebfac33751be5e6806"
checksum = "b193af5b67834b676abd72466a96c1024e6a6ad978a1f484bd90b85c94041351"
dependencies = [
"clap_builder",
"clap_derive",
@@ -172,9 +172,9 @@ dependencies = [
[[package]]
name = "clap_builder"
version = "4.5.58"
version = "4.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f13174bda5dfd69d7e947827e5af4b0f2f94a4a3ee92912fba07a66150f21e2"
checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f"
dependencies = [
"anstream",
"anstyle",
@@ -184,9 +184,9 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "4.5.55"
version = "4.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5"
checksum = "1110bd8a634a1ab8cb04345d8d878267d57c3cf1b38d91b71af6686408bbca6a"
dependencies = [
"heck",
"proc-macro2",
@@ -196,15 +196,15 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "1.0.0"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831"
checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
[[package]]
name = "colorchoice"
version = "1.0.4"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
[[package]]
name = "cpufeatures"
@@ -260,14 +260,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.61.2",
"windows-sys",
]
[[package]]
name = "fastrand"
version = "2.3.0"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
checksum = "a043dc74da1e37d6afe657061213aa6f425f855399a11d3463c6ecccc4dfda1f"
[[package]]
name = "fixedbitset"
@@ -393,10 +393,23 @@ checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
"cfg-if",
"libc",
"r-efi",
"r-efi 5.3.0",
"wasip2",
]
[[package]]
name = "getrandom"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555"
dependencies = [
"cfg-if",
"libc",
"r-efi 6.0.0",
"wasip2",
"wasip3",
]
[[package]]
name = "h2"
version = "0.4.13"
@@ -484,9 +497,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]]
name = "hyper"
version = "1.8.1"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11"
checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca"
dependencies = [
"atomic-waker",
"bytes",
@@ -499,7 +512,6 @@ dependencies = [
"httpdate",
"itoa",
"pin-project-lite",
"pin-utils",
"smallvec",
"tokio",
"want",
@@ -539,13 +551,21 @@ dependencies = [
]
[[package]]
name = "indexmap"
version = "2.13.0"
name = "id-arena"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
[[package]]
name = "indexmap"
version = "2.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45a8a2b9cb3e0b0c1803dbb0758ffac5de2f425b23c28f518faabd9d805342ff"
dependencies = [
"equivalent",
"hashbrown 0.16.1",
"serde",
"serde_core",
]
[[package]]
@@ -565,21 +585,27 @@ dependencies = [
[[package]]
name = "itoa"
version = "1.0.17"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
[[package]]
name = "leb128fmt"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
[[package]]
name = "libc"
version = "0.2.180"
version = "0.2.184"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc"
checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af"
[[package]]
name = "linux-raw-sys"
version = "0.11.0"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
[[package]]
name = "log"
@@ -607,13 +633,13 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "mio"
version = "1.1.1"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc"
checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1"
dependencies = [
"libc",
"wasi",
"windows-sys 0.61.2",
"windows-sys",
]
[[package]]
@@ -643,9 +669,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.21.3"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "once_cell_polyfill"
@@ -692,15 +718,9 @@ dependencies = [
[[package]]
name = "pin-project-lite"
version = "0.2.16"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
[[package]]
name = "ppv-lite86"
@@ -785,9 +805,9 @@ dependencies = [
[[package]]
name = "pulldown-cmark"
version = "0.13.1"
version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83c41efbf8f90ac44de7f3a868f0867851d261b56291732d0cbf7cceaaeb55a6"
checksum = "7c3a14896dfa883796f1cb410461aef38810ea05f2b2c33c5aded3649095fdad"
dependencies = [
"bitflags",
"memchr",
@@ -805,9 +825,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.43"
version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a"
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
dependencies = [
"proc-macro2",
]
@@ -818,6 +838,12 @@ version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]]
name = "r-efi"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
[[package]]
name = "rand"
version = "0.9.2"
@@ -844,14 +870,14 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
dependencies = [
"getrandom",
"getrandom 0.3.4",
]
[[package]]
name = "redb"
version = "3.1.0"
version = "3.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae323eb086579a3769daa2c753bb96deb95993c534711e0dbe881b5192906a06"
checksum = "4ba239c1c1693315d3cc0e601db3b3965543afbf48c41730fdca2f069f510f4a"
dependencies = [
"libc",
]
@@ -887,17 +913,23 @@ checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
[[package]]
name = "rustix"
version = "1.1.3"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34"
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.61.2",
"windows-sys",
]
[[package]]
name = "semver"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
[[package]]
name = "serde"
version = "1.0.228"
@@ -929,10 +961,23 @@ dependencies = [
]
[[package]]
name = "serde_spanned"
version = "1.0.4"
name = "serde_json"
version = "1.0.149"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8bbf91e5a4d6315eee45e704372590b30e260ee83af6639d64557f51b067776"
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
dependencies = [
"itoa",
"memchr",
"serde",
"serde_core",
"zmij",
]
[[package]]
name = "serde_spanned"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26"
dependencies = [
"serde_core",
]
@@ -972,12 +1017,12 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "socket2"
version = "0.6.2"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0"
checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e"
dependencies = [
"libc",
"windows-sys 0.60.2",
"windows-sys",
]
[[package]]
@@ -988,9 +1033,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.114"
version = "2.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a"
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
dependencies = [
"proc-macro2",
"quote",
@@ -1005,15 +1050,15 @@ checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
[[package]]
name = "tempfile"
version = "3.25.0"
version = "3.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0136791f7c95b1f6dd99f9cc786b91bb81c3800b639b3478e561ddb7be95e5f1"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
"getrandom",
"getrandom 0.4.2",
"once_cell",
"rustix",
"windows-sys 0.61.2",
"windows-sys",
]
[[package]]
@@ -1038,9 +1083,9 @@ dependencies = [
[[package]]
name = "tokio"
version = "1.49.0"
version = "1.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86"
checksum = "2bd1c4c0fc4a7ab90fc15ef6daaa3ec3b893f004f915f2392557ed23237820cd"
dependencies = [
"bytes",
"libc",
@@ -1049,14 +1094,14 @@ dependencies = [
"signal-hook-registry",
"socket2",
"tokio-macros",
"windows-sys 0.61.2",
"windows-sys",
]
[[package]]
name = "tokio-macros"
version = "2.6.0"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5"
checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496"
dependencies = [
"proc-macro2",
"quote",
@@ -1101,9 +1146,9 @@ dependencies = [
[[package]]
name = "toml"
version = "1.0.1+spec-1.1.0"
version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbe30f93627849fa362d4a602212d41bb237dc2bd0f8ba0b2ce785012e124220"
checksum = "81f3d15e84cbcd896376e6730314d59fb5a87f31e4b038454184435cd57defee"
dependencies = [
"indexmap",
"serde_core",
@@ -1116,27 +1161,27 @@ dependencies = [
[[package]]
name = "toml_datetime"
version = "1.0.0+spec-1.1.0"
version = "1.1.1+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32c2555c699578a4f59f0cc68e5116c8d7cabbd45e1409b989d4be085b53f13e"
checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7"
dependencies = [
"serde_core",
]
[[package]]
name = "toml_parser"
version = "1.0.8+spec-1.1.0"
version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0742ff5ff03ea7e67c8ae6c93cac239e0d9784833362da3f9a9c1da8dfefcbdc"
checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526"
dependencies = [
"winnow",
]
[[package]]
name = "toml_writer"
version = "1.0.6+spec-1.1.0"
version = "1.1.1+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607"
checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db"
[[package]]
name = "tonic"
@@ -1305,9 +1350,15 @@ checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
[[package]]
name = "unicode-ident"
version = "1.0.22"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "unicode-xid"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]]
name = "utf-8"
@@ -1351,21 +1402,55 @@ dependencies = [
"wit-bindgen",
]
[[package]]
name = "wasip3"
version = "0.4.0+wasi-0.3.0-rc-2026-01-06"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5"
dependencies = [
"wit-bindgen",
]
[[package]]
name = "wasm-encoder"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319"
dependencies = [
"leb128fmt",
"wasmparser",
]
[[package]]
name = "wasm-metadata"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
dependencies = [
"anyhow",
"indexmap",
"wasm-encoder",
"wasmparser",
]
[[package]]
name = "wasmparser"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
dependencies = [
"bitflags",
"hashbrown 0.15.5",
"indexmap",
"semver",
]
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.60.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.61.2"
@@ -1375,99 +1460,122 @@ dependencies = [
"windows-link",
]
[[package]]
name = "windows-targets"
version = "0.53.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
dependencies = [
"windows-link",
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
[[package]]
name = "windows_aarch64_msvc"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
[[package]]
name = "windows_i686_gnu"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
[[package]]
name = "windows_i686_gnullvm"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
[[package]]
name = "windows_i686_msvc"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
[[package]]
name = "windows_x86_64_gnu"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
[[package]]
name = "windows_x86_64_msvc"
version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
[[package]]
name = "winnow"
version = "0.7.14"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829"
checksum = "09dac053f1cd375980747450bfc7250c264eaae0583872e845c0c7cd578872b5"
[[package]]
name = "wit-bindgen"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
dependencies = [
"wit-bindgen-rust-macro",
]
[[package]]
name = "wit-bindgen-core"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc"
dependencies = [
"anyhow",
"heck",
"wit-parser",
]
[[package]]
name = "wit-bindgen-rust"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
dependencies = [
"anyhow",
"heck",
"indexmap",
"prettyplease",
"syn",
"wasm-metadata",
"wit-bindgen-core",
"wit-component",
]
[[package]]
name = "wit-bindgen-rust-macro"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a"
dependencies = [
"anyhow",
"prettyplease",
"proc-macro2",
"quote",
"syn",
"wit-bindgen-core",
"wit-bindgen-rust",
]
[[package]]
name = "wit-component"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
dependencies = [
"anyhow",
"bitflags",
"indexmap",
"log",
"serde",
"serde_derive",
"serde_json",
"wasm-encoder",
"wasm-metadata",
"wasmparser",
"wit-parser",
]
[[package]]
name = "wit-parser"
version = "0.244.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
dependencies = [
"anyhow",
"id-arena",
"indexmap",
"log",
"semver",
"serde",
"serde_derive",
"serde_json",
"unicode-xid",
"wasmparser",
]
[[package]]
name = "zerocopy"
version = "0.8.33"
version = "0.8.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "668f5168d10b9ee831de31933dc111a459c97ec93225beb307aed970d1372dfd"
checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.33"
version = "0.8.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c7962b26b0a8685668b671ee4b54d007a67d4eaf05fda79ac0ecf41e32270f1"
checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "zmij"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
+1 -1
View File
@@ -5,7 +5,7 @@ edition = "2024"
[[bin]] # Bin to run the HelloWorld gRPC server
name = "nyash_server"
name = "nyash-server"
path = "src/server.rs"