Chapter 5 (Secure Messaging) - 1
Chapter 5 (Secure Messaging) - 1
Course Teacher:
Sultana Jahan Soheli
Assistant Professor
Department of Information & Communication
Engineering
Topic Contents
5.1 Introduction
5.2 Symmetric Data Encryption with Private Key
5.2.1 Digital Encryption Standard
5.2.2 Triple DES Encryption
5.2.3 Advanced Encryption Standard
5.3 Public Key Encryption
5.3.1 RSA Encryption Scheme
5.3.2 Diffie-Hellman Key Exchange Algorithm
5.3.3 Combining RSA with DES
5.4 Public Key Certifying Authority
5.5 Digital Signature
E-Commerce and E- Governance
Lecture 5
SECURE MESSAGING
4
Public-Key Cryptography
• probably most significant advance in the 3000
year history of cryptography
• uses two keys – a public & a private key
• asymmetric since parties are not equal
• uses clever application of number theoretic
concepts to function
• complements rather than replaces private key
crypto
5
Public-Key Cryptography
• public-key/two-key/asymmetric cryptography
involves the use of two keys:
– a public-key, which may be known by anybody,
and can be used to encrypt messages, and verify
signatures
– a private-key, known only to the recipient, used
to decrypt messages, and sign (create) signatures
• is asymmetric because
– those who encrypt messages or verify signatures
cannot decrypt messages or create signatures
6
Public-Key Cryptography
7
Why Public-Key Cryptography?
• developed to address two key issues:
– key distribution – how to have secure
communications in general without having to trust
a KDC with your key
– digital signatures – how to verify a message
comes intact from the claimed sender
• public invention due to Whitfield Diffie &
Martin Hellman at Stanford Uni in 1976
– known earlier in classified community
8
Public-Key Characteristics
• Public-Key algorithms rely on two keys with
the characteristics that it is:
– computationally infeasible to find decryption key
knowing only algorithm & encryption key
– computationally easy to en/decrypt messages
when the relevant (en/decrypt) key is known
– either of the two related keys can be used for
encryption, with the other used for decryption (in
some schemes)
9
Public-Key Cryptosystems
10
Public-Key Applications
• can classify uses into 3 categories:
– encryption/decryption (provide secrecy)
– digital signatures (provide authentication)
– key exchange (of session keys)
• some algorithms are suitable for all uses,
others are specific to one
11
Security of Public Key Schemes
• like private key schemes brute force exhaustive
search attack is always theoretically possible
• but keys used are too large (>512bits)
• security relies on a large enough difference in
difficulty between easy (en/decrypt) and hard
(cryptanalyse) problems
• more generally the hard problem is known, its just
made too hard to do in practise
• requires the use of very large numbers
• hence is slow compared to private key schemes
12
Modular Arithmetic Operations
• is 'clock arithmetic'
• uses a finite number of values, and loops back
from either end
• modular arithmetic is when do addition &
multiplication and modulo reduce answer
• can do reduction at any point, ie
a+b mod n = [a mod n + b mod n] mod n
13
Modulo 8 Addition Example
+ 0 1 2 3 4 5 6 7
0 0 1 2 3 4 5 6 7
1 1 2 3 4 5 6 7 0
2 2 3 4 5 6 7 0 1
3 3 4 5 6 7 0 1 2
4 4 5 6 7 0 1 2 3
5 5 6 7 0 1 2 3 4
6 6 7 0 1 2 3 4 5
7 7 0 1 2 3 4 5 6
14
5.3.1 RSA Encryption Scheme
Currently the most popular public key encryption method was proposed by Rivest,
Shamir and Adleman in 1978 and is called the RSA scheme.
It is a block cipher in which the plain text and ciphertext and keys are usually
1024 bits long (around 309 decimal digits). It can, however, work with any block size
with integers 0 to (n - 1) for some n. The encryption and decryption in RSA is
performed as shown below.
The operation Me mod n and Cd mod n are known as modular exponentiation. The
public key is (n, e) and the private key is (n, d).
Given n we have to find a-pair e, d which satisfies the encryption and decryption
schemes.
16
Euler Totient Function ø(n)
when doing arithmetic modulo n
complete set of residues is: 0..n-1
reduced set of residues is those numbers (residues)
which are relatively prime to n
eg for n=10,
complete set of residues is {0,1,2,3,4,5,6,7,8,9}
reduced set of residues is {1,3,7,9}
number of elements in reduced set of residues is
called the Euler Totient Function ø(n)
17
Euler Totient Function ø(n)
to compute ø(n) need to count number of
residues to be excluded
in general need prime factorization, but
for p (p prime) ø(p) = p-1
for p.q (p,q prime) ø(pq) =(p-1)x(q-
1)
eg.
ø(37) = 36
ø(21) = (3–1)x(7–1) = 2x6 = 12
18
Euler's Theorem
a generalisation of Fermat's Theorem
aø(n) = 1 (mod n)
for any a,n where gcd(a,n)=1
eg.
a=3;n=10; ø(10)=4;
hence 34 = 81 = 1 mod 10
a=2;n=11; ø(11)=10;
hence 210 = 1024 = 1 mod 11
19
RSA Key Setup
21
Why RSA Works
• because of Euler's Theorem:
• aø(n)mod N = 1
– where gcd(a,N)=1
• in RSA have:
– N=p.q
– ø(N)=(p-1)(q-1)
– carefully chosen e & d to be inverses mod ø(N)
– hence e.d=1+k.ø(N) for some k
• hence :
Cd = (Me)d = M1+k.ø(N) = M1.(Mø(N))q = M1.
(1)q = M1 = M mod N
22
RSA Example
1. Select primes: p=17 & q=11
2. Compute n = pq =17×11=187
3. Compute ø(n)=(p–1)(q-1)=16×10=160
4. Select e : gcd(e,160)=1; choose e=7
5. Determine d: de=1 mod 160 and d < 160
Value is d=23 since 23×7=161= 10×160+1
6. Publish public key KU={7,187}
7. Keep secret private key KR={23,17,11}
23
RSA Example cont
• sample RSA encryption/decryption is:
• given message M = 88 (nb. 88<187)
• encryption:
C = 887 mod 187 = 11
• decryption:
M = 1123 mod 187 = 88
24
RSA Key Generation
• users of RSA must:
– determine two primes at random - p, q
– select either e or d and compute the other
• primes p,q must not be easily derived from
modulus N=p.q
– means must be sufficiently large
– typically guess and use probabilistic test
• exponents e, d are inverses, so use Inverse
algorithm to compute the other
25
5.3.2 Diffie-Hellman Key Exchange Algorithm
• first public-key type scheme proposed
– For key distribution only
• by Diffie & Hellman in 1976 along with the
exposition of public key concepts
– note: now know that James Ellis (UK CESG)
secretly proposed the concept in 1970
• is a practical method for public exchange of a
secret key
• used in a number of commercial products
26
Diffie-Hellman Setup
• all users agree on global parameters:
– large prime integer or polynomial q
– α a primitive root mod q
• each user (eg. A) generates their key
– chooses a secret key (number): xA < q
xA
– compute their public key: yA = α mod q
• each user makes public that key yA
27
Diffie-Hellman Key Exchange
• shared session key for users A & B is K:
xB
K = y A mod q (which B can compute)
xA
K = y B mod q (which A can compute)
(example)
• K is used as session key in private-key encryption
scheme between Alice and Bob
• if Alice and Bob subsequently communicate, they will
have the same key as before, unless they choose new
public-keys
• attacker needs an x, must solve discrete log
28
Diffie-Hellman Example
• users Alice & Bob who wish to swap keys:
• agree on prime q=353 and α=3
• select random secret keys:
– A chooses xA=97, B chooses xB=233
• compute public keys:
– yA=397 mod 353 = 40 (Alice)
– yB=3233 mod 353 = 248 (Bob)
• compute shared session key as:
xA 97
KAB= yB mod 353 = 248 = 160 (Alice)
xB 233
KAB= yA mod 353 = 40 = 160 (Bob)
29
Diffie-Hellman Example
• users Alice & Bob who wish to swap keys:
• agree on prime q=353 and α=3
• select random secret keys:
– A chooses xA=97, B chooses xB=233
• compute public keys:
– yA=397 mod 353 = 40 (Alice)
– yB=3233 mod 353 = 248 (Bob)
• compute shared session key as:
xA 97
KAB= y B mod 353 = 248 = 160 (Alice)
xB 233
KAB= y A mod 353 = 40 = 160 (Bob)
30
31
5.3.3 Combining RSA with DES
We saw that 3DES is computationally simple to implement and fast whereas RSA
is computationally complex.
32
5.4 PUBLIC KEY CERTIFYING AUTHORITY
In RSA an entity A has to know the public key of another entity B to be able to
send encrypted information to it.
A will not know this and all communications from A to B henceforth can be
decrypted by C. Thus, A must be sure that the public key it gets from B does
indeed belongs to B.
34
•Suppose A wants its public key certificate. It applies to the certifying authority
with all relevant documents. If the authority is satisfied, it will approve the
certificate. It will be encrypted with the authority’s private key and sent to A. It also
maintains a list of public keys which are revoked [See Table 5.2 (b) for format]. We
explain later why a public certificate may be revoked.
•This certificate can be decrypted using the public key of the certifying
authority. This certificate is an important document which A can intimate to any
other entity which wants to have e-commerce transactions with A.
• B can decrypt it using the public key of the certifying authority. The fact that
the certificate is encrypted with certifying authority's private key gives B the
assurance that the public key of A is indeed given by the certifying authority and is
not a fake.
•From the decrypted certificate B can extract A's public key and other details
such as validity period of the certificate and whether it is currently valid. B is now
confident that it can transact business with A. Before this B should also send its
public key certificate to A following a procedure similar to the one followed by A.
35
A public key may be revoked by a certifying authority for several reasons
such as bankruptcy of a company or on the request of the company if it doubts
that its private key is compromised.
36
5.5 DIGITAL SIGNATURE
So far we have described the methods of encrypting documents exchanged
between entities participating in e-commerce.
First, the letter head of a business, its seal and the signature of a person in the
document convinces the recipient of the authenticity of the document. Second, the
signature physically appears following the text and this ties the 'signature to the
typed matter in the document. In a legal document, every page is signed and every
correction is also signed. We have to mimic the physical signature with an -electronic
equivalent. There are two important requirements to be met by a digitally signed
electronic document.
1.A receiver R receiving a document from a sender S has to be sure it is from S.
2. The signature should be tied to the document sent by S. This will ensure that S
cannot. later claim that he or she never sent the document to R, in other words S
cannot repudiate his or her communication.
These requirements are met by the following scheme (See also Figure 5.12).
37
Step 1: Before starting a transaction, S and R exchange their public key
certificates issued by a certifying authority. This is necessary to meet
condition 1 mentioned earlier.
Step 3: R decrypts DE using its own private key and gets the original
document D.
Step 5: R decrypts H(D) E using the public key of S getting back H(D).
38
39
Hash Functions
• A hash function is like a MAC
• condenses arbitrary message to fixed size
h = H(M)
• usually assume that the hash function is public and
not keyed
-note that a MAC is keyed
• hash used to detect changes to message
• can use in various ways with message
• most often to create a digital signature
40
Hash Functions & Digital Signatures
41
Requirements for Hash Functions
1. can be applied to any size message M
2. produces a fixed-length output h
3. is easy to compute h=H(M) for any message M
4. given h is infeasible to find x s.t. H(x)=h
• one-way property
5. given x is infeasible to find y s.t. H(y)=H(x)
• weak collision resistance
6. is infeasible to find any x,y s.t. H(y)=H(x)
• strong collision resistance
42
Simple Hash Functions
• are several proposals for simple functions
• based on XOR of message blocks
-divide the message into equal size blocks
-perform XOR operation block by block
-final output is the hash
• not very secure
• need a stronger cryptographic function (next
chapter)
43
THANKS…
44
44