0% found this document useful (0 votes)
10 views13 pages

Infromation Term Work

The RSA Algorithm, developed in 1978 by Rivest, Shamir, and Adleman, is an asymmetric encryption method that uses a public and private key based on large prime numbers. The algorithm involves several steps including selecting prime numbers, calculating keys, and performing encryption and decryption using modular arithmetic. Additionally, the document explains cipher text, types of ciphers (stream and block), and the MD5 algorithm for hashing, along with the concept of Message Authentication Code (MAC).

Uploaded by

Aryan Kanojia
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)
10 views13 pages

Infromation Term Work

The RSA Algorithm, developed in 1978 by Rivest, Shamir, and Adleman, is an asymmetric encryption method that uses a public and private key based on large prime numbers. The algorithm involves several steps including selecting prime numbers, calculating keys, and performing encryption and decryption using modular arithmetic. Additionally, the document explains cipher text, types of ciphers (stream and block), and the MD5 algorithm for hashing, along with the concept of Message Authentication Code (MAC).

Uploaded by

Aryan Kanojia
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/ 13

Q.1.

Explain RSA Algorithm

The RSA Algorithm was founded in 1978 by three scientists named Rivest, Shamir, and
Adleman, which s why the algorithm is called RSA. It is an asymmetric algorithm, which
means the sender and receiver use two different keys – a private key and a public key.

The RSA algorithm is based on the mathematical truth that it is easy to locate and multiply
massive prime numbers together, but it’s extremely difficult to factor their product. The
private and public keys in RSA are based on very large prime numbers (made of 100 or more
digits). While the algorithm itself is simple (unlike symmetric-key cryptographic algorithms),
the real challenge in RSA is the choice and generation of the public and private keys.

The encryption and decryption process in RSA Algorithm follows these steps:

Step 1) Consider two prime numbers P & Q

Step 2) Calculate N = P × Q

Step 3) For Encryption key such that it is not factor of (P-1)(Q-1)

Step 4) For Decryption key Equation (D × E) mod (P-1) × (Q-1) = 1

Step 5) For Encryption calculate cipher text CT from your message or plain text
CT = PT^E mod N
Where PT = Plain Text, CT = Cipher Text, E = Encryption

Step 6) Send cipher text that is CT to receiver

Step 7) For decryption, calculate the plain text PT from cipher text CT as,

PT = CT^D mod N

Where PT = Plain Text, CT = Cipher Text, D = Decryption

An example to illustrate the RSA algorithm process:

1) Consider P = 7 and Q = 17 (two large prime numbers)

2) Calculate N = P × Q = 7 × 17 = 119
3) For the Encryption key, we need to find (P-1)(Q-1) = (7-1)(17-1) = 6 × 16 = 96

We must choose E that is not a factor of 96


The factors of 96 are 2, 2, 2, 2, 2, and 3 (As 96 = 2 × 2 × 2 × 2 × 2 × 3)

We cannot choose 2 and 3 as encryption Key as they are factors of 96

Also, we cannot choose 8 because 2 × 2 × 2 × 2, and we cannot choose 9 also as it contains


3 as a factor

So we choose E as 5 because it does not have factors 2 and 3

4) For Decryption key, we use the equation (D × E) mod (P-1)×(Q-1) = 1

Putting the values of E, P, Q we get:

(D × 5) mod (7-1) × (17-1) = 1

(D × 5) mod 6 × 16 = 1
(D × 5) mod 96 = 1

(As we want the result to equal 1, we have to find a value for D that makes the equation
equal to 1)

So, we consider D = 77 and put into it:

(77 × 5) mod 96 = 1

385 mod 96 = 1

5) For Encryption, calculate cipher text CT from the plain text:

CT = PT^E mod N

Consider plain text = 10


CT = 10^5 mod 119 (PT = 10, E = 5, N = 119)

100000 mod 119 = 40

6) Send 40 (the cipher text) to the receiver

7) For decryption, the receiver calculates the plain text PT from cipher text CT as:
PT = CT^D mod N

As we sent 40 to receiver, CT = 40, D = 77, N = 119

By putting values, we get:


PT = 40^77 mod 119 = 10, which is the original text

The completed process shows how we start with a message (10), encrypt it to get ciphertext
(40), and then decrypt it to recover the original message (10).

Q. 2. What is mean by cipher text. Explain its type.

Cipher text is the text which comes from the output of an encryption algorithm applied to
plain text. When a person or device lacking the cipher is unable to read it, the data is said to
be encrypted. Cipher text needs to be converted into plain text so that it is in readable form.

Cipher as an algorithm which is applied to plain text or message to get ciphertext. Cipher text
is the unreadable output of an encryption algorithm. The term “cipher” is sometimes used as
an alternative term for ciphertext. Ciphertext is not understandable until it has been converted
into plain text using a key.

Types of cipher are:

1) Caesar Cipher

2) Mono Alphabetic Cipher

3) Homophonic Substitution Cipher

4) Polygram Substitution Cipher

5) Vigenere Cipher

The categorizes of ciphers into broader types:

Stream Cipher:
A type of symmetric key (secret key) cipher that operates on small units of data (as small as a
single bit) at a time. It generates a key stream or sequence of bits using the secret key as a
seed. Stream ciphers encrypt data one bit, or byte, at a time. As this cipher uses only one key
for encryption as well as decryption, it has fast implementations with low resource
consumption.

This is useful for encrypting wireless signals, which more naturally fit a streaming model
than transmitting data in larger, fixed-size chunks. Stream cipher uses one-time pad; the key
typically used with a stream cipher one-time pad is unbreakable because it’s always at least
the exact same size as the message it is encrypting. Cryptographers also refer to the
symmetric key used in a stream cipher as a keystream.

Advantages of Stream Cipher:

1) Speed – Stream cipher is faster transformation.

2) Ease of use – as single key used.

3) Low Consumption – Low resources required.

**Disadvantages of Stream Cipher:**

1) Low diffusion: plaintext symbol is contained in a single cipher text symbol.

2) Susceptibility to insertions/modifications: As it works on bits.

Block Cipher:

Block cipher encrypts a group of plaintext symbols as one block. The key is applied to blocks
mostly 64 bits in size at a time. Size of block can be 128, 192, or 256 bits (128 bits used by
AES and 64 bits used by DES).

Consider a 128-bit block cipher – it requires 128 bits of plaintext and encrypts it into 128 bits
of ciphertext. Where the amount of plaintext is less than 128 bits, padding may be needed.

Advantages of Block Cipher:

1) Block Ciphers provide integrity protection like MAC.


2) It provides ease of implementation and less restrictive requirements.
Disadvantages of Block Cipher:

1) Block Ciphers are slow and less memory efficient.

2) Transmission errors are more common.

Difference between Stream Cipher and Block Cipher:

Sr. No Stream Cipher Block Cipher

1. It encrypts one bit at a time (One time It encrypts block at a time.


pad)

2. It uses only confusion. It uses both confusion and


diffusion.

3. It uses substitution technique. It uses transportation technique.

4. It is faster than block cipher. It is slower than stream cipher.

5. It requires less code. It requires more code.

6. It is more complex. It is simple.

Q.3. Explain type of stream cipher.

A stream cipher is a type of symmetric key (secret key) cipher that operates on small units of
data (as small as a single bit) at a time. It generates a key stream or sequence of bits using the
secret key as a seed. Stream ciphers encrypt data one bit, or byte, at a time. As this cipher
uses only one key for encryption as well as decryption, it has fast implementations with low
resource consumption.

