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

Cryptography Lecture

Uploaded by

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

Cryptography Lecture

Uploaded by

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

CSCD604: Distributed Systems

Session 3 – Security & Cryptography

By
Solomon Mensah (PhD)

College of Education
School of Continuing and Distance Education
2014/2015 – 2016/2017
Agenda
• Cryptography vs Security
• Authentication vs Authorization
• Types of Cipher
• Key Distribution
• Message Integrity
Cryptography ≠ Security
• Cryptography may be a component of a secure system
• Adding cryptography may not make a system secure
• Cryptography or cryptology is the practice and study of
techniques for secure communication in the presence of
third parties called adversaries.
• Security is the state of being free from danger or threat.
Significance of Cryptography
• Confidentiality
– others cannot read contents of the message
• Integrity
– verify that message has not been modified
• Availability
– message should be available to receiver
• Nonrepudiation
– sender should not be able to falsely deny that a message was sent
• Authentication
– validates or confirms a user
– determine origin of message
• Authorization
– user permission to access a specific resource or function
Authentication vs Authorization
Confidentiality: Encryption
• Plaintext (cleartext) message P
• Encryption E(P)
• Produces Ciphertext, C = E(P)
• Decryption, P = D(C)
• Cipher = cryptographic algorithm
Types of Ciphers
• Symmetric/secret key algorithm
– –Shared key
C=EK(P) P = DK(C)
– –Key length → difficulty of attack
• Asymmetric/Public key algorithm
– –Key pair: private key (k) & a shared public key (K)
C = Ek(P) P = DK(C)
C = EK(P) P = Dk(C)
Key Distribution
• Secure key distribution is the biggest problem with
symmetric cryptography
Distributing Keys
• Manual: pre-shared keys
– –Initial configuration, out of band (send via USB key, recite, …)
• Trusted third party
– –Knows all keys
– –Alice creates a session key
– –Encrypts it with her key –sends to Trent
– –Trent decrypts it and sends it to Bob
– –Alternatively: Trent creates a session key – encrypts it for Alice & for Bob
• Public key cryptography
– –Alice encrypts a message with Bob’s public key
– –Only Bob can decrypt
• Diffie-Hellman
• Hybrid cryptosystems
Diffie-Hellman Key Exchange
• Key distribution algorithm
– –First algorithm to use public/private “keys”
– –Uses a one-way function
• Based on difficulty of computing discrete logarithms in a
finite field compared with ease of calculating
exponentiation
– –Eavesdroppers cannot compute this
Diffie-Hellman: Introduction
• Discovered by Whitfield Diffie and Martin Hellman

• Diffie-Hellman key agreement protocol


– Exponential key agreement
– Allows two users to exchange a secret key
– Requires no prior secrets
– Real-time over an untrusted network
Diffie-Hellman: Introduction
• Security of transmission is critical for many
network and Internet applications
• Requires users to share information in a way that
others can’t decipher the flow of information

“It is insufficient to protect ourselves with laws; we


need to protect ourselves with mathematics.”
-Bruce Schneier
Diffie-Hellman: Introduction
• Based on the difficulty of computing discrete
logarithms of large numbers.

• No known successful attack strategies

• Requires two large numbers, one prime (P), and


one generator (G), a primitive root of P
Diffie-Hellman: Implementation
• P and G are both publicly available numbers
– P is at least 512 bits/ 64 bytes
• Users pick private values ‘a’ and ‘b’
• Compute public values
– x = ga mod p à Sender
– y = gb mod p à Receiver
• Public values x and y are exchanged
Diffie-Hellman: Implementation

• Compute shared, private key


– ka = ya mod p à Sender
– kb = xb mod p à Receiver

• Algebraically it can be shown that ka = kb


– Users now have a symmetric secret key to encrypt
Example
• Two Internet users, Alice and Bob wish to have a
secure conversation.
– They decide to use the Diffie-Hellman protocol
Example
• Bob and Alice are unable to talk on the untrusted
network.

–Who knows who’s listening?


Example

• Alice and Bob get public numbers


– P = 23, G = 9

• Alice and Bob compute public values


– X = 94 mod 23 => 6561 mod 23 = 6
– Y = 93 mod 23 => 729 mod 23 = 16

• Alice and Bob exchange public numbers


Example

• Alice and Bob compute symmetric keys


– ka = ya mod p => 164 mod 23 = 9
– kb = xb mod p => 63 mod 23 = 9
• Alice and Bob now can talk securely!
Try this example
• Shared details => g = 3, p = 17
• Sender picks a random number of 8 and receiver picks
a random number of 6
• Show how Diffie-Hellman algorithm can provide a
secure means of key exchange between sender and
receiver.
Diffie-Hellman: Applications

• Diffie-Hellman is used in many protocols, namely


