Bca Cns Notes
Bca Cns Notes
UNIT- 1
INTRODUCTION
Computer data often travels from one computer to another, leaving the safety of its protected
physical surroundings. Once the data is out of hand, people with bad intention could modify or
forge your data, either for amusement or for their own benefit.
Cryptography can reformat and transform our data, making it safer on its trip between
computers. The technology is based on the essentials of secret codes, augmented by modern
mathematics that protects our data in powerful ways.
• Computer Security - generic name for the collection of tools designed to protect data and to
thwart hackers
• Internet Security - measures to protect data during their transmission over a collection of
Interconnected networks
Basic Concepts
Cryptography The art or science encompassing the principles and methods of transforming an
intelligible message into one that is unintelligible, and then retransforming that message back to
its
Original form
Plaintext The original intelligible message
Cipher An algorithm for transforming an intelligible message into one that is unintelligible by
transposition and/or substitution methods
Key Some critical information used by the cipher, known only to the sender& receiver
Encipher (encode) The process of converting plaintext to cipher text using a cipher and a key
Decipher (decode) the process of converting cipher text back into plaintext using a cipher and a
Key
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
In 1994, the Internet Architecture Board (IAB) issued a report entitled "Security in the
Internet Architecture" (RFC 1636). The report stated the general consensus that the
Internet needs more and better security, and it identified key areas for security mechanisms.
Among these were the need to secure the network infrastructure from unauthorized
monitoring and control of network traffic and the need to secure end-user-to-end-user traffic
using authentication and encryption mechanisms
These concerns are fully justified. As confirmation, consider the trends reported by
the Computer Emergency Response Team (CERT) Coordination Center (CERT/CC). The
trend in Internet-related vulnerabilities reported to CERT over a 10-year period. These
include security weaknesses in the operating systems of attached computers (e.g., Windows,
Linux) as well as vulnerabilities in Internet routers and other network devices. The number of
security related incidents reported to CERT. These include denial of service attacks; IP
spoofing, in which intruders create packets with false IP addresses and exploit applications
that use authentication based on IP; and various forms of eavesdropping and packet sniffing,
in which attackers read transmitted information, including logon information and database
contents.
SECURITY ATTACKS
Types:
Active attacks: An Active attack attempts to alter system resources or effect their
operations. Active attacks involve some modification of the data stream or creation of false
statement.
An active attack involves changing the information in some way by conducting some process
on the information. Types of active attacks are as following:
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
1. Masquerade –
Masquerade attack takes place when one entity pretends to be a different entity. A
Masquerade attack involves one of the other forms of active attacks.
2. Modification of messages –
It means that some portion of a message is altered or that message is delayed or
reordered to produce an unauthorized effect. For example, a message meaning “Allow
JOHN to read confidential file X” is modified as “Allow Smith to read confidential file
X”.
3. Repudiation
This attack is done by either sender or receiver. The sender or receiver can deny later
that he/she has send or receive a message. For example, customer asks his Bank “To
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
transfer an amount to someone” and later on the senders (customer) deny that he had
made such a request. This is repudiation.
4. Replay –
It involves the passive capture of a message and its subsequent transmission to produce
an authorized effect.
5. Denial of Service
It prevents normal use of communication facilities. This attack may have a specific
target. For example, an entity may suppress all messages directed to a particular
destination. Another form of service denial is the disruption of an entire network either
by disabling the network or by overloading it by messages so as to degrade
performance.
Passive attacks: A Passive attack attempts to learn or make use of information from
the system but does not affect system resources. Passive Attacks are in the nature of
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
2. Traffic analysis
Suppose that we had a way of masking (encryption) information, so that the attacker
even if captured the message could not extract any information from the message.
The opponent could determine the location and identity of communicating host and
could observe the frequency and length of messages being exchanged. This information
might be useful in guessing the nature of the communication that was taking place.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
SECURITY SERVICES:
A processing or communication service that enhances the security of the data processing
systems and the information transfers of an organization. These services are intended to counter
security attacks, and they make use of one or more security mechanisms to provide the service.
Authentication: The assurance that the communicating entity is the one that it claims to be.
Data Confidentiality:
Protects data from unauthorized disclosure.
Access Control:
The prevention of unauthorized use of a resource (i.e., this service controls who can have access
to a resource, under what conditions access can occur, and what those accessing the resource
are allowed to do).
Data Integrity:
The assurance that data received are exactly as sent by an authorized entity (i.e., contain no
modification, insertion, deletion, or replay).
Non-repudiation:
Protects against denial by one of the entities involved in a communication of having
participated in all or part of the communication.
Proof of Origin: Proof that the message was sent by the specified party.
Proof of Delivery: Proof that the message was received by the specified party.
SECURITY MECHANISMS
Encipherment
The use of mathematical algorithms to transform data into a form that is not readily
intelligible. The transformation and subsequent recovery of the data depend on an algorithm
and zero or more encryption keys.
Digital Signature
Data appended to, or a cryptographic transformation of, a data unit that allows a
recipient of the data unit to prove the source and integrity of the data unit and protect against
forgery (e.g., by the recipient).
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Access Control
A variety of mechanisms that enforce access rights to resources.
Data Integrity
A variety of mechanisms used to assure the integrity of a data unit or stream of data
units
When we send our data from source side to destination side we have to use some transfer
method like the internet or any other communication channel by which we are able to send
our message. The two parties, who are the principals in this transaction, must cooperate for
the exchange to take place. When the transfer of data happened from one source to another
source some logical information channel is established between them by defining a route
through the internet from source to destination and by the cooperative use of communication
protocols (e.g., TCP/IP) by the two principals.
When we use the protocol for this logical information channel the main aspect
security has come. Who may present a threat to confidentiality, authenticity, and so on. All
the technique for providing security has to components:
A trusted third party may be needed to achieve secure transmission. For example, a third
party may be responsible for distributing the secret information to the two principals while
keeping it from any opponent. Or a third party may be needed to arbitrate disputes between
the two principals concerning the authenticity of a message transmission.
This model shows that there are four basic tasks in designing a particular security service:
1. Design an algorithm for performing the security-related transformation.
2. Generate the secret information to be used with the algorithm.
3. Develop methods for the distribution and sharing of secret information.
4. Specify a protocol to be used by the two principals that make use of the security
algorithm and the secret information to achieve a particular security service.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
SYMMETRIC CIPHERS
CLASSICAL ENCRYPTION TECHNIQUES
There are two basic building blocks of all encryption techniques: substitution and
transposition.
SUBSTITUTION TECHNIQUES
A substitution technique is one in which the letters of plaintext are replaced by other
letters or by numbers or symbols.
If the plaintext is viewed as a sequence of bits, then substitution involves replacing
plaintext bit patterns with cipher text bit patterns.
CAESAR CIPHER
The Caesar Cipher technique is one of the earliest and simplest method of encryption
technique. The Caesar cipher involves replacing each letter of the alphabet with the letter
standing three places further down the alphabet.
For example
Plain: meet me after the toga party
Cipher: PHHW PH DIWHU WKH WRJD SDUWB
Note that the alphabet is wrapped around, so that the letter following Z is A. We can
define the transformation by listing all possibilities, as follows:
Plain: a b c d e f g h i j k l m n o p q r s t u v w x y z
cipher: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
PLAYFAIR CIPHER:
In this scheme, pairs of letters are encrypted, instead of single letters
Initially a key table is created. The key table is a 5×5 grid of alphabets that acts as the
key for encrypting the plaintext. Each of the 25 alphabets must be unique and one letter of the
alphabet (usually J) is omitted from the table as we need only 25 alphabets instead of 26. If the
plaintext contains J, then it is replaced by I.
The sender and the receiver deicide on a particular key, say ‘tutorials’. In a key table,
the first characters (going left to right) in the table is the phrase, excluding the duplicate letters.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
The rest of the table will be filled with the remaining letters of the alphabet, in natural order.
The key table works out to be –
HI DE MO NE YZ
The rules of encryption are −
o If both the letters are in the same column, take the letter below each one (going
V W X Y Z
If both letters are in the same row, take the letter to the right of each one (going back to
the left if at the farthest right)
A L S B C row, hence
take letter to
the right of
D E F G H
them to
replace. DE
K M N P Q → EF
V W X Y Z
If neither of the preceding two rules are true, form a rectangle with the two letters and take the
letters on the horizontal opposite corner of the rectangle.
Using these rules, the result of the encryption of ‘hide money’ with the key of ‘tutorials’ would
be −
QC EF NU MF ZV
Decrypting the Playfair cipher is as simple as doing the same process in reverse. Receiver has
the same key and can create the same key table, and then decrypt any messages made using
that key.
HILL CIPHER
Hill cipher is a polygraphic substitution cipher based on linear algebra.Each letter is
represented by a number modulo 26. Often the simple scheme A = 0, B = 1, …, Z = 25 is
used, but this is not an essential feature of the cipher. To encrypt a message, each block of n
letters (considered as an n-component vector) is multiplied by an invertible n × n matrix,
against modulus 26.
To decrypt the message, each block is multiplied by the inverse of the matrix used for
encryption.
The matrix used for encryption is the cipher key, and it should be chosen randomly from the
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
TRANSPOSITION TECHNIQUE
Looking at the image, you would get it why it got named rail fence because it appears like the
rail fence.
Once you have written the message as a sequence of diagonals, to obtain the cipher text out of it
you have to read it as a sequence of rows. So, reading the first row the first half of cipher text
will be:
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
memtmro
reading the second row of the rail fence, we will get the second half of the cipher text:
eteoorw
Now, to obtain the complete cipher text combine both the halves of cipher text and the complete
cipher text will be:
Cipher Text: M E M T M R O E T E O O R W
Rail fence cipher is easy to implement and even easy for a cryptanalyst to break this technique.
So, there was a need for a more complex technique.
Columnar transposition involves writing the plain text out in rows, and then reading the
cipher text off in columns. It is the route cipher where the route is to read down each column in
order.
For example the plain text “a simple transposition “with 5 columns look like the grid
below
“ALNISESTITPIMROOPASN”
ROTOR MACHINE
A rotor machine is an electro-mechanical stream cipher device used for encrypting and
decrypting messages. Rotor machines were the cryptographic state-of-the-art for a prominent
period of history; they were in widespread use in the 1920s–1970s.
The most famous example is the German Enigma machine, the output of which was
deciphered by the Allies during World War II, producing intelligence code-named Ultra.
The primary component is a set of rotors, also termed wheels or drums, which are
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
rotating disks with an array of electrical contacts on either side. The wiring between the
contacts implements a fixed substitution of letters, replacing them in some complex fashion. On
its own, this would offer little security; however, after encrypting each letter, the rotors advance
positions, changing the substitution. By this means, a rotor machine produces a
complex polyalphabetic substitution cipher, which changes with every keypress.
STEGANOGRAPHY
Steganography has been used for centuries, but these days, hackers and IT pros have
digitized. The word “steganography” seems fancy, but it actually comes from a fairly normal
place. The root “steganos” is Greek for “hidden” or “covered,” and the root “graph” is Greek
for “to write.” Put these words together, and you’ve got something close to “hidden writing,” or
“secret writing.” it to do some pretty creative things. There are a number of apps that can be
used for steganography, including Steghide, Xiao, Stegais and Concealment.
STEGANOGRAPHY TECHNIQUES
Intranets.
Digital Watermarking.
Detection Algorithm.
Detection Method.
Watermarking Technique.
Trojans.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
UNIT- 2
Feistel Cipher
Feistel Cipher model is a structure or a design used to develop many block ciphers
such as DES. Same encryption as well as decryption algorithm is used. A separate key is used
for each round. However same round keys are used for encryption as well as decryption.
Encryption Process
The encryption process uses the Feistel structure consisting multiple rounds of
processing of the plaintext, each round consisting of a “substitution” step followed by a
permutation step.
The input block to each round is divided into two halves that can be denoted as L and R
for the left half and the right half.
In each round, the right half of the block, R, goes through unchanged. But the left half,
L, goes through an operation that depends on R and the encryption key. First, we apply
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
an encrypting function ‘f’ that takes two input − the key K and R. The function
produces the output f(R,K). Then, we XOR the output of the mathematical function
with L.
The permutation step at the end of each round swaps the modified L and unmodified R.
Therefore, the L for the next round would be R of the current round. And R for the next
round be the output L of the current round.
Above substitution and permutation steps form a ‘round’. The number of rounds are
specified by the algorithm design.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Once the last round is completed then the two sub blocks, ‘R’ and ‘L’ are concatenated
in this order to form the cipher text block.
Decryption Process
The process of decryption in Feistel cipher is almost similar. Instead of starting with a
block of plaintext, the cipher text block is fed into the start of the Feistel structure and then the
process thereafter is exactly the same as described in the given illustration.
The final swapping of ‘L’ and ‘R’ in last step of the Feistel Cipher is essential. If these are not
swapped then the resulting cipher text could not be decrypted using the same algorithm.
Number of Rounds
The number of rounds used in a Feistel Cipher depends on desired security from the
system. More number of rounds provides more secure system. But at the same time, more
rounds mean the inefficient slow encryption and decryption processes. Number of rounds in
the systems thus depend upon efficiency–security tradeoff.
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.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
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.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
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 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. 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
on the first position, bit number 17 moves on the second position, and so on. If we observe
the table carefully, 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.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Because of this compression permutation technique, a different subset of key bits is used in
each round. That makes DES not easy to crack.
Recall that after 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.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Operation of AES
AES is an iterative rather than Feistel cipher. It is based on ‘substitution–permutation
network’. It comprises of a series of linked operations, some of which involve replacing inputs
by specific outputs (substitutions) and others involve shuffling bits around (permutations).
Interestingly, AES performs all its computations on bytes rather than bits. Hence, AES
treats the 128 bits of a plaintext block as 16 bytes. These 16 bytes are arranged in four columns
and four rows for processing as a matrix −
Unlike DES, the number of rounds in AES is variable and depends on the length of the
key. AES uses 10 rounds for 128-bit keys, 12 rounds for 192-bit keys and 14 rounds for 256-
bit keys. Each of these rounds uses a different 128-bit round key, which is calculated from the
original AES key.
Encryption Process
Here, we restrict to description of a typical round of AES encryption. Each round comprise of
four sub-processes. The first round process is depicted below −
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Shift rows
Each of the four rows of the matrix is shifted to the left. Any entries that ‘fall off’ are re-
inserted on the right side of row. Shift is carried out as follows −
The result is a new matrix consisting of the same 16 bytes but shifted with respect to
each other.
Mix Columns
Each column of four bytes is now transformed using a special mathematical function. This
function takes as input the four bytes of one column and outputs four completely new bytes,
which replace the original column. The result is another new matrix consisting of 16 new
bytes. It should be noted that this step is not performed in the last round.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Addroundkey
The 16 bytes of the matrix are now considered as 128 bits and are XORed to the 128 bits of the
round key. If this is the last round then the output is the cipher text. Otherwise, the resulting
128 bits are interpreted as 16 bytes and we begin another similar round.
Decryption Process
The process of decryption of an AES cipher text is similar to the encryption process in the
reverse order. Each round consists of the four processes conducted in the reverse order −
LINEAR CRYPTANALYSIS
Any linear relation between the plaintext bits and ciphertext bits can be written as a
chain of exclusive-or operations of the following form:
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Where ⊕ denotes the binary operation XOR (exclusive-OR), Xi denotes the ith bit of
the input X = [X1, X2, …], Yj denotes the jth bit of the output Y = [Y1, Y2, …] and Kk
denotes the kth bit of the key K = [K1, K2, …]. The sum therefore denotes the XOR ‘sum’ of u
input and v output bits vs w private key bits.
DIFFERENTIAL CRYPTANALYSIS
Differential cryptanalysis preceded linear cryptanalysis having initially been designed in
1990 as an attack on DES. Differential cryptanalysis is similar to linear cryptanalysis;
differential cryptanalysis aims to map bitwise differences in inputs to differences in the output
in order to reverse engineer the action of the encryption algorithm. It is again aiming to
approximate the encryption algorithm looking to find a maximum likelihood estimator of the
true encryption action by altering plaintexts or (looking at different plaintexts) and analysing
the impact of changes to the plaintext to the resulting ciphertext. Differential cryptanalysis is
therefore a chosen plaintext attack.
The description of differential cryptanalysis is analogous to that of linear cryptanalysis
and is essentially the same as would be the case of applying linear cryptanalysis to input
differences rather than to input and output bits directly.
UNIT- 3
The second problem that Diffie pondered, and one that was apparently unrelated to the
first was that of” digital signatures." If the use of cryptography was to become widespread, not
just in military situations but for commercial and private purposes, then electronic messages
and documents would need the equivalent of signatures used in paper documents. That is, could
a method be devised that would stipulate, to the satisfaction of all parties, that a digital message
had been sent by a particular person?
The process of encryption and decryption is depicted in the following illustration –
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Each receiver possesses a unique decryption key, generally referred to as his private
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.
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.
Conventional Encryption
1. The same algorithm with the same key is used for encryption and decryption.
2. The sender and receiver must share the algorithm and the key.
Public-Key Encryption
1. One algorithm is used for encryption and decryption with a pair of keys, one for
encryption and one for decryption.
2. The sender and receiver must each have one of the matched pair of keys (not the same
one).
● Encryption/decryption: The sender encrypts a message with the recipient's public key.
● Digital signature: The sender "signs" a message with its private key. Signing is achieved by
a
cryptographic algorithm applied to the message or to a small block of data that is a function of
the message.
● Key exchange: Two sides cooperate to exchange a session key. Several different approaches
are possible, involving the private key(s) of one or both parties.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Public-Key Cryptanalysis
As with symmetric encryption, a public-key encryption scheme is vulnerable to a brute-
force attack. The countermeasure is the same: Use large keys. However, there is a tradeoff to be
considered. Public-key systems depend on the use of some sort of invertible mathematical
function. The complexity of calculating these functions may not scale linearly with the number
of bits in the key but grow more rapidly than that. Thus, the key size must be large enough to
make brute-force attack impractical but small enough for practical encryption and decryption.
In practice, the key sizes that have been proposed do make brute-force attack impractical but
result in encryption/decryption speeds that are too slow for general-purpose use. Instead, as was
mentioned earlier, public-key encryption is currently confined to key management and
signature applications.
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.
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 −
o The pair of numbers (n, e) form the RSA public key and is made public.
prime number ensures that attacker cannot find in finite time the two primes (p
& q) used to obtain n. This is strength of RSA.
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
ed = 1 mod (p − 1)(q − 1)
ALGORITHM
e - Public key
d = 1 + k.f (n)
e
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
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 cipher text 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.
RSA Decryption
The decryption process for RSA is also very straightforward. Suppose that the receiver
of public-key pair (n, e) has received a cipher text C.
Receiver raises C to the power of his private key d. The result modulo n will be the
plaintext P.
Plaintext = Cd mod n
Example:
Step 1: p = 3 q = 5
Step 2: n = p*q -
3 * 5 = 15
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
(2)(4) = 8
Step 4: e = 7
1<7<8
GCD (e, f(n) ) = 1
(7, 8) = 1
Public Key = 7
Private Key = 7
Encryption: M = 2
C = Me mod n
C = 27 mod 15
C = 128 mod 15
C=8
Decryption:
M = Cd mod n
87 mod 15
2097152 mod 15
M=2
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Security of RSA: -
1. Plain text attacks:
It is classified into 3 subcategories:-
Short message attack:
In this we assume that attacker knows some blocks of plain text and tries to decode
cipher text with the help of that. So, to prevent this pad the plain text before encrypting.
Cycling attack:
In this attacker will think that plain text is converted into cipher text using permutation
and he will apply right for conversion. But attacker does not right plain text. Hence will
keep doing it.
Unconcealed Message attack:
Sometimes happened that plain text is same as cipher text after encryption. So it must be
checked it cannot be attacked.
3. Factorisation attack:
If attacker will able to know P and Q using N, then he could find out value of private key.
This can be failed when N contains atleast 300 longer digits in decimal terms, attacker will
not able to find. Hence it fails.
Key Generation
Key generation is an important part where we have to generate both public key and
private key. The sender will be encrypting the message with receiver’s public key and the
receiver will decrypt its private key.
Q=d*P
d = The random number that we have selected within the range of ( 1 to n-1 ). P is the point on
the curve.
‘Q’ is the public key and‘d’ is the private key.
Encryption
Let ‘m’ be the message that we are sending. We have to represent this message on the
curve. This have in-depth implementation details. All the advance research on ECC is done by a
company called certicom
Consider ‘m’ has the point ‘M’ on the curve ‘E’. Randomly select ‘k’ from [1 – (n-1)].
Two cipher texts will be generated let it be C1 and C2.
C1 = k*P
C2 = M + k*Q
C1 and C2 will be send.
Decryption
We have to get back the message ‘m’ that was send to us,
M = C2 – d * C1
M is the original message that we have send.
Proof
How does we get back the message?
M = C2 – d * C1
C2 – d * C1 = (M + k * Q) – d * ( k * P ) ( C2 = M + k * Q and C1 = k * P )
= M + k * d * P – d * k *P ( canceling out k * d * P )
= M (Original Message)
This algorithm is used to exchange the secret key between the sender and the receiver.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
This algorithm facilitates the exchange of secret key without actually transmitting it.
Example:
q = 11 , a=2 , XA =11 , XB =8
= 9 = 3
YA YB
3 3
UNIT- 4
AUTHENTICATION REQUIREMENTS
In the context of communications across a network, the following attacks can be identified:
1. Disclosure: Release of message contents to any person or process not possessing the
appropriate cryptographic key.
2. Traffic analysis: Discovery of the pattern of traffic between parties. In a connection oriented
application, the frequency and duration of connections could be determined. In either a
connection-oriented or connectionless environment, the number and length of messages
between parties could be determined.
3. Masquerade: Insertion of messages into the network from a fraudulent source. This includes
the creation of messages by an opponent that are purported to come from an authorized entity.
Also included are fraudulent acknowledgments of message receipt or nonreceipt by someone
other than the message recipient.
AUTHENTICATION FUNCTIONS
Message encryption: The cipher text of the entire message serves as its authenticator.
Message authentication code (MAC): A function of the message and a secret key that
produces a fixed-length value that serves as the authenticator.
Hash function: A function that maps a message of any length into a fixed-length hash value,
which serves as the authenticator.
Essentially, a MAC is an encrypted checksum generated on the underlying message that is sent
along with a message to ensure message authentication.
The process of using MAC for authentication is depicted in the following illustration −
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
The sender uses some publicly known MAC algorithm, inputs the message and the
secret key K and produces a MAC value.
Similar to hash, MAC function also compresses an arbitrary long input into a fixed
length output. The major difference between hash and MAC is that MAC uses secret
key during the compression.
The sender forwards the message along with the MAC. Here, we assume that the
message is sent in the clear, as we are concerned of providing message origin
authentication, not confidentiality. If confidentiality is required then the message needs
encryption.
On receipt of the message and the MAC, the receiver feeds the received message and
the shared secret key K into the MAC algorithm and re-computes the MAC value.
The receiver now checks equality of freshly computed MAC with the MAC received
from the sender. If they match, then the receiver accepts the message and assures
himself that the message has been sent by the intended sender.
If the computed MAC does not match the MAC sent by the sender, the receiver cannot
determine whether it is the message that has been altered or it is the origin that has been
falsified. As a bottom-line, a receiver safely assumes that the message is not the
genuine.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
HASH FUNCTIONS
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 −
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 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.
In order to be an effective cryptographic tool, the hash function is desired to possess following
properties −
Pre-Image Resistance
o This property protects against an attacker who only has a hash value and is
trying to find the input.
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.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
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 This property makes it very difficult for an attacker to find two input values with
the same hash.
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 −
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
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.
Security of Hash Functions and Macs Just as with symmetric and public-key encryption, we can
group attacks on hash functions and MACs into two categories: brute-force attacks and
cryptanalysis.
Brute-Force Attacks The nature of brute-force attacks differs somewhat for hash functions and
MACs. Hash Functions the strength of a hash function against brute-force attacks depends
solely on the length of the hash code produced by the algorithm. Recall from our discussion of
hash functions that there are three desirable properties:
● One-way: For any given code h, it is computationally infeasible to find x such that H(x) = h.
● Weak collision resistance: For any given block x, it is computationally infeasible to find y x
with H(y) = H(x).
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
● Strong collision resistance: It is computationally infeasible to find any pair (x, y) such that H
(x) = H(y). For a hash code of length n, the level of effort required, as we have seen is
proportional to the following
DIGITAL SIGNATURES
The signature is formed by taking the hash of the message and encrypting the message with the
creator's private key. The signature guarantees the source and integrity of the message.
In one-way authentication, the recipient wants some assurance that a message is from the
alleged sender.
The digital signature standard (DSS) is an NIST standard that uses the secure hash algorithm
(SHA).
A variety of approaches has been proposed for the digital signature function. These approaches
fall into two categories: direct and arbitrated.
The direct digital signature involves only the communicating parties (source, destination). It is
assumed that the destination knows the public key of the source. A digital signature may be
formed by encrypting the entire message with the sender's private key or by encrypting a hash
code of the message with the sender's private key.
Confidentiality can be provided by further encrypting the entire message plus signature with
either the receiver's public key (public-key encryption) or a shared secret key (symmetric
encryption); for example, see Fig d and note that it is important to perform the signature
function first and then an outer confidentiality function. In case of dispute, some third party
must view the message and its signature. If the signature is calculated on an encrypted message,
then the third party also needs access to the decryption key to read the original message.
However, if the signature is the inner operation, then the recipient can store the plaintext
message and its signature for later use in dispute resolution.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
The validity of the scheme depends on the security of the sender's private key. If a sender later
wishes to deny sending a particular message, the sender can claim that the private key was lost
or stolen and that someone else forged his or her signature.
Administrative controls relating to the security of private keys can be employed to thwart or at
least weaken this ploy, but the threat is still there, at least to some degree. One example is to
require every signed message to include a timestamp (date and time) and to require prompt
reporting of compromised keys to a central authority.
Another threat is that some private key might actually be stolen from X at time T. The opponent
can then send a message signed with X's signature and stamped with a time before or equal to
T.
The problems associated with direct digital signatures can be addressed by using an arbiter. As
with direct signature schemes; there is a variety of arbitrated signature schemes. In general
terms, they all operate as follows.
Every signed message from a sender X to a receiver Y goes first to an arbiter A, who subjects
the message and its signature to a number of tests to check its origin and content. The message
is then dated and sent to Y with an indication that it has been verified to the satisfaction of the
arbiter. The presence of A solves the problem faced by direct signature schemes: that X might
disown the message.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
The arbiter plays a sensitive and crucial role in this sort of scheme, and all parties must
have a great deal of trust that the arbitration mechanism is working properly. In the first,
symmetric encryption is used.
It is assumed that the sender X and the arbiter A share a secret key K xaand that A and Y
share secret key Kay. X constructs a message M and computes its hash value H(M). Then X
transmits the message plus a signature to A. The signature consists of an identifier IDX of X
plus the hash value, all encrypted using Kxa. A decrypts the signature and checks the hash value
to validate the message. Then A transmits a message to Y, encrypted with Kay. The message
includes IDX, the original message from X, the signature, and a timestamp. Y can decrypt this
to recover the message and the signature. The timestamp informs Y that this message is timely
and not a replay. Y can store M and the signature. In case of dispute, Y, who claims to have
received M from X, sends the following message to A:
KERBEROS
A user may gain access to a particular workstation and pretend to be another user
operating from that workstation.
A user may alter the network address of a workstation so that the requests sent from the
altered workstation appear to come from the impersonated workstation.
A user may eavesdrop on exchanges and use a replay attack to gain entrance to a server
or to disrupt operations.
In any of these cases, an unauthorized user may be able to gain access to services and data that
he or she is not authorized to access. Rather than building in elaborate authentication protocols
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Version 4 [MILL88, STEI88] implementations still exist. Version 5 [KOHL94] corrects some
of the security deficiencies of version 4 and has been issued as a proposed Internet Standard
(RFC 1510).
Database:
The Authentication Server verifies access rights of users in database.
Kerberos Overview:
Step-1:
User logon and request services on host. Thus user request for ticket-granting-service.
Step-2:
Authentication Server verifies user’s access right using database and then gives ticket-
granting-ticket and session key. Results are encrypted using Password of user.
Step-3:
Decryption of message is done using the password then send the ticket to Ticket
Granting Server. The Ticket contain authenticators like user name and network address.
Step-4:
Ticket Granting Server decrypts the ticket send by User and authenticator verifies the
request then creates the ticket for requesting services from the Server.
Step-5:
User send the Ticket and Authenticator to the Server.
Step-6:
Server verifies the Ticket and authenticators then generate the access to the service.
After this User can access the services.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
X.509 uses the public-key cryptography and digital signatures. It does not dictate the use
of a specific algorithm but recommends RSA. The digital signature scheme is assumed to
require the use of a hash function. Again, the standard does not dictate a specific hash
algorithm.
Certificates
The key of X.509 scheme is the public-key certificate associated with each user. These
user certificates are assumed to be created by some trusted certification authority (CA) and
placed in the directory by the CA or by the user. The directory server itself is not responsible
for the creation of public keys or for the certification function.
Version: Differentiates among successive versions of the certificate format; the default
is version 1. If the Issuer Unique Identifier or Subject Unique Identifier are present, the
value must be version 2. If one or more extensions are present, the version must be
version 3.
Serial number: An integer value, unique within the issuing CA that is unambiguously
associated with this certificate.
Signature algorithm identifier: The algorithm used to sign the certificate, together
with any associated parameters. Because this information is repeated in the Signature
field at the end of the certificate, this field has little, if any, utility.
Issuer name: X.500 name of the CA that created and signed this certificate.
Period of validity: Consists of two dates: the first and last on which the certificate is
valid.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Subject name: The name of the user to whom this certificate refers. That is, this
certificate certifies the public key of the subject who holds the corresponding private
key.
Subject's public-key information: The public key of the subject, plus an identifier of
the algorithm for which this key is to be used, together with any associated parameters.
Issuer unique identifier: An optional bit string field used to identify uniquely the
issuing CA in the event the X.500 name has been reused for different entities.
Subject unique identifier: An optional bit string field used to identify uniquely the
subject in the event the X.500 name has been reused for different entities.
Extensions: A set of one or more extension fields. Extensions were added in version 3
and are discussed later in this section.
Signature: Covers all of the other fields of the certificate; it contains the hash code of
the other fields, encrypted with the CA's private key. This field includes the signature
algorithm identifier.
The unique identifier fields were added in version 2 to handle the possible reuse of subject
and/or issuer names over time. These fields are rarely used.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
RFC 2822 (Internet Security Glossary) defines public-key infrastructure (PKI) as the set
of hardware, software, people, policies, and procedures needed to create, manage, store,
distribute, and revoke digital certificates based on asymmetric cryptography. The principal
objective for developing a PKI is to enable secure, convenient, and efficient acquisition of
public keys. The Internet Engineering Task Force (IETF) Public Key Infrastructure X.509
(PKIX) working group has been the driving force behind setting up a formal (and generic)
model based on X.509 that is suitable for deploying a certificate-based architecture on the
Internet.
End entity: A generic term used to denote end users, devices (e.g., servers, routers), or any
other entity that can be identified in the subject field of a public key certificate. End entities
typically consume and/or support PKI-related services.
MASTERJI DEGREE & PG COLLEGE
B.C.A V SEM - CRYPTOGRAPHY & NETWORK SECURITY
Certification authority (CA): The issuer of certificates and (usually) certificate revocation
lists (CRLs). It may also support a variety of administrative functions, although these are often
delegated to one or more Registration Authorities.
Repository: A generic term used to denote any method for storing certificates and CRLs so that
they can be retrieved by End Entities.
Registration: This is the process whereby a user first makes itself known to a CA (directly, or
through an RA), prior to that CA issuing a certificate or certificates for that user. Registration
begins the process of enrolling in a PKI. Registration usually involves some offline or online
procedure for mutual authentication. Typically, the end entity is issued one or more shared
secret keys used for subsequent authentication.
Initialization: Before a client system can operate securely, it is necessary to install key
materials that have the appropriate relationship with keys stored elsewhere in the infrastructure.
For example, the client needs to be securely initialized with the public key and other assured
information of the trusted CA(s), to be used in validating certificate paths.
Certification: This is the process in which a CA issues a certificate for a user's public key, and
returns that certificate to the user's client system and/or posts that certificate in a repository.
Key pair recovery: Key pairs can be used to support digital signature creation and
verification, encryption and decryption, or both. When a key pair is used for
encryption/decryption, it is file:///D|/1/0131873164/ch14lev1sec3.html (2 von 3) [14.10.2007
09:41:37] Section 14.3. Public-Key Infrastructure important to provide a mechanism to recover
the necessary decryption keys when normal access to the keying material is no longer possible,
otherwise it will not be possible to recover the encrypted data. Loss of access to the decryption
key can result from forgotten passwords/PINs, corrupted disk drives, damage to hardware
tokens, and so on. Key pair recovery allows end entities to restore their encryption/decryption
key pair from an authorized key backup facility (typically, the CA that issued the End Entity's
certificate).
Key pair update: All key pairs need to be updated regularly (i.e., replaced with a new key pair)
and new certificates issued. Update is required when the certificate lifetime expires and as a
result of certificate revocation.
The PKIX working group has defines two alternative management protocols between
PKIX entities that support the management functions listed in the preceding subsection. RFC
2510 defines the certificate management protocols (CMP). Within CMP, each of the
management functions is explicitly identified by specific protocol exchanges. CMP is designed
to be a flexible protocol able to accommodate a variety of technical, operational, and business
models.
RFC 2797 defines certificate management messages over CMS (CMC), where CMS
refers to RFC 2630, and cryptographic message syntax. CMC is built on earlier work and is
intended to leverage existing implementations. Although all of the PKIX functions are
supported, the functions do not all map into specific protocol exchanges.