started enduser docs
This commit is contained in:
		
							parent
							
								
									cf9bb7b4bf
								
							
						
					
					
						commit
						ea950ad69f
					
				
					 9 changed files with 33 additions and 389 deletions
				
			
		
							
								
								
									
										5
									
								
								Makefile
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								Makefile
									
										
									
									
									
								
							|  | @ -15,9 +15,6 @@ build: | |||
| 	rm -rf $(CURDIR)/dist | ||||
| 	$(JSPKGMAN) run vite build | ||||
| 
 | ||||
| wasm-pack: | ||||
| 	wasm-pack build $(CURDIR)/wasm --target web | ||||
| 	cp $(CURDIR)/wasm/pkg/crypttool_wasm_bg.wasm $(CURDIR)/src/lib/crypttool.wasm | ||||
| 
 | ||||
| docker: | ||||
| 	podman build -t docker.io/jmbitci/crypttool . | ||||
|  | @ -30,7 +27,5 @@ docker: | |||
| #TODO get rid of -f and check whether files exist instead
 | ||||
| clean: | ||||
| 		rm -f $(CURDIR)/src/lib/crypttool.wasm | ||||
| 		rm -rf $(CURDIR)/wasm/pkg/* | ||||
| 		rm -rf $(CURDIR)/wasm/target/* | ||||
| 		rm -rf $(CURDIR)/node_modules/* | ||||
| 		rm -rf $(CURDIR)/dist | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| # Crypttool | ||||
| # [Crypttool](https://crypttool.jmbit.de/) | ||||
| ## A website to encrypt and decrypt files offline in the Browser | ||||
| This Project is more of a proof of concept than an actually useful Application, but it essentially wants to solve the Issue of sending and recieving encrypted Files via E-Mail or other means.  | ||||
| The Idea of this Project is to do all of the Encryption client-side using Javascript or WebAssembly, so the Website will work without any Server and can be packaged as a single html file and distributed this way. | ||||
|  |  | |||
							
								
								
									
										29
									
								
								docs/index.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								docs/index.md
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| # Crypttool Docs | ||||
| 
 | ||||
| Crypttool is an open source utility to de- and encrypt files using a symmetrical key.  | ||||
| The emphasis is on using simple to use web interface to allow anyone to use symmetric encryption for e.g. Email  | ||||
| attachments without installing additional software. | ||||
| 
 | ||||
| The application runs entirely in the Browser and does not send any Data to the webserver beyond the main requests. | ||||
| 
 | ||||
| ## Usage: | ||||
| 
 | ||||
| ### 1. Password Generation | ||||
| The Password field is populated randomly on every page load using the [getRandomValues](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues)  | ||||
| function of the web browsers crypto API. Because this application (currently) does not use any cookies, it does not  | ||||
| persist the password across sessions.   | ||||
| If you want to use your own password, you can supply it by entering it in the password field and clicking "Update". Be | ||||
| careful when using a password that isn't truly randomly created, since the whole cryptography of this application is | ||||
| built on this string. Thus it is strongly advised to use a randomly generated password or passphrase. | ||||
| 
 | ||||
| ### 2. Encrypting a File | ||||
| To encrypt a file, you just need to drag it to the field containing the "Encrypt" button and press | ||||
| the "Encrypt button". Your browser will now encrypt the file and "download" it. The Encryption is handled using the | ||||
| [encrypt](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt) method of the  | ||||
| [SubtleCrypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) API. | ||||
| 
 | ||||
| ### 3. Decrypting a File | ||||
| To decrypt a file, first enter the password that was used to encrypt it in the "Password" field and click "Update". | ||||
| Then, drag the encrypted file to the field containing the "Decrypt" button. | ||||
| After pressing the "Decrypt" button, your browser should decrypt the file using the [decrypt](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/decrypt) | ||||
| method of the SubtleCrypto API and "download" the cleartext file. | ||||
|  | @ -55,8 +55,6 @@ function getKey(keyMaterial: CryptoKey) { | |||
| /* | ||||
| Derive a key from a password supplied by the user, and use the key | ||||
| to encrypt the message. | ||||
| Update the "ciphertextValue" box with a representation of part of | ||||
| the ciphertext. | ||||
| */ | ||||
| export async function encryptFile(file: File) { | ||||
|   let keyMaterial = await getKeyMaterial(); | ||||
|  | @ -81,9 +79,8 @@ export async function encryptFile(file: File) { | |||
| Derive a key from a password supplied by the user, and use the key | ||||
| to decrypt the ciphertext. | ||||
| If the ciphertext was decrypted successfully, | ||||
| update the "decryptedValue" box with the decrypted value. | ||||
| If there was an error decrypting, | ||||
| update the "decryptedValue" box with an error message. | ||||
| return the decryptet files blob, if the decryption failed, | ||||
| update the "errorMessage" box with an error message. | ||||
| */ | ||||
| export async function decryptFileContent(base64Encoded: string) { | ||||
|   //prepare cryptography
 | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ function generateRandomString(length: number): string { | |||
|   let result = ''; | ||||
|   while (result.length < length) { | ||||
|     const array = new Uint8Array(1); | ||||
|     // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
 | ||||
|     self.crypto.getRandomValues(array); | ||||
|     const charCode: number = array[0]; | ||||
|     if ( 33 < charCode && charCode < 126 ) { | ||||
|  |  | |||
							
								
								
									
										1
									
								
								wasm/.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								wasm/.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -1 +0,0 @@ | |||
| target/* | ||||
							
								
								
									
										336
									
								
								wasm/Cargo.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										336
									
								
								wasm/Cargo.lock
									
										
									
										generated
									
									
									
								
							|  | @ -1,336 +0,0 @@ | |||
| # This file is automatically @generated by Cargo. | ||||
| # It is not intended for manual editing. | ||||
| version = 3 | ||||
| 
 | ||||
| [[package]] | ||||
| name = "aes" | ||||
| version = "0.7.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" | ||||
| dependencies = [ | ||||
|  "cfg-if", | ||||
|  "cipher", | ||||
|  "cpufeatures", | ||||
|  "opaque-debug", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "base64" | ||||
| version = "0.13.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "block-buffer" | ||||
| version = "0.9.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" | ||||
| dependencies = [ | ||||
|  "block-padding", | ||||
|  "generic-array", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "block-modes" | ||||
| version = "0.8.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "2cb03d1bed155d89dce0f845b7899b18a9a163e148fd004e1c28421a783e2d8e" | ||||
| dependencies = [ | ||||
|  "block-padding", | ||||
|  "cipher", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "block-padding" | ||||
| version = "0.2.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "bumpalo" | ||||
| version = "3.11.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "byteorder" | ||||
| version = "1.4.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "cfg-if" | ||||
| version = "1.0.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "cipher" | ||||
| version = "0.3.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" | ||||
| dependencies = [ | ||||
|  "generic-array", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "cpufeatures" | ||||
| version = "0.2.5" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" | ||||
| dependencies = [ | ||||
|  "libc", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "crc-any" | ||||
| version = "2.4.3" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "774646b687f63643eb0f4bf13dc263cb581c8c9e57973b6ddf78bda3994d88df" | ||||
| dependencies = [ | ||||
|  "debug-helper", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "crypttool-wasm" | ||||
| version = "0.1.0" | ||||
| dependencies = [ | ||||
|  "magic-crypt", | ||||
|  "wasm-bindgen", | ||||
|  "web-sys", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "debug-helper" | ||||
| version = "0.3.13" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "f578e8e2c440e7297e008bb5486a3a8a194775224bbc23729b0dbdfaeebf162e" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "des" | ||||
| version = "0.7.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "ac41dd49fb554432020d52c875fc290e110113f864c6b1b525cd62c7e7747a5d" | ||||
| dependencies = [ | ||||
|  "byteorder", | ||||
|  "cipher", | ||||
|  "opaque-debug", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "digest" | ||||
| version = "0.9.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" | ||||
| dependencies = [ | ||||
|  "generic-array", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "generic-array" | ||||
| version = "0.14.6" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" | ||||
| dependencies = [ | ||||
|  "typenum", | ||||
|  "version_check", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "js-sys" | ||||
| version = "0.3.60" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" | ||||
| dependencies = [ | ||||
|  "wasm-bindgen", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "libc" | ||||
| version = "0.2.139" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "log" | ||||
| version = "0.4.17" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" | ||||
| dependencies = [ | ||||
|  "cfg-if", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "magic-crypt" | ||||
| version = "3.1.12" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "0196bd5c76f5f51d7d6563545f86262fef4c82d75466ba6f6d359c40a523318d" | ||||
| dependencies = [ | ||||
|  "aes", | ||||
|  "base64", | ||||
|  "block-modes", | ||||
|  "crc-any", | ||||
|  "des", | ||||
|  "digest", | ||||
|  "md-5", | ||||
|  "sha2", | ||||
|  "tiger", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "md-5" | ||||
| version = "0.9.1" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15" | ||||
| dependencies = [ | ||||
|  "block-buffer", | ||||
|  "digest", | ||||
|  "opaque-debug", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "once_cell" | ||||
| version = "1.17.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "opaque-debug" | ||||
| version = "0.3.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "proc-macro2" | ||||
| version = "1.0.49" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" | ||||
| dependencies = [ | ||||
|  "unicode-ident", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "quote" | ||||
| version = "1.0.23" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" | ||||
| dependencies = [ | ||||
|  "proc-macro2", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "sha2" | ||||
| version = "0.9.9" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" | ||||
| dependencies = [ | ||||
|  "block-buffer", | ||||
|  "cfg-if", | ||||
|  "cpufeatures", | ||||
|  "digest", | ||||
|  "opaque-debug", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "syn" | ||||
| version = "1.0.107" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" | ||||
| dependencies = [ | ||||
|  "proc-macro2", | ||||
|  "quote", | ||||
|  "unicode-ident", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "tiger" | ||||
| version = "0.1.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "443e531cbcf9de83258cfef70bcd56c91188de5819ebd4b19c85f589e0617005" | ||||
| dependencies = [ | ||||
|  "block-buffer", | ||||
|  "byteorder", | ||||
|  "digest", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "typenum" | ||||
| version = "1.16.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "unicode-ident" | ||||
| version = "1.0.6" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "version_check" | ||||
| version = "0.9.4" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "wasm-bindgen" | ||||
| version = "0.2.83" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" | ||||
| dependencies = [ | ||||
|  "cfg-if", | ||||
|  "wasm-bindgen-macro", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "wasm-bindgen-backend" | ||||
| version = "0.2.83" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" | ||||
| dependencies = [ | ||||
|  "bumpalo", | ||||
|  "log", | ||||
|  "once_cell", | ||||
|  "proc-macro2", | ||||
|  "quote", | ||||
|  "syn", | ||||
|  "wasm-bindgen-shared", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "wasm-bindgen-macro" | ||||
| version = "0.2.83" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" | ||||
| dependencies = [ | ||||
|  "quote", | ||||
|  "wasm-bindgen-macro-support", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "wasm-bindgen-macro-support" | ||||
| version = "0.2.83" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" | ||||
| dependencies = [ | ||||
|  "proc-macro2", | ||||
|  "quote", | ||||
|  "syn", | ||||
|  "wasm-bindgen-backend", | ||||
|  "wasm-bindgen-shared", | ||||
| ] | ||||
| 
 | ||||
| [[package]] | ||||
| name = "wasm-bindgen-shared" | ||||
| version = "0.2.83" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" | ||||
| 
 | ||||
| [[package]] | ||||
| name = "web-sys" | ||||
| version = "0.3.60" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" | ||||
| dependencies = [ | ||||
|  "js-sys", | ||||
|  "wasm-bindgen", | ||||
| ] | ||||
|  | @ -1,23 +0,0 @@ | |||
| [package] | ||||
| name = "crypttool-wasm" | ||||
| version = "0.1.0" | ||||
| edition = "2021" | ||||
| 
 | ||||
| # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||||
| 
 | ||||
| [lib] | ||||
| crate-type = ["cdylib", "rlib"] | ||||
| 
 | ||||
| [dependencies] | ||||
| wasm-bindgen = "0.2" | ||||
| magic-crypt = "3.1.12" | ||||
| 
 | ||||
| [dependencies.web-sys] | ||||
| version = "*" | ||||
| features = [ | ||||
|   'Document', | ||||
|   'Element', | ||||
|   'HtmlElement', | ||||
|   'Node', | ||||
|   'Window', | ||||
| ] | ||||
|  | @ -1,18 +0,0 @@ | |||
| use wasm_bindgen::prelude::*; | ||||
| use magic_crypt::{new_magic_crypt, MagicCryptTrait}; | ||||
| 
 | ||||
| // Hacky implementation for a wasm file to en- and decrypt files
 | ||||
| 
 | ||||
| #[wasm_bindgen] | ||||
| pub fn encrypt(password: &str, plain_base64: &str) -> String { | ||||
|     let crypt = new_magic_crypt!(password, 256); | ||||
|     let encrypted_base64 = crypt.encrypt_str_to_base64(plain_base64); | ||||
|     return encrypted_base64; | ||||
| } | ||||
| 
 | ||||
| #[wasm_bindgen] | ||||
| pub fn decrypt(password: &str, encrypted_base64: &str) -> String { | ||||
|     let crypt = new_magic_crypt!(password, 256); | ||||
|     let plain_base64 = crypt.decrypt_base64_to_string(encrypted_base64); | ||||
|     return plain_base64.unwrap(); | ||||
| } | ||||
		Loading…
	
	Add table
		
		Reference in a new issue