Cryptography and Network Security
Cryptography and Network Security
Security
Dr. A. M. Miyim
Federal University Dutse
Content
• The topic of cryptography and network security is very broad and involves some specific areas of mathematics such
as number theory. In this chapter, a very simple introduction to the topic is given to prepare the background for more
study. It is divided into three sections.
• ❑ The first section introduces the subject. It first describes security goals such as confidentiality, integrity, and
availability. The section shows how confidentiality is threatened by attacks such as snooping and traffic analysis. The
section then shows how integrity is threatened by attacks such as modification, masquerading, replaying, and
repudiation. The section mentions one attack that threatens availability, denial of service. This section ends with
describing the two techniques used in security: cryptography and steganography. We are going to concentrate on the
first.
• ❑ The second section discusses confidentiality. It first describes symmetric-key ciphers and explains traditional
symmetric-key ciphers such as substitution and transposition ciphers. It then moves to modern symmetric-key ciphers
and explains modern block and stream ciphers. The section then shows that denial of service is an attack to
availability.
• ❑ The third section discusses other aspects of security: message integrity, message authentication, digital signature,
entity authentication. These aspects today are part of the security system that complements confidentiality. The
section also describes the topic of key management including the distribution of keys for both symmetric-key and
asymmetric-key ciphers.
Three Security Goals: confidentiality, integrity, and
availability.
• Confidentiality
Confidentiality is probably the most common aspect of information security. We need to protect our confidential
information. An organization needs to guard against those malicious actions that endanger the confidentiality of its
information. Confidentiality not only applies to the storage of information, it also applies to the transmission of
information. When we send a piece of information to be stored in a remote computer or when we retrieve a piece of
information from a remote computer, we need to conceal it during transmission.
• Integrity
Information needs to be changed constantly. In a bank, when a customer deposits or withdraws money, the balance of her
account needs to be changed. Integrity means that changes need to be done only by authorized entities and through
authorized mechanisms. Integrity violation is not necessarily the result of a malicious act; an interruption in the system,
such as a power surge, may also create unwanted changes in some information.
• Availability
The third component of information security is availability. The information created and stored by an organization needs to
be available to authorized entities. Information is useless if it is not available. Information needs to be constantly changed,
which means it must be accessible to authorized entities. The unavailability of information is just as harmful for an
organization as the lack of confidentiality or integrity. Imagine what would happen to a bank if the customers could not
access their accounts for transactions.
Attacks
Three goals of security⎯confidentiality, integrity, and availability can be threatened by security attacks. Although
the literature uses different approaches to categorizing the attacks, we divide them into three groups related to the
security goals. Figure below shows the taxonomy.
Example:
Use the additive cipher with key = 15 to decrypt the message “WTAAD”.
Solution We apply the decryption algorithm to the plaintext character by character:
The result is “hello”. Note that the operation is in modulo 26, which means that we need to add 26 to a negative result
(for example −15 becomes 11).
Additive ciphers are vulnerable to attacks using exhaustive key searches (bruteforce attacks).
The key domain of the additive cipher is very small; there are only 26 keys.
However, one of the keys, zero, is useless (the ciphertext is the same as the plaintext). This leaves only 25 possible keys. Eve
can easily launch a brute-force attack on the ciphertext.
A better solution is to create a mapping between each plaintext character and the corresponding ciphertext character.
Alice and Bob can agree on a table showing the mapping for each character. The Figure shows an example of such a
mapping.
Polyalphabetic Ciphers
In a polyalphabetic cipher, each occurrence of a character may have a
different substitute.
The relationship of a character in the plaintext to a character in the
ciphertext is one-to-many.
For example, “a” could be enciphered as “D” at the beginning of the
text, but as “N” in the middle.
Polyalphabetic ciphers have the advantage of hiding the letter
frequency of the underlying language.
Eve cannot use single-letter frequency statistics to break the ciphertext.
To create a polyalphabetic cipher, we need to make each ciphertext character
dependent on both the corresponding plaintext character and the position of the
plaintext character in the message.
This implies that our key should be a stream of sub-keys, in which each sub-key
depends on the position of the plaintext character that uses that sub-key for
encipherment.
In other words, we need to have a key stream k = (k1, k2, k3, …) in which k i is used to
encipher the ith character in the plaintext to create the ith character in the ciphertext.
To see the position dependency of the key, let us discuss a simple polyalphabetic cipher
called the auto key cipher.
In this cipher, the key is a stream of sub-keys, in which each sub-key is used to encrypt
the corresponding character in the plaintext.
The first sub-key is a predetermined value secretly agreed upon by Alice and Bob.
The second sub-key is the value of the first plaintext character (between 0 and 25).
The third sub-key is the value of the second plaintext character and so on.
Example
Assume that Alice and Bob agreed to use an auto key cipher with initial
key value k1 = 12.
Now Alice wants to send Bob the message “Attack is today”.
Enciphering is done character by character. Each character in the
plaintext is first replaced by its integer value.
The first sub-key is added to create the first ciphertext character. The
rest of the key is created as the plaintext characters are read.
Note that the cipher is polyalphabetic because the three occurrences of
“a” in the plaintext are encrypted differently. The three occurrences of
“t” are also encrypted differently.
Plaintext: a t t a c k i s t o d a y
P’s Values: 00 19 19 00 02 10 08 18 19 14 03 00 24
Key stream: 12 00 19 19 00 02 10 08 18 19 14 03 00
C’s Values: 12 19 12 19 02 12 18 00 11 07 17 03 24
Ciphertext: M T M T C M S A L H R D Y
Transposition Ciphers
A transposition cipher does not substitute one symbol for another; instead it changes the
location of the symbols.
A symbol in the first position of the plaintext may appear in the tenth position of the ciphertext.
A symbol in the eighth position in the plaintext may appear in the first position of the ciphertext.
In other words, a transposition cipher reorders (transposes) the symbols.
Suppose Alice wants to secretly send the message “Enemy attacks tonight” to Bob.
The encryption and decryption is shown in Figure
An extra character (z) is added to the end of the message to make the number of characters a
multiple of 5.
The first table is created by Alice writing the plaintext row by row.
The columns are permuted using a key.
The ciphertext is created by reading the second table column by column.
Bob does the same three steps in the reverse order.
He writes the ciphertext column by column into the first table, permutes the columns, and then reads the
second table row by row.
Note that the same key is used for encryption and decryption, but the algorithm uses the key in reverse order.
Stream and Block Ciphers
Symmetric ciphers divided into two broad categories: stream ciphers and
block ciphers.
Stream Cipher In a stream cipher, encryption and decryption are done
one symbol (such as a character or a bit) at a time. We have a plaintext
stream, a ciphertext stream, and a key stream.
Call the plaintext stream P, the ciphertext stream C, and the key stream K.
Block Ciphers In a block cipher, a group of plaintext symbols of size m (m > 1) are encrypted together, creating
a group of ciphertext of the same size.
Based on the definition, in a block cipher, a single key is used to encrypt the whole block even if the key is made of
multiple values.
In a block cipher, a ciphertext block depends on the whole plaintext block.
Combination
In practice, blocks of plaintext are encrypted individually, but they use
a stream of keys to encrypt the whole message block by block.
In other words, the cipher is a block cipher when looking at the
individual blocks.
On the other hand, it is a stream cipher when looking at the whole
message as we consider each block as a single unit.
Each block uses a different key that may be generated before or
during the encryption process.
Modern Symmetric-Key Ciphers
The traditional symmetric-key ciphers that we have studied so far are
character-oriented ciphers.
With the advent of the computer, we need bit-oriented ciphers.
The information to be encrypted is not just text; it can also consist of numbers,
graphics, audio and video data.
It is convenient to convert these types of data into a stream of bits, to encrypt
the stream and then to send the encrypted stream.
In addition, when text is treated at the bit level, each character is replaced by 8
(or 16) bits, which means that the number of symbols becomes 8 (or 16) times
larger.
Mixing a larger number of symbols increases security.
A modern cipher can be either a block cipher or a stream cipher.
Modern Block Ciphers
A symmetric-key modern block cipher encrypts an n-bit block of plaintext or
decrypts an n-bit block of ciphertext.
The encryption or decryption algorithm uses a k-bit key.
The decryption algorithm must be the inverse of the encryption algorithm,
and both operations must use the same secret key so that Bob can retrieve
the message sent by Alice.
The figure shows the general idea of encryption and decryption in a
modern block cipher.
If the message has fewer than n bits, padding
must be added to make it an n-bit block;
if the message has more than n bits, it should be
divided into n-bit blocks and the appropriate
padding must be added to the last block if
necessary.
The common values for n are 64, 128, 256, and
512 bits.
Components of Modern Block Cipher
Modern block ciphers are substitution ciphers.
However, modern block ciphers are not designed as a single unit.
To provide an attack-resistant cipher, a modern block cipher is made
of a combination of transposition units (sometimes called P-boxes),
substitution units (sometimes called S-boxes), and exclusive-OR (XOR)
operations, as well as shifting elements, swapping elements, splitting
elements, and combining elements.
Figure below shows the components of a modern block cipher.
Components of a modern block cipher
A P-box (permutation box) parallels the traditional transposition cipher for
characters, but it transposes bits.
We can find three types of P-boxes in modern block ciphers:
straight P-boxes, expansion P-boxes and compression P-boxes.
An S-box (substitution box) can be thought of as a miniature substitution cipher,
but it substitutes bits.
Unlike the traditional substitution cipher, an S-box can have a different number
of inputs and outputs.
An important component in most block ciphers is the exclusive-OR operation, in
which the output is 0 if the two inputs are the same, and the output is 1 if the
two inputs are different.
In modern block ciphers, n exclusive-OR operations are used to combine an n-bit
data piece with an n-bit key.
An exclusive-OR operation is normally the only unit where the key is applied,
while the other components are normally based on predefined functions.
Data Encryption Standard (DES)
• As an example of a modern block cipher, let us discuss the Data
Encryption Standard (DES). The Figure shows the elements of a DES
cipher at the encryption site.
• At the encryption site, DES takes a 64-bit plaintext and creates a 64-
bit ciphertext;
• at the decryption site, DES takes a 64-bit ciphertext and creates a 64-
bit block of plaintext.
• The same 56-bit cipher key is used for both encryption and
decryption.
• The initial permutation takes a 64-bit input and permutes them
according to a predefined rule.
• The final permutation is the inverse of the initial permutation.
• These two permutations cancel the effect of each other.
• In other words, if the rounds are eliminated from the structures, the
ciphertext is the same as the plaintext.
General Structure of
DES
Rounds
DES uses 16 rounds and each round of DES is an invertible (Feistel)
transformation, as shown in the figure above.
The round takes Li−1 and Ri−1 from the previous round (or the initial
permutation box) and creates Li and Ri, which go to the next round (or
final permutation box).
Each round can have up to two cipher elements (mixer and swapper).
Each of these elements is invertible.
The swapper is obviously invertible and it swaps the left half of the
text with the right half.
The mixer is invertible because of the XOR operation with all non-
invertible elements collected inside the function f(Ri−1, Ki).
Key Generation
• The round-key generator creates sixteen 48-bit keys out of a 56-bit
cipher key.
• However, the cipher key is normally given as a 64-bit key in which 8
extra bits are the parity bits, which are dropped before the actual key-
generation process, as shown in Figure
Examples
1. We choose a random plaintext block and a random key to determine
(using a program) what the ciphertext block would be (all in
hexadecimal) as shown below.
• To check the effectiveness of DES when a single bit is changed in the input, we use
two different plaintexts with only a single bit difference (in a program).
• The two ciphertexts are completely different without even changing the key.
2. Although the two plaintext blocks differ only in the rightmost bit, the ciphertext blocks
differ in 29 bits.
DES Function • The heart of DES is the DES function.
• The DES function applies a 48-bit key to the
rightmost 32 bits (Ri−1) to produce a 32-bit
output.
• This function is made up of four sections: an
expansion P-box, a whitener (that adds a
key), a group of S-boxes and a straight P-
box, as shown.
• Since Ri−1 is a 32-bit input and Ki is a 48-bit
key, we first need to expand Ri−1 to 48 bits.
• This expansion permutation follows a
predetermined rule.
• After the expansion permutation, DES uses the XOR operation on the expanded right section and the round key.
• The S-boxes do the real mixing and the DES uses 8 S-boxes, each with a 6-bit input and a 4-bit output.
• The last operation in the DES function is a straight permutation with a 32-bit input and a 32-bit output.