Chapter Three
Chapter Three
Introduction to Cryptography
5/27/2025 1
Contents
• Introduction
Key:
• Substitution and transposition Cipher
KDC(Key Distribution Center),
RSA(Rivest-Shamir-Adleman),
• Steganography KPI(Key Performance Indicator)
5/27/2025 2
Introduction
The word “cryptography” derives from the Greek word for “secrete writing”
2. Bob wants to know that Alice is really Alice and not an impostor (authentication), because Alice gets
special prices as negotiated.
3. Alice wants to keep the order secret from her competitors; and Bob does not want other customers
to see Alice’s special prices (privacy)
4. Alice and Bob both want to be sure that crackers cannot change the price or quantity (integrity)
5. Bob wants to ensure that Alice cannot later claim that she did not place the order (non-repudiation)
5/27/2025 4
General Requirements
Cryptographic techniques can be used to satisfy the below requirements:
Authentication: The sender knows that the message is going to the intended
recipient; and the recipient knows that the message was sent by the proper sender
Privacy: The message is secret: only the sender and the intended recipient know its
contents
Integrity: The message was not modified (intentionally or accidentally) while in transit
Non-repudiation: The author of the message cannot later deny having sent the
message
5/27/2025 5
How Does It Work?
An ordinary message (the plaintext) is processed by an encryption algorithm to
produce a scrambled message (the ciphertext)
The receiver then uses a matching decryption algorithm to recover the plaintext
from the ciphertext
There would be no security if these algorithms were known to everyone.
Hence, there is an additional piece of input data called a key
The key is secret, even though many people may know the algorithms
The idea is the same as that of combination locks: Many people may use locks
with the same design, but each one chooses a different combination (i.e., a
different key)
5/27/2025 6
Two Basic Types
Secret-key (or symmetric) cryptography:
• Both encryption and decryption operations use the same key
• Secret-key systems have been around for many hundreds of years
Public-key (or asymmetric) cryptography:
• Public-key systems use different keys for the encryption and decryption operations.
• One key can be made public while the other key is kept secret (and is called private
key).
• Recent invention (dating from mid 1970s).
• Can grow more easily to worldwide scale and more easily permit unaffiliated
persons to communicate securely.
• Can be used to provide digital signatures (to be discussed more later).
5/27/2025 7
Symmetric Cryptography
Plaintext input Plaintext output
“The quick
Ciphertext “The quick
brown fox “AxCv;5bmEseTfid3) brown fox
jumps over fGsmWe#4^,sdgfMwi jumps over
the lazy r3:dkJeTsY8R\s@!q3 the lazy
dog” %” dog”
Encryption Decryption
Key: Key is the secret
piece of information
which is used for
encryption and decryption
in Cryptography. Same key Bulk Data should be
protected with
(shared secret) Symmetric Encryption
5/27/2025 8
Asymmetric Cryptography
Plaintext input Plaintext output
“The quick
Ciphertext “The quick
brown fox “Py75c%bn&*)9|fDe^ brown fox
jumps over bDFaq#xzjFr@g5=&n jumps over
the lazy mdFg$5knvMd’rkveg the lazy
dog” Ms” dog”
Encryption Decryption
Since secret-key algorithms are usually faster, it is more efficient to use a secret-key algorithm
to encrypt the actual data.
The system first generates a (random) key for the secret-key algorithm.
The system then encrypts that key using the public-key algorithm.
The receiver first decrypts the secret key using the public-key algorithm, and then decrypts the
data using that newly decrypted key.
5/27/2025 10
Main Components
There are 4 main components in the use of cryptography for any practical systems:
cryptosystems, modes, protocols, and key management
The term cryptosystems refers to the cryptographic algorithms and their characteristics.
Modes refers to how the cryptographic algorithms are initialized and used to manage
messages that are longer than a single block
Protocols refers to the ways in which cryptographic algorithms are composed and
applied to real problems (e.g., the securing of a communication channel or information
in a database)
• Very important for e-commerce because they are used for protecting content as well
as for payment systems.
Key management refers to the essential problems of creating, distributing, storing, and
updating keys
• Since modern cryptographic algorithms and protocols are very strong, key
management is attempting target for attackers
5/27/2025 11
Cryptographic Strength
One way to attack a cryptosystem is to try all possible keys to
decrypt a message (exhaustive search or brute force attack)
There must be enough possible keys to make this attack
computationally infeasible
• The Data Encryption Standard (DES) in 1977 uses 56-bit keys.
• There are 256 possible keys (or 72.1 x 1015 different keys), which seems sufficiently
large.
• Several years ago, Digital Equipment Corporation built a chip capable of 16,000,000 DES
operations per second.
• If one were to build a machine with 1000 such chips, a 56-bit key DES encrypted
message could be broken in less than 8 weeks!
5/27/2025 12
Key Length
Given a reasonably strong algorithm, how well the data is protected depends largely on
the length of the encryption key
An encrypted message must remain secret during the useful life of the information
• Financial credentials must remain secret beyond their validity period.
• Contract bids must remain secret beyond the contract award.
• Editorial material must remain secret until published.
• Confidential personal information must remain secret beyond the lifetime of the
person.
The value of the information in the encrypted message governs the resources used to
attack it
• An attacker would be foolish to spend $1 million to obtain information worth $1
thousand.
• He may spend $1 million to obtain a secret worth $2 million.
5/27/2025 13
Key Length (cont.)
Today, it is common to use 128-bit keys for symmetric algorithms, both for
communication security and for the security of data to be protected for 20
years.
5/27/2025 14
Key Updates
The longer a key has been in used, the greater the chance that it is discovered by
subterfuge (rather than by brute force attack).
It is important to note that changing a key does not increase the time that an attacker will
need to break it using brute force attack.
However, changing a key will limit the amount of information revealed if any particular
key is discovered.
Example: If the encryption key is changed every month, then only one month’s worth of
information is lost if a key is discovered.
5/27/2025 15
Secret-Key Cryptosystems (in the case of symmetric encryption)
Blowfish:
• A block cipher algorithm using variable key lengths, designed by Bruce Schneier.
• Freely available and very fast, running nearly 3 times faster than DES.
• Widely used in file encryption applications for personal computers.
• The key length is variable from 32 bits to 448 bits, making it interesting for variable
security applications.
Advanced Encryption Standard (AES):
• AES is an effort of the National Institute of Standard and Technology (NIST) to
develop and standardize a replacement for DES.
• AES uses Rijndael algorithm, which is an iterated block cipher algorithm whose block
length and key length can be independently set to 128 bits, 192 bits, or 256 bits.
• AES is a good choice for new applications, because it is standard, it is receiving
careful study by cryptographers, and it continues to resist attacks.
5/27/2025 16
Public-Key (Asymmetric) Cryptography
5/27/2025 17
Overview (cont.)
Bob and Alice communicates using public-key cryptography.
First, Bob and Alice each create a key pair (public key and private key).
Next, they publish their respective public keys in the town directory.
If Bob wants to send Alice a message, he encrypts the message using Alice’s public key.
• The ciphertext can be read only by Alice, because only Alice knows her own private key.
Alice decrypts the message using her private key, revealing the original message.
5/27/2025 18
Overview (cont.)
Authentication problem: How can Alice tell if the message is really from Bob?
Answer: Bob applies his digital signature to the message.
• Bob can do so by encrypting the message using his own private key, creating a signed
message.
• Of course, anyone can decrypt this signed message by using Bob’s public key.
• The signed message is not secret, but only Bob could have sent it, because only Bob
knows his private key.
Solution to the authentication problem:
• Bob first signs his message using his private key.
• He then encrypts this signed message using Alice’s public key.
• Then only Alice can decrypt this message.
• Once she has, she can verify (by using Bob’s public key) that Bob indeed sent the
message.
5/27/2025 19
Overview (cont.)
Another problem (security of the key directory):
• When Bob sends a message to Alice, he looks up Alice’s public key in the directory.
• Suppose someone has substituted his own public key with Alice’s public key in the directory.
• So Bob will unwittingly encrypt his message using not Alice’s public key, but the public key of someone else.
Solution: Public-key certificates
• A public key certificate is a document containing a name and the corresponding public key, signed by a
trusted certificate authority.
• Suppose the town clerk is operating as a certificate authority.
• When Alice first creates her public key, she appears in person before the clerk with a document attesting
that the public key is really hers.
• The clerk then signs the document with her private key. The resulting signed document becomes a public-
key certificate.
• Anyone can verify the clerk’s signature using the clerk’s public key.
• Once Alice has a certificate, she can place it in the directory.
• Bob then can be assured that the key he uses to send messages to Alice is really Alice’s public key.
5/27/2025 20
Overview (cont.)
The certificate authority at the top of the hierarchy is called the root, and its
public key is called the root key.
5/27/2025 21
Public-key infrastructure (PKI)
• Public-key infrastructure (PKI) is the set of hardware, software, people, policies, and procedures
needed to create, manage, store, distribute, and revoke digital certificates based on asymmetric
cryptography.
• It includes Public and Private key encryption, Digital Signature and Certificate Authority
• Its principal objective is to enable secure, convenient, and efficient acquisition of public keys.
• PKI use trusted party, called a certification authority (CA), typically accomplishes this by
issuing signed (encrypted) binary certificates that affirm the identity of the certificate subject
and bind that identity to the public key contained in the certificate.
5/27/2025 22
The RSA Algorithm
The best known public-key cryptosystem is RSA, whose algorithm is as follows:
1. Bob chooses two distinct large primes p and q and computes n = pq.
2. Bob chooses the encryption key e such that the greatest common divisor gcd(e, (p – 1)(q – 1)) = 1.
3. Bob then computes the decryption key d with
de = 1 (mod(p -1)(q – 1))
(read: de is congruent to 1 mod (p – 1)(q – 1)).
5/27/2025 23
The RSA Algorithm (cont.)
Recall the definition of congruence:
Let a, b, n be integers with n being nonzero. We say that
a = b (mod n)
(read: a is congruent to b mod n)
if (a – b) is a multiple (positive or negative) of n, that is
a = b + kn
for some integer k (positive, negative or zero).
Examples:
32 = 7 (mod 5), -12 = 37 (mod 7), 17 = 17 (mod 13)
A text message can be written as a number using some numbering scheme to number the letters. If we
number
a = 01, b = 02, c = 03, …, z = 26
then the message cat can be written as the number
m = 30120.
Proof of the algorithm (i.e., why m = cd (mod n)?) can be found in any standard cryptography text book (such
as “Introduction to Cryptography” by Wade Trappe and Lawrence C.
5/27/2025 24
Modes
When the message to be encrypted is longer than the block length of the cipher,
it is necessary to execute the algorithm several times and to combine the results
in some way.
We shall look at the Electronic Codebook (ECB) Mode and the Cipher Block
Chaining (CBC) Mode
There are also other modes such as Cipher Feedback Mode, Output Feedback
Mode etc.,
5/27/2025 25
Electronic Codebook (ECB) Mode
The encryption algorithm is Plaintext 1 Plaintext 2
applied independently to each
block of the message.
Encrypt (key) Encrypt (key)
Disadvantages:
• The same input block is always
encrypted as the same ciphertext Ciphertext 1 Ciphertext 2
block.
• An attacker can substitute blocks to
Decrypt (key) Decrypt (key)
alter part of a message (e.g.,
changing payment amount by
substituting the block where the
amount appears). Plaintext 1 Plaintext 2
5/27/2025 26
Cipher Block Chaining (CBC) Mode
Plaintext 1 Plaintext 2
IV
Each plaintext block is exclusive- + +
ORed with the preceding ciphertext
Encrypt (key) Encrypt (key)
block before the plaintext is
encrypted.
Ciphertext 1 Ciphertext 2
The process is bootstrapped using an
initialization vector (IV).
Decrypt (key) Decrypt (key)
IV
+ +
Plaintext 1 Plaintext 2
5/27/2025 27
CBC Mode (cont.)
In CBC mode, each block of plaintext is scrambled by XOR with a block of ciphertext.
Because these ciphertext blocks are different, if the same plaintext block occurs in multiple places, it will be
encrypted into different ciphertext blocks.
The IV must be random and different for each message, but it doesn’t need to be secret.
• The IV is often transmitted in the clear as the first part of the message.
CBC mode also makes the overall message more resistant to tampering.
• If an attacker switches blocks around, duplicates blocks, or substitutes old blocks in new messages, the
chaining that occurs during decryption will result in the output plaintext being gibberish.
5/27/2025 28
Protocols
A protocol is a series of steps taken to accomplish a task.
5/27/2025 29
Communications: Session Keys
A session key is a cryptographic key adopted for use for a particular message or
during a particular session of communications.
Session keys are used for two reasons:
1. To achieve greater performance:
o Usually a communications system will use a relatively low-performance public-key
cryptosystem to communicate a session key.
o The session key is then used in a high-performance secret-key cryptosystem to
encrypt the bulk volume of message data.
2. To limit the amount of data encrypted with the master key.
o Because only the session key is encrypted by the master key, the attacker cannot
exploit statistical properties of the actual message to assist in the attack on the
master key.
5/27/2025 30
Communications: Data Compression
Data compression refers to the problem of encoding a message in the minimum
amount of space.
In order to do this, data compression algorithms (e.g., ZIP and COMPRESS) exploit
statistical properties of the source file to encode the same information with fewer
bits.
In general, it is not possible to compress an encrypted message, because a good
encryption algorithm should destroy the statistical properties that a compression
algorithm can exploit.
However, it is possible to encrypt a compressed message.
Compressing a file before encrypting it may slightly improve security, because
compression algorithms reduce the redundancy that may be exploited during
cryptanalysis.
5/27/2025 31
Digital Signatures
5/27/2025 32
… cont (Digital Signature Process)
5/27/2025 33
Key Management
Key management is the tempting target for attackers (because modern
cryptographic algorithms, modes and protocols are strong).
• Key storage
• Key distribution
• Key destruction
5/27/2025 34
Key Generation
Generally, there are two methods for generating keys (by computer software):
1. User Input:
o Key generators rely on input from users.
o The letters typed are ignored, but the random variations in the inter-arrival time of keystrokes are used to
generate the key.
2. Pseudorandom:
o Unpredictable pieces of information such as the computer’s real time clock, the number of hardware
interrupts received, etc. are combined into a randomness pool.
o This pool can be used to generate keys that are sufficiently random for most purposes.
5/27/2025 35
Key Storage
During the lifetime of a key, it may be used and stored in different places, such as the
following:
In memory:
• When a key is used by a computer, it must be in memory.
• Contents of memory may be available to other software running on the same system.
• PC operating systems provide no protection.
• Multi-user operating systems prevent users from reading or writing the memory allocated to
others. However, a privileged user has access to memory of other users.
• Hence, keys in memory are only as secure as access to the machine and the password of the
system administrator.
• Good practice: zeroing out all storage used for keys as soon as they are no longer needed.
5/27/2025 36
Key Storage (cont.)
On disk:
• Cryptographic keys are usually stored in disk files, because they are too long and too random to
be entered by hand.
• Disk files containing keys are frequently stored in encrypted form. Hence, stealing the encrypted
file may not benefit the attacker.
• However, the security of all the keys in the file is only as good as that of the master key (needed
to decrypt the file), which is usually a human-sensible password.
In protected hardware:
• Commercial systems often use protected hardware devices such as cryptographic accelerators
and smart cards to store keys and to perform cryptographic operations.
• Since the key never leaves the device (which is designed to be tamper-proof), the key is physically
protected.
• However, it is still possible to rogue software to command the use of the key to decrypt or
encrypt messages
5/27/2025 37
Key Distribution
Sharing a key between two people:
• Meeting in person
• Sending the key by courier
• Using public-key cryptography
• Use a master key to encrypt session keys.
Sharing keys between more than two people:
• Using a Key Distribution Center (KDC), which is a central, trusted authority.
o KDC shares a separate master key with each member of the network and provides a session key
for any two parties that want to communicate.
• Using public-key certificates (discussed in the above):
o A certificate binds a public key to a name by having a trusted third party (the certificate
authority) sign the certificate.
o These certificates can be freely published and exchanged over open communication channels.
o Parties wanting to communicate use the public key from the certificate to encrypt a session key.
5/27/2025 38
Key Destruction
Keys should be destroyed when they are no longer needed.
Keys stored in memory: Zero out all storage used for the keys.
Keys stored on disk: Overwrite the disk multiple times with 0s and 1s,
alternating patterns and using random patterns (since it may be possible to
analyze erased magnetic media).
Keys stored on backup tapes: Destroy the tapes when they are no longer
needed.
Keys stored on paper: Burn or shred with a confetti shredder (not a strip
shredder).
5/27/2025 39
Substitution and transposition Cipher
5/27/2025 41
Steganography
5/27/2025 42
Steganography: Basics
The word steganography comes from the Greek steganos , meaning covered or
secret, and graphy , meaning writing or drawing. Therefore, steganography
literally means covered writing.
Steganography simply takes one piece of information and hides it within
another
• Computer files (images, sounds recordings, even disks) contain unused or insignificant
areas of data
• Steganography takes advantage of these areas, replacing them with information (encrypted
mail, for instance).
• The files can then be exchanged without anyone knowing what really lies inside of them
• An image of the space shuttle landing might contain a private letter to a friend.
• Rumor has it that terrorists used steganography to transmit messages to one another.
Steganography: Early Examples
?
5/27/2025 50