This is a cryptography package I wrote for my Data Security class from my University. Features:
- A simplified version of AES - which uses 16 bit block encryption and decryption, and a 16 bit key. Has SBOX, ShiftRows,
MixColums, AddRoundKey and their inverses InvSBOX, InvShiftRows, InvMixColums (analogous to the AES algorithm).
- Galois Field 16 - A mathematical field which AES uses for binary arithmetic.
- A simplified version of SHA-1 - which uses 32 block sizes. Features three types of attacks
- A brute for force attack for finding the message from given the hash value.
- A collision attack - Check if there is another message other than M, that has the same hash as M.
- A birthday attack - for finding any two different messages that produce the same hash.
- RSA - A complete version of RSA encryption algorithm build with the help of BigInteger java class.
- Features attack when Bob is not careful when choosing prime numbers
$p,q$ ; that is when$|p-q|<2n^{1/4}$ .
- Features attack when Bob is not careful when choosing prime numbers
- HMAC with Simplified SHA-1 - A hash message authentication code written based on a scheme.
- Digital Signature Scheme - Uses simplified AES for encryption of the message, signs with RSA the hash of the message calculated with Simplified SHA-1
- Block Ciphers - Features several modes of operation with any encryption algorithm:
- ECB - Electronic Code Book mode
- CBC - Cipher Block Chaining mode
- CFB - Cipher Feedback mode
- OFB - Output Feedback mode
- CTR - Counter Mode
- GCM - Galois Counter Mode
- Relative Frequencies Attack - performs an attack on a text based on relative frequency distribution. The attacker supposes that the text was encrypted on a alphabet mapping rule.
- A Non Linear Feedback Shift Register - NLFSR I designed.
Below are given the encryption algorithms Simplified AES, Simplified SHA-1, A non linear feedback shift register (NLFSR), Digital Signature scheme all designed by professor Artan Berisha at Department of Mathematics at University of Prishtina.
Simplified AES algorithm, has as input the block of length 16 bits, the key 16-bit length as well as the 16-bit block output. The algorithm has the actions SBOX, ShiftRows, MixColums, AddRoundKey and their inverses InvSBOX, InvShiftRows, InvMixColums ( analogous to the AES algorithm).
It has three rounds, where two firs rounds are identical and the third round does not have MixColoumns. Let
, where
Then B enters in the below structure (Three rounds). First SBOX substitution is made, given with the
This SBOX is built within the Galois Field
Then comes the MixColoumns operation, where the multiplication with Maximal Distance Separabile matrix) and the result from ShiftRows operation. The MDS matrix for MixColoumnns is
where multiplication and addition is performed within the Galuois Field
In AddRoundKey, the obtained matrix XOR-s with the KEY from the first round
This matrix goes in again in the second round with the same repetition of operations and then again in round 3.
Below is given the encryption scheme for simplified AES.
It has three rounds, where the first round does not have InvMixColoumns and two last rounds are identical(second and the third round).
Given the encrypted text
In the first round the first operation is AddRound Key, so it is calculated
After AddRoundKey, comes InvShiftRows, where the second row is shifted right for four bits.
Then the substitution is done with the InvSBOX given with the matrix\table:
This InvSBOX is built within the Galois Field
After InvSBOX the first round ends and then the two last rounds begin.
In the second round, AddRoundKey is performed first, where the obtained value XOR-s the second round key
Then comes the MixColoumns operation, where the multiplication with Maximal Distance Separabile matrix) and the result from InvShiftRows operation. The MDS matrix for InvMixColoumnns is
where multiplication and addition is done within Galois Field
Then after InvMixColoumns comes InvShiftRows, where the second row is shifted right for four bits.
Then the substitution happens with the InvSBOX(inverse of SBOX)
This matrix goes back again in the third round with the repetition of the operations and finally in the end it XOR-s with the key
Below is given the Simplified AES decryption scheme:
Three keys are generated for both encryption and decryption for SAES. Below is given the scheme:
Below is given the scheme for Simplified SHA-1
There are 3 registers A, B and C. The lengths of the registers are 11, 21, 29 respectively. The register at the end has a length of 11+21+29 bits, which is given as the sum of the three registers gives the key stream after 11+21+29 cycles XOR-ed.
- The output of each register is the XOR-sum of three bits:
- last bit
- a bit of a corresponding register position,
- Output of the logical AND function of the two bits of the corresponding register.
- The output of the logical AND function of two bits of one register is the input for one bit of the other register.
- Output from register A is input to one bit of register B.
- The first element of the registers is as the output of the logic function XOr between a bit of it and a bit from the other register.