0% found this document useful (0 votes)
15 views38 pages

lec3

Security Network

Uploaded by

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

lec3

Security Network

Uploaded by

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

Asymmetric-Key

Cryptography
LEC3
Introduction

In this section we introduce asymmetric-key (public key


cryptography). As we mentioned before, an asymmetric-key
(or public-key) cipher uses two keys: one private and one
public. We discuss two algorithms: RSA and Diffie-Hellman.

2
3
Applications for Public-Key Cryptosystems

• Encryption/decryption: The sender encrypts a


message with the recipient's public key.
• Digital signature: The sender "signs" a message with
its private key. Signing is achieved by a cryptographic
algorithm applied to the message or to a small block of
data that is a function of the message.
• Key exchange: Two sides cooperate to exchange a
session key. Several different approaches are possible,
involving the private key(s) of one or both parties.
4
RSA‫خوارزمية‬

• The most common public key algorithm is RSA, named


for its inventors Rivest, Shamir, and Adleman (RSA). It
uses two numbers, e and d, as the public and private keys.

5
Procedure

Bob use the following steps to select the private and public keys:
1. Bob chooses two very large prime numbers p and q. Remember that a
prime number is one that can be divided evenly only by 1 and itself.
2. Bob multiplies the above two primes to find n, the modulus for
encryption and decryption. In other words, n = p * q.
3. Bob calculates another number ϕ= (p -1) * (q - 1).
4. Bob chooses a random integer e , 1<e< ϕ. He then calculates d so that:
d*e mod ϕ=1
d=(1/e)modϕ
5. Bob announces e and n to the public; he keeps ϕ and d secret.
6
Encryption:
Anyone who needs to send a message to Bob can use n and e. For example,
if Alice needs to send a message to Bob, she can change the message,
usually a short one, to an integer. This is the plaintext. She then calculates
the ciphertext, using e and n.
C=p^e(mod n)
Alice sends C, the ciphertext, to Bob.
Decryption:
Bob keeps ϕ and d private. When he receives the ciphertext, he uses his
private key d to decrypt the message:
P= C^d(mod n)
7
Note
In RSA, e and n are announced to the public; d and  are kept
secret.
Example

Bob chooses 7 and 11 as p and q and calculates


n = 7 · 11 = 77. The value of  = (7 − 1) (11 − 1) or 60.
Now he chooses two keys, e and d. If he chooses e to be 13,
then d is 37. Now imagine Alice sends the plaintext 5 to
Bob. She uses the public key 13 to encrypt 5.

C=p^e(mod n)
C=5^13(mod 77)
C=26
Example (continued)

Bob receives the ciphertext 26 and uses the private key 37


to decipher the ciphertext:

P= C^d(mod n)
P= 26^37(mod 77)
P=5

The plaintext 5 sent by Alice is received as plaintext 5 by


Bob.
Example

Jennifer creates a pair of keys for herself. She chooses


p = 397 and q = 401. She calculates n = 159,197 and
 = 396 · 400 = 158,400. She then chooses e = 343 and
d = 12,007. Show how Ted can send a message to Jennifer if
he knows e and n.
Example (continuted)

Solution
Suppose Ted wants to send the message “NO” to Jennifer.
He changes each character to a number (from 00 to 25)
with each character coded as two digits. He then
concatenates the two coded characters and gets a four-
digit number. The plaintext is 1314. Ted then uses e and n
to encrypt the message. The ciphertext is 1314 343 = 33,677
mod 159,197. Jennifer receives the message 33,677 and
uses the decryption key d to decipher it as 33,677 12,007 =
1314 mod 159,197. Jennifer then decodes 1314 as the
message “NO”. The next Figure shows the process.
Figure Example
The biggest problem for public key cryptographic scheme is
speed.
Public key algorithms are extremely slow compared to
symmetric algorithms. This is because public key calculations
take longer than symmetric key calculations since they
involve the use of exponentiation of very large numbers
which in turn take longer to compute.
the fastest public key cryptographic algorithm such as RSA is
still far slower than any typical symmetric algorithm. This
makes these algorithms and the public key scheme less
desirable for use in cases of long messages.
15
Applications:
•RSA can be used to encrypt and decrypt actual messages.
• it is very slow if the message is long.
• RSA, is useful for short messages such as a small message
digest or a symmetric key to be used for a symmetric-key
cryptosystem.
•RSA is used in digital signatures.

