CS unit 1
CS unit 1
H.S.Mistry
• Well, the idea here is to make sure that data has not been
modified. Corruption of data is a failure to maintain data
integrity. To check if our data has been modified or not, we make
use of a hash function.
We have two common types: SHA (Secure Hash Algorithm) and
MD5(Message Direct 5). Now MD5 is a 128-bit hash and SHA is a
160-bit hash if we’re using SHA-1. There are also other SHA
methods that we could use like SHA-0, SHA-2, and SHA-3.
Availability
• This means that the network should be readily available to its users.
This applies to systems and to data. To ensure availability, the network
administrator should maintain hardware, make regular upgrades,
have a plan for fail-over, and prevent bottlenecks in a network.
Attacks such as DoS or DDoS may render a network unavailable as the
resources of the network get exhausted. The impact may be
significant to the companies and users who rely on the network as a
business tool. Thus, proper measures should be taken to prevent such
attacks.
1.3 OSI SECURITY ARCHITECTURE
• The International Telecommunication Union (ITU) recommends the
Open System Interconnection (OSI) Security architecture , which
outlines a methodical way to specify security needs and method to
satisfy those criteria.
• The OSI security architecture provides a general description of
security services, security mechanisms, as well as a description of
security attacks
1.3.1 Security Attacks
• Attack: An assault on system security that devices from an intelligent
threat; that is , an intelligent act that is deliberate attempt to evade
security services and violate the security policy of a system
• A security attack is an activity or act made upon a system with the
goal to obtain unauthorized access to information or resources. It is
usually carried out by evading security policies that are in place in
organizations or individuals devices.
• Security attacks can be classified into two categories:
• Active attack
• Passive attack
• Threat: A potential for violation of security, which exist when there is
a circumstances, capability, actions, or event that could breach
security and cause harm.
1.3.2 Security Mechanism
• A security mechanism is a method or technology that protects data
and systems from unauthorized access, attacks, and other threats.
Security measures provide data integrity, confidentiality, and
availability, thereby protecting sensitive information and maintaining
trust in digital transactions. In this article, we will see types of security
mechanisms.
1.3.3 Security Services:
• “ A processing or communication services that is provided by a system
to give a specific kind of protection to system resources”
• The OSI security architecture classifies security services as follow:
• Authentication
• Access control services
• Data confidentiality
• Data integrity
• Non-repudiation
1.4 CRYPTOGRAPHY AND CRYPTOGRAPHIC
TECHNIQUES
• 1.4.1 Basic cryptographic terms:
• Cryptography: “ Cryptography is the art of archiving security by
encoding message to make them non-readable”
• Cryptanalysis: “ Cryptanalysis is the technique of decoding messages
from a non-readable format without knowing how they were initially
converted from readable format to non readable format.”
• Cryptology: “Cryptology is a combination of cryptography and
cryptanalysis.”
Cryptography + Cryptanalysis = Cryptology
• Plaintext or Clear text : “Any original message that can be readable and
understand by the sender , the recipient, and also by anyone else who
gets access to that message.”
• Cipher Text: “ When an original plain-text message is codified using any
suitable scheme into the form which is not understandable by other
then the sender and the recipient, then such resulting message is called
cipher text.”
• Encryption : “The process of encoding plain text message into cipher
text message is called encryption”
• Decryption: “The reverse process of transforming cipher text message
back to plain text message is called decryption.”
1.4.2 Cryptographic techniques
[A] Substitution Techniques
• Caesar Cipher
• Monoalphabetic Cipher
• Polyalphabetic Cipher
• Playfair Cipher
• Hill Cipher
• One-time Pad
Caser Cipher
• The Caesar cipher is a simple encryption technique that was used by
Julius Caesar to send secret messages to his allies. It works by shifting
the letters in the plaintext message by a certain number of positions,
known as the “shift” or “key”. The Caesar Cipher technique is one of
the earliest and simplest methods of encryption techniques.
• 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. For example with a shift of 1, A would be replaced by B, B
would become C, and so on. The method is apparently named after
Julius Caesar, who apparently used it to communicate with his
officials.
• For example, if the shift is 3, then the letter A would be replaced by
the letter D, B would become E, C would become F, and so on. The
alphabet is wrapped around so that after Z, it starts back at A.
• Here is an example of how to use the Caesar cipher to encrypt the
message “HELLO” with a shift of 3:
• Write down the plaintext message: HELLO
• Choose a shift value. In this case, we will use a shift of 3.
• Replace each letter in the plaintext message with the letter that is
three positions to the right in the alphabet.
• H becomes K (shift 3 from H)
E becomes H (shift 3 from E)
L becomes O (shift 3 from L)
L becomes O (shift 3 from L)
O becomes R (shift 3 from O)
• 4.The encrypted message is now “KHOOR”.
Monoalphabetic Cipher
• A monoalphabetic cipher is a substitution cipher where each letter in
the plaintext is replaced by another letter in the ciphertext. In this
cipher, each letter is consistently replaced by the same corresponding
letter across the entire message.
• The key is simply a mapping of the letters in the alphabet to other
letters. This mapping can be random or follow any fixed rule. The key
remains the same for the entire message.
• Steps for Encryption (Using Monoalphabetic Cipher):
• Choose a key: This key is the mapping of each letter in the alphabet to
another letter. The mapping can be random.
• Encrypt the message: Each letter in the plaintext is replaced by its
corresponding letter from the key.
• Example:
• Step 1: Create a key for substitution.
• Let’s create a simple substitution key where we randomly map letters
to other letters:
• Plaintext alphabet: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
• Ciphertext alphabet: D M S E L G Q T R V X A Z H B U I F P W Y J K C O
N
• Here, we will replace:
• A→D
• B→M
• C→S
• D→E
• E→L
• F→G
• G→Q
• H→T
• I→R
• J→V
• K→X
• L→A
• M→Z
• N→H
• O→B
• P→U
• Q→I
• R→F
•S→P
•T→W
• U→Y
• V→J
• W→K
• X→C
•Y→O
• Z→N
• Step 2: Encrypt a message.
• Let’s encrypt the message "HELLO".
•H→T
•E→L
•L→A
•L→A
•O→B
• So, the encrypted message is: "TLAAB".
• Step 3: Decrypting the message.
• To decrypt, you simply reverse the substitution by using the same key.
The receiver will replace each letter in the ciphertext with the
corresponding letter from the plaintext alphabet.
• T→H
•L→E
•A→L
•A→L
•B→O
Difference between ceasar cipher
and monoalphabetic cipher
• Caesar Cipher:
• Shift-based: Each letter in the plaintext is shifted by a fixed number of
positions in the alphabet. For example, with a shift of 3:
• A→D
• B→E
• C→F
• and so on.
• If the shift is 3, the word "HELLO" becomes "KHOOR."
• The key in a Caesar cipher is always a number (the shift).
• Monoalphabetic Cipher:
• Substitution-based: Each letter in the plaintext is replaced with a
specific letter in the ciphertext. The mapping can be random, and it's
not necessarily a shift.
• For example, A → P, B → M, C → Z, etc. This mapping is fixed but can be
different from a Caesar cipher.
• The key in a monoalphabetic cipher is the specific letter mapping
(which could be anything, not just a shift).
• In summary:
• Caesar cipher is a type of monoalphabetic cipher with a fixed shift.
• Monoalphabetic cipher allows for any kind of letter substitution, not
just shifting.
Polyalphabetic Cipher
• A polyalphabetic cipher is a type of substitution cipher where each
letter in the plaintext is replaced by a letter from a different alphabet,
based on a key. The key determines how much to shift each letter, and
it repeats to cover the entire message. This makes it harder to break
than the monoalphabetic cipher, where each letter is replaced by the
same letter.
• Example (Vigenère Cipher):
• Message: "HELLO"
Key: "KEY" (repeated as needed)
• Step 1: Write the plaintext and key, repeating the key to match the
length of the message.
• Plaintext: H E L L O
• Key: K E Y K E
• Step 2: Encrypt each letter based on the key.
• H (shift by K = 10) → R
• E (shift by E = 4) → I
• L (shift by Y = 24) → J
• L (shift by K = 10) → V
• O (shift by E = 4) → S
• Ciphertext: "RIJVS“
• n a polyalphabetic cipher like the Vigenère cipher, each letter in the
plaintext is encrypted using a shifting pattern determined by the key,
making it more secure than monoalphabetic ciphers.
• H (7) with K (10): Shift H (7) by 10 → R (17)
• E (4) with E (4): Shift E (4) by 4 → I (8)
• L (11) with Y (24): Shift L (11) by 24 → J (9) (Since 11 + 24 = 35, and 35
mod 26 = 9)
• L (11) with K (10): Shift L (11) by 10 → V (21)
• O (14) with E (4): Shift O (14) by 4 → S (18)
• When we say "a mod b", we're asking for the remainder when a is
divided by b.
• For example, 35 mod 26 means "what is the remainder when 35 is
divided by 26?"
• 35 divided by 26 gives a quotient of 1 (because 26 fits into 35 once)
and a remainder of 9.
• So, 35 mod 26 = 9.
Playfair Cipher
• The Playfair Cipher is a classical encryption technique used for
encrypting messages. It is a substitution cipher based on a 5x5 grid of
letters.
• Rules of the Playfair Cipher:
• Create a Key Square:
• Use a keyword to fill a 5x5 grid with unique letters.
• Omit the letter 'J' (combine it with 'I').
• Fill remaining spaces with other letters of the alphabet.
• Divide the Plaintext into Digraphs:
• Split the plaintext into pairs of two letters (e.g., "HELLO" → "HE", "LL", "O").
• If a pair has two identical letters (e.g., "LL"), insert a filler (e.g., "X") between
them.
• If the plaintext has an odd length, add a filler (e.g., "X") at the end.
• Encryption Rules:
• For each pair of letters:
• Same Row: Replace each letter with the letter to its right (wrap to the beginning if at the
end).
• Same Column: Replace each letter with the letter below it (wrap to the top if at the
bottom).
• Rectangle Rule: Replace each letter with the one in the same row but in the column of the
other letter.
• Decryption:
• Reverse the encryption process:
• Same row: Move left.
• Same column: Move up.
• Rectangle rule: Use the opposite corners.
• Example:
• Key: "MONARCHY“
• Plaintext: "HELLO"
• Create the 5x5 grid (omit 'J')
• Divide into digraphs: "HE", "LX", "LO"
(Add filler "X" between duplicate "L" and at the end if needed.)
• Encrypt each digraph:
• HE: H and E form a rectangle → replace with "C" and "F".
• LX: L and X are in the same row → replace with “S" and "U".
• LO: L and O form a rectangle → replace with “P" and “M".
• Ciphertext: "CFSUPM"
• Same Row: Replace each letter with the letter to its right (wrap
around if needed).
• Same Column: Replace each letter with the letter below it (wrap
around if needed).
• Rectangle Rule: Replace with the opposite corners of the rectangle.
[B] Transposition techniques
• The transposition technique is a kind of encryption that works by
performing permutation on the given plaintext. Transposition ciphers
are created by using the transposition technique to map normal text
into ciphertext.
• This chapter will cover multiple uses of the transposition technique as
well as the variations between transposition and the substitution
technique.
• On the other hand, the substitution approach substitutes a symbol in
plaintext with a symbol in ciphertext. However, the transposition
method generates the ciphertext by applying permutation to the
original plaintext.
• Rail Fence Transposition
• Columnar Transposition
• Columnar Transposition - Multiple Rounds
• Book Cipher/Running Key Cipher
• Vernam Cipher
Rail Fence Transposition
• Rail-Fence is a basic Transposition method in which plaintext is
written as a series of diagonals, which is then read row by row to
generate the ciphertext.
Plaintext: Let us meet Today
We will now write this simple sentence in a diagonal
format, as you can see below, following a specific
order −
• Ciphertext: LTSETOAEUMETDY
• The rail fence cipher is simple to use and even simpler to break for a
cryptanalyst. Thus, a more complex method is required.
Columnar Transposition
• In comparison to the rail fence, the columnar transposition cipher is
more complex. To get ciphertext using this method, use these steps −