Prerequisite Knowledge: RSA (Rivest–Shamir–Adleman) is an algorithm used by modern computers to encrypt and decrypt messages. It is an asymmetric cryptographic algorithm.
It is a small simple project that implements the RSA encryption algorithm , to encrypt / decrypt small messages using generated private keys, hence allowing encrypted communication between people.
The working of the project can be broken into loosely coupled procedures:
-
Generate RSA Key from user salt.
-
Save both public / private key to file.
-
Now the program does two function:
- Encrypt Message to Disk.
- Decrypt Encrypted Message on Disk.
-
Procedure for Encrypting Message to Disk:
- perform input of message from user.
- use “RSABlock” encryption algorithm to encrypt message.
- Save encrypted message to disk.
-
Procedure for Decrypting Encrypted Message on Disk:
- read encrypted message from disk.
- use “RSABlock” decryption algorithm to decrypt the encrypted message.
- display the decrypted message to user.
-
The decrypting operation only works if a private key is loaded.
-
The encrypting operation works on both keys.
This is the part of program handled by ( class : RSAGenerator
), this
part is responsible for creation of public and private keys that are
needed for algorithm.
Procedure:
- take salt input from user.
- generate two coprime numbers.
- feed these numbers to RSA_KEY_GENERATION algorithm.
- generated (
class : RSAGenerator
) object is feed to (class : RSAKey
) object. - once keys are generated the keygen object is no longer needed as the keys exist on their own.
This is the part of program handled by ( class : RSABlockKey ), this part is responsible for encrypting large chunks of data, which is not support by vanilla RSA Algorithm. Procedure:
- the algorithm converts any object/string/datatype into an char
array (
char ptr
pointing to mloc of the object/datatype ). - the algorithm runs sequentially on each item of the array (
char ptr
),and encrypts/decrypts them by RSA algorithm. - the encrypted/decrypted message can be stored or read from disk using custom methods provided in the class.
- The blockkey requires RSAKey to perform encryption/decryption.
The overall program has used the following header files:
- iostream.h
- fstream.h
- math.h
- thread.h
- chrono.h
The program internally contains two header files:
- RSA.h: Responsible for implementing RSA,RSABlock Algorithm.
- Loader.h Responsible for generating custom loading screen.
The program generated two category of file of which each is an binary file. Key Files: These files are responsible for storing the generated public and private key:
<key-name>.key.dat
: This file stores the private key. denotes name of key.Ex. Private key pbm is stored as : “pbm.key.dat”.<key-name>.public.key.dat
: This file stores the public key. denotes name of key. Ex. Public key sbm is stored as : “sbm.public.key.dat”.
Message Files:
<msg-name>.msg.dat
: this stores the encrypted form of message in
binary format. <msg-name>
denotes name of message.
Ex. Message cipho is stored as “cipho.msg.data”