Thursday, November 20, 2014

DES | Assymetric Key

DES Attack à man in the middle attack
Sender …DES encrypted message + key by hacker ….Receiver
IDEA àInternational Data Encryption Standard (Commercial Version)
Input   : 128 bits
Key     : 128 bits
Output: 128 bits
To get down encryption it take 8 rounds
For doing email encryption is using PGPà Pretty good privacy
RC-5 à Rivest Cipher / Smart Card
AES à Advanced Encryption Standard
Input : 128 bits or 256 bits
Key: 128 bits or 256 bits
Output : 128 bits or 256 bits
Week 4 Day 5 – ITEC Programme
AXCRYPTà Encryptionà EAS
 For Securing key exchange there is save way to do it using Diffie Hellman Key Exchange or Agreement.
Sender ------à------ Receiver
Step 1 : 1st sender & receiver agree upon two large prime numbers
Step 2 : Sender choses another large random number.
Ex : it is X
Such that sender calculate A= g x mod n
Step 3 : This A is sent to receiver
Step 4 : At the receiver end, receiver also chooses large random number that is suppose Y
And calculate B such that B= g y mod n
Step 5 : Receiver sends B to sender
Step 6 : Sender calculates the key as K1= B x mod n
Step 7 : Receiver calculates the key as K2=A y mod n so K=K1=K2

Example
Step 1 : Let n=11 g=7
Step 2 : ender chooses x  suppose x =3
Step 3 : A=g x mod n
                 =7 3 mod 11
                 = 2
Step 4 : suppose y= 6 and B =4
              B = g y mod n
                  = 7 6 mod 11
                  = 4
Step 5 : B will be sent to sender
Step 6 : Sender calculates key value
             K1 = B x mod n
                  = 4 3 mod 11
                  = 9
Step 7 : Receiver end calculate key value
             K2 = A y mod n
                  = 26 mod 11
                  = 9
            K = k 1 = k 2

Assymetric Key

Assymetric Keyà Same Key (Encryption & Decryption)
Assymetric Key à Public Key (Known to all)  and Private key (Remind private or an individual)
Public Key à Encryption, Private Key à Decryption
But if the aim is authentication
Private Key à Encryption, Public Key à Decryption
RSA Algorithm
Working of RSA
Step 1 : Change two large prime numbers , suppose P & Q
Step 2 : Calculate N= P.Q
Step 3 : Select the public key E such that it shared not be the factor of (p-1) (q-1)
Step 4 : Encryption is given by
              C= (PT) E mod n
              Where  C =Cipher text
                           PT = Plain text
                            E = Public key
                            N = P.Q
Step 5 : The private key D should be chosen by receiver such that
              (D.E) mod (P-1).(Q-1) = 1
Step 6 : Decryption
             PT = C D mod n
              D = Private key
              C = Cipher text
              PT= Plain text


Example :
Step 1 : suppose P=7 Q = 17
Step 2 : n = p. q
                = 7 . 17
                = 119
Step 3 : E such that (p-1) (q-1)
               (p-1) (q-1) = 6.16 = 96
               Suppose E= 5 bcoz 6=1,2,3,6 (6 can be devided by numbers written beside)
               And 16 (1,2,4,8,16) /prime #. So choose which is not there.
Step 4 : C=(PT) E mod N
                = (10) 5 mod 119
                = 40
Step 5 : (D.E) mod (P-1) . (Q-1) =1
              (D.5) mod 96 = 1
              To figure out D à 96 . 4 = 384 + 1 = 385 / 5 = 77
              (D.5) mod 96 = 1
              (77.5) mod 97 = 1
Step 6 : Decryption
             PT = C D mod n
                  = 40 77 mod 119

                  = 10

Wednesday, November 19, 2014

Introduction to Cryptography

History of Cryptography
•Cryptography has roots that began around 2000 B.C. in Egypt
•Encryption methods evolved from being mainly for show into practical applications used to decorate tombto tell the story of the life of the deceased. The practice was not as much to hide the messages themselves, but to make them seem more noble, ceremonial, and majestic used to hide information from others.

•A Hebrew cryptographic method required the alphabet to be flipped so that each letter in the original alphabet is mapped to a different letter in the flipped alphabet. The encryption method was called atbash. An example of an encryption key used in the atbash encryption scheme is shown in following:
    ABCDEFGHI JK LMNOPQ R STU VW XYZ
    ZYXWVUTSR QP ONMLKJ I HGF ED CBA
