0% found this document useful (0 votes)
32 views

Computer Security Chapter 3

Uploaded by

harshvasudevkoli
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Computer Security Chapter 3

Uploaded by

harshvasudevkoli
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

CS

3. Cryptography

3.1 Introduction:
❖ Cryptography:
⚫ Cryptography is technique of securing information and communications through use of codes so
that only those person for whom the information is intended can understand it and process it.
⚫ Cryptography in cybersecurity entails the use of encryption and decryption algorithms.
Converting the plain text (readable text) to cipher text (unreadable text) is called encryption,

and reversing the process i.e cipher text to plain text is called decryption.

⚫ In Cryptography the techniques which are use to protect information are obtained from

mathematical concepts and a set of rule based calculations known as algorithms to convert
messages in ways that make it hard to decode it.

❖ Cryptanalysis :
⚫ Cryptanalysis is the study and process of analyzing and decrypting ciphers, codes, and encrypted
text without using the real key. Alternately, we can say it’s the technique of accessing a
communication’s plain text content when you don’t have access to the decryption key.
⚫ Cryptanalysis is a method of converting ciphertext to plaintext.
⚫ The person practicing Cryptanalysis is called a Cryptanalyst.
⚫ As a cryptanalyst, you are in charge of decoding or decrypting data to understand hidden signals,
even if you do not have the encryption key.

❖ Cryptology :
⚫ Cryptology is the mathematics that underpins cryptography and cryptanalysis, such as number
theory and formula and algorithm application.
⚫ It is the study of conversion of plain text to cipher text and vice-versa. It is also called the study of
Encryption and Decryption.
⚫ It deals with the study of secure communication.
⚫ Cryptology has two parts Cryptography( Encryption) and Cryptanalysis(Decryption).
❖ Substitution techniques:
⚫ An encryption requires two things: 1.Algorithm 2.Key
⚫ There are numerous encryption techniques available for protecting sensitive data.one of them is
Substitution technique.
⚫ A substitution technique is one in which the letters of plaintext are replaced by other letters or by
numbers or symbols.
⚫ If the plain text (original message) is treated as the string of bits, thus the substitution technique
would restore bit pattern of plain text with the bit pattern of cipher text.

1. Caesar’s cipher :
⚫ In this substitution technique, it can encrypt the plain text, each alphabet of the plain text is
replaced by the alphabet three places further it and it can decrypt the cipher text each
alphabet of cipher text is restored by the alphabet three places before it.
⚫ The Caesar cipher is a kind of replacement (substitution) cipher, where all letter of plain text
is replaced by another letter.
⚫ Caesar ciphers is a weak method of cryptography. It can be easily hacked. It means the
message encrypted by this method can be easily decrypted.
◆ Algorithm for Caesar Cipher:
Input:
1. Choose a shift value between 1 and 25.
2. Write down the alphabet in order from A to Z.
3. Create a new alphabet by shifting each letter of the original alphabet by the shift value. For
example, if the shift value is 3, the new alphabet would be:
4. ABCDEFGHIJKLMNOPQRSTUVWXYZ
DEFGHIJKLMNOPQRSTUVWXYZABC
5. Replace each letter of the message with the corresponding letter from the new alphabet. For
example, if the shift value is 3, the word “hello” would become “khoor”.
6. To decrypt the message, shift each letter back by the same amount. For example, if the shift
value is 3, the encrypted message “khoor” would become “hello”.

The formula of encryption is:

CT = (p + k) mod 26

The formula of decryption is:

PT = (p - k) mod 26

Where,

CT denotes the encryption (cipher text)


PT denotes the decryption (plain text)
p denotes the letters value
k denotes the key value (shift value)
Let us assign a numerical equivalent to each letter:

➢ Example: Plain Text: “JAVATPOINT” Key : 3

Encryption

The formula of encryption is:

CT = (p+ k) mod 26

By applying formula:

Cipher Text (Encrypted Message): "MDYDWSRLQW"


Note that the Caesar cipher is monoalphabetic, so the same plaintext letters are encrypted as the same
letters. For example, "JAVATPOINT" has "A", encrypted by "D".

Decryption

The formula of decryption is:

PT = (p - k) mod 26
PT = (00 - 15) mod 26
= -15

The value of dn is negative, so 26 will be added to it.

= -15 + 26
= 11