16
Diffie-Hellman
• RSA is a public-key cryptosystem that is often used to encrypt and decrypt
symmetric keys.
• Diffie-Hellman, on the other hand, was originally designed for key exchange.
• In the Diffie-Hellman cryptosystem, two parties create a symmetric session
key to exchange data.
• They do not have to meet to agree on the key; it can be done through the
Internet. Let us see how the protocol works when Alice and Bob need a
symmetric key to communicate. Before establishing a symmetric key, the two
parties need to choose two numbers p and g. The first number, p, is a large.
The second number is a random number. These two numbers can be sent
through the Internet; they can be public.

17
19
20
21
Example:

22
MESSAGE INTEGRITY

Encryption and decryption provide secrecy, or


confidentiality, but not integrity. However, on occasion
we may not even need secrecy, but instead must have
integrity.
Hash function
The electronic equivalent of the document and
fingerprint pair is the message and message digest
pair.
To preserve the integrity of a message, the message
is passed through an algorithm called a hash
function.
The hash function creates a compressed image of the
message that can be used as a fingerprint.

24
Figure Message and message digest
The two pairs document/fingerprint and
message/message digest are similar, with some
differences.
The document and fingerprint are physically linked
together; also, neither needs to be kept secret.
The message and message digest can be unlinked (or
sent) separately.
the message digest needs to be kept secret.

26
• Creating and Checking the Digest
The message digest is created at the sender site and is
sent with the message to the receiver.
To check the integrity of a message, or document, the
receiver creates the hash function again and compares
the new message digest with the one received.
If both are the same, the receiver is sure that the original
message has not been changed.

27
28
Figure Checking integrity

Notes: We need to make sure the digest cannot be altered by attacker


Hash Function Criteria

30
• One-wayness:
a message digest is created by a one-way hashing function.
We must not be able to recreate the message from the
digest.
• Weak Collision Resistance:
The second criterion, weak collision resistance, ensures that
a message cannot easily be forged.
• Strong Collision Resistance:
strong collision resistance, ensures that we cannot find two
messages that hash to the same digest.
31
Message Authentication
Code
• The digest created by a hash function is normally
called a modification detection code (MDC). The
code can detect any modification in the message.
• To provide message authentication, we need to
change a modification detection code to a message
authentication code (MAC).
• An MDC uses a keyless hash function; a MAC
uses a keyed hash function.

32
Figure MAC, created by Alice and checked by Bob
34
Digital Signature
Although a MAC can provide message integrity and message
authentication, it has a drawback. It needs a symmetric key that must be
established between the sender and the receiver.
A digital signature, on the other hand, can use a pair of asymmetric
keys (a public one and a private one).
When Alice sends a message to Bob, Bob needs to check the
authenticity of the sender; he needs to be sure that the message comes
from Alice and not Eve.
Bob can ask Alice to sign the message electronically. In other words, an
electronic signature can prove the authenticity of Alice as the sender of
the message. We refer to this type of signature as a digital signature.
35
• Digital signature can be achieved in two ways:
signing the document or signing a digest of the
document.
• Signing a document or digest is encrypting it with
the private key of the sender; verifying the document
is decrypting it with the public key of the sender.
• In a cryptosystem, we use the private and public keys
of the receiver; in digital signature, we use the
private and public key of the sender.

36
Signing the message itself in digital
signature

37
Signing the digest in a digital
signature

38
The End

39

You might also like