You are on page 1of 4

Cryptography is the practice and study of techniques for secure communication in the presence

of third parties (called adversaries). The original message is encrypted before sending it to
receiving party who can decrypt it to obtain the original message with the use of key but the
third party listening over the unsecured network cannot obtain the original message without that
shared key. The basic idea behind encryption and decryption is that the message becomes useless
to anyone who cannot decrypt it. Depending on the type of key used, cryptography is subdivided
into two types.
1) Private key cryptography or Symmetric Cryptography
2) Public key cryptography or Asymmetric Cryptography
Private Key Cryptography: Also known as Symmetric cryptography, its the type of
cryptography that use the same cryptographic keys for both encryption of plaintext and
decryption of ciphertext. The keys may be identical or there may be a simple transformation to
go between the two keys. Examples of Symmetric Cryptography include DES, AES, and
classical cryptography such as hill cipher, block cipher etc.

Fig: Private key Cryptography


Due to the various problems faced during the key exchange of Private Key Cryptography, the
Public Key Cryptography was introduced. Asymmetric cryptography or public-key
cryptography is cryptography in which a pair of keys is used to encrypt and decrypt a message
so that it arrives securely.

Fig: Public key cryptography


Public key cryptography is widely used now-a-days due to its easiness in exchange of keys and
its strength to encrypt a certain message.
Public key encryption algorithms Requirements:
- Need Ek(.) and Dk(.) such that
1> Dk(Ek(m))=m
2> And given the public encryption key Ek(.), it should be impossible to calculate
private decryption key Dk(.)
One of the widely used public key cryptographic algorithms of today is RSA (Rivest, Shamir,
Adelson Algorithm).
RSA: Creating public/private key pair:
1>
2>
3>
4>
5>

Choose two large prime numbers p, q. (e.g., 1024 bits each)


Compute n = pq, z = (p-1)(q-1)
Choose e (with e<n) that has no common factors with z. (e, z are relatively prime).
Choose d such that ed-1 is exactly divisible by z. (in other words: ed mod z = 1 ).
Public key is (n,e). Private key is (n,d)

RSA: Encryption, decryption:


1> Given (n,e) and (n,d) as computed above. To encrypt message m, compute c=memod n
2> To decrypt received bit pattern c, compute m = cdmod n
[ m = cdmod n
= (memod n)dmod n
= m]
RSA example:

Choose p = 3 and q = 11

Compute n = p * q = 3 * 11 = 33

Compute z = (p - 1) * (q - 1) = 2 * 10 = 20

Choose e such that 1 < e < z and e and n are coprime. Let e = 7

Compute a value for d such that (d * e) % z= 1. One solution is d = 3 [(3 * 7) % 20 = 1]

Public key is (e, n) => (7, 33)

Private key is (d, n) => (3, 33)

The encryption of m = 2 is c = 27 % 33 = 29

The decryption of c = 29 is m = 293 % 33 = 2

Why is RSA Secure?


1> Suppose you know Bobs public key (n,e). How hard is it to determine d?
2> Essentially need to find factors of n without knowing the two factors p and q.
3> Fact: factoring a big number is hard.
One of the major problem faced in public key cryptographic system is the exchange of keys.
How can two parties agree on sharing some shared key more even so if its physically impossible
to meet? To solve this problem, different key exchange algorithms are in practice. DiffieHellman Algorithm is one such type of algorithm. It allows two entities to agree on shared key
but does not provide encryption.
Diffie-Hellman Algorithm:
1> p is a large prime; g is a number less than p.
p and g are made public

2> Alice and Bob each separately choose 512-bit random numbers, SA and SB.
the private keys
3> Alice and Bob compute public keys:
TA = gSA mod p ; TB = gSB mod p ;
4> Alice and Bob exchange TA and TB in the clear
5> Alice computes (TB)SA mod p
6> Bob computes (TA)SB mod p
7> shared secret:
S = (TB)SA mod p = = gSASB mod p = (TA)SB mod p
Even though Eve might sniff TB and TA, Eve cannot easily determine S.
Diffie-Hellman: Example
p = 11 and g = 5
Private keys: SA = 3 and SB = 4
Public keys:
TA = gSA mod p = 53 mod 11 = 125 mod 11 = 4
TB = gSB mod p = 54 mod 11 = 625 mod 11 = 9
Exchange public keys & compute shared secret:
(TB)SA mod p = 93 mod 11 = 729 mod 11 = 3
(TA)SB mod p = 44 mod 11 = 256 mod 11 = 3
Shared secret:
3 = symmetric key

You might also like