Computer security
Cryptography
Introduction to Asymmetric Cryptography
In asymmetric cryptography, two keys are used that are linked mathematically, but are mutually exclusive.
One for encryption and the other for decryption.
• Asymmetric encryption is also called public key encryption as one key is made public
• A pair of keys are required for encryption/decryption
• These keys are mathematically related
• Each key is used to encrypt/decrypt
• Cannot encrypt/decrypt with only one key
• Public key is usually shared while private key is secured by the owner
• Secure Message format: message is encrypted with the receiver's public key (Confidentiality)
• Open Message format: message is encrypted with the sender’s private key (Authenticity)
• This provides authenticity, integrity, and non-repudiation
• Examples: RSA, Diffie-Hellman, Elliptic curve cryptosystem (ECC), and Digital signature algorithm
(DSA).
• A symmetric key pair can be used for : Encryption
❑ Jim want to send a secret msg to Pam
❑ Jim use’s Pam Public key to Encrypt the msg
❑ Only the correlating Privet key can Decrypt
This is how a symmetric keys can use to provide ➔ Confidentiality
There is something else we can do with a Symmetric keys
A symmetric key pair can be used for : Signatures
❑ Pam has msg to send and doesn’t care about confidentiality (meaning who can read this msg)
❑ Pam want to prove that she sent this msg
❑ Pam uses her Privet Key to Encrypt the msg
❑ If Jim can decrypt with Pam’s Public Key:
• Jim knows Pam must have sent the msg ➔ Authentication
• Jim knows msg wasn’t modified in transit ➔ Integrity
• a symmetric keys can be used to provide Confidentiality & Signatures
• But in reality, its not that simple
• Remember a Symmetric Key has limitations
• Can't use for Bulk data transfers (slower & more taxing in the CPU), but can use it for limited
data
• Bulk data should be Protected with Symmetric Key
• So, what if we used A symmetric Keys to share Symmetric Key ? (That’s what SSL & TLS do)
This how it works:
• Pam randomly generates a Symmetric Secret Key
• Pam Encrypts Symmetric Key with Jim’s Public Key
• Jim Decrypts Symmetric Key with Jim’s Privet Key
• Bulk data can now be Symmetrically Encrypted
• Can be done in either direction, for arbitrary amount of data
(This is concept referred to Hypered Encryption)
• Hypered Encryption:
• Concept of using both Asymmetric and Symmetric Encryption
• Asymmetric Encryption to facilitate a Key Exchange
• Secret Key used with Symmetric Encryption with bulk data
• But what about signature ?
• Entire msg can't be Encrypted with Privet Key
• Asymmetric Encryptions has limitations
• Could we sign a fixed, representational sample of the msg?
• Hashing algorithms
• Process for using an Asymmetric Key pair for Signature :
• Pam Calculates a Hash of a msg.
• Pam Encrypts resulting Digest with Pam’s Privet Key
• This is the actual Signature
• Signature is appended to the msg
• Jim decrypts the signature with Pam’s Public Key
• Jim calculate Hash of received msg
• If both digests match, this prove:
• Msg hasn’t changed since Pam Singed it. ➔ Integrity
• Only Pam could have created the signatures ➔ Authentication
We keep in mind Many different items can be signed … Software , Email .. etc
Ali(Pka,Prka)
SAMI(Pks,PrkS)
Ali(m)->Pks(m)->Pkra(c)->SAMI
Encryption->Signe
SAMI->Pka(s)->PrkS(c)->m
- Encryption(confidentiality):sender(Pkr)/Decryption
:receiver (PrKr)
- Authenticity/Signature/non-repudiation:
sender(Prks)/Decrytipn:receiver (Pks)
Introduction to Asymmetric Cryptography—Diagram
Introduction to RSA Algorithm
RSA stands for Ron Rivest, Adi Shamir, and Leonard Adleman, the inventors of this algorithm.
RSA:
• Is a worldwide standard
• Provides digital signatures, encryption, and secret key distribution
• Is based on the difficulty in factoring the two large prime number’s (up to 200 digits long) product forms
• Used in Web browsers with SSL, systems that use public key cryptosystems
Other Types of Asymmetric Cryptography: Elliptic Curve Cryptosystems
Elliptic Curve Cryptosystems (ECCs)
• Instead of generating keys as the product of very
large prime numbers, ECC generates keys through
the properties of the elliptic curve equation
• An ECC key of 160-bit provides the same
protection as a 1024-bit RSA key
• ECC is more efficient than RSA
• Provides encryption, digital signature, and key
exchange
• Used in devices with limited processing, storage,
and bandwidth capacity
• Examples: Wireless and mobile phone
Zero Knowledge Proof
Ownership:
Applicable in public-key cryptography • Prove that you own a private
Application of Zero key
Knowledge Proof
It means someone can tell you something that you can trust without Membership:
• Prove you are part of
telling you more information that you need group,without revelaing your
identity
For example, you trust a message based on half the key pair (public Sealed Bid Auction
key), without needing to know the other half of the pair (private key) • Prove who won, without
revealing bid.
M of N Control
M of N Control requires that a minimum number of agents (M) out of the total number of agents (N) work together to
perform high-security tasks.
This is a back-up process of public and private key material over multiple systems or devices.
It’s a tool that prevents the recreation of private and public key material from the backup.
The key materials are backed up and then mathematically distributed across several systems or devices.
So, implementing three of eight controls would require three people out of the eight with the assigned work task of key
escrow recovery agent to work together to pull a single key out of the key escrow database (thereby also illustrating that
M is always less than or equal to N).
Other Types of Asymmetric Cryptography: Diffie-Hellman Key Exchange
Diffie-Hellman Key Exchange
• It is the key distribution asymmetric algorithm
• A protocol whereby two or more parties can agree on a key in
such a way that both influence the outcome
• Allows two users to exchange a secret key
• Requires no prior secrets
• Does not provide for encryption or digital signature functions
• Vulnerable to Man-in-the-middle attack
• The algorithm is based on the difficulty of calculating discrete
logarithms in a finite field.
• Currently used in many protocols, namely:
• Secure Sockets Layer (SSL)/Transport Layer Security (TLS)
• Secure Shell (SSH)
• Internet Protocol Security (IPSec)
• Public Key Infrastructure (PKI)
Other Types of Asymmetric Cryptography: Diffie-Hellman Key Exchange- Example
Diffie-Hellman Key Exchange
• Step 1: Alice and Bob get public numbers P = 23, G = 9
• Step 2: Alice selected a private key a = 4
and Bob selected a private key b = 3
• Step 3: Alice and Bob compute public values
Alice: x =(9^4 mod 23) = (6561 mod 23) = 6
Bob: y = (9^3 mod 23) = (729 mod 23) = 16
• Step 4: Alice and Bob exchange public numbers
• Step 5: Alice receives public key y =16
and Bob receives public key x = 6
• Step 6: Alice and Bob compute symmetric keys
Alice: ka = y^a mod p = 65536 mod 23 = 9
Bob: kb = x^b mod p = 216 mod 23 = 9
• Step 7: 9 is the shared secret.
Hybrid Key Cryptography or Digital Envelope
A hybrid system that combines the symmetric and asymmetric methods.
• The more efficient symmetric algorithm encrypts a
message using a secret key.
• The symmetric secret key is encrypted using a
recipient’s public key with an asymmetric algorithm.
• The message encrypted with that secret key and the
encrypted symmetric secret key are sent to the
recipient.
• The recipient uses his private key to decrypt the secret
key.
• The secret key is then used to decrypt the message.
• A symmetric algorithm is used for bulk encryption.
• To distribute the symmetric key, the asymmetric
algorithm is used.
Session Keys
Single use symmetric key that is used to encrypt/decrypt communication
between two users for a single session.
It’s more secure than static symmetric keys.
Peers decide on the session key and continue to use it till the session is over.
Eavesdropping is difficult, breaking the keys is futile.
Symmetric vs. Asymmetric Cryptography
Symmetric Cryptography Asymmetric Cryptography
Same key is used for A pair of keys, one for encryption and the
encryption and decryption in other for decryption, are used in asymmetric
symmetric algorithms algorithms
Symmetric algorithms consume less
Asymmetric algorithms consume more computing power
computing power
Asymmetric algorithms are used to distribute the symmetric
Symmetric algorithms are much faster
key as they are slower
In an asymmetric algorithm the encryption key is called
“Symmetric key” is synonymous with secret public key and decryption key is called private or secret
key or session key key and the “asymmetric key” refers to the public key or
private key of an asymmetric key pair
Advantages and Disadvantages
Types of cryptography Advantages Disadvantages
• Presents the challenge of key
• Very fast to encrypt or decrypt,
Symmetric management
secure,
Cryptography • Does not provide authenticity,
and affordable
• Best for encrypting large files non- repudiation
• Provides better key distribution
than symmetric systems • Much slower operation
Asymmetric • Provides better scalability due to than symmetric
Cryptography ease of key distribution systems
• Provides authenticity and • Vulnerable to man-in-the-middle
non- repudiation, in
addition to attacks
confidentiality and
integrity
Introduction to Public Key Infrastructure
“A public key infrastructure (PKI) is a set of hardware, software, people, Components of PKI
policies, and procedures needed to create, manage, distribute, use,
store, and revoke digital certificates.”
• Public key infrastructure provides CIA and non-repudiation. Certificate
Authority(s)
• PKI includes Certificate authority (CA), Digital certificates,
Registration authorities (RA), policies and procedures, certificate
revocation, time-stamping, non-repudiation support, and security- Users
Registratio
enabled applications. n
PKI Authority(s)
• A digital certificate is required by each participant in a PKI, which Components
contains a particular participant’s public key and other identifying
information.
• This is signed by a trusted certificate authority and the authenticity Keys Certificates
of public key is the liability of the CA.
• PKI is used in online banking and ecommerce.
Certificate Authority and Registration Authority
Certificate Authority Registration Authority
• A trusted third party responsible for issue • It performs the registration duties
and maintenance of Digital Certificates • It establishes and confirms the identity of
• It can also be internal to an organization the individual, initiates the registration
• Revocation of certificates is also handled process with CA and performs certificate
by the CA lifecycle management
• The revoked certificates are stored in the • RA verifies all the necessary information
Certificate Revocation List (CRL) which is before allowing a request to go to CA
updated and maintained by the CA • RA cannot issue certificates
PKI Certificate
A digital certificate, also known as a public key certificate, is used to cryptographically link ownership of a public key with the
entity that owns it.
Digital certificates are for sharing public keys to be used for encryption and authentication.
Digital certificates include the public key being certified, identifying information about the entity that owns the public key,
metadata relating to the digital certificate and a digital signature of the public key created by the issuer of the certificate.
X.509 is the standard that dictates the fields that is used in the certificate and the valid values that can be populated in the fields
Enrollment Process
When a user wants to obtain a digital certificate, then the user must first prove his identity to the CA
in some manner. This process is called enrollment.
Once the certificate authority is satisfied with the user’s identity, then the user must provide its
public key to the CA.
Next, the CA creates an X.509 digital certificate which contains the identification information of a
user and a copy of the user’s public key.
The CA then digitally signs the certificate using the CA’s private key and provides the user with a
copy of your signed digital certificate.
The user may then safely distribute this certificate to anyone with whom you want to communicate
securely.
Step 1 Step 2 Step 3 Step 4
• The user needs to prove his • The user seeking the certificate
identity in order to obtain a • The CA creates a X.509 digital • The CA digitally signs the
needs to provide its public key certificate containing the user’s certificate and provides the
digital certificate. after the verification process by identifying information and user with a copy of the signed
the CA is complete public key. digital certificate
Verification Process
When a user receives a digital certificate from someone with whom he wants to communicate, the user must
verify the following:
The certificate actually
The digital signature of The CA is trusted by The certificate is not
contains the data you
the CA is authentic. the user. listed on a CRL.
are trusting.
Revocation Process
Occasionally, a certificate authority needs to revoke a certificate. This might occur because of the following reasons:
The certificate was The certificate was The details of the The security
compromised erroneously issued certificate changed association changed
Certificate Revocation List (CRL)
Certificate Revocation Lists
• Certificate revocation lists (CRLs) are maintained by the various
certificate authorities and contain the serial numbers of
certificates that have been issued by a CA and have been
revoked along with the date and time the revocation went into
effect.
Online Certificate Status Protocol (OCSP)
• It carries out real-time validation of certificates and reports it
back to the user
• It checks the CRL that is maintained by the CA
PKI Process
Step 1 Step 6 Step 7
• User A and User B wants to • CA will digitally sign that • User A will present that
participate in the PKI process. certificate and send the digitally certificate to B to
signed certificate to User A. communication
Step 2 Step 5 Step 8
• User A will generate Public Key • Certificate Authority will • User B will take the certificate
and Private Key at its system. generate a digital certificate and verify the digital signature
which is of X.509 standard and of the CA.
this certificate has the public
key of the user embedded in it.
Step 3 Step 4 Step 9
• User A will send Public Key and • RA/CA will verify the • After verification, B can trust
identification information to information provided by User the public key of A and can be
the Registration A. securely communicated with
Authority/Certificate Authority User A.
One-Way Hash
A hash function uses an algorithm without any key for Characteristics:
encryption. This encryption cannot be reversed. Hence, it is • Hash should be computed over the entire
called “one-way”. message.
• A fixed-length hash value (message digest/hash) is created or • Hash should be a one-way function.
• Given a message and Hash value,
”hashed” from variable length plaintext.
computing another message with the
• When the plaintext changes, its hash value also changes.
same Hash value should be impossible.
Thus, for providing integrity, the hash functions are used.
• Hash is used to guarantee the integrity of data. • Resistant to Birthday attacks.
• Hash can be applied to any size data block.
• Hash produces fixed-length output.
Hashing Algorithms
A hash function is any algorithm or subroutine that maps large data sets of variable length to smaller data
sets of a fixed length.
MD5:
• Is the most widely used of the MD (Message-Digest Algorithm) family of hash algorithms
• Harder to break, for input of any length it creates a 128-bit hash value
SHA-1:
• Belongs to the Secure hash algorithm (SHA) family
• Generates a 160-bit hash value
• SHA-2 includes SHA-224, SHA-256, SHA-384, and SHA-512, termed after the length of the hash value each
creates
Message Authentication Code
• Message authentication code (MAC), sometimes known as a tag, is a short piece of information
used to authenticate a message, in other words, to confirm that the message came from the stated
sender (its authenticity) and has not been changed.
• The MAC value protects both a message's data integrity as well as its authenticity, by allowing
verifiers (who also possess the secret key) to detect any changes to the message content.
• It is an authentication scheme derived by applying a secret key, in some form, to a message
• Receiver performs same computation on message and checks if it matches the MAC
Birthday Attack
• If the algorithm does produce the same value for two distinctly different messages, this is called a hash
collision.
• The Birthday attack attempts to exploit the probability of two messages producing the same message
digest by using the same hash function.
• It is based on the statistical probability that with 23 people in a room, there is more than 50% probability
that 2 people have the same birthday.
• SHA-1 (160 bits) may require approximately 280 computations to find a hash collision.
• A hashing algorithm that has a larger bit output is less vulnerable to brute-force attacks such as a birthday
attack.
Salting
Salt is a random value that is added to password hash to prevent dictionary attacks and hash collisions.
• It makes it difficult for the attacker to break into a system by using strategy of password hash-matching.
• For each password, a new salt is randomly generated.
• Instead of the original password, the output of cryptographic hash function processed is stored in the
database.
• It is used in Unix systems and for internet security.
Digital Signatures
Digital signatures:
• Are used for signing the document cryptographically
• To digitally sign the data:
• Create the hash of a data
• Encrypt that hash with the sender's private key
• To verify the digital signature:
• Hash the data
• Find the sender’s public key
• Decrypt the signature with the sender's public key
• Check whether the hash you have created matches the hash which you received
• Hashing provides message integrity, signing of Hash provides authentication and non-
repudiation
• Involves encrypting the hash value of a message with a private key
Cryptanalysis
• Cryptanalysis is the study of ciphertext, ciphers, and cryptosystems with the aim of understanding how
they work and finding along with improving techniques for defeating or weakening them.
• Cryptanalysis is used to breach cryptographic security systems and decipher the contents of encrypted
messages, even without knowing the cryptographic key.
Cryptographic Attacks
• The attacker has the ciphertext of several messages.
Ciphertext Only
• Each of the messages has been encrypted using the same encryption
Known-Plaintext algorithm.
• The goal is to discover the key used in the encryption process.
Chosen-Plaintext
• It is the hardest attack to be successful at, because the attacker has
Chosen-Ciphertext
very little information about the encryption process.
Cryptographic Attacks
Ciphertext Only • The attacker has the plaintext and corresponding ciphertext of one or more
messages.
Known-Plaintext
• Allows the attacker to analyze the relationship between the plaintext and the
Chosen-Plaintext ciphertext.
Chosen-Ciphertext • The goal is to discover the key used to encrypt the messages.
Cryptographic Attacks
• The attacker knows the algorithm used for encryption.
Ciphertext Only
• The attacker runs samples of plaintext to obtain the corresponding
Known-Plaintext ciphertexts.
Chosen-Plaintext • Allows the attacker to compare ciphertexts to possibly discover the
encryption key.
Chosen-Ciphertext
• An Adaptive Chosen-Plaintext attack is where the attacker can modify the
chosen plaintext based on the resulting ciphertext.
Cryptographic Attacks
Ciphertext Only • The attacker has access to the system used for decryption.
• The attacker can choose the ciphertext to be decrypted and has access to the
Known-Plaintext
resulting decrypted plaintext.
Chosen-Plaintext • The goal is to figure out the encryption key. “lunchtime”, “midnight” attacks,
where the attacker gains access to an unattended decryption system.
Chosen-Ciphertext
Key Management
Key management is the most challenging part of cryptography and can be handled manually or
automatically.
• Key management includes:
o Generating, destroying, and recovering keys
o Protection of keys against capturing, modification, corruption, or disclosure to unauthorized
individuals
o Regular update of keys and distribution to the right entities
• Key distribution protocols (asymmetric) include:
o RSA
o Diffie-Hellman
• The Kerberos Key Distribution Center (KDC) is an example of automated key mana gement
.
Key Management Principles
Key management includes taking backup copies and
adopting multiparty key recovery. Key management
rules include the following:
• Keys should be:
o Stored and transmitted by secure means
o Random
o Properly destroyed at the end of their lifetime
o Long enough to provide the necessary level of
protection
• The key’s lifetime should correspond with the
sensitivity of the data it is protecting
Business Scenario
Important points on Key Management:
• The value of information encrypted with a key should correspond to the level of effort
taken to protect an encryption key
• The cipher text can be compromised if the encryption key is compromised
• The level of protection required for a key should be same as that required for original
unencrypted data
• The automatic key management is more accurate and secure.
• Keys must be updated continuously and distributed to the right entities
• Keys need to be generated, recovered, and destroyed properly.
Question: What should be the relationship between key’s lifetime and sensitivity of data?
Answer: Shorter key lifetime for more sensitive data and longer key lifetime for less sensitive data.