Plain Text (Decrypted Message) : “JAVATPOINT”

Advantages of Caesar cipher

1. It is very easy to implement.


2. This method is the simplest method of cryptography.
3. Only one short key is used in its entire process.
4. If a system does not use complex coding techniques, it is the best method for it.
5. It requires only a few computing resources.

Disadvantages of Caesar cipher

1. It can be easily hacked. It means the message encrypted by this method can be easily decrypted.
2. It provides very little security.
3. By looking at the pattern of letters in it, the entire message can be decrypted.

❖ Monoalphabetic Cipher :
⚫ A mono-alphabetic substitution cipher is a type of substitution ciphers in which the equivalent
letters of the plaintext are restored by the same letters of the ciphertext.
⚫ Caesar cipher is a type of Monoalphabetic cipher. It uses the similar substitution method to
receive the cipher text characters for each plain text character.
⚫ Mono, which defines one, it signifies that each letter of the plaintext has a single substitute of
the ciphertext.
➢ For instance, if a letter A in the plaintext is changed to D then each appearance of A in the plaintext
will be restored by D.
Plaintext : hello
Ciphertext : IFMMP
This is a monoalphabetic cipher as both l’s are encrypted as ‘M’.

❖ Polyalphabetic Cipher :
⚫ A poly-alphabetic cipher is a cipher based on substitution, using multiple substitution alphabets. It
encrypts plaintext letters differently based on their placement in the text, Rather than being a one-
to-one correspondence, there is a one-to-many relationship between each letter and its
substitutes.
⚫ In polyalphabetic substitution, each appearance of a character in the plaintext can have a different
substitution character in the ciphertext.
⚫ The relationship among a character in plaintext and a character in ciphertext is one to many. For
instance, letter ‘A’ can be restored by the letter ‘C’ and the similar letter ‘A’ can be restored by ‘N’
later in the ciphertext.
⚫ Polyalphabetic ciphers are complex to break due to the absence of plaintext letter frequencies,
making statistical analysis unsuitable for breaking them.
⚫ As the name polyalphabetic recommend this is achieved by using multiple keys rather than only
one key.

3.2 Transposition techniques :


⚫ The transposition technique is a cryptographic technique that converts the plain text to cipher
text by performing permutations(Re-arrangment) on the plain text, i.e., changing each character of
plain text for each round.
⚫ Mapping plain text into cipher text using transposition technique is called transposition cipher.
⚫ It includes various techniques like the Rail Fence technique, Simple columnar transposition
technique, simple columnar transposition technique with multiple rounds and Vernam cipher to
encrypt the plain text in a secure way.

1.Rail Fence Technique:

⚫ Rail-Fence is the simple Transposition technique that involves writing plain text as a sequence of
diagonals and then reading it row by row to produce the ciphertext.
⚫ Rail fence cipher is easy to implement and even easy for a cryptanalyst to break this technique. So,
there is a need for a more complex technique.
◆ Algorithm :

Step 1: Write down all the characters of plain text message in a sequence of diagnosis.
Step 2: Read the plain text written in step 1 as a sequence of rows.

Example: Plain Text: meet me tomorrow


➢ Now, we will write this plain text sequence wise in a diagonal form

➢ Once you have written the message as a sequence of diagonals, to obtain the cipher text out of it
you have to read it as a sequence of rows. So, reading the first row the first half of cipher text will
be: m e m t m r o

➢ reading the second row of the rail fence, we will get the second half of the cipher text: e t e o o r w

➢ Now, to obtain the complete cipher text combine both the halves of cipher text and the complete
cipher text will be: Cipher Text: M E M T M R O E T E O O R W

2. Simple Columnar Transposition Technique -(Basic):

⚫ The columnar transposition cipher is more complex as compared to the rail fence.
⚫ The simple columnar transposition technique can be categorized into two parts – Basic technique
and multiple rounds.
⚫ Simple columnar transposition technique – basic technique. The simple columnar transposition
technique simply arranges the plain text in a sequence of rows of a rectangle and reads it in a
columnar manner.
◆ Algorithm :

Step 1: Write all the characters of plain text message row by row in a rectangle of predefined size.

Step 2: Read the message in a columnar manner, i.e. column by column.

Note: For reading the message, it needs not to be in the order of columns. It can happen in any random
sequence.

