Cryptography (Module 1) Notes
Cryptography (Module 1) Notes
of codes so that only those person for whom the information is intended can
understand it and process it. Thus preventing unauthorized access to information.
The prefix “crypt” means “hidden” and suffix “graphy” means “writing”. 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. These algorithms are used
for cryptographic key generation, digital signing, verification to protect data privacy,
web browsing on internet and to protect confidential transactions such as credit card
and debit card transactions.
Techniques used For Cryptography: In today’s age of computers 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. The process of conversion of cipher
text to plain text this is known as decryption.
Features Of Cryptography are as follows:
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 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.
Types Of Cryptography: In general there are three types Of cryptography:
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. Symmetric Key Systems are faster and simpler but the
problem is that sender and receiver have to somehow exchange key in a
secure manner. The most popular symmetric key cryptography system are
Data Encryption System(DES) and Advanced Encryption System(AES).
2. Hash Functions: There is no usage of any key in this algorithm. 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. Many operating
systems use hash functions to encrypt passwords.
3. Asymmetric Key Cryptography: Under this system a pair of keys is used
to encrypt and decrypt information. A receiver’s public key is used for
encryption and a receiver’s private key is used for decryption. Public key
and Private Key are different. Even if the public key is known by everyone
the intended receiver can only decode it because he alone know his private
key. The most popular asymmetric key cryptography algorithm is RSA
algorithm.
Applications Of Cryptography:
1. Computer passwords: Cryptography is widely utilized in computer
security, particularly when creating and maintaining passwords. When a
user logs in, their password is hashed and compared to the hash that was
previously stored. Passwords are hashed and encrypted before being
stored. In this technique, the passwords are encrypted so that even if a
hacker gains access to the password database, they cannot read the
passwords.
2. Digital Currencies: To safeguard transactions and prevent fraud, digital
currencies like Bitcoin also use cryptography. Complex algorithms and
cryptographic keys are used to safeguard transactions, making it nearly
hard to tamper with or forge the transactions.
3. Secure web browsing: Online browsing security is provided by the use of
cryptography, which shields users from eavesdropping and man-in-the-
middle assaults. Public key cryptography is used by the Secure Sockets
Layer (SSL) and Transport Layer Security (TLS) protocols to encrypt data
sent between the web server and the client, establishing a secure channel
for communication.
4. Electronic signatures: Electronic signatures serve as the digital
equivalent of a handwritten signature and are used to sign documents.
Digital signatures are created using cryptography and can be validated
using public key cryptography. In many nations, electronic signatures are
enforceable by law, and their use is expanding quickly.
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. Cryptographic methods are
employed by authentication protocols to confirm the user’s identity and
confirm that they have the required access rights to the resource.
6. Cryptocurrencies: Cryptography is heavily used by cryptocurrencies like
Bitcoin and Ethereum to safeguard transactions, thwart fraud, and
maintain the network’s integrity. Complex algorithms and cryptographic
keys are used to safeguard transactions, making it nearly hard to tamper
with or forge the transactions.
7. End-to-End Encryption: End-to-end encryption is used to protect two-
way communications like video conversations, instant messages, and
email. Even if the message is encrypted, it assures that only the intended
receivers can read the message. End-to-end encryption is widely used in
communication apps like WhatsApp and Signal, and it provides a high
level of security and privacy for users.
Advantages
Type of Attacks
The main aim of any organisation is to protect their data from attackers.
In cryptography, attacks are of two types such as Passive attacks and
Active attacks.
Passive attacks are those that retrieve information from the system without
affecting the system resources while active attacks are those that retrieve
system information and make changes to the system resources and their
operations.
1. Confidentiality:
The degree of confidentiality determines the secrecy of the information.
The principle specifies that only the sender and receiver will be able to
access the information shared between them. Confidentiality compromises
if an unauthorized person is able to access a message.
For example, let us consider sender A wants to share some confidential
information with receiver B and the information gets intercepted by the
attacker C. Now the confidential information is in the hands of an intruder
C.
2. Authentication:
Authentication is the mechanism to identify the user or system or the
entity. It ensures the identity of the person trying to access the
information. The authentication is mostly secured by using username and
password. The authorized person whose identity is preregistered can prove
his/her identity and can access the sensitive information.
3. Integrity:
Integrity gives the assurance that the information received is exact and
accurate. If the content of the message is changed after the sender sends it
but before reaching the intended receiver, then it is said that the integrity
of the message is lost.
System Integrity: System Integrity assures that a system performs its
intended function in an unimpaired manner, free from deliberate or
inadvertent unauthorized manipulation of the system.
Data Integrity: Data Integrity assures that information (both stored and in
transmitted packets) and programs are changed only in a specified
and authorized manner.
4. Non-Repudiation:
Non-repudiation is a mechanism that prevents the denial of the message
content sent through a network. In some cases the sender sends the message and
later denies it. But the non-repudiation does not allow the sender to refuse the
receiver.
5. Access control:
The principle of access control is determined by role management and rule
management. Role management determines who should access the data while rule
management determines up to what extent one can access the data. The information
displayed is dependent on the person who is accessing it.
6. Availability:
The principle of availability states that the resources will be available to
authorize party at all times. Information will not be useful if it is not available to be
accessed. Systems should have sufficient availability of information to satisfy the
user request.
There are various types of substitution ciphers which are as follows −
Examples(Encryption):
Plain text —
H E L L O
7 4 11 11 14
key—
M O N E Y
12 14 13 4 24
Cipher Text
T (19) S(18) Y(24) P(15) M(12)
Examples(Decryption):
All the techniques examined so far involve the substitution of a cipher text symbol for a plaintext
symbol. A very different kind of mapping is achieved by performing some sort of permutation on
the plaintext letters. This technique is referred to as a transposition cipher.
1. Rail fence
2. Row Transposition Ciphers
In a transposition cipher, the order of the alphabets is re-arranged to obtain the cipher-text.
In the rail fence cipher, the plain-text is written downwards and diagonally on successive rails of
an imaginary fence.
When we reach the bottom rail, we traverse upwards moving diagonally, after reaching the top
rail, the direction is changed again. Thus the alphabets of the message are written in a zig-zag
manner.
After each alphabet has been written, the individual rows are combined to obtain the cipher-
text.
For example, if the message is “GeeksforGeeks” and the number of rails = 3 then cipher is prepared
as:
Steganography is a means of concealing secret information within (or even on top of)
an otherwise mundane, non-secret document or other media to avoid detection. It
comes from the Greek words steganos, which means “covered” or “hidden,” and
graph, which means “to write.” Hence, “hidden writing.”
You can use steganography to hide text, video, images, or even audio data. It’s a
helpful bit of knowledge, limited only by the type of medium and the author’s
imagination.
Since the computer description of an image contains multiple bits, images are
frequently used as a cover source in digital steganography.
Message - Real data that you can mask within pictures. The message may be in the form
of standard text or an image.
Stego-Key - Messages can be embedded in cover images and stego-images with the
help of a key, or the messages can be derived from the photos themselves.
Embedding text in a picture (like an artist hiding their initials in a painting they’ve done)
Hiding an image in a video, viewable only if the video is played at a particular frame rate
Embedding a secret message in either the green, blue, or red channels of an RRB image
Types Of Cryptography: In general there are three types Of cryptography:
Applications Of Cryptography:
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 defence 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.
Block Cipher Design Principles
Block ciphers are built in the Feistel cipher structure. Block cipher has a specific
number of rounds and keys for generating ciphertext.Block cipher is a type of
encryption algorithm that processes fixed-size blocks of data, usually 64 or 128 bits,
to produce ciphertext. The design of a block cipher involves several important
principles to ensure the security and efficiency of the algorithm. Some of these
principles are:
1. Number of Rounds – The number of Rounds is regularly considered in design
criteria, it just reflects the number of rounds to be suitable for an algorithm to
make it more complex, in DES we have 16 rounds ensuring it to be more secure
while in AES we have 10 rounds which makes it more secure.
2. Design of function F – The core part of the Feistel Block cipher structure is the
Round Function. The complexity of cryptanalysis can be derived from the Round
function i.e. the increasing level of complexity for the round function would be
greatly contributing to an increase in complexity. To increase the complexity of
the round function, the avalanche effect is also included in the round function, as
the change of a single bit in plain text would produce a mischievous output due
to the presence of avalanche effect.
3. Confusion and Diffusion: The cipher should provide confusion and diffusion to
make it difficult for an attacker to determine the relationship between the
plaintext and ciphertext. Confusion means that the ciphertext should be a
complex function of the key and plaintext, making it difficult to guess the key.
Diffusion means that a small change in the plaintext should cause a significant
change in the ciphertext, which makes it difficult to analyse the encryption
pattern.
4. Key Size: The key size should be large enough to prevent brute-force attacks. A
larger key size means that there are more possible keys, making it harder for an
attacker to guess the correct one. A key size of 128 bits is considered to be secure
for most applications.
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.
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.
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.
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.
Triple DES:
Triple DES is a encryption technique which uses three instance of DES on same
plain text. It uses there different types of key choosing technique in first all used
keys are different and in second two keys are same and one is different and in third
all keys are same.
Group
A group (G) is indicated by {G,∙}. It is a group of elements with a binary
operation ′ ∙ ′ that satisfies four properties. The properties of Group are as
follows −
• R = A mod B
• A = B, B = R
• return A
Example GCD(1970,1066)
GCD(1970,1066) = 2
Modular Arithmetic
Modular Addition:
Rule for modular addition is:
(a + b) mod m = ((a mod m) + (b mod m)) mod m
Example:
(15 + 17) % 7
= ((15 % 7) + (17 % 7)) % 7
= (1 + 3) % 7
= 4 % 7
= 4
Modular Multiplication:
The Rule for modular multiplication is:
(a x b) mod m = ((a mod m) x (b mod m)) mod m
Example:
(12 x 13) % 5
= ((12 % 5) x (13 % 5)) % 5
= (2 x 3) % 5
= 6 % 5
= 1
Modular Inverse:
The modular inverse of a mod m exists only if a and m are relatively prime i.e.
gcd(a, m) = 1. Hence, for finding the inverse of an under modulo m, if (a x b) mod m
= 1 then b is the modular inverse of a.
Example: a = 5, m = 7 (5 x 3) % 7 = 1 hence, 3 is modulo inverse of 5 under 7.