Notes Cryptography
Notes Cryptography
a) Computer Security
The collection of tools designed to protect data to prevent hackers.
b) Network Security
It measures to protect data during data transmission in network.
c) Internet Security
It measures to protect data during their transmission over a collection of
interconnected networks.
d) Information Security
Information should be secured so information security should be against physical
damage and administrative damage.
There are three aspects of information security.
(i) Security Attack
Action that compromises the security of information owned by an organization.
Security Service:
X.800- defines security service as service provided by a protocol layer of
communication open systems, which ensures adequate security of the systems or of
data transfers.
RFC 2828 defines security service as a processing or communication service provided
by a system to give a specific kind of protection to system resources.
X.800 defines security service in 5 categories
i) Authentication
Assurance that the communication entity is the one claimed
ii) Access control
Prevention of the unauthorized use of a resource.
iii) Data Confidentiality
Protection of data from unauthorized disclosure.
iv) Data Integrity
Assurance that data received are exactly as sent by an authorized entity
v) Non repudiation
Protection againt denial by one of the parties in a communication.
Security Mechanism
X-800 defines security mechanism in many ways
(i) Enciphertext
(ii) Digital Signature
(iii) Access Control mechanisms
(iv) Data Integrity Mechanisms
(v) Authentication Exchange
(vi) Traffic Padding
(vii) Routing Control
(viii) Notorisation
Security Attack:
There are two types of attack
i) Passive attack
A passive attack moniters unencrypted traffic and looks for clear-text passwords
and sensitive information that can be used in other types of attacks.
Passive attaks are difficult to detect
It is possible to prevent the passive attack by encryption
Types:
i) Release of message contents
The message transmitted should be prevented from eaves dropping.
Attacker
A Internet B
Masqurade occurs when one entity pretends to be a ifferent entity. here the attacker
captures the authentication and impersonifies the sender. Generates and transmits
the message or replay the message
ii) Replay
The attacker captures the message and retranmits the message without any
modification to produce unauthorized effect
C
A Internet B
A Internet B
v) Software Attack
Software attacks are those which can be introduced into the systems or networks.
Ex viruses.
1.3 NETWORK SECURITY MODEL
Trusted third party
(e.g: arbiter, distributer of
secret information)
Sender Recipient
Secure Message
Message
Message
Secret Secret
information information
Opponent
i) Plaintext
It is original intelligible data or message that is fed into the algorithm as input.
Fig -1.4.1 (a) simplified model of symmetric encryption
iv) Ciphertext
This is the scrambled (or) altered message produced as output. It depends on the plain
text and the secret key. for a given message, two different keys will produce two different
ciphertexts. The ciphertext is an apparently random stream of data and as it is
unintelligible.
v) Decryption algorithm
Encryption algorithm run in reverse it takes the ciphertext and the secret key and
produces the original plain text.
The opponent should be unable to decrypt ciphertext or discover the key even if
he or she is in possession of a number of ciphertexts together with the plain-text
that produced each ciphertext.
ii) Sender and receiver should have secret key copies in a secure way. If key is
discovered, then all communication using this key is readable.
Assumption
It is not possible to decrypt a message on the basis of the ciphertext plus knowledge of
the encryption/decryption algorithm. For this, key should be secured (i.e̵.) manufactures have
developed low-cast chip implementations of data encryption algorithms. These chips are
incorporated into a number of products.
Solution
By usin`g symmetric encryption, the principal security problem is maintaining the
key secrecy
Working
with the message X and encryption key K as input, encryption algorithm forms
the ciphertext Y=[Y1,Y2,....YN], can be written as Y=E(K,X).
Y is produced by using encryption algorithm E as a Function of the plaintext X,
with the specific function determined by the value of the key k.
The receiver in possession of the Key is able to invert the transformation
X=D (K,Y)
opponent observing Y but no access to k or X, but attempt to recver X or K or both
X and K
Assume
An opponent knows the Encryption and Decryption algorithms. If the opponent wants
to know one particular message, then he/ she recover x by generating a plaintext estimate x.
1.4.1.1. Cryptography
Cryptographic systems characterization
(i) The type of operations used for transforming plaintext to ciphertext
Encryption algorithms based on 2 principles
a substitution
Each element in plaintext is mapped into another element.
b) Transposition
Elements in the plaintext are rearranged.
Basic requirement is that no information be lost.
(ii) The number of Keys used
a) If sender and receiver use the same key, the system is referred to as symmetric,
single-key, secret key, or conventional encryption.
b) If sender and receiver use different keys, the system is referred to as
asymmetric, two-key, or public-key encryption.
(iii)The way in which plaintext is processed
a) A block cipher process the input (i.e) one block of element at a time,
producting an output block for each input block.
b) A stream cipher processes the input elements continuously, producing output
one element at a time.
(I) Cryptanalysis
This attacks rely on the nature of the algorithm plus some knowledge of the general
characteristics of the plaintext or plain-cipher text pairs. This type of attack deduce a specific
plaintext or to deduce the key being used.
The table shows the various types of cryptanalytic attacks based on the amount of
information known to the cryptanalyst.
Assume
The opponent know the encryption algorithm possible attack under these
circumstances is the brute-force approach of trying all possible keys.
Solution
If the key space is very large, its impractical. So the opponent rely on an analysis of
the ciphertext, applying various statistical tests to it. To use this approach, the opponent
must have general idea of the type of plaintext that is concealed.
a) Ciphertext-only Attack
it’s easiest to defend against because the opponent has less amount of information.
Usually, the analyst has more information, analyst capture more plaintext messages
and their encryption or analyst know the particular plaintext pattern will appear in the
message.
Example
A file is encoded in the postscript format always begins with the same pattern, or
there may be a standardized header or banner to an electronic funds transfer
message. All these are examples of known plaintext. The analyst deduce the key
on the basis of the way in which the known plaintext is transformed.
b) Known plaintext
it is also referred to as a probable-world attack. It the opponent is working with the
encryption of same general prose message, he she may have little knowledge of what
is in the message. If opponent is with specific information, then parts of the message is
known.
Example
Accounting files is transmitted, the opponent know the placement of key words in
the header of the files.
c) Chosen-plaintext
if the analyst is able to get the source system to insert into the system a message
chosen by the analyst, then a Chosen-plaintext attack is possible
Example
If the analyst choose the message to encrypt, he may pick patterns that can be
expected to reveal the structure of the key.
e) Chosen text
These two are commonly employed as cryptanalytic techniques.
i) The cost of breaking the cipher exceeds the value of the encrypted information.
ii) the time required to break the cipher exceeds the lifetime of the information.
(i.e.) There are X different Keys, an attacker discover the actual key after X/2 tries,
known plaintext is provided, Analyst should recognize plaintext as plaintext.
if the message is plaintext, result POPS out. If the message is compressed before
encryption, the recognition of English language itself is more difficult.
if the message is some more general type of data, such as a numerical file, and this
has been compressed, the problem becomes more difficult to automate.
To supplement the brute-force approach, some degree of knowledge about the
expected plaintext is needed.
A substitution technique in which the letters of plaintext are replaced by other letters
or by number of symbols. If plaintext is viewed as a sequence of bits, then substitution
involves replacing plaintext bit patterns with ciphertext bit patterns.
a) Caesar Cipher
The Caesar cipher means replacing each letter of the alphabet with the letter standing
three places further down the alphabet.
Example
Plaintext Meet me after the toga party
Ciphertext PHHW PH DIWHU WKH WRJD SDUWB
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 MN O P Q R S T U V WX Y Z A B C
a b c d e f g h i j k l m
0 1 2 3 4 5 6 7 8 9 10 11 12
n o p q r s t u v w x y z
13 14 15 16 17 18 19 20 21 22 23 24 25
Try all the 25 possible keys. Below fig shows the results of applying this strategy to
the example ciphertext.
In this case, the plain text leaps out as occupying the third line.
If the language of the plaintext in unknown, then plaintext output may not be
recognizable. The input is abbreviated or compressed again making
recognition difficult.
Fig-1.4.2(b) Sample of compressed text
The above fig shows a portion of a text files compressed using an algorithm called
ZIP. If this file is encrypted with a simple substitution cipher then the plaintext is not
recognized when it is uncovered in the brute-force cryptanalysis .
b) Monoalphabetic Ciphers
Increase in the key space can be achieved by following an arbitrary substitution
permutation.
It is a finite set of elements S is an ordered sequence of all the elemts of S, with each
element appearing exactly once.
Example
If S={a,b,c}, there are six permutations of S.
Abc, acb, bac, bca, cab, cba
There are n! Permutations of a set of n elements, because the first element can be
chosen in one of n ways, the second in n-1 ways, the third in n-2 ways.
Recall the assignment for the Caesar Cipher
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 MN O P Q R S T U V WX Y Z A B C
Line of Attack`
Cryptanalyst know the nature of the plaintext, then the analyst can exploit the
regularities of the language.
To Solve
The cipher text
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
the relative frequency of the letters determined and compared to a standard
frequency distribution for English as shown in below fig
The above breakdown is compared with fig-1.4.2 (c), cipher letters p and z are the
equivalent of plain letters e and t, but it’s not certain which is which.
i) The letters S, V, O, M and H are all of relatively high frequency and probably
correspond to plain letters from the Set {a, h, i, n, o, r, s}.
ii) The letters with the lowest frequencies are likely included in the Set {b, j, k, q, v,
x, z}.
Tentative assignments are made and start to fill in the plaintext to see if it
looks like a reasonable “skeleton” of message.
A systematic approach is to look for other regularities.
Example
Certain words may be known to be in the text.
We could look for repeating sequences of cipher letters and try to deduce their
plaintext equivalent.
Diagram
A powerful tool is to look at the frequency of two=letter combinations known as
diagrams.
A table similar to fig-1.4.2(c) could be down up showing the relative frequency of
diagrams.
In out ciphertext, the common diagram is zw, which appears three times. So we
make the correspondence of z with t and w with h.
By our earlier hypothesis, we can equate p with e.
The sequence zwp appears in the ciphertext, and we can translate that sequence as
“the”.
This is the most Frequent trigram in English, which seems to indicate that we are
on the right track.
Notice the sequence zwsz in the first line. We don’t know that these four letters
form a complete word, but if they do, it is of the form th_t. If so, S equates with a.
So far, then, we have
Only four letters have been identified, but already we have quite a bit of the message.
Continued analysis of frequencies plus trial and error should easily yield a solution from this
point. The complete plaintext, with spaces added between words, follows
It was disclosed yesterday that several informal but direct contacts have been made
with political representatives of the viet cong in moscow
Monoalphabetic ciphers are easy to break because they reflect the frequency data of
the original alphabet. A countermeasure is to provide multiple substitutes, known as
homophones, for a single letter
Example
The letter e could be assigned a number of different cipher symbols, such as 16, 74, 35
and 21, which each homophone assigned to a letter in rotation or randomly.
If the number of symbols assigned to each letter is proportional to the relative
frequency of that letter, than single-letter frequency information is completely
obliterated.
With homophones, each element of plaintext affects only one element of ciphertext,
and multiple-letter patterns still survive in the ciphertext, making cryptanalysis
relatively straight forward.
Two methods are used in substitution cipher to lessen the extent to which the structure
of the plaintext survives in the ciphertext
i) To encrypt multiple letters of plaintext.
ii) To use multiple cipher alphabets
c) Playfair cipher
The best-known multiple-letter encryption cipher is the playfair, which treats diagrams
in the plaintext as single units and translate these units into ciphertext diagrams.
The playfair algoritms is based on the use of 5x5 matrix of letters constructed using a
keyword
Example
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
Playfair Cipher-Effect
Fig 1.4.2(d) Relative Frequency of occurrence of Letters
The line labelled plaintext plots a typical frequency distribution of the 26 alphabetic
characters in ordinary text.
Plot-development
The number of occurrences of each letter in the text is counted and divided by the
number of occurrences of the most frequently used letter.
Result
Using the results of the above fig,
e is the most frequently used letter.
e has a relative frequency of 1, t of 9.056/12.702 ≈ 0.72 and so on.
The point on the horizonal axis correspond to the letter in order of decreasing
frequency
the above fig shows the frequency distribution results when the text is encrypted
using the playfair cipher.
To normalize the plot the number of occurrences of each letter in the ciphertext
divided by the number of occurrences of e in the plaintext.
The resulting plot shows the extent to which the frequency distribution of letters,
which makes it trivial to solve substitution ciphers, is masked by encryption.
playfair cipher has a flatter distribution than does plaintext, but it reveals plenty of
structure for a cryptanalyst to work with.
d) Hill Cipher
Before learning hill cipher, let us study basics of linear algebra, which is necessary to
understand matrix arithmetic module 26
i) linear algebra
Define the inverse M-1 of a square matrix M by the eqn
M(M-1) = M-1 M = I
Where I is the identity matrix
Square Matrix
I is a square matrix that is all zeros except for ones along the main diagonal from
upper left to lower right.
The inverse of a matrix does not always exist, but when it does, it satisfies the
preceding equation.
Example
5 8 9 2
𝐴=( ) 𝐴−1 𝑚𝑜𝑑 26 = ( )
17 3 1 15
(5 × 9) + (8 × 1) (5 × 2) + (8 × 15)
𝐴𝐴−1 = ( )
(17 × 9) + (3 × 1) (17 × 2) + (3 × 15)
53 130 1 0
=( ) 𝑚𝑜𝑑 26 = ( )
156 79 0 1
Computation of inverse of a matrix
Determinant concept is used for any square matrix (𝑚 × 𝑚), the determinant
equals the sum of all the products that can be formed by taking exactly one element from
each row and exactly one element from each column, with certain of the product terms
preceded by a minus sign.
For a 2 × 2 matrix,
𝑘11 𝑘12
[ ]
𝑘21 𝑘22
The determinant is k11 k22 – k12 k21
For a 3 × 3 matrix,
Where (Dji) is the subdeterminant formed by deleting the jth row and the ith column
of A, det (A) is the determinant of A, and (det A) -1 is the multiplicative inverse of (det A)
mod 26.
5 8
det ( ) = (5 × 3) − (8 × 17) = −121 od 26 = 9
17 3
We can show that 9-1 mod 26 = 3, because 9 * 3 = 27 mod 26 = 1 (see Chapter 4
or Appendix E). Therefore, we compute the inverse of A as
5 8
A=( )
17 3
3 −8 3 18 9 54 9 2
𝐴−1 𝑚𝑜𝑑 26 = 3 ( ) = 3( )=( )= ( )
−17 5 9 5 27 15 1 15
ii) The Hill Algorithm
This encryption algorithm takes m successive plaintext letters and substitutes for
them m ciphertext letters.
The substitution is determined by m linear equations in which each character is
assigned a numeric`al value
(a = 0, b=1,….,Z = 25)
C=PK mod 26
Where c and p are row vectors of length 3 representing the plaintext and
ciphertext, and k is a 3× 3 matrix representing the encryption key operations are
performed mod 26.
Example
Plaintext “paymore money” and use the encryption key
17 17 5
K = [21 18 21]
2 2 19
The first three letters of the plaintext are represented by the vector ( 15 0 24)
Then (15 0 24) k = (303 303 531)
Mod 26 = ( 17 17 11) =RRL
Decryption
It requires using the inverse of the matrix k.
Compute det K = 23, and (det k)-1 mod 26 = 17
Computing the inverse as
4 9 15
𝑘 −1 = (15 17 6)
24 0 17
This is demonstrated as
Example
Plaintext “ hillcipher” is encrypted using a 2*2 Hill Cipher to yield the ciphertext
HCRZSS*NSP.
7 2 7 8
( )=( ) 𝐾 𝑚𝑜𝑑 26
17 25 11 11
The inverse of X can be computed
7 8 −1 25 22
( ) =( )
11 11 1 23
25 22 7 2 549 600 3 2
so K=( )( )= ( ) 𝑚𝑜𝑑26 = ( )
1 23 17 25 398 577 8 5
This result is verified by testing the remaining plaintext ciphertext pairs.
e) Polyalphabetic Ciphers
A monoalphabetic technique is to use different monoalphabetic substitutions as one
proceeds through the plaintext message. This approach is polyalphabetic substitution cipher.
Features
1. A set of related monoalphabetic substitution rules is used.
2. A Key determines which particular rule is chosen for a given transformation
i) Vigenere Cipher
Simplest polyalphabetic ciphers is the Vigenee Cipher.
Assume
Sequence of plaintext letters
P = P0, P1, P2,…..Pn-1 and
A key consisting of the sequence of letters
K = K0, K1, K2, …,Km-1 where m < n
Sequence of ciphertext letters
C = C1, C1, C2, …, Cn-1 is calculated as
C = C0, C1, C2, …, Cn-1 = E(K, P) = E[(k0, k1, k2, …, km-1), (p0, p1, p2,…, pn-1)]
= (p0 + k0) mod 26, (p1 + k1) mod 26, …, (pm-1 + km-1) mod 26,
(pm + k0) mod 26, (pm+1 + k1) mod 26, …, (p2m-1 + km-1) mod 26, …
First letter of the key is added to the first letter of the plaintext, mod 26, the second
letters are added and so on through the first m letters of the plaintext, for the next
m letters of text, the key letters are repeated.
This process continues all the plaintext sequence is encrypted.
Decryption
It is a generalization of eqn (2).
Pi = (Ci – Ki mod m) mod 26----------------------------------------(4)
Encryption
Example
Keyword is deceptive, Message “ we are discovered save yourself”
Encrypted as
Vigener cipher – advantage
The strength of this cipher is there are multiple ciphertext letters for each plaintext
letter, one for each unique letter of the keyword. So, the letter frequency information is
covered, not all knowledge of the plaintext structure is lost.
Example
Fig – 1.4.2 (d) shows the f.d. for a vigener cipher with a keyword of length 9.
If monoalphabetic substitution is used, then properties of the ciphertext should be
the same as the language of the plaintext. A shown in fig – 1.4.2(c), there is one cipher
letter with a relative frequency of occurrence of about 12.7%, one with 9.06% and so on.
Keyword length – Determination
If two identical sequences of plaintext letters occur at a distance (i.e) an integer
multiple of the keyword length, they will generate identical ciphertext sequences.
Example
Two instances of the sequence “red” are separated by nine character positions.
R is encrypted using key letter e
E is encrypted using key letter p
D is encrypted using key letter t
Ciphertext sequence is vtw. This is indicated above by underlining the relevant
ciphertext letters and shading the relevant ciphertext numbers.
An analyst detect the repeated sequences vtw at a displacement of 9 and make the
assumption that the keyword is either three or nine letters in length. The appearance of
vtw twice not reflect identical plaintext letters encrypted with ide`ntical key letters.
It the message is long there is repeated ciphertext sequences by looking for
common factors in the displacement of the various sequences, the analyst guess the
keyword length.
Cipher – solution
It the keyword length is m, then the cipher consists of m monoalphabetic
substitution ciphers.
Example
Keyword DECEPTIVE, the letters in positions 1, 10, 19 and so on are all
encrypted with the same monoalphabetic cipher.
So, we can use the frequency characteristics of the plaintext language to attack
each of the monoalphabetic ciphers separately.
Example
Key deceptive weared is coveredsave
Plaintext weared is covered save yourself
Ciphertext ZICVIWQNGKZEIIGASXSTSLVVWLA.
Key and plaintext share the same frequency distribution of letters, statistical
techniques are applied.
Example
E enciphered by e
By fig – 14.2 (c), can be expected to occur with a frequency of (0.127)2 =
0.016, t enciphered by t would occur only half.
pi = ci ki
which compares with Equation (4).
f) one-time pad
Vernam cipher yields the security. Using a random key which is as long as the
message so that the key is not repeated. Key is to encrypt and decrypt a single message, and
then discarded. Each new message requires a new key of the same length as the new message,
such a scheme known as one-time pad is unbreakable.
It produces o/p that bears no statistical relationship to the plaintext because ciphertext
has no information about the plaintext, there is no way to break the code.
Example
Vigenere scheme with 27 characters in which 27th character is the space character, but
with a one-time key (i.e) as long as the message.
Ciphertext
It’s difficult for the crypt analyst to say that one of these two keys is more likely than
the other. So, these is no way to decide which key is correct and which plaintext is
correct.
Example
Encipher the message
“meet me after the toga party”
With a rail fence of depth 2.
We write as
Mematrhtgpry
Etefeteoaat
The encrypted message is
MEMATRHTGPRYETEFE TEOAAT
Technique – complex
To write the message in a rectangle, row by row and read the message off, column by
column, but permute the order of the columns. The order then becomes the key to the
algorithm.
Example
the key is 4 3 1 2 5 6 7
to encrypt, start with the column that is labeled 1, in this column 3.
write down all the letters in that column. Proceed to column 4, which is labeled 2,
then column 2, then column 1, then columns 5, 6 and 7.
This cipher has the same letter frequenices as the original plaintext
In columnar transposition, laying out the cipher text in a matrix and playing around
with column positions.
digram and trigram frequency tables can be useful.
The result is a more complex permutation that is not easily reconstructed.
Thus, if the foregoing message is reencrypted using the same algorithm.
To visualize the result of this double transposition, designate the letters in the
original plaintext message by the numbers designating their position. Thus, with 28 letters
in the message, the original sequence of letters is
which has a somewhat regular structure. But after the second transposition, we
have
This is a much less structured permutation and is much more difficult to
cryptanalyze.
1.4.4 STEGANOGRAPHY
A plaintext message hidden in one or two ways. The methods of steganography
conceal the existence of the message, whereas the methods of cryptography render the
message unintelligible to outsiders by various transformations of the text.
3rd March
Dear George,
Greetings to all at Oxford. Many thanks for your letter and for the Summer
examination package. All Entry Forms and Fees Forms should be ready for final
despatch to the Syndicate by Friday 20th or at the very latest, I'm told, by the 21st.
Admin has improved here, though there's room for improvement still; just give us
all two or three more years and we'll really show you! Please don't let these
wretched 16+ proposals destroy your basic O and A pattern. Certainly this sort of
change, if implemented immediately, would bring chaos.
Sincerely yours,
Stenography – Drawbacks
It requires a lot of overhead to hide a relatively few bits of information, although
using a scheme like that proposed in the preceding paragraph may make it more
effective.
Once the system is discovered, it becomes worthless.
message is encrypted and hidden using stegnography.
Stenography – Advantages
It can be employed by parties who have something to lose should be fact of their
secret communication be discovered.
Encryption flags traffic identify the sender or receiver as someone with something
to hids.
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner
Scanned by CamScanner