Use log crate to filter verbose messages
This commit is contained in:
parent
860c0ebcac
commit
c3102882a9
5 changed files with 122 additions and 61 deletions
101
Cargo.lock
generated
101
Cargo.lock
generated
|
@ -38,7 +38,7 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
|
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -48,7 +48,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188"
|
checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"windows-sys",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -140,7 +140,7 @@ checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"errno-dragonfly",
|
"errno-dragonfly",
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -188,7 +188,7 @@ checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hermit-abi",
|
"hermit-abi",
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -200,7 +200,7 @@ dependencies = [
|
||||||
"hermit-abi",
|
"hermit-abi",
|
||||||
"io-lifetimes",
|
"io-lifetimes",
|
||||||
"rustix",
|
"rustix",
|
||||||
"windows-sys",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -221,6 +221,12 @@ version = "0.3.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
|
checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.18.0"
|
version = "1.18.0"
|
||||||
|
@ -297,7 +303,7 @@ dependencies = [
|
||||||
"io-lifetimes",
|
"io-lifetimes",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys",
|
"linux-raw-sys",
|
||||||
"windows-sys",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -337,6 +343,16 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "simple_logger"
|
||||||
|
version = "4.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2230cd5c29b815c9b699fb610b49a5ed65588f3509d9f0108be3a885da629333"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"windows-sys 0.42.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
|
@ -403,6 +419,21 @@ version = "0.2.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.42.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_gnullvm 0.42.2",
|
||||||
|
"windows_aarch64_msvc 0.42.2",
|
||||||
|
"windows_i686_gnu 0.42.2",
|
||||||
|
"windows_i686_msvc 0.42.2",
|
||||||
|
"windows_x86_64_gnu 0.42.2",
|
||||||
|
"windows_x86_64_gnullvm 0.42.2",
|
||||||
|
"windows_x86_64_msvc 0.42.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
|
@ -418,51 +449,93 @@ version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
|
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows_aarch64_gnullvm",
|
"windows_aarch64_gnullvm 0.48.0",
|
||||||
"windows_aarch64_msvc",
|
"windows_aarch64_msvc 0.48.0",
|
||||||
"windows_i686_gnu",
|
"windows_i686_gnu 0.48.0",
|
||||||
"windows_i686_msvc",
|
"windows_i686_msvc 0.48.0",
|
||||||
"windows_x86_64_gnu",
|
"windows_x86_64_gnu 0.48.0",
|
||||||
"windows_x86_64_gnullvm",
|
"windows_x86_64_gnullvm 0.48.0",
|
||||||
"windows_x86_64_msvc",
|
"windows_x86_64_msvc 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_gnullvm"
|
||||||
|
version = "0.42.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_gnullvm"
|
name = "windows_aarch64_gnullvm"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
|
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.42.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_msvc"
|
name = "windows_aarch64_msvc"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
|
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.42.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnu"
|
name = "windows_i686_gnu"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
|
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.42.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_msvc"
|
name = "windows_i686_msvc"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
|
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.42.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnu"
|
name = "windows_x86_64_gnu"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
|
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnullvm"
|
||||||
|
version = "0.42.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnullvm"
|
name = "windows_x86_64_gnullvm"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
|
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.42.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_msvc"
|
name = "windows_x86_64_msvc"
|
||||||
version = "0.48.0"
|
version = "0.48.0"
|
||||||
|
@ -475,7 +548,9 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"simple_logger",
|
||||||
"umskt",
|
"umskt",
|
||||||
]
|
]
|
||||||
|
|
|
@ -59,9 +59,7 @@ mod tests {
|
||||||
fn test_base24() {
|
fn test_base24() {
|
||||||
let input = "JTW3TJ7PFJ7V9CCMX84V9PFT8";
|
let input = "JTW3TJ7PFJ7V9CCMX84V9PFT8";
|
||||||
let unbase24 = super::base24_decode(input).unwrap();
|
let unbase24 = super::base24_decode(input).unwrap();
|
||||||
println!("{:?}", unbase24);
|
|
||||||
let base24 = super::base24_encode(&unbase24).unwrap();
|
let base24 = super::base24_encode(&unbase24).unwrap();
|
||||||
println!("{}", base24);
|
|
||||||
assert_eq!(input, base24);
|
assert_eq!(input, base24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,3 +15,6 @@ anyhow = "1.0.71"
|
||||||
clap = { version = "4.3.4", features = ["derive"] }
|
clap = { version = "4.3.4", features = ["derive"] }
|
||||||
serde = { version = "1.0.164", features = ["derive"] }
|
serde = { version = "1.0.164", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
log = "0.4.19"
|
||||||
|
simple_logger = { version = "4.2.0", default-features = false }
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,14 @@ use anyhow::Result;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::{from_reader, from_str};
|
use serde_json::{from_reader, from_str};
|
||||||
|
|
||||||
pub fn load_keys<P: AsRef<Path> + std::fmt::Display>(
|
pub fn load_keys<P: AsRef<Path> + std::fmt::Display>(path: Option<P>) -> Result<Keys> {
|
||||||
path: Option<P>,
|
|
||||||
verbose: bool,
|
|
||||||
) -> Result<Keys> {
|
|
||||||
let keys = {
|
let keys = {
|
||||||
if let Some(path) = path {
|
if let Some(path) = path {
|
||||||
let file = File::open(&path)?;
|
let file = File::open(&path)?;
|
||||||
let reader = BufReader::new(file);
|
let reader = BufReader::new(file);
|
||||||
let keys: Keys = from_reader(reader)?;
|
let keys: Keys = from_reader(reader)?;
|
||||||
|
|
||||||
if verbose {
|
log::info!("Loaded keys from {}", path);
|
||||||
println!("Loaded keys from {}", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
keys
|
keys
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,18 +13,23 @@ use crate::{cli::*, keys::load_keys};
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let args = Cli::parse();
|
let args = Cli::parse();
|
||||||
let verbose = args.verbose;
|
|
||||||
|
if args.verbose {
|
||||||
|
simple_logger::init_with_level(log::Level::Info)?;
|
||||||
|
} else {
|
||||||
|
simple_logger::init_with_level(log::Level::Warn)?;
|
||||||
|
}
|
||||||
|
|
||||||
match &args.command {
|
match &args.command {
|
||||||
Commands::List(args) => list(args, verbose),
|
Commands::List(args) => list(args),
|
||||||
Commands::Generate(args) => generate(args, verbose),
|
Commands::Generate(args) => generate(args),
|
||||||
Commands::Validate(args) => validate(args, verbose),
|
Commands::Validate(args) => validate(args),
|
||||||
Commands::ConfirmationId(args) => confirmation_id(&args.instid),
|
Commands::ConfirmationId(args) => confirmation_id(&args.instid),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list(args: &ListArgs, verbose: bool) -> Result<()> {
|
fn list(args: &ListArgs) -> Result<()> {
|
||||||
let keys = load_keys(args.keys_path.as_ref(), verbose)?;
|
let keys = load_keys(args.keys_path.as_ref())?;
|
||||||
for (key, value) in keys.products.iter() {
|
for (key, value) in keys.products.iter() {
|
||||||
println!("{}: {:?}", key, value.bink);
|
println!("{}: {:?}", key, value.bink);
|
||||||
}
|
}
|
||||||
|
@ -33,12 +38,12 @@ fn list(args: &ListArgs, verbose: bool) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate(args: &GenerateArgs, verbose: bool) -> Result<()> {
|
fn generate(args: &GenerateArgs) -> Result<()> {
|
||||||
if args.channel_id > 999 {
|
if args.channel_id > 999 {
|
||||||
bail!("Channel ID must be 3 digits or fewer");
|
bail!("Channel ID must be 3 digits or fewer");
|
||||||
}
|
}
|
||||||
|
|
||||||
let keys = load_keys(args.keys_path.as_ref(), verbose)?;
|
let keys = load_keys(args.keys_path.as_ref())?;
|
||||||
|
|
||||||
let bink_id = args.bink_id.to_ascii_uppercase();
|
let bink_id = args.bink_id.to_ascii_uppercase();
|
||||||
let bink = &keys.bink[&bink_id];
|
let bink = &keys.bink[&bink_id];
|
||||||
|
@ -50,36 +55,36 @@ fn generate(args: &GenerateArgs, verbose: bool) -> Result<()> {
|
||||||
// we need the result of the function K(x; y) = kG(x; y).
|
// we need the result of the function K(x; y) = kG(x; y).
|
||||||
let private_key = &bink.private;
|
let private_key = &bink.private;
|
||||||
|
|
||||||
let curve = initialize_curve(bink, &bink_id, verbose)?;
|
let curve = initialize_curve(bink, &bink_id)?;
|
||||||
let private_key = PrivateKey::new(gen_order, private_key)?;
|
let private_key = PrivateKey::new(gen_order, private_key)?;
|
||||||
|
|
||||||
if u32::from_str_radix(&bink_id, 16)? < 0x40 {
|
if u32::from_str_radix(&bink_id, 16)? < 0x40 {
|
||||||
bink1998_generate(&curve, &private_key, args.channel_id, args.count, verbose)?;
|
bink1998_generate(&curve, &private_key, args.channel_id, args.count)?;
|
||||||
} else {
|
} else {
|
||||||
bink2002_generate(&curve, &private_key, args.channel_id, args.count, verbose)?;
|
bink2002_generate(&curve, &private_key, args.channel_id, args.count)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate(args: &ValidateArgs, verbose: bool) -> Result<()> {
|
fn validate(args: &ValidateArgs) -> Result<()> {
|
||||||
// We can validate any given key using the available public key: {p, a, b, G, K}.
|
// We can validate any given key using the available public key: {p, a, b, G, K}.
|
||||||
// No private key or gen_order is required.
|
// No private key or gen_order is required.
|
||||||
let keys = load_keys(args.keys_path.as_ref(), verbose)?;
|
let keys = load_keys(args.keys_path.as_ref())?;
|
||||||
let bink_id = args.bink_id.to_ascii_uppercase();
|
let bink_id = args.bink_id.to_ascii_uppercase();
|
||||||
let bink = &keys.bink[&bink_id];
|
let bink = &keys.bink[&bink_id];
|
||||||
let curve = initialize_curve(bink, &bink_id, verbose)?;
|
let curve = initialize_curve(bink, &bink_id)?;
|
||||||
|
|
||||||
if u32::from_str_radix(&bink_id, 16)? < 0x40 {
|
if u32::from_str_radix(&bink_id, 16)? < 0x40 {
|
||||||
bink1998_validate(&curve, &args.key_to_check, verbose)?;
|
bink1998_validate(&curve, &args.key_to_check)?;
|
||||||
} else {
|
} else {
|
||||||
bink2002_validate(&curve, &args.key_to_check, verbose)?;
|
bink2002_validate(&curve, &args.key_to_check)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn initialize_curve(bink: &Bink, bink_id: &str, verbose: bool) -> Result<EllipticCurve> {
|
fn initialize_curve(bink: &Bink, bink_id: &str) -> Result<EllipticCurve> {
|
||||||
let p = &bink.p;
|
let p = &bink.p;
|
||||||
let a = &bink.a;
|
let a = &bink.a;
|
||||||
let b = &bink.b;
|
let b = &bink.b;
|
||||||
|
@ -88,12 +93,7 @@ fn initialize_curve(bink: &Bink, bink_id: &str, verbose: bool) -> Result<Ellipti
|
||||||
let kx = &bink.public.x;
|
let kx = &bink.public.x;
|
||||||
let ky = &bink.public.y;
|
let ky = &bink.public.y;
|
||||||
|
|
||||||
if verbose {
|
log::info!("Elliptic curve parameters for BINK ID {bink_id}:\n{bink}");
|
||||||
println!("-----------------------------------------------------------");
|
|
||||||
println!("Elliptic curve parameters for BINK ID {bink_id}:");
|
|
||||||
println!("-----------------------------------------------------------");
|
|
||||||
println!("{bink}");
|
|
||||||
}
|
|
||||||
|
|
||||||
EllipticCurve::new(p, a, b, gx, gy, kx, ky)
|
EllipticCurve::new(p, a, b, gx, gy, kx, ky)
|
||||||
}
|
}
|
||||||
|
@ -103,13 +103,10 @@ fn bink1998_generate(
|
||||||
private_key: &PrivateKey,
|
private_key: &PrivateKey,
|
||||||
channel_id: u32,
|
channel_id: u32,
|
||||||
count: u64,
|
count: u64,
|
||||||
verbose: bool,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
for _ in 0..count {
|
for _ in 0..count {
|
||||||
let product_key = bink1998::ProductKey::new(curve, private_key, channel_id, None, None)?;
|
let product_key = bink1998::ProductKey::new(curve, private_key, channel_id, None, None)?;
|
||||||
if verbose {
|
log::info!("{:?}", product_key);
|
||||||
println!("{:?}", product_key);
|
|
||||||
}
|
|
||||||
println!("{product_key}");
|
println!("{product_key}");
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -120,33 +117,26 @@ fn bink2002_generate(
|
||||||
private_key: &PrivateKey,
|
private_key: &PrivateKey,
|
||||||
channel_id: u32,
|
channel_id: u32,
|
||||||
count: u64,
|
count: u64,
|
||||||
verbose: bool,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
for _ in 0..count {
|
for _ in 0..count {
|
||||||
let product_key = bink2002::ProductKey::new(curve, private_key, channel_id, None, None)?;
|
let product_key = bink2002::ProductKey::new(curve, private_key, channel_id, None, None)?;
|
||||||
if verbose {
|
log::info!("{:?}", product_key);
|
||||||
println!("{:?}", product_key);
|
|
||||||
}
|
|
||||||
println!("{product_key}");
|
println!("{product_key}");
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bink1998_validate(curve: &EllipticCurve, key: &str, verbose: bool) -> Result<()> {
|
fn bink1998_validate(curve: &EllipticCurve, key: &str) -> Result<()> {
|
||||||
let product_key = bink1998::ProductKey::from_key(curve, key)?;
|
let product_key = bink1998::ProductKey::from_key(curve, key)?;
|
||||||
if verbose {
|
log::info!("{:?}", product_key);
|
||||||
println!("{:?}", product_key);
|
|
||||||
}
|
|
||||||
println!("{product_key}");
|
println!("{product_key}");
|
||||||
println!("Key validated successfully!");
|
println!("Key validated successfully!");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bink2002_validate(curve: &EllipticCurve, key: &str, verbose: bool) -> Result<()> {
|
fn bink2002_validate(curve: &EllipticCurve, key: &str) -> Result<()> {
|
||||||
let product_key = bink2002::ProductKey::from_key(curve, key)?;
|
let product_key = bink2002::ProductKey::from_key(curve, key)?;
|
||||||
if verbose {
|
log::info!("{:?}", product_key);
|
||||||
println!("{:?}", product_key);
|
|
||||||
}
|
|
||||||
println!("{product_key}");
|
println!("{product_key}");
|
||||||
println!("Key validated successfully!");
|
println!("Key validated successfully!");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Reference in a new issue