0% found this document useful (0 votes)
85 views

Cryptography Notes

Symmetric encryption uses a single secret key known to both the sender and receiver. It was historically the most common encryption method. A symmetric encryption scheme requires a plaintext, encryption algorithm, secret key, which produces ciphertext, and decryption algorithm to recover the plaintext. For secure symmetric encryption, a strong algorithm and secure exchange of the secret key between sender and receiver are needed.

Uploaded by

Asif Koujaganur
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views

Cryptography Notes

Symmetric encryption uses a single secret key known to both the sender and receiver. It was historically the most common encryption method. A symmetric encryption scheme requires a plaintext, encryption algorithm, secret key, which produces ciphertext, and decryption algorithm to recover the plaintext. For secure symmetric encryption, a strong algorithm and secure exchange of the secret key between sender and receiver are needed.

Uploaded by

Asif Koujaganur
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Symmetric encryption is also referred to as conventional

encryption or single-key encryption. It was the only type of


encryption in use prior to the development of public-key encryption. It
remains by far the most widely used of the two types of encryption.

A symmetric encryption scheme has five ingredients:

1. Plain text: This is the Original intelligible message or data


that is fed in to the algorithm as input.
2. Encryption Algorithm: The encryption algorithm performs
various substitutions and transformation on the plain text to
convert it into ciphertext.
3. Secret Key: The secret key is also input to the encryption
algorithm. The key is a value independent of the plain text.
The algorithm will produce a different output depending on the
specific key being used at the time. The exact substitutions
and transformations performed by the algorithm depend on
the key.
4. Ciphertext: This is the scrambled message produced as
output. It depends on the plain text and the secret key. For a
given message, two different keys will produce different
ciphertexts. The ciphertext is an apparently random stream of
data and, as it stands, is unintelligible.
5. Decryption Algorithm: This is essentially the encryption
algorithm run in reverse. It takes the ciphertext and the secret
key as the input and produces the original plain text.
Fig 1 Simplified Model of Conventional Encryption
There are two requirements for secure use of conventional
encryption-

 We need a strong encryption algorithm. At a minimum, we


would like the algorithm to be such that an opponent who
known the algorithm and has access to one or more ciphertext
would be unable to decipher the ciphertext or figure out the
key. Usually, this requirement is stated in a stronger form.
The opponent should be unable to decrypt ciphertext or
discover the key even if he or she is in possession of a number
of ciphertext together with the plain text that produce each
ciphertext
 Sender and Receiver must have obtained copies of the secret
key in a secure fashion and must keep the key secure. If
someone can discover the key and knows the algorithm, all
information using this key is readable.
CLASSICAL ENCRYPTION TECHNIQUES
There are two basic building blocks of all encryption techniques: substitution and
transposition.

1 SUBSTITUTION TECHNIQUES
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 cipher text bit
patterns.
(i)Caesar cipher (or) shift cipher
The earliest known use of a substitution cipher and the simplest was by Julius
Caesar. The Caesar cipher involves replacing each letter of the alphabet with the
letter standing 3 places further down the alphabet.
e.g., Plain text : pay more mone Cipher text: SDB PRUH PRQHB
Note that the alphabet is wrapped around, so that letter following „z‟ is „a‟. For
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. The decryption algorithm is simply
P = D(C) = (C-k) mod 26
(ii)Playfair cipher
The best known multiple letter encryption cipher is the playfair, which treats
digrams in the plaintext as single units and translates these units into cipher
text digrams. The playfair algorithm is based on the use of 5x5 matrix of
letters constructed using a keyword. Let the keyword be „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 alphabetical order.

The letter „i‟ and „j‟ count as one letter. Plaintext is encrypted two letters at a time
according to the following rules:

1. Repeating plaintext letters that would fall in the same pair are separated with
a filler letter such as „x‟.

2. 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 following the last.

3. Plaintext letters that fall in the same column are replaced by the letter
beneath, with the top element of the column following the last.
4. Otherwise, each plaintext letter is replaced by the letter that lies in its own
row and the column occupied by the other plaintext letter.

Plaintext = meet me at the school house

Splitting two letters as a unit => me et me at th es ch ox ol ho us ex Corresponding


cipher text => CL KL CL RS PD IL HY AV MP HF XL IU
Strength of playfair cipher

1. Playfair cipher is a great advance over simple mono alphabetic ciphers.

