mirror of
https://github.com/kristoferssolo/des-rs.git
synced 2025-12-20 11:04:38 +00:00
refactor: use workspace
This commit is contained in:
parent
b8b963455d
commit
15481c0a9a
71
Cargo.lock
generated
71
Cargo.lock
generated
@ -11,6 +11,20 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit-wrap"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"unsynn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.3"
|
||||
@ -24,12 +38,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bba18ee93d577a8428902687bcc2b6b45a56b1981a1f6d779731c86cc4c5db18"
|
||||
|
||||
[[package]]
|
||||
name = "des"
|
||||
name = "des-lib"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bit-wrap",
|
||||
"claims",
|
||||
"rand",
|
||||
"rstest",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -81,6 +97,15 @@ dependencies = [
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fxhash"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.3"
|
||||
@ -127,6 +152,12 @@ version = "2.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
||||
|
||||
[[package]]
|
||||
name = "mutants"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc0287524726960e07b119cebd01678f852f147742ae0d925e6a520dca956126"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.16"
|
||||
@ -309,6 +340,12 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shadow_counted"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65da48d447333cebe1aadbdd3662f3ba56e76e67f53bc46f3dd5f67c74629d6b"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.11"
|
||||
@ -326,6 +363,26 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.7.2"
|
||||
@ -362,6 +419,18 @@ version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
|
||||
|
||||
[[package]]
|
||||
name = "unsynn"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7940603a9e25cf11211cc43b81f4fcad2b8ab4df291ca855f32c40e1ac22d5bc"
|
||||
dependencies = [
|
||||
"fxhash",
|
||||
"mutants",
|
||||
"proc-macro2",
|
||||
"shadow_counted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.14.7+wasi-0.2.4"
|
||||
|
||||
16
Cargo.toml
16
Cargo.toml
@ -1,17 +1,15 @@
|
||||
[package]
|
||||
name = "des"
|
||||
version = "0.1.0"
|
||||
authors = ["Kristofers Solo <dev@kristofers.xyz>"]
|
||||
edition = "2024"
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = ["des-lib", "bit-wrap"]
|
||||
|
||||
[dependencies]
|
||||
|
||||
[dev-dependencies]
|
||||
[workspace.dependencies]
|
||||
bit-wrap = { path = "bit-wrap" }
|
||||
thiserror = "2"
|
||||
claims = "0.8"
|
||||
rand = "0.9"
|
||||
rstest = "0.26"
|
||||
|
||||
[lints.clippy]
|
||||
[workspace.lints.clippy]
|
||||
pedantic = "warn"
|
||||
nursery = "warn"
|
||||
unwrap_used = "warn"
|
||||
|
||||
17
des-lib/Cargo.toml
Normal file
17
des-lib/Cargo.toml
Normal file
@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "des-lib"
|
||||
version = "0.1.0"
|
||||
authors = ["Kristofers Solo <dev@kristofers.xyz>"]
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
bit-wrap.workspace = true
|
||||
thiserror.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
claims.workspace = true
|
||||
rand.workspace = true
|
||||
rstest.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
0
des-lib/src/blocks/mod.rs
Normal file
0
des-lib/src/blocks/mod.rs
Normal file
0
des-lib/src/error.rs
Normal file
0
des-lib/src/error.rs
Normal file
29
des-lib/src/keys/key.rs
Normal file
29
des-lib/src/keys/key.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use std::fmt::{Debug, Display};
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Key(u64);
|
||||
|
||||
impl Key {
|
||||
// #[macro_use]
|
||||
// pub fn new(key: u64) -> Self {
|
||||
// key.into()
|
||||
// }
|
||||
}
|
||||
|
||||
impl From<u64> for Key {
|
||||
fn from(key: u64) -> Self {
|
||||
Self(key)
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for Key {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "Key(0x{:016X})", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Key {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "0x{:016X}", self.0)
|
||||
}
|
||||
}
|
||||
5
des-lib/src/keys/mod.rs
Normal file
5
des-lib/src/keys/mod.rs
Normal file
@ -0,0 +1,5 @@
|
||||
mod key;
|
||||
mod subkey;
|
||||
|
||||
pub use key::Key;
|
||||
pub use subkey::Subkey;
|
||||
33
des-lib/src/keys/subkey.rs
Normal file
33
des-lib/src/keys/subkey.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use bit_wrap::BitWrapper;
|
||||
|
||||
#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, BitWrapper)]
|
||||
#[bit_width(48)]
|
||||
pub struct Subkey(u64);
|
||||
|
||||
// impl TryFrom<u64> for Subkey {
|
||||
// type Error = SubkeyError;
|
||||
// fn try_from(key: u64) -> Result<Self, Self::Error> {
|
||||
// if key > Self::MAX {
|
||||
// return Err(SubkeyError::ValueOutOfRange(key));
|
||||
// }
|
||||
// Ok(Self(key))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl From<u32> for Subkey {
|
||||
// fn from(value: u32) -> Self {
|
||||
// Self(u64::from(value))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl From<u16> for Subkey {
|
||||
// fn from(value: u16) -> Self {
|
||||
// Self(u64::from(value))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// impl From<u8> for Subkey {
|
||||
// fn from(value: u8) -> Self {
|
||||
// Self(u64::from(value))
|
||||
// }
|
||||
// }
|
||||
@ -1,6 +1,10 @@
|
||||
mod blocks;
|
||||
mod constants;
|
||||
mod error;
|
||||
mod keys;
|
||||
|
||||
use crate::constants::{E_BOX, FP, IP, PC1_TABLE, PC2_TABLE, P_BOX, ROUND_ROTATIONS, S_BOXES};
|
||||
use crate::constants::{E_BOX, FP, IP, P_BOX, PC1_TABLE, PC2_TABLE, ROUND_ROTATIONS, S_BOXES};
|
||||
pub use keys::{Key, Subkey};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Des {
|
||||
Loading…
Reference in New Issue
Block a user