Step 3: The resultant message is ciphertext.

Example: Plain Text: meet tomorrow


➢ Now, put the plain text in the rectangle of a predefined size. For our example, the predefined size
of the rectangle would be 3×4. As you can see in the image below the plain text is placed in the
rectangle of 3×4. the permuted order of the column is 3,1,4,2

col1 col2 col3 col4

M E E T

T O M O

R R O W
➢ Now, to obtain the cipher text we have to read the plain text column by column as the sequence of
permuted column order. So, the cipher text obtained by the columnar transposition technique in
this example is:

Cipher Text: EMOMTRTOWEOR.

➢ Similar to the rail fence cipher, the columnar cipher can be easily broken. The cryptanalyst only
has to try few permutation and combination over the order of column to obtain the permuted
order of column and the get the original message. So, a more sophisticated technique is required
to strengthen the encryption.

3. Simple columnar transposition technique – Multiple rounds


Simple columnar transposition technique with multiple rounds is the same as basic; only the
difference is that we iterate the process multiple times in multiple rounds.

◆ Algorithm :

Step 1: Write all the characters of plain text message row by row in a rectangle of predefined size.

Step 2: Read the message in a columnar manner, i.e. column by column.

Note: For reading the message, it needs not to be in the order of columns. It can happen in any random
sequence.

Step 3: The resultant message is ciphertext.

Step 4: Repeat the procedure from step 1 to step 3 many times as desired.

Example: Plain Text: meet tomorrow


➢ Let us put this plain text in the rectangle of predefined size of 3×4. Proceeding with the next step,
The permuted order of the column is 3,1,4,2

col1 col2 col3 col4

M E E T

T O M O

R R O W

➢ Now after the first round the cipher text obtained is as follow:

Cipher Text round 1: EMOMTRTOWEOR.

➢ Now, again we have to put the cipher text of round 1 in the rectangle of size 3×4 row by row and
permute the order of columns before reading the cipher text for round 2. In the second round, the
permuted order of the column is 2, 3, 1, 4.
col1 col2 col3 col4

M T R E

O R E M

O T O W

➢ So, the obtained cipher text for round 2 is TRTREOMOOEMW. In this way, we can perform as
many iterations as requires. Increasing the number of iterations increases the complexity of the
techniques.

4.Vernam Cipher (one-time pad):


⚫ Vernam cipher algorithm , whose specific subset is called One Time Pad, which is
implemented using random set of non-repeating characters as the input cipher text.
⚫ The most difficult point here is that once and input cipher text for transposition is used it
is never used again for any other message.
⚫ Along with that, the key must be used only once to encrypt and decrypt the individual message
after that the key must be discarded.

Method to take key: In the Vernam cipher algorithm, we take a key to encrypt the plain text whose
length should be equal to the length of the plain text.

◆ Algorithm:
1. Assign a number to each character of the plain-text and the key according to alphabetical order.
2. Add each number corresponding to plain-text alphabet number and Key alphabet number.
3. If the sum is greater than 26 ,subtract it from 26.
4. Assign corresponding alphabet to each number of the sum and this gives the output cipher text.

Example:
Plain Text: H E L L O
Key: B A X Y C
➢ Now according to our encryption algorithm we assign a number to each character of our plain-
text and key.

PT: H E L L O
NO: 7 4 11 11 14

KEY: b a x y c
NO: 1 0 23 24 2
➢ Now add the number of Plain-Text and Key and after doing the addition and subtraction operation
(if required), we will get the corresponding Cipher-Text character number.

ADD: 8 4 34 35 16
➢ In this case, there are two numbers which are greater than the 26 so we have to subtract 26 from
them and after applying the subtraction operation the new Cipher text character numbers are as
follow:

SUB: 8 4 8 9 16
➢ New Cipher-Text is after getting the corresponding character from the number.
Cipher Text: I E I J Q

❖ Differenece between Substitution and Transposition


