02 - Cryptography Part 02
02 - Cryptography Part 02
02 - Cryptography Part 02
to
Information
Security
Brute Force Speed
• Openssl speed aes
Introduction to Information Security
Symmetric vs
Hash Functions Digital Signatures
Asymmetric Keys
Model of Encryption for Confidentiality
Public‐Key Encryption Structure
Asymmetric
• Uses two
Publicly separate keys
Some form of
proposed by Based on • Public key and
private key protocol is
Diffie and mathematical
• Public key is needed for
Hellman in functions
made public for distribution
1976
others to use
Public‐Key Encryption Structure
• Each user is having two keys (one public and one private)
Keys Generation
Source: https://docs.huihoo.com/globus/gt3‐tutorial/ch10s03.html
Public and Private Keys
Source: www.hackernoon.com
X=
X Transmitted D[PUb, Y]
ciphertext
Y = E[PRb, X]
Plaintext Plaintext
Encryption algorithm Decryption algorithm
input output
(e.g., RSA)
Digital
Signature Provides only a digital
signature function with SHA‐1
Cannot be used for
encryption or key exchange
Standard (DSS)
Elliptic curve
cryptography Security like RSA, but with
much smaller keys
(ECC)
Public Key Encryption Example
User B
User A User C
Applications of Public Key
Cryptosystems
Private Key:
o This approach utilizes the advantages of both symmetric and asymmetric encryption mechanisms
o Note that public key crypto algorithms typically much slower than symmetric key algorithms
Applications of Public Key Cryptosystems
Key exchange, share secret session keys
Suppose we have two users (A,B) and A wants to send data to B using symmetric key
encryption but still A wants to generate the symmetric key and send it to B securely.
Keys Generation
How can a user generate symmetric key?
Open SSL
https://qsandbox.com/tools/private‐public‐keygen
Keys Generation
https://qsandbox.com/tools/private‐public‐keygen https://qsandbox.com/tools/private‐public‐keygen
‐‐‐‐‐BEGIN RSA PRIVATE KEY‐‐‐‐‐ ‐‐‐‐‐BEGIN RSA PRIVATE KEY‐‐‐‐‐
MIIEowIBAAKCAQEAqk60EeuhImS2tUn/8MBrEEeqPZ8H1GhMKol3Fb55xNQrwAF/ AAAAB3NzaC1yc2EAAAADAQABAAABAQCqTrQR66EiZLa1Sf/wwGsQR6o9nwfUaEwqiXc
31khZi5Sv2fJos0Kvz/atSoxpFf5M0wZKTmP+FiiglzqudR9f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WHLfze2/ss9QM
yQAvaYhdM7NpgTrhJ667pNpVnIFC3BUqJuS7CSpwkfsUDdule9NF9V8CgYEAzycP
IcIeRbfhOECPw9B6yR2UpYZsiHzvcIdMjvi+cwaQZhjx1t1Nie9VlmkhUVfI5Oiz
PW5yaoIpvAuwsxBhp36vQClkRJYN+Cre6dVJfvKP9vgC1BE2/kbe4b5y9FF/ODe2
1+5R/RC2xLIVKg1TmvHD3sjAe3efiNaOSA4JcGkCgYACikyPi+s0Kv7Q6VyLFpBS
ZudDYPfVs9vhwUz1oy7h8LKY10QD5K2fJaJS7VZPdmBxJcGLbcHXgEZdgHYBij0s
Cfv/Pb9fl0OZjKzy759W82Vt7PjnZrzMxELOPEYbtKOmWqaTCwnawIPeArVi4KKE
m6giQS/goy4nyKnjp7YlcwKBgQCvWE6Usq3RMc6wQOXwSB5G8oUKf3iLJ8W9qKkD
NEZxMxMzeNXsnDKwGSiHQsHzCq2AJgDidQTgZwFQrUyKpckjcDaDxwWakLGOaSt7
HxExJbz6vgAW5eN45SBwUTcY24smWPKqYI6B+Y3bfSoxCErGkvLLN37GhAFEYOja
0RboUQKBgGDWLqKln+npfdbg+0y4bHChPnYnAdGnwNU9072kba5gCXgrQ5iBI52f
J+VRhoKwuiR3H05l6CHYf26sDltzZbdSvubHUMNDr1Xu9PMins9bahl307x+3WVy
eOAW+lJKF1IfUXlWtGuJtjSMrFtIVPvwpCW5nENL2sV3NREqN9Oc
‐‐‐‐‐END RSA PRIVATE KEY‐‐‐‐‐
OpenSSL Syntax (Asymmetric Key Generation)
• OpenSSL genrsa ‐des3 ‐out private.pem 2048
• Less private.pem
• Less public.pem
Open SSL
OpenSSL is a program and library that supports many different cryptographic
operations, including:
Hash functions
Certificate creation
Digital signatures
MAC assumes that user A and B are sharing a common secret key KAB
Message Authentication Code (MAC)
MAC Algorithms
MAC vs. HASH
The main difference between MAC and Hash is that the MAC is always taking a key as an
input to its algorithm which is used to encrypt the data while digesting the message
The Hash function is not taking any key during the hashing process
Authentication using Hash Functions
Authentication using Hash Functions
Alice Bob
Darth
Hash Security Requirements and Attacks
Hashing Algorithms
The following are the three most commonly used cryptographic hash functions:
Message Digest 5 (MD5): MD5 produces a 128‐bit hash and is now considered a legacy algorithm that should be avoided
Secure Hash Algorithm 1 (SHA‐1): SHA‐1 takes a message of up to 2^64 bits in length and produces a 160‐bit message
digest. The algorithm is slightly slower than MD5, but the larger message digest makes it more secure against brute‐force
collision and inversion attacks.
Secure Hash Algorithm 2 (SHA‐2): SHA‐2 algorithms are the secure hash algorithms that the U.S. government requires by
law for use in certain applications. The SHA‐2 family includes 224‐bit, 256‐bit, 384‐bit, and 512‐bit functions. When choosing a
hashing algorithm, use SHA‐256 or higher, as they are currently the most secure
Secure Hash Algorithm 3 (SHA‐3) is the latest member of the Secure Hash Algorithm family of standards, released by NIST
on August 5, 2015. Although part of the same series of standards, SHA‐3 is internally different from the MD5‐like structure
of SHA‐1 and SHA‐2.
Hashing Algorithms
To be useful for message
authentication, a hash function H must have the following
properties:
Cryptanalysis Passwords
• Exploit logical weaknesses • Hash of a password is
in the algorithm stored by an operating
system
$md5sum plaintext.txt
$sha1sum plaintext.txt
• Less private.pem
• Less public.pem
• OpenSSL list‐message‐digest‐algorithms
• $md5sum plaintext.txt
• $sha1sum plaintext.txt
• $sha256sum plaintext.txt
• $Cat plaintext1.txt
Installing
Cygwin
• Go to https://www.cygwin.com/
• Go to:
• Install Cygwin by running setup-
x86_64.exe