0% found this document useful (0 votes)
431 views21 pages

Debremarkos University School of Computing: Information Security (Chapter Two)

This document provides an overview of basics in cryptography. It discusses models for secure communication over networks, including the use of encryption algorithms, secret keys, and trusted third parties. It also covers cryptology topics like cryptanalysis, cryptographic algorithms, hash functions, and mathematical tools used in cryptography like prime numbers, modular arithmetic, and algorithms for testing primality. Internet standards and standards bodies that develop cryptography standards are also introduced.

Uploaded by

tadesse yizengaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
431 views21 pages

Debremarkos University School of Computing: Information Security (Chapter Two)

This document provides an overview of basics in cryptography. It discusses models for secure communication over networks, including the use of encryption algorithms, secret keys, and trusted third parties. It also covers cryptology topics like cryptanalysis, cryptographic algorithms, hash functions, and mathematical tools used in cryptography like prime numbers, modular arithmetic, and algorithms for testing primality. Internet standards and standards bodies that develop cryptography standards are also introduced.

Uploaded by

tadesse yizengaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Chapter2-Basics to Cryptography

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

A model for Internetwork security

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.

Figure1. Model for network security


A trusted third party may be needed to achieve secure transmission. For example, a third party
may be responsible for distributing the secret information to the two principals while keeping it

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.

Figure.2. Network Access Security Model


Viruses and worms are two examples of software attacks. Such attacks can be introduced into a
system by means of a disk that contains the unwanted logic concealed in otherwise useful software.

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

Internet Standards and RFCs

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

• Internet Society: ISOC is a professional


membership society with worldwide
organizational and individual membership. It
provides leadership in addressing issues that
confront the future of the Internet and is the
Figure 2 Figure 1 https://www.internetsociety.org/
organization home for the groups responsible
for Internet infrastructure standards, including
the Internet Engineering Task Force (IETF), the Internet Architecture Board (IAB) and
Internet Engineering Steering Group (IESG). These organizations develop Internet
standards and related specifications, all of which are published as Requests for Comments
(RFCs).
• ITU-T: The International Telecommunication Union (ITU) is an international organization
within the United Nations System in which governments and the private sector coordinate
global telecom networks and services. The ITU Telecommunication Standardization Sector
(ITU-T) is one of the three sectors of the ITU. ITU-T’s mission is the development of
technical standards covering all fields of telecommunications. ITU-T standards are referred
to as Recommendations.
• ISO: The International Organization for Standardization (ISO)7 is a worldwide federation
of national standards bodies from more than 140 countries, one from each country. ISO is
a nongovernmental organization that promotes the development of standardization and
related activities with a view to facilitating the international exchange of goods and services
and to developing cooperation in the spheres of intellectual, scientific, technological, and
economic activity. ISO’s work results in international agreements that are published as
International Standards.
The principal advantages of standards are as follows:
• It assures that there will be a large market for a particular piece of equipment or
software. This encourages mass production and resulting in lower costs.
• A standard allows products from multiple vendors to communicate, giving the
purchaser more flexibility in equipment selection and use.
The principal disadvantages of standards are as follows:
• A standard tends to freeze the technology. By the time a standard is developed, subjected
to review and compromise, and promulgated, more efficient techniques are possible.
• There are multiple standards for the same thing. There are still areas where multiple
conflicting standards exist.
The Standardization Process
The decision of which RFCs become Internet standards is made by the IESG, on the
recommendation of the IETF. To become a standard, a specification must meet the following
criteria:
• Be stable and well understood

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

Figure 3 Standardization Process

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.

The two main branches of cryptology are cryptography and cryptanalysis.

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

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:

• AES (Advanced Encryption Standard)


• DES (Data Encryption Standard)
• IDEA (International Data Encryption Algorithm)
• Blowfish (Drop-in replacement for DES or IDEA)
• RC4 (Rivest Cipher 4)
• RC5 (Rivest Cipher 5)
• RC6 (Rivest Cipher 6)

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

Figure 4. Symmetric key cryptosystem


Due to the better performance and faster speed of symmetric encryption (compared to
asymmetric), symmetric cryptography is typically used for bulk encryption / encrypting large
amounts of data, e.g. for database encryption. In the case of a database, the secret key might only
be available to the database itself to encrypt or decrypt. Some examples of where symmetric
cryptography is used are:

• Payment applications, such as card transactions where PII needs to be protected to


prevent identity theft or fraudulent charges
• Validations to confirm that the sender of a message is who he claims to be
• Random number generation or hashing

There are five main components of a symmetric encryption system:

• 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

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

Figure 4. Public key cryptosystem


Difference Between Symmetric and Asymmetric Encryption

• 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

Figure 5. Hash Function

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 a process of finding weaknesses in cryptographic algorithms and using these


weaknesses to decipher the ciphertext without knowing the secret key (instance deduction).
Sometimes the weakness is not in the cryptographic algorithm itself, but rather in how it is applied
that makes cryptanalysis successful.

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.

An attacker may have other goals as well, such as:

• Total Break - Finding the secret key.


