Unit Ii
Unit Ii
Introduction to Cryptography:
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:
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.
History of Cryptography
Humans have two basic needs when we take about communication. One is the need to
communicate selectively, to communicate and share information. These two basic needs while
communicating gave rise to coding and encrypting the messages in such a way that only intended
people could have access to the information.
The word ‘cryptography’ originated from two greek words ‘Krypto’ means hidden and
‘graphene’ means writing.
Classical Cryptography
The roots are cryptography are found in Roman and Egyptian civilizations. Below are some of
the ancient types of cryptography:
1. Hieroglyphs Cryptography: The earliest known use of Cryptography can be dated back to
1900 BCE during the time of the Old Kingdom of Egypt in form of non-standard hieroglyphs.
• Hieroglyphs were a secret form of communication that the Egyptians used to
communicate with one another.
• This secret text was known only to the scribes of the kings who used to transmit
messages on their behalf.
2. Caesar Cipher: The ancient Greeks were well known for the use of Ciphers. The Caesar
Cipher or Shift Cipher is one of the earliest and simplest well-known cryptographic techniques.
It is a form of Substitution Cipher where each character in a word is replaced by a fixed number
of positions. For example with a shift of 3, A is replaced by D, B by E, and so on.
3. Vigenere Cipher: During the 16th century, Vigenere designed a cipher in which the
encryption key is repeated multiple times spanning the entire message, and then the cipher text
is generated by adding the message character with key character modulo 26. This approach is
also vulnerable to attacks, where the secrecy of the message depends on the secrecy of the
encryption key.
4. Hebern rotating machine: At the start of the 19th century, Hebern designed a Hebern
rotating machine. In this machine, a single rotor is used where the secret key is embedded in the
rotating disc and the key has an embedded substitution table. Each key press from the keyboard
resulted in the output of cipher text. This code is broken by using the letter frequencies.
5. Enigma machine: Cryptography played a vital in the victory of Allied forces during World
War I and World War II. World War II prominently saw the use of electromechanical cipher
machines. The story of the Allied victory over the Germans by cracking the world-famous
Enigma machine is well known. Like all rotor machines, Enigma is a combination of electro-
mechanical subsystems. It consisted of somewhat three to five rotors. Whenever a key was
pressed, one or more rotors rotated on the spindle, and accordingly, the key was scrambled to
something else. The Enigma cipher was broken by Poland.
In the early 1970s, IBM realized that its customer base is requesting some type of encryption
method to protect the data. They formed a crypto group headed by Horst-Feistel. This group
designed a cipher called Lucifer. In 1973, the Nation Bureau of Standards (NBS) which is now
known as the National Institute of Standards and Technology (NIST) put out a proposal for the
block cipher. Lucifer was eventually accepted and called Data Encryption Standard (DES).
• It is a symmetric-key algorithm based on the Feistel cipher and is used for the
encryption of electronic data.
• It has a relatively small key size of 56-bits and is encrypted 64 bits or 8 characters at
a time.
• In 1997, DES was broken by an exhaustive search attack.
• But, it was later discontinued as it was found to be insecure, especially against brute
force attacks cause of its relatively small key size.
In 1997, NIST again put out a proposal for a new block cipher. The Rijndael cipher is eventually
accepted and renamed as Advanced Encryption Standard (AES).
• DES was replaced by Advance Encryption Standard or AES in 2001.
• Unlike DES, AES is based on a substitution-permutation network.
• AES is a sub-set of Rijndael.
• It is a family of ciphers with different key and block sizes.
• In the case of AES, the block size is 128 bits or 16 characters which means 16
characters can be encrypted at a time.
• It comes with three different key size variants: 128 bits, 192 bits, and 256 bits.
In figure 1.1 it made the text secure by forming it into cipher text using encryption algorithm
and further decryption to use it.
The Principles of Security can be classified as follows:
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.
2. Transposition Cipher:
The transposition cipher does not deal with substitution of one symbol with another. It focuses
on changing the position of the symbol in the plain-text. A symbol in the first position in plain-
text may occur in fifth position in cipher-text.
Two of the transposition ciphers are:
Asymmetric – Key Cryptography (Public key
cryptotgraphy):
Encryption:
The process of changing the plaintext into the ciphertext is referred to as encryption.
The encryption process consists of an algorithm and a key. The key is a value independent of the
plaintext.
Security Goals:
The security goals in cryptography and network security revolve around preserving data's
confidentiality, integrity, and availability. These goals are achieved through encryption,
access control, and IP security architecture in cryptography and network security to
ensure data safety while it is in motion and stored.
• Data Privacy(confidentiality)
• Data Authenticity(it came from from where it claims)
• Data integrity(it has not been modified on the way) in the digital world
Confidentiality
Data Integrity
• Integrity Ensures that the message received is the same as the message that was sent
• Uses hashing to create a unique message digest from the message that is sent along with
the message
• Recipient uses the same technique to create a second digest from the message to compare
to the original one
• This technique only protects against unintentional alteration of the message
• A variation is used to create digital signatures to protect against malicious alteration
Authentication
• A user or system can prove their identity to another who does not have personal knowledge
of their identity
• Accomplished using digital certificates
• Kerberos is a common cryptographic authentication system
Cryptographic attacks:
Cryptography attacks are malicious attempts to compromise the security of cryptographic systems,
aiming to exploit vulnerabilities and gain unauthorized access to sensitive information. These
attacks pose a significant threat to the confidentiality, integrity, and availability of encrypted data.
These attacks pose a significant threat to the confidentiality, integrity, and availability of encrypted
data.
Understanding the different types of cryptography attacks is crucial for developing robust security
measures.
Brute Force
Brute force attacks can target various cryptographic systems, including passwords, encryption
keys, and digital signatures.
To mitigate the risk of brute force attacks, employing strong and complex encryption keys is
imperative.
Longer and more intricate keys exponentially increase the time and computational resources
required for attackers to succeed.
The effectiveness of cryptographic defences relies on the resilience against brute force attempts,
emphasising the importance of robust key management practices in the digital security landscape.
In these attacks, the attacker aims to deduce meaningful information from the ciphertext alone,
assuming the cryptographic algorithm is known.
Unlike more complex attacks, cipher-only attacks leverage only the intercepted encrypted
information to uncover potential vulnerabilities in the encryption process.
The effectiveness of cipher-only attacks relies heavily on the strength of the encryption
algorithm employed.
Robust cryptographic systems are designed to withstand such attacks, ensuring that even with
knowledge of the algorithm, deciphering the original information without the key remains a
formidable challenge.
These attacks underscore the importance of selecting secure encryption algorithms that can
withstand scrutiny even when the ciphertext is in the hands of potential adversaries.
In these attacks, adversaries aim to deduce the encryption key based on the known relationship
between certain plaintext and ciphertext pairs.
The challenge for cryptographic systems is to resist compromise even when portions of the
plaintext and corresponding encrypted data are known to the attacker.
The vulnerability lies in the potential exposure of specific data pairs, allowing attackers to analyse
patterns and deduce elements of the encryption key.
Robust encryption algorithms are designed to withstand known plaintext attacks by introducing
complexity and unpredictability, making it challenging for adversaries to extrapolate the
encryption key from limited information.
This type of attack emphasises the importance of developing and implementing encryption
methods that can effectively secure information even when portions of the data are known to
potential attackers.
This type of attack aims to deduce information about the encryption key by analysing the outcomes
of deliberately chosen input and output pairs.
In chosen plaintext attacks, attackers exploit their ability to manipulate the encryption process,
revealing patterns that may lead to the compromise of the cryptographic system.
The challenge for cryptographic defences lies in constructing algorithms that remain secure even
when subjected to intentional manipulation by adversaries.
Robust encryption methods employ intricate mathematical structures and mechanisms to resist
chosen plaintext attacks, ensuring that the system’s integrity and confidentiality are upheld.
As cybersecurity evolves, the continuous development of encryption techniques that can withstand
such advanced attacks becomes pivotal in maintaining the security of sensitive information.
In these attacks, attackers manipulate the decryption process, aiming to deduce sensitive
information or the encryption key itself.
The challenge lies in creating encryption methods that maintain security even when attackers have
a level of control over the ciphertexts they choose to decrypt.
Effective cryptographic defences focus on introducing complexities and safeguards that thwart the
adversary’s ability to extract meaningful information from intentionally chosen ciphertexts,
ensuring the confidentiality and integrity of encrypted data.
Key and Algorithm Attack
Key and algorithm attacks in cryptography target the vulnerability of the encryption key or the
underlying algorithm itself.
Criminals aim to exploit weaknesses in either the cryptographic key or the algorithm, seeking
unauthorised access to encrypted information.
In key attacks, the adversary focuses on compromising the encryption key, while algorithm attacks
aim to exploit flaws in the mathematical processes governing encryption.
To counteract key and algorithm attacks, robust key management practices and secure algorithms
are crucial.
The strength of cryptographic systems lies in the complexity and unpredictability introduced into
both the encryption key and algorithm.
By continually enhancing key and algorithm security, cryptographic defences ensure resilience
against sophisticated attacks, safeguarding sensitive information from unauthorised access and
manipulation.
Regular updates and advancements in cryptographic practices are essential to stay ahead of
evolving threats in the dynamic landscape of digital security.
These attacks do not directly target the algorithm or key but focus on exploiting auxiliary
information, such as power consumption, timing, or electromagnetic radiation.
By analysing these side channels, adversaries attempt to deduce sensitive information or gain
insights into the cryptographic operations.
Protecting against side channel attacks requires additional measures beyond traditional
cryptographic methods.
Replay Attacks
Replay attacks in cryptography involve the malicious retransmission of captured data to gain
unauthorised access or manipulate system behaviour.
Attackers intercept and duplicate previously recorded data transmissions, aiming to deceive the
system into accepting replicated information as legitimate.
These attacks exploit the lack of mechanisms to distinguish between original and duplicated data.
Preventing replay attacks necessitates the implementation of measures that can detect and discard
repeated or out-of-sequence data transmissions.
Time-stamping and sequence numbers are common techniques employed to mitigate the risk of
replay attacks.
By incorporating these safeguards, cryptographic systems can verify the freshness and authenticity
of incoming data, thwarting attempts to exploit repeated transmissions for unauthorised access or
manipulation.
Network Security is field in computer technology that deals with ensuring security of computer
network infrastructure. As the network is very necessary for sharing of information whether it is
at hardware level such as printer, scanner, or at software level. Therefore security mechanism
can also be termed as is set of processes that deal with recovery from security attack. Various
mechanisms are designed to recover from these specific attacks at various protocol layers.
2. Hash Functions
There is no usage of any key in this algorithm. A hash value with a fixed length is calculated as
per the plain text which makes it impossible for the contents of plain text to be recovered. Many
operating systems use hash functions to encrypt passwords.
3. Asymmetric Key Cryptography
In Asymmetric Key Cryptography, 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 keys and Private keys are different. Even if the public key is known by everyone the
intended receiver can only decode it because he alone knows his private key. The most popular
asymmetric key cryptography algorithm is the RSA algorithm.
The first thing to know about cryptography is that there is no single universal method
for encrypting your message. There are many ways to do it, each with its advantages and
disadvantages. Today's most common encryption methods are public and symmetric key
cryptography.
Many cryptographic algorithms arise naturally out of their use in other contexts, such as digital
signature schemes or encryption techniques for secure electronic commerce over insecure
networks such as the Internet. For example, RSA cryptosystems were initially developed to solve
integer factorization.
Cryptography is sometimes used by criminals to avoid detection and allow illicit messages to be
passed along without interception. It is also used by public-key cryptosystems such as RSA, which
are widely used in security protocols.
Encryption Algorithms
There are several types of encryption algorithms; these include block ciphers and stream ciphers.
• A block cipher encrypts blocks of plaintext and decrypts them one at a time.
Cryptographic algorithms have a basic algorithm that produces a key, and then they each use this
key to encrypt and decrypt information. But there are many ways to go about it.
• One way is to use a block cipher, which takes several bytes and converts them into a
more extended sequence of bytes. This process is called encryption.
• The other way is to take a block cipher, convert it into something smaller, and then
convert it back into the original block size. This process is called decryption (or
deciphering).
• Symmetric algorithms use the same key to encrypt and decrypt the data, while
asymmetric algorithms use two separate keys, one to encrypt and one to interpret the
data.
• The algorithms also use a message authentication code (MAC) to ensure the message's
integrity.
Substitution Cipher:
• some data is known as encryption. When plain text is encrypted it becomes unreadable
Hiding
and is known as ciphertext. In a Substitution cipher, any character of plain text from the given
fixed set of characters is substituted by some other character from the same set depending on a
key. For example with a shift of 1, A would be replaced by B, B would become C, and so on.
Note: Special case of Substitution cipher is known as Caesar cipher where the key is taken as 3.
Mathematical representation
The encryption can be represented using modular arithmetic by first transforming the letters into
numbers, according to the scheme, A = 0, B = 1,…, Z = 25. Encryption of a letter by a shift n can
be described mathematically as.
Examples:
Plain Text: I am studying Data Encryption
Key: 4
Output: M eq wxyhCmrk Hexe IrgvCtxmsr
Example
A simple example for a transposition cipher is columnar transposition cipher where each
character in the plain text is written horizontally with specified alphabet width. The cipher is
written vertically, which creates an entirely different cipher text.
Consider the plain text hello world, and let us apply the simple columnar transposition technique
as shown below
The plain text characters are placed horizontally and the cipher text is created with vertical format
as : holewdlo lr. Now, the receiver has to use the same table to decrypt the cipher text to plain
text.
Stream Ciphers:
•
In stream cipher, one byte is encrypted at a time while in block cipher ~128 bits are encrypted at
a time. Initially, a key(k) will be supplied as input to pseudorandom bit generator and then it
produces a random 8-bit output which is treated as keystream. The resulted keystream will be of
size 1 byte, i.e., 8 bits. Stream ciphers are fast because they encrypt data bit by bit or byte by byte,
which makes them efficient for encrypting large amounts of data quickly.Stream ciphers work well
for real-time communication, such as video streaming or online gaming, because they can encrypt
and decrypt data as it’s being transmitted.
Key Points of Stream Cipher
1. Stream Cipher follows the sequence of pseudorandom number stream.
2. One of the benefits of following stream cipher is to make cryptanalysis more difficult,
so the number of bits chosen in the Keystream must be long in order to make
cryptanalysis more difficult.
3. By making the key more longer it is also safe against brute force attacks.
4. The longer the key the stronger security is achieved, preventing any attack.
5. Keystream can be designed more efficiently by including more number of 1s and 0s,
for making cryptanalysis more difficult.
6. Considerable benefit of a stream cipher is, it requires few lines of code compared to
block cipher.
Encryption
For Encryption,
• Plain Text and Keystream produces Cipher Text (Same keystream will be used for
decryption.).
• The Plaintext will undergo XOR operation with keystream bit-by-bit and produces
the Cipher Text.
Example:
Plain Text : 10011001
Keystream : 11000011
Cipher Text : 01011010
Email communication is one way to show asymmetric encryption in action. Let’s say Alice and
Bob have a public-private key pair and Alice wishes to send Bob an encrypted message. Using
Bob’s public key, Alice encrypts her message before sending it to him. Bob uses his private key
to decrypt the message after receiving it encrypted.
For instance, Alice composes and encrypts an email for Bob using Bob’s public key. She follows
up by sending Bob the encrypted email. After receiving the email, Bob uses his private key to
decrypt it so that it may be read. As a result, Alice can communicate Bob securely without being
concerned that the message’s content will be viewed by someone else.
With the use of the matching private key, only the intended recipient may decode and read the
email, guaranteeing the confidentiality of its contents. To provide secure and private
communication over the internet, asymmetric encryption is commonly employed in a variety of
communication methods, including messaging apps, digital signatures, and file encryption.
The main features of asymmetric encryption (also known as public-key cryptography) are:
1. Dual keys: Asymmetric encryption uses a pair of keys, including a public key and a
private key. The public key can be freely shared with anyone, while the private key is
kept secret and known only to the key owner.
2. Encryption and decryption: Asymmetric encryption uses the public key to encrypt
data and the private key to decrypt data. This allows secure communication between
two parties without the need to exchange secret keys.
3. Digital signatures: Asymmetric encryption enables the creation of digital signatures,
which can be used to verify the authenticity of data. A digital signature is created by
encrypting a hash of the data with the sender’s private key.
4. Secure key exchange: Asymmetric encryption allows for secure key exchange,
which is a critical feature in secure communication. For example, the Diffie-Hellman
key exchange algorithm uses asymmetric encryption to establish a shared secret key
between two parties without exchanging the key itself.
5. Security: Asymmetric encryption is considered more secure than symmetric
encryption because it eliminates the need to exchange secret keys, which can be a
security risk. Additionally, the private key is kept secret, which makes it harder for
attackers to intercept or tamper with the data.
6. Slow processing: Asymmetric encryption is slower than symmetric encryption
because it involves more complex mathematical operations. This can make it less
suitable for applications that require fast data processing.
Now we are ready with our – Public Key ( n = 3127 and e = 3) and Private Key(d = 2011) Now
we will encrypt “HI”:
Convert letters to numbers : H = 8 and I = 9
Thus Encrypted Data c = (89e)mod n
Thus our Encrypted Data comes out to be 1394
Now we will decrypt 1394 :
Decrypted Data = (cd)mod n
Thus our Encrypted Data comes out to be 89
8 = H and I = 9 i.e. "HI".
• Neal Koblitz and Victor S. Miller independently proposed the use of elliptic curves in
encryption in 1985.
• Elliptic curve cryptography algorithms entered wide use from 2004 to 2005.
• In the mid-1980s, researchers found that examining elliptic curves could lead to the
discovery of new sources of difficult problems. Elliptic Curve Cryptography (ECC)
introduced a new degree of security to public key cryptosystems, that provide combined
encryption and digital signature services.
• The security of elliptic curve cryptosystems, like that of all public-key cryptosystems,
is based on tough mathematical issues at the core. Given two elliptic curve points G
and Y, where Y = kG.
• The term “elliptic curve” is derived from the ellipse. Elliptic curves were discovered in
the form of the Diophantine equation for c, after the 17th century. Furthermore, while
calculating the surface of the ellipse is simple, calculating the circumference of the
ellipse is difficult. The equation can be simplified to an integral: