Is Notes Ese
Is Notes Ese
Primes
1. A prime number is greater than 1 and has only two divisors: 1 and itself.
2. Examples: 2, 3, 5, 7, 11, etc.
3. 2 is the smallest and the only even prime number.
4. Prime numbers are essential for encryption as they make factoring difficult.
5. Large prime numbers are used in cryptographic algorithms like RSA.
6. Every composite number can be expressed as a product of prime numbers (prime
factorization).
7. The distribution of primes is irregular but follows some patterns (like the Prime Number
Theorem).
8. Generating large primes requires special algorithms (e.g., Miller-Rabin).
9. Primes are used to create keys in asymmetric cryptography.
10. Security increases with larger primes due to the complexity of factoring them.
Primality testing
Primality testing is the process of determining whether a given number is a prime number (a
number greater than 1 that is divisible only by 1 and itself). There are several algorithms for
primality testing, ranging from basic methods suitable for small numbers to advanced
probabilistic and deterministic methods used for very large numbers.
-Basic Methods
1. Trial Division
● Skip even numbers and test only divisibility by 2 and odd numbers.
● Use additional techniques like the 6k ± 1 rule (all primes > 3 can be written in this form).
-Probabilistic Tests
These tests are faster and suitable for very large numbers but provide only a high probability of
correctness.
1. Fermat Primality Test
● Based on Fermat's Little Theorem: If nn is prime, then a^(n−1)≡1 mod n for any 1<a<n.
● If the equality fails for some a, n is composite.
● However, some composite numbers (Carmichael numbers) may pass this test.
-Deterministic Tests
2. Eratosthenes' Sieve
-Use in Cryptography
These tests help ensure that large primes are reliably generated for secure key creation. Faster
probabilistic methods like Miller-Rabin are often preferred for their efficiency in practical
applications.
Fermats Test
The Fermat Primality Test is a probabilistic algorithm based on Fermat's Little Theorem,
which states:
If n is a prime number, then for any integer a such that 1 < a < n,
a^(n−1)≡1(modn)
-Key Points
-Pros
-Cons
Miller-Rabin’s Test
-Key Idea
The test is based on properties of modular arithmetic. It starts with the observation:
a^n≡a(modn)
for any integer a. This implies a specific behavior for a^n−1 mod n, which is leveraged in the
test.
-How It Works
-Probabilistic Nature
-Advantages
-Limitations
The Miller-Rabin test strikes a balance between efficiency and reliability, making it a popular
choice for primality testing in practical applications.
Factorization
● Factorization is finding the prime numbers that multiply together to give a target
number.
○ Example: For 15, the prime factors are 3 and 5.
● Why it matters in cryptography:
○ Many cryptosystems (like RSA) rely on the fact that factorizing large numbers is
computationally difficult.
● Factorization methods:
○ Trial Division: Check divisors one by one (slow for large numbers).
○ Pollard’s rho algorithm: Efficient for finding small factors of large numbers.
○ Elliptic Curve Factorization: Uses elliptic curves to find factors.
1. Uses two keys: a public key for encryption and a private key for decryption.
2. No need to share the private key, enhancing security.
3. Public keys can be freely distributed, e.g., on websites.
4. Private keys must be kept secret to prevent unauthorized decryption.
5. Asymmetric cryptography solves the key distribution problem of symmetric systems.
6. Common algorithms: RSA, ECC (Elliptic Curve Cryptography), and Diffie-Hellman.
7. It is widely used in securing internet communications like HTTPS and email.
8. Slower than symmetric cryptography but offers stronger security.
9. RSA and ECC rely on mathematical problems like factorization and elliptic curves.
10. Supports digital signatures, ensuring data authenticity and integrity.
RSA Cryptosystem
The RSA Cryptosystem is a widely used asymmetric encryption system based on the
mathematical properties of large prime numbers and modular arithmetic. It is named after its
inventors, Ron Rivest, Adi Shamir, and Leonard Adleman, who introduced it in 1977.
-Key Concepts
1. Asymmetric Cryptography:
○ Uses a pair of keys: a public key (used for encryption) and a private key (used
for decryption).
○ Ensures secure communication where only the intended recipient can decrypt the
message.
2. Security Basis:
RSA involves three main steps: key generation, encryption, and decryption.
1. Key Generation
2. Encryption
c=m^e mod n
3. Decryption
To decrypt a ciphertext c:
m= c^d mod n
Where m is the original message.
-Strength of RSA
● Factoring Challenge: Breaking RSA requires factoring nn into pp and qq, which
becomes computationally infeasible for very large nn (e.g., 2048-bit keys).
● Key Size: Larger keys offer higher security but require more computational resources.
-Applications
1. Secure Communication: Encrypt messages so that only the intended recipient can
read them.
2. Digital Signatures: Ensure the authenticity and integrity of messages or documents.
3. Key Exchange: Securely exchange symmetric encryption keys in protocols like TLS.
-Limitations
Euler's Totient Function, denoted by ϕ(n), is an important function in number theory. It counts the
number of integers from 11 to n that are coprime to n. Two numbers are coprime if their
greatest common divisor (gcd) is 11.
-Definition
Properties of ϕ(n)
3. Multiplicative Property:
If a and b are coprime (gcd(a,b)=1), then:
ϕ(a⋅b)=ϕ(a)⋅ϕ(b)
4. General Formula:
-Example Calculations
-Applications of Euler’s Totient Function
1. RSA Cryptosystem:
○ Used to calculate the totient value ϕ(n)\phi(n) for determining encryption and
decryption keys.
○ In RSA, nn is the product of two primes pp and qq, and ϕ(n)=(p−1)(q−1)\phi(n) =
(p-1)(q-1).
2. Euler’s Theorem:
Message authentication ensures that a message is genuine and hasn’t been altered. Hash
functions and other authentication techniques help achieve this.
Authentication Functions
Authentication functions are mechanisms designed to ensure the integrity and authenticity of a
message or communication. They confirm that:
1. Message Encryption:
○
Encrypting a message ensures confidentiality and, indirectly, authentication.
○
If only the sender and receiver share the decryption key, the receiver can verify
the sender.
○ Example: Symmetric encryption with a shared key (like AES).
2. Message Authentication Code (MAC):
○A MAC is a value generated using a secret key and the message content.
○It is appended to the message. The recipient uses the same secret key to verify
the MAC.
○ Ensures both integrity and authenticity but doesn’t provide confidentiality.
3. Hash-Based MAC (HMAC):
○ Uses block cipher algorithms (like AES) instead of hash functions to compute a
MAC.
○ Ideal for systems where block ciphers are already implemented.
5. Digital Signatures:
—-------------------------------------------------------------------------------------------------------------------
Authentication Codes (ACs) are mechanisms used to ensure the authenticity and integrity of a
message. They are similar in concept to MACs (Message Authentication Codes), but they might
be less standardized and used in simpler authentication systems.
-Key Points:
1. Purpose:
○ To prevent message forgery and tampering.
○ Ensures that a message comes from the correct sender.
2. Working Mechanism:
○ The sender uses a secret key to generate an authentication code for the
message.
○ The receiver, using the same secret key, verifies the authentication code to
validate the message.
3. Key Features:
○ Relies on symmetric keys (shared secret).
○ Protects against impersonation and alteration.
○ Simple and efficient for systems with limited computational power.
4. Drawbacks:
○ Requires a pre-shared key between sender and receiver.
○ Doesn’t support scalability like public-key systems.
________________________________________________________________________
HMAC is a type of Message Authentication Code (MAC) that combines a cryptographic hash
function (like SHA-256) with a secret key to ensure message integrity and authenticity. It is
widely used in secure communication protocols like TLS, IPsec, and HTTPS.
1. Input:
○ A message MM.
○ A secret key KK.
○ A cryptographic hash function HH (e.g., SHA-256 or SHA-1).
2. Key Padding:
○ Two fixed padding values, ipadipad (inner padding) and opadopad (outer
padding), are XORed with the key KK.
4. Hashing Steps:
○ The final hash value is the HMAC, which is appended to the message for
authentication.
1. Message Integrity:
○ Verifies that the message was sent by someone possessing the secret key.
3. Resistance to Attacks:
○ Can use various hash functions (SHA-256, SHA-1, MD5) depending on security
requirements.
5. Efficient and Secure:
-Advantages of HMAC
-Applications of HMAC
1. Input:
○ A message MM.
○ A secret key KK.
○ A block cipher algorithm CC (e.g., AES).
2. Key Derivation:
○
Derive two subkeys K1K_1 and K2K_2 from the main key KK.
○
These subkeys are computed using a shift and XOR operation based on the
encryption of a zero block.
3. Message Padding:
○ If the message MM isn’t a multiple of the block size, it is padded with a special
padding scheme (e.g., appending a "1" bit followed by "0"s).
○ If it’s already a multiple of the block size, no padding is added.
4. Block Processing:
○ The final encrypted block is the CMAC value, which is appended to the message
for verification.
○ Ensures the message hasn't been tampered with and authenticates the sender.
2. Based on Strong Block Ciphers:
-Advantages of CMAC
1. Security:
○ Stronger than earlier MAC methods, particularly for variable-length messages.
2. Flexibility:
○ Works with any block cipher, although AES is commonly used.
3. Efficiency:
○ Computationally efficient, especially when block ciphers are already in use.
-Applications of CMAC
1. Network Security:
○ Verifying the integrity and authenticity of transmitted messages (e.g., IPsec).
2. Data Storage:
○ Ensuring the integrity of stored data.
3. Secure Protocols:
○ Used in cryptographic protocols requiring message authentication (e.g., IEEE
802.11).
Hash Functions
A hash function is a mathematical algorithm that converts an input (or "message") into a
fixed-size string of characters, which is typically a sequence of numbers and letters. The output
is called a hash value or digest. Hash functions are widely used in cryptography to ensure data
integrity, secure password storage, and message authentication.
1. Deterministic:
○Regardless of input size, the output is always a fixed length. For example,
SHA-256 always produces a 256-bit hash.
3. Fast Computation:
○ The hash function should compute the hash value efficiently for any input.
4. Preimage Resistance:
○ It should be hard to find two different inputs that produce the same hash value.
6. Avalanche Effect:
○ A small change in the input should result in a significantly different hash value.
1. Data Integrity:
○ Verifying that data has not been altered (e.g., during file downloads).
2. Password Storage:
○ Hashing passwords before storing them ensures they are not stored in plaintext.
3. Message Authentication:
○ Hash functions are used to create a fixed-size digest of data, which is then
signed.
5. Blockchain:
1. Efficiency:
○ They are computationally fast and handle large data efficiently.
2. Security:
○ Strong hash functions provide robust resistance to tampering and forgery.
3. Simplicity:
○ Easy to implement and integrate into various systems.
-Digital Signatures
○The sender generates a pair of keys: a private key (kept secret) and a public key
(shared openly).
2. Signing:
○ The sender creates a hash of the message using a hash function (e.g.,
SHA-256).
○ The hash is encrypted with the sender's private key to produce the digital
signature.
3. Verification:
○ The recipient uses the sender’s public key to decrypt the signature.
○ The result is compared with the hash of the received message to verify
authenticity and integrity.
Authentication Protocols
Authentication protocols are structured procedures that verify the identities of entities (users,
devices, or systems) during communication. They prevent unauthorized access and ensure
secure interaction.
1. Challenge-Response Protocol:
○A system that uses digital certificates to bind public keys to entities (like people or
organizations).
○ Ensures secure key exchange and authentication.
5. Zero-Knowledge Protocols:
○ Allow one party to prove they know a value (e.g., a password) without revealing
the value itself.
○ Widely used in secure login systems.
Benefits:
Use Cases:
Digital signatures and authentication protocols are foundational for modern security, enabling
trusted interactions across diverse applications.
____________________________________________________________________________
The Digital Signature Standard (DSS) is a framework established by the U.S. National
Institute of Standards and Technology (NIST) for creating digital signatures. It ensures secure
and standardized implementation of digital signature algorithms for data integrity and
authentication.
1. Purpose:
○The sender generates a private key (used for signing) and a corresponding public
key (used for verification).
2. Message Hashing:
○ The private key encrypts the hash to produce the digital signature.
4. Signature Verification:
○ The receiver decrypts the signature using the sender's public key.
○ The output is compared with the hash of the received message. If they match,
the signature is valid.
-Advantages of DSS
1. Standardization:
○ Provides consistent guidelines for implementing secure digital signatures.
2. Security:
○ Incorporates strong algorithms like RSA and ECC.
3. Efficiency:
○ ECDSA reduces computational load and key size requirements compared to
RSA.
-Applications of DSS
1. Secure Communication:
○ Verifies sender authenticity in protocols like HTTPS and TLS.
2. Document Signing:
○ Ensures the authenticity and integrity of electronic documents.
3. E-commerce and Banking:
○ Used to authenticate financial transactions.
4. Blockchain:
○ Facilitates secure transactions and identities in distributed ledgers.
The DSS requires the use of secure cryptographic hash functions to generate message digests
for digital signature creation. Commonly used hash functions include:
Kerberos is a trusted third-party authentication protocol designed to provide secure and reliable
identity verification in networked environments. It ensures that users and services can prove
their identities to each other in a secure manner, even over untrusted networks.
○
Kerberos uses cryptographic tickets to authenticate users and grant access to
services.
○ A ticket is a time-sensitive token encrypted with a secret key.
3. Symmetric Encryption:
○ After the initial authentication, a user can access multiple services without
re-entering their credentials during the ticket's validity period.
-Components of Kerberos
1. Client:
○ The user or device attempting to access a network service.
2. Key Distribution Center (KDC):
○ The server hosting the resource or application the client wants to access.
1. Authentication Phase:
○ The client sends a request to the Authentication Server (AS) with the user’s ID.
○ The AS verifies the user and issues a Ticket Granting Ticket (TGT) encrypted
with the user's password.
○ The TGT contains:
■ The user’s ID.
■ A session key.
■ An expiration timestamp.
2. Ticket Granting Phase:
○ The client presents the TGT to the Ticket Granting Server (TGS) to request
access to a specific service.
○ The TGS issues a Service Ticket (ST) encrypted with the secret key of the
Service Server (SS).
3. Access Phase:
○ The client sends the Service Ticket (ST) to the Service Server (SS) to access
the desired resource.
○ The SS validates the ticket and grants access if it is valid.
-Features of Kerberos
1. Secure Authentication:
-Advantages of Kerberos
-Disadvantages of Kerberos
1. Dependency on KDC:
-Applications of Kerberos
1. Enterprise Networks:
The X.509 Authentication Service is a standard framework for public key infrastructure
(PKI). It defines the format for digital certificates and the mechanisms for verifying the
authenticity of entities (users, devices, or servers) in secure communications. It is widely used in
protocols such as SSL/TLS, S/MIME, and VPNs.
1. Digital Certificates:
○ The central element of X.509, which binds a public key to an entity’s identity.
○ A certificate includes information such as the entity's name, public key, and the
issuing Certificate Authority (CA).
2. Certificate Authority (CA):
1. Version:
○ The start and end dates during which the certificate is valid.
6. Subject:
○ Additional fields for enhanced functionality (e.g., Key Usage, Subject Alternative
Names).
9. Signature:
1. Certificate Issuance:
○ A user or entity generates a key pair (private and public keys) and submits the
public key to a CA along with identification information.
○ The CA verifies the entity’s identity and issues a digital certificate signed with the
CA’s private key.
2. Verification Process:
○ The recipient of a certificate uses the CA’s public key to verify the CA’s signature
on the certificate.
○ If the signature is valid, the certificate is trusted.
3. Mutual Authentication (Optional):
-Applications of X.509
1. SSL/TLS Certificates:
-Advantages of X.509
1. Trust and Authentication:
-Challenges of X.509
1. Complexity of PKI:
○ CRLs can grow large, and alternatives like OCSP (Online Certificate Status
Protocol) add operational overhead.
3. Trust Dependency:
Public Key Infrastructure (PKI) is a framework of technologies, policies, and processes that
enables the secure exchange of information over networks by using asymmetric
cryptography. It provides a reliable way to manage and distribute public and private keys,
ensuring trust, security, and authentication in digital communications.
○ A list maintained by the CA that contains certificates that are no longer valid,
such as those revoked due to compromise or expiration.
5. Online Certificate Status Protocol (OCSP):
○ Guidelines that define how certificates and keys are issued, managed, revoked,
and used securely.
○ The RA verifies the identity of the entity using provided documentation or other
mechanisms.
4. Certificate Issuance:
○ The CA issues a digital certificate, binding the entity's identity to their public key.
5. Certificate Distribution:
-Functions of PKI
1. Authentication:
-Applications of PKI
1. SSL/TLS Certificates:
○ Encrypts and signs emails using protocols like S/MIME to ensure privacy and
authenticity.
3. Code Signing:
1. Scalability:
○ Applicable across diverse use cases, including web security, email, and file
encryption.
4. Strong Security:
-Challenges of PKI
1. Complexity:
Symmetric Key Distribution involves securely sharing a secret key between two parties for
encryption and decryption of messages. Since symmetric encryption uses the same key for both
operations, ensuring its secure delivery is critical.
-Methods of Distribution:
1. Manual Distribution:
○ Exchanging keys in person or using a secure courier.
○ Simple but impractical for large-scale systems.
2. Using a Trusted Third Party (e.g., Kerberos):
○ A trusted intermediary helps generate and distribute keys securely.
3. Key Encryption Keys (KEK):
○ Encrypting the symmetric key with a more secure key and transmitting it over the
network.
4. Key Distribution Center (KDC):
○ Centralized server that manages key distribution for users in a network.
Kerberos
Symmetric Key Agreement refers to the process by which two parties establish a shared
secret key for encryption and decryption of data. The key is the same for both encryption and
decryption, hence the term symmetric key. The challenge is to securely agree upon this key,
especially when communication occurs over an insecure channel.
-Key Characteristics
1. Shared Secret:
○ Unlike public-key methods, symmetric key agreement does not involve separate
encryption and decryption keys.
○ A widely-used protocol that allows two parties to agree on a shared secret over
an insecure channel.
○ Both parties contribute to the key computation using modular arithmetic and large
prime numbers.
○ Vulnerable to man-in-the-middle attacks without authentication.
2. Kerberos:
○Uses a trusted third party (Key Distribution Center, or KDC) to mediate and
distribute symmetric keys securely.
○ Each session key is encrypted with the user’s pre-shared secret key, ensuring
confidentiality.
3. Dynamic Key Generation:
○Keys are generated during each communication session, often using random
number generators or cryptographic functions.
4. Ephemeral Keys:
○ Temporary keys generated for a single session to enhance security and prevent
replay attacks.
-Security Considerations
○ Ensure unique session keys to prevent attackers from reusing intercepted keys.
3. Scalability:
1. Efficiency:
○ In systems with many users, the number of keys required increases significantly.
3. No Non-Repudiation:
○ Since both parties use the same key, it is impossible to prove who encrypted or
decrypted the data.
-Applications
○ Applications like Signal and WhatsApp use symmetric keys to encrypt message
payloads.
4. Wi-Fi Security:
○ Protocols like WPA2 use symmetric key encryption for secure wireless
communication.
Email security is critical because emails often contain sensitive information, including personal
data, financial details, and business communications. Securing email at the application layer
involves methods to ensure confidentiality, authentication, integrity, and non-repudiation
during email communication.
1. Confidentiality: Ensuring that only the intended recipient can read the email.
2. Authentication: Verifying that the email sender is who they claim to be.
3. Integrity: Ensuring the email content is not altered during transmission.
4. Non-repudiation: Ensuring the sender cannot deny sending the email.
5. Phishing and Spoofing Attacks: Protecting users from fraudulent emails designed to
steal information.
Various technologies and protocols secure email communication at the application layer:
3. Authentication Protocols
● SPF (Sender Policy Framework): Prevents email spoofing by verifying the sender's IP
address.
● DKIM (DomainKeys Identified Mail): Ensures the email’s integrity using digital
signatures.
● DMARC (Domain-based Message Authentication, Reporting, and Conformance):
Combines SPF and DKIM to enhance protection against email spoofing.
● Filters inbound and outbound emails to detect phishing, malware, and spam.
● Enforces email encryption policies and prevents data leakage.
● ProtonMail, Tutanota, and Gmail Confidential Mode provide secure, encrypted email
services.
○ The sender encrypts the email content using the recipient's public key.
○ Only the recipient can decrypt the message using their private key.
2. Digital Signatures for Authentication and Integrity
○ SPF and DKIM validate the sender’s domain and email content.
1. Sender Side:
○ Uses fast symmetric encryption to encrypt the message and secure public-key
cryptography to encrypt the symmetric key.
2. Key Rings
PGP uses key rings to store and manage public and private keys:
○ Stores trusted public keys of others, used for encrypting messages sent to them
and verifying their digital signatures.
2. Private Key Ring:
○ Stores the user's private keys, used for decrypting messages and creating digital
signatures.
Management Features:
3. PGP Certificates
1. Decentralized Trust:
○Unlike centralized systems (e.g., S/MIME), PGP does not rely on a central
Certificate Authority (CA).
2. Key Signing:
○ Users validate and sign each other’s public keys to establish trust.
3. Trust Levels:
○ Users assign trust levels (e.g., full, marginal, or none) to public keys based on
personal judgment.
4. Trust Chains:
○ Trust in a key can be derived indirectly if a trusted user has signed that key.
5. PGP Packet
PGP messages are structured into packets, each containing specific data. Key packet types
include:
6. PGP Messages
A PGP message consists of one or more packets, structured for secure communication:
1. Message Encryption:
○ The sender hashes the message and encrypts the hash with their private key to
create a digital signature.
○ The recipient decrypts the signature with the sender’s public key to verify integrity
and authenticity.
3. Final Structure:
Summary:
MIME is a standard that extends email formats to support multimedia content such as text,
images, audio, and video. It allows the transmission of:
Components of MIME:
2. S/MIME Overview
Key Features:
1. Encryption:
○ Verifies the authenticity of the sender and ensures the integrity of the message.
3. Certificate-Based Trust:
○ Supported by most email clients (e.g., Microsoft Outlook, Apple Mail, Gmail).
○ The sender encrypts the email content with the recipient's public key.
○ A digital signature is added using the sender’s private key.
2. Receiving an Encrypted Email:
4. S/MIME Certificates
S/MIME relies on X.509 digital certificates to manage public keys and authenticate users.
1. Certificate Components:
○ Trusted third parties (like DigiCert, GlobalSign) issue and validate certificates.
6. Benefits of S/MIME
7. Applications of S/MIME