Computer-Security
Computer-Security
By
1.1 Definitions
Computer Security - generic name for the collection of tools designed to protect data
and to thwart hackers.
Information systems security is the ability to provide the services required by the user
community while simultaneously preventing unauthorized use of system resources
Internet Security - measures to protect data during their transmission over a collection
of interconnected networks
• security attack
• security service
• security mechanism
Security Attack
information security is about how to prevent attacks, or failing that, to detect attacks on
information-based systems
have a wide range of attacks and can focus of generic types of attacks
• passive
• active
Passive Attacks
1
2 | Data Security Concepts
Active Attacks
Examples of Confidentiality
|3
Data integrity: assures that information and programs are changed only in a specified
and authorized manner
System integrity: Assures that a system performs its operations in unimpaired manner
Examples of Integrity
3. Availability: - assures that the resources that need to be accessed are accessible to
authorized parties in the ways they are needed. Availability is a natural result of the
other two concepts (confidentiality and integrity).
Examples of Availability
4. Authentication is the process by which the information system assures that you are
who you say you are; how you prove your identity is authentic. Methods of performing
authentication are:
1. User ID and passwords. The system compares the given password with a
stored password. If the two passwords match then the user is authentic.
4 | Data Security Concepts
2. Swipe card, which has a magnetic strip embedded, which would already
contain your details, so that no physical data entry takes place or just a PIN is
entered.
3. Digital certificate, an encrypted piece of data which contains information
about its owner, creator, generation and expiration dates, and other data to
uniquely identify a user.
4. key fob, small electronic devices which generate a new random password
synchronized to the main computer
5. Biometrics - retinal scanners and fingerprint readers. Parts of the body are
considered unique enough to allow authentication to computer systems based
on their properties.
Cryptanalysis is the art of breaking ciphers, i.e. retrieving the plaintext without
knowing the proper key.
Encryption Key. It is a value that is known to the sender. The sender inputs the
encryption key into the encryption algorithm along with the plaintext in order to
compute the ciphertext.
Decryption Key. It is a value that is known to the receiver. The decryption key is
related to the encryption key, but is not always identical to it. The receiver inputs the
decryption key into the decryption algorithm along with the ciphertext in order to
compute the plaintext.
For a given cryptosystem, a collection of all possible decryption keys is called a key
space
Some cryptographic methods rely on the secrecy of the algorithms. Keyless Cipher is a
cipher that does not require the use of a key.
6 | Data Security Concepts
All modern algorithms use a key to control encryption and decryption; a message can
be decrypted only if the key matches the encryption key.
The key used for decryption can be different from the encryption key, but for most
algorithms they are the same.
• Symmetric algorithms use the same key for encryption and decryption (or the
decryption key is easily derived from the encryption key)
• two main types:
o stream ciphers – operate on individual characters of the plaintext
o block ciphers – process the plaintext in larger blocks of characters
algorithms use a different key for encryption and decryption, and the decryption key
cannot be derived from the encryption key.
permit the encryption key to be public (it can even be published in a newspaper),
allowing anyone to encrypt with the key, whereas only the proper recipient (who knows
the decryption key) can decrypt the message. The encryption key is also called the
public key and the decryption key the private key or secret key.
There are many cryptanalytic techniques. Some of the more important ones for a system
implementer are
several important cryptosystems make use of modular arithmetic. This is when the
answer to a calculation is always in the range 0 – m where m is the modulus.
𝑎 𝑚𝑜𝑑 𝑛 = 𝑟
𝑎 𝑑𝑖𝑣 𝑛 = 𝑞
𝑎 = 𝑞𝑛 + 𝑟
𝑟 = 𝑎– 𝑞 ∗ 𝑛
Example :- if a=13 and n=5, find q and r.
𝑞 = 13 𝑑𝑖𝑣 5 = 2 𝑎𝑛𝑑 𝑟 = 13 − 2 ∗ 5 = 3 which is equivalent to
(13 𝑚𝑜𝑑 5 )
Example :- find (−13 𝑚𝑜𝑑 5).
This can be found by find the number (b) where 5 ∗ 𝑏 > 13 then let 𝑏 = 3 and
5 ∗ 3 = 15 which is less than 13 so
−13 𝑚𝑜𝑑 5 = 5 ∗ 3 − 13 = 2
Properties of Congruences.
Examples 4 ≡ 9 ≡ 14 ≡ 19 ≡ −1 ≡ −6 𝑚𝑜𝑑 5
73 ≡ 4(𝑚𝑜𝑑 23)
9
10 | M a t h e m a t i c
Examples
11 𝑚𝑜𝑑 8 = 3; 15 𝑚𝑜𝑑 8 = 7
[(11 𝑚𝑜𝑑 8 ) + (15 𝑚𝑜𝑑 8)] 𝑚𝑜𝑑 8 = 10 𝑚𝑜𝑑 8 = 2
(11 + 15) 𝑚𝑜𝑑 8 = 26 𝑚𝑜𝑑 8 = 2
[(11 𝑚𝑜𝑑 8 ) − (15 𝑚𝑜𝑑 8)] 𝑚𝑜𝑑 8 = −4 𝑚𝑜𝑑 8 = 4
(11 − 15) 𝑚𝑜𝑑 8 = −4 𝑚𝑜𝑑 8 = 4
[(11 𝑚𝑜𝑑 8 ) × (15 𝑚𝑜𝑑 8)] 𝑚𝑜𝑑 8 = 21 𝑚𝑜𝑑 8 = 5
(11 × 15) 𝑚𝑜𝑑 8 = 165 𝑚𝑜𝑑 8 = 5
Exponentiation is done by repeated multiplication, as in ordinary arithmetic.
Example
To find (117 𝑚𝑜𝑑 13)do the followings
112 = 121 ≡ 4(𝑚𝑜𝑑13)
(114 (112 ))2 = 42 ≡ 3(𝑚𝑜𝑑13)
117 = 11 × 4 × 3 ≡ 132 ≡ 2(𝑚𝑜𝑑13)
Let a and b be two non-zero integers. The greatest common divisor of a and b,
denoted gcd(a,b) is the largest of all common divisors of a and b.
When gcd(a,b) = 1, we say that a and b are relatively prime.
It can be calculated using the following equation: -
𝑮CD(a,b)=𝑮CD(b,a mod b)
Example :- find the GCD(72,48).
GCD(89,25)=GCD(25, 89 mod 25)= GCD(25, 14)
GCD(25, 14)=GCD(14, 25 mod 14)= GCD(14,11)
GCD(14,11)=GCD(11, 14 mod 11)= GCD(11,3)
GCD(11,3)=GCD(3, 11 mod 3)=GCD(3, 2)
GCD(3,2)=GCD(2, 3 mod 2)=GCD(2,1)
GCD(2,1)=GCD(1, 2 mod 1)=GCD(1,0) so the GCD(89,25)=1
Example 2: GCD (93, 36)
GCD (93, 36) = GCD (36, 93 mod 36 ) = GCD (36,21)
GCD (36, 21) = GCD (21, 36 mod 21 ) = GCD (21,15)
GCD (21, 15) = GCD (15, 21 mod 15 ) = GCD (15,6)
GCD (15, 6) = GCD (6, 15 mod 6 ) = GCD (6,3)
GCD (6, 3) = GCD (3, 6 mod 3 ) = GCD (3,0)
The least common multiple of the positive integers a and b is the smallest
positive integer that is divisible by both a and b.
The least common multiple of a and b is denoted by LCM(a, b).
•It can be calculated using the following equation: -
𝑳𝑪𝑴(a, b)=𝒂 ∗𝒃 / 𝑮CD(a, b)
Example :- find the LCM(354,144).
| 11
In Zn, two numbers a and b are the multiplicative inverse of each other if The extended
Euclidean algorithm finds the multiplicative inverses of b in Zn when n and b are given
and gcd (n, b) = 1 as shown in this figure:
The GCD(26,11)must be 1 in order to find the inverse. By using the extended Euclidean
algorithm, we can use this table the inverse of 11 is -7 mod 26=19.
•Or we can find the inverse based on using the equation 𝑛=𝑞𝑛+𝑟
12 | M a t h e m a t i c
26=11*2+4
11=4*2+3
4=3*1+1
3=3*1+0
1=4-(3*1)
1=4-(11-(4*2))
1=4-11+4*2
1=3*4-11
1=3*(26-11*2)-11
1=3*26-6*11-11= 3*26-7*11 so the multiplicative inverse of 11 is -7
100=23*4+8
23=8*2+7
8=7*1+1
7=1*7+0
1=8-(7*1)
1=8-(23-8*2)
1=8-23+8*2
1=3*8-23
1=3*(100-23*4)-23=3*100-12*23-23=3*100-13*23
Transposition (or permutation) cipher: Transposition cipher keeps the letters the same,
but rearranges their order according to a specific algorithm.
Substitution cipher: replacing each element of the plaintext with another element.
Transposition cipher
Simple transposition ciphers, which were used in the past, are keyless. A good example
of a keyless cipher using the first method is the rail fence cipher. The ciphertext is
created reading the pattern row by row. For example, to send the message (Meet me at
the park) to Bob, Alice writes
• Write the message in rows of a fixed length, and then read out again column
by column.
• The columns are chosen in some scrambled order.
• Both the length of the rows and the permutation of the columns are usually
defined by a key.
13
14 | C l a s s i c a l S y m m e t r i c C i p h e r
Example: Let the plaintext is (WE ARE DISCOVERED FLEE AT ONCE) the key
word be: ZEBRA.
The ciphertext:
• It is simple substitution
• involves replacing each letter in the message with another letter of the alphabet.
| 15
Additive Cipher
Example
Use the additive cipher with key = 15 to encrypt the plain text (hello).
Plaintext h e l l o
7 4 11 11 14
Encryption
Ciphertext WTAAD
Ciphertext W T A A D
22 19 0 0 3
Decryption
(0 − 15)𝑚𝑜𝑑 26 = 11 → 𝑙, (3 − 15)𝑚𝑜𝑑 26 = 14 → 0
Ciphertext h e l l o
Caesar Cipher Named for Julious Caesar. Caesar used a key of 3 for his
communications.
Plaintext A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Ciphertext d e f g h i j k l m n o p q r s t u v w x y z a b c
Example: Eve has intercepted the ciphertext (UVACLYFZLJBYL). Show how she can
use a brute-force attack to break the cipher.
Eve tries keys from 1 to 7. With a key of 7, the plaintext is (not very secure),
• E
• T
• A, O, R, N , I
• H , C , D , L, M
• .
• .
• X , J ,Z , Q
Example : - Eve has intercepted the following ciphertext. Using a statistical attack,
find the plaintext.
When Eve tabulates the frequency of letters in this ciphertext, she gets:
So we will replace each character with the corresponding high frequency in plaintext
as shown: -
Multiplicative cipher
The key domain for any multiplicative cipher which must be in Z26*, is the set
that has only 12 members: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25.(why)
• The affine cipher uses a pair of keys in which the first key is from Z26* and the
second is from Z26. The size of the key domain is 26 × 12 = 312.
• The additive cipher is a special case of an affine cipher in which k1 = 1. The
multiplicative cipher is a special case of affine cipher in which k2 = 0.
20 | C l a s s i c a l S y m m e t r i c C i p h e r
Example: - Use an affine cipher to encrypt the message “hello” with the key pair (7, 2).
To decrypt the message “ZEBBW” with the key pair (7, 2) in modulus 26. where where
the multiplication inverse of 7 is 15
Assume that Alice and Bob agreed to use an autokey cipher with initial key value
k1 = 12. Now Alice wants to send Bob the message “Attack is today”. Enciphering is
done character by character as shown :-
| 21
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
Encrypting and Decrypting
Solution:
SH EW EN TT OT HE ST OR E
But, we are not allowed to encipher any double letters. So, in this case, we will insert
an Q into the plaintext. (If Q is a double letter, then insert another infrequent letter, say
X.)
SH EW EN TQ TO TH ES TO RE
P R O B L
E M S A C
D F G H I/J
K N Q T U
V W X Y Z
To encipher pairs of letters, adhere to the following rules:
1.If the two letters are on the same row of the chart, like "ES", then replace each letter
by the letter to the right. (If necessary, wrap around to the left end of the row. So "ES"
encrypts to "MA".
2. If the two letters are on the same column of the chart, like, "TH", then replace each
letter by the letter below it. (If necessary, wrap around to the top end of the column.)
So "TH" encrypts to "YT".
3. If two letters are on a different row and column, like, "SH", then replace each letter
by another letter on its same row, but in the column of the other letter. So "SH" encrypts
to "AG".
Plaintext : SH EW EN TQ TO TH ES TO RE
Ciphertext: AG MV MK UT QB YT MA QB PM
To decipher, ignore rule 1. In rules 2 and 3 shift up and left instead of down and right.
Rule 4 remains the same. Once you are done, drop any extra Xs that don't make sense
in the final message and locate any missing Qs or any Is that should be Js.
Vigenere Cipher
We can encrypt the message “She is listening” using the 6-character keyword
“PASCAL” (15, 0, 18, 2, 0, 11).
| 23
• First, you need to assign two numbers to each letter in the alphabet and also
assign numbers to space, . , and ? or !.
• The key space is the set of all invertible matrices over Z26. 26 was chosen
because there are 26 characters, which solves some problems later on.
The key matrix in the Hill cipher needs to have a multiplicative inverse.
24 | C l a s s i c a l S y m m e t r i c C i p h e r
For example, the plaintext “code is ready” can make a 3 × 4 matrix when adding extra
bogus character “z” to the last block and removing the spaces. The ciphertext is
“OHKNIHGKLISS”.
𝒂 𝒃 −𝟏 𝟏 𝒅 −𝒃 𝟏 𝒅 −𝒃
𝑴−𝟏 = [ ] = [ ]= [ ]
𝒄 𝒅 𝒅𝒆𝒕(𝑴) −𝒄 𝒂 𝒂𝒅 − 𝒃𝒄 −𝒄 𝒂
A 1 2 5 7 9 11 15 17 19 21 23 25
-1
A 1 9 21 15 3 19 7 23 11 5 17 25
26 | C l a s s i c a l S y m m e t r i c C i p h e r
HELLO WORLD
| 27
3 10 20
𝐾𝑒𝑦 = [20 9 17]
9 4 17
Encryption
𝐴 𝑇 𝑇 0 19 19
𝐴 𝐶 𝐾 0 2 10
𝐼 𝑆 𝑇 = 8 18 19
𝑂 𝑁 𝐼 14 13 8
[𝐺 𝐻 𝑇 ] [ 6 7 19]
Encryption
0 19 19
0 2 10 3 10 20
8 18 19 × [20 9 17] 𝑚𝑜𝑑 26
14 13 8 9 4 17
[6 7 19]
551 247 646 5 13 22
130 58 204 0 6 22
555 318 789 𝑚𝑜𝑑 26 = 9 6 9
374 289 638 10 3 13
[329 199 562] [17 17 16]
𝐴 𝑇 𝑇 𝐹 𝑁 𝑊
𝐴 𝐶 𝐾 𝐴 𝐺 𝑊
𝐼 𝑆 𝑇 ==> 𝐽 𝐺 𝐽
𝑂 𝑁 𝐼 𝐾 𝐷 𝑁
[𝐺 𝐻 𝑇 ] [𝑅 𝑅 𝑄]
Adj (key)
28 | C l a s s i c a l S y m m e t r i c C i p h e r
Decryption
3 10 20
𝐾𝑒𝑦 = [20 9 17]
9 4 17
Step 1: Find Determinant of Key
Exercise
3.4.4 One-Time Pad
The one-time pad, which is a provably secure cryptosystem, was developed by Gilbert
Vernam in 1918.The message is represented as a binary string (a sequence of 0’s and
1’s using a coding mechanism such as ASCII coding.
The key is a truly random sequence of 0’s and 1’s of the same length as the message.
The encryption is done by adding the key to the message modulo 2, bit by bit. This
process is often called exclusive or, and is denoted by XOR. The symbol is used
| 31
a b c=ab
0 0 0
0 1 1
1 0 1
1 1 0
message =‘IF’
Encryption:
Decryption:
Unpredictability:
4.1 Introduction
Symmetric cryptography is split into block ciphers and stream ciphers, which are easy
to distinguish.
Cryptography
Symmetric Asymmetric
Protocols
Ciphers Ciphers
Stream
Block Cipher
Ciphers
A stream cipher processes the input elements continuously, producing output one
element at a time, as it goes along. Although block ciphers are far more common, there
are certain applications in which a stream cipher is more appropriate.
Stream ciphers encrypt bits individually. This is achieved by adding a bit from a key
stream to a plaintext bit. There are synchronous stream ciphers where the key stream
depends only on the key, and asynchronous ones where the key stream also depends on
the ciphertext. If the dotted line in Fig. 4.2 is present, the stream cipher is an
33
34 | M o d e r n S y m m e t r i c C i p h e r s
asynchronous one. Most practical stream ciphers are synchronous ones. An example of
an asynchronous stream cipher is the cipher feedback (CFB) mode introduced in
Block ciphers encrypt an entire block of plaintext bits at a time with the same key. This
means that the encryption of any plaintext bit in a given block depends on every other
plaintext bit in the same block. In practice, the vast majority of block ciphers either
have a block length of 128 bits (16 bytes) such as the advanced encryption standard
(AES), or a block length of 64 bits (8 bytes) such as the data encryption standard (DES)
or triple DES (3DES) algorithm. All of these ciphers are introduced in later chapters.
means they need fewer gates (or smaller chip area) than a block cipher for
encrypting at the same data rate. However, modern block ciphers such as AES
are also very efficient in software. Moreover, for hardware, there are also highly
efficient block ciphers, such as PRESENT, which are as efficient as very
compact stream ciphers.
As mentioned above, stream ciphers encrypt plaintext bits individually. The question
now is: How does encryption of an individual bit work? The answer is surprisingly
simple: Each bit xi is encrypted by adding a secret key stream bit 𝑠𝑖 modulo 2.
The plaintext, the ciphertext and the key stream consist of individual
bits, 𝑖. 𝑒. , 𝑥𝑖 , 𝑦𝑖 , 𝑠𝑖 ∈ {0,1}.
As we have learned so far, practical stream ciphers use a stream of key bits s1, s2, . . that
are generated by the key stream generator, which should have certain properties. An
elegant way of realizing long pseudorandom sequences is to use linear feedback shift
registers (LFSRs). LFSRs are easily implemented in hardware and many, but certainly
not all, stream ciphers make use of LFSRs. A prominent example is the A5/1 cipher,
which is standardized for voice encryption in GSM. As we will see, even though a plain
LFSR produces a sequence with good statistical properties, it is cryptographically
weak. However, combinations of LFSRs, such as A5/1 or the cipher Trivium, can make
secure stream ciphers. It should be stressed that there are many ways for constructing
stream ciphers. This section only introduces one of several popular approaches.
An LFSR consists of clocked storage elements (flip-flops) and a feedback path. The
number of storage elements gives us the degree of the LFSR. In other words, an LFSR
with 𝑚 𝑓𝑙𝑖𝑝 − 𝑓𝑙𝑜𝑝𝑠 is said to be of degree m. The feedback network computes the
input for the last flip-flop as XOR-sum of certain flip-flops in the shift register. Example
1. Simple LFSR We consider an LFSR of degree m = 3 with flip-flops 𝐹𝐹2 , 𝐹𝐹1 , 𝐹𝐹0 ,
and a feedback path as shown in Fig. 4.3. The internal state bits are denoted by 𝑠𝑖 and
are shifted by one to the right with each clock tick. The rightmost state bit is also the
current output bit. The leftmost state bit is computed in the feedback path, which is the
XOR sum of some of the flip-flop values in the previous clock period. Since the XOR
36 | M o d e r n S y m m e t r i c C i p h e r s
is a linear operation, such circuits are called linear feedback shift registers. If we assume
an initial state of (𝑠2 = 1, 𝑠1 = 0, 𝑠0 = 0),
Fig. 4.3 Linear feedback shift register of degree 3 with initial values 𝑠2 , 𝑠1 , 𝑠0
There is a simple formula which determines the functioning of this LFSR. Let’s
look at how the output bits 𝑠𝑖 are computed, assuming the initial state bits s0, s1, s2:
𝑠3 ≡ 𝑠1 + 𝑠0 𝑚𝑜𝑑 2
𝑠4 ≡ 𝑠2 + 𝑠1 𝑚𝑜𝑑 2
𝑠5 ≡ 𝑠3 + 𝑠2 𝑚𝑜𝑑 2
𝑠𝑖 + 3 ≡ 𝑠𝑖 + 1 + 𝑠𝑖 𝑚𝑜𝑑 2
| 37
where i = 0,1,2, . . .
The Data Encryption Standard (DES) has been by far the most popular block cipher for
most of the last 30 years. Even though it is nowadays not considered secure against a
determined attacker because the DES key space is too small, it is still used in legacy
applications. Furthermore, encrypting data three times in a row with DES — a process
referred to as 3DES or triple DES — yields a very secure cipher which is still widely
used today (Section 3.5 deals with 3DES.) Perhaps what is more important, since DES
is by far the best-studied symmetric algorithm, its design principles have inspired many
current ciphers. Hence, studying DES helps us to understand many other symmetric
algorithms.
ignored without economic consequences. The NBS received the most promising
candidate in 1974 from a team of cryptographers working at IBM. The algorithm IBM
submitted was based on the cipher Lucifer. Lucifer was a family of ciphers developed
by Horst Feistel in the late 1960s, and was one of the first instances of block ciphers
operating on digital data. Lucifer is a Feistel cipher which encrypts blocks of 64 bits
using a key size of 128 bits.
In order to investigate the security of the submitted ciphers, the NBS requested the help
of the National Security Agency (NSA), which did not even admit its existence at that
point in time. It seems certain that the NSA influenced changes to the cipher, which
was rechristened DES. One of the changes that occurred was that DES is specifically
designed to withstand differential cryptanalysis, an attack not known to the public until
1990. It is not clear whether the IBM team developed the knowledge about differential
cryptanalysis by themselves or whether they were guided by the NSA. Allegedly, the
NSA also convinced IBM to reduce the Lucifer key length of 128 bit to 56 bit, which
made the cipher much more vulnerable to brute-force attacks.
39