Cns 19773
Cns 19773
For Encrypt each plaintext letter p, substitute the cipher text letter c such that
C = E(p) = (p+3) mod 26,
a shift may be any amount, so that general Caesar algorithm is
C = E (p) = (p+k) mod 26
where k takes on a value in the range 1 to 25.
The decryption algorithm is simply P = D(C) = (C-k) mod 26 (or) to Encrypt a message M.
Convert the letter into the number that matches its order in the alphabet starting from 0,
and call this number X, (A=0, B=1, C=2, ..., Y=24, Z=25).
Calcúlate: Y = (X + K) mod 26
Convert the number Y into a letter that matches its order in the alphabet starting from 0.
Example:
By using the Shift Cipher with key K=19 for our message.
We encrypt the message "KHAN", as follows
• So, after applying the Shift Cipher with key K=19 our message text "KHAN" gave
us cipher text "DATG".
• For every letter in the cipher text C, convert the letter into the number that matches its
order in the alphabet starting from 0, and call this number Y.
• If it is known that a given ciphertext is a Caesar cipher, then a brute-force
cryptanalysis is easily performed: Simply try all the 25 possible keys.
Monoalphabetic Ciphers:
With only 25 possible keys, the Caesar cipher is far from secure. A dramatic increase in the
key space can be achieved by allowing an arbitrary substitution. Before proceeding, the term
permutation can be defined.
A permutation of a finite set of elements S is an ordered sequence of all the elements of S,
with each element appearing exactly once.
For example, if S = {a, b, c}, there are six permutations of S:
In general, 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, and so on.
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 Caesar
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
If, instead, the “cipher” line can be any permutation of the 26 alphabetic characters, then there
are 26! or greater than 4 * 1026 possible keys.
This is 10 orders of magnitude greater than the key space for DES and would
seem to eliminate brute-force techniques for cryptanalysis. Such an
approach is referred to as a mono alphabetic substitution cipher, because a
single cipher alphabet (mapping from plain alphabet to cipher alphabet) is
used per message.
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.
For example, the letter e could be assigned a number of different cipher symbols, such as 16,
74, 35, and 21, with each homophone assigned to a letter in rotation or randomly.
Playfair Cipher:
The best-known multiple-letter encryption cipher is the Playfair, which treats diagrams in the
plaintext as single units and translates these units into cipher text diagrams
Repeating plaintext letters that are in the same pair are separated with a filler letter, such as x,
so that balloon would be treated as ba lx lo on.
Two plaintext letters that fall in the same row of the matrix are each replaced by the letter to
the right, with the first element of the row circularly following the last. For example, ar is
encrypted as RM.
Two plaintext letters that fall in the same column are each replaced by the letter beneath, with
the top element of the column circularly following the last. For example, mu is encrypted as
CM.
Otherwise, each plaintext letter in a pair is replaced by the letter that lies in its own row and
the column occupied by the other plaintext letter. Thus, hs becomes BP and ea becomes IM
The Playfair cipher is a great advance over simple monoalphabetic ciphers. For one thing,
whereas there are only 26 letters, there are 26 * 26 = 676 digrams, so that identification of
individual digrams is more difficult. Furthermore, the relative frequencies of individual
letters exhibit a much greater range than that of digrams, making frequency analysis much
more difficult.
For these reasons, the Playfair cipher was for a long time considered unbreakable. It was used
as the standard field system by the British Army in World War I and still enjoyed
considerable use by the U.S. Army and other Allied forces during World War II.
Hill Cipher:
Another interesting multiletter cipher is the Hill cipher, developed by the mathematician
Lester Hill in 1929.
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 numerical value (a = 0, b = 1,….., z = 25). For m = 3, the system can
be described as
c1 = (k11p1 + k21p2 + k31p3) mod 26 c2 = (k12p1 + k22p2 + k32p3) mod 26 c3 = (k13p1 + k23p2 +
k33p3) mod 26
or
C = PK mod 26
Where C and P are row vectors of length 3 representing the plaintext and ciphertext, and K is
a 3 x 3 matrix representing the encryption key. Operations are performed mod 26.
Polyalphabetic ciphers
A polyalphabetic cipher is any cipher based on substitution, using multiple substitution
alphabets. The Vigenère cipher is probably the best-known example of a polyalphabetic
cipher.
Vigenere cipher:
� Vigenere Cipher is a method of encrypting alphabetic text. It uses a simple form
of polyalphabetic substitution. A polyalphabetic cipher is any cipher based on
substitution, using multiple substitution alphabets .The encryption of the original
text is done using the Vigenère square or Vigenère table.
• The table consists of the alphabets written out 26 times in different rows, each
alphabet shifted cyclically to the left compared to the previous alphabet,
corresponding to the 26 possible Caesar Ciphers.
• At different points in the encryption process, the cipher uses a different alphabet
from one of the rows.
• The alphabet used at each point depends on a repeating keyword
The Vigenère cipher can be expressed in the following manner. Assume a sequence of
plaintext letters P = p0, p1, p2, ...... ,p n-1 and a key consisting of the sequence of letters K = k0,
k1, k2, ...... , k m-1, where typically m <n. The sequence of ciphertext letters C = C0, C1, C2,
……, C n-1 is calculated as follows:
C = C0, C1, C2, …..,C n-1 = E(K, P) = E[(k0, k1, k2, ….., k m-1), (p0, p1, p2…., p n-1)]
= (p0 + k0) mod 26, (p1 + k1) mod 26, ……, (p m-1 + k m-1) mod 26, (pm+ k0) mod 26, (p m+1 +
k1) mod 26, ……. , (p 2m-1 + k
Thus, the 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 the plaintext, the key letters are repeated. This process continues until all of the plaintext
sequence is encrypted. A general equation of the encryption process is
To encrypt a message, a key is needed that is as long as the message. Usually, the key is a
repeating keyword. For example, if the keyword is deceptive, the message “we are discovered
save yourself” is encrypted as
ciphertext : ZICVTWQNGRZGVTWAVZHCQYGLMGJ
The strength of this cipher is that there are multiple ciphertext letters for each plaintext letter,
one for each unique letter of the keyword. Thus, the letter frequency information is obscured.
However, not all knowledge of the plaintext structure is lost.
Vernam Cipher The ultimate defense against such a cryptanalysis is to choose a keyword that
is as long as the plaintext and has no statistical relationship to it. Such a system was
introduced by an AT&T engineer named Gilbert Vernam in 1918.
ciphertext = 1 0 0 0 0 1 0 1
Advantage:
Encryption method is completely unbreakable for a ciphertext only attack.
Disadvantages
It requires a very long key which is expensive to produce and expensive to transmit.
Once a key is used, it is dangerous to reuse it for a second message; any knowledge on
the first message would give knowledge of the second.
STEGANOGRAPHY:
� Steganography is the technique of hiding secret data within an ordinary, non-secret,
non file
or message in order to avoid detection; the secret data is then extracted at its destination.
The use of steganography can be combined with encryption as an extra step for hiding
or protecting data.
� It stems from two Greek words, which are steganos, means covered
and graphia, means writing
� Examples,
1. Playing an audio track backwards to reveal a secret message
2. Playing a video at a faster frame rate (FPS) to reveal a hidden image
3. Embedding a message in the red, green, or blue channel of an RGB image
4. Hiding information within a file header or metadata
5. Embedding an image or message within a photo through the addition of digital noise
• As the image depicts, both cover file(X) and secret message(M) are fed into
steganographic encoder as input.
• Steganographic Encoder function, f(X,M,K) embeds the secret message into a cover
file.
• Resulting Stego Object looks very similar to your cover file, with no visible changes.
• This completes encoding. To retrieve the secret message, Stego Object is fed into
Steganographic Decoder.
� Steganography Techniques
� Depending on the nature of the cover object (actual object in which secret data is
embedded), steganography can be divided into five types:
1. Text Steganography
2. Image Steganography
3. Video Steganography
4. Audio Steganography
5. Network Steganography
� Text Steganography: Text Steganography is hiding information inside the text
files. Various techniques used to hide the data in the text are:
• Format Based Method
• Random and Statistical Generation
• Linguistic Method
� Image Steganography: Hiding the data by taking the cover object as the image is known
as image steganography. There are a lot of ways to hide information inside an image.
Common approaches include:
• Least Significant Bit Insertion
• Masking and Filtering
• Redundant Pattern Encoding
• Encrypt and Scatter
• Coding and Cosine Transformation
� Audio Steganography: In audio steganography, the secret message is embedded into an
audio signal which alters the binary sequence of the corresponding audio file. Different
methods of audio steganography include:
• Least Significant Bit Encoding
• Parity Encoding
• Phase Coding
• Spread Spectrum
� Video Steganography: In Video Steganography you can hide kind of data into digital
video format. Two main classes of Video Steganography include:
• embedding data in uncompressed raw video and compressing it later
• Embedding data directly into the compressed data stream
• Network Steganography (Protocol Steganography): It is the technique of embedding
information within network control protocols used in data transmission such TCP,
UDP, ICMP etc. For Example, you can hide information in the header of a
TCP/IP packet in some fields that are either optional.
Example:
(i) the sequence of first letters of each word of the overall message spells out the real (hidden)
message.
(ii) Subset of the words of the overall message is used to convey the hidden message.
Various other techniques have been used historically, some of them are:
Character marking – selected letters of printed or typewritten text are overwritten in pencil.
The marks are ordinarily not visible unless the paper is held to an angle to bright light.
Invisible ink – a number of substances can be used for writing but leave no visible trace until
heat or some chemical is applied to the paper.
Pin punctures – small pin punctures on selected letters are ordinarily not visible unless the
paper is held in front of the light.
Typewritten correction ribbon – used between the lines typed with a black ribbon, the
results of typing with the correction tape are visible only under a strong light.
Drawbacks of steganography
Requires a lot of overhead to hide a relatively few bits of information.
Once the system is discovered, it becomes virtually worthless.
TRANSPOSITION TECHNIQUES:
All the techniques examined so far involve the substitution of a cipher text symbol for a
plaintext symbol. A very different kind of mapping is achieved by performing some sort of
permutation on the plaintext letters. This technique is referred to as a transposition cipher.
Rail fence is simplest of such cipher, in which the plaintext is written down as a sequence of
diagonals and then read off as a sequence of rows.
Plaintext = meet at the school house
To encipher this message with a rail fence of depth 2, we write the message as
follows:
meatecolos
etthsHohue
The encrypted message is MEATECOLOSETTHSHOHUE
Row Transposition Ciphers--A more complex scheme is 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 of columns then becomes the key of the algorithm.
e.g., plaintext = meet at the school house
Key = 4 3 1 2 5 6 7
PT = m e e t a t t
heschoo
lhouse
CT = ESOTCUEEHMHLAHSTOETO
A pure transposition cipher is easily recognized because it has the same letter frequencies as
the original plaintext. The transposition cipher can be made significantly more secure by
performing more than one stage of transposition. The result is more complex permutation that
is not easily reconstructed.
FINITE FIELDS AND NUMBER THEORY:
� Finite fields have become increasingly important in cryptography.
� A number of cryptographic algorithms rely heavily on properties of finite fields, notably
the Advanced Encryption Standard (AES) and elliptic curve cryptography.
� Other examples include the message authentication code CMAC and the authenticated
encryption scheme GCM
� Groups, Rings, Fields, Modular arithmetic, Euclid’s algorithm
� Finite fields Euclid’s algorithm
� Polynomial Arithmetic
� Prime numbers-Fermat’s and Euler’s theorem
� Testing for primality
� The Chinese remainder theorem
� Discrete logarithms
� Widely used in cryptography to perform large calculations
� Some basic concepts are
� Prime Number: a number that is divisible only by itself and 1 (e.g. 2, 3, 5, 7, 11)
� Relative Prime Number: Two integers are relatively prime (or coprime) if there is no
integer greater than one that divides them both (that is, their greatest common divisor
is one). For example, 12 and 13, GCD (12,13) = 112 and 13 are relatively prime,
but 12 and 14 are not.,
� Modular
Congruent Modulo
� Modular : When we divide two integers we will have an equation that looks like the
following:
� A/B=Q remainder R
� A is the dividend
B is the divisor
Q is the quotient
R is the remainder
� Sometimes, we are only interested in what the remainder is when we divide A by B.
For these cases there is an operator called the modulo operator (abbreviated as mod).
� Using the same A, B, Q, and R as above, we would have: A mod B=R
� We would say this as A modulo B is equal to R. Where B is referred to as
the modulus.
Ex. 13/5= 2 remainder of 3 then, 13 mod 5 = 3
CONGRUENT MODULO:
� Consider two integers a and b
� a and b said to be congruent to n for
� a (mod n) = b (mod n) then
� a ≡ b (mod n) (OR) a (mod n) = b
� example:
� let a=73, b=4 and n=23
find a mod n
� 73 mod 23 =4 (reminder of 73/23)
find b mod n
� since 23 is larger than 4 then,
� 4 mod 23 = 4
here 73 mod 23 = 4 and 4 mod 23=4, this can be written as
� 73 ≡ 4 (mod 23) ==> a ≡ b (mod n)
Properties of Congruences
The (mod n)) operator maps all integers into the set of integers {0, 1, c, (n
( - 1)}. This
technique is known as modular arithmetic.
First property:
Define (a mod n) = raand (b mod n) = rb. Then we can write a = ra+ jnfor some integer j and b
= rb+ knfor some integer k.
Then
Define (a mod n) = raand (b mod n) = rb. Then we can write a = ra+ jnfor some integer j and b
= rb+ knfor some integer k.
Then
11 mod 8 = 3; 15 mod 8 = 7
Thus, the rules for ordinary arithmetic involving addition, subtraction, and multiplication
carry over into modular arithmetic. The following table below provides an illustration of
modular addition and multiplication modulo 8
Both matrices are symmetric about the main diagonal in conformance to the commutative
property of addition and multiplication.
As in ordinary addition, there is an additive inverse, or negative, to each integer in modular
arithmetic.
In this case, the negative of an integer x is the integer y such that (x + y) mod 8 = 0.
Fermat’s Theorem
Fermat‟s theorem states the following:
fo If p is prime and a is a positive integer
ger
not divisible by p, then
Proof: Consider the set of positive integers less than p: {1, 2, c, p - 1} and
multiply each element by a, modulo p, to get the set X = {a mod p, 2a a mod
p, c, (p - 1)amod p}.
}. None of the elements of X is equal to zero because p
does not divide a. Furthermore, no two of the integers in X are equal.
Euler’s Theorem
Euler‟s theorem states that for every a and n that are relatively prime:
(n) = (n- 1) and Fermat‟s theorem holds. However, it also holds for any integer n. (n) is
the number of positive integers less than n that are relatively primeto n.
R = {x1, x2,……,Φ(݊)}
That is, each element xiof R is a unique positive integer less than n with gcd(x
gcd( i, n) = 1.
Because a is relatively prime to n and xiis relatively prime to n, aximust also be relatively
prime to n. Thus, all the members of S are integers that are less than n and that are relatively
primeto n.
Therefore,
ϕn ϕn
(axi mod n) = xi
i=1 i=1
ϕn ϕn
xi = ∑(axi mod n)
i=1 i=1
ϕn
(݊) × [∏ xi (݉݀
i=1 ݊)]
(݊) ≡ 1 ݉݊ ݀
which completes the proof. This is the same line of reasoning applied to the proof of
Fermat‟s theorem.
ϕ(n) 4
a=3; n=10; ϕ(10)= 4a = 3 = 81 = 1(mod 10) = 1(mod n) a=2; n=11;
ϕ(n) 10
ϕ(11)= 10a = 2 = 1024 = 1(mod 11) = 1(mod n)
As is the case for Fermat‟s theorem, an alternative form of the theorem is also useful:
ܽ߶ ݊ +1 ≡ ܽ ݉݊ ݀
One of the most useful results of number theory is the Chinese remainder theorem (CRT).
In essence, the CRT says it is possible to reconstruct integers in a certain range from their
residues modulo a set of pairwise relatively prime moduli.
FINITE FIELDS
Groups, Rings and Field:
Group:: A set of elements that is closed with respect to some operation.
Closed-> The result of the operation is also in the set
The operation obeys:
Obeys associative law: (a.b).c = a.(b.c)
Has identity e: e.a = a.e = a
Has inverses a-1: a.a-1 = e
Abelian Group: The operation is commutative
a.b = b.a
Example: Z8, + modular addition, identity =0
Cyclic Group
Exponentiation: Repeated application of operator
example: a3 = a.a.a
Cyclic Group: Every element is a power of some fixed element, i.e., b = ak
for some a and every b in group a is said to be a generator of the group
Example: {1, 2, 4, 8} with mod 12 multiplication, the generator is 2.
20=1, 21=2, 22=4, 23=8, 24=4, 25=8
Ring:
A group with two operations: addition and multiplication
The group is abelian with respect to addition: a+b=b+a
Multiplication and additions are both associative:
a+(b+c)=(a+b)+c
a.(b.c)=(a.b).c
Multiplication distributes over addition, a.(b+c)=a.b+a.c
Commutative Ring: Multiplication is commutative, i.e., a.b = b.a
Integral Domain: Multiplication operation has an identity and no zero divisors
Field:
An integral domain in which each element has a multiplicative inverse.
Polynomial Arithmetic
f(x) = anxn + an-1xn-1 + …+ a1x + a0 = Σ aixi
1. Ordinary polynomial arithmetic:
• Add, subtract, multiply, divide polynomials,
• Find remainders, quotient.
• Some polynomials have no factors and are prime.
2. Polynomial arithmetic with mod p coefficients
3. Polynomial arithmetic with mod p coefficients and mod m(x) operations
Polynomial Arithmetic with Mod 2 Coefficients
• All coefficients are 0 or 1, e.g.,
let f(x) = x3 + x2 and g(x)
g = x2 + x + 1
f(x) + g(x) = x3 + x + 1
f(x) x g(x) = x5 + x2
• Polynomial Division: f(x)
f = q(x) g(x) + r(x)
• can interpret r(x) as being a remainder
• r(x) = f(x) mod g(x)
• if no remainder, say g(x) divides f(x)
• if g(x) has no divisors other than itself & 1 say it is irreducible (or prime) polynomial
• Arithmetic modulo an irreducible polynomial form a finite field
• Can use Euclid‟s algorithm to find gcd and inverses.
Discrete Logarithm:
The inverse problem to exponential is to find the discreate logarithm of a number modulo P,
that is to find ݅
ܾ = ܽ݅ (݉) ݀
Written as
݅ = ݈݀) ݀݉( ܾܽ݃
If a is a primitive root then it always exists, otherwise it may not.
Eg. ݈݃ = ݔ3 4 ݉ ݀13 has no answer
݈݃ = ݔ2 3 ݉ ݀13 =4 by typing successive power
References