Unit 4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

➢ Cryptography

Cryptography is technique of securing information and communications through use 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 transiti receiver on between sender
and intended 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 is Data Encryption System(DES).
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
public key is used for encryption and a 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 knows the private key.
➢ Public Key Cryptography
Unlike symmetric key cryptography, we do not find historical use of public-key
cryptography. It is a relatively new concept.
Symmetric cryptography was well suited for organizations such as governments, military,
and big financial corporations were involved in the classified communication.
With the spread of more unsecure computer networks in last few decades, a genuine need was
felt to use cryptography at larger scale. The symmetric key was found to be non-practical due
to challenges it faced for key management. This gave rise to the public key cryptosystems.
The process of encryption and decryption is depicted in the following illustration −

The most important properties of public key encryption scheme are −


• Different keys are used for encryption and decryption. This is a property which
set this scheme different than symmetric encryption scheme.
• Each receiver possesses a unique decryption key, generally referred to as his
private key.
• Receiver needs to publish an encryption key, referred to as his public key.
• Some assurance of the authenticity of a public key is needed in this scheme to
avoid spoofing by adversary as the receiver. Generally, this type of
cryptosystem involves trusted third party which certifies that a particular
public key belongs to a specific person or entity only.
• Encryption algorithm is complex enough to prohibit attacker from deducing
the plaintext from the ciphertext and the encryption (public) key.
• Though private and public keys are related mathematically, it is not be feasible
to calculate the private key from the public key. In fact, intelligent part of any
public-key cryptosystem is in designing a relationship between two keys.
➢ RSA Cryptosystem
This cryptosystem is one the initial system. It remains most employed cryptosystem even
today. The system was invented by three scholars Ron Rivest, Adi Shamir, and Len
Adleman and hence, it is termed as RSA cryptosystem.
We will see two aspects of the RSA cryptosystem, firstly generation of key pair and secondly
encryption-decryption algorithms.
Generation of RSA Key Pair
Each person or a party who desires to participate in communication using encryption needs to
generate a pair of keys, namely public key and private key. The process followed in the
generation of keys is described below −
• Generate the RSA modulus (n)
o Select two large primes, p and q.
o Calculate n=p*q. For strong unbreakable encryption, let n be a
large number, typically a minimum of 512 bits.
• Find Derived Number (e)
o Number e must be greater than 1 and less than (p − 1)(q − 1).
o There must be no common factor for e and (p − 1)(q − 1) except for 1.
In other words two numbers e and (p – 1)(q – 1) are coprime.
• Form the public key
o The pair of numbers (n, e) form the RSA public key and is made
public.
o Interestingly, though n is part of the public key, difficulty in
factorizing a large prime number ensures that attacker cannot
find in finite time the two primes (p & q) used to obtain n. This
is strength of RSA.
• Generate the private key
o Private Key d is calculated from p, q, and e. For given n and e,
there is unique number d.
o Number d is the inverse of e modulo (p - 1)(q – 1). This means
that d is the number less than (p - 1)(q - 1) such that when
multiplied by e, it is equal to 1 modulo (p - 1)(q - 1).
o This relationship is written mathematically as follows −
ed = 1 mod (p − 1)(q − 1)
The Extended Euclidean Algorithm takes p, q, and e as input and gives d as output.
Example
An example of generating RSA Key pair is given below. (For ease of understanding, the
primes p & q taken here are small values. Practically, these values are very high).
• Let two primes be p = 7 and q = 13. Thus, modulus n = pq = 7 x 13 = 91.
• Select e = 5, which is a valid choice since there is no number that is common
factor of 5 and (p − 1)(q − 1) = 6 × 12 = 72, except for 1.
• The pair of numbers (n, e) = (91, 5) forms the public key and can be made
available to anyone whom we wish to be able to send us encrypted messages.
• Input p = 7, q = 13, and e = 5 to the Extended Euclidean Algorithm. The output
will be d = 29.
• Check that the d calculated is correct by computing −
de = 29 × 5 = 145 = 1 mod 72
• Hence, public key is (91, 5) and private keys is (91, 29).
Encryption and Decryption
Once the key pair has been generated, the process of encryption and decryption are relatively
straightforward and computationally easy.
Interestingly, RSA does not directly operate on strings of bits as in case of symmetric key
encryption. It operates on numbers modulo n. Hence, it is necessary to represent the plaintext
as a series of numbers less than n.
RSA Encryption
• Suppose the sender wish to send some text message to someone whose public
key is (n, e).
• The sender then represents the plaintext as a series of numbers less than n.
• To encrypt the first plaintext P, which is a number modulo n. The encryption
process is simple mathematical step as −
C = Pe mod n
• In other words, the ciphertext C is equal to the plaintext P multiplied by itself e
times and then reduced modulo n. This means that C is also a number less than
n.
• Returning to our Key Generation example with plaintext P = 10, we get
ciphertext C −
5
C = 10 mod 91
RSA Decryption
• The decryption process for RSA is also very straightforward. Suppose that the
receiver of public-key pair (n, e) has received a ciphertext C.
• Receiver raises C to the power of his private key d. The result modulo n will
be the plaintext P.
d
Plaintext = C mod n
• Returning again to our numerical example, the ciphertext C = 82 would get
decrypted to number 10 using private key 29 −
Plaintext = 8229 mod 91 = 10
RSA Analysis
The security of RSA depends on the strengths of two separate functions. The RSA
cryptosystem is most popular public-key cryptosystem strength of which is based on the
practical difficulty of factoring the very large numbers.
• Encryption Function − It is considered as a one-way function of converting
plaintext into ciphertext and it can be reversed only with the knowledge of
private key d.
• Key Generation − The difficulty of determining a private key from an RSA
public key is equivalent to factoring the modulus n. An attacker thus cannot
use knowledge of an RSA public key to determine an RSA private key unless
he can factor n. It is also a one way function, going from p & q values to
modulus n is easy but reverse is not possible.
If either of these two functions are proved non one-way, then RSA will be broken. In fact, if a
technique for factoring efficiently is developed then RSA will no longer be safe.
The strength of RSA encryption drastically goes down against attacks if the number p and q
are not large primes and/ or chosen public key e is a small number.
➢ DIGITAL SIGNATURE

