diff --git a/src/enhanced-secure-crypto/.gitattributes b/src/enhanced-secure-crypto/.gitattributes
deleted file mode 100644
index 6f561bd..0000000
--- a/src/enhanced-secure-crypto/.gitattributes
+++ /dev/null
@@ -1,3 +0,0 @@
-*.rs linguist-detectable=true
-*.rs linguist-language=Rust
-pkg/* linguist-vendored
diff --git a/src/enhanced-secure-crypto/Cargo.lock b/src/enhanced-secure-crypto/Cargo.lock
deleted file mode 100644
index 56e074f..0000000
--- a/src/enhanced-secure-crypto/Cargo.lock
+++ /dev/null
@@ -1,430 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-version = 4
-
-[[package]]
-name = "base64"
-version = "0.13.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
-
-[[package]]
-name = "bumpalo"
-version = "3.19.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
-
-[[package]]
-name = "cc"
-version = "1.2.32"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2352e5597e9c544d5e6d9c95190d5d27738ade584fa8db0a16e130e5c2b5296e"
-dependencies = [
- "shlex",
-]
-
-[[package]]
-name = "cfg-if"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
-
-[[package]]
-name = "console_error_panic_hook"
-version = "0.1.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
-dependencies = [
- "cfg-if",
- "wasm-bindgen",
-]
-
-[[package]]
-name = "enhanced-secure-crypto"
-version = "0.1.0"
-dependencies = [
- "base64",
- "console_error_panic_hook",
- "getrandom",
- "hex",
- "js-sys",
- "rand",
- "ring",
- "serde",
- "serde-wasm-bindgen",
- "serde_json",
- "thiserror",
- "wasm-bindgen",
- "wasm-bindgen-futures",
- "web-sys",
-]
-
-[[package]]
-name = "getrandom"
-version = "0.2.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
-dependencies = [
- "cfg-if",
- "js-sys",
- "libc",
- "wasi",
- "wasm-bindgen",
-]
-
-[[package]]
-name = "hex"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
-
-[[package]]
-name = "itoa"
-version = "1.0.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
-
-[[package]]
-name = "js-sys"
-version = "0.3.77"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
-dependencies = [
- "once_cell",
- "wasm-bindgen",
-]
-
-[[package]]
-name = "libc"
-version = "0.2.175"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
-
-[[package]]
-name = "log"
-version = "0.4.27"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
-
-[[package]]
-name = "memchr"
-version = "2.7.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
-
-[[package]]
-name = "once_cell"
-version = "1.21.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
-
-[[package]]
-name = "ppv-lite86"
-version = "0.2.21"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
-dependencies = [
- "zerocopy",
-]
-
-[[package]]
-name = "proc-macro2"
-version = "1.0.97"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d61789d7719defeb74ea5fe81f2fdfdbd28a803847077cecce2ff14e1472f6f1"
-dependencies = [
- "unicode-ident",
-]
-
-[[package]]
-name = "quote"
-version = "1.0.40"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
-dependencies = [
- "proc-macro2",
-]
-
-[[package]]
-name = "rand"
-version = "0.8.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
-dependencies = [
- "libc",
- "rand_chacha",
- "rand_core",
-]
-
-[[package]]
-name = "rand_chacha"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
-dependencies = [
- "ppv-lite86",
- "rand_core",
-]
-
-[[package]]
-name = "rand_core"
-version = "0.6.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
-dependencies = [
- "getrandom",
-]
-
-[[package]]
-name = "ring"
-version = "0.16.20"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
-dependencies = [
- "cc",
- "libc",
- "once_cell",
- "spin",
- "untrusted",
- "web-sys",
- "winapi",
-]
-
-[[package]]
-name = "rustversion"
-version = "1.0.22"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
-
-[[package]]
-name = "ryu"
-version = "1.0.20"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
-
-[[package]]
-name = "serde"
-version = "1.0.219"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
-dependencies = [
- "serde_derive",
-]
-
-[[package]]
-name = "serde-wasm-bindgen"
-version = "0.4.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e3b4c031cd0d9014307d82b8abf653c0290fbdaeb4c02d00c63cf52f728628bf"
-dependencies = [
- "js-sys",
- "serde",
- "wasm-bindgen",
-]
-
-[[package]]
-name = "serde_derive"
-version = "1.0.219"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "serde_json"
-version = "1.0.142"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7"
-dependencies = [
- "itoa",
- "memchr",
- "ryu",
- "serde",
-]
-
-[[package]]
-name = "shlex"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
-
-[[package]]
-name = "spin"
-version = "0.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
-
-[[package]]
-name = "syn"
-version = "2.0.105"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7bc3fcb250e53458e712715cf74285c1f889686520d79294a9ef3bd7aa1fc619"
-dependencies = [
- "proc-macro2",
- "quote",
- "unicode-ident",
-]
-
-[[package]]
-name = "thiserror"
-version = "1.0.69"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
-dependencies = [
- "thiserror-impl",
-]
-
-[[package]]
-name = "thiserror-impl"
-version = "1.0.69"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "unicode-ident"
-version = "1.0.18"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
-
-[[package]]
-name = "untrusted"
-version = "0.7.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
-
-[[package]]
-name = "wasi"
-version = "0.11.1+wasi-snapshot-preview1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
-
-[[package]]
-name = "wasm-bindgen"
-version = "0.2.100"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
-dependencies = [
- "cfg-if",
- "once_cell",
- "rustversion",
- "wasm-bindgen-macro",
-]
-
-[[package]]
-name = "wasm-bindgen-backend"
-version = "0.2.100"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
-dependencies = [
- "bumpalo",
- "log",
- "proc-macro2",
- "quote",
- "syn",
- "wasm-bindgen-shared",
-]
-
-[[package]]
-name = "wasm-bindgen-futures"
-version = "0.4.50"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61"
-dependencies = [
- "cfg-if",
- "js-sys",
- "once_cell",
- "wasm-bindgen",
- "web-sys",
-]
-
-[[package]]
-name = "wasm-bindgen-macro"
-version = "0.2.100"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
-dependencies = [
- "quote",
- "wasm-bindgen-macro-support",
-]
-
-[[package]]
-name = "wasm-bindgen-macro-support"
-version = "0.2.100"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
- "wasm-bindgen-backend",
- "wasm-bindgen-shared",
-]
-
-[[package]]
-name = "wasm-bindgen-shared"
-version = "0.2.100"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
-dependencies = [
- "unicode-ident",
-]
-
-[[package]]
-name = "web-sys"
-version = "0.3.77"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2"
-dependencies = [
- "js-sys",
- "wasm-bindgen",
-]
-
-[[package]]
-name = "winapi"
-version = "0.3.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
-dependencies = [
- "winapi-i686-pc-windows-gnu",
- "winapi-x86_64-pc-windows-gnu",
-]
-
-[[package]]
-name = "winapi-i686-pc-windows-gnu"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
-
-[[package]]
-name = "winapi-x86_64-pc-windows-gnu"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-
-[[package]]
-name = "zerocopy"
-version = "0.8.26"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f"
-dependencies = [
- "zerocopy-derive",
-]
-
-[[package]]
-name = "zerocopy-derive"
-version = "0.8.26"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
diff --git a/src/enhanced-secure-crypto/Cargo.toml b/src/enhanced-secure-crypto/Cargo.toml
deleted file mode 100644
index cc263ad..0000000
--- a/src/enhanced-secure-crypto/Cargo.toml
+++ /dev/null
@@ -1,36 +0,0 @@
-[package]
-name = "enhanced-secure-crypto"
-version = "0.1.0"
-edition = "2021"
-
-[lib]
-crate-type = ["cdylib", "rlib"]
-
-[dependencies]
-wasm-bindgen = "0.2"
-js-sys = "0.3"
-serde = { version = "1.0", features = ["derive"] }
-serde_json = "1.0"
-serde-wasm-bindgen = "0.4"
-ring = "0.16"
-rand = "0.8"
-base64 = "0.13"
-hex = "0.4"
-thiserror = "1.0"
-getrandom = { version = "0.2", features = ["js"] }
-wasm-bindgen-futures = "0.4"
-console_error_panic_hook = "0.1"
-
-[dependencies.web-sys]
-version = "0.3"
-features = [
- "console",
- "CryptoKey",
- "SubtleCrypto",
- "Window",
- "Crypto",
-]
-
-[features]
-default = []
-test-utils = []
\ No newline at end of file
diff --git a/src/enhanced-secure-crypto/crypto-bridge.js b/src/enhanced-secure-crypto/crypto-bridge.js
deleted file mode 100644
index 95eabc7..0000000
--- a/src/enhanced-secure-crypto/crypto-bridge.js
+++ /dev/null
@@ -1,89 +0,0 @@
-import init, * as wasm from './pkg/enhanced_secure_crypto.js';
-
-export class SecureCryptoBridge {
- constructor() {
- this.wasmModule = null;
- this.cryptoUtils = null;
- this.isInitialized = false;
- }
-
- async initialize() {
- try {
- await init();
- this.cryptoUtils = new wasm.EnhancedSecureCryptoUtils();
- this.isInitialized = true;
- console.log('✅ Secure Crypto WASM module initialized successfully');
- return true;
- } catch (error) {
- console.error('❌ Failed to initialize WASM module:', error);
- return false;
- }
- }
-
- ensureInitialized() {
- if (!this.isInitialized) {
- throw new Error('Crypto module not initialized. Call initialize() first.');
- }
- }
-
- async encryptData(data, password) {
- this.ensureInitialized();
- try {
- return this.cryptoUtils.encrypt_data(data, password);
- } catch (error) {
- throw new Error(`Encryption failed: ${error.message}`);
- }
- }
-
- async decryptData(encryptedData, password) {
- this.ensureInitialized();
- try {
- return this.cryptoUtils.decrypt_data(encryptedData, password);
- } catch (error) {
- throw new Error(`Decryption failed: ${error.message}`);
- }
- }
-
- generateSecurePassword() {
- this.ensureInitialized();
- return this.cryptoUtils.generate_secure_password();
- }
-
- generateSalt() {
- this.ensureInitialized();
- return Array.from(this.cryptoUtils.generate_salt());
- }
-
- async generateECDSAKeyPair() {
- this.ensureInitialized();
- try {
- return this.cryptoUtils.generate_ecdsa_keypair();
- } catch (error) {
- throw new Error(`Key generation failed: ${error.message}`);
- }
- }
-
- sanitizeMessage(message) {
- this.ensureInitialized();
- return this.cryptoUtils.sanitize_message(message);
- }
-
- arrayBufferToBase64(buffer) {
- this.ensureInitialized();
- return wasm.array_buffer_to_base64(buffer);
- }
-
- base64ToArrayBuffer(base64Str) {
- this.ensureInitialized();
- return Array.from(wasm.base64_to_array_buffer(base64Str));
- }
-}
-
-let cryptoBridgeInstance = null;
-
-export function getCryptoBridge() {
- if (!cryptoBridgeInstance) {
- cryptoBridgeInstance = new SecureCryptoBridge();
- }
- return cryptoBridgeInstance;
-}
\ No newline at end of file
diff --git a/src/enhanced-secure-crypto/demo.html b/src/enhanced-secure-crypto/demo.html
deleted file mode 100644
index db1e761..0000000
--- a/src/enhanced-secure-crypto/demo.html
+++ /dev/null
@@ -1,269 +0,0 @@
-
-
-
-
-
- Enhanced Secure Crypto Demo
-
-
-
- 🔐 Enhanced Secure Crypto Demo (Rust + WASM)
-
-
-
Status
-
Initializing...
-
Crypto Ready: ⏳ Loading...
-
-
-
-
-
-
🔑 Password Management
-
-
-
-
-
-
-
-
-
-
💬 Message Operations
-
-
-
-
-
-
-
-
-
-
-
🔐 Encrypted Message
-
-
-
-
-
-
-
📄 Decrypted Message
-
-
-
-
-
-
✍️ Digital Signature
-
-
-
-
-
-
🛡️ Security Information
-
- - Encryption: AES-256-GCM (256-bit key)
- - Key Derivation: PBKDF2-HMAC-SHA256 (100,000 iterations)
- - Digital Signatures: ECDSA P-384 with SHA-384
- - Random Generation: Cryptographically secure PRNG
- - Memory Safety: Rust + WebAssembly
- - Performance: ~5-7x faster than pure JavaScript
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/enhanced-secure-crypto/react-crypto-hook.js b/src/enhanced-secure-crypto/react-crypto-hook.js
deleted file mode 100644
index 8dd5f36..0000000
--- a/src/enhanced-secure-crypto/react-crypto-hook.js
+++ /dev/null
@@ -1,62 +0,0 @@
-import { useState, useEffect, useCallback, useRef } from 'react';
-import { getCryptoBridge } from './crypto-bridge.js';
-
-export function useCrypto() {
- const [isReady, setIsReady] = useState(false);
- const [error, setError] = useState(null);
- const cryptoBridge = useRef(getCryptoBridge());
-
- useEffect(() => {
- const initializeCrypto = async () => {
- try {
- const success = await cryptoBridge.current.initialize();
- if (success) {
- setIsReady(true);
- setError(null);
- } else {
- setError('Failed to initialize crypto module');
- }
- } catch (err) {
- setError(err.message);
- }
- };
-
- initializeCrypto();
- }, []);
-
- const encryptData = useCallback(async (data, password) => {
- if (!isReady) throw new Error('Crypto not ready');
- return await cryptoBridge.current.encryptData(data, password);
- }, [isReady]);
-
- const decryptData = useCallback(async (encryptedData, password) => {
- if (!isReady) throw new Error('Crypto not ready');
- return await cryptoBridge.current.decryptData(encryptedData, password);
- }, [isReady]);
-
- const generateKeyPair = useCallback(async () => {
- if (!isReady) throw new Error('Crypto not ready');
- return await cryptoBridge.current.generateECDSAKeyPair();
- }, [isReady]);
-
- const generatePassword = useCallback(() => {
- if (!isReady) throw new Error('Crypto not ready');
- return cryptoBridge.current.generateSecurePassword();
- }, [isReady]);
-
- const sanitizeMessage = useCallback((message) => {
- if (!isReady) throw new Error('Crypto not ready');
- return cryptoBridge.current.sanitizeMessage(message);
- }, [isReady]);
-
- return {
- isReady,
- error,
- encryptData,
- decryptData,
- generateKeyPair,
- generatePassword,
- sanitizeMessage,
- cryptoBridge: cryptoBridge.current
- };
-}
\ No newline at end of file
diff --git a/src/enhanced-secure-crypto/scripts/build.sh b/src/enhanced-secure-crypto/scripts/build.sh
deleted file mode 100644
index d259e4f..0000000
--- a/src/enhanced-secure-crypto/scripts/build.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-echo "🔧 Building Enhanced Secure Crypto WASM module..."
-
-# Проверка wasm-pack
-if ! command -v wasm-pack &> /dev/null; then
- echo "❌ wasm-pack not found. Installing..."
- curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
-fi
-
-# Сборка
-echo "🚀 Building WASM module..."
-wasm-pack build --target web --out-dir pkg --release
-
-if [ $? -eq 0 ]; then
- echo "✅ Build completed successfully!"
- echo "📁 Generated files:"
- ls -la pkg/
-else
- echo "❌ Build failed!"
- exit 1
-fi
\ No newline at end of file
diff --git a/src/enhanced-secure-crypto/scripts/test.sh b/src/enhanced-secure-crypto/scripts/test.sh
deleted file mode 100644
index 129809d..0000000
--- a/src/enhanced-secure-crypto/scripts/test.sh
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/bin/bash
-echo "🧪 Running tests..."
-
-# Сборка тестовой версии
-wasm-pack build --target web --out-dir pkg --dev
-
-# Создание тестового HTML
-cat > test.html << 'EOF'
-
-
-
-
- Crypto Module Test
-
-
-
- 🔐 Enhanced Secure Crypto Module Test
-
-
-
Status
-
Initializing...
-
-
-
-
-
-
-
-
-
Results
-
No tests run yet.
-
-
-
-
-
-EOF
-
-echo "✅ Test file created. Run: basic-http-server . and open http://localhost:8000/test.html"
\ No newline at end of file
diff --git a/src/enhanced-secure-crypto/secure-chat-demo.jsx b/src/enhanced-secure-crypto/secure-chat-demo.jsx
deleted file mode 100644
index 0f63c79..0000000
--- a/src/enhanced-secure-crypto/secure-chat-demo.jsx
+++ /dev/null
@@ -1,294 +0,0 @@
-// secure-chat-demo.jsx
-import React, { useState, useEffect, useCallback } from 'react';
-
-// Импорт нашего модуля
-import init, { EnhancedSecureCryptoUtils } from './pkg/enhanced_secure_crypto.js';
-
-export function SecureChatDemo() {
- const [crypto, setCrypto] = useState(null);
- const [isReady, setIsReady] = useState(false);
- const [error, setError] = useState(null);
- const [status, setStatus] = useState('Initializing...');
-
- // Состояние для демонстрации
- const [message, setMessage] = useState('');
- const [password, setPassword] = useState('');
- const [encryptedMessage, setEncryptedMessage] = useState('');
- const [decryptedMessage, setDecryptedMessage] = useState('');
- const [keyPair, setKeyPair] = useState(null);
- const [signature, setSignature] = useState('');
-
- // Инициализация WASM модуля
- useEffect(() => {
- const initializeCrypto = async () => {
- try {
- setStatus('Loading WASM module...');
- await init();
-
- setStatus('Creating crypto instance...');
- const cryptoInstance = new EnhancedSecureCryptoUtils();
- setCrypto(cryptoInstance);
-
- setStatus('Generating secure password...');
- const generatedPassword = cryptoInstance.generate_secure_password();
- setPassword(generatedPassword);
-
- setStatus('Generating key pair...');
- const generatedKeyPair = cryptoInstance.generate_ecdsa_keypair();
- setKeyPair(generatedKeyPair);
-
- setIsReady(true);
- setStatus('✅ Rust crypto module ready!');
- setError(null);
-
- } catch (err) {
- console.error('Crypto initialization failed:', err);
- setError(err.message);
- setStatus('❌ Failed to initialize crypto module');
- setIsReady(false);
- }
- };
-
- initializeCrypto();
- }, []);
-
- // Функция шифрования
- const handleEncrypt = useCallback(async () => {
- if (!crypto || !message.trim()) {
- setStatus('❌ Please enter a message');
- return;
- }
-
- try {
- setStatus('🔒 Encrypting message...');
- const sanitized = crypto.sanitize_message(message);
- const encrypted = crypto.encrypt_data(sanitized, password);
- setEncryptedMessage(encrypted);
- setStatus('✅ Message encrypted successfully');
- } catch (err) {
- setStatus(`❌ Encryption failed: ${err.message}`);
- setError(err.message);
- }
- }, [crypto, message, password]);
-
- // Функция расшифровки
- const handleDecrypt = useCallback(async () => {
- if (!crypto || !encryptedMessage.trim()) {
- setStatus('❌ No encrypted message to decrypt');
- return;
- }
-
- try {
- setStatus('🔓 Decrypting message...');
- const decrypted = crypto.decrypt_data(encryptedMessage, password);
- setDecryptedMessage(decrypted);
- setStatus('✅ Message decrypted successfully');
- } catch (err) {
- setStatus(`❌ Decryption failed: ${err.message}`);
- setError(err.message);
- }
- }, [crypto, encryptedMessage, password]);
-
- // Функция подписи
- const handleSign = useCallback(async () => {
- if (!crypto || !message.trim() || !keyPair) {
- setStatus('❌ Need message and keys to sign');
- return;
- }
-
- try {
- setStatus('✍️ Signing message...');
- const signatureBytes = crypto.sign_data(keyPair.private_key, message);
- const signatureHex = Array.from(signatureBytes)
- .map(b => b.toString(16).padStart(2, '0'))
- .join('');
- setSignature(signatureHex);
- setStatus('✅ Message signed successfully');
- } catch (err) {
- setStatus(`❌ Signing failed: ${err.message}`);
- setError(err.message);
- }
- }, [crypto, message, keyPair]);
-
- // Функция верификации подписи
- const handleVerify = useCallback(async () => {
- if (!crypto || !message.trim() || !keyPair || !signature) {
- setStatus('❌ Need message, keys and signature to verify');
- return;
- }
-
- try {
- setStatus('🔍 Verifying signature...');
- const signatureBytes = signature.match(/.{1,2}/g).map(byte => parseInt(byte, 16));
- const isValid = crypto.verify_signature(keyPair.public_key, signatureBytes, message);
- setStatus(isValid ? '✅ Signature is valid' : '❌ Signature is invalid');
- } catch (err) {
- setStatus(`❌ Verification failed: ${err.message}`);
- setError(err.message);
- }
- }, [crypto, message, keyPair, signature]);
-
- // Генерация нового пароля
- const generateNewPassword = useCallback(() => {
- if (!crypto) return;
- const newPassword = crypto.generate_secure_password();
- setPassword(newPassword);
- setStatus('🔑 New password generated');
- }, [crypto]);
-
- // Генерация кода верификации
- const generateVerificationCode = useCallback(() => {
- if (!crypto) return;
- const code = crypto.generate_verification_code();
- setStatus(`🔢 Verification code: ${code}`);
- }, [crypto]);
-
- if (error) {
- return (
-
-
❌ Crypto Module Error
-
{error}
-
Please check that your browser supports WebAssembly.
-
- );
- }
-
- return (
-
-
🔐 Enhanced Secure Crypto Demo (Rust + WASM)
-
- {/* Status Panel */}
-
-
Status
-
Module Status: {status}
-
Crypto Ready: {isReady ? '✅ Yes' : '⏳ Loading...'}
-
Algorithm: AES-256-GCM + ECDSA P-384
- {keyPair && (
-
Key Pair: ✅ Generated ({keyPair.curve})
- )}
-
-
- {isReady && (
- <>
- {/* Password Section */}
-
-
🔑 Password Management
-
- setPassword(e.target.value)}
- placeholder="Encryption password"
- style={{ flex: 1, padding: '8px' }}
- />
-
-
-
-
-
- {/* Message Section */}
-
-
- {/* Encrypted Message Section */}
- {encryptedMessage && (
-
-
🔐 Encrypted Message
-
-
-
- )}
-
- {/* Decrypted Message Section */}
- {decryptedMessage && (
-
-
📄 Decrypted Message
-
- {decryptedMessage}
-
-
- )}
-
- {/* Signature Section */}
- {signature && (
-
-
✍️ Digital Signature
-
-
- )}
-
- {/* Security Info */}
-
-
🛡️ Security Information
-
- - Encryption: AES-256-GCM (256-bit key)
- - Key Derivation: PBKDF2-HMAC-SHA256 (100,000 iterations)
- - Digital Signatures: ECDSA P-384 with SHA-384
- - Random Generation: Cryptographically secure PRNG
- - Memory Safety: Rust + WebAssembly
- - Performance: ~5-7x faster than pure JavaScript
-
-
- >
- )}
-
- );
-}
-
-const buttonStyle = {
- backgroundColor: '#007bff',
- color: 'white',
- border: 'none',
- padding: '10px 15px',
- borderRadius: '5px',
- cursor: 'pointer',
- fontSize: '14px'
-};
-
-export default SecureChatDemo;
\ No newline at end of file
diff --git a/src/enhanced-secure-crypto/src/lib.rs b/src/enhanced-secure-crypto/src/lib.rs
deleted file mode 100644
index 424562f..0000000
--- a/src/enhanced-secure-crypto/src/lib.rs
+++ /dev/null
@@ -1,304 +0,0 @@
-use wasm_bindgen::prelude::*;
-use serde::{Deserialize, Serialize};
-use ring::{
- aead::{self, AES_256_GCM, LessSafeKey, UnboundKey},
- digest::{SHA256, SHA384},
- rand::{SecureRandom, SystemRandom},
- signature::{EcdsaKeyPair, KeyPair, ECDSA_P384_SHA384_ASN1_SIGNING, ECDSA_P384_SHA384_ASN1},
- pbkdf2,
-};
-use std::time::{SystemTime, UNIX_EPOCH};
-
-// Включение panic hook для лучшей отладки в WASM
-#[wasm_bindgen(start)]
-pub fn main() {
- console_error_panic_hook::set_once();
-}
-
-// Основные структуры данных
-#[derive(Serialize, Deserialize, Clone, Debug)]
-pub struct EncryptedPackage {
- pub version: String,
- pub salt: Vec,
- pub iv: Vec,
- pub data: Vec,
- pub timestamp: u64,
-}
-
-#[derive(Serialize, Deserialize, Clone, Debug)]
-pub struct CryptoKeyPair {
- pub private_key: Vec,
- pub public_key: Vec,
- pub algorithm: String,
- pub curve: String,
-}
-
-#[derive(Serialize, Deserialize, Clone, Debug)]
-pub struct AuthChallenge {
- pub challenge: Vec,
- pub timestamp: u64,
- pub nonce: Vec,
- pub version: String,
-}
-
-// Главный класс
-#[wasm_bindgen]
-pub struct EnhancedSecureCryptoUtils {
- rng: SystemRandom,
-}
-
-#[wasm_bindgen]
-impl EnhancedSecureCryptoUtils {
- #[wasm_bindgen(constructor)]
- pub fn new() -> Self {
- Self {
- rng: SystemRandom::new(),
- }
- }
-
- // Генерация безопасного пароля
- #[wasm_bindgen]
- pub fn generate_secure_password(&self) -> String {
- const CHARS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- let mut password = Vec::with_capacity(16);
-
- for _ in 0..16 {
- let mut byte = [0u8; 1];
- self.rng.fill(&mut byte).unwrap();
- let index = (byte[0] as usize) % CHARS.len();
- password.push(CHARS[index]);
- }
-
- String::from_utf8(password).unwrap()
- }
-
- // Генерация соли (64 байта)
- #[wasm_bindgen]
- pub fn generate_salt(&self) -> Vec {
- let mut salt = vec![0u8; 64];
- self.rng.fill(&mut salt).unwrap();
- salt
- }
-
- // Шифрование данных с PBKDF2 и AES-GCM
- #[wasm_bindgen]
- pub fn encrypt_data(&self, data: &str, password: &str) -> Result {
- let salt = self.generate_salt();
- let iterations = 100_000;
-
- // Вывод ключа через PBKDF2
- let mut key_bytes = [0u8; 32];
- pbkdf2::derive(
- pbkdf2::PBKDF2_HMAC_SHA256,
- std::num::NonZeroU32::new(iterations).unwrap(),
- &salt,
- password.as_bytes(),
- &mut key_bytes,
- );
-
- // Создание ключа AES-GCM
- let unbound_key = UnboundKey::new(&AES_256_GCM, &key_bytes)
- .map_err(|e| JsValue::from_str(&format!("Key creation failed: {}", e)))?;
- let key = LessSafeKey::new(unbound_key);
-
- // Генерация IV
- let mut iv = [0u8; 12];
- self.rng.fill(&mut iv).unwrap();
-
- // Шифрование
- let mut data_bytes = data.as_bytes().to_vec();
- key.seal_in_place_append_tag(aead::Nonce::assume_unique_for_key(iv), aead::Aad::empty(), &mut data_bytes)
- .map_err(|e| JsValue::from_str(&format!("Encryption failed: {}", e)))?;
-
- let package = EncryptedPackage {
- version: "1.0".to_string(),
- salt,
- iv: iv.to_vec(),
- data: data_bytes,
- timestamp: current_timestamp(),
- };
-
- let package_json = serde_json::to_string(&package)
- .map_err(|e| JsValue::from_str(&format!("Serialization failed: {}", e)))?;
-
- Ok(base64::encode(&package_json))
- }
-
- // Расшифровка данных
- #[wasm_bindgen]
- pub fn decrypt_data(&self, encrypted_data: &str, password: &str) -> Result {
- // Декодирование base64
- let package_json = base64::decode(encrypted_data)
- .map_err(|e| JsValue::from_str(&format!("Base64 decode failed: {}", e)))?;
-
- let package_str = String::from_utf8(package_json)
- .map_err(|e| JsValue::from_str(&format!("UTF-8 decode failed: {}", e)))?;
-
- let package: EncryptedPackage = serde_json::from_str(&package_str)
- .map_err(|e| JsValue::from_str(&format!("Deserialization failed: {}", e)))?;
-
- // Вывод ключа
- let mut key_bytes = [0u8; 32];
- pbkdf2::derive(
- pbkdf2::PBKDF2_HMAC_SHA256,
- std::num::NonZeroU32::new(100_000).unwrap(),
- &package.salt,
- password.as_bytes(),
- &mut key_bytes,
- );
-
- let unbound_key = UnboundKey::new(&AES_256_GCM, &key_bytes)
- .map_err(|e| JsValue::from_str(&format!("Key creation failed: {}", e)))?;
- let key = LessSafeKey::new(unbound_key);
-
- // Расшифровка
- let mut encrypted_data = package.data;
- let iv_array: [u8; 12] = package.iv.try_into()
- .map_err(|_| JsValue::from_str("Invalid IV length"))?;
-
- let decrypted = key.open_in_place(aead::Nonce::assume_unique_for_key(iv_array), aead::Aad::empty(), &mut encrypted_data)
- .map_err(|e| JsValue::from_str(&format!("Decryption failed: {}", e)))?;
-
- String::from_utf8(decrypted.to_vec())
- .map_err(|e| JsValue::from_str(&format!("UTF-8 conversion failed: {}", e)))
- }
-
- // Генерация ключевой пары ECDSA P-384
- #[wasm_bindgen]
- pub fn generate_ecdsa_keypair(&self) -> Result {
- let rng = &self.rng;
- let key_pair_doc = EcdsaKeyPair::generate_pkcs8(&ECDSA_P384_SHA384_ASN1_SIGNING, rng)
- .map_err(|e| JsValue::from_str(&format!("Key generation failed: {}", e)))?;
-
- let key_pair = EcdsaKeyPair::from_pkcs8(&ECDSA_P384_SHA384_ASN1_SIGNING, key_pair_doc.as_ref())
- .map_err(|e| JsValue::from_str(&format!("Key pair parsing failed: {}", e)))?;
-
- let private_key = key_pair_doc.as_ref().to_vec();
- let public_key = key_pair.public_key().as_ref().to_vec();
-
- let keypair = CryptoKeyPair {
- private_key,
- public_key,
- algorithm: "ECDSA".to_string(),
- curve: "P-384".to_string(),
- };
-
- Ok(serde_wasm_bindgen::to_value(&keypair)?)
- }
-
- // Подпись данных
- #[wasm_bindgen]
- pub fn sign_data(&self, private_key_bytes: &[u8], data: &str) -> Result, JsValue> {
- let key_pair = EcdsaKeyPair::from_pkcs8(&ECDSA_P384_SHA384_ASN1_SIGNING, private_key_bytes)
- .map_err(|e| JsValue::from_str(&format!("Invalid private key: {}", e)))?;
-
- let signature = key_pair.sign(&self.rng, data.as_bytes())
- .map_err(|e| JsValue::from_str(&format!("Signing failed: {}", e)))?;
-
- Ok(signature.as_ref().to_vec())
- }
-
- // Проверка подписи
- #[wasm_bindgen]
- pub fn verify_signature(&self, public_key_bytes: &[u8], signature: &[u8], data: &str) -> Result {
- let public_key = ring::signature::UnparsedPublicKey::new(&ECDSA_P384_SHA384_ASN1, public_key_bytes);
-
- match public_key.verify(data.as_bytes(), signature) {
- Ok(_) => Ok(true),
- Err(_) => Ok(false),
- }
- }
-
- // Вычисление отпечатка ключа
- #[wasm_bindgen]
- pub fn calculate_key_fingerprint(&self, key_data: &[u8]) -> String {
- let digest = ring::digest::digest(&SHA256, key_data);
- hex::encode(&digest.as_ref()[..12])
- }
-
- // Генерация кода верификации
- #[wasm_bindgen]
- pub fn generate_verification_code(&self) -> String {
- let mut bytes = [0u8; 6];
- self.rng.fill(&mut bytes).unwrap();
-
- bytes.iter()
- .map(|b| format!("{:02X}", b))
- .collect::>()
- .chunks(2)
- .map(|chunk| chunk.join(""))
- .collect::>()
- .join("-")
- }
-
- // Генерация вызова для взаимной аутентификации
- #[wasm_bindgen]
- pub fn generate_mutual_auth_challenge(&self) -> Result {
- let mut challenge = vec![0u8; 48];
- self.rng.fill(&mut challenge).unwrap();
-
- let mut nonce = vec![0u8; 16];
- self.rng.fill(&mut nonce).unwrap();
-
- let auth_challenge = AuthChallenge {
- challenge,
- timestamp: current_timestamp(),
- nonce,
- version: "4.0".to_string(),
- };
-
- Ok(serde_wasm_bindgen::to_value(&auth_challenge)?)
- }
-
- // Очистка сообщения от вредоносного содержимого
- #[wasm_bindgen]
- pub fn sanitize_message(&self, message: &str) -> Result {
- if message.len() > 2000 {
- return Err(JsValue::from_str("Message too long"));
- }
-
- let sanitized = message
- .replace("
-