2. Since there are 26 letters, 26x26 = 676 diagrams are possible, so identification
of individual digram is more difficult.

3. Frequency analysis is much more difficult.

(iii)Polyalphabetic ciphers
Another way to improve on the simple monoalphabetic technique is to use
different monoalphabetic substitutions as one proceeds through the plaintext
message. The general name for this approach is polyalphabetic cipher. All
the techniques have the following features in common.

A set of related monoalphabetic substitution rules are used


A key determines which particular rule is chosen for a given transformation.

(iv)Vigenere cipher
In this scheme, the set of related monoalphabetic substitution rules
consisting of 26 caesar ciphers with shifts of 0 through 25. Each cipher is
denoted by a key letter. e.g.,
Caesar cipher with a shift of 3 is denoted by the key value 'd‟ (since a=0, b=1, c=2
and so on). To aid in understanding the scheme, a matrix known as vigenere
tableau is constructed.
Each of the 26 ciphers is laid out horizontally, with the key letter for each cipher
to its left. A normal alphabet for the plaintext runs across the top. The process of
encryption is simple: Given a key letter X and a plaintext letter y, the cipher text is
at the intersection of the row labeled x and the column labeled y; in this case, the
ciphertext is V.

To encrypt a message, a key is needed that is as long as the message. Usually, the
key is a repeating keyword.

e.g., key =deceptivedecepti vedeceptive


PT =wearediscoveredsaveyourself
CT = ZICVTWQNGRZGVTWAVZHCQYGLMGJ
Decryption is equally simple. The key letter again identifies the row. The
position of the cipher text letter in that row determines the column, and the
plaintext letter is at the top of that column.

Strength of Vigenere cipher

There are multiple ciphertext letters for each plaintext letter



Letter frequency inforamiton is obscured.

One Time Pad Cipher

It is an unbreakable cryptosystem. It represents the message as a sequence of


0s and 1s. this can be accomplished by writing all numbers in binary, for
example, or by using ASCII. The key is a random sequence of 0‟s and 1‟s
of same length as the message.

Once a key is used, it is discarded and never used again. The system can be
expressed as follows:

Thus the cipher text is generated by performing the bitwise XOR of the plaintext
and the key. Decryption uses the same key. Because of the properties of XOR,
decryption simply involves the same bitwise operation:
Advantage:

Encryption method is completely unbreakable for a ciphertext only attack.

Disadvantages

It requires a very long key which is expensive to produce and expensive to


transmit.

Once a key is used, it is dangerous to reuse it for a second message; any knowledge
on the first message would give knowledge of the second.

2 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:
m e a t e c o l o s
e t t h s H o h ue
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., plaintext = meet at the school house

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.
What Is Steganography?

A steganography technique involves hiding sensitive information within an ordinary, non-secret


file or message, so that it will not be detected. The sensitive information will then be extracted
from the ordinary file or message at its destination, thus avoiding detection. Steganography is an
additional step that can be used in conjunction with encryption in order to conceal or protect
data.

Steganography is a means of concealing secret information within (or even on top of) an
otherwise mundane, non-secret document or other media to avoid detection. It comes from the
Greek words steganos, which means “covered” or “hidden,” and graph, which means “to write.”
Hence, “hidden writing.”

You can use steganography to hide text, video, images, or even audio data. It’s a helpful bit of
knowledge, limited only by the type of medium and the author’s imagination.

Different Types of Steganography

1. Text Steganography − There is steganography in text files, which entails secretly


storing information. In this method, the hidden data is encoded into the letter of
each word.

2. Image Steganography − The second type of steganography is image


steganography, which entails concealing data by using an image of a different
object as a cover. Pixel intensities are the key to data concealment in image
steganography.

Since the computer description of an image contains multiple bits, images are
frequently used as a cover source in digital steganography.
The various terms used to describe image steganography include:

 Cover-Image - Unique picture that can conceal data.

 Message - Real data that you can mask within pictures. The message may be in
the form of standard text or an image.

 Stego-Image − A stego image is an image with a hidden message.

 Stego-Key - Messages can be embedded in cover images and stego-images with


the help of a key, or the messages can be derived from the photos themselves.

3. Audio Steganography − It is the science of hiding data in sound. Used digitally,


it protects against unauthorized reproduction. Watermarking is a technique that
encrypts one piece of data (the message) within another (the "carrier"). Its typical
uses involve media playback, primarily audio clips.

