UNIT 1
Cryptography Introduction
Cryptography is the study and practice of techniques for secure communication in the
presence of third parties called adversaries.
It deals with developing and analyzing protocols that prevents malicious third parties
from retrieving information being shared between two entities thereby following the
various aspects of information security. Secure Communication refers to the scenario
where the message or data shared between two parties can’t be accessed by an
adversary.
In Cryptography, an Adversary is a malicious entity, which aims to retrieve precious
information or data thereby undermining the principles of information security.
Data Confidentiality, Data Integrity, Authentication and Non-repudiation are core
principles of modern-day cryptography.
1. Confidentiality refers to certain rules and guidelines usually executed under confidentiality
agreements which ensure that the information is restricted to certain people or places.
2. Data integrity refers to maintaining and making sure that the data stays accurate and
consistent over its entire life cycle.
3. Authentication is the process of making sure that the piece of data being claimed by the
user belongs to it.
4. Non-repudiation refers to the ability to make sure that a person or a party associated with a
contract or a communication cannot deny the authenticity of their signature over their
document or the sending of a message.
Consider two parties Alice and Bob. Now, Alice wants to send a message m to Bob
over a secure channel. So, what happens is as follows.
The sender’s message or sometimes called the Plaintext, is converted into an
unreadable form using a Key k. The resultant text obtained is called the Ciphertext.
This process is known as Encryption.
At the time of received, the Ciphertext is converted back into the plaintext using the
same Key k, so that it can be read by the receiver. This process is known as Decryption.
Alice (Sender) Bob (Receiver)
C = E (m, k) ----> m = D (C, k)
Here, C refers to the Ciphertext while E and D are the Encryption and Decryption algorithms
respectively.
Let’s consider the case of Caesar Cipher or Shift Cipher as an example. As the name suggests,
in Caesar’s Cipher each character in a word is replaced by another character under some
defined rules.
Thus, if A is replaced by D, B by E and so on. Then, each character in the word would be
shifted by a position of 3.
For example:
Plaintext : Geeksforgeeks
Ciphertext : Jhhnvirujhhnv
Note: Even if the adversary knows that the cipher is based on Caesar’s Cipher, it cannot
predict the plaintext as it doesn’t have the key in this case which is to shift the characters back
by three places. Refer to Introduction to Crypto-terminologies .
Types of Cryptography:
There are several types of cryptography, each with its own unique features and applications.
Some of the most common types of cryptography include:
1. Symmetric-key cryptography: This type of cryptography involves the use of a single key
to encrypt and decrypt data. Both the sender and receiver use the same key, which must be kept
secret to maintain the security of the communication.
2. Asymmetric-key cryptography: Asymmetric-key cryptography, also known as public-key
cryptography, uses a pair of keys – a public key and a private key – to encrypt and decrypt
data. The public key is available to anyone, while the private key is kept secret by the owner.
Hash functions: A hash function is a mathematical algorithm that converts data of any size
into a fixed-size output. Hash functions are often used to verify the integrity of data and ensure
that it has not been tampered with.
Applications of Cryptography:
Cryptography has a wide range of applications in modern-day communication, including:
Secure online transactions: Cryptography is used to secure online transactions, such as
online banking and e-commerce, by encrypting sensitive data and protecting it from
unauthorized access.
Digital signatures: Digital signatures are used to verify the authenticity and integrity of
digital documents and ensure that they have not been tampered with.
Password protection: Passwords are often encrypted using cryptographic algorithms to
protect them from being stolen or intercepted.
Military and intelligence applications: Cryptography is widely used in military and intelligence
applications to protect classified information and communications.
Challenges of Cryptography:
While cryptography is a powerful tool for securing information, it also presents several
challenges, including:
Key management: Cryptography relies on the use of keys, which must be managed
carefully to maintain the security of the communication.
Quantum computing: The development of quantum computing poses a potential threat to
current cryptographic algorithms, which may become vulnerable to attacks.
Human error: Cryptography is only as strong as its weakest link, and human error can
easily compromise the security of a communication.
2. Network Security Model
A Network Security Model exhibits how the security service has been designed over the
network to prevent the opponent from causing a threat to the confidentiality or authenticity of the
information that is being transmitted through the network.
In this section, we will be discussing the general ‘network security model’ where we will study
how messages are shared between the sender and receiver securely over the network. And we
will also discuss the ‘network access security model’ which is designed to secure your system
from unwanted access through the network
For a message to be sent or receive there must be a sender and a receiver. Both the sender and
receiver must also be mutually agreeing to the sharing of the message. Now, the transmission of
a message from sender to receiver needs a medium i.e. Information channel which is
an Internet service.
A logical route is defined through the network (Internet), from sender to the receiver and using
the communication protocols both the sender and the receiver established communication.
Well, we are concerned about the security of the message over the network when the message
has some confidential or authentic information which has a threat from an opponent present at
the information channel. Any security service would have the three components discussed
below:
1. Transformation of the information which has to be sent to the receiver. So, that any opponent
present at the information channel is unable to read the message. This indicates
the encryption of the message.
It also includes the addition of code during the transformation of the information which will be
used in verifying the identity of the authentic receiver.
2. Sharing of the secret information between sender and receiver of which the opponent must
not any clue. Yes, we are talking of the encryption key which is used during the encryption of
the message at the sender’s end and also during the decryption of message at receiver’s end.
3. There must be a trusted third party which should take the responsibility of distributing the
secret information (key) to both the communicating parties and also prevent it from any
opponent.
Now we will study a general network security model with the help of the figure given below:
The network security model presents the two communicating parties sender and receiver who
mutually agrees to exchange the information. The sender has information to share with the
receiver.
But sender cannot send the message on the information cannel in the readable form as it will
have a threat of being attacked by the opponent. So, before sending the message through the
information channel, it should be transformed into an unreadable format.
Secret information is used while transforming the message which will also be required when
the message will be retransformed at the recipient side. That’s why a trusted third party is
required which would take the responsibility of distributing this secret information to both the
parties involved in communication.
So, considering this general model of network security, one must consider the following four
tasks while designing the security model.
1. To transform a readable message at the sender side into an unreadable format, an appropriate
algorithm should be designed such that it should be difficult for an opponent to crack that
security algorithm.
2. Next, the network security model designer is concerned about the generation of the secret
information which is known as a key.
This secret information is used in conjunction with the security algorithm in order to transform
the message.
3. Now, the secret information is required at both the ends, sender’s end and receiver’s end. At
sender’s end, it is used to encrypt or transform the message into unreadable form and at the
receiver’s end, it is used to decrypt or retransform the message into readable form.
So, there must be a trusted third party which will distribute the secret information to both
sender and receiver.
While designing the network security model designer must also concentrate on developing the
methods to distribute the key to the sender and receiver.
An appropriate methodology must be used to deliver the secret information to the
communicating parties without the interference of the opponent.
It is also taken care that the communication protocols that are used by the communicating
parties should be supporting the security algorithm and the secret key in order to achieve the
security service.
Till now we have discussed the security of the information or message over the network. Now,
we will discuss the network access security m
odel which is designed to secure the information system which can be accessed by the attacker
through the network.
You are well aware of the attackers who attack your system that is accessible through the
internet. These attackers fall into two categories:
1. Hacker: The one who is only interested in penetrating into your system. They do not cause
any harm to your system they only get satisfied by getting access to your system.
2. Intruders: These attackers intend to do damage to your system or try to obtain the
information from the system which can be used to attain financial gain.
The attacker can place a logical program on your system through the network which can affect
the software on your system. This leads to two kinds of risks:
a. Information threat: This kind of threats modifies data on the user’s behalf to which actually
user should not access. Like enabling some crucial permission in the system.
b. Service threat: This kind of threat disables the user from accessing data on the system.
Well, these kinds of threats can be introduced by launching worms and viruses and may more
like this on your system. Attack with worms and viruses are the software attack that can be
introduced to your system through the internet.
The network security model to secure your system is shown in the figure below:
There are two ways to secure your system from attacker of which the first is to introduce
the gatekeeper function. Introducing gatekeeper function means introducing login-
id and passwords which would keep away the unwanted access.
In case the unwanted user gets access to the system the second way to secure your system is
introducing internal control which would detect the unwanted user trying to access the system
by analyzing system activities. This second method we call as antivirus which we install on our
system to prevent the unwanted user from accessing your computer system through the internet.
So, this is all about the network security model. We have discussed two network security model.
One, securing your information over the network during information transmission.
Second, securing your information system which can be accessed by the hacker through the
network or internet.
Data encryption standard (DES) | Set 1
The Data Encryption Standard (DES), a historic encryption algorithm known for its 56-bit key
length. We explore its operation, key transformation, and encryption process, shedding light on
its role in data security and its vulnerabilities in today’s context.
What is DES?
Data Encryption Standard (DES) is a block cipher with a 56-bit key length that has played a
significant role in data security.
Data encryption standard (DES) has been found vulnerable to very powerful attacks therefore,
the popularity of DES has been found slightly on the decline.
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.
The basic idea is shown below:
We have mentioned that DES uses a 56-bit key. Actually, The initial key consists of 64 bits.
However, before the DES process even starts, every 8th bit of the key is discarded to produce a
56-bit key. That is bit positions 8, 16, 24, 32, 40, 48, 56, and 64 are discarded.
Thus, the discarding of every 8th bit of the key produces a 56-bit key from the original 64-bit
key.
DES is based on the two fundamental attributes of cryptography: substitution (also called
confusion) and transposition (also called diffusion). DES consists of 16 steps, each of which is
called a round. Each round performs the steps of substitution and transposition. Let us now
discuss the broad-level steps in DES.
In the first step, the 64-bit plain text block is handed over to an initial Permutation (IP)
function.
The initial permutation is performed on plain text.
Next, the initial permutation (IP) produces two halves of the permuted block; saying Left
Plain Text (LPT) and Right Plain Text (RPT).
Now each LPT and RPT go through 16 rounds of the encryption process.
In the end, LPT and RPT are rejoined and a Final Permutation (FP) is performed on the
combined block
The result of this process produces 64-bit ciphertext.
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.
This is nothing but jugglery of bit positions of the original plain text block. the same rule applies
to all the other bit positions shown in the figure.
As we have noted after IP is done, the resulting 64-bit permuted text block is divided into two
half blocks. Each half-block consists of 32 bits, and each of the 16 rounds, in turn, consists of the
broad-level steps outlined in the figure.
Step 1: Key transformation
We have noted initial 64-bit key is transformed into a 56-bit key by discarding every 8th
bit of the initial key.
Thus, for each a 56-bit key is available. From this 56-bit key, a different 48-bit Sub Key
is generated during each round using a process called key transformation.
For this, 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.
For example: if 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. The number of key bits shifted per round is
shown in the figure.
After an appropriate shift, 48 of the 56 bits are selected. From the 48 we might obtain 64 or 56
bits based on requirement which helps us to recognize that this model is very versatile and can
handle any range of requirements needed or provided.
For selecting 48 of the 56 bits the table is shown in the figure given below.
For instance, after the shift, bit number 14 moves to the first position, bit number 17 moves to
the second position, and so on. If we observe the table , we will realize that it contains only 48-
bit positions.
Bit number 18 is discarded (we will not find it in the table), like 7 others, to reduce a 56-bit key
to a 48-bit key. Since the key transformation process involves permutation as well as a selection
of a 48-bit subset of the original 56-bit key it is called Compression Permutation.
Because of this compression permutation technique, a different subset of key bits is used in each
round. That makes DES not easy to crack.
Step 2: Expansion Permutation
Recall that after the initial permutation, we had two 32-bit plain text areas called Left
Plain Text (LPT) and Right Plain Text(RPT).
During the expansion permutation, the RPT is expanded from 32 bits to 48 bits. Bits are
permuted as well hence called expansion permutation. 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.
This process results in expansion as well as a permutation of the input bit while creating output.
The key transformation process compresses the 56-bit key to 48 bits.
Then the expansion permutation process expands the 32-bit RPT to 48-bits. Now the 48-bit key
is XOR with 48-bit RPT and the resulting output is given to the next step, which is the S-Box
substitution.
What is steganography?
Steganography is the technique of hiding data within an ordinary, nonsecret file or message to
avoid detection; the hidden data is then extracted at its destination.
Steganography use can be combined with encryption as an extra step for hiding or protecting
data. The word steganography is derived from the Greek word steganos, meaning "hidden or
covered," and the Greek root graph, meaning "to write."
Steganography can be used to conceal almost any type of digital content, including text, image,
video or audio content.
The secret data can be hidden inside almost any other type of digital content. The content to be
concealed through steganography -- called hidden text -- is often encrypted before being
incorporated into the innocuous-seeming cover text file or data stream.
If not encrypted, the hidden text is commonly processed in some method to increase the
difficulty of detecting the secret content.
What are some examples of steganography?
Steganography is practiced by those wishing to convey a secret message or code. While there are
many legitimate uses for steganography, some malware developers use steganography to obscure
the transmission of malicious code -- known as stegware.
Forms of steganography have been used for centuries and include almost any technique for
hiding a secret message in an otherwise harmless container.
For example, using invisible ink to hide secret messages in otherwise inoffensive messages;
hiding documents recorded on microdot, which can be as small as 1 millimeter in diameter;
hiding messages on or inside legitimate-seeming correspondence; and even using multiplayer
gaming environments to share information.
How is steganography used today?
In modern digital steganography, data is first encrypted or obfuscated, and then inserted using a
special algorithm into data that is part of a particular file format, such as a JPEG image, audio or
video file. The secret message can be embedded into ordinary data files in many ways.
One technique is to hide data in bits that represent the same color pixels repeated in a row in an
image file.
By applying the encrypted data to this redundant data in an inconspicuous way, the result is an
image file that appears identical to the original image, but has noise patterns of regular,
unencrypted data.
The practice of adding a watermark -- a trademark or other identifying data hidden in multimedia
or other content files -- is a common use of steganography.
Online publishers often use watermarking to identify the source of media files that are being
shared without permission.
While there are many different uses of steganography, including embedding sensitive
information into file types, one of the most common techniques is to embed a text file into an
image file.
When done correctly, anyone viewing the image file should not see a difference between the
original image file and the altered file; this is accomplished by storing the message with less
significant bites in the data file. This process can be completed manually or by using a
steganography tool.
What are the advantages of steganography over cryptography?
Steganography is distinct from cryptography. Using both together can help improve the security
of the protected information and prevent detection of the secret communication.
If steganographically hidden data is also encrypted, the data might still be safe from detection --
though the channel will no longer be safe from detection. There are advantages to using
steganography combined with encryption over encryption-only communication.
The primary advantage of using steganography to hide data over cryptography is that it helps
obscure the fact that sensitive data is hidden in the file or other content carrying the hidden text.
Whereas an encrypted file, message or network packet payload is clearly marked and identifiable
as such, using steganographic techniques helps to obscure the presence of a secure channel.
Steganography software
Steganography software is used to perform a variety of functions, including the following:
Hiding data, including encoding the data to prepare it to be hidden inside another file.
Keeping track of which bits of the cover text file contain hidden data.
Encrypting the data to be hidden.
Extracting hidden data by its intended recipient.
Proprietary and open source programs are available to do steganography. OpenStego is one open
source steganography program. Other programs can be characterized by the types of data that
can be hidden, as well as what types of files that data can be hidden inside.
Some online steganography software tools include Xiao Steganography, used to hide secret files
in BMP images or WAV files; Image Steganography, a JavaScript tool that hides images inside
other image files; and Crypture, a command-line tool.