3.3 Symmetric and asymmetric cryptography:
❖ Introduction to Symmetric encryption:
⚫ Symmetric Key Cryptography also known as Symmetric Encryption.
⚫ Symmetric key cryptography is a type of encryption scheme in which the only one key is used for
both to encrypt and decrypt messages.
⚫ Symmetric-key cryptography is called a shared-key, secret-key, single-key, one-key and eventually
private-key cryptography.
⚫ With this form of cryptography, it is clear that the key should be known to both the sender and the
receiver that the shared.
⚫ Symmetric key cryptography schemes are categorized as stream ciphers or block ciphers.
⚫ Stream ciphers work on a single bit at a time and execute a feedback structure, ensuring the key
changes repeatedly.
⚫ Block ciphers encrypt one block of information at a time using the same key on each block. In a
block cipher, the same plaintext block will encrypt to the same ciphertext, while in a stream cipher,
the same plaintext will encrypt to different ciphertext.

Sender Receiver

➢ Advantages of Symmetric key cryptography:


⚫ It is fast, efficient and easy to implement.
⚫ It is suitable for encrypting large amount of data, such as files,disks or databases.
➢ Disadvantages of Symmetric key cryptography:
⚫ It requires a secure way to distribute and manage keys among the parties involved.
⚫ If the key is compromised, the data can be easily decrypted by an unauthorized person.
⚫ It does not provide non-repeudiation and authentication.
-
❖ Asymmetric Key Cryptography:

⚫ Asymmetric encryption, also known as public-key cryptography, is a type of encryption that

uses a pair of keys to encrypt and decrypt data.

⚫ The pair of keys includes a public key, which can be shared with anyone, and a private key,

which is kept secret by the owner.

⚫ In asymmetric encryption, the sender uses the recipient’s public key to encrypt the data. The

recipient then uses their private key to decrypt the data.

⚫ This approach allows for secure communication between two parties without the need for both

parties to have the same secret key.


⚫ Asymmetric encryption has several advantages over symmetric encryption, which uses the same

key for both encryption and decryption.

Sender Receiver

➢ Advantages of Asymmetric key cryptography:

⚫ It provides non-repeudiation and authentication.

⚫ It allows secure key exchange.

➢ Disadvantages of Symmetric key cryptography:

⚫ It is slower,more complex and hard to implement.

⚫ Not suitable for encrypting large amount of data.


Symmetric Key Encryption Asymmetric Key Encryption

It requires two keys, a public key and a private


It only requires a single key for both encryption
key, one to encrypt and the other one to
and decryption.
decrypt.

The size of cipher text is the same or smaller The size of cipher text is the same or larger
than the original plain text. than the original plain text.

The encryption process is very fast. The encryption process is slow.

It is used when a large amount of data is


It is used to transfer small amounts of data.
required to transfer.

It provides confidentiality, authenticity, and


It only provides confidentiality.
non-repudiation.

The length of key used is 128 or 256 bits The length of key used is 2048 or higher

In symmetric key encryption, resource


In asymmetric key encryption, resource
utilization is low as compared to asymmetric key
utilization is high.
encryption.

It is efficient as it is used for handling large It is comparatively less efficient as it can


amount of data. handle a small amount of data.

It is more secure as two keys are used here-


Security is less as only one key is used for both
one for encryption and the other for
encryption and decryption purpose.
decryption.
Symmetric cryptography:
DES algorithm:

Data encryption standard (DES) has been found vulnerable to very powerful attacks
DES is a block cipher and encrypts data in blocks of size of 64 bits each, which means 64 bits of plain text go
as the input to DES, which produces 64 bits of ciphertext.
The same algorithm and key are used for encryption and decryption, with minor differences. The key
length is 56 bits.

Since DES is based on the Feistel Cipher, all that is required to specify DES is −

• Round function
• Key schedule
• Any additional processing − Initial and final permutation
Initial Permutation (IP):
• As we have noted, the initial permutation (IP) happens only once and it happens before the first
round.
• It suggests how the transposition in IP should proceed, as shown in the figure.
• For example, it says that the IP replaces the first bit of the original plain text block with the 58th bit
of the original plain text, the second bit with the 50th bit of the original plain text block, and so on.

Key generation:
• 64-bit key is transformed into a 56-bit key by discarding every 8th bit of the initial key.
• The 56-bit key is divided into two halves, each of 28 bits. These halves are circularly shifted left by
one or two positions, depending on the round.
• The round numbers 1, 2, 9, or 16 the shift is done by only one position for other rounds, the circular
shift is done by two positions.

Round function:

The entire 64 bits input in the round contains the left hand side 32 bit and right hand side 32 bit.
The DES function applies a 48-bit key to the rightmost 32 bits to produce a 32-bit output.
Expansion Permutation Box :
• Since right input is 32-bit and round key is a 48-bit, we first need to expand right input to 48 bits.
• This happens as the 32-bit RPT is divided into 8 blocks, with each block consisting of 4 bits.
• Then, each 4-bit block of the previous step is then expanded to a corresponding 6-bit block, i.e., per 4-
bit block, 2 more bits are added.

XOR (Whitener). –
• After the expansion permutation, DES does XOR operation on the expanded right section and the
round key.
• The round key is used only in this operation.
Substitution Boxes. –

• The S-boxes carry out the real mixing (confusion).


• DES uses 8 S-boxes, each with a 6-bit input and a 4-bit output.
• There are a total of eight S-box tables. The output of all eight s-boxes is then combined in to 32 bit
section.
Straight Permutation – The 32 bit output of S-boxes is then subjected to the straight permutation

• The right plain text(output of straight permutation) 32 bits are XOR with the left plain text 32 bits
and placed in the right plain text of next round.
• The right plain text 32 bits(before the round function) are placed in the left plain text 32 bits of next
round.
32 bit swap :
After 16 rounds the LPT 32 bits and RPT 32 bits are swapped.
Final permutation:
Final permutation is a straight permutation.
It is inverse of the initial permutation, it is called inverse initial permutation.
After final permutation, the 64 bit cipher text is ready.
AES algorithm:
The more popular and widely adopted symmetric encryption algorithm likely to be used nowadays is the
Advanced Encryption Standard (AES). It is found at least six time faster than triple DES.
The features of AES are as follows −
• Symmetric key symmetric block cipher
• 128-bit data, 128/192/256-bit keys
• Stronger and faster than Triple-DES
• Vulnerable against exhaustive key search attack
• Software implementable in C and Java
State/matrix:
Data block viewed as 4-by-4 table of bytes
Represented as 4 by 4 matrix of 8-bit byte

The matrix shown in the image above is known as a state array.

Encryption:
Pre- round permutation:
You pass the block data stored in the state array through an XOR function with the first key generated (K0).
It passes the resultant state array on as input to the next step.
Each round comprises of 4 steps :
• SubBytes
• ShiftRows
• MixColumns
• Add Round Key
The last round doesn’t have the MixColumns round.
The SubBytes does the substitution
ShiftRows and MixColumns performs the permutation in the algorithm.
1.Sub-Bytes:
In this step, it converts each byte of the state array into hexadecimal, divided into two equal parts.
These parts are the rows and columns, mapped with a substitution box (S-Box) to generate new values for
the final state array.
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.
2.Shift rows:
This step is just as it sounds. Each row is shifted a particular number of times.
• The first row is not shifted
• The second row is shifted once to the left.
• The third row is shifted twice to the left.
• The fourth row is shifted thrice to the left.

(A left circular shift is performed.)


[ b0 | b1 | b2 | b3 ] [ b0 | b1 | b2 | b3 ]
| b4 | b5 | b6 | b7 | -> | b5 | b6 | b7 | b4 |
| b8 | b9 | b10 | b11 | | b10 | b11 | b8 | b9 |
[ b12 | b13 | b14 | b15 ] [ b15 | b12 | b13 | b14 ]

3.MixColumns:

• This step is basically 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.
• This step is not performed in the last round.
4.Add round key:
• The 16 bytes of the matrix are now considered as 128 bits and are XORed to the 128 bits of the
round key.
• The resulting 128 bits are interpreted as 16 bytes and we begin another similar round.
• If this is the last round then the output is the ciphertext.

Decryption Process
The process of decryption of an AES ciphertext is similar to the encryption process in the reverse order.
Each round consists of the four processes conducted in the reverse order −
• Add round key
• Mix columns
• Shift rows
• Byte substitution
International Data Encryption Algorithm (IDEA):
The International Data Encryption Algorithm (IDEA) is a symmetric-key block cipher that was first
introduced in 1991.
Features:
• Symmetric block cipher.
• 64 bit block data is used.
• 128 bits key and 52 subkeys are used.
• 8 rounds.
• 6 keys used in each round except the last round.
• In last round 6 + 4 keys are used.
• 3 operations are used: Addition, Multiplication and XOR.

