Skip to content

Commit d08d00a

Browse files
committed
update init
0 parents  commit d08d00a

File tree

12 files changed

+2249
-0
lines changed

12 files changed

+2249
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode

LICENSE

Lines changed: 675 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# System Encryption Utility
2+
3+
---------------------------
4+
5+
[Encryption](https://en.wikipedia.org/wiki/Encryption) utility written in c++
6+
7+
## User Notice:
8+
contact address: **auc_02@proton.me**
9+
10+
you better backup first.
11+
The Encryption use [CBC](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation) (Cipher Block Chaining) and [AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) (Advanced Encryption Standard) algorithms to guarantee maximum security degree and data integrity. user supplied location where to store Block **Key** and [IV(Initialization-Vector)](https://en.wikipedia.org/wiki/Initialization_vector) and path to encrypt/decrypt.
12+
you will be prompted to confirm your actions before actually proceeding with execution.
13+
14+
**Decryption**
15+
For decryption process, key/IV block locations will removed from system.
16+
statically **pre-compiled**, both for encryption(enc.cpp = enc/enc.exe) and decryption(dec.cpp = dec/dec.exe). This was compiled on Linux **x86-64** bit.
17+
Heavyly relying on **crypto++**, and for file streaming operations it uses **std::filesystem** and std::[i/o]fstream.
18+
19+
20+
## Table Of Contents
21+
------------------------------------------------------------------------------------------
22+
23+
* Usage
24+
* Risk Assessment
25+
* OS/Architecture Support
26+
* GPG Version
27+
* Pseudo-Code
28+
29+
### NOTICE
30+
.gpg files decryption Passphrase is: **0987654321QWERTYqwerty**
31+
32+
## Usage
33+
EncryptFile/DecryptFile anything from a simple .txt file, to everything else which is not a regular text file(binary file).
34+
Create a **backup** copy of your data, just in case!
35+
There is no UI(User-Interface), so you might need to have some basic experience with **CLI**.
36+
37+
**Setting CLI Flags**
38+
39+
Set Execution Verbosity and Atomicity Flags, `./enc -verbose=true` or `./enc -verbose=false` for omitting logs, if you want to perform an atomic operation instead of applying a small delay during resource aggregation, `./enc -atomic=true` or `./enc -atomic=false` making the execution ETA slower but guaranteeing data integrity at higher rate of success and lower rate of failure(`./enc -atomic=true`). flags are optional, and the sequence order does not matter.
40+
41+
---------------------------------------------
42+
43+
Perform with atomicity and verbosity, no delay applied, will execute faster.
44+
45+
> ./enc -atomic=true -verbose=true
46+
47+
> ./dec -atomic=true -verbose=true
48+
49+
Perform with delay and no verbosity, will execute slower but increase success rate.
50+
51+
> ./enc -verbose=false -atomic=false
52+
53+
> ./dec -verbose=false -atomic=false
54+
55+
---------------------------------------------
56+
57+
## Risk Assessment
58+
Some of the risks are obviously data corruption during runtime encryption/decryption, even if the success rate is almost 100%, you should create a backup copy of the data you want to encrypt before actually encrypting it.
59+
60+
## OS/Architecture Support
61+
It is supported on most used Operating Systems such as **Linux**, **Windows**, **Mac** OS, supporting both **x86-64**, **x64** and **x86/32** bit System Architectures.
62+
63+
64+
## GPG Version
65+
66+
**GPG Installation and Configuration**
67+
68+
----------------------------------------------
69+
70+
If you don't have gpg installed on your System, this is how you can install it:
71+
72+
> sudo apt-get install gnupg
73+
74+
If you haven't created your own pair or gpg public/private keys yet:
75+
76+
> gpg --full-generate-key
77+
78+
More about [GPG](https://www.redhat.com/sysadmin/encryption-decryption-gpg)
79+
80+
**TAR Installation**
81+
Tar is a command line utility, so you should already have it installed by default, if you don't have tar installed on your system for some reason:
82+
83+
> sudo apt-get install tar
84+
85+
More about [Tar](https://man7.org/linux/man-pages/man1/tar.1.html)
86+
87+
There is a gpg(( encrypted version using **symmetric** encryption mode with **AES256** Key Block Size, it is just the same as the raw version, but provides more **confidentiality** and **integrity**, using the .gpg content is **preferable**, here's how you can decrypt the gpg version.
88+
89+
------------------------
90+
**Navigate to the path of the downloaded .gpg file:**
91+
> cd /path/to/gpg-file
92+
93+
------------------------
94+
**DecryptFile the gpg_dblock.tar.gpg file:**
95+
> gpg -d gpg_ublock.tar.gpg > real-content.tar
96+
97+
Supply the password provided above and wait for the execution, a real-content.tar will be created in the same directory, this is the tar file containing the data.
98+
99+
------------------------
100+
**Extract from Tar, assuming you extracted into "real-content.tar", otherwise provide the .tar filename you have used.**
101+
> tar -xvf real-content.tar
102+
103+
-------------------------
104+
**Now You have SysEnc-v03 in the same directory, this is the result :), congrats!**
105+
106+
107+
## Pseudo Code
108+
109+
### Public Methods
110+
111+
```cpp
112+
explicit Crypto();
113+
114+
[[nodiscard]] inline const uBlock<void *> Init(const InitMode_e __init_mode, const Int16_t __exe_mode);
115+
[[maybe_unused, nodiscard]] inline static const uBlock<KeyIvBlockPairPath> SupplyKeyIvPath(void);
116+
[[maybe_unused, nodiscard]] inline static const String_t SupplyTargetPath(void);
117+
[[maybe_unused, nodiscard]] inline static const uBlock<KeyIvBlockPairPath> StoreKeyIvAddress(const KeyIvBlockPairPath &_key_iv_location);
118+
[[nodiscard]] inline static const uBlock<KeyIvBlockPairPath> GetKeyIvAddress(void);
119+
[[nodiscard]] inline static const uBlock<KeyIvBlockPairPath> KisbUseLocation(const KeyIvBlockPairPath &__kisb_location);
120+
[[maybe_unused, nodiscard]] inline static const uBlock<KeyIvBlock> GenerateKeyIv(void);
121+
[[nodiscard]] inline static const uBlock<KeyIvBlockInfo> IntersectSecBlocks(const KeyIvBlock &__kisb_block, const KeyIvBlockPairPath &__kisb_path);
122+
[[nodiscard]] inline static const uBlock<KeyIvBlock> KisbCollect(const KeyIvBlockPairPath &__kisb_path);
123+
[[nodiscard]] inline static const uBlock<KeyIvBlock> KisbCollect(void);
124+
[[nodiscard]] inline const bool KisbDelegate(const KeyIvBlockInfo &__kisb_block);
125+
[[maybe_unused, nodiscard]] inline const ErrorBlockInfo EncryptFile(const String_t &__file_name) __attribute__((hot));
126+
[[maybe_unused, nodiscard]] inline const ErrorBlockInfo DecryptFile(const String_t &__file_name) __attribute__((hot));
127+
128+
[[nodiscard]] inline static const bool Rename(const StringView_t &__file_name, const SourceRenameMode_e __rename_mode) __attribute__((hot));
129+
[[maybe_unused]] inline void SetRootDirectory(const StringView_t &__root) noexcept;
130+
[[maybe_unused, nodiscard]] inline static uBlock<String_t> RegisterTargetDirectory(const StringView_t &__target);
131+
[[maybe_unused, nodiscard]] inline static uBlock<String_t> RetrieveTargetDirectory(void);
132+
[[nodiscard]] inline static const uBlock<std::vector<String_t>> ResourceAggregate(const StringView_t &__use_root);
133+
[[maybe_unused, nodiscard]] inline const String_t *GetRoot(void) noexcept;
134+
[[maybe_unused, nodiscard]] inline static const bool DirectoryExists(const StringView_t &__dir) noexcept __attribute__((hot));
135+
[[maybe_unused]] inline void CleanOperation(void);
136+
[[maybe_unused]] inline static void LogMessage() __attribute__((hot, nothrow));
137+
template <typename mT, typename... tArgs> [[maybe_unused]] inline static void LogMessage(mT msg, tArgs... __mlist) __attribute__((hot, nothrow));
138+
[[maybe_unused]] inline static void LogWarning() __attribute__((hot, nothrow));
139+
template <typename mT, typename... tArgs> [[maybe_unused]] inline static void LogWarning(mT msg, tArgs... __mlist) __attribute__((hot, nothrow));
140+
[[maybe_unused]] inline static void LogError() __attribute__((hot, nothrow));
141+
template <typename mT, typename... tArgs> [[maybe_unused]] inline static void LogError(mT msg, tArgs... __mlist) __attribute__((hot, nothrow));
142+
[[maybe_unused]] inline static void CondWait(const Int32_t _wtime) noexcept;
143+
[[maybe_unused]] inline void UseCommandLineArguments(const int argc, char **argv);
144+
[[maybe_unused]] inline static const bool BackupTarget(const StringView_t &__dir_name);
145+
146+
~Crypto();
147+
```
148+
149+
### PRIVATE METHODS
150+
```cpp
151+
template <typename ET> inline static void __ErrorFrameInjection(const ET &_e, ErrorBlockInfo &_eBlock) noexcept __attribute__((hot));
152+
[[maybe_unused, nodiscard]] inline static const uBlock<void *> __CreateDefaultKisbReference(void);
153+
[[maybe_unused, nodiscard]] inline static const bool __HasKisbAddressInfo(void);
154+
[[nodiscard]] inline static const SplitPathObj __SplitPath(const StringView_t &__path) __attribute__((hot));
155+
inline static void __AddPathToForbidden(const KeyIvBlockPairPath &__path) noexcept;
156+
[[nodiscard]] inline static const bool __IsResourceForbidden(const StringView_t &__resource) noexcept __attribute__((hot));
157+
158+
inline static void __FileRenameParseByte(const System::StringView_t &__file_name, System::String_t &__new_file_name, const bool _plus) __attribute__((hot, nothrow));
159+
};
160+
```

0 commit comments

Comments
 (0)