4. Video Steganography − Video steganography is a method of secretly embedding


data or other files within a video file on a computer. Video (a collection of still
images) can function as the "carrier" in this scheme. Discrete cosine transform
(DCT) is commonly used to insert values that can be used to hide the data in each
image in the video, which is undetectable to the naked eye. Video steganography
typically employs the following file formats: H.264, MP4, MPEG, and AVI.

5. Network or Protocol Steganography − It involves concealing data by using a


network protocol like TCP, UDP, ICMP, IP, etc., as a cover object. Steganography
can be used in the case of covert channels, which occur in the OSI layer network
model.
Steganography vs. Cryptography

Factors Steganography Cryptography

It's a method to conceal the fact that


Explanation communication is taking place It's a method for making information unintelligible

Aim Maintain communication security Enable data protection

Optional, but increases security when


Key utilized Necessary prerequisite

Data Visibility No Yes

Once hidden information is decoded, You can recover the original message from the
Failure the data can be used by anyone ciphertext if you can access the decryption key

Does not modify the data's general


Data Structure structure Modifies the overall data structure
Block Cipher and Stream Cipher
Block cipher and stream cipher are members of the family of symmetric key
ciphers, essentially encryption techniques used for directly transforming
the plaintext into ciphertext.

In this article, we will discuss the characteristics of block ciphers and stream
ciphers and how they differ from one another.

What is Block Cipher?

A block cipher is a symmetric cryptographic technique which we used


to encrypt a fixed-size data block using a shared, secret
key. During encryption, we used plaintext and ciphertext is the resultant
encrypted text. It uses the same key to encrypt both the plaintext, and
the ciphertext.
A block cipher processes the data blocks of fixed size. Typically, a message's
size exceeds a block's size. As a result, the lengthy message is broken up into a
number of sequential message blocks, and the cipher operates on these
blocks one at a time.

With the help of the shared secret key, a block cipher encrypts and decrypts its
input one block rather than one bit at a time. Since the block's size is fixed,
padding is not necessary. It is a symmetric algorithm. During encryption, it
converts text input into cyphertext using the shared key. It uses the same key
during decryption to change the cyphertext back to the original plaintext. The
length of the output and input are identical.

o Popular variations of the block cipher algorithm include the Data


Encryption Standard (DES), TripleDES, and the Advanced Encryption
Standard (AES).
o The stream cipher uses a shared key and operates on its input one bit at
a time, which is the block cipher's counterpart.
o Alternative to the block cipher algorithm includes public-key
cryptography and asymmetric cryptography. This algorithm uses the
public key to encrypt plaintext and a private key to decrypt the
ciphertext.

There are various modes of operation of a block cipher:

o Electronic Code Book (ECB) Mode


o Cipher Block Chaining (CBC) Mode
o Cipher Feedback (CFB) Mode
o Output Feedback (OCB) Mode
o Counter (CTR) Mode

These modes serve as a block cipher's general procedures principles.

1. Electronic Codebook Mode


Electronically code message in plaintext form is dine in ECB mode. It is the most
straightforward block cipher operating mode. It does not introduce any
randomness to the key stream, and it is the only mode we can use to encrypt
a single-bit stream. Using the cipher's key and substitution alphabet, each
plaintext symbol, such as a character from the plaintext alphabet, is
transformed into a ciphertext symbol. Each block of plaintext is encrypted
separately from every other block. Only 8 bytes of the key are used when the
plaintext block is only 8 bytes long, and all 100 bytes of the key are utilised
when the plaintext block is 100 bytes long.

2. Cipher Block Chaining Mode (CBC)


When using CBC mode to encrypt data, each block of plaintext is combined
with the ciphertext that came before it. A ciphertext generated by the
symmetric algorithm depends on all plaintext block processed in the data
stream before it. This is done to ensure that every block of the ciphertext
depends on every other block that came before it. Before using the cipher
algorithm to encrypt the data, each block of plaintext is XORed (exclusive OR)
with the block of ciphertext that came before it. Numerous security
applications used CBC mode. For example, Secure Sockets Layer/Transport
Layer Security uses CBC mode in order to encrypt data which is transferred
over the internet.

3. Ciphertext Feedback Mode (CFB)


