From aa45914abc4d8ca8290feb1f35cced81f6d6b9df Mon Sep 17 00:00:00 2001 From: SymmetricChaos <42520289+SymmetricChaos@users.noreply.github.com> Date: Fri, 16 Aug 2024 07:55:11 -0400 Subject: [PATCH] added gost --- src/cipher_panel/mod.rs | 3 +++ src/cipher_panel/tea_controls.rs | 17 +++-------------- src/cipher_panel/triple_des_controls.rs | 17 +++-------------- src/cipher_panel/xtea_controls.rs | 17 +++-------------- 4 files changed, 12 insertions(+), 42 deletions(-) diff --git a/src/cipher_panel/mod.rs b/src/cipher_panel/mod.rs index 220b6139..a515588c 100644 --- a/src/cipher_panel/mod.rs +++ b/src/cipher_panel/mod.rs @@ -170,6 +170,7 @@ pub struct CipherInterface { blowfish: blowfish_controls::BlowfishFrame, des: des_controls::DesFrame, desx: desx_controls::DesXFrame, + gost: gost_controls::GostFrame, idea: idea_controls::IdeaFrame, rc5: rc5_controls::Rc5Frame, tea: tea_controls::TeaFrame, @@ -312,6 +313,7 @@ impl CipherInterface { CipherId::Blowfish, CipherId::Des, CipherId::DesX, + CipherId::Gost, CipherId::Idea, CipherId::Rc5, CipherId::Tea, @@ -383,6 +385,7 @@ impl CipherInterface { CipherId::Dryad => &mut self.dryad, CipherId::Enigma => &mut self.enigma, CipherId::FourSquare => &mut self.four_square, + CipherId::Gost => &mut self.gost, CipherId::Grille => &mut self.grille, CipherId::Hebern => &mut self.hebern, CipherId::Hutton => &mut self.hutton, diff --git a/src/cipher_panel/tea_controls.rs b/src/cipher_panel/tea_controls.rs index bd32797f..a1eeb43a 100644 --- a/src/cipher_panel/tea_controls.rs +++ b/src/cipher_panel/tea_controls.rs @@ -1,9 +1,6 @@ use super::CipherFrame; use crate::ui_elements::{block_cipher_mode, block_cipher_padding, UiElements}; -use ciphers::{ - digital::block_ciphers::{block_cipher::BCMode, tea::Tea}, - Cipher, -}; +use ciphers::{digital::block_ciphers::tea::Tea, Cipher}; use egui::Ui; use rand::{thread_rng, Rng}; @@ -52,17 +49,9 @@ impl CipherFrame for TeaFrame { ui.add_space(8.0); - if self.cipher.mode.iv_needed() { - if self.cipher.mode == BCMode::Ctr { - ui.subheading("Counter"); - } else { - ui.subheading("Initialization Vector"); - } - } else { - ui.subheading("Counter/IV Not Needed"); - } - ui.add_enabled_ui(self.cipher.mode.iv_needed(), |ui| { + ui.subheading("IV/Counter"); + ui.label("In the selected mode the cipher must have a 64-bit initial value provided."); ui.u64_drag_value_hex(&mut self.cipher.iv); }); diff --git a/src/cipher_panel/triple_des_controls.rs b/src/cipher_panel/triple_des_controls.rs index 0ca321a5..cc96fffc 100644 --- a/src/cipher_panel/triple_des_controls.rs +++ b/src/cipher_panel/triple_des_controls.rs @@ -1,10 +1,7 @@ use super::CipherFrame; use crate::ui_elements::{block_cipher_mode, block_cipher_padding, u64_drag_value, UiElements}; use ciphers::{ - digital::block_ciphers::{ - block_cipher::BCMode, - des::{des_functions::set_des_key_parity, triple_des::TripleDes}, - }, + digital::block_ciphers::des::{des_functions::set_des_key_parity, triple_des::TripleDes}, Cipher, }; use egui::Ui; @@ -71,17 +68,9 @@ impl CipherFrame for TripleDesFrame { ui.add_space(8.0); - if self.cipher.mode.iv_needed() { - if self.cipher.mode == BCMode::Ctr { - ui.subheading("Counter"); - } else { - ui.subheading("Initialization Vector"); - } - } else { - ui.subheading("Counter/IV Not Needed"); - } - ui.add_enabled_ui(self.cipher.mode.iv_needed(), |ui| { + ui.subheading("IV/Counter"); + ui.label("In the selected mode the cipher must have a 64-bit initial value provided."); ui.u64_drag_value_hex(&mut self.cipher.iv); }); diff --git a/src/cipher_panel/xtea_controls.rs b/src/cipher_panel/xtea_controls.rs index 604bad88..64af0569 100644 --- a/src/cipher_panel/xtea_controls.rs +++ b/src/cipher_panel/xtea_controls.rs @@ -1,9 +1,6 @@ use super::CipherFrame; use crate::ui_elements::{block_cipher_mode, block_cipher_padding, UiElements}; -use ciphers::{ - digital::block_ciphers::{block_cipher::BCMode, xtea::Xtea}, - Cipher, -}; +use ciphers::{digital::block_ciphers::xtea::Xtea, Cipher}; use egui::Ui; use rand::{thread_rng, Rng}; @@ -52,17 +49,9 @@ impl CipherFrame for XteaFrame { ui.add_space(8.0); - if self.cipher.mode.iv_needed() { - if self.cipher.mode == BCMode::Ctr { - ui.subheading("Counter"); - } else { - ui.subheading("Initialization Vector"); - } - } else { - ui.subheading("Counter/IV Not Needed"); - } - ui.add_enabled_ui(self.cipher.mode.iv_needed(), |ui| { + ui.subheading("IV/Counter"); + ui.label("In the selected mode the cipher must have a 64-bit initial value provided."); ui.u64_drag_value_hex(&mut self.cipher.iv); });