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

CH 3

This document provides an overview of public-key cryptography and message authentication techniques. It discusses approaches to message authentication like using conventional encryption or message authentication codes. It also covers secure hash functions and HMAC. For public-key cryptography, it outlines the basic principles and applications like encryption, digital signatures, and key exchange. It then describes the RSA and Diffie-Hellman public-key algorithms and the steps for RSA key generation and encryption/decryption.

Uploaded by

Fendy Rasid
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)
36 views

CH 3

This document provides an overview of public-key cryptography and message authentication techniques. It discusses approaches to message authentication like using conventional encryption or message authentication codes. It also covers secure hash functions and HMAC. For public-key cryptography, it outlines the basic principles and applications like encryption, digital signatures, and key exchange. It then describes the RSA and Diffie-Hellman public-key algorithms and the steps for RSA key generation and encryption/decryption.

Uploaded by

Fendy Rasid
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/ 48

Chapter 3

Public-Key Cryptography
and Message
Authentication
Outline
 Approaches to Message Authentication
 Secure Hash Functions and HMAC
 Public-Key Cryptography Principles
 Public-Key Cryptography Algorithms
 Digital Signatures
 Key Management
Message Authentication
 Message authentication is a mechanism or
service used to verify message’s integrity

 Ensure data received are exactly the same


as sent (no modification, insertion,
deletion or replay)

 Sender’s identity is valid


Authentication
• Requirements - must be able to verify that:
• Message came from apparent source or author,
• Contents have not been altered,
• Sometimes, it was sent at a certain time or
sequence.

• Protection against passive attack (encryption)

• Protection against active attack (falsification of data


and transactions)
Approaches to Message
Authentication

 Authentication Using Conventional Encryption


 Only the sender and receiver should share a key

 Message Authentication without Message Encryption


 An authentication tag is generated and appended to each
message
 Do not rely on encryption
 Message confidentiality is not provided
Common Cryptographic Techniques
for Message Authentication
 Message Authentication Code (MAC)
 an algorithm that uses secret key
 takes a variable-length message and a secret
key as input to produce authentication code

 Hash Function
 maps a variable-length message into a fixed
length hash value (message digest)
 a secure hash function must be combined with
a secret key
One-way HASH function
One-way HASH function...cont
 Secret value is added before the hash and removed
before transmission.
Secure HASH Functions
 Purpose of the HASH function is to produce a
”fingerprint”.
 Properties of a HASH function H :
1. H can be applied to a block of data at any size
2. H produces a fixed length output
3. H(x) is easy to compute for any given x.
4. For any given block x, it is computationally infeasible to
find x such that H(x) = h
5. For any given block x, it is computationally infeasible to
find with H(y) = H(x).
6. It is computationally infeasible to find any pair (x, y)
suchythat
 xH(x) = H(y)
Simple Hash Function

 One-bit circular shift on the hash value after each


block is processed would improve
Example 1
 Given a message like below. Find hash code
when using bit by bit XOR (Bitwise XOR)
function. The bit with bold is assume a first bit

01110 10001 10101 11110 11101 11111


Answer
Column 1 Column 2 Column 3 Column 4 Column 5

Block 1 0 1 1 1 0

Block 2 1 0 0 0 1

Block 3 1 0 1 0 1

Block 4 1 1 1 1 0

Block 5 1 1 1 0 1

Block 6 1 1 1 1 1

Hash Code 1 0 1 1 0

Message Digest/Hash Code = 10110


Example 2
 Given a message like below. Find hash code
when using bit by bit XOR (Bitwise XOR)
function. The bit 3 from the left is assume a
first bit.

01110 10001 10101 11110 11101


Answer
Column 1 Column 2 Column 3 Column 4 Column 5

Block 1 1 1 0 0 1

Block 2 0 0 1 1 0

Block 3 1 0 1 1 0

Block 4 1 1 1 0 1

Block 5 1 1 1 1 0

Hash Code 0 1 0 1 0

Message Digest/Hash Code = 10110


One Bit Circular Shift
 Initially set the n-bit hash value to zero