It is occasionally important to quickly encrypt and send plaintext values, one at
a time, as opposed to CBC mode, which encrypts a predetermined number of
bits of plaintext at a time. CFB also uses an IV, similar to CBC. A block cipher is
a part of the random number generator used by CFB. In CFB mode, the
previous ciphertext block is encrypted, and the output is XORed with the
current plaintext block to create the current ciphertext block.

4. Output Feedback Mode (OFB)


In certain ways, CBC and OFB modes are comparable and can be used with
any block cipher. It uses a feedback mechanism; however, in OFB mode, the
preceding block of ciphertext is XORed with the plaintext after encryption
rather than prior to encryption.

5. Counter Mode (CTR)


CTR mode uses a block chaining mode of encryption as a building block. The
process of encrypting data is performed by XORing the plaintext with a series
of pseudorandom values that are each created from the ciphertext using a
feedback function; data is encrypted. A series of XORs between blocks of
plaintext and corresponding blocks of ciphertext can be used to represent
the CTR encryption process.

Examples of Block Ciphers


The majority of contemporary cipher suites are based on block ciphers. Several
encryption standard protocols that utilise block ciphers are:

1. Data Encryption Standard (DES)

Initially, sensitive, private information was protected using a 56-bit symmetric


key algorithm. DES was later discontinued because of its short length and
other security issues, although it is still regarded as a pioneer encryption
standard.

2. Advanced Encryption Standard (AES)

It is a popular block cipher which encrypts data in blocks of 128 bits using 128,
192, and 256-bit symmetric keys. The underlying block cipher uses
substitution-permutation and transportation techniques to produce ciphertext
by shuffling and replacing input data in a sequence of linked
calculations. AES is a widely encryption standard since cryptanalysis efforts
against its algorithms have been ineffective.

3. Twofish

Twofish is an encryption standard that uses a Feistel network, a complex key


schedule, and substitution techniques to separate the key and ciphertext.
Using keys that can range in size from 128 to 256 bits, the standard encrypts
plaintext data in blocks of 128 bits.

Block ciphers are also used by other encryption schemes such as 3DES,
Serpent, and Blowfish.

What is Stream Cipher?

A stream cipher uses time-varying changes on plaintext data to encrypt a