MAC(Message Authentication Code) was used to provide Message Integrity and Message
Authentication but it needs symmetric key established between sender and receiver. A
digital signature on other hand uses pair of asymmetric keys.
A valid digital signature helps the receiver to know the message comes from the authentic
sender and is not altered in between.
What is a Signature?

We sign a document to show that is approved by us or created by us. The signature is proof
to the recipient that this document is coming from the correct source. The signature on the
document simply means the document is authentic.
When A sends a message to B, B needs to check the authenticity of the message and
confirm it comes from A and not C. So B can ask A to sign the message electronically. The
electronic signature proves the identity of A is also called a digital signature.

Conventional Signature Digital Signature

A conventional Signature is part of a


document. For example, when we sign a A digital signature is not part of a document.
cheque the signature is present on the This means the sender sends two documents
cheque not on a separate document. message and signature.

To verify conventional signatures the To verify digital signatures the recipient


recipient compares the signature on the applies verification technique to a
document with the signature on file. So combination of message and the signature to
recipient needs to have a copy of this verify authenticity. So here a copy of the
signature on file for comparison. signature is not stored anywhere.
One to One relationship between message
the One to Many relationships between and signature. Every message has its own
document and signature. signature.

Copy of signed document can be


distinguished from the original signature No distinction can be made unless there is a
on file. factor of time(timestamp) on the document.

• Digital Signature needs a public key system. The sender uses a private key to
sign a document and the verifier uses the public key to verify the document.

Cryptography Vs Digital Signature


• In Cryptosystem uses private and public keys of the receiver.
• In Digital signature uses private and public keys of the sender.

Process of Digital Signature


1. Signing the document
2. Signing a digest
Signing the document
• Encrypt the document using the private key of the sender.
• Decrypt the document using the public key of the sender.
Signing a digest
• Using public keys is very inefficient if we are dealing with long messages. The
solution is to sign a digest of the message.
• Message digest has one to one relationship with a message.
• A digest can be made out of messages at the sender’s site.
• Digest then goes through the signing process using the sender’s private key.
• Sender then sends a message and signature to the receiver.
• At the receiver site using the public hash function, a digest is created out of the
message it received.
• Using verification process authentication of signature is determined.

Features of Digital Signature

Message Integrity
It is preserved by using the hash function in signing and verifying algorithms.
Message Authentication
The message is verified using the public key of the sender. When A sends a message to B .
B uses the public key of A for verification and A public key cannot create the same
signature as C’s private key.
Message Nonrepudiation
To provide a message non-repudiation trusted third party is needed.
• A creates a signature from the message and sends a message to B and a signature
to the trusted center.
• The center validates A public key and verifies messages that come from A.
• The center saves a copy of the message with sender identity, receiver identity,
and timestamp.
• The center uses a private key to create a new signature.
• The center sends a message, a new signature, A’s identity, B’s identity to B.
• B verifies the message using the public key of the trusted center.
In the future, if A denies that no message is sent from its site, the center can show a copy
of the saved message.

