Author SHA1 Message Date
Leon Etienne 6842db6434 professionalize wording 2026-08-08 17:02:53 +02:00
leonetienne 77fca14226 fix git remote ids 2024-09-26 10:26:48 +02:00
Leon Etienne 9aac8d89c0 Install graphviz for doxygen pipelione 2022-10-25 22:18:42 +00:00
Leon Etienne 94e3d846eb Fix readme cropping for doxygen 2022-10-25 22:15:33 +00:00
Leon Etienne fdb2bedd8c Add build status to readme 2022-10-25 21:47:43 +00:00
Leon Etienne 65bfee850d Import working drone config 2022-10-25 21:44:05 +00:00
Leon Etienne 64727ecf7e Cicd-test 2022-10-25 20:10:42 +00:00
Leonetienne 90eb7dbaea Merge branch 'master' of gitea.leonetienne.de:leonetienne/GCrypt 2022-08-12 09:13:10 +02:00
Leonetienne a61546b9be CLI: Fix typo in option name 2022-08-12 09:12:44 +02:00
Leonetienne c9cb647ab8 typo readme 2022-07-07 14:09:26 +02:00
Leonetienne d39a90a412 Improved tests for block class 2022-06-04 00:01:21 +02:00
Leonetienne 35f577dafa Adjust makefile doxygen 2022-06-01 21:35:46 +02:00
Leonetienne 70f1c7b551 Fix image alt tag in readme, that screwed with doxygen 2022-06-01 21:01:38 +02:00
Leonetienne 7012950d6d Update project name in doxygen config 2022-06-01 20:59:26 +02:00
Leonetienne c99b1fd8ee Add docs link to readme 2022-06-01 20:58:31 +02:00
Leonetienne a2922a142f Readme 2022-06-01 19:57:55 +02:00
Leonetienne 819fe3e859 Readme 2022-06-01 19:56:08 +02:00
Leonetienne b4f97a7336 Update readme 2022-06-01 19:55:06 +02:00
Leonetienne df71552ce9 Merge branch 'master' of gitea.leonetienne.de:leonetienne/GCrypt 2022-06-01 16:54:25 +02:00
Leonetienne 8bda01aa53 A bit of code cleanup 2022-06-01 16:54:14 +02:00
Leonetienne 02dd904c79 Fix compiler warning on macos 2022-06-01 15:28:17 +02:00
Leonetienne 2bf492594a Typo readme 2022-06-01 04:01:12 +02:00
Leonetienne b49b76478f Fixes in cli readme 2022-06-01 03:58:48 +02:00
Leonetienne 612b662e9e Update help page in cli readme 2022-06-01 03:47:58 +02:00
Leonetienne a3af14c025 Wording in help page 2022-06-01 03:46:27 +02:00
Leonetienne 2649d89aba Adjust links in readme 2022-06-01 03:32:01 +02:00
Leonetienne 71416651c0 Merge branch 'feature/relaunch' into master 2022-06-01 03:30:55 +02:00
Leonetienne 14bcfb5f88 Add parameter to control progress report interval 2022-06-01 03:30:18 +02:00
Leonetienne 57adf4419a Implement progress output 2022-06-01 03:29:05 +02:00
Leonetienne 55e7092ed4 Update CLI readme 2022-06-01 02:49:49 +02:00
Leonetienne 00dc5916ab Fix docs 2022-06-01 02:34:16 +02:00
Leonetienne 51d4c95965 Doxygen now using makefile 2022-06-01 02:34:11 +02:00
Leonetienne a319e81a38 Fix outdated information in readme 2022-06-01 02:29:20 +02:00
Leonetienne 47756e713d Docs 2022-06-01 02:23:51 +02:00
Leonetienne 403292df64 Bump version 2022-06-01 02:10:08 +02:00
Leonetienne 67212e31b6 Added module for hashing 2022-06-01 02:09:49 +02:00
Leonetienne b3db6ef6c8 Implemented low space-complexity stream decoding for all ioformats 2022-06-01 01:53:52 +02:00
Leonetienne cc5c96b5eb Fix wrong minlen for base ugh 2022-06-01 01:49:10 +02:00
Leonetienne 33622d148b Fix wrong minlen for base uwu 2022-05-31 22:19:01 +02:00
Leonetienne cc6b05dd12 Sophisticated and bug-fixed DataOutput/InputLayer, and added ModuleDecryption 2022-05-31 21:40:13 +02:00
Leonetienne 1a11f406e4 Now by-default prepending a newline to stdout 2022-05-31 18:26:02 +02:00
Leonetienne 628491998d Integrated DataOutputLayer to ModuleGenerateKey 2022-05-31 18:19:12 +02:00
Leonetienne 313c265c0b More streamlined handling of io bases 2022-05-31 18:17:29 +02:00
Leonetienne 30289214f8 Added encryption module, and data output layer 2022-05-31 17:35:05 +02:00
Leonetienne ada88e8139 Fix Indentation 2022-05-31 17:07:45 +02:00
Leonetienne 9d63835876 Add additional methods to data ingestion layer 2022-05-31 15:32:17 +02:00
Leonetienne 7c764c3a11 Forbid instanciation of static classes 2022-05-31 14:28:17 +02:00
Leonetienne ff2355f154 Implement relevant methods for DataIngestionLayer 2022-05-31 14:25:23 +02:00
Leonetienne 22499d5d89 Fix typo in comment 2022-05-31 10:44:05 +02:00
Leonetienne 8a2b219d49 Implement unified istream for ingestion layer 2022-05-27 18:26:48 +02:00
Leonetienne 3695fea2b6 Rename cmake cli target name 2022-05-27 17:21:30 +02:00
Leonetienne 12a6c7c457 Change module GenerateKeyfile to more versatile GenerateKey, which doesnt have to output to a file 2022-05-27 17:21:10 +02:00
Leonetienne e43a3deac9 Implement GenerateKeyfile module 2022-05-27 17:04:16 +02:00
Leonetienne 9f80e326dd Fix Key::WriteToFile method being not const qualified 2022-05-27 17:04:05 +02:00
Leonetienne 9ed4d95036 A bit of cleanup 2022-05-27 16:50:18 +02:00
Leonetienne aac31ea5dc Removed bunch of garbage from main.cpp 2022-05-27 16:14:24 +02:00
Leonetienne 19edd5ce66 More tests on data formatter 2022-05-27 16:08:24 +02:00
Leonetienne facca04951 Added tests for recoding single blocks to all formats 2022-05-27 15:56:28 +02:00
Leonetienne 774dd4d152 Renamed method, and added first test to cli 2022-05-27 15:34:16 +02:00
Leonetienne 0a555855a3 Added test project 2022-05-27 15:27:33 +02:00
Leonetienne 2daf76f30e A bit of error handling and better comments 2022-05-27 14:47:26 +02:00
Leonetienne f858e7fc1b Remove unused code 2022-05-27 03:34:02 +02:00
Leonetienne 33436e55a5 Fix multiple definition issue 2022-05-27 03:30:11 +02:00
Leonetienne cb5fe0fd37 Proper include guard 2022-05-27 03:29:51 +02:00
Leonetienne 5412133e42 Move blocklenght lookup table to Bases.h 2022-05-27 03:27:43 +02:00
Leonetienne 050300c594 Better comment. 2022-05-27 03:01:47 +02:00
Leonetienne 798fdf22b7 Added multiblocks methods to data formatter 2022-05-27 03:00:34 +02:00
Leonetienne 7d9221a1de Got block conversions working... 2022-05-27 02:13:05 +02:00
Leonetienne 651641661e Implemented to-block methods of dataformatter 2022-05-26 23:22:04 +02:00
Leonetienne 8b90a5bf07 Implement output formatting module 2022-05-26 22:30:59 +02:00
Leonetienne cad651eab5 Add exceptoins 2022-05-26 22:06:04 +02:00
Leonetienne bf94eae8e7 Added module PrepareKey 2022-05-26 21:56:15 +02:00
Leonetienne 4ca536a38a Add Configuration class to intelligently decide default settings 2022-05-26 21:32:55 +02:00
Leonetienne 81c106c2c6 Adjust cli parameter definitions 2022-05-26 20:19:15 +02:00
Leonetienne 78c5c00944 GCryptLib version bump 2022-05-26 19:59:16 +02:00
Leonetienne 1ea89541f9 More streamlined naming scheme for digestion method of ghash 2022-05-26 19:57:14 +02:00
Leonetienne 3f990b30d0 Fix dangling hint 2022-05-26 19:34:58 +02:00
Leonetienne 3a7802d314 Fix apple linker problem 2022-05-26 19:25:40 +02:00
Leonetienne 44248914ef Added how2compile to readme 2022-05-26 19:05:35 +02:00
Leonetienne 5b0ea29b7b Add new visualizations 2022-05-26 18:59:59 +02:00
Leonetienne e7d44a871d Fix bad filename in visualization 2022-05-26 18:59:05 +02:00
Leonetienne 700a308fd6 Tidied up example/static test executables 2022-05-26 18:24:44 +02:00
Leonetienne 1cd465c977 Got rid of flexblocks 2022-05-26 15:47:24 +02:00
Leonetienne 05b29f32df Many methods now using vectors of blocks instead of flexblocks 2022-05-26 15:04:39 +02:00
Leonetienne f4df0f9ae5 Added a method to GPrng to get a random uint32, which is about twice as fast as GetRandom<uint32_t> 2022-05-26 12:52:04 +02:00
Leonetienne 6a5b9c1287 Made GPrng::GetBlock() faster by a factor of 100 2022-05-26 12:23:27 +02:00
Leonetienne bd9511c8b9 Unstupided mathematical expression 2022-05-26 04:40:23 +02:00
Leonetienne 02d12513f7 Fix markup in artifacts 2022-05-26 04:25:02 +02:00
Leonetienne 85f418307f Add artifact directory 2022-05-26 04:23:32 +02:00
Leonetienne 11e9d85a4f Implement direct file i/o to- and from blocks. 2022-05-26 04:22:42 +02:00
Leonetienne 1678e28b4d Add additional jumbling-up in feistel rounds 2022-05-26 02:44:22 +02:00
Leonetienne bdbf0ffa64 Implement new sbox, reduction, and expansion function 2022-05-26 02:30:16 +02:00
Leonetienne 02b27093ef Replaced halfblock with instanciation of Basic_Block 2022-05-26 00:55:24 +02:00
Leonetienne 3e1fa2c00a Typo in comment 2022-05-25 16:51:38 +02:00
Leonetienne c108b4a4b0 Templatified block class 2022-05-25 16:38:16 +02:00
Leonetienne ecd64e8637 Merge origin feature/relaunch into feature/relaunch 2022-05-25 14:58:40 +02:00
Leonetienne c66271eafe Fix macos compile issue 2022-05-25 14:57:40 +02:00
Leonetienne a55a8f221f Cipher now using new block class 2022-05-25 13:05:25 +02:00
Leonetienne 96ba2485c4 Added bitshift methods to block class 2022-05-25 12:54:26 +02:00
Leonetienne d8a39ad46f Add SetBit, and FlipBit methods to block 2022-05-24 23:51:17 +02:00
Leonetienne ac4b389efc Add GetBit() method to Block 2022-05-24 23:18:39 +02:00
Leonetienne 6c09afefba Implemented remaining operands for block class 2022-05-24 22:09:06 +02:00
Leonetienne ddbc209b58 Fix blanklines in block.cpp 2022-05-24 01:07:00 +02:00
Leonetienne 4848f887d4 Add comment 2022-05-24 01:05:45 +02:00
Leonetienne 30a57caadc [Progress:] Completely re-done Block class to not use bitsets, and provide custom operators. 2022-05-24 01:02:06 +02:00
Leonetienne 41dc2ef65e Experimentally implement matrix-mult 2022-05-23 22:42:14 +02:00
Leonetienne 873101833d Typo readme 2022-05-22 23:27:23 +02:00
Leonetienne 8873207901 Merge branch 'feature/relaunch' of gitea.leonetienne.de:leonetienne/GCrypt into feature/relaunch 2022-05-22 23:23:31 +02:00
Leonetienne c97bfd5742 Wording readme 2022-05-22 23:22:54 +02:00
Leonetienne f5b045c488 Fix typo in readme 2022-05-22 23:16:57 +02:00
Leonetienne c28f3b45cf Fix typo in readme 2022-05-22 22:39:25 +02:00
Leonetienne 66a909c4d7 Fix invalid html in readme 2022-05-22 21:25:53 +02:00
Leonetienne e4941429cc Added another visualization to readme 2022-05-22 21:22:02 +02:00
Leon Etienne 950c591fc9 Put images in readme next to each other 2022-05-22 20:55:04 +02:00
Leonetienne e5685e1c59 Readme and visualizations 2022-05-22 20:40:56 +02:00
Leonetienne 4ca1b74e24 Improved security 2022-05-22 20:13:41 +02:00
Leonetienne 4ce86b8f54 Add method to load and save keyfiles 2022-05-22 17:54:26 +02:00
Leonetienne 994c5dc503 Fix include guard 2022-05-22 17:54:04 +02:00
Leonetienne 57b1d7ac2a Indentation 2022-05-22 17:32:54 +02:00
Leonetienne e67067b65c Bump gcryptlib version 2022-05-22 17:30:15 +02:00
Leonetienne e6567f3c8b Now using actual include guards 2022-05-22 17:29:38 +02:00
Leonetienne 4d74153e92 Implemented a Key::Random() method 2022-05-22 17:24:56 +02:00
Leonetienne 5770a0d45a Implemented GPrng pnrg 2022-05-22 16:54:40 +02:00
Leonetienne 0c1bbf362e GHash now uses a full-size key for the cipher 2022-05-22 14:30:24 +02:00
Leonetienne 3e2f269962 Adjusted tests 2022-05-22 14:29:21 +02:00
Leonetienne f52758f1ce Cmake make colored output 2022-05-22 14:21:21 +02:00
Leonetienne bc780f3a4f Moved utility functions to cpp file 2022-05-22 14:13:10 +02:00
Leonetienne 9fce71e8ba Added padding direction option for Util::StringToBitblock 2022-05-22 13:54:03 +02:00
Leonetienne 1a2a74cdac Implemented a key class 2022-05-22 13:45:40 +02:00
Leonetienne c0b6bff8b7 Renamed class GCryptWrapper to GWrapper 2022-05-22 13:07:40 +02:00
Leonetienne 875e9a34f9 Renamed method DigestFlexblock to CipherFlexblock, and made it public 2022-05-22 13:04:20 +02:00
Leonetienne 923e37bde6 Renamed class Hasher to GHash 2022-05-22 12:55:39 +02:00
Leonetienne 2590bd9a48 Renamed class Cipher to GCipher 2022-05-22 12:51:58 +02:00
Leonetienne d45ca55ff3 Cmake specify color output as always 2022-05-22 12:51:29 +02:00
Leonetienne 9328e74461 Fix warning 2022-05-22 12:31:48 +02:00
Leonetienne 0d1755a22e Warnings are now treated as errors 2022-05-22 12:31:33 +02:00
Leonetienne 52ff44edce Added class for hashing, that is now used for password to key transformation 2022-05-22 00:23:10 +02:00
Leonetienne a7a30e13bf Implemented digestion (feeding one block at a time) 2022-05-21 20:41:09 +02:00
Leonetienne 549838e7d1 Added warning to readme 2022-05-21 20:40:44 +02:00
Leonetienne 038ae1001a Merge branch 'master' of gitea.leonetienne.de:leonetienne/GCrypt 2022-05-20 10:19:45 +02:00
Leon Etienne 41737fe5f2 Fix typo in code samples in readme 2022-05-17 14:16:17 +02:00
Leonetienne 39d175ae1c Add ideas for cli relaunch 2022-05-17 12:32:30 +02:00
Leonetienne 1d790ee10f Switch to https-based git submodules 2022-05-17 01:31:26 +02:00
Leonetienne 0c55485c9a Version bump gcryptlib 2022-05-17 01:18:00 +02:00
Leonetienne 65f4f6e582 Step 2: fix broken submodule config 2022-05-17 01:17:48 +02:00
Leonetienne f60cd3877e Step 1: fix broken submodule config 2022-05-17 01:16:25 +02:00
Leonetienne cd5f0f0646 Streamlined workflow of GCryptCLI 2022-05-17 01:13:42 +02:00
Leonetienne d64eea5be7 unbloated readme 2022-05-16 23:49:08 +02:00
Leonetienne 43bbea9f1e Fix dangling var in cmakelist of gcryptlib 2022-05-16 23:47:36 +02:00
Leonetienne be0a30bae9 Update readme 2022-05-16 23:37:14 +02:00
Leonetienne 2945d2a285 Translated encryption/decryption consistency tests to catch2 2022-05-16 23:26:29 +02:00
Leonetienne 43f8608073 Translated password2key transformation collision resistance tests to catch2 2022-05-16 23:03:55 +02:00
Leonetienne 0f004f54c6 Renamed legacy wrapper class to GCryptWrapper 2022-05-16 22:50:52 +02:00
Leonetienne 8608bf66ca Translated gcrypt wrapper tests to catch2 2022-05-16 22:47:41 +02:00
Leonetienne a00ec743d7 GCryptLib: Fix include paths 2022-05-16 22:35:28 +02:00
Leonetienne 28ddbfc79e Fix directory structure for include dir 2022-05-16 22:22:42 +02:00
Leonetienne 5ed81cda80 Doxygen adjustment, and better directory name for GCryptLib 2022-05-16 22:19:20 +02:00
Leonetienne 243181944e Gcryptlib: new brace style, and moved to Leonetienne namespace 2022-05-16 22:15:34 +02:00
Leonetienne 70af3619a2 retabbed gcryptlib 2022-05-16 22:01:52 +02:00
Leonetienne 8948515be5 New directory structure for the crypto library 2022-05-16 21:43:22 +02:00
Leon Etienne f220b5aefc Added comment 2022-05-16 00:21:01 +02:00
Leonetienne 3657838a6e Remove bunch of microsoft crap 2022-05-13 22:28:01 +02:00
Leon Etienne b6ed2001e1 Typos 2022-05-13 22:12:59 +02:00
Leon Etienne 297b5c068b Rename header in cli/readme 2022-05-13 12:46:56 +02:00
Leon Etienne 39fd063fcd Update readme.md 2022-05-13 11:58:34 +02:00
Leon Etienne 4cbd6bfd27 Update documentation for PasswordToKey function 2022-05-13 11:37:08 +02:00
Leon Etienne 520924e018 Update 'readme.md' 2022-04-13 18:56:56 +02:00
Leonetienne 6c0f8cf103 Rename cli cmake target 2022-03-18 17:10:32 +01:00
Leon Etienne 3c2aa9c14a Fix filename 2022-03-16 22:45:56 +01:00
Leonetienne 4969840025 readme 2022-03-16 01:42:19 +01:00
Leonetienne d78bf7775f Update readme 2022-03-16 01:37:53 +01:00
Leonetienne 6a071c764d Implemented hashsum mode 2022-03-16 01:31:28 +01:00
Leonetienne 60340e878a Updated hazelnupp 2022-03-13 19:48:29 +01:00
Leonetienne a88dc386a9 fix broken base uwu 2022-03-13 19:36:29 +01:00
Leonetienne 51bebbc2df more digits for uwu base 2022-03-13 19:23:13 +01:00
Leonetienne f08b1337c7 Fix build command 2022-03-13 19:15:43 +01:00
Leonetienne f522025b6c Fix build command 2022-03-13 19:15:29 +01:00
Leonetienne 193b01b643 Updated installation instructions, and removed useless non-crossplatform binary 2022-03-13 19:13:54 +01:00
Leonetienne 4e7bb762f1 readme 2022-03-13 19:08:09 +01:00
Leonetienne 77dc9c754c more uwu digits and readme 2022-03-13 19:06:14 +01:00
Leonetienne a006c015f6 readme 2022-03-13 18:56:55 +01:00
Leonetienne 830dd66964 More uwu digits, and included warning in readme 2022-03-13 18:55:56 +01:00
Leonetienne 5b8d9f5483 readme 2022-03-13 18:26:24 +01:00
Leonetienne cc447371d4 readme 2022-03-13 18:25:20 +01:00
Leonetienne ab253e06a5 readme 2022-03-13 18:24:11 +01:00
Leonetienne f5a4989b6e readme 2022-03-13 18:23:16 +01:00
Leonetienne e260dbd1f0 Merge branch 'master' of github.com:Leonetienne/GCrypt 2022-03-13 18:22:30 +01:00
16 changed files with 275 additions and 170 deletions
+56
View File
@@ -0,0 +1,56 @@
kind: pipeline
type: kubernetes
name: cicd-pipeline
steps:
- name: Build docs
image: ubuntu
commands:
- apt-get update
- >-
apt-get
install
make
doxygen
graphviz
-y
- cd "GCryptLib/doxygen"
- make
- name: Deploy docs to production
image: ubuntu
environment:
SSH_PRIV:
from_secret: ssh-priv
SSH_PUB:
from_secret: ssh-pub
KNOWN_HOSTS:
from_secret: known-hosts # this is just $(ssh-keyscan -p 2222 leonetienne.de)
commands:
- apt-get update
- >-
apt-get
install
openssh-client
rsync
-y
- eval "$(ssh-agent -s)"
- mkdir -p ~/.ssh
- echo "$SSH_PRIV" > ~/.ssh/id_ed25519
- echo "$SSH_PUB" > ~/.ssh/id_ed25519.pub
- echo "$KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 600 ~/.ssh/id_ed25519
- chmod 644 ~/.ssh/id_ed25519.pub
- chmod 644 ~/.ssh/known_hosts
- ssh-add
- cd "GCryptLib/doxygen"
- >-
rsync
-avz
--recursive
--delete
--delete-excluded
-e
"ssh -o IdentitiesOnly=yes -p 2222"
./build/
doxygen-gcrypt@leonetienne.de:app
+7 -5
View File
@@ -1,15 +1,17 @@
[submodule "StringTools"]
path = StringTools
url = https://gitea.leonetienne.de/leonetienne/StringTools.git
url = https://code.ze.mawtrixx.net/leonetienne/StringTools.git
[submodule "Hazelnupp"]
path = Hazelnupp
url = https://gitea.leonetienne.de/leonetienne/Hazelnupp.git
url = https://code.ze.mawtrixx.net/leonetienne/Hazelnupp.git
[submodule "GeneralUtility"]
path = GeneralUtility
url = https://gitea.leonetienne.de/leonetienne/GeneralUtility.git
url = https://code.ze.mawtrixx.net/leonetienne/GeneralUtility.git
[submodule "GCryptLib/exec/Eule"]
path = GCryptLib/exec/Eule
url = https://gitea.leonetienne.de/leonetienne/Eule.git
url = https://code.ze.mawtrixx.net/leonetienne/Eule.git
[submodule "GCryptLib/exec/BmpPP"]
path = GCryptLib/exec/BmpPP
url = https://gitea.leonetienne.de/leonetienne/BmpPP.git
url = https://code.ze.mawtrixx.net/leonetienne/BmpPP.git
[submodule "BmpPP"]
url = https://code.ze.mawtrixx.net/leonetienne/BmpPP.git
@@ -0,0 +1 @@
<mxfile host="app.diagrams.net" modified="2022-05-17T08:55:29.265Z" agent="5.0 (X11)" etag="82noNgqBrG7hiBNRM9Jy" version="18.0.6"><diagram id="ngb83caThQZh03zxjPih" name="Page-1">7VpNc+I4EP01VJHDUDYEkhwDJDvMMMXWcNjZuWwJq7G1sS2PLALk169alr9hQwhkApULltpS66Pfe2q5aHQGweoPQSLvG6fgN9oWXTU6w0a7bXdvLPVAyzqxXHdvEoMrGDWNcsOUPYExmn7uglGISw0l575kUdno8DAER5ZsRAi+LDebc788akRcqBmmDvHr1r8YlV66Ciu3fwbmeunItmXeBCRtbAyxRyhfFkydu0ZnIDiXSSlYDcDHzUv3Jel3v+VtNjEBodylw7/Bl88/u/F0YP9Yj9rf5uLrl+4n4+WR+Auz4Ea75yt/fcoeVdHF4pBIgo5CF2LJeKjKPlmDUM/mcDS+SLvMRNojtajZFPyUXFvEZ26ox+z9WuAm9H2Yy7xW7XUc79+B0Fi1748ng6//TEc/71RlxiTa5oIH6CrUi48WEhc8Zwoa7QEGVFIWJkUi3PjCFEOKzYMAKCMS/DU6AtCDSI/hY+Zz50EDWduUO2s4HLfU4ztEQPTYi1AyjN7d5B7doUkAcTyg2G5MYllwpF9LwvyIUAo4/pIp9LUtq3XKsbn1Y67XHUc8jNkMN14xGHFHnF8LJhQi0/hA6Ih1ZND5AOuTXvho3kAyJ11Zap0t5nMQowSI2WAsHyrBQa2fFIrbGzsMcvyNxho1WjFCLg1o9e6uFWz1RqeYhEcQmdEjmiosZLGnOyiYKl64+wXgpburhVWuU7UWfBEiATpDS71eekzCNCIOvl2q80nZPBn4qmarolqFZErpb01UJI8yn/gOVluV1s70Wx18wAOQAnmedrg0km/OPLtn6sv8BOmmJ4hXPD06xkjMqeVmvnNhVwWj7S/Q+c4LdJ6yTTo/zHX+gPHbix0hk0w1fgJEHs7YYZGnp6mRiaBmAaJ6iT8zcFGmrUhwB+LYaAbCHJYauVpWmrnXKbbi4UXrkJO+K88sU31NGAfYY7YYI+rITSZzUs4gC42mWdMoHlbuKeRlRUhFxF2CtfPkN59pNFHjJRG0cphNxnqCKwcimUk2zktv/kCjXmQBCo3QJMvE1ccX70a+T0JgOle7Cox1LIG5fIHA8IVMkqlcXSbvRl02E3XyQqIuBZMSwpQXoNIxvVKVM3JcOnZKEhkjQQcVm9+XnUxMaA+dnkxq6QnuMJTyk0EhRdEBMfGimRu/nDY373XWkuq9smyNwknIQEb5Z2XAPpYMdDfIQGXvIKS3eDFXNUcFJGZOebvKewsrJn9gudU1tb9NOywPV4Vmw7WpJEMCrd3sKxurpsUXwoHn78dSXfBAPpdf1QNVDMSGOKQ2AT6RCqnlrxcbYmNG+JOzUOY46FxXjoNqGpks0/QqfiKoOqoCql1xlOxDzZGGSrbs/dHTq6HnXuUGzT7y9aIOJBXgMZmBX8ZPKmOOCrbS3Dr/AkYp+uiriyV7IjPtD3ET4br0Srv9Rnf4fyQ1n5tM5/wjTxFj2wmyldGfrFan23sdKNImfD6P4Shhujolkv82UtplLrVv9iWlvSXZe4aUav/JutDMoHvnCacqkoMn8XhQKF3XoFS7hzUfYH0m5L86A/LffJD/efJnB+dryV91dCzy18Z5C/KnglM874sZefNMaH9zBrS3N31B/OB9hUaX9mXrqldi0mWVsbtSf4Ov7DL3Rvm4Xf+qc3YJub3l6nZa7Dype/d7Scn3pmbV0a68fG1K3rXf4lSu38LPOSe3z+FGbn9cyffIyvfmf9XRsfhfG+dN+F+/k59lVm6/79u4qub/DUua5/+w69z9Bw==</diagram></mxfile>
Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

+24
View File
@@ -0,0 +1,24 @@
* Add a new iobase: bytes.
For cleartext:
Format is ALWAYS raw bytes. That works fine with text, and files.
The iobase ONLY affects ciphertext!
For ciphertext:
format depends..:
If none specified:
- raw bytes if an outputfile is given
- hex if output to stdout
If specified:
Just use the specified iobase. Even if it means dumping bytes to stdout, or writing base-2 to files.
* --intext or --infile should no longer be required. Default behaviour should be reading from stdin.
* No guessing where to output (like file-in got saved to another file beforehand.) Default behaviour should be stdout.
* --progress should output reports to stderr. This way it won't disturb piping the ciphertext to another program.
* Add a module to generate keyfiles.
Should seed a gcrypt prng with std::random_device, and then dump BLOCK_SIZE bits to the specified output.
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef GCRYPTCLI_VERSION_H
#define GCRYPTCLI_VERSION_H
#define GCRYPTCLI_VERSION 0.1251
#define GCRYPTCLI_VERSION 0.12512
#endif
+46 -47
View File
@@ -23,15 +23,14 @@ Have these depencies installed:
6) Compile: `make`.
The executable `gcrypt` should now lie in `build/`.
If you want to use this globally, you could move it to `/usr/bin/`, or some other location in your $PATH.
If you want to use this globally, you could move it to `/usr/bin/`, or some other location in your $PATH. ### Options and flags
### Options and flags
All arguments and flags:
### All arguments and flags:
```
CLI for the GCrypt cipher/obfuscator
Copyright (c) 2022 Leon Etienne
GCrypt v0.236
GCrypt CLI v0.1241
GCryptLib v0.236
GCryptCLI v0.12511
THIS IS EXPERIMENTAL SOFTWARE AND MUST BE CONSIDERED INSECURE. DO NOT USE THIS TO ENCRYPT SENSITIVE DATA! READ THE README FILES ACCESSIBLE AT "https://gitea.leonetienne.de/leonetienne/GCrypt"
==== AVAILABLE PARAMETERS ====
@@ -40,7 +39,11 @@ THIS IS EXPERIMENTAL SOFTWARE AND MUST BE CONSIDERED INSECURE. DO NOT USE THIS T
--iobase-16 VOID incompatibilities=[--iobase-bytes, --iobase-2, --iobase-8, --iobase-64, --iobase-uwu, --iobase-ugh] Interpret and format ciphertexts in base16 (hex)
--progress -p VOID Print digestion progress to stdout. May be advisable for large files, as the cipher is rather slow.
--progress-interval INT default=['1000'] Print digestion progress reports every these many data blocks.
--buffer-input VOID Will read the entire input before beginning any digestion.
--progress -p VOID Print digestion progress to stderr. May be advisable for large files, as the cipher is rather slow.
--cli-version -v VOID Will supply the version of GCryptCLI used.
@@ -50,19 +53,7 @@ THIS IS EXPERIMENTAL SOFTWARE AND MUST BE CONSIDERED INSECURE. DO NOT USE THIS T
--iobase-10 VOID incompatibilities=[--iobase-bytes, --iobase-2, --iobase-8, --iobase-16, --iobase-64, --iobase-uwu, --iobase-ugh] Interpret and format ciphertexts in base10
--ofile -o STRING incompatibilities=[--ostdout, --hash] Write output in this file.
--key -k STRING incompatibilities=[--keyfile, --keyask, --hash] Use this value as a password to extrapolate the encryption key. WARNING: Arguments may be logged by the system!
--keyask -ka VOID incompatibilities=[--key, --keyfile, --hash] Read the encryption key from stdin.
--no-newline VOID Don't postfix stdout output with a newline
--puffer-output VOID Will digest the entire data before initiating any output.
--puffer-input VOID Will read the entire input before beginning any digestion.
--decrypt -d VOID incompatibilities=[--encrypt, --hash, --generate-key] Use decryption module.
--buffer-output VOID Will digest the entire data before initiating any output.
--lib-version VOID Will supply the version of GCryptLib used.
@@ -80,6 +71,16 @@ THIS IS EXPERIMENTAL SOFTWARE AND MUST BE CONSIDERED INSECURE. DO NOT USE THIS T
--generate-key VOID incompatibilities=[--encrypt, --decrypt, --hash] Use the key generation module. Will generate a random key based on hardware events, output it, and exit.
--ofile -o STRING incompatibilities=[--ostdout, --hash] Write output in this file.
--key -k STRING incompatibilities=[--keyfile, --keyask, --hash] Use this value as a password to extrapolate the encryption key. WARNING: Arguments may be logged by the system!
--keyask -ka VOID incompatibilities=[--key, --keyfile, --hash] Read the encryption key from stdin.
--no-newline VOID Don't postfix stdout output with a newline
--decrypt -d VOID incompatibilities=[--encrypt, --hash, --generate-key] Use decryption module.
--hash -h VOID incompatibilities=[--encrypt, --decrypt, --generate-key] Use the GHash hash module to calculate a hashsum.
--intext -it STRING incompatibilities=[--infile] Encrypt this string.
@@ -101,9 +102,8 @@ hello, world!
```
#### What about not using hex?
> :warning: Custom bases are super imperformant.
> Encrypting all text in main.cpp took about two seconds.
> Outputting it in base-64 took just over ONE MINUTE. In base-2 over SEVEN MINUTES. The general trend seems to be, the larger the base, the better it performs.
> :warning: Custom bases are super imperformant. Please only use them for text-based input...
> The larger the base, the exponentially longer it takes to recode.
```sh
$ gcrypt -e --keyask --intext "hello, world!" --iobase-2
@@ -130,44 +130,34 @@ $ gcrypt -e --key "secretpassword" --intext "hello, world!"
```sh
$ gcrypt -e --keyfile "dog.jpg" --intext "hello, world!"
```
> :warning: Some operating systems will log cli arguments! One might find your keyfile!
#### Creating keyfiles
```sh
$ gcrypt --generate-key --ofile "my-keyfile.bin"
```
This will generate a random 512-bit keyfile from hardware events
> :warning: Some operating systems will log cli arguments! One might find your keyfile!
This will generate a random 512-bit keyfile from hardware events and other random sources, if available.
To see how this randomness gets sourced, see [std::random_device](https://en.cppreference.com/w/cpp/numeric/random/random_device).
#### Encrypting files
```sh
$ gcrypt -e --keyask --infile "cat.jpg"
$ gcrypt -e --keyask --infile "cat.jpg" --ofile "cat.jpg.crypt"
```
File `cat.jpg.crypt` will be created.
#### Encrypting files to a target file name
```sh
$ gcrypt -e --keyask --infile "cat.jpg" -o "encrypted_cat.jpg"
```
File `encrypted_cat.jpg` will be created.
#### Decrypting files
```sh
$ gcrypt -d --keyask --infile "cat.jpg.crypt"
$ gcrypt -d --keyask --infile "cat.jpg.crypt" --ofile "decrypted_cat.jpg"
```
File `cat.jpg.crypt.plain` will be created. Its contents match `cat.jpg`
File `decrypted_cat.jpg` will be created. You can now open it again. Its contents match `cat.jpg`.
> :warning: Since this is a block cipher, decrypted files may be tailpadded with a few nullbytes.
#### Decrypting files to a target file name
```sh
$ gcrypt -d --keyask --infile "cat.jpg.crypt" -o "decrypted_cat.jpg"
```
File `decrypted_cat.jpg` will be created. You can now open it again.
#### Encrypting large files takes time. How's the progress?
```sh
$ gcrypt -e --keyask --infile "cat.jpg" --progress
$ gcrypt -e --keyask --infile "cat.jpg" --buffer-input --progress
```
Something along the lines of `Encrypting... (Block 200 / 1148 - 17.4216%)` will be regularly, but not too often, printed to stdout.
Something along the lines of `Encrypting... (Block 200 / 1148 - 17.4216%)` will be regularly, but not too often, printed to stderr.
Obviously, to print progress, we have to know the size of the input. Hence, it has to be buffered.
#### Any cipher can also compute hashsums
```sh
@@ -177,15 +167,16 @@ a96f42c9d97e46b9e1ed7de5182770170d4ef9b7b8264f3fbd89b38dc60c1fe06232653f58560133
$ gcrypt -h --infile "cat.jpg"
fe6bdfb6ec39771c4fdcdc40e52397bcd67fbfef0ad5a15ebbd8b9e4c2a815848b3984eda5ef6f727e9e420c23500c90c42ab80ac5659048be8969357741e3e5
```
The hashsum will always be of size BLOCK_SIZE. That is 512.
The hashsum will always be of size BLOCK_SIZE. That is 512 bits.
#### What version am i running?
Depending on wether you want to know the GCrypt version or the CLI's version,
Depending on whether you want to know the GCryptLib version or the CLI's version,
use either `--cli-version` or `--lib-version`.
It will print out a floating point number.
You can see both in the `--help`-page.
#### I want to stream the output of file en/decryption.
// Easily! If you do not supply any output or input, stdout and stdin will be used instead!
#### Streaming the output of file en/decryption.
Easily! If you do not supply any output or input, stdout and stdin will be used instead!
```sh
# mpv is a media player, as an example
$ gcrypt -d --key "123" --infile "music.mp3.crypt" | mpv -
@@ -195,8 +186,8 @@ $ gcrypt -d --key "123" --infile "music.mp3.crypt" | mpv -
By default, gcrypt will read a block, digest it, and output the result immediately.
Sometimes you don't want that. Use these flags, respectively:
```
--puffer-input # Reads all input to memory before beginning to digest it
--puffer-output # Digests all input before beginning to write any
--buffer-input # Reads all input to memory before beginning to digest it
--buffer-output # Digests all input before beginning to write any
```
## Esoteric data formats
@@ -212,6 +203,14 @@ $ gcrypt -e --keyask --intext "hello, world!" --iobase-ugh
Grr... Wha-? Aah! Aah! Uh-huh... Aah! Grr... Aah! Aah! Uh-huh... Ah... Ugh Grr... Ugh Pft! Nu-uh... Gah! Bah! Huh...? Ah... Uh-huh... Wha-? Pft! Nu-uh... Ugh Wha-? Psh! Agh! Ah... Aah! Nu-uh... Psh! Pft! Nu-uh... Psh! Shh! Gah! Ah... Pft! Gah! Shh! Bah! Gah! Uh-huh... Gah! Duh! Aah! Uh-huh... Er- Nu-uh... Gah! Wha-? Pft! Er- Shh! Ah... Huh...? Er- Wha-? Uh-huh... Ah... Shh! Ugh Bah! Wha-? Uaah! Ah... Nu-uh... Uh-huh... Ugh Pft! Pft! Gah! Shh! Shh! Wha-? Bah! Ugh Grr... Aah! Pft! Nu-uh... Ah... Aah! Agh! Er- Psh! Uaah! Nu-uh... Ugh Wha-? Uh-huh... Shh! Pft! Aah! Agh! Grr... Agh! Agh! Grr... Pft! Wha-? Wha-? Uh-huh... Aah! Ugh Aah! Pft! Gah! Bah! Huh...? Ugh Bah! Uaah! Gah! Bah! Duh! Duh! Uh-huh... Grr... Ah... Grr... Ugh Ah... Pft!
```
Yes, you can send these... *adventorous* texsts to your friends, and they can actually decipher them
back to the original message :). Almost going a bit into the steganography territory here, hehe.
These weird number bases don't impact security at all. This is because they are just that.
Number bases, to represent a bunch of bytes, that is our ciphertext.
These just bring a bit more fun into the big world of cryptography :).
## LICENSE
```
GNU GENERAL PUBLIC LICENSE
+8 -8
View File
@@ -13,8 +13,8 @@ void CommandlineInterface::Init(int argc, const char* const* argv) {
std::stringstream ss;
ss << "CLI for the GCrypt cipher/obfuscator" << std::endl
<< "Copyright (c) 2022 Leon Etienne" << std::endl
<< "GCrypt v" << GCRYPT_VERSION << std::endl
<< "GCrypt CLI v" << GCRYPTCLI_VERSION << std::endl
<< "GCryptLib v" << GCRYPT_VERSION << std::endl
<< "GCryptCLI v" << GCRYPTCLI_VERSION << std::endl
<< "THIS IS EXPERIMENTAL SOFTWARE AND MUST BE CONSIDERED INSECURE. DO NOT USE THIS TO ENCRYPT SENSITIVE DATA! READ THE README FILES ACCESSIBLE AT \"https://gitea.leonetienne.de/leonetienne/GCrypt\"";
nupp.SetBriefDescription(ss.str());
ss.str("");
@@ -102,11 +102,11 @@ void CommandlineInterface::Init(int argc, const char* const* argv) {
nupp.RegisterConstraint("--cli-version", ParamConstraint(true, DATA_TYPE::VOID, {}, false, {}));
nupp.RegisterAbbreviation("-v", "--cli-version");
nupp.RegisterDescription("--puffer-input", "Will read the entire input before beginning any digestion.");
nupp.RegisterConstraint("--puffer-input", ParamConstraint(true, DATA_TYPE::VOID, {}, false, {}));
nupp.RegisterDescription("--buffer-input", "Will read the entire input before beginning any digestion.");
nupp.RegisterConstraint("--buffer-input", ParamConstraint(true, DATA_TYPE::VOID, {}, false, {}));
nupp.RegisterDescription("--puffer-output", "Will digest the entire data before initiating any output.");
nupp.RegisterConstraint("--puffer-output", ParamConstraint(true, DATA_TYPE::VOID, {}, false, {}));
nupp.RegisterDescription("--buffer-output", "Will digest the entire data before initiating any output.");
nupp.RegisterConstraint("--buffer-output", ParamConstraint(true, DATA_TYPE::VOID, {}, false, {}));
nupp.RegisterDescription("--no-newline", "Don't postfix stdout output with a newline");
nupp.RegisterConstraint("--no-newline", ParamConstraint(true, DATA_TYPE::VOID, {}, false, {}));
@@ -173,10 +173,10 @@ void CommandlineInterface::SpecialCompatibilityChecking() {
if (
(nupp.HasParam("--progress")) &&
(!nupp.HasParam("--puffer-input"))
(!nupp.HasParam("--buffer-input"))
) {
CrashWithMsg("--progress requires --puffer-input to work!");
CrashWithMsg("--progress requires --buffer-input to work!");
}
return;
+4 -6
View File
@@ -57,9 +57,7 @@ void DataIngestionLayer::Init() {
}
// Derive from our the current module if we're reading ciphertext or not
if (
(Configuration::activeModule == Configuration::MODULE::DECRYPTION)
) {
if (Configuration::activeModule == Configuration::MODULE::DECRYPTION) {
isReadingCiphertext = true;
}
else {
@@ -325,16 +323,16 @@ bool DataIngestionLayer::ReachedEOF() {
}
bool DataIngestionLayer::IsBlockReady() {
// We're not ready, if we haven't reached EOF, if we should puffer
// We're not ready, if we haven't reached EOF, if we should buffer
// the input.
if (
(CommandlineInterface::Get().HasParam("--puffer-input")) &&
(CommandlineInterface::Get().HasParam("--buffer-input")) &&
(!reachedEof)
) {
return false;
}
// If we're not puffering, just return whether or not
// If we're not buffering, just return whether or not
// we have any blocks...
return blocks.size() > 0;
}
+3 -3
View File
@@ -65,13 +65,13 @@ void DataOutputLayer::WriteBlock() {
}
// Check if we have any block to write
// and if we should (output-puffering)
// and if we should (output-buffering)
// Basically: only output if we have anything to output, and
// if --puffer-output is given, only output once we have reachedEof.
// if --buffer-output is given, only output once we have reachedEof.
if (
(blocks.size() > 0) &&
(
(!CommandlineInterface::Get().HasParam("--puffer-output")) ||
(!CommandlineInterface::Get().HasParam("--buffer-output")) ||
(reachedEof)
)
) {
+1 -1
View File
@@ -1,6 +1,6 @@
all:
# Copy all but the header of the readme here
tail ../../readme.md -n +2 > index.md
tail ../../readme.md -n +9 > index.md
#
# Run doxygen
doxygen doxyfig
+2 -2
View File
@@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
PROJECT_NAME = "Leonetienne/GhettoCrypt"
PROJECT_NAME = "Leonetienne/GCrypt"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
@@ -44,7 +44,7 @@ PROJECT_NUMBER =
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.
PROJECT_BRIEF = "Ghetto (but also super easy) cryptography!"
PROJECT_BRIEF = "An educational cryptography library (GCrypt / GNU Crypt)"
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
+1 -1
View File
@@ -4,7 +4,7 @@
#include <cstdint>
#include <array>
#include <string>
#include <ostream>
#include <iosfwd>
#include <bitset>
namespace Leonetienne::GCrypt {
+37 -36
View File
@@ -9,7 +9,11 @@
// Just to be sure, the compiler will optimize this
// little formula out, let's do it in the preprocessor
#define MAT_INDEX(row, column) (column*4 + row)
namespace {
constexpr std::size_t MAT_INDEX(const std::size_t row, const std::size_t column) {
return column*4 + row;
}
}
namespace Leonetienne::GCrypt {
@@ -148,25 +152,25 @@ namespace Leonetienne::GCrypt {
// Maybe pre-calculate the 1d-index...?
m.Get(0, 0) = (this->Get(0, 0) * o.Get(0, 0)) + (this->Get(0, 1) * o.Get(1, 0)) + (this->Get(0, 2) * o.Get(2, 0)) + (this->Get(0, 3) * o.Get(3, 0));
m.Get(0, 1) = (this->Get(0, 0) * o.Get(0, 1)) + (this->Get(0, 1) * o.Get(1, 1)) + (this->Get(0, 2) * o.Get(2, 1)) + (this->Get(0, 3) * o.Get(3, 1));
m.Get(0, 2) = (this->Get(0, 0) * o.Get(0, 2)) + (this->Get(0, 1) * o.Get(1, 2)) + (this->Get(0, 2) * o.Get(2, 2)) + (this->Get(0, 3) * o.Get(3, 2));
m.Get(0, 3) = (this->Get(0, 0) * o.Get(0, 3)) + (this->Get(0, 1) * o.Get(1, 3)) + (this->Get(0, 2) * o.Get(2, 3)) + (this->Get(0, 3) * o.Get(3, 3));
m.Get(MAT_INDEX(0, 0)) = (this->Get(MAT_INDEX(0, 0)) * o.Get(MAT_INDEX(0, 0))) + (this->Get(MAT_INDEX(0, 1)) * o.Get(MAT_INDEX(1, 0))) + (this->Get(MAT_INDEX(0, 2)) * o.Get(MAT_INDEX(2, 0))) + (this->Get(MAT_INDEX(0, 3)) * o.Get(MAT_INDEX(3, 0)));
m.Get(MAT_INDEX(0, 1)) = (this->Get(MAT_INDEX(0, 0)) * o.Get(MAT_INDEX(0, 1))) + (this->Get(MAT_INDEX(0, 1)) * o.Get(MAT_INDEX(1, 1))) + (this->Get(MAT_INDEX(0, 2)) * o.Get(MAT_INDEX(2, 1))) + (this->Get(MAT_INDEX(0, 3)) * o.Get(MAT_INDEX(3, 1)));
m.Get(MAT_INDEX(0, 2)) = (this->Get(MAT_INDEX(0, 0)) * o.Get(MAT_INDEX(0, 2))) + (this->Get(MAT_INDEX(0, 1)) * o.Get(MAT_INDEX(1, 2))) + (this->Get(MAT_INDEX(0, 2)) * o.Get(MAT_INDEX(2, 2))) + (this->Get(MAT_INDEX(0, 3)) * o.Get(MAT_INDEX(3, 2)));
m.Get(MAT_INDEX(0, 3)) = (this->Get(MAT_INDEX(0, 0)) * o.Get(MAT_INDEX(0, 3))) + (this->Get(MAT_INDEX(0, 1)) * o.Get(MAT_INDEX(1, 3))) + (this->Get(MAT_INDEX(0, 2)) * o.Get(MAT_INDEX(2, 3))) + (this->Get(MAT_INDEX(0, 3)) * o.Get(MAT_INDEX(3, 3)));
m.Get(1, 0) = (this->Get(1, 0) * o.Get(0, 0)) + (this->Get(1, 1) * o.Get(1, 0)) + (this->Get(1, 2) * o.Get(2, 0)) + (this->Get(1, 3) * o.Get(3, 0));
m.Get(1, 1) = (this->Get(1, 0) * o.Get(0, 1)) + (this->Get(1, 1) * o.Get(1, 1)) + (this->Get(1, 2) * o.Get(2, 1)) + (this->Get(1, 3) * o.Get(3, 1));
m.Get(1, 2) = (this->Get(1, 0) * o.Get(0, 2)) + (this->Get(1, 1) * o.Get(1, 2)) + (this->Get(1, 2) * o.Get(2, 2)) + (this->Get(1, 3) * o.Get(3, 2));
m.Get(1, 3) = (this->Get(1, 0) * o.Get(0, 3)) + (this->Get(1, 1) * o.Get(1, 3)) + (this->Get(1, 2) * o.Get(2, 3)) + (this->Get(1, 3) * o.Get(3, 3));
m.Get(MAT_INDEX(1, 0)) = (this->Get(MAT_INDEX(1, 0)) * o.Get(MAT_INDEX(0, 0))) + (this->Get(MAT_INDEX(1, 1)) * o.Get(MAT_INDEX(1, 0))) + (this->Get(MAT_INDEX(1, 2)) * o.Get(MAT_INDEX(2, 0))) + (this->Get(MAT_INDEX(1, 3)) * o.Get(MAT_INDEX(3, 0)));
m.Get(MAT_INDEX(1, 1)) = (this->Get(MAT_INDEX(1, 0)) * o.Get(MAT_INDEX(0, 1))) + (this->Get(MAT_INDEX(1, 1)) * o.Get(MAT_INDEX(1, 1))) + (this->Get(MAT_INDEX(1, 2)) * o.Get(MAT_INDEX(2, 1))) + (this->Get(MAT_INDEX(1, 3)) * o.Get(MAT_INDEX(3, 1)));
m.Get(MAT_INDEX(1, 2)) = (this->Get(MAT_INDEX(1, 0)) * o.Get(MAT_INDEX(0, 2))) + (this->Get(MAT_INDEX(1, 1)) * o.Get(MAT_INDEX(1, 2))) + (this->Get(MAT_INDEX(1, 2)) * o.Get(MAT_INDEX(2, 2))) + (this->Get(MAT_INDEX(1, 3)) * o.Get(MAT_INDEX(3, 2)));
m.Get(MAT_INDEX(1, 3)) = (this->Get(MAT_INDEX(1, 0)) * o.Get(MAT_INDEX(0, 3))) + (this->Get(MAT_INDEX(1, 1)) * o.Get(MAT_INDEX(1, 3))) + (this->Get(MAT_INDEX(1, 2)) * o.Get(MAT_INDEX(2, 3))) + (this->Get(MAT_INDEX(1, 3)) * o.Get(MAT_INDEX(3, 3)));
m.Get(2, 0) = (this->Get(2, 0) * o.Get(0, 0)) + (this->Get(2, 1) * o.Get(1, 0)) + (this->Get(2, 2) * o.Get(2, 0)) + (this->Get(2, 3) * o.Get(3, 0));
m.Get(2, 1) = (this->Get(2, 0) * o.Get(0, 1)) + (this->Get(2, 1) * o.Get(1, 1)) + (this->Get(2, 2) * o.Get(2, 1)) + (this->Get(2, 3) * o.Get(3, 1));
m.Get(2, 2) = (this->Get(2, 0) * o.Get(0, 2)) + (this->Get(2, 1) * o.Get(1, 2)) + (this->Get(2, 2) * o.Get(2, 2)) + (this->Get(2, 3) * o.Get(3, 2));
m.Get(2, 3) = (this->Get(2, 0) * o.Get(0, 3)) + (this->Get(2, 1) * o.Get(1, 3)) + (this->Get(2, 2) * o.Get(2, 3)) + (this->Get(2, 3) * o.Get(3, 3));
m.Get(MAT_INDEX(2, 0)) = (this->Get(MAT_INDEX(2, 0)) * o.Get(MAT_INDEX(0, 0))) + (this->Get(MAT_INDEX(2, 1)) * o.Get(MAT_INDEX(1, 0))) + (this->Get(MAT_INDEX(2, 2)) * o.Get(MAT_INDEX(2, 0))) + (this->Get(MAT_INDEX(2, 3)) * o.Get(MAT_INDEX(3, 0)));
m.Get(MAT_INDEX(2, 1)) = (this->Get(MAT_INDEX(2, 0)) * o.Get(MAT_INDEX(0, 1))) + (this->Get(MAT_INDEX(2, 1)) * o.Get(MAT_INDEX(1, 1))) + (this->Get(MAT_INDEX(2, 2)) * o.Get(MAT_INDEX(2, 1))) + (this->Get(MAT_INDEX(2, 3)) * o.Get(MAT_INDEX(3, 1)));
m.Get(MAT_INDEX(2, 2)) = (this->Get(MAT_INDEX(2, 0)) * o.Get(MAT_INDEX(0, 2))) + (this->Get(MAT_INDEX(2, 1)) * o.Get(MAT_INDEX(1, 2))) + (this->Get(MAT_INDEX(2, 2)) * o.Get(MAT_INDEX(2, 2))) + (this->Get(MAT_INDEX(2, 3)) * o.Get(MAT_INDEX(3, 2)));
m.Get(MAT_INDEX(2, 3)) = (this->Get(MAT_INDEX(2, 0)) * o.Get(MAT_INDEX(0, 3))) + (this->Get(MAT_INDEX(2, 1)) * o.Get(MAT_INDEX(1, 3))) + (this->Get(MAT_INDEX(2, 2)) * o.Get(MAT_INDEX(2, 3))) + (this->Get(MAT_INDEX(2, 3)) * o.Get(MAT_INDEX(3, 3)));
m.Get(3, 0) = (this->Get(3, 0) * o.Get(0, 0)) + (this->Get(3, 1) * o.Get(1, 0)) + (this->Get(3, 2) * o.Get(2, 0)) + (this->Get(3, 3) * o.Get(3, 0));
m.Get(3, 1) = (this->Get(3, 0) * o.Get(0, 1)) + (this->Get(3, 1) * o.Get(1, 1)) + (this->Get(3, 2) * o.Get(2, 1)) + (this->Get(3, 3) * o.Get(3, 1));
m.Get(3, 2) = (this->Get(3, 0) * o.Get(0, 2)) + (this->Get(3, 1) * o.Get(1, 2)) + (this->Get(3, 2) * o.Get(2, 2)) + (this->Get(3, 3) * o.Get(3, 2));
m.Get(3, 3) = (this->Get(3, 0) * o.Get(0, 3)) + (this->Get(3, 1) * o.Get(1, 3)) + (this->Get(3, 2) * o.Get(2, 3)) + (this->Get(3, 3) * o.Get(3, 3));
m.Get(MAT_INDEX(3, 0)) = (this->Get(MAT_INDEX(3, 0)) * o.Get(MAT_INDEX(0, 0))) + (this->Get(MAT_INDEX(3, 1)) * o.Get(MAT_INDEX(1, 0))) + (this->Get(MAT_INDEX(3, 2)) * o.Get(MAT_INDEX(2, 0))) + (this->Get(MAT_INDEX(3, 3)) * o.Get(MAT_INDEX(3, 0)));
m.Get(MAT_INDEX(3, 1)) = (this->Get(MAT_INDEX(3, 0)) * o.Get(MAT_INDEX(0, 1))) + (this->Get(MAT_INDEX(3, 1)) * o.Get(MAT_INDEX(1, 1))) + (this->Get(MAT_INDEX(3, 2)) * o.Get(MAT_INDEX(2, 1))) + (this->Get(MAT_INDEX(3, 3)) * o.Get(MAT_INDEX(3, 1)));
m.Get(MAT_INDEX(3, 2)) = (this->Get(MAT_INDEX(3, 0)) * o.Get(MAT_INDEX(0, 2))) + (this->Get(MAT_INDEX(3, 1)) * o.Get(MAT_INDEX(1, 2))) + (this->Get(MAT_INDEX(3, 2)) * o.Get(MAT_INDEX(2, 2))) + (this->Get(MAT_INDEX(3, 3)) * o.Get(MAT_INDEX(3, 2)));
m.Get(MAT_INDEX(3, 3)) = (this->Get(MAT_INDEX(3, 0)) * o.Get(MAT_INDEX(0, 3))) + (this->Get(MAT_INDEX(3, 1)) * o.Get(MAT_INDEX(1, 3))) + (this->Get(MAT_INDEX(3, 2)) * o.Get(MAT_INDEX(2, 3))) + (this->Get(MAT_INDEX(3, 3)) * o.Get(MAT_INDEX(3, 3)));
return m;
}
@@ -183,25 +187,25 @@ namespace Leonetienne::GCrypt {
// Maybe pre-calculate the 1d-index...?
this->Get(0, 0) = (m.Get(0, 0) * o.Get(0, 0)) + (m.Get(0, 1) * o.Get(1, 0)) + (m.Get(0, 2) * o.Get(2, 0)) + (m.Get(0, 3) * o.Get(3, 0));
this->Get(0, 1) = (m.Get(0, 0) * o.Get(0, 1)) + (m.Get(0, 1) * o.Get(1, 1)) + (m.Get(0, 2) * o.Get(2, 1)) + (m.Get(0, 3) * o.Get(3, 1));
this->Get(0, 2) = (m.Get(0, 0) * o.Get(0, 2)) + (m.Get(0, 1) * o.Get(1, 2)) + (m.Get(0, 2) * o.Get(2, 2)) + (m.Get(0, 3) * o.Get(3, 2));
this->Get(0, 3) = (m.Get(0, 0) * o.Get(0, 3)) + (m.Get(0, 1) * o.Get(1, 3)) + (m.Get(0, 2) * o.Get(2, 3)) + (m.Get(0, 3) * o.Get(3, 3));
this->Get(MAT_INDEX(0, 0)) = (m.Get(MAT_INDEX(0, 0)) * o.Get(MAT_INDEX(0, 0))) + (m.Get(MAT_INDEX(0, 1)) * o.Get(MAT_INDEX(1, 0))) + (m.Get(MAT_INDEX(0, 2)) * o.Get(MAT_INDEX(2, 0))) + (m.Get(MAT_INDEX(0, 3)) * o.Get(MAT_INDEX(3, 0)));
this->Get(MAT_INDEX(0, 1)) = (m.Get(MAT_INDEX(0, 0)) * o.Get(MAT_INDEX(0, 1))) + (m.Get(MAT_INDEX(0, 1)) * o.Get(MAT_INDEX(1, 1))) + (m.Get(MAT_INDEX(0, 2)) * o.Get(MAT_INDEX(2, 1))) + (m.Get(MAT_INDEX(0, 3)) * o.Get(MAT_INDEX(3, 1)));
this->Get(MAT_INDEX(0, 2)) = (m.Get(MAT_INDEX(0, 0)) * o.Get(MAT_INDEX(0, 2))) + (m.Get(MAT_INDEX(0, 1)) * o.Get(MAT_INDEX(1, 2))) + (m.Get(MAT_INDEX(0, 2)) * o.Get(MAT_INDEX(2, 2))) + (m.Get(MAT_INDEX(0, 3)) * o.Get(MAT_INDEX(3, 2)));
this->Get(MAT_INDEX(0, 3)) = (m.Get(MAT_INDEX(0, 0)) * o.Get(MAT_INDEX(0, 3))) + (m.Get(MAT_INDEX(0, 1)) * o.Get(MAT_INDEX(1, 3))) + (m.Get(MAT_INDEX(0, 2)) * o.Get(MAT_INDEX(2, 3))) + (m.Get(MAT_INDEX(0, 3)) * o.Get(MAT_INDEX(3, 3)));
this->Get(1, 0) = (m.Get(1, 0) * o.Get(0, 0)) + (m.Get(1, 1) * o.Get(1, 0)) + (m.Get(1, 2) * o.Get(2, 0)) + (m.Get(1, 3) * o.Get(3, 0));
this->Get(1, 1) = (m.Get(1, 0) * o.Get(0, 1)) + (m.Get(1, 1) * o.Get(1, 1)) + (m.Get(1, 2) * o.Get(2, 1)) + (m.Get(1, 3) * o.Get(3, 1));
this->Get(1, 2) = (m.Get(1, 0) * o.Get(0, 2)) + (m.Get(1, 1) * o.Get(1, 2)) + (m.Get(1, 2) * o.Get(2, 2)) + (m.Get(1, 3) * o.Get(3, 2));
this->Get(1, 3) = (m.Get(1, 0) * o.Get(0, 3)) + (m.Get(1, 1) * o.Get(1, 3)) + (m.Get(1, 2) * o.Get(2, 3)) + (m.Get(1, 3) * o.Get(3, 3));
this->Get(MAT_INDEX(1, 0)) = (m.Get(MAT_INDEX(1, 0)) * o.Get(MAT_INDEX(0, 0))) + (m.Get(MAT_INDEX(1, 1)) * o.Get(MAT_INDEX(1, 0))) + (m.Get(MAT_INDEX(1, 2)) * o.Get(MAT_INDEX(2, 0))) + (m.Get(MAT_INDEX(1, 3)) * o.Get(MAT_INDEX(3, 0)));
this->Get(MAT_INDEX(1, 1)) = (m.Get(MAT_INDEX(1, 0)) * o.Get(MAT_INDEX(0, 1))) + (m.Get(MAT_INDEX(1, 1)) * o.Get(MAT_INDEX(1, 1))) + (m.Get(MAT_INDEX(1, 2)) * o.Get(MAT_INDEX(2, 1))) + (m.Get(MAT_INDEX(1, 3)) * o.Get(MAT_INDEX(3, 1)));
this->Get(MAT_INDEX(1, 2)) = (m.Get(MAT_INDEX(1, 0)) * o.Get(MAT_INDEX(0, 2))) + (m.Get(MAT_INDEX(1, 1)) * o.Get(MAT_INDEX(1, 2))) + (m.Get(MAT_INDEX(1, 2)) * o.Get(MAT_INDEX(2, 2))) + (m.Get(MAT_INDEX(1, 3)) * o.Get(MAT_INDEX(3, 2)));
this->Get(MAT_INDEX(1, 3)) = (m.Get(MAT_INDEX(1, 0)) * o.Get(MAT_INDEX(0, 3))) + (m.Get(MAT_INDEX(1, 1)) * o.Get(MAT_INDEX(1, 3))) + (m.Get(MAT_INDEX(1, 2)) * o.Get(MAT_INDEX(2, 3))) + (m.Get(MAT_INDEX(1, 3)) * o.Get(MAT_INDEX(3, 3)));
this->Get(2, 0) = (m.Get(2, 0) * o.Get(0, 0)) + (m.Get(2, 1) * o.Get(1, 0)) + (m.Get(2, 2) * o.Get(2, 0)) + (m.Get(2, 3) * o.Get(3, 0));
this->Get(2, 1) = (m.Get(2, 0) * o.Get(0, 1)) + (m.Get(2, 1) * o.Get(1, 1)) + (m.Get(2, 2) * o.Get(2, 1)) + (m.Get(2, 3) * o.Get(3, 1));
this->Get(2, 2) = (m.Get(2, 0) * o.Get(0, 2)) + (m.Get(2, 1) * o.Get(1, 2)) + (m.Get(2, 2) * o.Get(2, 2)) + (m.Get(2, 3) * o.Get(3, 2));
this->Get(2, 3) = (m.Get(2, 0) * o.Get(0, 3)) + (m.Get(2, 1) * o.Get(1, 3)) + (m.Get(2, 2) * o.Get(2, 3)) + (m.Get(2, 3) * o.Get(3, 3));
this->Get(MAT_INDEX(2, 0)) = (m.Get(MAT_INDEX(2, 0)) * o.Get(MAT_INDEX(0, 0))) + (m.Get(MAT_INDEX(2, 1)) * o.Get(MAT_INDEX(1, 0))) + (m.Get(MAT_INDEX(2, 2)) * o.Get(MAT_INDEX(2, 0))) + (m.Get(MAT_INDEX(2, 3)) * o.Get(MAT_INDEX(3, 0)));
this->Get(MAT_INDEX(2, 1)) = (m.Get(MAT_INDEX(2, 0)) * o.Get(MAT_INDEX(0, 1))) + (m.Get(MAT_INDEX(2, 1)) * o.Get(MAT_INDEX(1, 1))) + (m.Get(MAT_INDEX(2, 2)) * o.Get(MAT_INDEX(2, 1))) + (m.Get(MAT_INDEX(2, 3)) * o.Get(MAT_INDEX(3, 1)));
this->Get(MAT_INDEX(2, 2)) = (m.Get(MAT_INDEX(2, 0)) * o.Get(MAT_INDEX(0, 2))) + (m.Get(MAT_INDEX(2, 1)) * o.Get(MAT_INDEX(1, 2))) + (m.Get(MAT_INDEX(2, 2)) * o.Get(MAT_INDEX(2, 2))) + (m.Get(MAT_INDEX(2, 3)) * o.Get(MAT_INDEX(3, 2)));
this->Get(MAT_INDEX(2, 3)) = (m.Get(MAT_INDEX(2, 0)) * o.Get(MAT_INDEX(0, 3))) + (m.Get(MAT_INDEX(2, 1)) * o.Get(MAT_INDEX(1, 3))) + (m.Get(MAT_INDEX(2, 2)) * o.Get(MAT_INDEX(2, 3))) + (m.Get(MAT_INDEX(2, 3)) * o.Get(MAT_INDEX(3, 3)));
this->Get(3, 0) = (m.Get(3, 0) * o.Get(0, 0)) + (m.Get(3, 1) * o.Get(1, 0)) + (m.Get(3, 2) * o.Get(2, 0)) + (m.Get(3, 3) * o.Get(3, 0));
this->Get(3, 1) = (m.Get(3, 0) * o.Get(0, 1)) + (m.Get(3, 1) * o.Get(1, 1)) + (m.Get(3, 2) * o.Get(2, 1)) + (m.Get(3, 3) * o.Get(3, 1));
this->Get(3, 2) = (m.Get(3, 0) * o.Get(0, 2)) + (m.Get(3, 1) * o.Get(1, 2)) + (m.Get(3, 2) * o.Get(2, 2)) + (m.Get(3, 3) * o.Get(3, 2));
this->Get(3, 3) = (m.Get(3, 0) * o.Get(0, 3)) + (m.Get(3, 1) * o.Get(1, 3)) + (m.Get(3, 2) * o.Get(2, 3)) + (m.Get(3, 3) * o.Get(3, 3));
this->Get(MAT_INDEX(3, 0)) = (m.Get(MAT_INDEX(3, 0)) * o.Get(MAT_INDEX(0, 0))) + (m.Get(MAT_INDEX(3, 1)) * o.Get(MAT_INDEX(1, 0))) + (m.Get(MAT_INDEX(3, 2)) * o.Get(MAT_INDEX(2, 0))) + (m.Get(MAT_INDEX(3, 3)) * o.Get(MAT_INDEX(3, 0)));
this->Get(MAT_INDEX(3, 1)) = (m.Get(MAT_INDEX(3, 0)) * o.Get(MAT_INDEX(0, 1))) + (m.Get(MAT_INDEX(3, 1)) * o.Get(MAT_INDEX(1, 1))) + (m.Get(MAT_INDEX(3, 2)) * o.Get(MAT_INDEX(2, 1))) + (m.Get(MAT_INDEX(3, 3)) * o.Get(MAT_INDEX(3, 1)));
this->Get(MAT_INDEX(3, 2)) = (m.Get(MAT_INDEX(3, 0)) * o.Get(MAT_INDEX(0, 2))) + (m.Get(MAT_INDEX(3, 1)) * o.Get(MAT_INDEX(1, 2))) + (m.Get(MAT_INDEX(3, 2)) * o.Get(MAT_INDEX(2, 2))) + (m.Get(MAT_INDEX(3, 3)) * o.Get(MAT_INDEX(3, 2)));
this->Get(MAT_INDEX(3, 3)) = (m.Get(MAT_INDEX(3, 0)) * o.Get(MAT_INDEX(0, 3))) + (m.Get(MAT_INDEX(3, 1)) * o.Get(MAT_INDEX(1, 3))) + (m.Get(MAT_INDEX(3, 2)) * o.Get(MAT_INDEX(2, 3))) + (m.Get(MAT_INDEX(3, 3)) * o.Get(MAT_INDEX(3, 3)));
return;
}
@@ -833,6 +837,3 @@ namespace Leonetienne::GCrypt {
template class Basic_Block<std::uint16_t>;
}
#undef MAT_INDEX
+36 -17
View File
@@ -302,8 +302,8 @@ TEST_CASE(__FILE__"/operator-&=", "[Block]") {
// Tests that subtraction undoes addition, and vica versa
TEST_CASE(__FILE__"/subtraction-undoes-addition", "[Block]") {
// Setup
const Block a = Key::FromPassword("Halleluja");
const Block b = Key::FromPassword("Ananas");
const Block a = Key::Random();
const Block b = Key::Random();
// Exercise
const Block a_plus_b = a + b;
@@ -441,7 +441,7 @@ TEST_CASE(__FILE__"/shift-rows-up", "[Block]") {
// Tests that ShiftRowsUpInplace() does the exact same thing as ShiftRowsUp()
TEST_CASE(__FILE__"/shift-rows-up-same-as-inplace", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
const Block initial_a = a;
// Exercise and verify
@@ -475,7 +475,7 @@ TEST_CASE(__FILE__"/shift-rows-down", "[Block]") {
// Tests that ShiftRowsDownInplace() does the exact same thing as ShiftRowsDown()
TEST_CASE(__FILE__"/shift-rows-down-same-as-inplace", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
const Block initial_a = a;
// Exercise and verify
@@ -509,7 +509,7 @@ TEST_CASE(__FILE__"/shift-columns-left", "[Block]") {
// Tests that ShiftColumnsLeftInplace()() does the exact same thing as ShiftColumnsLeft()
TEST_CASE(__FILE__"/shift-columns-left-same-as-inplace", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
const Block initial_a = a;
// Exercise and verify
@@ -543,7 +543,7 @@ TEST_CASE(__FILE__"/shift-columns-right", "[Block]") {
// Tests that ShiftColumnsRightInplace()() does the exact same thing as ShiftColumnsRight()
TEST_CASE(__FILE__"/shift-columns-right-same-as-inplace", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
const Block initial_a = a;
// Exercise and verify
@@ -576,7 +576,7 @@ TEST_CASE(__FILE__"/shift-cells-left", "[Block]") {
// Tests that ShiftCellsLeftInplace()() does the exact same thing as ShiftCellsLeft()
TEST_CASE(__FILE__"/shift-cells-left-same-as-inplace", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
const Block initial_a = a;
// Exercise and verify
@@ -609,7 +609,7 @@ TEST_CASE(__FILE__"/shift-cells-right", "[Block]") {
// Tests that ShiftCellsRightInplace()() does the exact same thing as ShiftCellsRight()
TEST_CASE(__FILE__"/shift-cells-right-same-as-inplace", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
const Block initial_a = a;
// Exercise and verify
@@ -620,7 +620,7 @@ TEST_CASE(__FILE__"/shift-cells-right-same-as-inplace", "[Block]") {
// Tests that shifting down undoes shifting up, and vica versa
TEST_CASE(__FILE__"/shift-down-undoes-shift-up", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
const Block initial_a = a;
// Exercise
@@ -634,7 +634,7 @@ TEST_CASE(__FILE__"/shift-down-undoes-shift-up", "[Block]") {
// Tests that shifting left undoes shifting right, and vica versa
TEST_CASE(__FILE__"/shift-left-undoes-shift-right", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
const Block initial_a = a;
// Exercise
@@ -648,7 +648,7 @@ TEST_CASE(__FILE__"/shift-left-undoes-shift-right", "[Block]") {
// Tests that shifting cells left undoes shifting cells right, and vica versa
TEST_CASE(__FILE__"/cellshift-left-undoes-cellshift-right", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
const Block initial_a = a;
// Exercise
@@ -662,7 +662,7 @@ TEST_CASE(__FILE__"/cellshift-left-undoes-cellshift-right", "[Block]") {
// Tests that multiple, combined shifts and additions can be undone
TEST_CASE(__FILE__"/multiple-combined-shifts-and-additions-can-be-undone", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
Block key = Key::FromPassword("Papaya");
const Block initial_a = a;
@@ -689,8 +689,9 @@ TEST_CASE(__FILE__"/multiple-combined-shifts-and-additions-can-be-undone", "[Blo
// Tests that the get-bit method works
TEST_CASE(__FILE__"/get-bit", "[Block]") {
for (std::size_t i = 0; i < 100; i++) {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
// Exercise
std::stringstream ss;
@@ -700,12 +701,30 @@ TEST_CASE(__FILE__"/get-bit", "[Block]") {
// Verify
REQUIRE(ss.str() == a.ToBinaryString());
}
}
// Tests that the set-bit method works
TEST_CASE(__FILE__"/set-bit", "[Block]") {
for (std::size_t i = 0; i < 100; i++) {
// Setup
const std::string a_bits = Key::Random().ToBinaryString();
// Exercise
Block a;
for (std::size_t i = 0; i < 512; i++) {
a.SetBit(i, a_bits[i] == '1');
}
// Verify
REQUIRE(a_bits == a.ToBinaryString());
}
}
// Tests that the set-bit to-false method works
TEST_CASE(__FILE__"/set-bit-to-false", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
// Exercise
a.SetBit(5, 0);
@@ -723,7 +742,7 @@ TEST_CASE(__FILE__"/set-bit-to-false", "[Block]") {
// Tests that the set-bit to-true method works
TEST_CASE(__FILE__"/set-bit-to-true", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
// Exercise
a.SetBit(5, 1);
@@ -741,7 +760,7 @@ TEST_CASE(__FILE__"/set-bit-to-true", "[Block]") {
// Tests that the flip-bit method works
TEST_CASE(__FILE__"/flip-bit", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
std::string compare = a.ToBinaryString();
compare[5] = compare[5] == '1' ? '0' : '1';
@@ -863,7 +882,7 @@ TEST_CASE(__FILE__"/bitshift-right-inplace", "[Block]") {
TEST_CASE(__FILE__"/bitshifting-undoes-itself", "[Block]") {
// Setup
Block a = Key::FromPassword("Halleluja");
Block a = Key::Random();
const Block initial_a = a;
+41 -36
View File
@@ -1,23 +1,26 @@
# GCrypt
*(GhettoCrypt), because frankly I have no idea what the fuck I'm doing*
[![Build Status](https://drone.leonetienne.de/api/badges/leonetienne/GCrypt/status.svg)](https://drone.leonetienne.de/leonetienne/GCrypt)
# GCrypt
*GCrypt (GNU Crypt) — an educational project for learning how block ciphers work*
<sub>*Please don't use this for anything critical*</sub>
## What the hell is this?
> **Note:** This project is unrelated to [libgcrypt](https://www.gnupg.org/software/libgcrypt/index.html), the cryptographic library used by GnuPG. Any naming similarity is coincidental — "GCrypt" here just stands for "GNU Crypt".
## [Documentation](https://gcrypt.rtfm.leonetienne.de/)
## What is this?
An educational project on implementing a block cipher using a feistel network.
This block cipher employs a few modes of operation. Read more about them [here](#modes-of-operation).
## Features
* It has very easy syntax
* It's slow
* It absolutely tanks your ram when working with files
* Even leaves some key fragments in there✨
* It's probably super insecure
* But the syntax is pythonlike easy🙇
It's pretty ghetto, you know?
* Very easy to use
* 512-bit keys
* Not performance-optimized, and not audited for security
## What are the actual advantages?
* It's two files to import into your project
* No dependencies
* 1 Line to use
* 100% cross plattform
@@ -25,9 +28,8 @@ It's pretty ghetto, you know?
* For data obfuscation
* If your only other option would be no encryption at all
### I am not kidding, don't use this for critical stuff! Homebrew ciphers tend to be shit!
Especially mine!🗡️
Even assumed it's a good cipher, it's implementation leaves a lot to be desired in terms of being cryptographically secure. The whole leaving partial keys in ram- thingy...
### Seriously, don't use this for anything critical. Homebrew ciphers are rarely secure — this one included.
Even assuming it's a good cipher, its implementation leaves a lot to be desired in terms of being cryptographically secure.
## How do I use this?
### *"I don't care about the library. Just let me use it from the command line!"*
@@ -102,6 +104,8 @@ This way you can cipher on bitlevel. Examples on how to do this are in [GWrapper
This way you could, for example, decrypt an ecrypted file directly into memory.
Without saying, this is more advanced and not as-easy as the methods supplied in the wrapper.
Want more documentation? See the [doxygen page](https://gcrypt.rtfm.leonetienne.de/).
---
## The deets 🍝
@@ -110,25 +114,26 @@ Without saying, this is more advanced and not as-easy as the methods supplied in
* [CBC] This block cipher makes use of cipher block chaining. Nothing special.
* [IV] The initialization vector is indeed a bit of special sauce, as it depends on your key instead of being static. It is generated by running the feistel network on *E(m=seed, k=seed)*, which is a one-way function, because *m=k*.
* [RRKM] Never heard of a mode like this, so i've named it **R**olling**R**ound**K**ey**M**ode. This basically means that the round key extrapolation is carried out continously over EVERY round on EVERY block. So in addition to *M<sub>i</sub>* being dependent on *E(M<sub>i-1</sub>,K<sub>i-1,0</sub>)* due to CBC, so is now *K<sub>i</sub>* dependent on *K<sub>i-1,r</sub>* with *r* being the maximum number of extrapolated keys within a call of *E()*. This is handled within the feistel network class, as an instance lifecycle sees all blocks. Just in case you want to take a peek.
* [I-don't-even-know-any-more] Inspired by Rijndael, it does some monkey tricks with reversible matrix-mutators after each feistel round.
### Password to key
How does GCrypt transform a password to a key?..
Well, it uses the included hash function [GHash](https://gitea.leonetienne.de/leonetienne/GCrypt/src/branch/feature/relaunch/GCryptLib/include/GCrypt/GHash.h).
Well, it uses the included hash function [GHash](https://gitea.leonetienne.de/leonetienne/GCrypt/src/branch/master/GCryptLib/include/GCrypt/GHash.h).
### Hashing with GHash
GHash is a streaming hash function based on the GCipher.
For all intents and purposes, it does the following:
You have a *Block b*, which is initialized with a static random distribution.
Once you give the GHash instance a data block to digest, it will use the GCipher to encrypt it, with itself as a key, and xor that onto *b*.
(*b<sub>i</sub> = b<sub>i-1</sub> &#8853; E(key=b, data=b)*)
(*b<sub>i</sub> = b<sub>i-1</sub> &#8853; E(key=b<sub>new</sub>, data=b<sub>new</sub>)*)
The lastest *b* represents the current result of the hash function.
GHash also supports a do-it-all wrapper method that takes a Flexblock (A block of arbitrary length), and returns a hashsum for it.
This wrapper function adds an additional block including the length of the input. This wrapper function is used to transform Passwords to Keys.
GHash also supports a do-it-all wrapper method that takes a vector of blocks, and returns a hashsum for it.
This wrapper function adds an additional block including the length of the input, if provided. This wrapper function is used to transform Passwords to Keys.
### GPrng...?
Whilst we're at it, why not implement a pseudo-random number generator based on GHash aswell. So here it is, [GPrng](https://gitea.leonetienne.de/leonetienne/GCrypt/src/branch/feature/relaunch/GCryptLib/include/GCrypt/GPrng.h).
Whilst we're at it, why not implement a pseudo-random number generator based on GHash aswell. So here it is, [GPrng](https://gitea.leonetienne.de/leonetienne/GCrypt/src/branch/master/GCryptLib/include/GCrypt/GPrng.h).
GPrng is really nothing special. I just wanted to implement it, mainly to visualize the GCiphers entropy.
GPrng basically does the following: It creates a GHash instance, which initially digests the prng's seed. This produces a hash result, which is one block in size.
@@ -140,30 +145,30 @@ future output.
#### Single-block diffusion
`"Hello :3"` in binary, and it's ciphertext:
!["Hello :3" in binary](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-singleblock-diffusion-input.bmp.png)
![Hello :3 in binary](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-singleblock-diffusion-input.bmp.png)
&nbsp;&nbsp;&nbsp;
![Ciphertext 1](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-singleblock-diffusion-output.bmp.png)
![Ciphertext 1](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-singleblock-diffusion-output.bmp.png)
Now, let's flip a single bit in the input:
One bit flipped, and again the corresponding ciphertext:
![One bit flipped](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-singleblock-diffusion-input-flip.bmp.png)
![One bit flipped](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-singleblock-diffusion-input-flip.bmp.png)
&nbsp;&nbsp;&nbsp;
![Ciphertext for flipped bit](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-singleblock-diffusion-output-flip.bmp.png)
![Ciphertext for flipped bit](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-singleblock-diffusion-output-flip.bmp.png)
Let's gif them together, to better see the difference:
![Input](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-singleblock-diffusion-input.gif)
![Input](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-singleblock-diffusion-input.gif)
&nbsp;&nbsp;&nbsp;
![Ciphertext](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-singleblock-diffusion-output.gif)
![Ciphertext](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-singleblock-diffusion-output.gif)
As shown, flipping even a single bit, affects the entire ciphertext.
#### What about input longer than a single block?
Input, and ciphertext:
![Input](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-multiblock-diffusion-input.gif)
![Input](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-multiblock-diffusion-input.gif)
&nbsp;&nbsp;&nbsp;
![Ciphertext](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-multiblock-diffusion-output.gif)
![Ciphertext](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-multiblock-diffusion-output.gif)
Notice how the ciphertext doesn't change until the block containing the bitflip is reached? This is a limitation of cipher block chaining.
@@ -171,11 +176,11 @@ Notice how the ciphertext doesn't change until the block containing the bitflip
How non-transparent is the cipher with extreme inputs? Even with a super problematic key?:
Input, key, and ciphertext:
![Input](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-extreme-input-diffusion-input.gif)
![Input](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-extreme-input-diffusion-input.gif)
&nbsp;&nbsp;&nbsp;
![Key](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-extreme-input-diffusion-key.bmp.png)
![Key](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-extreme-input-diffusion-key.bmp.png)
&nbsp;&nbsp;&nbsp;
![Ciphertext](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-extreme-input-diffusion-output.gif)
![Ciphertext](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-extreme-input-diffusion-output.gif)
Notice how even cleartexts that are completely uniform, with a key that is almost just zeores, will still produce ambiguous ciphertexts.
@@ -183,18 +188,18 @@ Notice how even cleartexts that are completely uniform, with a key that is almos
Check it out, here are the distributions of a few different getter-methods, some in black/white, some in grayscale, some in color.
Blackwhite - GetBit(), Grayscale - GetRandom<T>(), and Grayscale - operator():
![Input](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-prng-distribution-blackwhite.bmp.png)
![Input](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-prng-distribution-blackwhite.bmp.png)
&nbsp;&nbsp;&nbsp;
![Key](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-prng-distribution-getrandom-grayscale.bmp.png)
![Key](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-prng-distribution-getrandom-grayscale.bmp.png)
&nbsp;&nbsp;&nbsp;
![Ciphertext](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-prng-distribution-operator-grayscale.bmp.png)
![Ciphertext](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-prng-distribution-operator-grayscale.bmp.png)
Color - GetRandom<T>(), Color - operator(), and Color - GetBlock():
![Input](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-prng-distribution-getrandom-color.bmp.png)
![Input](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-prng-distribution-getrandom-color.bmp.png)
&nbsp;&nbsp;&nbsp;
![Key](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-prng-distribution-operator-color.bmp.png)
![Key](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-prng-distribution-operator-color.bmp.png)
&nbsp;&nbsp;&nbsp;
![Ciphertext](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/feature/relaunch/GCryptLib/visualizations/visualize-prng-distribution-getblock-color.bmp.png)
![Ciphertext](https://gitea.leonetienne.de/leonetienne/GCrypt/raw/branch/master/GCryptLib/visualizations/visualize-prng-distribution-getblock-color.bmp.png)
## Noteworthy:
* This is no fixed algorithm. Newer versions may very well be unable to decrypt ciphertexts encrypted with earlier versions.