continuous string of binary numbers. As a result, this method of encryption
works bit-by-bit, utilising keystreams to generate ciphertext for arbitrary
lengths of plain text messages. The cipher combines a key (128/256 bits) and a
nonce digit (64-128 bits) in order to generate the keystream - a
pseudorandom number XORed with the plaintext to generate the ciphertext.
The keystream must be different for each encryption iteration even though the
key and nonce can be reused to maintain security. In order to build the
keystream, stream encryption ciphers generate a unique nonce (a number
used only once utilising feedback shift registers.

Since a mistake in the translation of one bit often does not affect the entire
plaintext block, stream cipher encryption algorithms are less likely to cause
system-wide errors to spread. Additionally, stream encryption is linear and
continuous, making it easier and quicker to deploy. However, stream ciphers
do not have diffusion because each digit of the plaintext is mapped to one
ciphertext output. Furthermore, they don't check for validity, which leaves
them open to insertions. If hackers defeat the encryption algorithm, they are
able to add to or change the encrypted message without being noticed.
Stream ciphers are typically used to encrypt data in an application where the
volume of plain text cannot be predicted and in low latency use-cases.

In other words, a stream cipher is a type of encryption that uses plain text
numbers and a stream of pseudorandom cipher digits. Each binary digit
receives one bit at a time of this pseudorandom encryption digit stream. This
encryption technique uses an infinite number of pseudorandom cipher digits
for each key.

State cipher is another name for a stream cipher. The term "state cipher" refers
to a system where the encryption of each number is dependent on the
cipher's current state.

Types of Stream Ciphers


There are two types of Stream Ciphers:

1. Synchronous Stream Ciphers

In a synchronous stream cipher, the keystream block is created independently of


the previous ciphertext and plaintext messages. The most popular stream
cipher modes produce a string of bits using pseudorandom number
generators and combine it with the key to create the keystream, which is
then XORed with the plaintext to produce the ciphertext.

2. Self-Synchronizing/Asynchronous stream Ciphers

The previous ciphertext block's fixed size (N-bits) and symmetric key are used
to generate the keystream block via a self-synchronizing stream cipher, also
known as ciphertext autokey. Asynchronous stream cipher can recognize
active attacks by altering the ciphertext, which changes the information in the
subsequent keystream. Due to the fact that a single-digit error can only affect
a maximum of N bits, these ciphers also have restricted error propagation.
Example of Stream Ciphers
The following are examples of stream ciphers:

1. River Cipher (RC4)

A quick and easy encryption algorithm called RC4/ARC4/ARCFOUR was created


in 1987 to accomplish byte-by-byte encryption utilising 64- or 128-bit length
keys. Transport Layer Security, secure Sockets Layer, and the IEEE 802.11
WLAN standard all use extensively RC4. The widely used encryption method is
available in a number of variations, including SPRITZ, RC4A, and RC4A+.

2. Salsa20

Salsa20 is a powerful, up-to-date encryption cipher that creates the encryption


keystream using an expansion function. Salsa20 also relies on a core function
which uses add-rotate-XOR (ARX) operations to map the key, a nonce digit,
and constant vectors retrieved from the expansion function to the keystream.

3. Software-Optimized Encryption Algorithm (SEAL)

An additive binary stream cipher called SEAL is designed for systems with 32-
bit CPUs and enough RAM. The encryption standard depends on a
pseudorandom family that maps a 32-bit string to any length string using a
length-increasing function and a 160-bit key.

PANAMA, Scream, Rabbit, HC-256, and Grain are a few other examples of
stream ciphers.

Difference Between Block Cipher and


Stream Cipher
Parameters Block Cipher Stream Cipher

Definition Block Cipher is the kind of Stream cipher is the kind of


encryption that converts plaintext encryption that converts
by taking each block individually. plaintext by taking one byte
of the plaintext at a time.

Principle It uses both diffusion and Only the confusion principle


confusion principles for the is used by Stream Cipher for
conversion (used later in the conversion.
encryption).

Decryption In Block cipher, reverse encryption In a stream cipher, XOR is


or decryption is more difficult than used for encryption that can
stream cipher since more bits are quickly converted back to
combined to be encrypted in this plain text.
scenario.

Implementatio Feistel Cipher is the most popular Vernam Cipher is the main
n block cipher implementation. implementation of Stream
Cipher.

Implementatio Feistel Cipher is the most popular Vernam Cipher is the main
n block cipher implementation. implementation of Stream
Cipher.

Conversion of Since a block cipher converts However, in stream cipher,


Bits blocks at once, it converts more only 8 bits can be
significant bits than a stream transformed simultaneously.
cipher, which can convert 64 bits or
more.

Reversibility It is difficult to reverse encrypted It uses XOR encryption,


text. which is easily reversed to
the plain text.

Confusion and Block Cipher uses both confusion Stream cipher relies on
Diffusion and diffusion. confusion only.

Algorithm ECB (Electronic Code CFB (Cipher Feedback)


modes used Book) CBC (Cipher Block Chaining) OFB (Output Feedback)

Complexity Simple design Complex comparatively

No of bits used 64 Bits or more 8 Bits

Advantages of Stream Cipher Over


Block Cipher
The following are the advantages of stream cipher over block cipher:

o Stream ciphers are faster than block ciphers and work well for both
small and large chunks of data.
o Unlike block ciphers, which need a significant amount of memory
because they operate on large chinks of data, stream ciphers only
operate on bits at a time.
o Stream cipher bytes are encrypted separately from other data chunks,
whereas block cipher encrypts an entire block at once.
o In general, Stream ciphers operate best in situations where the amount
of data is either continuous or unknown, such as network streams,
whereas block cipher function better when the amount of duration of
the data is known, such as in files, data fields, or response protocols.

Key Differences Between Block Cipher


and Stream Cipher
o When using a block cipher, each block of text is encrypted separately.
Decrypt the text similarly by selecting one block at a time. The stream
cipher approach, in contrast, encrypts and decrypts the text one byte at
a time.
o In block cipher, confusion and diffusion, both are used but in stream
cipher only relies on confusion.
o In Block Cipher, the same key is used for encryption but in Stream
Cipher, a different key is used for each byte.
o The ECB (Electronic Code Book) and CBC (Cipher Block Chaining) algorithm
modes are used in the block cipher. Contrarily, the CFB (Cipher
Feedback) and OFB (Output Feedback) algorithm modes are used in the
stream cipher.
o In the Block cipher, the typical block size is between 64 and 128 bits. In
contrast, the stream cipher converts 1 byte (8 bits) at a time.

You might also like