process each successive n bit block of data
as follows:
* rotate the current hash value to the
left by one bit
* XOR the block into hash value
 More secure when we implement hash
code by using CBC mode.
Cont’
 Message, M = X1, X2, X3, X4…… Xn

 Encrypted Message= Y1, Y2, Y3, Y4…… Yn

 Hash Code, C = Xn+1= X1,XORX3, X4…… Xn


Example 3
 Given a message like below. Find hash code
when one bit circular shift. The bold bit is
assume a first bit.

01110 10001 10101 11110 11101


Answer
C1 C2 C3 C4 C5
Initialization 0 0 0 0 0
Shift Left 1 Bit 0 0 0 0 0
Block 1 0 1 1 1 0
Hash Code 1 0 1 1 1 0
Shift Left 1 Bit 1 1 1 0 0
Block 2 1 0 0 0 1
Hash Code 2 0 1 1 0 1
Shift Left 1 Bit 1 1 0 1 0
Block 3 1 0 1 0 1
Hash Code 3 0 1 1 1 1
Shift Left 1 Bit 1 1 1 1 0
Block 4 1 1 1 1 0
Hash Code 4 0 0 0 0 0
Shift Left 1 Bit 0 0 0 0 0
Block 5 1 1 1 0 1
Hash Code 5 1 1 1 0 1

Message Digest/Hash Code = 11101


Example 4
By using hash algorithm 8 bits, encrypt this
message “ I LOVE U” with hashing as below:

Bit 1 - 4: Change (2,3)


Not (4)
Bit 5 - 8: Not (5)
Not (7)
Change (6,8) ; assume a=1;
Answer
27 26 25 24 23 22 21 20
I 0 0 0 0 1 0 0 1
L 0 0 0 0 1 1 0 0
O 0 0 0 0 1 1 1 1
V 0 0 0 1 0 1 1 0
E 0 0 0 0 0 1 0 1
U 0 0 0 1 0 1 0 1

22 0 0 0 1 0 1 1 0
19 0 0 0 1 0 0 1 1
21 0 0 0 1 0 1 0 1
9 0 0 0 0 1 0 0 1
31 0 0 0 1 1 1 1 1
15 0 0 0 0 1 1 1 1

Hashing Code = VSUI*O


Activity 2
By using hash algorithm 8 bits, encrypt this
message “ Good Morning” with hashing as below:

Bit 1 - 4: Change (1,3)


Change (2,4)
Not 2
Bit 5 - 8: Not (5)
Change (5,7)
Change (6,8) ; assume R=1;
Message Digest Generation Using SHA-1
SHA-1 Processing of single 512-Bit Block
Other Secure HASH functions

SHA-1 MD5 RIPEMD-160

Digest length 160 bits 128 bits 160 bits


Basic unit of 512 bits 512 bits 512 bits
processing

Number of steps 80 (4 rounds of 64 (4 rounds 160 (5 paired


20) of 16) rounds of 16)

Maximum message 264-1 bits


size
 
HMAC
 Use a MAC derived from a cryptographic hash code,
such as SHA-1.
 Motivations:
 Cryptographic hash functions executes faster in software
than encryptoin algorithms such as DES
 Library code for cryptographic hash functions is widely
available
 No export restrictions from the US
HMAC Structure
Public-Key Cryptography Principles
 The use of two keys has consequences in: key
distribution, confidentiality and authentication.
 The scheme has six ingredients (see Figure 3.7)
 Plaintext
 Encryption algorithm
 Public and private key
 Ciphertext
 Decryption algorithm
Encryption using Public-Key System
Authentication using Public-Key System
Applications for Public-Key Cryptosystems
 Three categories:
 Encryption/decryption: The sender encrypts a message with
the recipient’s public key.

 Digital signature: The sender ”signs” a message with its


private key.

 Key exchange: Two sides cooperate two exhange a session


key.
Requirements for Public-Key Cryptography
1. Computationally easy for a party B to generate a
pair (public key KUb, private key KRb)
2. Easy for sender to generate ciphertext:
3. Easy for the receiver to decrypt ciphertect using
private key:

C  E KUb (M )

M  DKRb (C )  DKRb [ EKUb ( M )]