Subkey generation:
• 128 bit key is divided into 8 parts of 16 bits each.
• Then a cyclic left shift is made for 25 positions to get a new 128 bit key.
• The process is repeated until required keys are generated.

The plaintext of 64-bit input block-divided into 4 part (16 bits each) Declare p1 to p4
The p1, p2, p3 and p4 outputs from each round are given as input to the next round, before giving input to
the next round p2 and p3 are swapped.
This swap between 12 and 13 takes place after each complete round, except the last complete round (8th
round)

The p1, p2, p3 and p4 output from the last round are not swapped and are given as input for final
transformation.

The last output created is 4 blocks of ciphertext C1 to C4 as each one of 16 bits and combine them to make
a ciphertext.
Decryption:
Decryption process is similar to encryption algorithm.
But the keys will be used in reverse order and the inverse of the keys are applied.
Asymmetric key cryptography:
RSA Algorithm:
• The RSA algorithm is a public-key signature algorithm developed by Ron Rivest, Adi Shamir, and Leonard
Adleman.
• RSA algorithm is an asymmetric cryptography algorithm. Asymmetric actually means that it works on
two different keys i.e. Public Key and Private Key.
• There are two broad components when it comes to RSA cryptography, they are:
➢ Key Generation: Generating the keys to be used for encrypting and decrypting the data to be
exchanged.
➢ Encryption/Decryption Function: The steps that need to be run when scrambling and recovering
the data.

Steps to Generate Public Key And Private Key


An individual can generate his public key and private key using the following steps:
Step-01:
Choose any two prime numbers p and q such that
• They are different.
• They are very large.

Step-02:
Calculate ‘n’ and Euler’s totient function Ø(n) where-
• n=pxq
• Ø(n) = (p-1) x (q-1)

Step-03:
Choose any value of ‘e’ such that-
• 1 < e < Ø(n)
• gcd (e, Ø(n)) = 1

Step-04:
Determine ‘d’ such that-

• You already know the value of ‘e’ and Ø(n).


• Choose the least positive integer value of ‘k’ which gives the integer value of ‘d’ as a result.
• Use trial and error method.
• Start substituting different values of ‘k’ from 0.

RSA Algorithm:
Let,
Public key of the receiver = (e , n)
Private key of the receiver = (d , n)
Then, RSA Algorithm works in the following steps
Step-01:
At sender side,
• Sender represents the message to be sent as an integer between 0 and n-1.
• Sender encrypts the message using the public key of receiver.
• It raises the plain text message ‘P’ to the eth power modulo n.
• This converts the message into cipher text ‘C’.

Step-02:
• The cipher text ‘C’ is sent to the receiver over the communication channel

Step-03:
At receiver side,
• Receiver decrypts the cipher text using his private key.
• It raises the cipher text ‘C’ to the dth power modulo n.
• This converts the cipher text back into the plain text ‘P’.

Note: ‘e’ and ‘d’ must be multiplicative inverses modulo Ø(n)


Diffie-Hellman key exchange algorithm:
➢ Diffie–Hellman key exchange is a mathematical method of securely exchanging cryptographic keys
over a public channel.
➢ Two parties can agree on a symmetric key using this network.
➢ This can then be done for key agreement in encryption/decryption.
➢ This algorithm can be done for only key agreement but not for encryption/decryption.
➢ It is based on mathematical principles

Algorithm:
The Diffie-Hellman key exchange works by allowing two parties (Alice and Bob) to agree on a shared secret
key over an insecure channel, without any other party being able to intercept the key or learn anything
about it.
1. Firstly Alice and Bob agree upon two large prime numbers- ‘n’ and ‘g’. These two numbers need not
to be secret and can be shared publicly.
2. Alice chooses another large random number X(private to her).
And calculate ‘A’ such that: A = gX mod n

3. Alice sends this to Bob.

4. Bob chooses another large random number Y(private to him).


And calculate ‘B’ such that: B = gY mod n

5. Bob sends this to Alice.

6. Alice now computes her secret key ‘K1’ as follows:


K1 = Bx mod n

7. Bob now computes her secret key ‘K2’ as follows:


K2 = AY mod n

8. K1 = K2 (key exchange complete)


Step-by-Step explanation is as follows:

Alice Bob

Public Keys available = N, G Public Keys available = N, G

Private Key Selected = x Private Key Selected = y