– Secure Sockets Layer (SSL)/Transport Layer Security (TLS)
– Secure Shell (SSH)
– Internet Protocol Security (IPSec)
– Public Key Infrastructure (PKI)
• Authenticated Diffie-Hellman Key Agreement (1992)
– Defeats middleperson attack
• Diffie-Hellman POP Algorithm
– Enhances IPSec layer
• Diffie-Hellman continues to play large role in secure protocol
creation
Assignment I
• Write the step-by-step pseudocode for
– Diffie-Hellman key exchange algorithm
– RSA key exchange algorithm
• Compare and contrast between Diffie-
Hellman and RSA key exchange algorithms
• Write a program (in any programming
language) to implement Diffie-Hellman and
RSA key exchange algorithms
Hybrid Cryptography
• Hybrid Cryptography:
– a mode of encryption that merges two or more encryption
systems
• It incorporates a combination of asymmetric and
symmetric encryption to benefit from the strengths of
each form of encryption
– These strengths are respectively defined as speedy and security.
• Hybrid encryption is considered a highly secure type of
encryption as long as the public and private keys are fully
secured.
Hybrid Cryptosystem
• Session key: randomly-generated key for one
communication session
• Use a public key (or asymmetric) algorithm to send the
session key
• Use a symmetric (or secret/private key) algorithm to
encrypt data with the session key
Public key algorithms are almost never used to encrypt messages
–MUCH slower; vulnerable to chosen-plaintext attacks
–RSA-2048 approximately 55x slower to encrypt and 2,000x slower to decrypt than
AES-256
Message Integrity
Hash functions
• Hash function converts the plaintext into a message digest or
hash.
• Hash function is primarily used for comparison
– Currently, being used for encryption.
• Passwords used in facebook, twitter, gmail, etc
• All passwords in the database must be hashed and not in
plaintext
• Examples of Hash functions are
– MD2, MD5, SHA-1, SHA-256, SHA-512, CRC32, tiger, Adler32,
RipeMD128, etc
Hash functions
• Cryptographic hash function (also known as a digest)
–Input: arbitrary data
–Output: fixed-length bit string
• Properties of a cryptographic hash, H = hash(M):
– –One-way function
• Given H, it should be difficult to compute M
– –Collision resistant
• Given H, it should be difficult to find M’, such that H=
hash(M’)
• For a hash of length L, a perfect hash would take 2(L/2) attempts
– –Efficient
• Computing H should be computationally efficient
Message Authentication Codes vs.
Signatures
• Message Authentication Code (MAC)
– MAC is a short piece of information used to authenticate a message to
confirm that the message came from the stated sender and has not been
changed.
– Hash of message encrypted with a symmetric key:
• An intruder will not be able to replace the hash value
• Digital Signature
– Hash of message encrypted with the owner’s private key
– Alice encrypts the hash with her private key
– Bob validates it by decrypting it with her public key & comparing with the
hash(M)
– –Provides non-repudiation: recipient cannot change the encrypted hash.
Digital signatures: public key
cryptography

1.1 Alice generates a hash of the message


1.2 Alice encrypts the hash with her private key. This is her signature (S)
1.3 Alice sends Bob the message & the encrypted hash

2.1 Bob decrypts the hash using Alice’s public key


2.2 Bob computes the hash of the message sent by Alice
2.3 If the hashes match, the signature is valid
– the encrypted hash must have been generated by Alice
Digital signatures: multiple signers

Charles:
• Generates a hash of the message, H(P)
• Decrypts Alice’s signature with Alice’s public key
- Validates the signature: DA(S) ≟ H(P)
• Decrypts Bob’s signature with Bob’s public key
- Validates the signature: DB(S) ≟ H(P)
Covert AND authenticated messaging
• If we want to keep the message secret
–combine encryption with a digital signature
• Use a session key:
–Pick a random key (K) to encrypt the message
with a symmetric algorithm
–encrypt K with the public key of each recipient
–for signing, encrypt the hash of the message
with sender’s private key
Covert AND authenticated messaging

Alice generates a digital signature by encrypting the message


with her private key
Covert AND authenticated messaging

Alice picks a random key (K) and encrypts the message P with it
using a symmetric cipher
Covert AND authenticated messaging

Alice encrypts the session key for each


recipient of this message using their public keys
Covert AND authenticated messaging

The aggregate message is sent to Bob & Charles


Assignment II:

• Implement a program that will allow a user (sender) to first create


a message digest of a plaintext and secondly add a digital
signature to the message digest.
– The digital signature can be stored temporary in a buffer.
• At the receiver’s end, the digital signature has to be decrypted to
obtain the message digest. The receiver also creates another
digest using the plaintext and compares the created digest with
the digest sent by the sender to see if it has not been
compromised.
– Assume that the key (for encryption/decryption) and plaintext are known
to sender and receiver.
– Hint: Use the logic behind how passwords are hashed in the database
whereby the sender is the user and receiver is the database.
Resource Material
–Resource materials can be found at the
following link:

– SAKAI: https://sakai.ug.edu.gh/
Thank you

You might also like