lec3
lec3
Cryptography
LEC3
Introduction
2
3
Applications for Public-Key Cryptosystems
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
C=p^e(mod n)
C=5^13(mod 77)
C=26
Example (continued)
P= C^d(mod n)
P= 26^37(mod 77)
P=5
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
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
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