❖ HASH FUNCTION

Hash functions are extremely useful and appear in almost all information security applications.
A hash function is a mathematical function that converts a numerical input value into another
compressed numerical value. The input to the hash function is of arbitrary length but output is
always of fixed length.
Values returned by a hash function are called message digest or simply hash values. The
following picture illustrated hash function −

➢ Features of Hash Functions

The typical features of hash functions are −


• Fixed Length Output (Hash Value)
o Hash function coverts data of arbitrary length to a fixed length.
This process is often referred to as hashing the data.
o In general, the hash is much smaller than the input data, hence
hash functions are sometimes called compression functions.
o Since a hash is a smaller representation of a larger data, it is also
referred to as a digest.
o Hash function with n bit output is referred to as an n-bit hash
function. Popular hash functions generate values between 160
and 512 bits.
• Efficiency of Operation
o Generally for any hash function h with input x, computation of
h(x) is a fast operation.
o Computationally hash functions are much faster than a symmetric
encryption.

➢ Properties of Hash Functions

In order to be an effective cryptographic tool, the hash function is desired to possess following
properties −
• Pre-Image Resistance
o This property means that it should be computationally hard to
reverse a hash function.
o In other words, if a hash function h produced a hash value z, then
it should be a difficult process to find any input value x that
hashes to z.
o This property protects against an attacker who only has a hash
value and is trying to find the input.
• Second Pre-Image Resistance
o This property means given an input and its hash, it should be hard
to find a different input with the same hash.
o In other words, if a hash function h for an input x produces hash
value h(x), then it should be difficult to find any other input value
y such that h(y) = h(x).
o This property of hash function protects against an attacker who
has an input value and its hash, and wants to substitute different
value as legitimate value in place of original input value.
• Collision Resistance
o This property means it should be hard to find two different inputs
of any length that result in the same hash. This property is also
referred to as collision free hash function.
o In other words, for a hash function h, it is hard to find any two
different inputs x and y such that h(x) = h(y).
o Since, hash function is compressing function with fixed hash
length, it is impossible for a hash function not to have collisions.
This property of collision free only confirms that these collisions
should be hard to find.
o This property makes it very difficult for an attacker to find two
input values with the same hash.
o Also, if a hash function is collision-resistant then it is second
pre-image resistant.

➢ Design of Hashing Algorithms

At the heart of a hashing is a mathematical function that operates on two fixed-size blocks of
data to create a hash code. This hash function forms the part of the hashing algorithm.
The size of each data block varies depending on the algorithm. Typically the block sizes are
from 128 bits to 512 bits. The following illustration demonstrates hash function −
Hashing algorithm involves rounds of above hash function like a block cipher. Each round
takes an input of a fixed size, typically a combination of the most recent message block and the
output of the last round.
This process is repeated for as many rounds as are required to hash the entire message.
Schematic of hashing algorithm is depicted in the following illustration −

Since, the hash value of first message block becomes an input to the second hash operation,
output of which alters the result of the third operation, and so on. This effect, known as
an avalanche effect of hashing.
Avalanche effect results in substantially different hash values for two messages that differ by
even a single bit of data.
Understand the difference between hash function and algorithm correctly. The hash function
generates a hash code by operating on two blocks of fixed-length binary data.
Hashing algorithm is a process for using the hash function, specifying how the message will
be broken up and how the results from previous message blocks are chained together.

➢ Popular Hash Functions

• Message Digest (MD)


• Secure Hash Function (SHA)

➢ Applications of Hash Functions

There are two direct applications of hash function based on its cryptographic properties.
✓ Password Storage
Hash functions provide protection to password storage.
• Instead of storing password in clear, mostly all logon processes store the hash
values of passwords in the file.
• The Password file consists of a table of pairs which are in the form (user id,
h(P)).
• The process of logon is depicted in the following illustration −

• An intruder can only see the hashes of passwords, even if he accessed the
password. He can neither logon using hash nor can he derive the password from
hash value since hash function possesses the property of pre-image resistance.

✓ Data Integrity Check