• Global Deduction - Finding a functionally equivalent algorithm for encryption and
decryption that does not require knowledge of the secret key.
• Information Deduction - Gaining some information about plaintexts or ciphertexts that was
not previously known.
• Distinguishing Algorithm - The attacker has the ability to distinguish the output of the
encryption (ciphertext) from a random permutation of bits.

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.

What is Substitution Cipher

Substitution of single letters separately—simple substitution—can be demonstrated by writing out


the alphabet in some order to represent the substitution. This is termed a substitution alphabet. The
cipher alphabet may be shifted or reversed (creating the Caesar and Atbash ciphers, respectively)
or scrambled in a more complex fashion, in which case it is called a mixed alphabet or deranged
alphabet. Traditionally, mixed alphabets may be created by first writing out a keyword, removing
repeated letters in it rather than writing all the remaining letters in the alphabet in the usual order.

What is Transposition Cipher

DMU Page 13
Chapter2-Basics to Cryptography

In cryptography, a transposition cipher is a method of encryption in which the positions held by


units of plaintext (which are commonly characters or groups of characters) are shifted according
to a regular system so that the ciphertext constitutes a permutation of the plaintext. That is, the
order of the units is changed. Mathematically a bijective function is used on the characters'
positions to encrypt and an inverse function to decrypt.

What is Block Cipher

In cryptography, a block cipher is a deterministic algorithm operating on fixed-length groups of


bits, called blocks, with an unvarying transformation that is specified by a symmetric key. Block
ciphers are important elementary components in the design of many cryptographic protocols and
are widely used to implement encryption of bulk data.

What is Stream Cipher

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).

What is Password Cracking

In cryptanalysis and computer security, password cracking is the process of


recovering passwords from data that have been stored in or transmitted by a computer system. A
common approach is to try guesses for the password repeatedly. Another common approach is to
say that you have "forgotten" the password and then change it.

Mathematical Tools for Cryptography

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

[(11 mod 8) + (15 mod 8)] mod 8 = 10 mod 8 = 2


(11 + 15) mod 8 = 26 mod 8 = 2

[(11 mod 8) - (15 mod 8)] mod 8 = -4 mod 8 = 4


(11 - 15) mod 8 = -4 mod 8 = 4

[(11 mod 8) * (15 mod 8)] mod 8 = 21 mod 8 = 5

DMU Page 15
Chapter2-Basics to Cryptography

(11 * 15) mod 8 = 165 mod 8 = 5


Additive inverse
(x+y) mod 8=0
Multiplicative inverse
x*y mod 8 = 1

Additive modulo 8 Multiplication modulo 8

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

The theorem is sometimes written in an alternative form, true for any m,

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

4 7-1 ≡ 1 (mod p) → 46≡1 (mod 7) →4096 mod7 ≡1


Therefore, m is relatively prime to p.
Example 2:
If p is prime and m is a positive integer then m p≡ m (mod p)
Let m=3 ; p=5 then m p≡ m (mod p) → mp=35=243 ≡ 3 (mod 5) ≡ m (mod p)
243 (mod 5) ≡ 3 (mod 5)
3=3

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.

It should be clear that, for a prime number p,

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,

f(n) = f(pq) = f(p) * f(q) = (p - 1) * (q - 1)

DMU Page 17
Chapter2-Basics to Cryptography

f(21) = f(3) * f(7) = (3 - 1) * (7 - 1) = 2 * 6 = 12


where the 12 integers are {1, 2, 4, 5, 8, 10, 11, 13, 16, 17, 19, 20}.

if n is prime, because in that case, f(n) = (n - 1) and Fermat’s theorem holds.

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)

a = 2; n = 11; f(11) = 10;


a f(n) = 210 = 1024 = 1(mod 11) = 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

If we generalize this congruence as mp ≡ 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

Testing for primality

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).

Chinese remainder theorem

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.

Figure 4 Euclidean Algorithm

DMU Page 19
Chapter2-Basics to Cryptography

Find the gcd(20,12)?


Assignment 1
1. Discus the encryption algorithms where the following number theories are used.
A. Prime & relative numbers
B. Modular arithmetic
C. Fermat’s and Euler’s theorems
D. Testing for primarily
E. Chinese remainder theorem
F. Discrete logarithms
2. Discuss application areas of cryptography.
3. Solve the following using Fermat’s theorem
a. 610mod11 a p-1=1
6 11-1 mode11
=1
=[(3mod11) (3 11mod11)] mod 11
b. 312mod11
=3*3 mod 11
= 9 mod 11
=9
=[(52mod13) (5 13mod13)]mod 13
=[(25 mod 13)(5)] mod 13
c. 515mod13
=(12*5) mod 13
=60 mod 13
=8

d. 714mod13

e. 45617mod17

f. 912mod13

4.

Find inverse key for multiplicative decryption


If GCD(key,26) is 1 then inverse of a particular key exist
GCD (7,26)=1
So a key will exist

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 5 2 1 -3 4 -11 t=-3-(2*4) -11

2 2 1 0 4 -11 26 t=4-(2*-11) 26

1 0 -11 26

Therefore the inverse of t1 = -11 ?


k-1 is 26-11=15
P=(C*k) mod 26 → p=(23*15) mod 26 → 345 mod 26→7
P=7 → H

DMU Page 21

You might also like