From 1e4e1746395eb9c22fb01d46669f3da10820b34a Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Sat, 13 Apr 2024 13:55:31 +0900 Subject: [PATCH] Update tutorial --- docs/tutorial/23.md | 417 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 417 insertions(+) create mode 100644 docs/tutorial/23.md diff --git a/docs/tutorial/23.md b/docs/tutorial/23.md new file mode 100644 index 0000000..ff0807f --- /dev/null +++ b/docs/tutorial/23.md @@ -0,0 +1,417 @@ + +## Encrypt and decrypt with default options + +#### Encrypt + +
+Output + +``` +$ tird + + MENU + ——————————————————————————————————————————— + 0. Exit 1. Info + 2. Encrypt 3. Decrypt + 4. Embed 5. Extract + 6. Encrypt & embed 7. Extract & decrypt + 8. Create w/ random 9. Overwrite w/ random + ——————————————————————————————————————————— +[01] Select an option [0-9]: 2 +I: action #2: encrypt file contents +[02] Use custom settings? (Y/N, default=N): +I: use custom settings: False +[06] File to encrypt: file1 +I: path: "file1"; size: 500000 B, 488.3 KiB +[07] Output (encrypted) file: file2 +I: path: "file2" +[10] Comments (optional, up to 512 B): +I: comments will be shown as: [None] +[11] Keyfile path (optional): +[12] Passphrase (optional): +I: receiving keying material is completed +W: no keyfile or passphrase specified! +I: deriving keys... +I: keys derived in 1.9s +I: processing, reading, writing... +I: written 594646 B, 580.7 KiB, 100.0% in 0.0s, avg 93.8 MiB/s +I: padding location in output file: + [16; 71269] -- 71253 B, 69.6 KiB + [571845; 594630] -- 22785 B, 22.3 KiB +I: action is completed + + MENU + ——————————————————————————————————————————— + 0. Exit 1. Info + 2. Encrypt 3. Decrypt + 4. Embed 5. Extract + 6. Encrypt & embed 7. Extract & decrypt + 8. Create w/ random 9. Overwrite w/ random + ——————————————————————————————————————————— +[01] Select an option [0-9]: +``` + +
+ +
+Screenshot + +![Screenshot](https://i.imgur.com/uZY88k1.png) +
+ +#### Decrypt + +
+Output + +``` +$ tird + + MENU + ——————————————————————————————————————————— + 0. Exit 1. Info + 2. Encrypt 3. Decrypt + 4. Embed 5. Extract + 6. Encrypt & embed 7. Extract & decrypt + 8. Create w/ random 9. Overwrite w/ random + ——————————————————————————————————————————— +[01] Select an option [0-9]: 3 +I: action #3: decrypt file contents +[02] Use custom settings? (Y/N, default=N): +I: use custom settings: False +[06] File to decrypt: file2 +I: path: "file2"; size: 594646 B, 580.7 KiB +[07] Output (decrypted) file: file3 +I: path: "file3" +[11] Keyfile path (optional): +[12] Passphrase (optional): +I: receiving keying material is completed +W: no keyfile or passphrase specified! +I: deriving keys... +I: keys derived in 1.9s +I: processing, reading, writing... +I: comments: [None] +I: decryption is completed +I: integrity/authenticity verification: OK +I: written 500000 B, 488.3 KiB, 100.0% in 0.0s, avg 78.0 MiB/s +I: action is completed + + MENU + ——————————————————————————————————————————— + 0. Exit 1. Info + 2. Encrypt 3. Decrypt + 4. Embed 5. Extract + 6. Encrypt & embed 7. Extract & decrypt + 8. Create w/ random 9. Overwrite w/ random + ——————————————————————————————————————————— +[01] Select an option [0-9]: +``` +
+ +
+Screenshot + +![Screenshot](https://i.imgur.com/MsaoqoZ.png) +
+ +#### Encrypt with debug + +
+Output + +``` +$ tird -d +W: debug messages enabled! + + MENU + ——————————————————————————————————————————— + 0. Exit 1. Info + 2. Encrypt 3. Decrypt + 4. Embed 5. Extract + 6. Encrypt & embed 7. Extract & decrypt + 8. Create w/ random 9. Overwrite w/ random + ——————————————————————————————————————————— +[01] Select an option [0-9]: 2 +I: action #2: encrypt file contents +[02] Use custom settings? (Y/N, default=N): +I: use custom settings: False +D: Argon2 time cost: 4 +D: max padding size, %: 20 +D: use fake MAC tag: False +[06] File to encrypt: file1 +D: real path: "/home/user/file1" +D: opening file "file1" in mode "rb" +D: opened file (object): <_io.BufferedReader name='file1'> +I: path: "file1"; size: 500000 B, 488.3 KiB +D: ciphertext_size: 500512 +D: min_cryptoblob_size: 500608 +D: max_pad: 100101 +D: max_cryptoblob_size: 600709 +[07] Output (encrypted) file: file2 +D: real path: "/home/user/file2" +D: opening file "file2" in mode "wb" +D: opened file (object): <_io.BufferedWriter name='file2'> +I: path: "file2" +[10] Comments (optional, up to 512 B): +D: comments_bytes: [b'\xd7wmT\x99X\xe7\xff`;\xd7\x01\xc6\xf1\xfcK,\x14\x18\x1bEc\x1f9a=\xcc\x89\x85\xaf9\xc9C\xe1E\xe3\xe1@E\xc8\xc2\x10\xe5\\\x90\xcfuN$\xfaB\xa7y\xd8/\xa2\x8f\xd5\x80X\xabS4\xf9\x8f\xf2~\xbb\xd9W\x06\x1d\xd5\xa6\n\xc2{\xbbx\xd4\x94:#L\xd8\xcf~B:\xe8q\x869\t,\xd3\xc4\t\xacW\xac\xba2\xccT@.\xbc\xfc\x8a\x91\x05BQIT\x19\xc4\xd1`un\x12\x18\xe3\x9b\x8a\x91o\x9e\xd0l\xa7\xa0t+\xb8\xaa\x83\xd3h)+x\x004\xa6\x81\x184\xad\xa2\x0b,i\x02\xf2\xf9t\x0eJX\xc4@\xe1\x0b7fOd\x07\x91\xfd\xd2\x18\xe2\xed\xbe\xf2\x1d\x8d\xbd s\xd9\xf2\'\x9b\n\xfb\xeaqWB\xbb\xcbRU\x93\xe5\xab\xbbSNV\xcf\x9c\x0cq\xe8\xa77\x0fe\xc4d\x95\xe3\xc5\xdfC\xbc\x13\x93\xa3\t\x86\xca\x16\xbemg\x87\xc8fm\x04\xf5X\x9c\xcd\xe9\x83\xb6\xce)\x05\xe8B\xb5\x1d2\xeep\xf1\xab\xcfem\xfd\x8fIR\x94\x17\x1d_\x9b\xea*\xe9-n\xe0{\xf8N;\xbcx\x9fy\x11\xcfY\xb2\xd5\x7f9\xcb\xa2r\x9d\x04V\x0e3A\x82\xb4\xf9\xcb\xae\x90<\x8e"t\xe1\xb9\xb67U,mr\xa1\xec\xa6cl%\x15@"\xc1\x0c\xc89\xe5\x9d\xf2\xd4\x01\xc9\xbf\x9a\xe6%v\xd3-.\x04\xbc\\\xae\xc3\x15\xa9Q*\xae\xaae\x03\x818\x02\x02\xc2\xc3pu\x93\x93\xa9v\xc7bE\x17y/\xd2\x97\x1f\x94\xc2\n\xe6{W\xf1\x06i\xb8\xfc\xfa\xd0*6\xc4>\xa5\x8c\xdf\xe3\xf5\xd2\x0c\x18\xf7\xf3\x9eA\xe8c~\xc9\x15\xdf\xc8\xef}7~\xc3\rV\x02\x1cS\x00\x97\xfb\xe1\xaeK\x84\x10\xb1\xb5?|\xc2q\x0eQ \xca\xf3=\xa2z\xe9\xb0E\xffr\x1fo\xee\x17^)\x95\xed\xfa\xae/q\xd1\xb7\xf3\xa1\xef\x89\xa5\x12\xd8\x83\xbf\xa60\xfe@\xc9dZ\x8b\xeb\x98\xb0\xd4i\xfc\x06(\xb4\xfc\xd7\x14\xb2\xe7A\xe5\xfd]\x0b\xbd\xb3*Z\x91\r\xe0\xb1@\xc6\xf5\x92'] +I: comments will be shown as: [None] +D: salt handling... +D: blake2_salt: a20236e32c5b95210e344d4d7ef33743 +D: argon2_salt: e6a4418bbb3b940fc52605579d5c4d00 +D: header_salt: a20236e32c5b9521e6a4418bbb3b940f +D: footer_salt: 0e344d4d7ef33743c52605579d5c4d00 +D: salt handling is completed +[11] Keyfile path (optional): +W: entered passphrases will be displayed! +[12] Passphrase (optional): +I: receiving keying material is completed +W: no keyfile or passphrase specified! +D: receiving user input is completed +D: current positions: if=0, of=0 +D: argon2_password: + 79a68c1bff3bd55c60907aa10e1b09b664d5279511f83b5d3c198adff919a58ebab17a09e9986f9dc3730e2524bac24a91e8faa4d3d1d5bf06b057aad555179a +I: deriving keys... +D: argon2_tag: + 1370df6f6ece2b92752b3fe6029467d19d3f0798dd871b13b8adbb32d26d3dec2335015a02654a9fff8c1eed6a146d868eb5c02f692db8b13f9fb10562b869ec9594d6576de2c49c9ad96c159e417508e58929056bd46528cddec41f3be8f6cea502a46b0d0f035741ecce1ee63e3ae4ab5fec94ca0120e5af6b9a333c01c547 +D: enc_key: + 1370df6f6ece2b92752b3fe6029467d19d3f0798dd871b13b8adbb32d26d3dec +D: pad_key: + 2335015a02654a9fff8c1eed6a146d868eb5c02f692db8b13f9fb10562b869ec +D: mac_key: + 9594d6576de2c49c9ad96c159e417508e58929056bd46528cddec41f3be8f6cea502a46b0d0f035741ecce1ee63e3ae4ab5fec94ca0120e5af6b9a333c01c547 +I: keys derived in 1.9s +D: pad_from_ciphertext()... +D: rnd_bytes: + 2335015a02654a9fff8c1eed6a146d86 +D: rnd_int: + 178682925912521203675000892408496993571 +D: rnd_int/RND_SPACE: + 0.5251019249964151 +D: header_footer_pads()... +D: rnd_bytes: + 8eb5c02f692db8b13f9fb10562b869ec +D: rnd_int: + 314246737904875458161957461897334797710 +D: rnd_int/RND_SPACE: + 0.9234881629287828 +D: pad_size: 52563 B, 51.3 KiB +D: header_pad_size: 11654 B, 11.4 KiB +D: footer_pad_size: 40909 B, 40.0 KiB +D: contents size: 500000 B, 488.3 KiB +D: cryptoblob size: 553171 B, 540.2 KiB +D: output data size: 553171 B, 540.2 KiB +I: processing, reading, writing... +D: writing header_salt... +D: header_salt is written +D: current positions: if=0, of=16 +D: handling header padding... +D: handling header padding is completed +D: current positions: if=0, of=11670 +D: handling comments... +D: nonce counter: 1, nonce: 010000000000000000000000 +D: comments (padded binary) found in plain and encrypted forms +D: encrypted comments (size=512) is written +D: handling comments is completed +D: current positions: if=0, of=12182 +D: handling input file contents... +D: nonce counter: 2, nonce: 020000000000000000000000 +D: contents chunk (size=131072) is written +D: current positions: if=131072, of=143254 +D: nonce counter: 3, nonce: 030000000000000000000000 +D: contents chunk (size=131072) is written +D: current positions: if=262144, of=274326 +D: nonce counter: 4, nonce: 040000000000000000000000 +D: contents chunk (size=131072) is written +D: current positions: if=393216, of=405398 +D: nonce counter: 5, nonce: 050000000000000000000000 +D: contents chunk (size=106784) is written +D: handling input file contents is completed +D: encryption is completed +D: current positions: if=500000, of=512182 +D: handling MAC tag... +D: found MAC tag: + 2add92401cbf84727c53cc23994b0acff0978ca27506ca09c8caa3a80b09c825c1ddd5832437936d42a579247edc7c9e7c219636ff2740ac0541712755387273 +D: fake MAC tag: + cb5c49bc50afc5672c5619b74fa29034e08de2631cf40e36e29d51180d68d4e2b6d251487b30a53a63658a5903d81d64449a78e8b36ecdfbf333ec4936312361 +D: MAC tag to write: + 2add92401cbf84727c53cc23994b0acff0978ca27506ca09c8caa3a80b09c825c1ddd5832437936d42a579247edc7c9e7c219636ff2740ac0541712755387273 +D: MAC tag is written +D: handling MAC tag is completed +D: current positions: if=500000, of=512246 +D: handling footer padding... +D: handling footer padding is completed +D: current positions: if=500000, of=553155 +D: writing footer_salt... +I: written 553171 B, 540.2 KiB, 100.0% in 0.0s, avg 76.7 MiB/s +D: footer_salt is written +D: current positions: if=500000, of=553171 +D: expected output data size: 553171 B +D: written 553171 B +I: padding location in output file: + [16; 11670] -- 11654 B, 11.4 KiB + [512246; 553155] -- 40909 B, 40.0 KiB +D: closing <_io.BufferedReader name='file1'> +D: <_io.BufferedReader name='file1'> closed +D: closing <_io.BufferedWriter name='file2'> +D: <_io.BufferedWriter name='file2'> closed +I: action is completed + + MENU + ——————————————————————————————————————————— + 0. Exit 1. Info + 2. Encrypt 3. Decrypt + 4. Embed 5. Extract + 6. Encrypt & embed 7. Extract & decrypt + 8. Create w/ random 9. Overwrite w/ random + ——————————————————————————————————————————— +[01] Select an option [0-9]: +``` +
+ +#### Decrypt with debug + +
+Output + +``` +$ tird -d +W: debug messages enabled! + + MENU + ——————————————————————————————————————————— + 0. Exit 1. Info + 2. Encrypt 3. Decrypt + 4. Embed 5. Extract + 6. Encrypt & embed 7. Extract & decrypt + 8. Create w/ random 9. Overwrite w/ random + ——————————————————————————————————————————— +[01] Select an option [0-9]: 3 +I: action #3: decrypt file contents +[02] Use custom settings? (Y/N, default=N): +I: use custom settings: False +D: Argon2 time cost: 4 +D: max padding size, %: 20 +[06] File to decrypt: file2 +D: real path: "/home/user/file2" +D: opening file "file2" in mode "rb" +D: opened file (object): <_io.BufferedReader name='file2'> +I: path: "file2"; size: 553171 B, 540.2 KiB +[07] Output (decrypted) file: file3 +D: real path: "/home/user/file3" +D: opening file "file3" in mode "wb" +D: opened file (object): <_io.BufferedWriter name='file3'> +I: path: "file3" +D: salt handling... +D: header_salt has been read +D: current positions: if=16, of=0 +D: move to position 553155 in <_io.BufferedReader name='file2'> +D: current position: before footer_salt +D: current positions: if=553155, of=0 +D: footer_salt has been read +D: current positions: if=553171, of=0 +D: move to position 16 in <_io.BufferedReader name='file2'> +D: returned to the position after header_salt +D: current positions: if=16, of=0 +D: blake2_salt: a20236e32c5b95210e344d4d7ef33743 +D: argon2_salt: e6a4418bbb3b940fc52605579d5c4d00 +D: header_salt: a20236e32c5b9521e6a4418bbb3b940f +D: footer_salt: 0e344d4d7ef33743c52605579d5c4d00 +D: salt handling is completed +[11] Keyfile path (optional): +W: entered passphrases will be displayed! +[12] Passphrase (optional): +I: receiving keying material is completed +W: no keyfile or passphrase specified! +D: receiving user input is completed +D: current positions: if=16, of=0 +D: argon2_password: + 79a68c1bff3bd55c60907aa10e1b09b664d5279511f83b5d3c198adff919a58ebab17a09e9986f9dc3730e2524bac24a91e8faa4d3d1d5bf06b057aad555179a +I: deriving keys... +D: argon2_tag: + 1370df6f6ece2b92752b3fe6029467d19d3f0798dd871b13b8adbb32d26d3dec2335015a02654a9fff8c1eed6a146d868eb5c02f692db8b13f9fb10562b869ec9594d6576de2c49c9ad96c159e417508e58929056bd46528cddec41f3be8f6cea502a46b0d0f035741ecce1ee63e3ae4ab5fec94ca0120e5af6b9a333c01c547 +D: enc_key: + 1370df6f6ece2b92752b3fe6029467d19d3f0798dd871b13b8adbb32d26d3dec +D: pad_key: + 2335015a02654a9fff8c1eed6a146d868eb5c02f692db8b13f9fb10562b869ec +D: mac_key: + 9594d6576de2c49c9ad96c159e417508e58929056bd46528cddec41f3be8f6cea502a46b0d0f035741ecce1ee63e3ae4ab5fec94ca0120e5af6b9a333c01c547 +I: keys derived in 1.9s +D: pad_from_padded_ciphertext()... +D: rnd_bytes: + 2335015a02654a9fff8c1eed6a146d86 +D: rnd_int: + 178682925912521203675000892408496993571 +D: rnd_int/RND_SPACE: + 0.5251019249964151 +D: header_footer_pads()... +D: rnd_bytes: + 8eb5c02f692db8b13f9fb10562b869ec +D: rnd_int: + 314246737904875458161957461897334797710 +D: rnd_int/RND_SPACE: + 0.9234881629287828 +D: pad_size: 52563 B, 51.3 KiB +D: header_pad_size: 11654 B, 11.4 KiB +D: footer_pad_size: 40909 B, 40.0 KiB +D: contents size: 500000 B, 488.3 KiB +D: cryptoblob size: 553171 B, 540.2 KiB +D: output data size: 500000 B, 488.3 KiB +I: processing, reading, writing... +D: handling header padding... +D: move to position 11654 in <_io.BufferedReader name='file2'> +D: handling header padding is completed +D: current positions: if=11670, of=0 +D: handling comments... +D: nonce counter: 1, nonce: 010000000000000000000000 +D: comments (padded binary) found in plain and encrypted forms +I: comments: [None] +D: handling comments is completed +D: current positions: if=12182, of=0 +D: writing output file contents... +D: nonce counter: 2, nonce: 020000000000000000000000 +D: contents chunk (size=131072) is written +D: current positions: if=143254, of=131072 +D: nonce counter: 3, nonce: 030000000000000000000000 +D: contents chunk (size=131072) is written +D: current positions: if=274326, of=262144 +D: nonce counter: 4, nonce: 040000000000000000000000 +D: contents chunk (size=131072) is written +D: current positions: if=405398, of=393216 +D: nonce counter: 5, nonce: 050000000000000000000000 +D: contents chunk (size=106784) is written +D: handling input file contents is completed +D: current positions: if=512182, of=500000 +I: decryption is completed +D: handling MAC tag... +D: found MAC tag: + 2add92401cbf84727c53cc23994b0acff0978ca27506ca09c8caa3a80b09c825c1ddd5832437936d42a579247edc7c9e7c219636ff2740ac0541712755387273 +D: read MAC tag: + 2add92401cbf84727c53cc23994b0acff0978ca27506ca09c8caa3a80b09c825c1ddd5832437936d42a579247edc7c9e7c219636ff2740ac0541712755387273 +D: found_mac_tag is equal to read_mac_tag +I: integrity/authenticity verification: OK +D: handling MAC tag is completed +D: current positions: if=512246, of=500000 +D: handling footer padding... +D: move to position 40909 in <_io.BufferedReader name='file2'> +D: handling footer padding is completed +D: current positions: if=553155, of=500000 +I: written 500000 B, 488.3 KiB, 100.0% in 0.0s, avg 75.6 MiB/s +D: expected output data size: 500000 B +D: written 500000 B +D: closing <_io.BufferedReader name='file2'> +D: <_io.BufferedReader name='file2'> closed +D: closing <_io.BufferedWriter name='file3'> +D: <_io.BufferedWriter name='file3'> closed +I: action is completed + + MENU + ——————————————————————————————————————————— + 0. Exit 1. Info + 2. Encrypt 3. Decrypt + 4. Embed 5. Extract + 6. Encrypt & embed 7. Extract & decrypt + 8. Create w/ random 9. Overwrite w/ random + ——————————————————————————————————————————— +[01] Select an option [0-9]: +``` +