Data integrity check is a most common application of the hash functions. It is used to generate
the checksums on data files. This application provides assurance to the user about correctness
of the data.
The process is depicted in the following illustration −

The integrity check helps the user to detect any changes made to original file. It however, does
not provide any assurance about originality. The attacker, instead of modifying file data, can
change the entire file and compute all together new hash and send to the receiver. This integrity
check application is useful only if the user is sure about the originality of file.
❖ PUBLIC KEYS DISTRIBUTION
Several techniques have been proposed for the distribution of public keys. Virtually
all these proposals can be grouped into the following general schemes:
• Public announcement
• Publicly available directory
• Public-key authority
• Public-key certificates
➢ Public Announcement of Public Keys
On the face of it, the point of public
key encryption is that the public key is public. Thus, if there is some broadly accepted public
key algorithm, such as RSA, any participant can send his or her public key to any other particip
ant or broadcast the key to the community at large (Figure 14.9).

Although this approach is convenient, it has a major weakness. Anyone can forge such a public
announcement. That is, some user could pretend to be user A and send a public key to another
participant or broadcast such a public key. Until
such time as user A discovers the forgery and alerts other participants, the forger is
able to read all encrypted messages intended for A and can use the forged keys
for authentication.
➢ Publicly Available Directory
A greater degree of security can be achieved by maintaining a publicly available
dynamic directory of public keys. Maintenance and distribution of the public direc- tory would
have to be the responsibility of some trusted
entity or organization (Figure 14.10). Such a scheme would include the following elements:

1. The authority maintains a directory with a {name, public key} entry


for each participant.
2. Each participant registers a public key with the directory authority.
Registration would have to be in person or by some form of secure authenti-
cated communication.
3. A participant may replace the existing key with a new one at any time
, either because of the desire to replace a public key that has already been used for
a large amount of data, or because the corresponding private key has been com-
promised in some way.

4. Participants could also access the directory


electronically. For this purpose, secure, authenticated communication from the
authority to the participant is mandatory.
This scheme is clearly more secure than individual public announcements but still has vulnera
bilities. If an adversary succeeds in obtaining or computing the private key of the directory
authority, the adversary could authoritatively pass out counterfeit public keys and subsequently
impersonate any participant and eaves- drop on messages sent to any participant. Another way
to achieve the same end is for the adversary to tamper with the records kept by the authority.

➢ Public-Key Authority
Stronger security for public-key distribution can be achieved by providing tighter
control over the distribution of public keys from the directory. A typical scenario is
illustrated in Figure 14.11. As before, the scenario assumes that a central authority maintains a
dynamic directory of public
keys of all participants. In addition, each participant reliably knows a public key for the
authority, with only the authority knowing the corresponding
private key. The following steps (matched by number to Figure 14.11) occur.
1. A sends a timestamped message to the public-key authority containing a
request for the current public key of B.
2. The authority responds with a message that is encrypted using the authority’s private ke
y, PRauth.Thus,A is able to decrypt the message using the authority’s public key.Therefor
e,A is assured that the message originated with the authority.The message
includes the following:
The original request used to enable A to match this response with the
corresponding earlier request and to verify that the original request was not altered
before reception by the authority

• The original timestamp given so A can determine that


this is not an old message from the authority containing a key other than B’s current public
key
3. A stores B’s public key and also uses it to encrypt a message to B containing an
identifier of A (IDA) and a nonce (N1), which is used to identify this transaction uniquely.
4, 5. B retrieves A’s public key from the authority in the same manner as A retrieved
B’s public key. At this point, public keys have been securely delivered to A and B, and
they may begin their protected exchange. However, two additional steps are desirable:
6. B sends a message to A encrypted with PUa and containing A’s nonce (N1) as well
as a new nonce generated by B (N2). Because only B could have decrypted message
(3), the presence of N1 in message (6) assures A that the correspondent is B.
7. A returns N2, which is encrypted using B’s public key, to assure B that its correspon
dent is A.
Thus, a total of seven messages are required. However, the initial four messages need be used
only infrequently because both A and B can save the other’s public key for future use—
a technique known as caching. Periodically, a user should
request fresh copies of the public keys of its correspondents to ensure currency.

