Cns Unit 1 Cryptography and Network Security
Cns Unit 1 Cryptography and Network Security
INTRODUCTION:
Computer and network security is essentially a battle of wits between a culprit who tries to
find holes and the designer or administrator who tries to close them.
CRYPTOGRAPHY:
Cryptography is the art and science of making a cryptosystem that is capable of providing
information security. Cryptography deals with the actual securing of digital data. It refers to
the design of mechanisms based on mathematical algorithms that provide fundamental
information security services.
CRYPTOSYSTEM
Figure.1. Cryptosystem
Cryptosystem shown in fig.1, is th study of secure communications techniques that allow
only the sender and intended recipient of a message to view its contents. When transmitting
electronic data, the most common use of cryptography is to encrypt and decrypt email and
other plain-text messages. It reformats and transform our data, making it safer on its trip
between computers. The technology is based on the essentials of secret codes, augmented by
modern mathematics that protects our data in powerful ways.
Network Security - measures to protect data during their transmission
Internet Security - measures to protect data during their transmission over a collection of
interconnected networks
Computer Security: The protection afforded to an automated information system in order to
attain the applicable objectives of preserving the integrity, availability, and confidentiality of
information system resources (includes hardware, software, firmware, information/data, and
telecommunications).
This definition introduces three key objectives that are at the heart of computer security:
Confidentiality (C): Preserving authorized restrictions on information access and disclosure,
including means for protecting personal privacy and proprietary information. A loss of
confidentiality is the unauthorized disclosure of information.
Integrity(I): Guarding against improper information modification or destruction, including
ensuring information nonrepudiation and authenticity. A loss of integrity is the unauthorized
modification or destruction of information.
Availability (A): Ensuring timely and reliable access to and use of information. A loss of
availability is the disruption of access to or use of information or an information system.
These three concepts form what is often referred to as the CIA triad. The three concepts
embody the fundamental security objectives for both data and for information and computing
services.
Confidentiality: This term covers two related concepts:
Data1 confidentiality: Assures that private or confidential information is not made available
or disclosed to unauthorized individuals.
Privacy: Assures that individual’s control or influence what information related to them may
be collected and stored and by whom and to whom that information may be disclosed.
Integrity: This term covers two related concepts:
Data integrity: Assures that information and programs are changed only in a specified and
authorized manner.
System integrity: Assures that a system performs its intended function in an unimpaired
manner, free from deliberate or inadvertent unauthorized manipulation of the system.
Availability: Assures that systems work promptly and service is not denied to authorized
users. Although the use of the CIA triad to define security objectives is well established,
some in the security field feel that additional concepts are needed to present a complete
picture. Two of the most commonly mentioned are as follows:
Authenticity: The property of being genuine and being able to be verified and trusted;
confidence in the validity of a transmission, a message, or message originator. This means
verifying that users are who they say they are and that each input arriving at the system came
from a trusted source.
Accountability: The security goal that generates the requirement for actions of an entity to
be traced uniquely to that entity. This supports nonrepudiation, deterrence, fault isolation,
intrusion detection and prevention, and after-action recovery and legal action.
THE OSI SECURITY ARCHITECTURE:
The OSI security architecture was developed in the context of the OSI protocol architecture
by ITU-T.
ITU-T: The International Telecommunication Union (ITU) Telecommunication
Standardization Sector (ITU-T) is a United Nations sponsored agency that develops
standards, called Recommendations, relating to telecommunications and to open systems
interconnection (OSI).
Recommendation X.800, Security Architecture for OSI, defines a systematic
approach. The OSI security architecture is useful to managers as a way of organizing the task
of providing security.
The OSI security architecture focuses on security attacks, mechanisms, and services. These
can be defined
briefly as
❖ Security attack
❖ Security mechanism.
❖ Security service
threat and attack are commonly used to mean more or less the same thing. The definitions
taken from RFC 4949, Internet Security Glossary.
Threat
A potential for violation of security, which exists when there is a circumstance, capability,
action, or event that could breach security and cause harm. That is, a threat is a possible
danger that might exploit a vulnerability.
Attack
An attack on system security that derives from an intelligent threat; that is, an intelligent act
that is a deliberate attempt (especially in the sense of a method or technique) to evade
security services and violate the security policy of a system.
SECURITY ATTACK:
Any action that compromises the security of information owned by an organization. There are
four general categories of attack which are listed below.
Interruption
An asset of the system is destroyed or becomes unavailable or unusable. This is an attack on
availability.
e.g., destruction of piece of hardware, cutting of a communication line or disabling of file
management system.
Figure.2a
Interception
An unauthorized party gains access to an asset. This is an attack on confidentiality.
Unauthorized party could be a person, a program or a computer. e.g., wiretapping to capture
data in the network, illicit copying of files.
Figure. 2b
Modification
An unauthorized party not only gains access to but tampers with an asset. This is an attack on
integrity.
e.g., changing values in data file, altering a program, modifying the contents of messages being
transmitted in a network.
Figure. 2c
Fabrication
An unauthorized party inserts counterfeit objects into the system. This is an attack on
authenticity.
e.g., insertion of spurious message in a network or addition of records to a file.
Figure.2d
The attack is majorly classified into two types:
● Active attack
● Passive Attack
PASSIVE ATTACK:
Passive attacks (Fig.3) are in the nature of eavesdropping on, or monitoring of, transmissions.
The goal of the opponent is to obtain information that is being transmitted.
Figure.3
Passive attacks are of two types:
Release of message contents: A telephone conversation, an e-mail message and a transferred
file may contain sensitive or confidential information. We would like to prevent the opponent
from learning the contents of these transmissions.
Traffic analysis: If we had encryption protection in place, an opponent might still be able to
observe the pattern of the message. The opponent could determine the location and identity of
communication hosts and could observe the frequency and length of messages being
exchanged. This information might be useful in guessing the nature of communication that
was taking place.
Passive attacks are very difficult to detect because they do not involve any alteration of data.
However, it is feasible to prevent the success of these attacks.
ACTIVE ATTACKS:
These attacks involve some modification of the data stream or the creation of a false stream.
Figure.4 These
attacks can be classified in to four categories:
Masquerade – One entity pretends to be a different entity.
Replay – involves passive capture of a data unit and its subsequent transmission to produce
an unauthorized effect.
Modification of messages – Some portion of message is altered or the messages are delayed
or recorded, to produce an unauthorized effect.
SECURITY SERVICE:
A processing or communication service that enhances the security of the data processing
systems and the information transfers of an organization. The services are intended to counter
security attacks, and they make use of one or more security mechanisms to provide the
service.
X.800 defines a security service as a service that is provided by a protocol layer of
communicating open systems and that ensures adequate security of the systems or of data
transfers. X.800 divides these services into five categories
AUTHENTICATION:
The authentication service is concerned with assuring that a communication is Authentic, the
function of the authentication service is to assure the recipient that the message is from the
source that it claims to be from. In the case of an ongoing interaction, such as the connection
of a terminal to a host, two aspects are involved. Two specific authentication services are
defined in X.800:
Peer Entity Authentication
Used in association with a logical connection to provide confidence in the identity of the
entities connected.
Data Origin Authentication
In a connectionless transfer, provides assurance that the source of received data is as claimed.
ACCESS CONTROL
The prevention of unauthorized use of a resource (i.e., this service controls who can have
access to a resource, under what conditions access can occur, and what those accessing the
resource is allowed to do).
DATA CONFIDENTIALITY
The protection of data from unauthorized disclosure. Confidentiality is the protection of
transmitted data from passive attacks. With respect to the content of a data transmission,
several levels of protection can be identified.
Connection Confidentiality: The protection of all user data on a connection.
Connectionless Confidentiality: The protection of all user data in a single data block
AUTHENTICATION
The confidentiality of selected fields within the user data on a connection or in a single data
block.
Traffic Flow Confidentiality: The protection of the information that might be derived from
observation of traffic flows.
DATA INTEGRITY
The assurance that data received are exactly as sent by an authorized entity (i.e., contain no
modification, insertion, deletion, or replay).
Connection Integrity with Recovery
Provides for the integrity of all user data on a connection and detects any modification,
insertion, deletion, or replay of any data within an entire data sequence, with recovery
attempted.
Connection Integrity without Recovery: As above, but provides only detection without
recovery.
Selective-Field Connection Integrity: Provides for the integrity of selected fields within the
user data of a data block transferred over a connection and takes the form of determination of
whether the selected fields have been modified, inserted, deleted, or replayed.
Connectionless Integrity: Provides for the integrity of a single connectionless data block
and may take the form of detection of data modification. Additionally, a limited form of
replay detection may be provided.
Selective-Field Connectionless Integrity: Provides for the integrity of selected fields within
a single connectionless data block; takes the form of determination of whether the selected
fields have been modified.
NONREPUDIATION
Provides protection against denial by one of the entities involved in a communication of
having participated in all or part of the communication.
Nonrepudiation, Origin: Proof that the message was sent by the specified party.
Nonrepudiation, Destination: Proof that the message was received by the specified party.
Summary:
Data Integrity: A variety of mechanisms used to assure the integrity of a data unit or stream of
data units
Authentication Exchange: A mechanism intended to ensure the identity of an entity by
means of information exchange.
Traffic Padding: The insertion of bits into gaps in a data stream to frustrate traffic analysis
attempts.
Routing Control: Enables selection of particular physically secure routes for certain data and
allows routing changes, especially when a breach of security is suspected.
Notarization: The use of a trusted third party to assure certain properties of a data exchange.
Cryptology, on the other hand, is the study of the conversion of plain text to ciphertext and vice
versa. It is also called the study of encryption and decryption.
One major difference is that Cryptology is the parent of Cryptography.
For example: David finds an encrypted message (ciphertext) in a dead drop, but has no
idea what the message means.
For example: David finds an enemy spy's hiding place and interrupts him while he is
sending an encrypted message. The spy is silly enough to have fled, leaving both the
plaintext message and its associated ciphertext written down.
For example: David finds an enemy spy's hiding place and interrupts him while he is
sending an encrypted message. The spy is silly enough to have fled, leaving both the
plaintext message and its associated ciphertext written down.
For example: David finds an enemy spy's hiding place and interrupts him while he is
sending an encrypted message. The spy is silly enough to have fled, leaving both the
plaintext message and its associated ciphertext written down.
NETWORK SECURITY MODEL:
A model for a network security is shown in the below figure. 5
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:
Information access threats: Intercept or modify data on behalf of users who should not have
access to that data.
Service threats: Exploit service flaws in computers to inhibit use by legitimate users.
Y = EK(X)
X = DK(Y)
A source produces a message in plaintext, X = [X1, X2, …, XM] where M are the number of
letters in the message. A key of the form K = [K1, K2, …, KJ] is generated. If the key is
generated at the source, then it must be provided to the destination by means of some secure
channel. With the message X and the encryption key K as input, the encryption algorithm
forms
the cipher text Y = [Y1, Y2, …, YN]. This can be expressed as Y = EK(X)
The intended receiver, in possession of the key, is able to invert the transformation: X =
DK(Y) An opponent, observing Y but not having access to K or X, may attempt to recover X
or K or both. It is assumed that the opponent knows the encryption and decryption
algorithms. If the opponent is interested in only this particular message, then the focus of
effort is to recover X by generating a plaintext estimate. Often if the opponent is interested in
being able to read future messages as well, in which case an attempt is made to recover K by
generating an estimate.
Substitution Encryption Techniques:
Substitution encryption technique is one type of classic encryption technique, A substitution
technique is one in which the letters of plaintext are replaced by other letters or by numbers
or symbols. If the plaintext is viewed as a sequence of bits, then substitution involves
replacing plaintext bit patterns with ciphertext bit patterns.
Monoalphabetic Cipher:
● The earliest known use of a substitution cipher and the simplest was by Julius Caesar.
● The Caesar Cipher is a type of shift cipher.
● Shift Ciphers work by using the modulo operator to encrypt and decrypt messages. The
Shift Cipher has a key K, which is an integer from 0 to 25.
e.g.,K=3 Plain text: pay more mone Cipher text: SDB PRUH PRQHB
Let us assign a numerical equivalent to each letter:
● For Encrypt each plaintext letter p, substitute the cipher text letter c such that
C = E(p) = (p+3) mod 26, a shift may be any amount, so that general Caesar algorithm is
C = E (p) = (p+k) mod 26, where k takes on a value in the range 1 to 25.
So, after applying the Shift Cipher with key K=19 our message text "KHAN" gave us
2. Monoalphabetic Ciphers:
Playfair Cipher:
● The best-known multiple-letter encryption cipher is the Playfair, which treats diagrams in
the plaintext as single units and translates these units into cipher text diagrams
● The Playfair algorithm is based on the use of a 5 * 5 matrix of letters constructed
using a keyword.
Step1:
In this case, the keyword is monarchy. The matrix is constructed by filling in the letters of
the keyword (minus duplicates) from left to right and from top to bottom, and then filling in
the remainder of the matrix with the remaining letters in alphabetic order. The letters I and J
count as one letter.
Step 2:
● Repeating plaintext letters that are in the same pair are separated with a filler letter, such
as x, so that balloon would be treated as ba lx lo on.
Step 3:
● Two plaintext letters that fall in the same row of the matrix are each replaced by the
letter to the right, with the first element of the row circularly following the last.
○ For example, ar is encrypted as RM.
● Two plaintext letters that fall in the same column are each replaced by the letter
beneath, with the top element of the column circularly following the last.
○ For example, mu is encrypted as CM.
● Otherwise, each plaintext letter in a pair is replaced by the letter that lies in its own
row and the column occupied by the other plaintext letter.
○ Thus, hs becomes BP and ea becomes IM
The Playfair cipher is a great advance over simple monoalphabetic ciphers. For one thing,
whereas there are only 26 letters, there are 26 * 26 = 676 digrams, so that identification
of individual digrams is more difficult. Furthermore, the relative frequencies of individual
letters exhibit a much greater range than that of digrams, making frequency analysis
much more difficult.
For these reasons, the Playfair cipher was for a long time considered unbreakable. It was
used as the standard field system by the British Army in World War I and still enjoyed
considerable use by the U.S. Army and other Allied forces during World War II.
Hill Cipher:
● Another interesting multi letter cipher is the Hill cipher, developed by the mathematician
Lester Hill in 1929.
In hill cipher algorithm every letter (A-Z) is represented by a number moduli 26. Usually, the
simple substitution scheme is used where A = 0, B = 1, C = 2…Z = 25 in order to use 2x2 key
matrix.
Encryption
To encrypt the text using hill cipher, we need to perform the following operation.
E(K, P) = (K * P) mod 26
Where K is the key matrix and P is plain text in vector form. Matrix multiplication of K and P
generates the encrypted ciphertext.
Steps For Encryption
Step 1:
Let's say our key text (2x2) is DDCF. Convert this key using a substitution scheme into a 2x2
key matrix as shown below:
Step 2:
Now, we will convert our plain text into vector form. Since the key matrix is 2x2, the vector
must be 2x1 for matrix multiplication. (Suppose the key matrix is 3x3, a vector will be a 3x1
matrix.)
In our case, plain text is TEXT that is four letters long word; thus we can put in a 2x1 vector
and then substitute as:
Step 3:
Multiply the key matrix with each 2x1 plain text vector, and take the modulo of result (2x1
vectors) by 26. Then concatenate the results, and we get the encrypted or ciphertext as RGWL.
Decryption
To encrypt the text using hill cipher, we need to perform the following operation.
D(K, C) = (K-1 * C) mod 26
Where K is the key matrix and C is the ciphertext in vector form. Matrix multiplication of
inverse of key matrix K and ciphertext C generates the decrypted plain text.
Steps For Decryption
Step 1:
Calculate the inverse of the key matrix. First, we need to find the determinant of the key matrix
(must be between 0-25). Here the Extended Euclidean algorithm is used to get modulo
multiplicative inverse of key matrix determinant
Step 2:
Now, we multiply the 2x1 blocks of ciphertext and the inverse of the key matrix. The resultant
block after concatenation is the plain text that we have encrypted i.e., TEXT.
Vigenere cipher:
Vigenere Cipher is a method of encrypting alphabetic text. It uses a simple form of
polyalphabetic substitution. A polyalphabetic cipher is any cipher based on
substitution, using multiple substitution alphabets .The encryption of the original text
is done using the Vigenère square or Vigenère table.
• The table consists of the alphabets written out 26 times in different rows, each
alphabet shifted cyclically to the left compared to the previous alphabet,
corresponding to the 26 possible Caesar Ciphers.
• At different points in the encryption process, the cipher uses a different alphabet from
one of the rows.
• The alphabet used at each point depends on a repeating keyword
The Vigenère cipher can be expressed in the following manner. Assume a sequence of
plaintext letters P = p0, p1, p2, ,p n-1 and a key consisting of the sequence of letters K = k0,
k1, k2, , k m-1, where typically m <n. The sequence of ciphertext letters C = C0, C1, C2,
……, C n-1 is calculated as follows:
C = C0, C1, C2, …..,C n-1 = E(K, P) = E[(k0, k1, k2, ….., k m-1), (p0, p1, p2…., p n-1)]= (p0 + k0) mod
26, (p1 + k1) mod 26, ……, (p m-1 + k m-1) mod 26, (pm+ k0) mod 26, (p m+1 +
k1) mod 26, ……. , (p 2m-1 + k m-1) mod 26,…..
Thus, the first letter of the key is added to the first letter of the plaintext, mod 26, the second
letters are added, and so on through the first m letters of the plaintext. For the next m letters
of the plaintext, the key letters are repeated. This process continues until all of the plaintext
sequence is encrypted. A general equation of the encryption process is
Where E is the encipher, D is the decipher, P is the plaintext, and K is the key.
To encrypt a message, a key is needed that is as long as the message. Usually, the key is a
repeating keyword.
The strength of this cipher is that there are multiple ciphertext letters for each plaintext letter,
one for each unique letter of the keyword. Thus, the letter frequency information is obscured.
However, not all knowledge of the plaintext structure is lost.
Vernam Cipher
The ultimate defense against such a cryptanalysis is to choose a keyword that is as long as the
plaintext and has no statistical relationship to it. Such a system was introduced by an AT&T
engineer named Gilbert Vernam in 1918.
where
pi= ith binary digit of plaintext
ki= ith binary digit of key
ci= ith binary digit of ciphertext
= exclusive-or (XOR) operation
Thus, the ciphertext is generated by performing the bitwise XOR of the plaintext and the key.
Because of the properties of the XOR, decryption simply involves the same bitwise operation
STEGANOGRAPHY:
Steganography is the technique of hiding secret data within an ordinary, non-secret, file
or message in order to avoid detection; the secret data is then extracted at its
destination.
The use of steganography can be combined with encryption as an extra step for hiding
or protecting data.
Itstems from two Greek words, which are steganos, means covered
and graphia, means writing
Examples,
1. Playing an audio track backwards to reveal a secret message
2. Playing a video at a faster frame rate (FPS) to reveal a hidden image
3. Embedding a message in the red, green, or blue channel of an RGB image
4. Hiding information within a file header or metadata
5. Embedding an image or message within a photo through the addition of digital noise
• As the image depicts, both cover file(X) and secret message(M) are fed into
steganographic encoder as input.
• Steganographic Encoder function, f(X,M,K) embeds the secret message into a cover
file.
• Resulting Stego Object looks very similar to your cover file, with no visible changes.
• This completes encoding. To retrieve the secret message, Stego Object is fed into .
TRANSPOSITION TECHNIQUES:
All the techniques examined so far involve the substitution of a cipher text symbol for a
plaintext symbol. A very different kind of mapping is achieved by performing some sort of
permutation on the plaintext letters. This technique is referred to as a transposition cipher.
Rail fence is simplest of such cipher, in which the plaintext is written down as a sequence of
diagonals and then read off as a sequence of rows.
Plaintext = meet at the school house
To encipher this message with a rail fence of depth 2, we write the message as
follows:
meatecolos
etthsHohue
The encrypted message is MEATECOLOSETTHSHOHUE
Row Transposition Ciphers-A more complex scheme is to write the message in a rectangle,
row by row, and read the message off, column by column, but permute the order of the
columns. The order of columns then becomes the key of the algorithm.
e.g.,
Try yourself:
plaintext = meet at the school house
Key = 4 3 1 2 5 6 7
CT = ESOTCUEEHMHLAHSTOETO
A pure transposition cipher is easily recognized because it has the same letter frequencies as the
original plaintext. The transposition cipher can be made significantly more secure by
performing more than one stage of transposition. The result is more complex permutation that is
not easily reconstructed.
FINITE FIELDS AND NUMBER THEORY:
● Finite fields have become increasingly important in cryptography.
● A number of cryptographic algorithms rely heavily on properties of finite fields,
notably the Advanced Encryption Standard (AES) and elliptic curve cryptography.
● Other examples include the message authentication code CMAC and the authenticated
encryption scheme GCM
○ Groups, Rings, Fields, Modular arithmetic, Euclid’s algorithm
○ Finite fields Euclid’s algorithm
○ Polynomial Arithmetic
○ Prime numbers-Fermat’s and Euler’s theorem
○ Testing for primality
● Widely used in cryptography to perform large calculations
● Prime Number: a number that is divisible only by itself and 1 (e.g. 2, 3, 5, 7, 11)
● Relative Prime Number: Two integers are relatively prime (or coprime) if there is no
integer greater than one that divides them both (that is, their greatest common divisor
is one).
○ For example, 12 and 13, GCD (12,13) = 1,12 and 13 are relatively prime, but
❑ example:
❑ let a=73, b=4 and n=23
Property 3: a mod n=b and b mod n=c, b = c (mod n) sub it in a mod n then a mod n= c
mod n and a ≡ c (mod n)
Arithmetic Property: ((a mod n) + (b mod n))mod n= (a+b) mod n [same for -,*,/]
Commutative Property: (a+b) mod n = (b+a) mod n [same for *]
Associative Property: ((a + b)+c) mod n = (a+(b + c)) mod n
Identity Property: (0+a) mod n = a mod n, (1 * a) mod n = a mod n
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
Thus, the rules for ordinary arithmetic involving addition, subtraction, and
multiplication carry over into modular arithmetic. The following table below provides
an illustration of modular addition and multiplication modulo 8
Both matrices are symmetric about the main diagonal in conformance to the
commutative property of addition and multiplication.
As in ordinary addition, there is an additive inverse, or negative, to each integer in modular
arithmetic.
In this case, the negative of an integer x is the integer y such that (x + y) mod 8 = 0.
To find the additive inverse of an integer in the left-hand column, scan across the
corresponding row of the matrix to find the value 0; the integer at the top of that column is
the additive inverse; thus, (2 + 6) mod 8 = 0. Similarly, the entries in the multiplication table
are straightforward.
Euler’s Theorem
Euler‟s theorem states that for every a and n that are relatively prime:
FINITE FIELDS
Groups, Rings and Field:
Group: A set of elements that is closed with respect to some operation.
Closed-> The result of the operation is also in the set
The operation obeys:
Obeys associative law: (a.b).c = a.(b.c)
Has identity e: e.a = a.e = a
Has inverses a-1: a.a-1 = e
Abelian Group: The operation is commutative
a.b = b.a
Example: Z8, + modular addition, identity =0
Cyclic Group
Exponentiation: Repeated application of operator
example: a3 = a.a.a
Cyclic Group: Every element is a power of some fixed element, i.e., b = ak
for some a and every b in group a is said to be a generator of the group
Example: {1, 2, 4, 8} with mod 12 multiplication, the generator is 2.
20=1, 21=2, 22=4, 23=8, 24=4, 25=8
Ring:
A group with two operations: addition and multiplication
The group is abelian with respect to addition: a+b=b+a
Multiplication and additions are both associative:
a+(b+c)=(a+b)+c
a.(b.c)=(a.b).c
Multiplication distributes over addition, a.(b+c)=a.b+a.c
Finite Field
In mathematics, a finite field is a field that contains a finite number of
elements. In other words, a finite field is a finite set on which the four basic
operations – addition, subtraction, multiplication and division (excluding
division by zero) – are defined and satisfy the field axioms/rules of the
arithmetic. Finite fields are an important area of mathematics and computer
science and are widely used in geometry, finite geometry, algebraic
geometry, number theory, coding theory and cryptography.
Recall that the Greatest Common Divisor (GCD) of two integers A and B is the largest integer
that divides both A and B .
The Euclidean Algorithm is a technique for quickly finding the GCD of two integers.
The Algorithm
The Euclidean Algorithm for finding GCD(A,B) is as follows:
Example:
● A=270, B=192
● A ≠0
● B ≠0
● Use long division to find that 270/192 = 1 with a remainder of 78. We can write this as:
270 = 192 * 1 +78
● Find GCD(192,78), since GCD(270,192)=GCD(192,78)
A=192, B=78
● A ≠0
● B ≠0
● Use long division to find that 192/78 = 2 with a remainder of 36. We can write this as:
● 192 = 78 * 2 + 36
● Find GCD(78,36), since GCD(192,78)=GCD(78,36)
A=78, B=36
● A ≠0
● B ≠0
● Use long division to find that 78/36 = 2 with a remainder of 6. We can write this as:
● 78 = 36 * 2 + 6
● Find GCD(36,6), since GCD(78,36)=GCD(36,6)
A=36, B=6
● A ≠0
● B ≠0
● Use long division to find that 36/6 = 6 with a remainder of 0. We can write this as:
● 36 = 6 * 6 + 0
● Find GCD(6,0), since GCD(36,6)=GCD(6,0)
A=6, B=0
● A ≠0
● B =0, GCD(6,0)=6
So we have shown:
GCD(270,192) = 6
References