Cryptography, Coding Theory and Information Security
Shruti Goel
Assistant Professor
Dyal Singh College, Karnal
ABSTRACT:-
Secure communications on the Internet or web is the foundation of network security and
web security. Cryptography is the practice and study of how to hide information from
potential enemies, hackers or the public. The sender encrypts a message with a small piece
of secret information (key), and then sends the encrypted message to the receiver. The
receiver decrypts the encrypted message with a small piece of secret information (a key that
is same or different from the key used by the sender) and recovers the original message.
People who don’t have the right keys would not be able to read the message even if they
steal a copy of the decrypted version. In this paper we discussing about meaning, basic
terminology related to cryptography and how the number theory work in cryptography. Hill
cipher method and RSA algorithm of cryptography.
Keyword :- cryptography, algorithm, RSA , Number theory , Security
Cryptology
Cryptography is the process of writing using various methods (“ciphers”) to keep messages
secret.
Cryptanalysis is the science of attacking ciphers, finding weaknesses or even proving that a
cipher is secure.
Cryptology covers both; it’s the complete science of secure communication
Basic terminology/notation
• P is the plaintext. This is the original readable message (written in some standard language, like
English, French, Cantonese, Hindi, Icelandic, . . . ).
• C is the cipher text. This is the output of some encryption scheme, and is not readable by humans.
JASC: Journal of Applied Science and Computations
Volume VI, Issue V, May/2019
ISSN NO: 1076-5131
Page No:376
• E is the encryption function. We write, for example,
E(P) = C
to mean that applying the encryption process E to the plaintext P produces the cipher text C.
• D is the decryption function, i.e.
D(C) = P.
Note D(E(P)) = P and E(D(C)) = C.
• The encryption key is piece of data that allows the computation of E. Similarly we have the decryption key. These may or may not be the same. They also may not be secret, as we’ll see later
on.
• To attack a cipher is to attempt unauthorized reading of plaintext, or to attempt unauthorized transmission of cipher text.
Shift (aka Caesar) cipher
• Encode letters by numbers: A → 0, B → 1, C → 2. . . Z → 25.
• Choose a key t, which is a number between 0 and 25 (for Caesar, t was always 3).
• For each letter P, E is defined by E(P) = P + t, i.e. add t to the code for each letter to get a new letter code. If you wind up with a number over 25, loop around to the beginning (like on a clock
going past midnight). So, e.g. 25 + 3 = 2.
For example, if we take t = 17, then encrypting the plaintext
ALLOFGAULISDIVIDEDINTOTHREEPARTS
Yields the cipher text
RCCFWXRLCZJUZMZUVUZEKFKYIVVGRIJK
• Decryption is done by D(C) = C – t
How did Caesar get to rule the known Western world using this? It’s horrendously insecure.
• Variations:
◦ Affine cipher: Choose a number a and define E(P) = aP +t. Must be careful choosing a, e.g.
a = 0 not very useful.
JASC: Journal of Applied Science and Computations
Volume VI, Issue V, May/2019
ISSN NO: 1076-5131
Page No:377
◦ Digraph affine cipher: Choose numbers
a1, a2, b1, b2, t1, t2,
and then encrypt by transforming pairs of letters:
E(P1, P2) = (a1P1+b1P2+t1, a2P1+b2P2+t1).
Again the choices must be made carefully. But these schemes are still insecure, since natural
languages have statistical biases (the wheel of fortune phenomenon).
Hill Cipher
The Hill Cipher uses linear algebra to disguise frequency patterns that occur in natural
language
A. In the forward direction or encryption process we use matrix multiplication.
B. In the reverse or decryption process we use matrix inversion.
C. First, let’s learn a little about linear algebra.
MATRICE MULTIPLICATION
Key matrix GYBNQKURP = 6,24,1,13,16,10,20,17,15
= =
ACT A=0, C=2, T=19
Become the cipher text
POH P=15, O = 14, H=7
MATRIX DECRYPTION
First you take the inverse of the matrix , which is too horrible to explain. This gives you
IFKVIVVMI = 8,5,10,21,8,21,21,12,8
Using are Encrypted cipher text POH =15,14,7
= = MOD 26
6 24 1
13 16 10
20 17 15
A
0
2
19
67
222
319
15
14 26
7
MOD
8 5 10
21 8 21
21 12 8
15
14
7
260
574
539
0
2
19
JASC: Journal of Applied Science and Computations
Volume VI, Issue V, May/2019
ISSN NO: 1076-5131
Page No:378
Which gives us are message 0,2,19 or ACT
Example of 2x2 matrix
We shall encrypt the plaintext message "short example" using the keyword hill and a 2 x 2
matrix. The first step is to turn the keyword into a matrix. If the keyword was longer than
the 4 letters needed, we would only take the first 4 letters, and if it was shorter, we would
fill it up with the alphabet in order (much like a Mixed Alphabet).
The keyword written as a matrix
With the keyword in a matrix, we need to convert this into a key matrix. We do this by
converting each letter into a number by its position in the alphabet (starting at 0). So, A = 0,
B = 1, C= 2, D = 3, etc.
The key matrix (each letter of the keyword is convertd to a number)
We now split the plaintext into digraphs, and write these as column vectors. That is, in the
first column vector we write the first plaintext letter at the top, and the second letter at the
bottom. Then we move to the next column vector, where the third plaintext letter goes at
the top, and the fourth at the bottom. This continues for the whole plaintext.
The plaintext "short example" split into column vectors.
Now we must convert the plaintext column vectors in the same way that we converted the
keyword into the key matrix. Each letter is replaced by its appropriate number.
The plaintext converted into numeric column vectors.
We shall decrypt the example above, so we are using the keyword hill and our cipher text is
"APADJ TFTWLFJ". We start by writing out the keyword as a matrix and converting this into a
key matrix as for encryption. Now we must convert this to the inverse key matrix, for which
there are several steps.
H I
L L
7 8
11 11
s o t x m l
h r e a p e
18 14 19 23 12 11
7 17 4 0 15 4
JASC: Journal of Applied Science and Computations
Volume VI, Issue V, May/2019
ISSN NO: 1076-5131
Page No:379
Similarly ,we get ADJTFTWLFJ.
USE OF DETERMINANTS
The determinant is a number that relates directly to the entries of the matrix. It is found by
multiplying the top left number by the bottom right number and subtracting from this the
product of the top right number and the bottom left number. This is shown algebraically
below. Note that the notation for determinant has straight lines instead of brackets around
our matrix
Once we have found this value, we need to take the number modulo 26. Below is the way
to calculate the determinant for our example.
We now have to find the multiplicative inverse of the determinant working modulo 26. That
is, the number between 1 and 25 that gives an answer of 1 when we multiply it by the
determinant. So, in this case, we are looking for the number that we need to multiply 15 by
to get an answer of 1 modulo 26. There are algorithms to calculate this, but it is often
easiest to use trial and error to find the inverse.
dd-1
=1 mod26
If d is the determinant, then we are looking for the inverse of d.
15*X=1mod 26
The multiplicative inverse is the number we multiply 15 by to get 1 modulo 26.
15*7=105=1mod 26
This calculation gives us an answer of 1 modulo 26.
7 8 18 182 0mod 26
11 11 7 275 15
H I s A
L L h P
a bad cb
c d
7 87*11 8*11 11mod 26
11 11
JASC: Journal of Applied Science and Computations
Volume VI, Issue V, May/2019
ISSN NO: 1076-5131
Page No:380
So the multiplicative inverse of the determinant modulo 26 is 7. We shall need this number
later.
Step 2 - Find the Adjugate Matrix
The adjugate matrix is a matrix of the same size as the original. For a 2 x 2 matrix, this is
fairly straightforward as it is just moving the elements to different positions and changing a
couple of signs. That is, we swap the top left and bottom right numbers in the key matrix,
and change the sign of the the top right and bottom left numbers. Algebraically this is given
below.
Again, once we have these values we will need to take each of them modulo 26 (in
particular, we need to add 26 to the negative values to get a number between 0 and 25. For
our example we get the matrix below.
The adjugate matrix of the key matrix.
Step 3 - Multiply the Multiplicative Inverse of the Determinant by the Adjugate Matrix
To get the inverse key matrix, we now multiply the inverse determinant (that was 7 in our
case) from step 1 by each of the elements of the adjugate matrix from step 2. Then we take
each of these answers modulo 26.
Multiplying the multiplicative inverse of the determinant by the adjugate to get the inverse
key matrix. NB - note that the 165 should read 105.
That is:
If K= k-1
=
Now we have the inverse key matrix, we have to convert the cipher text into column vectors
and multiply the inverse matrix by each column vector in turn, take the results modulo 26
and convert these back into letters to get the plaintext.
a b d badj
c d c a
7 8 11 8 11 18
11 11 11 7 15 7adj
11 18 77 126 25 227* mod 26
15 7 165 49 1 23
7 8,
11 11then
25 22
1 23
JASC: Journal of Applied Science and Computations
Volume VI, Issue V, May/2019
ISSN NO: 1076-5131
Page No:381
The decryption of the first digraph.
We get back our plaintext of "short example".
Drawbacks of Hill cipher
The Linearity of the cipher is its downfall. The know Plaintext attack is where the attacker
has samples of both the Plaintext and Encrypted versions. During WWII the Germans would
give a weather forecast every day at the same time. The message would contain the word
wetter in the same location in every message. Knowing the local weather also helped guess
the other parts of the message.
The Public Key Concept
• The RSA Algorithm
• Knapsack problems
• Discrete Logarithms by ElGamal
• Error Correcting Codes by McEliece
The RSA scheme But how can it be that DA isn’t easily computable from EA? How can there be such
functions? The RSA implementation of public key cryptography is based on the following empirically
25 22 25 22 0 330 1826
1 23 1 23 15 345 7
AMOD
P
s
h
25 22 25 22 0 66 1426
1 23 1 23 3 69 17
AMOD
D
o
r
25 22 25 22 9 643 1926
1 23 1 23 19 446 4
JMOD
T
t
e
25 22 25 22 5 543 2326
1 23 1 23 19 442 0
FMOD
T
x
a
25 22 25 22 22 792 1226
1 23 1 23 11 275 15
WMOD
L
m
p
25 22 25 22 5 323 1126
1 23 1 23 9 212 4
FMOD
J
l
e
JASC: Journal of Applied Science and Computations
Volume VI, Issue V, May/2019
ISSN NO: 1076-5131
Page No:382
observed fact (here written as if it were carved in stone): Multiplying two integers is easy, but
finding a nontrivial factor of an integer is hard. In other words, integer multiplication is in practice a
“one-way function.” If a number is large, it’s essentially impossible to factor it.
Alice secretly chooses two large primes p, q. Large means each has two hundred or so digits.
• She computes N = p · q. Her encryption function EA is built out of N, so she is essentially making
known.
• Her decryption function DA, on the other hand, needs p and q to work. But knowing N isn’t enough
to figure out p and q!
Proof for the RSA Algorithm
• Bob chooses two primes p, q and compute n=p. q
• Bob chooses e with gcd(e,(p-1)(q-1))= gcd(e, ψ(n))=1
• Bob solves de≡1 (mod ψ(n))
• Bob makes (e,n) public and (p,q,d) secret
• Alice encrypts M as C≡Me (mod n)
• Bob decrypts by computing M≡ Cd (mod n)
• Cd ≡ (Me
)d ≡ Med
≡ M1+kφ(n) ≡M (mod n) by Euler’s theorem
EXAMPLE:-
p=885320963, q=238855417,
• n=p.q=211463707796206571
• Let e=9007, ∴ d=116402471153538991
• M=“cat”=30120, C=113535859035722866
• ANOTHER EXAMPLE
• n=127x193=24511, φ(n)=24192,e=1307, d=10643
• Encrypt “box” with M=21524, then
C=?
JASC: Journal of Applied Science and Computations
Volume VI, Issue V, May/2019
ISSN NO: 1076-5131
Page No:383
Encrypt the following message
Formosa means a beautiful island
REFERENCE:-
1. Liddell, Henry George; Scott, Robert; Jones, Henry Stuart; McKenzie, Roderick (1984).
A Greek-English Lexicon. Oxford University Press.
2. Rivest, Ronald L. (1990). "Cryptography". In J. Van Leeuwen. Handbook of Theoretical
Computer Science. 1. Elsevier.
3. Bellare, Mihir; Rogaway, Phillip (21 September 2005). "Introduction". Introduction to
Modern Cryptography. p. 10.
4. Menezes, A.J.; van Oorschot, P.C.; Vanstone, S.A. (1997). Handbook of Applied
Cryptography. ISBN 978-0-8493-8523-0. Archived from the original on 7 March 2005.
5. Biggs, Norman (2008). Codes: An introduction to Information Communication and
Cryptography. Springer. p. 171.
6. "Overview per country". Crypto Law Survey. February 2013. Retrieved 26 March
2015.
7. "UK Data Encryption Disclosure Law Takes Effect". PC World. 1 October 2007.
Retrieved 26 March 2015.
8. How online surveillance cracked our trust in the web". TechRepublic. Archived from
the original on 2016-06-12. Retrieved 2016-06-12.
JASC: Journal of Applied Science and Computations
Volume VI, Issue V, May/2019
ISSN NO: 1076-5131
Page No:384