Key generated = Key generated =


a = G x mod N b = G y mod N

Exchange of generated keys takes place

Key received = b key received = a

Generated Secret Key = Generated Secret Key =


K x = b x mod N K y = a y mod N

Algebraically, it can be shown that


K x= K y

Users now have a symmetric secret key to encrypt


Example:
Hashing
• Hashing is a technique or process of mapping keys, and values into the hash table by using a hash
function.
• The most popular use for hashing is the implementation of hash tables.
• With the introduction of the Hash data structure, it is now possible to easily store data in constant time
and retrieve them in constant time as well.
• Hash tables support functions that include the following:
➢ insert (key, value)
➢ get (key)
➢ delete (key)
• It is done for faster access to elements.
• The efficiency of mapping depends on the efficiency of the hash function used.
Let a hash function H(x) maps the value x at the index x%10 in an Array. For example if the list of values is
[11,12,13,14,15] it will be stored at positions {1,2,3,4,5} in the array or Hash table respectively.

• Cryptography uses multiple hash functions to secure data. Some of the most popular cryptographic
hashes include the following:
➢ Secure Hash Algorithm 1 (SHA-1)
➢ Secure Hash Algorithm 2 (SHA-2)
➢ Secure Hash Algorithm 3 (SHA-3)
➢ MD2
➢ MD4
➢ MD5
• The situation where the newly inserted key maps to an already occupied is called collision.

Components of Hashing
There are majorly three components of hashing:
Key: A Key can be anything string or integer which is fed as input in the hash function.
Hash Function: The hash function receives the input key and returns the index of an element in an array
called a hash table. The index is known as the hash index.
Hash Table: Hash table is a data structure that maps keys to values using a special function called a hash
function. Each data value has its own unique index.
Advantages of Hashing:
a) Key-value support: Hashing is ideal for implementing key-value data structures.
b) Fast data retrieval: Hashing allows for quick access to elements with constant-time complexity.
c) Efficiency: Insertion, deletion, and searching operations are highly efficient.
d) Memory usage reduction: Hashing requires less memory as it allocates a fixed space for storing
elements.
e) Scalability: Hashing performs well with large data sets, maintaining constant access time.
f) Security and encryption: Hashing is essential for secure data storage and integrity verification.

Steganography:
• Steganography is the practice of concealing information within another message or physical object to avoid
detection.
• Steganography can be used to hide virtually any type of digital content, including text, image, video, or audio
content.
• That hidden data is then extracted at its destination.
• The use of steganography can be combined with encryption as an extra step for hiding or protecting data.

Text Steganography
• Text Steganography is hiding information inside the text files.
• It involves things like changing the format of existing text, changing words within a text, generating random
character sequences or using context-free grammars to generate readable texts.

Image Steganography
• Hiding the data by taking the cover object as the image is known as image steganography.
• In digital steganography, images are widely used cover source because there are a huge number of bits
present in the digital representation of an image

Audio Steganography
• In audio steganography, the secret message is embedded into an audio signal which alters the binary
sequence of the corresponding audio file.
• Hiding secret messages in digital sound is a much more difficult process when compared to others, such as
Image Steganography.

Video Steganography
• In Video Steganography you can hide kind of data into digital video format.
• The advantage of this type is a large amount of data can be hidden inside and the fact that it is a moving
stream of images and sounds.
• You can think of this as the combination of Image Steganography and Audio Steganography.
STEGANOGRAPHY CRYPTOGRAPHY

It is a technique to hide the existence It’s a technique to convert data


Definition
of communication into an incomprehensible form

Purpose Keep communication secure Provide data protection

Data
Never Always
Visibility

Data Doesn’t alter the overall structure of


Alters the overall structure of data
Structure data

Optional, but offers more security if


Key Necessary requirement
used

Once the presence of a secret If you possess the decryption key,


Failure message is discovered, anyone can then you can figure out original
use the secret data message from the ciphertext

Digital signature:

• A digital signature is an electronic, encrypted, stamp of authentication on digital information such as

email messages, macros, or electronic documents.

• A digital signature is a mathematical technique used to validate the authenticity and integrity of a digital

document, message or software.

• It's the digital equivalent of a handwritten signature or stamped seal, but it offers far more inherent

security.

• A signature confirms that the information originated from the signer and has not been altered.

You might also like