Debremarkos University School of Computing: Information Security (Chapter Two)
Debremarkos University School of Computing: Information Security (Chapter Two)
Debremarkos University
School of Computing
Information Security (Chapter Two)
Table of Contents
Chapter 2 ....................................................................................................................................... 2
Basics to Cryptography ................................................................................................................ 2
A model for Internetwork security .............................................................................................. 2
Internet Standards and RFCs ...................................................................................................... 4
Cryptology .................................................................................................................................. 6
Cryptography .............................................................................................................................. 7
Secret key cryptography....................................................................................................... 8
Public key cryptography .................................................................................................... 10
Hash functions ..................................................................................................................... 11
Cryptanalysis............................................................................................................................. 12
Mathematical Tools for Cryptography...................................................................................... 14
Prime numbers .................................................................................................................... 15
Modular arithmetic............................................................................................................. 15
Fermat’s theorems .............................................................................................................. 16
Euler’s theorems ................................................................................................................. 17
Testing for primality ........................................................................................................... 19
Chinese remainder theorem ............................................................................................... 19
DMU Page 1
Chapter2-Basics to Cryptography
Chapter 2
Basics to Cryptography
The network security involves all tools, devices, strategies and activities which enterprises and
organizations undertake to protect their networks, data and operations. Figure 1. Shows a message
to be transferred from one party to another across some sort of Internet service. The two parties,
who are the principals in this transaction, must cooperate for the exchange to take place. A logical
information channel is established by defining a route through the Internet from source to
destination and by the cooperative use of communication protocols (e.g., TCP/IP) by the two
principals.
Security aspects come into play when it is necessary or desirable to protect the information
transmission from an opponent who may present a threat to confidentiality, authenticity, and so
on. All of the techniques for providing security have two components:
1. A security-related transformation on the information to be sent. Examples include the
encryption of the message, which scrambles the message so that it is unreadable by the
opponent, and the addition of a code based on the contents of the message, which can be
used to verify the identity of the sender.
2. Some secret information shared by the two principals and, it is hoped, unknown to the
opponent. An example is an encryption key used in conjunction with the transformation to
scramble the message before transmission and unscramble it on reception.
DMU Page 2
Chapter2-Basics to Cryptography
from any opponent. Or a third party may be needed to arbitrate disputes between the two principals
concerning the authenticity of a message transmission.
This general model shows that there are four basic tasks in designing a particular security service:
1. Design an algorithm for performing the security-related transformation. The algorithm
should be such that an opponent cannot defeat its purpose.
2. Generate the secret information to be used with the algorithm.
3. Develop methods for the distribution and sharing of the secret information.
4. Specify a protocol to be used by the two principals that makes use of the security algorithm
and the secret information to achieve a particular security service.
The first chapter concentrates on the types of security mechanisms and services that fit into the
model shown in Figure1. However, there are other security-related situations of interest that do
not neatly fit this model. A general model of these other situations is illustrated by Figure 2, which
reflects a concern for protecting an information system from unwanted access. Most readers are
familiar with the concerns caused by the existence of hackers who attempt to penetrate systems
that can be accessed over a network. The hacker can be someone who, with no malign intent,
simply gets satisfaction from breaking and entering a computer system, called this passive. The
intruder can be Active one, a disgruntled employee who wishes to do damage or a criminal who
seeks to exploit computer assets for financial gain (e.g., obtaining credit card numbers or
performing illegal money transfers).
Another type of unwanted access is the placement in a computer system of logic that exploits
vulnerabilities in the system and that can affect application programs as well as utility programs,
such as editors and compilers. Programs can present two kinds of threats:
1. Information access threats: Intercept or modify data on behalf of users who should not have
access to that data.
2. Service threats: Exploit service flaws in computers to inhibit use by legitimate users.
DMU Page 3
Chapter2-Basics to Cryptography
They can also be inserted into a system across a network; this latter mechanism is of more concern
in network security.
The security mechanisms needed to cope with unwanted access fall into two broad categories (see
Figure 2.2).
• The first category might be termed a gatekeeper function. It includes password-based
login procedures that are designed to deny access to all but authorized users and screening
logic that is designed to detect and reject worms, viruses, and other similar attacks.
• The second line of defense consists of a variety of internal controls that monitor activity
and analyze stored information in an attempt to detect the presence of unwanted intruders.
This works while one gains access, either unwanted user or unwanted software
It has long been accepted in the telecommunications industry that standards are required to govern
the physical, electrical, and procedural characteristics of communication equipment. In the past,
this view has not been embraced by the computer industry. Whereas communication equipment
vendors recognize that their equipment will generally interface to and communicate with other
vendors' equipment, computer vendors have traditionally attempted to monopolize their customers.
Computers from different vendors must communicate with each other and, with the ongoing
evolution of protocol standards; customers will no longer accept special purpose protocol
conversion software development. Standards have been developed to cover management practices
and the overall architecture of security mechanisms and services.
An Internet Standard is a normative specification of a technology or methodology applicable to
the Internet.
A Requests for Comments (RFC) is authored by engineers and computer scientists in the form
of memorandum describing methods, behaviors, research, or innovations applicable to the working
of the Internet and Internet-connected systems.
Various organizations have been involved in the development or promotion of these standards.
The most important (in the current context) of these organizations are as follows.
• National Institute of Standards and Technology: NIST is a U.S. federal agency that
deals with measurement science, standards, and
technology related to U.S. government use and
to the promotion of U.S. private-sector
innovation. Despite its national scope, NIST
Federal Information Processing Standards
(FIPS) and Special Publications (SP) have a
Figure 1https://www.nist.gov/
worldwide impact.
DMU Page 4
Chapter2-Basics to Cryptography
DMU Page 5
Chapter2-Basics to Cryptography
• Be technically competent
• Have multiple, independent, and interoperable implementations with substantial
operational experience
• Enjoy significant public support
• Be recognizably useful in some or all parts of the Internet
The white boxes in figure 3 represent temporary states, which should be occupied for the minimum
practical time. However, a document must remain a Proposed Standard for at least six months and
a Draft Standard for at least four months to allow time for review and comment. The gray boxes
represent long-term states that may be occupied for years.
For a specification to be advanced to Draft Standard status, there must be at least two independent
and interoperable implementations from which adequate operational experience has been obtained.
After significant implementation and operational experience has been obtained, a specification
may be elevated to Internet Standard. At this point, the Specification is assigned an STD number
as well as an RFC number.
Finally, when a protocol becomes obsolete, it is assigned to the Historic state.
Cryptology
Algorithms: An algorithm is basically a procedure or a formula for solving a data snooping
problem. An encryption algorithm is a set of mathematical procedure for performing encryption
on data. Through the use of such an algorithm, information is made in the cipher text and requires
DMU Page 6
Chapter2-Basics to Cryptography
the use of a key to transforming the data into its original form. This brings us to the concept of
cryptography that has long been used in information security in communication systems.
Before beginning, we define some terms. An original message is known as the plaintext, while
the coded message is called the ciphertext. The process of converting from plaintext to ciphertext
is known as enciphering or encryption; restoring the plaintext from the ciphertext is deciphering
or decryption. The many schemes used for encryption constitute the area of study known as
cryptography. Such a scheme is known as a cryptographic system or a cipher. Techniques used
for deciphering a message without any knowledge of the enciphering details fall into the area of
cryptanalysis. Cryptanalysis is what the layperson calls “breaking the code.” The areas of
cryptography and cryptanalysis together are called cryptology.
Cryptology is the science concerned with data communication and storage in secure and usually
secret form. This is the technology which is applied in implementing the Computer Security.
Cryptology is the study of Cryptosystems. Cryptosystems are the techniques for ensuring the
secrecy and/or authenticity of information.
Cryptography
Cryptography is the practice and study of techniques for secure communication in the presence
of third parties called adversaries. More generally, cryptography is about constructing and
analyzing protocols that prevent third parties or the public from reading private messages; various
aspects in information security such as data confidentiality, data integrity, authentication,
and non-repudiation are central to modern cryptography. Applications of cryptography
include electronic commerce, chip-based payment cards, digital currencies, computer passwords,
and military communications.
Cryptography prior to the modern age was effectively synonymous with encryption, the
conversion of information from a readable state to apparent nonsense. The originator of an
encrypted message shared the decoding technique needed to recover the original information only
with intended recipients, thereby precluding unwanted persons from doing the same.
DMU Page 7
Chapter2-Basics to Cryptography
There are, in general, three types of cryptographic schemes typically used to accomplish these
goals: secret key (or symmetric) cryptography, public-key (or asymmetric) cryptography, and
hash functions, each of which is described below. In all cases, the initial unencrypted data is
referred to as plaintext. It is encrypted into ciphertext, which will in turn (usually) be decrypted
into usable plaintext.
Secret key cryptography (symmetrical encryption), a single key is used for both encryption and
decryption. Also referred to as conventional encryption or single-key encryption, was the only type
of encryption in use prior to the development of public key encryption in the 1970s. Symmetrical
encryption is an old and best-known technique. It uses a secret key that can either be a number, a
word or a string of random letters, and it's applied to a message. The sender uses the key (or some
set of rules) to encrypt the plaintext and sends the ciphertext to the receiver. The receiver applies
the same key (or ruleset) to decrypt the message and recover the plaintext. Because a single key is
used for both functions, secret key cryptography is also called symmetric encryption.
Example:
With this form of cryptography, it is obvious that the key must be known to both the sender and
the receiver; that, in fact, is the secret. The biggest difficulty with this approach, of course, is the
distribution of the key.
Unfortunately, symmetric encryption does come with its own drawbacks. Its weakest point is its
aspects of key management, including:
o Key Exhaustion
o Attribution data
DMU Page 8
Chapter2-Basics to Cryptography
• Plaintext,
• Encryption algorithm,
• Secret key,
• Ciphertext, and the
• Decryption algorithm.
1. Plaintext: The term plaintext refers to the original message that's created and sent into the
encryption method. Since you're bothering to encrypt it, the plaintext most likely contains
sensitive data that should not be seen by prying eyes. This is the original intelligible message
or data that is fed into the algorithm as input. The symmetric encryption example image
shows a simple example of how symmetric encryption works.
2. Encryption Algorithm: The encryption algorithm takes the plaintext and converts it into
an unreadable format. The encryption algorithm performs various substitutions and
transformations on the plaintext. A simple example of an encryption algorithm would be
DMU Page 9
Chapter2-Basics to Cryptography
changing all Ns to a 3, or all Zs to a 1. The routine may perform several passes and changes,
called permutations, on the plaintext. Once it's encrypted, you'll need a key to unlock it.
3. Key: Think of the key as a decoder ring: the secret of the scrambled text cannot be read
without the key. The key holds the information on all the switches and substitutions made to
the original plain text. In symmetric encryption, the key is actually bundled with the
algorithm; in this sense, the decoder ring is not universal. The changes and substitutions
depend on the key, and vice versa because the sender and recipient share the key.
4. Ciphertext: The ciphertext is the text that is now scrambled and ready to be sent. It may
look like a random stream of data, and is unreadable.
5. Decryption Algorithm: In the decryption algorithm, the secret key (the decoder ring) is
applied to the ciphertext. It converts it back to plaintext, basically performing the encryption
in reverse.
Public key cryptography (asymmetrical encryption): is an asymmetric scheme that uses a pair
of keys for encryption: a public key, which encrypts data, and a corresponding private, or secret
key for decryption. You publish your public key to the world while keeping your private key secret.
Anyone with a copy of your public key can then encrypt information that only you can read. Even
people you have never met. It is computationally infeasible to deduce the private key from the
public key. Anyone who has a public key can encrypt information but cannot decrypt it. Only the
person who has the corresponding private key can decrypt the information. The primary benefit of
public key cryptography is that it allows people who have no preexisting security arrangement to
exchange messages securely. The need for sender and receiver to share secret keys via some secure
channel is eliminated; all communications involve only public keys, and no private key is ever
transmitted or shared. Asymmetric encryption is mostly used in day-to-day communication
channels, especially over the Internet. Some examples of public-key cryptosystems are Elgamal,
RSA, Diffie-Hellman, and DSA, the Digital Signature Algorithm.
DMU Page 10
Chapter2-Basics to Cryptography
• Symmetric encryption uses a single key that must be shared among the people who need to
receive the message, while asymmetrical encryption uses a pair—consisting of a public key
and a private key—to encrypt and decrypt messages when communicating.
• Symmetric encryption is an old practice, while asymmetric encryption is relatively new.
• Asymmetric encryption was brought in to fix the problem of the necessity of sharing the key
in the symmetric encryption model, removing the need to share the key by using in its stead
a pair of public-private keys.
• Asymmetric encryption eats up more time than the symmetric encryption.
Hash functions
Hash functions, also called message digests and one-way encryption, are algorithms that, in
some sense, use no key. Instead, a fixed-length hash value is computed based upon the plaintext
that makes it impossible for either the contents or length of the plaintext to be recovered. Hash
algorithms are typically used to provide a digital fingerprint of a file's contents often used to
ensure that the file has not been altered by an intruder or virus. Hash functions are also
commonly employed by many operating systems to encrypt passwords. Hash functions, then,
provide a measure of the integrity of a file.
DMU Page 11
Chapter2-Basics to Cryptography
Cryptanalysis
Cryptanalysis (from the Greek kryptós and analýein, “to loosen” or “to untie”) deals with
defeating such techniques, to recover information, or forging information that will be accepted as
authentic.
Cryptanalysis is the study of methods for obtaining the meaning of encrypted information, without
access to the secret information that is typically required to do so. This is knowing how the system
works and finding a secret key. Cryptanalysis is also referred to as codebreaking or cracking the
code. The ciphertext is generally the easiest part of a cryptosystem to obtain and, therefore, is an
important part of cryptanalysis.
DMU Page 12
Chapter2-Basics to Cryptography
The goal of the attacker performing cryptanalysis will depend on the specific needs of the attacker
in a given attack context. In most cases, if cryptanalysis is successful at all, an attacker will not be
able to go past being able to deduce some information about the plaintext. However, that may be
sufficient for an attacker, depending on the context. Depending on what information is available
and what type of cipher is being analyzed, cryptanalysts can follow one or more attack models to
crack a cipher.
Historical Ciphers
Historical pen and paper ciphers used in the past are sometimes known as classical ciphers. They
include:
• Substitution Cipher: The units of plaintext are replaced with ciphertext (Caesar cipher
and One-time pad)
• Transposition Cipher: The ciphertext is a permutation of the plaintext (Rail fence
cipher)
• Polyalphabetic substitution Cipher: a substitution cipher using multiple substitution
alphabets (Vigenère cipher and Enigma machine)
• Permutation Cipher: a transposition cipher in which the key is a permutation
Historical ciphers are not generally used as a standalone encryption solution because they are quite
easy to crack. Many of the classical ciphers can be broken using brute force or by analyzing the
only ciphertext except the one-time pad.
DMU Page 13
Chapter2-Basics to Cryptography
In cryptography, a stream cipher is a symmetric key cipher in which plaintext digits are combined
with a pseudorandom cipher digit stream (keystream). In a stream cipher, each plaintext digit is
encrypted one at a time with the corresponding digit of the keystream, to give a digit of the
ciphertext stream. An alternative name is a state cipher, as the encryption of each digit is dependent
on the current state. In practice, a digit is typically a bit and the combining operation an exclusive-
or (xor).
Modern cryptography is heavily based on mathematical theory and computer science practice;
cryptographic algorithms are designed around computational hardness assumptions, making such
algorithms hard to break in practice by any adversary. It is theoretically possible to break such a
system, but it is infeasible to do so by any known practical means. These schemes are therefore
termed computationally secure; theoretical advances, e.g., improvements in integer
DMU Page 14
Chapter2-Basics to Cryptography
factorization algorithms, and faster computing technology require these solutions to be continually
adapted. The following are the mathematical theories highly used in cryptography
Prime numbers
Prime number: Every integer is evenly divisible by itself and 1. A prime number is an integer that
is only divisible by itself and 1. Examples: 11, 13, 17, 19, 23 …
Modular arithmetic
Modular arithmetic involves division of integers with an associated remainder. Given two
integers, m and n, m mod n is defined as the remainder when m is divided by n. The integer n is
called the modulus. This is commonly written as
m mod n = r
Where r is the remainder of m/n. If r = 0, then n divides m. The term r is sometimes referred to
as the residue. Examples
4 mod 3 = 1; 21 mod 5 = 1; 20 mod 4 = 0
Two integers a and b are said to be congruent modulo n, if (a mod n) = (b mod n). This is
written as:
a ≡ b (mod n).
73 ≡ 4 (mod 23); 21 ≡ -9 (mod 10)
Modular Arithmetic
Modular arithmetic exhibits the following properties:
1. [(a mod n) + (b mod n)] mod n = (a + b) mod n
2. [(a mod n) - (b mod n)] mod n = (a - b) mod n
3. [(a mod n) * (b mod n)] mod n = (a * b) mod n
Example:
Given: 11 mod 8 = 3; 15 mod 8 = 7
DMU Page 15
Chapter2-Basics to Cryptography
Fermat’s theorems
Two theorems that play important roles in public-key cryptography are Fermat’s theorem and
Euler’s theorem. Fermat’s little theorem states that for any prime p and any positive integer m
not divisible by p then:
mp-1 ≡1 mod p
mp ≡ m mod p
Expressed in this manner, the theorem means that for any prime p if we divide mp by p and m by
p we will get the same remainder. This relationship is useful for testing numbers to see if they are
prime (it can only be used to exclude; i.e., if the remainders of the two operations are not the same,
the number is definitely not prime, but if they are it may be prime).
Example 1:
Let m=4 ; p=7
DMU Page 16
Chapter2-Basics to Cryptography
Euler’s theorems
Eular’s Theorem totient function
This function, written f(n), is defined as the number of positive integers less than n and relatively
prime to n.
By convention, f(1) = 1.
Example
Determine f(37) and f(35).
Because 37 is prime, all of the positive integers from 1 through 36 are relatively prime to 37.
Thus f(37) = 36.
To determine f(35), we list all of the positive integers less than 35 that are relatively prime to it:
1, 2, 3, 4, 6, 8, 9, 11, 12, 13, 16, 17, 18
19, 22, 23, 24, 26, 27, 29, 31, 32, 33, 34
There are 24 numbers on the list, so f(35) = 24.
f(p) = p – 1
Now suppose that we have two prime numbers p and q with p ≠ q. Then we can show that,
for n = pq,
DMU Page 17
Chapter2-Basics to Cryptography
Euler’s theorem states that for every a and n that are relatively prime:
a f(n) = 1(mod n)
Example :
a = 3; n = 10; f(10) = 4;
a f(n) = 34 = 81 = 1(mod 10) = 1(mod n)
As is the case for Fermat’s theorem, an alternative form of the theorem is also useful:
af(n)+1 = a(mod n)
Euler’s theorem says that for any two integers m and n that are relatively prime the following is
true:
mf(n) ≡ 1 mod n
We know by virtue of Euler’s theorem that there is at least one value of p that satisfies the relation
-- F(p); there may be more.
Example 2
Let m=3 and n=5 then, relative prime factors of 3 = (1,2) relative prime factors 5=(1,2,3,4)
mF(n) ≡ 1 mod n → 34≡1 (mod 5)
81≡1 (mod 5)
81 mod 5 ≡ 1 mod 5
DMU Page 18
Chapter2-Basics to Cryptography
1≡1
A primality test is an algorithm for determining whether an input number is prime. Among other
fields of mathematics, it is used for cryptography. Unlike integer factorization, primality tests do
not generally give prime factors, only stating whether the input number is prime or not.
Factorization is thought to be a computationally difficult problem, whereas primality testing is
comparatively easy (its running time is polynomial in the size of the input).
The Chinese remainder theorem is a theorem of number theory, which states that if one knows the
remainders of the Euclidean division of an integer n by several integers, then one can determine
uniquely the remainder of the division of n by the product of these integers, under the condition
that the divisors are pairwise coprime.
The theorem was first discovered in the 3rd century AD by the Chinese mathematician Sunzi
in Sunzi Suanjing. The Chinese remainder theorem is widely used for computing with large
integers, as it allows replacing a computation for which one knows a bound on the size of the result
by several similar computations on small integers.
DMU Page 19
Chapter2-Basics to Cryptography
d. 714mod13
e. 45617mod17
f. 912mod13
4.
q r1 r2 r t1 t2 t t=t1-(q*t2) T1
DMU Page 20
Chapter2-Basics to Cryptography
26 7 0 1
3 26 7 5 0 1 -3 t=0-(3*1) -3
1 7 5 2 1 -3 4 t=1-(1*-3) 4
2 2 1 0 4 -11 26 t=4-(2*-11) 26
1 0 -11 26
DMU Page 21