This is useful for encrypting wireless signals, which more naturally fit a streaming model
than transmitting data in larger, fixed-size chunks. Stream cipher uses one-time pad; the key
typically used with a stream cipher one-time pad is unbreakable because it’s always at least
the exact same size as the message it is encrypting. Cryptographers also refer to the
symmetric key used in a stream cipher as a keystream. An example of stream cipher
mentioned in the PDF is simple substitution.

The two main types of stream ciphers:


1) Synchronous stream ciphers: In these ciphers, the keystream is generated
independently of the plaintext and of the ciphertext. The keystream is usually
produced by a pseudorandom generator, parameterized by a key, which is the secret
key of the whole scheme. Because the keystream generation is independent of the
plaintext and ciphertext, the sender and receiver must be exactly synchronized for
decryption to work correctly.

2) Self-synchronizing stream ciphers: In these ciphers, the key stream depends on the
secret key of the scheme, but also on a fixed number, say t, of cipher text digits. This
allows the cipher to recover automatically from any loss of synchronization, as after
processing t ciphertext digits, the keystream generation will be back in sync with the
sender’s keystream.

The following advantages of stream ciphers:

1) Speed - Stream cipher is faster transformation compared to block ciphers.

2) Ease of use - Stream ciphers are easier to use as a single key is involved.

3) Low Consumption - Stream ciphers require low resources, making them suitable for
resource-constrained environments.

The disadvantages of stream ciphers are:

1) Low diffusion: Each plaintext symbol is contained in a single cipher text symbol, which
makes it vulnerable to certain types of cryptanalysis.

2) Susceptibility to insertions/modifications: Since stream ciphers work on individual bits,


they can be susceptible to insertion or modification attacks if not implemented with proper
authentication mechanisms.

The confusion in relation to stream ciphers. Confusion means that the key does not relate in a
simple way to the ciphertext. Each character of the ciphertext should depend on several parts
of the key. Stream ciphers use one-time pad so they utilize confusion. Nonlinear functions are
responsible for confusion. Confusion is equivalent to substitution (e.g., a → b in Caesar
cipher).

By contrast, diffusion (which is primarily used in block ciphers) means that if we change a
character of the plaintext, then several characters of the ciphertext should change, and
similarly, if we change a character of the ciphertext, then several characters of the plaintext
should change. Block ciphers use both confusion and diffusion, while stream ciphers
primarily rely on confusion.

Q.4.Explain steps in MD5 Algorithm

explanation of the MD5 algorithm:

Step 1: Padding Bits

In the MD5 algorithm, the first step is to add padding bits to the original message. The
aim is to make the length of the original message equal to a value which is 64 bits less
than an exact multiple of 512.

For example, if the length of the original message is 1200 bits, we add padding of 272
bits to make the length of the message 1472 bits. This is because, if we add 64 to 1472,
we get 1536, which is a multiple of 512 (because 1536 = 512 * 3).

The padding always begins with a '1' bit followed by all necessary '0' bits (as
"100000....00").

Step 2: Append Length

The next step is to calculate the length of the original message and add it to the end of
the message, after padding. The length of the message is calculated excluding the
padding bits (i.e., it is the length of the original message).

For example, if the original message consisted of 1200 bits and we added a padding of
272 bits to make the length of the message 64 bits less than 1536 (a multiple of 512),
the length is considered as 1200 and not 1472 for this step. This length of the original
message is now expressed as a 64-bit value and these 64 bits are appended to the end
of the original message + padding.

Note that if the length of the message exceeds 2^64 bits then, we use only the low-
order 64 bits of the length. The length of the message is now an exact multiple of 512.
This now becomes the message whose digest will be calculated.
Step 3: Divide the Input into 512-bit Blocks

In this step, the input message is divided into blocks, each of length 512 bits. These
blocks become the input to the message digest processing logic.

Step 4: Initialize Chaining Variables

Here four variables also called chaining variables are initialized. They are denoted as A,
B, C, and D. Each of these is a 32-bit number. The initial hexadecimal values of these
chaining variables are as follows:

- A = 01234567

- B = 89ABCDEF

- C = FEDCBA98

- D = 76543210

Step 5: Process Each Block

After all the initializations, the real algorithm begins. It is quite complicated and
involves several sub-steps:

Step 5.1: Copy Chaining Variables

Initially, the four chaining variables are copied into four corresponding variables, a, b, c,
and d (note the smaller case). This means we now have a = A, b = B, c = C, and d = D.

The algorithm considers the combination of a, b, c, and d as a 128-bit single register


(which we shall call abcd). This register is useful in the actual algorithm operation for
holding final as well as intermediate results.

Step 5.2: Divide Block into Sub-blocks

The current 512-bit block is divided into 16 sub-blocks. Thus, each sub-block now
contains 32 bits.

Step 5.3: Process in Four Rounds


Now, we have four rounds. In each round, we process all the 16 sub-blocks belonging
to a block. The inputs to each round are:

- All the 16 sub-blocks

- The variables a, b, c, d

- Some constants, designated as t

All four rounds vary in one major way: Step 1 of the four rounds has different
processing. The other steps in all four rounds are the same.

a) In each round, we have 16 input sub-blocks, named M[0], M[1], …, M[15] or in


general, M[i], where i varies from 0 to 15.

b) Also, there is an array of constants. It contains 64 elements, with each element


consisting of 32 bits. The elements of this array are denoted as t[1], t[2], … t[64] or in
general as t[k], where k varies from 1 to 64. Since there are four rounds, we use 16 out of
the 64 values of t in each round.

The iterations in all four rounds can be summarized as follows:

In each case, the output of the intermediate as well as the final iteration is copied into
the register abcd. Note that we have 16 such iterations in each round.

1. A process P is first performed on b, c, and d. This process P is different in all four


rounds:

- Round 1: F(b,c,d) = (b AND c) OR ((NOT b) AND d)

- Round 2: G(b,c,d) = (b AND d) OR (c AND (NOT d))

- Round 3: H(b,c,d) = b XOR c XOR d

- Round 4: I(b,c,d) = c XOR (b OR (NOT d))

2. The variable a is added to the output of the process P (i.e., to the register abcd).
3. The message sub-block M[i] is added to the output of Step 2 (i.e., to the register
abcd).

4. The constant t[k] is added to the output of Step 3 (i.e., to the register abcd).

5. The output of Step 4 (i.e., the contents of register abcd) is circular-left shifted by s
bits. (The value of s keeps changing).

6. The variable b is added to the output of Step 5 (i.e., to the register abcd).

7. The output of Step 6 becomes the new abcd for the next step.

We can mathematically express a single MD5 operation as:

a = b + ((a + Process P(b, c, d) + M[i] + T[k]) <<< s)

The final output is a 128-bit message digest, which is represented as a 32-character


hexadecimal number.

Q.5. Explain Message Authentication Code (MAC)

A Message Authentication Code (MAC) is a tag attached to a message which is used to


ensure the integrity and authenticity of the message. In short, MAC is a piece of
information that can be used to authenticate a message.

Key Differences from Message Digest

MAC is similar to a message digest with one key difference. A message digest is simply
a fingerprint of a message; no cryptographic process is involved in the case of message
digests. In contrast, a MAC requires that the sender and the receiver should know a
shared symmetric (secret) key, which is used in the creation of the MAC. Thus, MAC
involves cryptographic processing. MAC is sometimes also called a keyed hash.

Detailed Working of MAC

Let us assume that sender A wants to send a message M to receiver B:

1. Sender A and receiver B share a secret key K, which is known only by A and B.
2. Sender A calculates the MAC by applying key K and message M to the MAC algorithm,
producing a value H1.

3. Sender A then sends the original message M and the MAC H1 to receiver B.

4. When receiver B receives the message, B also uses K to calculate its own MAC H2
over M.

5. Receiver B now compares received H1 with computed H2.

