Security and Cryptography (BIT8322 )
CRYPTOGRAPHY
Dr. Nadia IRADUKUNDA
E-mail: iradukundanadia1@gmail.com
niradukunda@mkurwanda.ac.rw
Kigali, Rwanda
Cryptography
v The prefix “crypt” means “hidden” and suffix “graphy” means “writing”.
v Cryptography is the art of keeping information secure by transforming it into form
that unintended recipients cannot understand.
n In cryptography, an original human readable message, referred to as plaintext, is
changed by means of an algorithm, or series of mathematical operations, into
something that to an uninformed observer would look like gibberish; this
gibberish is called ciphertext
v Cryptography is often associated with the process where an ordinary plain text is
converted to cipher text which is the text made such that intended receiver of the
text can only decode it and hence this process is known as encryption.
v The process of conversion of cipher text to plain text this is known as decryption.
2
Cryptography
3
Goals/aims of Cryptography
4
Goals/aims of Cryptography
1. Confidentiality: Information can only be accessed by the person for whom it is
intended and no other person except him can access it.
2. Integrity: Information cannot be modified in storage or transition between sender
and intended receiver without any addition to information being detected.
3. Non-repudiation: The assurance that someone cannot deny the validity of
something. The creator/sender of information cannot deny his intention to send
information at later stage.
4. Authentication: The identities of sender and receiver are confirmed. As well as
destination/origin of information is confirmed.
5
Types of Cryptography
1. Symmetric Key Cryptography:
2. Asymmetric Key Cryptography:
3. Hash Functions:
6
1. Symmetric Key Cryptography
v 1. Symmetric Key Cryptography: It is an encryption system where the sender and
receiver of message use a single common key to encrypt and decrypt messages.
n Symmetric Key Systems are faster and simpler but the problem is that sender
and receiver have to somehow exchange key in a secure manner.
n The most popular symmetric key cryptography system is Data Encryption
System(DES).
7
vSymmetric-key cryptography, is where a single key is used for
encryption and decryption. Also known as Secret key cryptography.
8
2. Asymmetric Key Cryptography
v 2. Asymmetric Key Cryptography: Under this system a pair of keys is used to
encrypt and decrypt information.
n A public key is used for encryption and a private key is used for decryption.
n Public key and Private Key are different.
n Even if the public key is known by everyone the intended receiver can only
decode it because he alone knows the private key.
9
Asymmetric Key Cryptography also known as Public key
v The private key is given to the receiver while the public key is provided to the
public/sender.
v Asymmetric cryptography is also known as Public Key Cryptography
11
On the basis of Public key Private key
Definition It is defined as the technique that uses It is defined as the technique that uses a
two different keys for encryption and single shared key (secret key) to encrypt
decryption. and decrypt the message.
Known as It is also called as Asymmetric key It is also called as symmetric key
encryption. encryption. It is because the same secret
key is used in bidirectional communication.
Efficiency It is inefficient as this technique is used It is efficient as this technique is
only for short messages. recommended for large amounts of text.
Speed It is slower as it uses two different keys; It is faster as it uses a single key for
both keys are related to each other encryption and decryption.
through the complicated mathematical
process.
Secret It is free to use. Apart from the sender and receiver, the
private key is kept secret and not public to
anyone.
Purpose The main purpose of the public key The main purpose of the secret key
algorithm is to share the keys securely. algorithm is to transmit the bulk data.
Loss of key There is a less possibility of key loss, as There is a possibility of losing the key that
the key held publicly. renders the system void.
3. Hash Functions:
v 3. Hash Functions: There is no usage of any key in this algorithm.
n A hash value with fixed length is calculated as per the plain text which makes it
impossible for contents of plain text to be recovered.
n Many operating systems use hash functions to encrypt passwords.
13
The difference between hashing and encryption
In short:
+ encryption is a two-way function
that includes encryption and
decryption whilst
+ hashing is a one-way function
that changes a plain text to a
unique digest that is irreversible.
14
HASHING
v Hashing is used to validate the integrity of the content by detecting all
modifications and thereafter changes to a hash output.
v Encryption encodes data for the primary purpose of maintaining data
confidentiality and security.
n It requires a private key to reversible function encrypted text to plain text
v Hashing and encryption are different but also have some similarities.
n They are both ideal in handling data, messages, and information in computing
systems.
n They both transform or change data into a different format.
n While encryption is reversible, hashing is not.
n Future improvements are very crucial given that attackers keep changing
tactics. This implies that an up-to-date way of hashing and encrypting is more
palatable in modern computing systems.
15
Applications Of Cryptography:
1. Computer passwords: Passwords are hashed and encrypted before being
stored..
2. Digital Currencies: To safeguard transactions and prevent fraud, digital currencies
like Bitcoin also use cryptography.
3. Secure web browsing: Public key cryptography is used by the Secure Sockets
Layer (SSL) and Transport Layer Security.
4. Electronic signatures: Electronic signatures serve as the digital equivalent of a
handwritten signature and are used to sign documents.
5. Authentication: Cryptography is used for authentication in many different situations,
such as when accessing a bank account, logging into a computer, or using a secure
network.
7. End-to-End Encryption: End-to-end encryption is used to protect two-way
communications like video conversations, instant messages, and email.
16
Advantages Of Cryptography:
1. Access Control: Cryptography can be used for access control to ensure that only
parties with the proper permissions have access to a resource. Only those with the
correct decryption key can access the resource thanks to encryption.
2. Secure Communication: For secure online communication, cryptography is
crucial. It offers secure mechanisms for transmitting private information like
passwords, bank account numbers, and other sensitive data over the internet.
3. Protection against attacks: Cryptography aids in the defense against various
types of assaults, including replay and man-in-the-middle attacks. It offers strategies
for spotting and stopping these assaults.
4. Compliance with legal requirements: Cryptography can assist firms in meeting a
variety of legal requirements, including data protection and privacy legislation
17
ENCRYPTION
TECHNIQUES
18
CLASSICAL AND MODERN ENCRYPTION
TECHNIQUES
19
CLASSICAL ENCRYPTION:
v There are two basic building blocks of all encryption techniques: substitution and
transposition.
v A substitution technique is one in which the letters of plaintext are replaced by
other letters or by numbers or symbols.
v In the transposition technique, the characters' identities are kept the same, but
their positions are altered to produce the ciphertext.
n A transposition cipher in cryptography is a type of encryption that scrambles
the locations of characters without altering the characters themselves.
20
Substitution techniques
21
a) Caesar Cipher(Shift cipher):
v The Caesar Cipher technique is one of the earliest and simplest methods of
encryption technique.
n The method is apparently named after Julius Caesar, who apparently used it to
communicate with his officials.
v It’s simply a type of substitution cipher, i.e., each letter of a given text is replaced
by a letter with a fixed number of positions down the alphabet.
n For example with a shift of 1, A would be replaced by B, B would become C, and so
on.
v ORDER OF ALPHABETS: ABCDEFGHIJKLMNOPQRSTUVWXYZ
v Example
Plaintext V O Y A G E R
Key +3 +3 +3 +3 +3 +3 +3
Ciphertext Y R B D J H U
22
QUIZ
vBy using Caesar Cipher, encrypt the following: Key = +5
1. WORK HARD
2. REMAIN FOCUSSED
23
DISCUSSION
1. a. By using Caesar Cipher (KEY = +4), decrypt the following:
(i) XLI WOC MW RS PSRKIVXLI PMQMX
b. By using Caesar Cipher, encrypt the following using a shift of +3:
(i) DREAM BIG
(ii) AIM HIGHER
24
Playfair Cipher
25
SUBSTITUTION - b) Playfair Cipher
v The Playfair cipher was the first practical digraph substitution cipher.
v The scheme was invented in 1854 by Charles Wheatstone but was named after Lord
Playfair who promoted the use of the cipher.
v In playfair cipher, we encrypt a pair of alphabets (digraphs) instead of a single alphabet.
v Process:
v 1. Generate the key Square(5×5):
n The key square is a 5×5 grid of alphabets that acts as the key for encrypting the
plaintext.
n Each of the 25 alphabets must be unique and one letter of the alphabet (usually J) is
omitted from the table (as the table can hold only 25 alphabets).
n If the plaintext contains J, then it is replaced by I.
n The initial alphabets in the key square are the unique alphabets of the key in the order
in which they appear followed by the remaining letters of the alphabet in order.
26
b) Playfair Cipher: Process:
v 1. Generate the key Square(5×5): M O N A R
n The key square is a 5×5 grid of C H Y B D
alphabets that acts as the key for
E F G I/J K
encrypting the plaintext.
L P Q S T
n Each of the 25 alphabets must be unique
and one letter of the alphabet (usually J) U V W X Z
is omitted from the table (as the table can
hold only 25 alphabets).
v 1. If the plaintext contains J, then it is replaced by I.
n The initial alphabets in the key square are the unique alphabets of
the key in the order in which they appear followed by the remaining
letters of the alphabet in order.
27
SUMMARY: RULES FOR ENCRYPTION USING PLAY CIPHER
28
b) Playfair Cipher: Process:
v2. Algorithm to encrypt the plain text: The plaintext is split into pairs of
two letters (digraphs).
vEXCEPTIONS
vIf there is an odd number of letters, a Z is added to the last letter.
n For example:
n PlainText: "instruments"
n After Split: 'in' 'st' 'ru' 'me' 'nt' 'sz’ -------à z is added as a “bogus”
29
b) Playfair Cipher: Process: Algorithm to encrypt the plain text
vThe plaintext is split into pairs of two letters (digraphs).
vIf there are consecutive same letters. Pair cannot be made with same
letter. Break the letter in single and add a bogus letter to the previous
letter.
n Plain Text: “hello”
n After Split: ‘he’ ‘lx’ ‘lo’
n Here ‘x’ is the bogus letter.
30
b) Playfair Cipher: Process:
1. The plaintext is split into pairs of two letters (digraphs).
vIf the letter is standing alone in the process of pairing, then add an
extra bogus letter with the alone letter
n Plain Text: “helloe” AfterSplit: ‘he’ ‘lx’ ‘lo’ ‘ez’
n Here ‘z’ is the bogus letter.
31
Rules for Encryption:
v 2. ENCRYPTION
v If both the letters are in the same column: Take the letter below each one (going
back to the top if at the bottom).
n For example:
n Diagraph: "me"
M O N A R
n Encrypted Text: cl
C H Y B D
n Encryption:
m -> c E F G I K
e -> l L P Q S T
U V W X Z
32
CONT.
v If both the letters are in the same row: Take the letter to the right of each one
(going back to the leftmost if at the rightmost position).
n For example:
n Diagraph: "st"
n Encrypted Text: tl
n Encryption:
n s -> t
n t -> l
33
CONT.
v If neither of the above rules is true: Form a rectangle with the two letters and take
the letters on the horizontal opposite corner of the rectangle.
n For example:
n Diagraph: "nt"
n Encrypted Text: rq
n Encryption:
n n -> r
n t -> q
34
Examples: Attack
35
Examples: Attack
36
Examples: Attack
37
Examples: mosque
38
Examples: mosque
39
Examples: mosque
40
Examples: mosque
41
Examples: mosque
42
43
QUIZ
vBy usingPlayFair Cipher, encrypt the following:
(i) WELL DONE IS BETTER THAN WELL SAID
44
DISCUSSION
1. Using Play Fair Cipher, Encrypt this message
(i) “THE MOST CERTAIN WAY TO SUCCEED IS ALWAYS TO TRY JUST ONE
MORE TIME”
(ii) “IN THE MIDDLE OF DIFFICULTY LIES OPPORTUNITY”
2. Using Play Fair Cipher (Key is Cryptography), Encrypt this message:
(i) “AIM FOR SUCCESS AND WORK FOR IT”
(ii) “ALL OUR DREAMS CAN COME TRUE IF WE HAVE THE COURAGE TO
PURSUE THEM”
45
TRANSPOSITION
TECHNIQUES
46
Transposition technique
v a) Rail fence cipher
v In the rail fence cipher, the plain-text is written downwards and diagonally on
successive rails of an imaginary fence.
n When we reach the bottom rail, we traverse upwards moving diagonally,
n After reaching the top rail, the direction is changed again.
n Thus the alphabets of the message are written in a zig-zag manner.
v After each alphabet has been written, the individual rows are combined to obtain
the cipher-text.
v For example, if the message is “GeeksforGeeks” and the number of rails = 3 then
cipher is prepared as:
47
CONT.
Its encryption will be done row wise i.e. GSGSEKFREKEOE
48
REVIEW QUESTIONS
vBy using Rail fence cipher, encrypt the following by:
1. WORK HARD. using number of rails = 4
2. REMAIN FOCUSSED. using number of rails = 5
3. BE THE CHANGE THAT YOU WISH TO SEE IN THE WORLD. using
number of rails = 8
4. AIM HIGHER. using number of rails = 4
5. NO MAN IS AN ISLAND. using number of rails = 3
49
DISCUSSION
1. a. Elaborate more on what is meant by “VPN” and its operation.
b. Discuss the benefits of a VPN connection.
c. Expound the types of VPNs as used in security and Cryptography.
2. a. What is meant by “Firewall” in information security?
b. Explain in details the different types of firewalls.
c. Discuss the various advantages of firewall in information Security.
3. a. Using a concrete example, discuss how “Monoalphabetic cipher”
work.
b. Using a concrete example, discuss how the reverse of
“monoalphabetic” work.
4. Encrypt the following using Rail Fence Cipher:
NO MAN IS AN ISLAND. using number of rails = 3
REMAIN FOCUSSED. using number of rails = 5
50
MODERN ENCRYPTION
v Encryption ensures that information stays private and confidential, whether it's being
stored or in transit.
v Here are some essential encryption terms :
v Algorithm
n Also known as a cipher, algorithms are the rules or instructions for the encryption process.
n The key length, functionality, and features of the encryption system in use determine the
effectiveness of the encryption.
v Decryption
n Decryption is the process of converting unreadable ciphertext to readable information.
v Key
n An encryption key is a randomized string of bits used to encrypt and decrypt data.
n Each key is unique, and longer keys are harder to break.
n Typical key lengths are 128 and 256 bits for private keys and 2048 for public keys.
51
CONT.
v There are two kinds of cryptographic key
v Symmetric Key Systems
n In a symmetric key system, everyone accessing the data has the same key.
n Keys that encrypt and decrypt messages must also remain secret to ensure privacy.
n While it's possible for this to work, securely distributing the keys to ensure proper
controls are in place makes symmetric encryption impractical for widespread
commercial use.
v Asymmetric Key Systems
n An asymmetric key system, also known as a public/private key system, uses two keys.
n One key remains secret—the private key—while the other key is made widely available
to anyone who needs it.
n This key is called the public key. The private and public keys are mathematically tied
together, so the corresponding private key can only decrypt that information encrypted
using the public key
52
DISCUSSION
DISCUSS in details THE FOLLOWING COMMON Encryption
Algorithms:
1. Triple Data Encryption Standard (DES)
2. Advanced Encryption Standard (AES)
3. RSA (Rivest-Shamir-Adleman) Security
4. Blowfish
5. Twofish
6. polyalphabetic cipher
7. Hill cipher, Row column Transposition
53
Common Encryption Algorithms:
1. Triple DES
v Triple DES was designed to replace the original Data Encryption Standard (DES)
algorithm, which hackers eventually learned to defeat with relative ease. At one time,
Triple DES was the recommended standard and the most widely used symmetric
algorithm in the industry.
v Triple DES uses three individual keys with 56 bits each. The total key length adds up to
168 bits, but experts would argue that 112-bits in key strength is more accurate. Despite
slowly being phased out, Triple DES has, for the most part, been replaced by the
Advanced Encryption Standard (AES).
2. AES
v The Advanced Encryption Standard (AES) is the algorithm trusted as the standard by the
U.S. Government and numerous organizations. Although it is highly efficient in 128-bit
form, AES also uses keys of 192 and 256 bits for heavy-duty encryption purposes.
v AES is largely considered impervious to all attacks, except for brute force, which attempts
to decipher messages using all possible combinations in the 128, 192, or 256-bit cipher.
54
CONT.
v 3. RSA Security
v RSA is a public-key encryption algorithm and the standard for encrypting data sent over the
internet. It also happens to be one of the methods used in PGP and GPG programs. Unlike
Triple DES, RSA is considered an asymmetric algorithm due to its use of a pair of keys.
You've got your public key to encrypt the message and a private key to decrypt it. The result
of RSA encryption is a huge batch of mumbo jumbo that takes attackers a lot of time and
processing power to break.
v 4. Blowfish
v Blowfish is yet another algorithm designed to replace DES.
v This symmetric cipher splits messages into blocks of 64 bits and encrypts them individually.
v Blowfish is known for its tremendous speed and overall effectiveness.
v Meanwhile, vendors have taken full advantage of its free availability in the public domain.
v You'll find Blowfish in software categories ranging from e-commerce platforms for securing
payments to password management tools, where it protects passwords.
v It's one of the more flexible encryption methods available.
55
CONT.
v 5. Twofish
v Computer security expert Bruce Schneier is the mastermind behind Blowfish and its
successor Twofish.
v Keys used in this algorithm may be up to 256 bits in length, and as a symmetric
technique, you only need one key.
v Twofish is one of the fastest of its kind and ideal for use in hardware and software
environments.
v Like Blowfish, Twofish is freely available to anyone who wants to use it.
56
Thank you for Your Attention
Dr. Nadia IRADUKUNDA
E-mail: iradukundanadia1@gmail.com
niradukunda@mkurwanda.ac.rw