computer security
computer security
Security
L EC T U RER: S HEB I K A RAN I
L EC T U RE: C RY PTOG RAPHI C ALG ORI T HM( AES )
What is Cryptography?
Cryptography is a process of hiding transmitted information by the sender such that it may be read
only by the intended recipient. Cryptography is widely used in various fields such as end-to-end
messaging, banking and finance, secure web communication, and access control.
What are Cryptographic Algorithms?
A cryptographic algorithm is a set of steps that can be used to convert plain text into cipher text. A
cryptographic algorithm is also known as an encryption algorithm.
A cryptographic algorithm uses an encryption key to hide the information and convert it into an
unreadable format. Similarly, a decryption key can be used to convert it back into plain-readable text.
Types of Cryptographic Algorithms
To protect sensitive data and conversations, cryptography uses complex algorithms. These
mathematical formulas enable the encryption, decryption, signature, and verification processes that
protect secret data during transmission and storage.
There are various types of cryptographic algorithms but in this article we will be discussing the 4
major types of cryptographic algorithms.
1. Advanced Encryption Standard (AES)
2. Data Encryption Standard (DES)
3. RSA Algorithm (Rivest, Shamir, Adleman Algorithm)
4. Secure Hash Algorithm (SHA)
Advanced Encryption Standard (AES)
AES (Advanced Encryption Standard) is a popular encryption algorithm which uses the same key for
encryption and decryption It is a symmetric block cipher algorithm with block size of 128 bits, 192 bits
or 256 bits.
The more rounds there are, the safer the encryption. This is why AES-256 is considered the safest
encryption.(1 word=32bits)
Advanced Encryption Standard (AES)
Bits 0 or 1 State:
w0 w1 w2 w3
Advanced Encryption Standard (AES)
Encryption
AES considers each block as a 16-byte (4 byte x 4 byte = 128 ) grid in a column-major arrangement.
Advanced Encryption Standard (AES)
• SubBytes
• ShiftRows
• MixColumns
The SubBytes does the substitution and ShiftRows and MixColumns perform the permutation in the algorithm.
Advanced Encryption Standard (AES)
Sub Bytes:
In this step, each byte is substituted by another byte. It is performed using a lookup table also called
the S-box. This substitution is done in a way that a byte is never substituted by itself and also not
substituted by another byte which is a compliment of the current byte. The result of this step is a 16-
byte (4 x 4 ) matrix like before.
Shift Rows
This step is just as it sounds. Each row is shifted a particular number of times.
Mix Columns
This step is a matrix multiplication. Each column is multiplied with a specific matrix and thus the
position of each byte in the column is changed as a result.
Now the resultant output of the previous stage is XOR-ed with the corresponding round key. Here, the
16 bytes are not considered as a grid but just as 128 bits of data.
After all these rounds 128 bits of encrypted data are given back as output. This process is repeated
until all the data to be encrypted undergoes this process.
AES Sub bytes
It is also known as forward substitute bytes transformation.
AES defines a 16*16 matrix of byte values, called an S-box, that contains a permutation of all
possible 256 8-bit values.
These row and column values serve as index into S-box to select a unique 8-bit output value.
AES Sub bytes
Let’s take an example: Row E
State: EA 87
EA 04 65 85 87 F2 4D 97
83 45 5D 96 Column A EC 6E 4C 90
5C 33 98 B0 4A C3 46 E7
F0 2D AD C5 8C D8 95 A6
State array
AES Shift Rows
It is also called as forward shift row transformation.
2 3 1 1 87 F2 4D 97
1 2 3 1 * 6E 4C 90 EC ->
1 1 2 3 46 E7 4A C3
3 1 1 2 A6 8C D8 95
Rules:
2 3 1 1 87 F2 4D 97
1 2 3 1 6E 4C 90 EC
1 1 2 3 46 E7 4A C3
3 1 1 2 A6 8C D8 95
AES Mix Column
{2}*{87}(+){3}*{6E}(+){1}*{46}(+){1}*{A6}
2= 0000 0010
X^7+X^6+X^5+X^4+X^3+X^2+X^1+X^0
AES Mix Column
For 02:
X^7+X^6+X^5+X^4+X^3+X^2+X^1+X^0
0 0 0 0 0 0 1 0 X
For 87:
X^7+X^6+X^5+X^4+X^3+X^2+X^1+X^0 X^7+X^2+X^1+1
1 0 0 0 0 1 1 1
AES Mix Column
Now Multiply the values:
{02}*{87}= X*{X^7+X^2+X^1+1}
=X^8+X^3+X^2+X
= X^4+ X^3+X+1+X^3+X^2+X
= X^4+X^2+1
X^7+X^6+X^5+X^4+X^3+X^2+X^1+X^0
0 0 0 1 0 1 0 1
3= 0000 0011
6E=0110 1110
X^7+X^6+X^5+X^4+X^3+X^2+X^1+X^0
0 0 0 0 0 0 1 1 (X+1)
X^7+X^6+X^5+X^4+X^3+X^2+X^1+X^0
0 1 1 0 1 1 1 0 (X^6+X^5+X^3+X^2+X)
AES Mix Column
{03}*{6E}= (X+1) * (X^6+X^5+X^3+X^2+X)
= X^7+X^6+X^4+X^3+X^2+X^6+X^5+X^3+X^2+X
X^7+X^6+X^5+X^4+X^3+X^2+X^1+X^0
1 0 1 1 0 0 1 0
2 3 1 1 87 F2 4D 97 47
1 2 3 1 * 6E 4C 90 EC ->
1 1 2 3 46 E7 4A C3
3 1 1 2 A6 8C D8 95
Rules:
2 3 1 1 87 F2 4D 97
1 2 3 1 6E 4C 90 EC
1 1 2 3 46 E7 4A C3
3 1 1 2 A6 8C D8 95
AES Mix Column
2nd row and First column operation:
47 40 A3 4C
37 D4 70 9F
94 E4 3A 42
ED A5 A6 BC
AES Add Round Key
Fourth Transformation function of AES is called as Add Round Key.
The 128 bits of State are bitwise X-OR with the 128 bits of the round key.
77 = 0111 0000
ED = 1110 1101
F3 = 1111 0011
47 40 A3 4C AC 19 28 57 EB 59 8B 1B
* ->
37 D4 70 9F 77 FA D1 5C 40 2E A1 C3
94 E4 3A 42 66 DC 29 00 F2 38 13 42
ED A5 A6 BC F3 21 41 6A 1E 84 E7 D6