05 Cryptography and Data Comptression
05 Cryptography and Data Comptression
Computer Networks
Encryption + Decryption = Cryptography. 06/04/24
Need for Security
•Types:
–Cipher : cipher is a character-for-character or bit-for-bit transformation,
without regard to the linguistic structure of the message.
–Code : a code replaces one word with another word or symbol.
•We assume that the enemy, or intruder, hears and accurately copies down
the complete cipher-text.
•But, he does not know what the decryption key is and so cannot decrypt
the ciphertext easily.
•Intruder is needed to break this code.
•The art of breaking ciphers, called cryptanalysis, and the art devising them
Computer Networks 06/04/24
(cryptography) is collectively known as cryptology.
Need for Security
Sender
Receiver
Plaintext
Cipher text
Encryption
Decryption
Computer Networks 06/04/24
Categories of cryptography
In symmetric-key cryptography, the same key is used by the sender (for encryption)
and the receiver (for decryption). The key is shared.
RSA
Diffie-Hellman
Computer Networks 06/04/24
ASYMMETRIC-KEY CRYPTOGRAPHY
RSA
• RSA –Rivest–Shamir –Adelman
• Used for all, Encryption, Authentication and Digital Signing.
• Has long keys. i.e1024 bits which makes is secure.
• Key advantage: difficulty of factoring large integers.
• General Algorithm:
• Generate two large random prime numbers, pand q, equal in size such that n=pq
and φ= (p-1)(q-1).
• Compute n= pq and φ= (p-1)(q-1)
• Choose an integer ‘e’ such that 1 < e <φ gcd(e,φ) = 1.
• Compute secret exponent d, 1 < d < φsuch that ed=1(mod φ).
• The public key is (n,e) and private key (n,d). Keep secret p, q, φ.
• Note:
• ‘n’ is modulus
• ‘e’ and ‘d’ is private key for encryption and decryption respectively.
• ‘p’, ‘q’ and ‘φ’ is secret key.
06/04/24
Computer Networks
ASYMMETRIC-KEY CRYPTOGRAPHY
The resulting keys are public keys and private key are {7, 187} and {23,187}.
Example:
• Keys for a plaintext input of M = 88.
• Encryption:
• To calculate C = 887 mod 187:
• 887 mod 187 = [(884 mod 187) × (882 mod 187) × (881 mod 187)] mod 187
• 881 mod 187 = 88
• 882 mod 187 = 7744 mod 187 = 77
• 884 mod 187= 59,969,536 mod 187 = 132
• 887 mod 187 = (88 × 77 × 132) mod 187
=894,432 mod 187 = 11
• Decryption:
M =1123 mod 187:
• 11 mod 187 = [(111 mod 187) × (112 mod 187) × (114 mod 187) ×
23
187 = 88
• Limitations of RSA:
• To defeat the RSA algorithm: Use brute-force approach, i.e try
all possible private keys.
• The larger the number of bits in e and d, the more secure the
algorithm.
• Because the calculations involved (both in key generation and in
encryption/decryption) are complex, the larger the size of the
key, the slower the system will run.
Diffie-Hellman
Let us give a trivial example to make the procedure clear. Our example uses small
numbers, but note that in a real situation, the numbers are very large. Assume g = 7 and
p = 23. The steps are as follows:
Data compression is a reduction in the number of bits needed to represent data. Compressing
data can save storage capacity, Speed file transfer and decreases costs for storage hardware
and network bandwidth.
Even with very fast transmission speed of data we need to send data in short time. We need
to Compress data for this purpose.
Virtually all form od data contain redundancy i.e. it is the amount of wasted “space” used to
transmit certain data.
Data compression is the function of presentation layer in OSI reference model. Compression
is often used to maximize the use of bandwidth across a network or to optimize disk space
when saving data.
There are two general types of compression algorithms:
1. Lossless compression
2. Lossy compression
Lossless Compression
Lossless compression compresses the data in such a way that when data is decompressed it is
exactly the same as it was before compression i.e. there is no loss of data.
A lossless compression is used to compress file data such as executable code, text files, and
numeric data, because programs that process such file data cannot tolerate mistakes in the data.
Lossless compression will typically not compress file as much as lossy compression techniques
and may take more processing power to accomplish the compression.
06/04/24
Computer Networks
Data Compression
Lossless Compression Algorithms
The various algorithms used to implement lossless data compression are :
• In this method first a reference symbol is placed. Then for each symbol in the data, we
place the difference between that symbol and the reference symbol used.
•For example, using symbol A as reference symbol, the string AAABBC DDDD would be
encoded as AOOOl123333, since A is the same as reference symbol, B has a difference of
1 from the reference symbol and so on.
Lossy Compression
Lossy compression is the one that does not promise that the data received is exactly the
same as data send i.e. the data may be lost.
This is because a lossy algorithm removes information that it cannot later restore.
Lossy algorithms are used to compress still images, video and audio.
Lossy algorithms typically achieve much better compression ratios than the lossless
algorithms.
Lossy compression is the method which eliminate the While Lossless Compression does not eliminate the data which is
1.
data which is not noticeable. not noticeable.
In Lossy compression, A file does not restore or rebuilt in While in Lossless Compression, A file can be restored in its original
2.
its original form. form.
3. In Lossy compression, Data’s quality is compromised. But Lossless Compression does not compromise the data’s quality.
4. Lossy compression reduces the size of data. But Lossless Compression does not reduce the size of data.
Algorithms used in Lossy compression are: Transform Algorithms used in Lossless compression are: Run Length
5. coding, Discrete Cosine Transform, Discrete Wavelet Encoding, Lempel-Ziv-Welch, Huffman Coding, Arithmetic
Transform, fractal compression etc. encoding etc.
6. Lossy compression is used in Images, audio, video. Lossless Compression is used in Text, images, sound.
Lossless Compression has less data-holding capacity than Lossy
7. Lossy compression has more data-holding capacity.
compression technique.