➢ Public-Key Certificates
The scenario of Figure 14.11 is attractive, yet it has some drawbacks. The public-key
authority could be somewhat of a bottleneck in the system, for a user must appeal to the
authority for a public key for every other user that it wishes to contact. As before, the directory
of names and public keys maintained by the authority is vul- nerable to tampering.
An alternative approach, first suggested by Kohnfelder [KOHN78], is
to use certificates that can be used by participants to exchange keys without contacting a publ
ic-key authority, in a way that is as reliable as if the keys were obtained directly from a
public-key authority. In essence, a certificate consists of a public key, an identifier of the key
owner, and the whole block signed by a trusted third party. Typically, the third
party is a certificate authority, such as a government agency or a financial institution, that is
trusted by the user community. A user can present his or her public key to the authority in a
secure manner and obtain a certificate. The user can then publish the certificate. Anyone
needing this user’s public key can obtain the certificate and verify that it is valid by way of the
attached trusted signature. A participant can also convey its key information to another
by transmitting its certificate. Other participants can verify that the certificate was created by
the authority.
❖ Transport Layer Security (TLS) Handshake

TLS is a data privacy and security protocol implemented for secure communication
over internet. It usually encrypts communication between server and clients.
A Transport Layer Security (TLS) connection is established via handshake.

TLS Handshake in action :


Figure – TLS Handshake
1. With a TLS enabled service, a sender sends a Client Hello (as
referred in protocol). This includes information about Client.

2. Then server responds with Server Hello message (selecting highest


version of TLS supported by Client) and then chooses a cipher suite
from list in Client Hello message. The server also transmits its Digital
certificate and a final Server Hello Done message.

3. Client validates certificate. Client then sends Client Key Exchange


message. Here client chooses a key exchange mechanism to
securely establish a shared secret with server. Client also needs to
send Change Cipher Spec indicating that it is switching to secure
communication now, which is finally followed by Finished message
for indicating a successful handshake.

4. Server replies with Change Cipher Spec and an encrypted Finished


message once shared secret is received.

Session key is Shared Symmetric Encryption Key used in TLS sessions to


encrypt data being sent back and forth.

❖ IP security (IPSec)

The IP security (IPSec) is an Internet Engineering Task Force (IETF) standard suite of
protocols between 2 communication points across the IP network that provide data
authentication, integrity, and confidentiality. It also defines the encrypted, decrypted and
authenticated packets. The protocols needed for secure key exchange and key management
are defined in it.

➢ Uses of IP Security –

IPsec can be used to do the following things:


• To encrypt application layer data.
• To provide security for routers sending routing data across the public internet.
• To provide authentication without encryption, like to authenticate that the data
originates from a known sender.
• To protect network data by setting up circuits using IPsec tunnelling in which all
data is being sent between the two endpoints is encrypted, as with a Virtual Private
Network(VPN) connection.

➢ Components of IP Security –

It has the following components:


1. Encapsulating Security Payload (ESP) –
It provides data integrity, encryption, authentication and anti replay. It also
provides authentication for payload.

2. Authentication Header (AH) –


It also provides data integrity, authentication and anti replay and it does not
provide encryption. The anti replay protection, protects against unauthorized
transmission of packets. It does not protect data’s confidentiality.

3. Internet Key Exchange (IKE) –

Internet Key Exchange is a special protocol that helps to enable two systems or
devices to establish a secure and strong communication channel over a nonreliable
network also. This protocol achieves this using a series of key exchanges to create
a secure and strong tunnel between a client and a server with the help of which
they can send encrypted traffic easily and securely. The security of the tunnel is
based on the Diffie-Hellman key exchange method, which is one of the widely
used techniques used for security.

Working of IP Security –

1. The host checks if the packet should be transmitted using IPsec or not. These
packet traffic triggers the security policy for themselves. This is done when the
system sending the packet apply an appropriate encryption. The incoming packets
are also checked by the host that they are encrypted properly or not.
2. Then the IKE Phase 1 starts in which the 2 hosts(using IPsec) authenticate
themselves to each other to start a secure channel. It has 2 modes. The Main
mode which provides the greater security and the Aggressive mode which
enables the host to establish an IPsec circuit more quickly.

3. The channel created in the last step is then used to securely negotiate the way the
IP circuit will encrypt data across the IP circuit.

4. Now, the IKE Phase 2 is conducted over the secure channel in which the two
hosts negotiate the type of cryptographic algorithms to use on the session and
agreeing on secret keying material to be used with those algorithms.

5. Then the data is exchanged across the newly created IPsec encrypted tunnel. These
packets are encrypted and decrypted by the hosts using IPsec SAs.

6. When the communication between the hosts is completed or the session times out
then the IPsec tunnel is terminated by discarding the keys by both the hosts.

You might also like