Requirements for Public-Key
Cryptography...cont
4. Computationally infeasible to determine private key
(KRb) knowing public key (KUb)
5. Computationally infeasible to recover message M,
knowing KUb and ciphertext C
6. Either of the two keys can be used for encryption,
with the other used for decryption:

M  DKRb [ EKUb ( M )]  DKUb [ EKRb ( M )]


Public-Key Cryptographic
Algorithms
 RSA and Diffie-Hellman
 RSA - Ron Rives, Adi Shamir and Len Adleman at
MIT, in 1977.
 RSA is a block cipher
 The most widely implemented
 Diffie-Hellman
 Echange a secret key securely
 Compute discrete logarithms
The RSA Algorithm – Key
Generation

1. Select p,q p and q both prime


2. Calculate n = p x q
3. Calculate  ( n)  ( p  1)( q  1)
4. Select integer e gcd( (n), e)  1; 1  e   (n)
1
5. Calculate d d  e mod  (n)
6. Public Key KU = {e,n}
7. Private key KR = {d,n}
Example of RSA Algorithm
The RSA Algorithm - Encryption

 Plaintext: M<n

 Ciphertext: C = Me (mod n)
The RSA Algorithm - Decryption

 Ciphertext: C

 Plaintext: M = Cd (mod n)
Example 5
 Perform the encryption and decryption
using the RSA algorithm based on the
given value.

p=11, q=13, e=11,M=9


Answer
n=p*q We do not value of d, so.
n=11*13
1=10 – 1(9)
n=143
1=1-10 – [11-10(1)](9)
1=10-11(9)+10(9)
Ф(n) = (p-1)*(q-1)
1=10(1+9) – 11(9)
Ф(n) = (11-1)*(13-1)
Ф(n) = 10*12 1=10(10)-11(9)
Ф(n) =120 1=[120-11(10)](10)-11(9)
1=120(10)-11(100)-11(9)
gcd (Ф(n), e) 1=120(10)-11[100+9]
gcd (120,11) 1=120(10)-11[109]
SO, d=-109 ≈(120-109)mod 672
10=11(10) +10 ≈ 11 mod 672
11=10(1) +1
10=1(9) +1
KU={11,143)
1=1(1)+0
KR={11,143)
Answer Con’t
C=Me (mod n)
C=911 mod 143
=[91 mod 143 x 92 mod 143 x 98 mod 143] mod 143
=[9 x 81 x 3] mod 143
=2187 mod 143
= 42

P=Cd (mod n)
P=4211 mod 143
=[421 mod 143 x 422 mod 143 x 424 mod 143 x 424 mod 143x ] mod 143
=[42 x 48 x 16 x16] mod 143
=516096 mod 143
=9
Diffie-Hellman Key Echange
Diffie Hellman Key Exchange
 First published public-key algorithm
(1976)
 Purpose is to allow two users to exchange
a private key
 Diffie-Hellman depends on the difficulty in
computing discrete logarithms (inverse
exponentials)
 Choose a prime p, consider the sequence
 a mod p, a2 mod p, a3 mod p, … ap-1 mod
p
Con’t
 If these are distinct and a permutation of
1 … p-1, then
1. b = ai mod p then ‘i’ is the discrete
logarithm of b
2. a is called a primitive root of p
 Diffie-Hellman fig 3.10
Example 6
Using a Diffie Hellman scheme with a common prome
q=11 and primitive root, σ =2.

a) If user A has public key YA =9, What is A’s private key XA

YA =σ XA
mod q
= 2XA mod 11
= 26 mod 11
XA = 6
Example 6, Con’t
b) If user B has public key YB =3, What is the
shared key K.

Serect Key = K = (YB ) XA


mod q
= 36 mod 11
= 729 mod 11
=3
Other Public-Key Cryptographic
Algorithms

 Digital Signature Standard (DSS)


 Makes use of the SHA-1
 Not for encryption or key echange
 Elliptic-Curve Cryptography (ECC)
 Good for smaller bit size
 Low confidence level, compared with RSA
 Very complex
Key Management Public-Key Certificate Use

You might also like