•Around 400 B.C., the Spartans used a system of encrypting information by writing a message on a sheet of papyrus, which was wrapped around a staff. (This would look like a piece of paper wrapped around a stick or wooden rod.) The message was only readable if it was around the correct staff, which allowed the letters to properly match
What is Cryptography
•From Greek word Kryptos + graphy which means secret writing
•Art and science of achieving security by encoding messages to make them non-readable.
Basic Of Encryption :
Plain text -> Encryption -> Cipher Text -> Decryption -> Plain Text
Conceptual cryptography is to make readable message unreadable and so the opposite.
Goals of cryptosystem
•Cryptosystems can provide confidentiality, authenticity, integrity, and nonrepudiation services. It does not provide availability of data or systems. Confidentiality means that unauthorized parties cannot access information. Authenticity refers to validating the source of the message to ensure the sender is properly identified.  Integrity provide assurance that the message was not modified during transmission, accidentally or intentionally. Nonrepudiation means that a sender cannot deny sending the message at a later date, and the receiver cannot deny receiving it.
What is Cryptanalysis?
Technique of decoding messages from non-readable format back to readable format without knowing how they were initially converted from readable format to non-readable format.
Cryptology
•Combination of Cryptography and Cryptanalysis
•Cryptography + Cryptanalysis= Cryptology
Cryptography
•Plain text
    The original message or data that is fed into the algorithm as input.
    e.g -  This is the plain text.
• Encryption Algorithm
     The algorithm which converts the plain text
     into cipher text by various transpositions and substitutions.
•Secret Key
    The Key is a value independent of the plain text. The algorithm will produce a different output depending on the specific key being used at that time.
•Cipher Text
    The scrambled message produced as the output while changing the plain text as cipher text using encryption algorithm.
•Decryption Algorithm
    It takes the cipher text and the secret key and produces the original plain text.
Requirements for Secure Use of Encryption 
There are two requirements for secure use of encryption:
•Strong Encryption Algorithm
•
•Sender and Receiver must have copies of the secret key and should keep the key secure.
Cryptographic Systems are characterized  by three independent dimensions:
•Type of operations used for transforming plaintext to ciphertext.
•The number of keys used
The way in which the plaintext is processed
•Cryptanalysis
    Cryptanalytic attacks rely on nature of the algorithm
•Brute Force Attacks --> only possible combination are checked for
•Passwords : dictionary and brute force  

DES | DATA ENCRYPTION STANDARD

DES (DATA ENCRYPTION STANDARD)

This is a symmetric key algorithm.
Input is taken à 64 bits
Key is taken à 56 bits
Output is taken à 64 bits
In case of this symmetric key algorithm, the size of the output is either equal or lesser than the size of the input. Generally the size of the output is longer than the input.
16 rounds processing to get it done.
In 1976, a Professor from Santa Clara University Edward found Simplified DES to make a symmetric more simple.
Input à 5 bits
Key à10 bits
Output à 8 bits
P10 : Permutation applied on 10 bits
 P8 : Permutation applied on 8 bits
IP : Initial Permutation
Fk : Complex function
SW : Switch function
Ip-1 : Inverse of initial Permutation
Let’s try the exercise !
10 bit keyàp10àShiftàp8àShiftàp8
10 bit key = 1010000010
Step 1 à Apply  P10 on the 10 bit key
Given p10 =  3 5 2 7 4 10 1 9 8 6
#      = 1 2 3 4 5 6 7 8 9 10
Key = 1 0 1 0 0 0 0 0 1  0
Answer P10 à 10000 01100
Step 2 : Apply left circular shift separately on second 5 bit
1 0 0 0  0         0 1 1 0 0
1 2 3 4  5         1 2 3 4 5
Start from #2  which is 0 and 3rd which is 0 (reverse) and 4th is 0  and 5 which is 0 and 1 which 1
And the result will be 00001 and the rest also start from #2 so the result is 11000
Answer Shift à 0000111000
Step 3 à Apply p8 on the output step 2
Given P8 : 6 3 7 4 8 5 10 9
#      = 1 2 3 4 5 6 7 8 9 10
Key = 0 0 0 0 1 1 1 0 0 0
Answer P8 à 1 0 1 0 0  1 0 0  (k1 Subkey)
Step 4 à Apply left cecular  by 2 bits on output of step 2
0 0 0 0 1               1 1 0 0 0
1 2 3 4 5               1 2 3 4 5
Start from #2  which is 0 and 3rd which is 0 (reverse) and 4th is 0  and 5 which is 0 and 1 which 1
And the result will be 00100 and the rest also start from #2 so the result is 00011
Answe Shift
à 00100 00011 (k2)
Step 5 à Apply p8 on output of step 4
Given p8 : 6 3 7 4 8 5 10 9
#      = 1 2 3 4 5 6 7 8 9 10
Key = 0 0 1 0 0 0 0 0 1  1
Final Cipher text à 0 1 0 0 0 0 1