- If the two match, receiver B concludes that message M has not been changed during
transit.

- If H1 ≠ H2, then receiver B rejects the message, realizing that the message was
changed during transit.

Importance of MAC

1. The MAC assures that the message is not altered by an attacker during transit,
because if an attacker alters the message but does not alter the MAC, then the
receiver's calculation of the MAC will differ from it. There is no chance for an attacker to
alter the MAC since the key used in the calculation of the MAC is assumed to be known
only to sender A and receiver B. As the attackers do not know the key K, they cannot
alter the MAC.

2. The receiver B is assured that the message indeed came from the correct sender A.
Since only sender A and receiver B know the secret key, no one else could have
calculated the MAC sent by sender A.

Technical Aspects of MAC

Though the calculation of the MAC is quite similar to an encryption process, in


symmetric key cryptography the cryptographic process must be reversible. This means
the sender performs encryption and the receiver performs decryption. But in the case of
MAC, both the sender and the receiver are performing the encryption process only.
Thus, a MAC algorithm need not be reversible – it is sufficient to be a one-way function
(encryption) only.

Limitations of MAC
1. MAC does not provide Non-Repudiation. Non-repudiation is the assurance that a
message originator cannot deny any previously sent messages and actions or
commitments.

2. MAC can provide message authentication only among pre-decided legitimate users
who have shared a key. This requires establishment of a shared key prior to using the
MAC.

The HMAC (Hash-based Message Authentication Code), which is a nested MAC that
includes a cryptographic hash function and a secret key in deriving the message
authentication code. HMAC is used in various protocols like FTPS, SFTP, HTTPS, and
has been chosen as a mandatory security implementation for the Internet Protocol (IP)
security and also used in the Secure Socket Layer (SSL) protocol.

Q.6. how to create a digital signature

To create a digital signature, the process involves several steps as outlined in the
document:

1. First, signing software such as an email program is used to provide a one-way hash of
the electronic data to be signed. A hash is a fixed-length string of letters and numbers
generated by an algorithm.

2. The digital signature creator's private key is then used to encrypt this hash. The
encrypted hash -- along with other information, such as the hashing algorithm --
constitutes the digital signature.

3. The reason for encrypting the hash instead of the entire message or document is
efficiency. A hash function can convert an arbitrary input into a fixed-length value,
which is usually much shorter. This saves time as hashing is much faster than signing.

4. The value of a hash is unique to the hashed data. Any change in the data, even a
change in a single character, will result in a different hash value. This attribute enables
others to use the signer's public key to decrypt the hash to validate the integrity of the
data.
5. If the decrypted hash matches a second computed hash of the same data, it proves
that the data hasn't changed since it was signed. If the two hashes don't match, the
data has either been tampered with or the signature was created with a private key that
doesn't correspond to the public key presented by the signer.

The document also explains the model of a digital signature scheme:

- Each person adopting this scheme has a public-private key pair.

- Generally, the key pairs used for encryption/decryption and signing/verifying are
different. The private key used for signing is referred to as the signature key and the
public key as the verification key.

- The signer feeds data to the hash function and generates a hash of the data.

- This hash value and signature key are then fed to the signature algorithm which
produces the digital signature on the given hash.

- The signature is appended to the data and then both are sent to the verifier.

- The verifier feeds the digital signature and the verification key into the verification
algorithm.

- The verifier also runs the same hash function on received data to generate a hash
value.

- For verification, this hash value and output of verification algorithm are compared.
Based on the comparison result, the verifier decides whether the digital signature is
valid.

- Since the digital signature is created by the 'private' key of the signer and no one else
can have this key, the signer cannot repudiate signing the data in the future.

Signing the hash rather than the entire data is more efficient because "signing large
data through modular exponentiation is computationally expensive and time
consuming. The hash of the data is a relatively small digest of the data, hence signing a
hash is more efficient than signing the entire data.”

You might also like