02 Cryptographic Tools
02 Cryptographic Tools
Assignment 1/3
Quiz 0/4
Project 0/1
MSE 0/1
ESE 0/1
Outline
• Cryptographic Tools
• Confidentiality with Symmetric Encryption
• Message Authentication and Hash Functions
• Internal Structure of DES
• Public-Key Encryption
• Digital Signatures and Key Management
• Random and Pseudorandom Numbers
Objective
• Explain the basic operation of symmetric block encryption algorithms.
• Compare and contrast block encryption and stream encryption.
• Discuss the use of secure hash functions for message authentication.
• List other applications of secure hash functions.
• Explain the basic operation of asymmetric block encryption algorithms.
• Present an overview of the digital signature mechanism and explain the concept
of digital envelopes.
• Explain the significance of random and pseudorandom numbers in cryptography
Cryptographic Tools
• Cryptographic algorithms are the important elements in security services
1110010 0110100
0110100 1110010
1000110 1000110
Kerkhoff’s principle
The adversary knows all details about a cryptosystem except the secret key.
• X = plaintext
• Y = ciphertext/ encrypted text
• K = secret key
• E = encryption algorithm
• D = decryption algorithm
• Both E and D are known to public
Without knowledge of the key it would be difficult for the attacker to decrypt.
10
Cryptography Classifications
1. Types of operations
• Substitution
• Transposition
• Combinations are called product ciphers
2. The number of key used
• Symmetric
• Asymmetric
3. The way in which the plaintext is processed
• Block ciphers
• Stream ciphers
Substitution:
Caesar Cipher/ Shift Cipher/ Additive Cipher
Plain: a b c d e f g h i j k l m n o p q r s t u v w x y z
Cipher: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
12
Caesar Cipher
13
Transposition: Railfence cipher
• A transposition cipher rearranges the plaintext letters according to a secret
transformation defined by the key.
• The simplest example is railfence cipher, in which the plaintext is written in rows of
n-letter blocks (the number of columns, n is the key) and then the ciphertext is
read in columns
• Example:
• Plaintext: TRANSPOSITIONCIPHERX
• Key is: 5
• Re-write as rows of 5-letter blocks:
TRANS
POSIT
IONCI
PHERX
• Example:
• Plaintext: TRANSPOSITIONCIPHER
• Key is “SECRET”, so re-write as rows of 6-letter blocks:
SECRET CEERST
521436 123456
TRANSP ARSNTP
OSITIO ISITOO
NCIPHE ICHPNE
R R
• Cipher text: AIIRSCSIHNTPTONRPOE
Transposition: Railfence cipher
• Modified Example :
• Plaintext: TRANSPOSITIONCIPHER
• Key is “SECRET”, so re-write as rows of 6-letter blocks:
SECRET CEERST
521436 123456
TRANSP ARSNTP
OSITIO ISITOO
NCIPHE ICHPNE
RABCDE BADCRE
• Ciphertext: AIIB RSCA SIHD NTPC TONR POEE
Confidentiality by Symmetric Encryption
• Keypoints for symmetric encryption
• Sender and recipient share a common key
• All classical/ historical encryption algorithms are symmetric
• Anybody having the key can carry out encryption/ decryption
17
Types of Attacks
Types of Attacks
• Opponent’s goal is to break cryptosystem: adversary
• Assume adversary knows the algorithm but not key, so may attack like
• A ciphertext only: when an attacker has a quantity of ciphertext
• Goal is to recover the plaintext or the key
• A known plaintext: when an attacker has a quantity of ciphertext and its
corresponding plaintext
• Goal is to recover the key
• A chosen plaintext: Attacker can generate ciphertext w.r.t plaintext;
supplied by the attacker (Public keys available)
• Goal is to recover the key
• A chosen ciphertext: Ciphertext chosen by attacker with corresponding
decrypted plaintext with the Key
• Goal is to recover the key
Cryptanalysis
• Cryptanalysis is the study of breaking ciphers (also called code breaking or
cracking) or reading encrypted messages without knowledge of the key
• Goals:
• Decrypt a message
• Recover the key
• Arab/Iraqi scientist Abu Yusuf Yaqub ibn Ishaq al-Kindi published his book
“Risalah fi Istikhraj al-Mu’amma” (A Manuscript on Deciphering Cryptographic
Messages), which contains the first ever published description of how to crack
simple substitution ciphers
• Example
Example: Transposition Cipher
• Rearrange letters in plaintext to produce ciphertext
6 0.0660 25 0.0430
The Result
• Most probable keys, based on :
• i = 6, (i) = 0.0660
• plaintext EBIIL TLOLA
• i = 10, (i) = 0.0635
• plaintext AXEEH PHKEW
• i = 3, (i) = 0.0575
• plaintext HELLO WORLD
• i = 14, (i) = 0.0535
• plaintext WTAAD LDGAS
• Only English phrase is for i = 3
• That’s the key (3 or ‘D’)
Other English language features
• Digram frequencies
• Common digraphs: EN, RE, ER, NT, TH
• Trigram frequencies
• Common trigrams: THE, ING, THA, ENT
38
ATM Introduction
• Automated Teller Machines (ATM) have become ubiquitous and let you
withdraw money from your bank account 24 hrs a day and 7 days a week
with your ATM card. The ATM card constitutes of two things:
39
Working Principle of ATM
Leased Line
• After the customer enters an ATM counter, he inserts his ATM card into the machine
and types his PIN on a numeric keypad.
• The Cash dispenser reads the card number from the magnetic strip and the PIN that
he has typed and sends them to the ATM Server.
• The ATM Server verifies the PIN against the card number with the help of the PIN
machine and sends a positive or negative acknowledgement to the Cash dispenser.
• At this point, the customer is authenticated and can use his account.
41
ATM PIN Security
• The security of the ATM PIN is a critical element in the entire process.
• There are two ways that an attacker could try to get the ATM PIN:
He could either sniff the network when the Cash dispenser is transmitting
the PIN to ATM Server or
He could compromise the ATM Server and PIN machine to extract the PIN of
a user.
42
ATM PIN Security
• To prevent the sniffing of the PIN during the transmission, PIN is encrypted
using DES or 3DES encryption algorithm and then transmitted from Cash
dispenser to ATM Server.
• The shared secret key is stored in Cash dispenser as well as in ATM
Server. This application stores the shared DES key in encrypted form
using vendor’s proprietary algorithm (e.g. ACI ATM software).
• The system splits each customer’s PIN into two parts and stores them in two
different machines. So even if one of the machines is compromised, still PIN
will be secured.
• Now the problem is how to split the PIN securely into two parts?
• Plus have to keep in mind that customer can always change his PIN.
43
ATM PIN Security
• An algorithm has been designed that allows the customer’s PIN to be split and also
allows the customer to change his PIN.
• Let the customer PIN be a and let’s say it is split into two parts b and c .
a=b+c
b is a variable part of the PIN and is called PIN Offset. The PIN Offset is stored in
the ATM Server.
c is the constant part of the PIN and is called Natural PIN. The Natural PIN is
generated in the PIN machine each time.
• How does the PIN Machine generate the constant c for each customer and yet keep
it a secret?
• Remember that the ATM card number of a customer is unique. So, the constant
part c can be a cryptographic function of the card number.
c = f (card # ) 44
ATM PIN Security
• There are different methods to derive a constant number from a card number.
• Derive it using the DES algorithm
• The PIN machine stores a DES key in its Electrically Erasable Programmable
Read Only Memory (EEPROM). This key is used to encrypt the card number
and generate DES encrypted value.
• The DES key is stored in the EEPROM of the machine. EEPROM is chip
which is fixed on machine’s circuit board. To retrieve the key, one has to
open the box case, remove the circuit board from the box, connect the
EEPROM to a EEPROM reader to get the key. So physical security is very
important for ATM Server room.
45
ATM PIN Security
• Card # + DES key = DES encrypted value
• This DES encrypted value is then converted into decimalized form and
the first four digits of the value are taken. That is the Natural PIN, c
• Summarize :
DES encrypted value → Decimalized value → First 4 digits of the value = c
• The Natural PIN, the constant part, c is not stored anywhere in the entire
process.
• Hence, Nobody can get the PIN by compromising the PIN machine.
• The valid card number, the PIN Offset b of that card and the PIN typed by the customer are sent to
the PIN machine.
• Now the PIN machine generates the Natural PIN c from the card no., adds it with PIN Offset b and
generates the true Customer PIN a .
• Then it compares the actual Customer PIN a with the customer supplied PIN. If the two of them
matched then it sends positive acknowledgement to ATM Server indicating that the customer is
authenticated.
• Note that in this process, the Natural PIN never leaves the tamper proof PIN Machine, and the PIN
machine does not have to store individual PINs of all the users. Instead, it securely stores the DES key
for generating the Natural PIN from each user’s card number.
47
Symmetric Block Encryption
Algorithms
Symmetric Block Encryption Algorithms
• Process the plaintext in to fixed-size series of blocks
• Produces the equal size of chipertext block against plaintext block
• For example, it says that the IP replaces the first bit of the original plain text block
with the 58th bit of the original plain text, the second bit with the 50th bit of the
original plain text block, and so on.
Data Encryption Standard 10/10
Practical Security Issues
• Typically, symmetric encryption employ the fixed size of data unit 64-bit, 128 bit
etc. (block cipher)
• Email, network packet, database record are broken down into series of fixes length data unit
• A simplest approach to encrypt multiple-block is electronic codebook (ECB) mode,
b bits data with same key.
• b=128, plaintext length of nb is divided into n b-bit blocks (P1, P2…Pn), cipher text (C1, C2…)
• However, the reordering may alter the meaning of the overall data
sequence.
Because messages may be any size and the message authentication code is a small fixed
size, there must theoretically be many messages that result in the same MAC. However, it
should be infeasible in practice to find pairs of such messages with the same MAC. This is
known as collision resistance
Limitations of MAC
• Establishment of Shared Secret
• It can provide message authentication among predefined legitimate users
who have shared key.
• This requires establishment of shared secret prior to use of MAC.
• Inability to Provide Non-Repudiation
• MAC technique does not provide a non-repudiation service.
• If the sender and receiver get involved in a dispute over message
origination, MACs cannot provide a proof that a message was indeed
sent by the sender.
• Though no third party can compute the MAC
• Still sender could deny having sent the message and claim that the
receiver forged it, as it is impossible to determine which of the two
parties computed the MAC.
One way Hash Functions
• An alternative to the message authentication
code is the one-way hash function.
Still cannot provide a proof that a message was indeed sent by the sender
Message Authentication using HASH function
• It provides a digital signature as well as message authentication; and it does not require the distribution of keys
to communicating parties
• These two approaches have an advantage over approaches that encrypt the
entire message in that less computation is required
Message Authentication using HASH function
2. Each user places one of the two keys in a public register or other accessible
file. This is the public key. The companion key is kept private, each user
maintains a collection of public keys obtained from others.
• If Bob wishes to send a private message to Alice, Bob encrypts the message
using Alice’s public key.
• When Alice receives the message, she decrypts it using her private key. No
other recipient can decrypt the message because only Alice knows Alice’s
private key.
Public Key Encryption
Public Key Authentication
• In broad terms, we can classify the use of public-key cryptosystems into three
categories:
• Digital signature
• Symmetric key distribution
• Encryption of secret keys
Asymmetric Encryption Algorithms
• RSA (Rivest, Shamir, Adleman)
• One of the first public-key scheme developed at MIT in 1977
• Only widely accepted public-key encryption algorithm
• Given tech advances need 1024+ bit (300 digits) keys considered strong
• Block cipher
• Exponentiatial cipher
• Relies on the difficulty of determining the number of relatively prime to a large
integer n
Background
• Totient function (n) a) 7 and 9
The factors of 7 are 1 and 7
• Number of positive integers less The factors of 9 are 1, 3, and 9
than n 1 is the only common factor of 7 and 9
• and relatively prime to n HCF of (7, 9) = 1
Thus, (7, 9) is relatively prime because only
• Relatively prime means with no
1 is a common factor.
factors in common with n
gcd(7,9) = 1
a) 8 and 10
• Example: (10) = 4 The factors of 8 are 1, 2, 4, and 8
The factors of 10 are 1, 2, 5, and 10
• 1, 3, 7, 9 are relatively prime to 10 1 and 2 are the common factors of 8 and
10.
HCF (8, 10) = 2
• Example: (21) = 12 Thus, (8,10) is not relatively prime.
gcd(8,10) != 1
• 1, 2, 4, 5, 8, 10, 11, 13, 16, 17, 19,
20 are relatively prime to 21
Algorithm
• 0753 mod 77 = 35
• 0453 mod 77 = 09
• 1153 mod 77 = 44
• 1153 mod 77 = 44
• 1453 mod 77 = 49
• Alice sends 35 09 44 44 49
Example: Integrity/Authentication
• Bob receives 35 09 44 44 49
• Bob uses Alice’s public key, e = 17, n = 77, to decrypt message:
• 3517 mod 77 = 07
• 0917 mod 77 = 04
• 4417 mod 77 = 11
• 4417 mod 77 = 11
• 4917 mod 77 = 14
• Bob translates message to letters to read HELLO
• Alice sent it as only she knows her private key, so no one else could have
enciphered it
• If (enciphered) message’s blocks (letters) altered in transit, would not decrypt
properly
Example: Confidentiality + Integrity
• Alice wants to send Bob message HELLO both enciphered and authenticated
(integrity-checked)
• Alice’s keys: public (17, 77); private: 53
• Bob’s keys: public: (37, 77); private: 13
• Alice sends 07 37 44 44 14
Public Key Algorithms
• Diffie-Hellman key exchange algorithm
• only allows exchange of a secret key
• The purpose is that two users securely reach agreement about a shared
secret (key) for symmetric encryption.
• Digital Signature Standard (DSS)
• provides only a digital signature function with SHA-1
• Unlike RSA, it cannot be used for encryption or key exchange.
• Elliptic curve cryptography (ECC)
• Generally, for cryptography, public-key encryption and digital signatures uses
RSA (but bit length increased, memory, load effects the real-time applications)
• new, security like RSA, but with much smaller keys
Public Key Algorithms
Digital Signature
• Public-key encryption can be used for authentication
• E.g. Bob uses a secure hash function, such as SHA-512, to generate a
hash value for the message and then encrypts the hash code with his
private key, creating a digital signature.
• Digital signature does not provide confidentiality. That is, the message
being sent is safe from alteration but not safe from eavesdropping.
• Because any observer can decrypt the message by using the
sender’s public key.
• The RA may appear to the client as a CA, but they do not actually sign
the certificate that is issued.