Encryption
8 bits Plain text à IPà FKàSWàFKàIP à 8 bits Cipher text
Suppose : PT : 1011101
Step 1 : Initial Permutation
Given à 2 6 3 1 4 8 5 7
#      = 1 2 3 4 5 6 7 8
Key = 1 0 1 1 1 1 0 1
Answer p8 à 0 1 1 1 1 1 1 0
Step 2 : Complex function is combination of substitution and permutation.
0 1 1 1                   1 1 1 0
    L                            R
Fk (L1R) = L + F (R,SK),R)
Where + is Exclusive OR
F  is Mapping Function
R is Right side
SK is Subkey à K1
L is left side
Let’s see the result k1 and k2 in previous steps
K1 : 10100100
K2 : 01000011
Suppose output of F (1110,10100100) = 1101
L = 0111
Fk (0111,1110)=(0111+1101,1110)

XOR
0 1 1 1
1 1 0 1
1 0 1 0   à output
Fk = ( 1010,  1110)
             L         R
Step 3 à Switch function
 ( the left L is shifted to R and R is shifted to L / interchanging of L&R)
( 1010,  1110)
    R         L
Step 4 : Complec funcion
Fk (1110,1010)= (1110+F (1010,01000011),1010)
Fk(1010,01000011)= 1100
Fk(1110,1010)=(1110+1100,1010)
                       = (0010,1010)
XOR
1 1 1 0
1 1 0 0
0 0 1 0
Step 5 : Apply IP-1 to output of step 4
Geven : 4 1  3 5 7 2 8 6
#      = 1 2 3 4 5 6 7 8
Key = 0 0 1 0 1 0 1 0

Final Cipher text à 0 0 1 1 1 0 0 0

Tuesday, November 18, 2014

TRANSPOSITION


Is the position of the characters of the plaintext
1. Rail Fence Technique
In this case will be given plaintext and dept =2 or depth=3
Step 1 : Arrange the alphabets of the plain text diagonally
Step 2 : The cipher text will be read as row –wise
Ex : Dept = 2 , Given text à Come home 
C                             M                            H                             M                                                                                 
                O                             E                              O                             E                                                        
From this case, the cipher text will be C M H M     O E O E 
Depth= 3
C                                                             H                                                                                                                        
                O                             E                              O                             E                                                        
                                M                                                            M                                                         
From this case, the cipher text will be CH OEOE  MM

2. Simple Columnar

In this step will be given Plaintext (PT) and Random number of columns
Step 1 : Arrange the alphabets of the plaintext row-wise in the number of columns decided by the user
Step 2 : Specify the random order of columns.
Step 3 : Write the cipher text alphabets according to the order in step 2

Ex:
Given à Number of columns 1-6 , Plain Text à Come Home Tomorrow
1
2
3
4
5
6
C
O
M
E
H
O
M
E
T
O
M
O
R
R
O
w



So the Chiper text wil be  6,4,3,1, 2,5 oo,eow,mto,cmr,oer,hm or 6,5,4,3,2,1 its random.
In this case the Cipher text can be applied for second time so the plain text can’t be easily read.
1
2
3
4
5
6
O
O
E
O
W
M
T
O
C
M
R
O
E
R
M
H



3. One-time Pad or VERNAM CIPHER

In this case will be given PT and One-time Pad and A=0
Step 1 : Convert the alphabets of the plaintext into their corresponding numerical equivalents.
Step 2 : Convert the alphabets of the one-time pad into their corresponding numerical equivalents.
Step 3 : Add the corresponding numerical equivalents with the numerical equivalents of one-time pad.
Step 4 : Subtract 26 if  the sum is greater than 25
Ex:
PT à  H O W ARE YOU
One-time Pad à N C B T Z Q A R X
Change it into numerical code & add them each
PT
H
O
W
A
R
E
Y
O
U

7
14
22
0
17
4
24
14
20
OTP
N
C
B
T
Z
Q
A
R
X
Step 3
13
2
1
19
25
16
0
17
23
SUM
20
16
23
19
42
20
24
31
43
Step 4




26


26
26

20
16
23
19
16
20
24
5
17
Ciphtxt
U
Q
X
T
Q
U
Y
F
R

Decryption :
In this case will be given One-time pad
Step 1 : Convert the alphabets of the plaintext into their corresponding numerical equivalents.
Step 2 : Convert the alphabets of the one-time pad into their corresponding numerical equivalents.
Step 3 : Subtract one-time pad from cipher text
Step 4 : If the different is negative than add 26 to it.

CT
U
Q
X
T
Q
U
Y
F
R

20
16
23
19
16
20
24
5
17
OTP
N
C
B
T
Z
Q
A
R
X
Step 3
13
2
1
19
25
16
0
17
23
SUM
7
14
22
0
-9
4
24
-12
-6
step 4




26


26
26

7
14
22
0
17
4
24
14
20
PlainText
H
O
W
A
R
E
Y
O
U