Chapter 4 Review of Shared Key Cryptography and Hash Functions
Chapter 4 Review of Shared Key Cryptography and Hash Functions
Chapter 4 Review of Shared Key Cryptography and Hash Functions
6. Asymmetric Encryption:
• Asymmetric-key encryption uses a pair of public and private keys. The public key is used for
encryption, and the private key is used for decryption. This allows secure communication
without sharing the private key.
7.Hash Functions:
• Cryptographic hash functions take an input (or message) and produce a fixed-size string of
characters, which is typically a hash value. Hash functions are used for data integrity
verification.
8.Digital Signatures:
• Digital signatures use asymmetric-key cryptography to provide authentication and integrity
for messages. They are used to verify the origin and content of a message.
9.Authentication:
• Cryptography is used to verify the identity of communicating parties, ensuring that the
information is not altered and that it comes from a legitimate source.
10.Cryptanalysis:
• Cryptanalysis is the study of techniques for defeating cryptographic systems or gaining
Types of Cryptographic Functions
1. Symmetric Encryption:
• Overview:
• Key Usage: Same key is used for both encryption and decryption.
• Key Management: Securely sharing the secret key between communicating parties is crucial.
• Examples: AES (Advanced Encryption Standard), DES (Data Encryption Standard), 3DES (Triple
DES).
• Process:
1.Key Generation: A secret key is generated and shared between the parties.
2.Encryption: The plaintext is transformed into ciphertext using the secret key.
3.Decryption: The ciphertext is transformed back into plaintext using the same secret key.
• Advantages:
• Efficiency: Symmetric encryption is generally faster and computationally less intensive than
asymmetric encryption.
• Suitability: Well-suited for bulk data encryption and secure communication between trusted
parties.
• Challenges:
• Key Distribution: The secure distribution of the secret key can be challenging, especially in large
Fig. Symmetric cryptography
2. Asymmetric cryptography
• Overview:
• Key Usage: Uses a pair of public and private keys.
• Key Management: Each user has a public key (used for encryption) and a private
key (used for decryption).
• Examples: RSA (Rivest–Shamir–Adleman)
• Process:
1.Key Generation: A user generates a public-private key pair.
2.Encryption: The sender uses the recipient's public key to encrypt the message.
3.Decryption: The recipient uses their private key to decrypt the message.
• Advantages:
• Key Distribution: No need for secure key distribution; public keys can be freely
distributed.
• Security: Provides a higher level of security for key exchange and authentication.
• Challenges:
• Computational Overhead: Asymmetric encryption is computationally more
intensive than symmetric encryption.
Fig. Asymmetric cryptography
3. Hash Functions:
• Overview:
• One-Way Function: Hash functions are designed to be one-way, making it computationally infeasible to
reverse the process and obtain the original input from the hash value.
• Fixed Output Size: Regardless of input size, the hash function produces a fixed-size output.
• Examples: SHA-256 (Secure Hash Algorithm 256-bit), MD5 (Message Digest Algorithm 5), SHA-3.
• Process:
1.Hashing: The input (message or data) is processed by the hash function to produce a fixed-size hash
value.
2.Fixed Size: The hash value is typically a fixed length, regardless of the input size.
3.Collision Resistance: Hash functions aim to be collision-resistant, meaning it should be difficult to find
two different inputs that produce the same hash value.
• Use Cases:
• Integrity Verification: Hash functions are used to verify the integrity of data by comparing hash values
before and after transmission or storage.
• Digital Signatures: Hash values are often signed with a private key to create digital signatures.
• Security Considerations:
• Pre-image Resistance: It should be computationally infeasible to reverse the hash function and find the
original input.
• Collision Resistance: It should be difficult to find two different inputs that produce the same hash value.
• Note: MD5 is considered insecure for cryptographic purposes due to vulnerabilities, and SHA-1 is also
deprecated for security-sensitive applications. SHA-256(SHA-2 family) and SHA-3 are currently
Hashing V.S. Encryption
Hello, world. k NhbXBsZSBzZW50ZW5jZS
A sample sentence to E B0byBzaG93IEVuY3J5cHR
show encryption. pb24KsZSBzZ
Hello, world. k
NhbXBsZSBzZW50ZW5jZS
A sample sentence to D
B0byBzaG93IEVuY3J5cHR
show encryption. pb24KsZSBzZ
• Hashing
Hashingisisone-way.
one way, There is no
there is no going
'de-hashing’
back
Attacks on Cryptography
• Cryptography is designed to provide secure communication and protect data from unauthorized access.
• However, like any technology, cryptographic systems are not immune to attacks.
• Various attacks aim to exploit vulnerabilities in algorithms, implementation flaws, or weaknesses in key
management.
• Here are some common types of attacks on cryptography:
1. Brute Force Attacks:
• Description: An attacker tries all possible keys until the correct one is found.
• Prevention: Increasing key length makes brute force attacks computationally infeasible.
2. Cryptanalysis:
• Description: Analyzing the mathematical structure of cryptographic algorithms to exploit weaknesses.
• Prevention: Use algorithms with proven security, regularly update algorithms, and avoid proprietary or secret
algorithms.
3. Man-in-the-Middle (MITM) Attacks:
• Description: An attacker intercepts and possibly alters the communication between two parties without their
knowledge.
• Prevention: Use protocols with strong authentication and encryption, such as HTTPS.
4. Side-Channel Attacks:
• Description: Exploiting information leaked during the execution of a cryptographic
algorithm, such as timing, power consumption, or electromagnetic radiation.
• Prevention: Implement countermeasures, such as constant-time algorithms, to
minimize side-channel information.
5. Known-Plaintext and Chosen-Plaintext Attacks:
• Description: The attacker has access to plaintext-ciphertext pairs and aims to derive the
key.
• Prevention: Use algorithms resistant to these attacks; regularly update keys.
6. Birthday Attacks:
• Description: Exploiting the probability of two different inputs producing the same hash
value.
• Prevention: Use hash functions with a sufficiently large output size to make collisions
unlikely.
7. Collision Attacks:
• Description: Finding two different inputs that produce the same hash value.
• Prevention: Use hash functions with strong collision resistance.
8. Differential Cryptanalysis:
• Description: Analyzing differences in plaintexts and their corresponding ciphertexts to
deduce the key.
9. Fault Attacks:
• Description: Introducing faults (e.g., manipulating voltage or temperature) during
cryptographic operations to extract information.
• Prevention: Implement countermeasures, such as error detection and correction.
10. Key Management Attacks:
• Description: Attacking the process of generating, storing, or exchanging cryptographic
keys.
• Prevention: Implement secure key management practices, including key generation,
distribution, and storage.
11. Zero-Day Exploits:
• Description: Exploiting undisclosed vulnerabilities in software or cryptographic
algorithms.
• Prevention: Regularly update software and algorithms, and stay informed about security
advisories.
12. Social Engineering:
• Description: Manipulating individuals to reveal sensitive information, including
cryptographic keys.
• Prevention: Educate users about security awareness and implement strong access
controls.
Symmetric key cryptography
• Symmetric key cryptography, also known as secret key
cryptography or conventional cryptography, is a type of
encryption where the same key is used for both the
encryption and decryption of the message.
• The security of the communication relies on keeping
the key secret.
• Key Concepts:
1.Key Usage:
• The same secret key is used for both encryption and decryption processes.
• This means that both communicating parties need to know and agree upon the secret key.
2.Efficiency:
• Symmetric key algorithms are generally more computationally efficient than asymmetric key
algorithms (such as RSA ).
• They are often used for bulk data encryption due to their speed.
3.Types of Symmetric Key Algorithms:
1.Block Ciphers: Operate on fixed-size blocks of data. Common block ciphers include AES and
DES.
2.Stream Ciphers: Operate on a continuous stream of data. They encrypt individual bits or
bytes.
• RC4(Rivest Cipher 4) is an example of a stream cipher.
4.Key Management:
• The secure distribution of the secret key is crucial. If an unauthorized party gains access to the
key, it compromises the security of the communication.
5.Key Length:
• The security of symmetric key cryptography relies heavily on the length of the key. Longer keys
generally provide stronger security. Common key lengths are 128, 192, and 256 bits for AES.
• Symmetric Key Encryption Process:
1.Key Generation:
• A secret key is generated using a random or pseudorandom process.
2.Encryption:
• The plaintext (original message) is divided into fixed-size blocks, and each block is encrypted using the secret key and
the chosen symmetric key algorithm.
3.Ciphertext:
• The encrypted blocks form the ciphertext, which is the unreadable output that is transmitted or stored.
4.Decryption:
• The recipient uses the same secret key and algorithm to decrypt the ciphertext and obtain the original plaintext.
• Advantages:
• Speed and Efficiency: Symmetric key algorithms are generally faster than asymmetric key algorithms,
making them suitable for large-scale data encryption.
• Suitable for Bulk Data Encryption: Symmetric cryptography is often used to encrypt large volumes of
data, such as in securing communication channels or encrypting files.
• Challenges:
• Key Distribution: The secure distribution of secret keys between communicating parties can be
challenging, especially in large networks.
• Scalability: As the number of communicating parties increases, the challenge of securely managing and
distributing keys becomes more complex.
• Symmetric key cryptography is widely used in various applications, including secure communication over
the internet, data protection, and encryption of stored information. While it excels in efficiency and speed,
key management remains a critical aspect for maintaining security. Symmetric key cryptography is often
1. DES (Data Encryption Standard):
• Overview:
• Developed by IBM in the 1970s, DES was the standard symmetric key encryption algorithm for federal use in the United States until
it was eventually superseded by AES.
• DES is a block cipher that operates on 64-bit blocks of data and uses a 56-bit key.
• Key Features:
• Block Size: 64 bits.
• Key Size: 56 bits (although officially, it's a 64-bit key with 8 bits used for parity and discarded).
• Operation:
• DES uses a Feistel network structure, where the data block is divided into two halves, and a series of rounds are applied to each half.
• Security Concerns:
• Due to the small key size, DES became vulnerable to brute-force attacks. As computational power increased, DES was deemed
insecure.
• Triple DES (3DES) was introduced to address this vulnerability.
2. AES (Advanced Encryption Standard):
• Overview:
• AES is a symmetric key encryption algorithm established as the standard by the National Institute of Standards and Technology
(NIST) in 2001.
• AES is widely used for secure data encryption and is considered more secure than DES and 3DES.
• Key Features:
• Block Size: 128 bits.
• Key Sizes: AES supports key sizes of 128, 192, and 256 bits.
• Operation:
• AES operates on blocks of data, with a fixed block size of 128 bits. It uses a series of substitution-permutation networks (SPN) to
achieve encryption.
• Strengths:
• AES is considered highly secure and has withstood extensive cryptanalysis.
• It is computationally efficient and supports a range of key sizes for different security requirements.
3. Rivest Cipher 4(RC4):
• Overview:
• RC4 is a stream cipher designed by Ron Rivest in 1987. Unlike block ciphers such as DES and AES, RC4
encrypts data in a continuous stream.
• Key Features:
• Operation: RC4 operates on individual bits or bytes of the plaintext, producing a stream of pseudorandom bits
that are XORed with the plaintext to produce the ciphertext.
• Key Size: RC4 supports variable key sizes.
• Operation:
• RC4 generates a pseudorandom stream of bits based on a key. This stream is then XORed with the plaintext to
produce the ciphertext.
• Strengths and Concerns:
• RC4 gained popularity due to its simplicity and speed, but it has shown vulnerabilities, especially when used
with weak keys.
• WEP (Wired Equivalent Privacy), a security protocol for Wi-Fi networks, initially used RC4 but faced significant
vulnerabilities.
• Status:
• Due to vulnerabilities and widespread attacks against RC4, its usage has diminished, and it is generally not
recommended for secure communications.
• Salsa20 and ChaCha are examples of modern and secure stream ciphers.
• Summary:
• DES: An outdated standard, replaced by 3DES and AES due to its small key size.
• AES: The current widely accepted symmetric key encryption standard, offering strong security and
efficiency.
Public Key Cryptography
• Public key cryptography, also known as asymmetric
cryptography, is a cryptographic system that uses pairs of
keys: public keys and private keys.
• This system enables secure communication and data
exchange between parties, even if they have never shared
a secret key
• Key Components:
1.Public Key:
• This key is used for encryption and is freely distributed. It's associated with a user's identity and
can be openly shared with anyone.
2.Private Key:
• This key is kept secret and is used for decryption. Only the owner of the private key should have
access to it.
• Operations:
1.Encryption:
• If Person A wants to send an encrypted message to Person B, A encrypts the message using B's
public key.
• Only Person B, who possesses the corresponding private key, can decrypt and read the
message.
2.Digital Signatures:
• A person can use their private key to sign a document, creating a digital signature. Anyone with
access to the corresponding public key can verify that the signature matches the document and
that it was indeed signed by the holder of the private key. This is Authentication.
3.Key Exchange:
• Public key cryptography is often used for secure key exchange, allowing two parties to establish
• Key Algorithms:
1. RSA (Rivest–Shamir–Adleman):
• One of the first widely used public key cryptosystems. It is based on the mathematical properties of large prime numbers.
2. DSA (Digital Signature Algorithm):
• A popular algorithm for digital signatures.
3. Elliptic Curve Cryptography (ECC):
• An approach that uses the mathematics of elliptic curves to provide strong security with shorter key lengths compared to traditional
algorithms like RSA.
4. Diffie-Hellman Key Exchange:
• A key exchange algorithm that allows two parties to agree on a shared secret over an insecure communication channel.
• Advantages of Public Key Cryptography:
1.Key Distribution:
• Public key cryptography eliminates the need for secure key distribution, a common challenge in symmetric key cryptography.
2.Digital Signatures:
• Provides a means of verifying the authenticity and integrity of messages or documents.
4.Non-Repudiation:
• The sender cannot deny sending a message that they encrypted with their private key.
• Challenges and Considerations:
1. Computational Intensity:
• Public key operations can be more computationally intensive than symmetric key operations.
2. Key Management:
• Proper management of public and private keys is crucial to maintaining security.
3. Quantum Computing Threat:
• Certain public key algorithms, especially RSA and ECC, could be vulnerable to attacks from quantum computers. Post-quantum
Asymmetric Cryptography
• The essential steps for secrecy shown in figure 4-1 are the following:
1- Each end system (user) in the network generates two keys, one for encryption
of message at the sender end and the other for decryption at the receiver.
2- Each system (user) publishes its encryption key by placing it in a public register
or file. This is the public key and the companion key is kept private. The user
also keeps the private keys of all other users.
3- If A (Bob) wishes to send a message to B (Alice), he encrypts the message using
B’s public key.
4- When B (Alice) receives the message, B decrypts it using her owns private key.
No other recipient can decrypt the message because only B knows B’s
private key.
(Note: No private key distribution, but only public key).
Four types of Public Key
Cryptography:
1. Diffie Hellman Algorithm (DH)
2. Rivest Shamir Adleman Algorithm (RSA)
3. Certificate Authority (CA)
4. Public Key Infrastructure (PKI)
1. Diffie-Hellman Key Exchange
An overview of the Diffie-Hellman key exchange algorithm
2. RSA Algorithm
OR(Commutative property of Keys)
The following number is 1024 bits number that was published
in 1991.
3. Certificate Authority (CA)
3. Certificate Authority (CA) (Cont…)
• A Certificate Authority (CA) is a trusted third party that
plays a crucial role in the implementation of public-key
cryptography, particularly in the context of SSL/TLS
protocols used for securing websites and internet
communications.
• The primary function of a CA is to verify the authenticity
of entities, such as websites or individuals, and to issue
digital certificates that attest to the validity of their
public keys.
• Here's an explanation of how Certificate Authorities
work:
1. Key Pair Generation:
• Entities that want to secure their communications generate a key pair
consisting of a public key and a private key. The private key is kept
confidential, while the public key is shared openly.
2. Certificate Signing Request (CSR):
• When an entity (such as a website) wants a digital certificate, it
generates a Certificate Signing Request (CSR). The CSR includes the
entity's public key and additional information like the domain name.
3. Certificate Authority Verification:
• The entity submits the CSR to a Certificate Authority for verification.
• The CA performs various checks to ensure that the entity making the
request has control over the domain or resource for which the
certificate is requested. This process may involve domain validation
through email verification, DNS records, or other methods.
4. Certificate Issuance:
• Once the CA verifies the legitimacy of the request, it issues a digital
certificate. The certificate contains:
• Information about the entity (such as its name and domain).
• The entity's public key.
• The digital signature of the CA.
5. Digital Signatures:
• The CA signs the certificate using its private key. This digital signature is
crucial for the verification process.
• The digital signature allows relying parties (e.g., browsers, user, server) to
confirm that the certificate has been issued by a trusted CA and that the
information in the certificate has not been tampered with.
6. Certificate Distribution:
• The CA sends the issued digital certificate back to the entity that
requested it.
• The entity installs the certificate on its server, associating it with the
corresponding private key.
7. Certificate Revocation:
• If a private key is compromised or the entity's status changes, the CA
may revoke the certificate before its expiration date.
• Revoked certificates are maintained in Certificate Revocation Lists (CRLs)
or using the Online Certificate Status Protocol (OCSP).
8. Browser Trust:
• Web browsers and other client applications come pre-installed with a list
of trusted root certificates.
• The CA's root certificate, or an intermediate certificate signed by the
root, must be present in the client's trust store for the digital certificate
to be trusted.
9. Strengths and Considerations:
• Establishes trust in the digital identity of entities.
• Requires a secure infrastructure to prevent fraudulent certificate
issuance.
• Follows standards such as X.509 for certificate format.
• Types of Certificate Authorities:
1.Root Certificate Authorities (Root CAs):
• These are the top-level CAs in a certificate hierarchy.
• Root CAs are self-signed and establish the trust anchor for the
entire system.
2.Intermediate Certificate Authorities:
• Intermediate CAs are subordinate to root CAs.
• They are used to issue certificates on behalf of the root CA.
3.End-entity CAs:
• These are the CAs that issue certificates to actual entities,
such as websites, servers, or individuals.
Digital Signature
• A digital signature is a cryptographic technique used to
provide authenticity, integrity, and non-
repudiation to digital messages or documents.
• It ensures that the sender of the message is who they
claim to be and that the message has not been altered
during transmission.
• Here's how digital signatures work:
1. Key Pair Generation:
• Like in other public-key cryptography systems, the signer generates a key pair consisting of a
private key and a corresponding public key.
2. Signing Process:
• To sign a message or document, the sender applies a mathematical algorithm (typically a
hash function) to create a unique value called a hash or message digest from the original
content.
• The sender then encrypts the hash value with their private key, creating the digital signature.
3. Digital Signature Creation:
• The digital signature is a cryptographic value unique to both the content of the message and
the private key of the sender.
• The combination of the original message and the digital signature is sent to the recipient.
4. Verification Process:
• Upon receiving the message and its associated digital signature, the recipient uses the
sender's public key to decrypt the digital signature, obtaining the hash value.
• The recipient independently computes the hash of the received message using the same
hash function.
• If the computed hash matches the decrypted hash from the digital signature, it indicates that
the message has not been altered and was indeed signed by the private key associated with
the provided public key.
• Properties of Digital Signatures:
1.Authentication:
• Digital signatures provide a mechanism for verifying the identity of the sender.
2.Data Integrity:
• They ensure that the content of the message has not been tampered with during transmission.
3.Non-Repudiation:
• The sender cannot deny having sent the message since the digital signature is unique to their private key.
4.Timestamping:
• Some digital signature schemes incorporate timestamps to provide evidence of when the signature was created.
• Applications of Digital Signatures:
1. Email Security:
• Digital signatures are used to sign and verify emails, ensuring their authenticity.
2. Document Signing:
• Digital signatures are used to sign electronic documents, providing a legally binding way to verify the
authenticity of the document and the identity of the signer.
3. Software Distribution:
• Code signing certificates use digital signatures to verify the authenticity and integrity of software, ensuring that
it has not been modified by malicious actors.
4. Financial Transactions:
• Digital signatures are employed in financial transactions to verify the authenticity of parties involved.
5. Authentication Protocols:
• They are used in various authentication protocols, such as TLS/SSL, to secure online communications.
• Popular Digital Signature Algorithms:
1.RSA (Rivest-Shamir-Adleman):
• Based on the mathematical properties of factoring large
composite numbers.
2.DSA (Digital Signature Algorithm):
• Designed for use with the Digital Signature Standard (DSS) for
U.S. government applications.
3.ECDSA (Elliptic Curve Digital Signature
Algorithm):
• Based on the mathematics of elliptic curves, providing strong
security with shorter key lengths compared to RSA.
4. Public Key Infrastructure (PKI)
• Public Key Infrastructure (PKI) is a comprehensive system that
facilitates secure communication and digital signatures on the
internet.
• It is based on asymmetric cryptography and provides a framework
for managing digital keys and certificates.
• PKI is widely used to secure various online activities, including
secure email communication, web browsing, and electronic
transactions.
• Purpose: Managing Public and Private Keys.
• Role: A framework that includes policies, processes, and
technologies to manage and distribute digital keys and
certificates.
• Key Components of PKI:
1.Public and Private Key Pairs:
• PKI relies on asymmetric cryptography, where each entity has a pair of cryptographic keys: a
public key and a private key. The public key is shared openly, while the private key is kept
secure.
2.Digital Certificates:
• Digital certificates are electronic documents that bind a public key to an individual or entity.
They are issued by Certificate Authorities (CAs) and contain information such as the owner's
name, public key, expiration date, and the digital signature of the CA.
3.Certificate Authority (CA):
• The CA is a trusted third party that verifies the identity of individuals or entities and issues
digital certificates. The CA's role is to establish trust in the authenticity of the public key.
4.Registration Authority (RA):
• The RA acts as the verifier for the CA, ensuring that the information provided by the entity
requesting a digital certificate is accurate. The RA forwards the verified information to the CA
for certificate issuance.
5.Certificate Revocation Lists (CRLs):
• CRLs are lists maintained by CAs that contain information about certificates that have been
revoked before their expiration dates. They are used by relying parties to check the status of a
certificate.
6.Public Key Directory or Repository:
• A directory or repository where digital certificates are stored and can be retrieved by users or
applications. LDAP (Lightweight Directory Access Protocol) is often used for this purpose.
• PKI Workflow:
1.Key Pair Generation:
• The user or entity generates a pair of public and private keys.
2.Certificate Enrollment:
• The user or entity requests a digital certificate from a CA or a Registration Authority (RA).
3.Identity Verification:
• The CA or RA verifies the identity of the entity making the certificate request.
4.Certificate Issuance:
• Upon successful verification, the CA issues a digital certificate, binding the public key to
the identity.
5.Certificate Distribution:
• The digital certificate is sent to the entity and can be made publicly available in a
directory.
6.Certificate Revocation:
• If a private key is compromised or the entity's status changes, the CA revokes the
certificate, and this information is added to the CRL.
7.Certificate Validation:
• Relying parties use the public key in the digital certificate to verify the authenticity of the
entity and establish a secure communication channel.
• Applications of PKI:
1.Secure Web Communication:
1. PKI is used to secure HTTPS connections between web browsers and servers,
ensuring the confidentiality and integrity of data.
2.Email Security:
1. PKI is employed for secure email communication using protocols like S/MIME
(Secure/Multipurpose Internet Mail Extensions).
3.Digital Signatures:
1. PKI enables the use of digital signatures for document signing, code signing, and
other authentication purposes.
4.Virtual Private Networks (VPNs):
1. PKI is used to establish secure VPN connections, providing encrypted
communication over public networks.
5.Smart Cards and Authentication Tokens:
1. PKI is integrated into smart cards and authentication tokens for secure access to
systems and networks.
6.Government and Enterprise Security:
1. PKI is widely used in government and enterprise environments to secure
communications and ensure the integrity of digital transactions.
Here are some examples of well-known Certificate Authorities:
1. DigiCert:
• A leading global Certificate Authority providing SSL/TLS and PKI solutions.
2. Symantec (Now Digicert):
• Acquired by DigiCert, Symantec was a major player in the field of SSL/TLS certificates.
3. Let's Encrypt:
• A free and open Certificate Authority that provides SSL/TLS certificates to enable HTTPS on
websites.
4. GlobalSign:
1. A global provider of SSL/TLS certificates and other PKI solutions.
5. Comodo CA (Now Sectigo):
• Renamed to Sectigo, it is a major provider of digital certificates, including SSL/TLS certificates.
6. Entrust Datacard:
• A provider of SSL/TLS certificates and other identity and security solutions.
7. GoDaddy:
• Known for domain registration services, GoDaddy also offers SSL/TLS certificates.
• It's important to note that the landscape of CAs evolves, with companies merging, rebranding, or
entering and exiting the market. When selecting a CA, it's crucial to choose one that is widely
recognized and trusted by major web browsers and operating systems to ensure the effectiveness of
Introduction to the TCP/IP Stack