626_CRYPTOGRAPHY AND NETWORK SECURITY.pdf
Document Details
Full Transcript
Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 CRYPTOGRAPHY & NETWORK SECURITY...
Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 CRYPTOGRAPHY & NETWORK SECURITY Syllabus Module I: Computer Security Introduction, Need for security, Principles of Security, Plain text and Cipher Text, Encryption and Decryption, Symmetric and Asymmetric Key Cryptography, Steganography, Key Range and Key Size, Possible Types of Attacks. Module II: Digital Certificates and Public Key Infrastructure (PKI) Digital Certificates, Private Key Management, The PKI-X Model, Public Key Cryptography Standards (PKCS), XML,PKI and Security, Hash functions, Key Pre-distribution, Blom’s Scheme, Diffie- Hellman Key Pre-distribution, Kerberos. Module III: Network Security, Firewalls and Virtual Private Networks Brief Introduction to TCP/IP, Firewalls, IP Security, Virtual Private Networks (VPN), Intrusion, Internet Security Protocols: Basic concepts, Secure Socket Layer (SSL), Transport Layer Security (TLS), Email Security: Pretty Good Privacy (PGP). Module IV: User Authentication and Kerberos Authentication basics, Passwords, Authentication Tokens, Certificate-based Authentication, Biometric Authentication, Kerberos, Key Distribution Center (KDC), Security Handshake Pitfalls, Single Sign On (SSO) Approaches. Module V: IP Security Peer to Peer Server, Create the WebSocket Server, Connect to Blockchain Peers, Handle Messages from Peers, Synchronize the Blockchain across Peers. Module VI: Operating System Security Identification of Authorization, User management, Overview of Software firewall, Policy, Registry, Disaster Recovery, OS Security management, IAS Authentication. Module VII: Wireless Security Introduction of WLAN, 802.11 Standards (802.11a, 802.11b, 802.11g, 802.11n) security type, Overview of SSID WLAN Security authentication (WEP, TKIP, WAP1, WAP2). Module VIII: Malicious Logic Malicious Logic, Types of Malicious Logic: Virus, Worm, Trojan Horse, Zombies, Denial of Service Attacks, Intrusion, Intruders and their types, Intrusion Detection System, Intrusion Prevention System. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata Pa ge |1 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Study Material Cryptography & Network Security & BNCSD502C Module I: Computer Security Introduction to Security 1. Need for Security In today's digital world, the need for security is paramount due to: Sensitive Information: Protection of personal, financial, and medical data. Business Integrity: Safeguarding intellectual property and trade secrets. National Security: Preventing cyber-attacks on critical infrastructure. Privacy: Ensuring individuals' rights to privacy are maintained. 2. Principles of Security The core principles of security, often referred to as the CIA Triad, are: Confidentiality: Ensuring that information is accessible only to those authorized to have access. Integrity: Maintaining the accuracy and completeness of data. Availability: Ensuring that authorized users have access to information and resources when needed. 3. Plain Text and Cipher Text Plain Text: The original message or data that is readable without any decryption. Cipher Text: The encoded version of the plain text produced by an encryption algorithm. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata Pa ge |2 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Example: If "HELLO" is the plain text, it could be transformed into something unreadable like "KHOOR" using a simple cipher. 4. Encryption and Decryption Encryption: The process of converting plain text into cipher text using an algorithm and an encryption key. Decryption: The process of converting cipher text back to plain text using a decryption key. 5. Symmetric Key Cryptography Definition: Uses the same key for both encryption and decryption. Example Algorithms: AES (Advanced Encryption Standard), DES (Data Encryption Standard). Advantages: Faster encryption and decryption processes. Suitable for large amounts of data. Symmetric Key Cryptography Definition: Uses the same key for both encryption and decryption. Example Algorithms: AES (Advanced Encryption Standard) DES (Data Encryption Standard) 3DES (Triple DES) Advantages: Faster encryption and decryption processes. Suitable for large amounts of data. Disadvantages: Key distribution is a challenge since both parties need to securely share the key. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata Pa ge |3 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Example: Algorithm: AES 1. Plain Text: "HELLO" 2. Key: "SECRETKEY" 3. Encryption Process: o Apply AES encryption using "SECRETKEY" to transform "HELLO" into cipher text. 4. Cipher Text: "A1B2C3D4" 5. Decryption Process: o Apply AES decryption using the same "SECRETKEY" to transform "A1B2C3D4" back into "HELLO". 6. Plain Text: "HELLO" Disadvantages: Key distribution is a challenge since both parties need to securely share the key. 6. Asymmetric Key Cryptography Definition: Uses a pair of keys – a public key for encryption and a private key for decryption. Example Algorithms: RSA (Rivest-Shamir-Adleman), ECC (Elliptic Curve Cryptography). Advantages: Solves the key distribution problem. Enhances security since the private key is never shared. Disadvantages: Slower than symmetric key algorithms. More computationally intensive. 7. Steganography Definition: The practice of hiding messages or information within other non-secret text or data. Example: Embedding a message within an image file. Applications: Digital watermarking. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata Pa ge |4 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Covert communication. 8. Key Range and Key Size Key Range: The total number of possible keys that can be used in an encryption algorithm. Key Size: The length of the key, typically measured in bits. Impact on Security: Larger key sizes generally provide higher security but may require more computational resources. Example: A 128-bit key has 21282^{128}2128 possible combinations. 9. Possible Types of Attacks Brute Force Attack: Trying all possible keys until the correct one is found. Phishing: Deceptive attempts to obtain sensitive information by pretending to be a trustworthy entity. Man-in-the-Middle Attack: Intercepting and altering communication between two parties. SQL Injection: Inserting malicious SQL code into a query to manipulate the database. Encryption and Decryption Example of Symmetric Key Encryption: Algorithm: AES (Advanced Encryption Standard) 1. Plain Text: "HELLO" 2. Key: "SECRETKEY" 3. Encryption Process: o Apply AES encryption using "SECRETKEY" to transform "HELLO" into cipher text. 4. Cipher Text: "A1B2C3D4" 5. Decryption Process: o Apply AES decryption using the same "SECRETKEY" to transform "A1B2C3D4" back into "HELLO". 6. Plain Text: "HELLO" Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata Pa ge |5 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Example of Asymmetric Key Encryption: Algorithm: RSA (Rivest-Shamir-Adleman) 1. Public Key: Used for encryption. 2. Private Key: Used for decryption. 3. Plain Text: "HELLO" 4. Encryption Process: o Encrypt "HELLO" using the recipient's public key to produce cipher text. 5. Cipher Text: "XYZ123" 6. Decryption Process: o Decrypt "XYZ123" using the recipient's private key to get back "HELLO". 7. Plain Text: "HELLO" Key Range and Key Size Impact on Security: DES: 56-bit key, vulnerable to brute-force attacks due to its smaller key size. AES: Key sizes of 128, 192, and 256 bits, providing stronger security against brute-force attacks. Comparison: 56-bit Key: 2562^{56}256 combinations, easier to break. 128-bit Key: 21282^{128}2128 combinations, extremely difficult to break with current technology. Example Calculation: For a 128-bit key: 2^128=340,282,366,920,938,463,463,374,607,431,768,211,4562 Possible Types of Attacks Brute Force Attack: Description: An attacker tries every possible key combination until the correct key is found. Defense: Use longer key sizes to make brute-force attacks infeasible Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata Pa ge |6 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Phishing: Description: An attacker sends emails or messages pretending to be a reputable source to trick individuals into revealing sensitive information. Defense: Educate users to recognize phishing attempts, use email filtering. Man-in-the-Middle Attack: Description: An attacker intercepts and possibly alters the communication between two parties. Defense: Use end-to-end encryption, mutual authentication. SQL Injection: Description: An attacker inserts malicious SQL queries into input fields to manipulate the database. Defense: Use prepared statements, parameterized queries, and input validation. Multiple Choice Question State the core principles of security: A) Confidentiality, Integrity, Availability B) Confidentiality, Authentication, Non-repudiation C) Integrity, Availability, Non-repudiation D) Confidentiality, Authentication, Availability What does the principle of confidentiality ensure? A) Data is accurate and complete B) Data is accessible only to authorized users C) Systems are available when needed D) Data can be changed by any user Which encryption algorithm uses the same key for both encryption and decryption? A) RSA B) AES C) ECC D) Diffie-Hellman Explain the process of converting plain text to cipher text: A) Decryption B) Authentication C) Encryption Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata Pa ge |7 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 D) Hashing How is plain text different from cipher text? A) Plain text is encoded; cipher text is readable B) Plain text is readable, cipher text is encoded C) Plain text uses a private key, cipher text uses a public key D) Plain text is always longer than cipher text Which algorithm is an example of asymmetric key cryptography? A) DES B) 3DES C) AES D) RSA Choose the correct definition of integrity in security: A) Ensuring data is accessible only to authorized users B) Maintaining the accuracy and completeness of data C) Ensuring systems are available when needed D) Encrypting data for security What is steganography primarily used for? A) Encrypting data B) Hiding information within non-secret text or data C) Generating digital signatures D) Creating hash values Write an example of a symmetric key encryption algorithm: A) RSA B) ECC C) AES D) Diffie-Hellman Find the typical key sizes used by AES: A) 56 bits, 128 bits, 192 bits B) 64 bits, 128 bits, 256 bits C) 128 bits, 192 bits, 256 bits D) 256 bits, 384 bits, 512 bits What problem does asymmetric key cryptography solve? Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata Pa ge |8 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 A) Decryption speed B) Key distribution C) Encryption speed D) Data availability Explain what a brute force attack involves: A) Sending phishing emails B) Trying all possible keys until the correct one is found C) Intercepting and altering communications D) Injecting malicious code into a database Which principle of security ensures systems are available when needed? A) Confidentiality B) Integrity C) Availability D) Authentication Choose the correct statement about symmetric key cryptography: A) It uses two keys for encryption and decryption B) It is slower than asymmetric key cryptography C) It uses the same key for both encryption and decryption D) It is not suitable for large amounts of data What is the role of a private key in asymmetric cryptography? A) Encrypting data B) Decrypting data C) Generating hash values D) Hiding messages Give examples of situations where encryption is necessary: A) Browsing public websites B) Sending confidential emails C) Posting on social media D) Reading news articles How does a digital signature ensure integrity? A) By encrypting data B) By verifying the data has not been altered C) By hiding data within other data D) By distributing keys securely Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata Pa ge |9 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 State an example of a man-in-the-middle attack: A) Encrypting data with AES B) Intercepting and altering emails C) Sending phishing emails D) Injecting malicious SQL queries What does the key size in cryptography determine? A) The speed of encryption B) The complexity and security level C) The type of data to be encrypted D) The method of encryption Choose the correct definition of a cipher text: A) The original readable message B) The encrypted, unreadable message C) The key used for encryption D) The process of converting plain text Explain how SQL injection works: A) By encrypting SQL queries B) By intercepting and modifying network traffic C) By inserting malicious SQL code into input fields D) By sending phishing emails What is a common defense against phishing attacks? A) Using longer keys B) Educating users to recognize phishing attempts C) Encrypting all data D) Hiding data within images Find the primary application of digital watermarking: A) Encrypting messages B) Hiding ownership information in digital media C) Generating digital signatures D) Decrypting hidden messages Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 10 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 State one of the advantages of symmetric key cryptography: A) Solves the key distribution problem B) Enhances security with two keys C) Faster encryption and decryption processes D) Requires more computational resources What is the purpose of using checksums and hash functions? A) Encrypting data B) Hiding information C) Verifying data integrity D) Distributing keys Explain the concept of key distribution in cryptography: A) The process of hiding keys within data B) The method of sharing encryption keys securely C) The technique of generating encryption keys D) The act of encrypting keys Choose an example of a symmetric encryption algorithm: A) RSA B) ECC C) AES D) Diffie-Hellman What is the role of a public key in asymmetric cryptography? A) Decrypting data B) Encrypting data C) Hiding messages D) Verifying integrity Give examples of attacks that compromise availability: A) Brute force attacks B) Denial of Service (DoS) attacks C) Phishing attacks D) SQL injection attacks How can digital signatures be used in communication? A) To encrypt messages B) To verify the authenticity and integrity of messages Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 11 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 C) To hide messages within other data D) To generate encryption keys Short Type Question: 1.What is cryptography? 2. Why is network security important? 3. List the core principles of security. 4. What does the principle of confidentiality ensure? 5. Define plain text and cipher text. 6.What is the difference between encryption and decryption? 7. Name two symmetric encryption algorithms. 8. What is the primary advantage of symmetric key cryptography? 9. Explain the key pair usage in asymmetric key cryptography. 10. What is steganography? 11.Give an example of how steganography can be used. 12.What does key size in cryptography determine? 13.Why are larger key sizes generally more secure? 14.Describe a brute force attack. 15.What is phishing? 16.How can man-in-the-middle attacks be prevented? 17.What is SQL injection? 18.List two defenses against SQL injection attacks. 19.What is the role of a digital signature in ensuring integrity? 20.How does asymmetric key cryptography solve the key distribution problem? Long Type Questions Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 12 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 1.Explain the importance of network security and the types of threats it addresses. 2.Discuss the core principles of security and their significance in maintaining a secure system. 3.Describe the process of encryption and decryption, and differentiate between symmetric and asymmetric key cryptography. 4.Explain the concept of steganography and its various methods with examples. 5.Discuss the impact of key size on the security and performance of cryptographic algorithms. 6.What are the possible types of attacks in network security, and how can they be mitigated? 7.Explain the role of digital signatures in ensuring data integrity and authenticity. 8.Describe the key distribution problem and how asymmetric key cryptography addresses it. 9.Discuss the advantages and disadvantages of symmetric key cryptography. 10.Explain how brute force attacks work and the strategies to defend against them. 11.What is phishing, and what measures can be taken to prevent it? 12.Describe the man-in-the-middle attack and how encryption can protect against it. 13.What is SQL injection, and what are its potential consequences? 14.Explain the concept of key range and its significance in cryptographic security. 15.Discuss the role of multi-factor authentication in enhancing security. 16.Describe the advantages and disadvantages of asymmetric key cryptography. 17.Explain the concept of digital watermarking and its applications. 18.What are the challenges of key management in symmetric key cryptography, and how can they be addressed? 19.Describe the role of hashing in ensuring data integrity and security. 20.Discuss the significance of end-to-end encryption in secure communication. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 13 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Module II: Digital Certificates and Public Key Infrastructure (PKI) Digital Certificates Definition Digital certificates are electronic documents used to verify the ownership of a public key by the named subject of the certificate. They are issued by a trusted entity known as a Certificate Authority (CA). Components Subject: The entity that the certificate represents. Public Key: The public key belonging to the subject. Issuer: The CA that issued the certificate. Serial Number: A unique identifier for the certificate. Validity Period: The timeframe during which the certificate is valid. Signature: The digital signature of the CA. Example SSL/TLS Certificate: When you visit a secure website (e.g., https://www.example.com), your browser checks the website's SSL certificate. This certificate includes the website's public key, the domain name, and the CA's digital signature. If the certificate is valid, your browser establishes a secure connection. Private Key Management Importance Proper management of private keys is essential to maintain the security of encrypted communications and digital signatures. Methods Key Storage: Securely storing private keys using hardware security modules (HSMs) or encrypted software solutions. o Example: Banks use HSMs to store private keys securely, ensuring they are not exposed to unauthorized access. Key Distribution: Distributing keys in a secure manner to authorized parties. o Example: A company uses secure email or courier services to distribute private keys to employees. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 14 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Key Lifespan: Regularly updating and replacing keys to minimize the risk of compromised keys. o Example: Organizations might rotate SSH keys periodically to maintain security. The PKI-X Model Public Key Infrastructure (PKI) PKI is a framework for managing public-key encryption and digital certificates. Components Certificate Authority (CA): Issues and verifies digital certificates. o Example: Let's Encrypt provides free SSL/TLS certificates to secure websites. Registration Authority (RA): Authenticates the entity requesting a certificate before forwarding the request to the CA. o Example: When applying for an SSL certificate, the RA verifies the domain ownership and the applicant’s identity. Certificate Revocation List (CRL): A list of certificates that have been revoked before their expiration date. o Example: If a private key is compromised, the corresponding certificate is added to the CRL. X.509 Standard: The most widely used standard for defining the format of public key certificates. o Example: X.509 certificates are used in protocols such as SSL/TLS and S/MIME. Public Key Cryptography Standards (PKCS) Overview PKCS is a set of standards for public key cryptography developed by RSA Laboratories. Standards PKCS#1: RSA Cryptography Standard. o Example: Defines methods for encrypting and signing data using RSA, including padding schemes. PKCS#7: Cryptographic Message Syntax Standard. o Example: Used in S/MIME for securing email messages, providing a standard format for signed and encrypted messages. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 15 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 PKCS#12: Personal Information Exchange Syntax Standard. o Example: Defines a format for storing and transporting private keys and certificates, often used in SSL/TLS configurations. XML, PKI, and Security XML Security XML security refers to the use of XML encryption and XML signatures to secure data. Applications Web Services: Securing SOAP messages in web services. Digital Communication: Protecting data integrity and confidentiality in digital transactions. Standards XML Signature: Provides integrity, message authentication, and signer authentication. o Example: Digital signatures on SOAP messages ensure that the message has not been tampered with and verifies the sender’s identity. XML Encryption: Ensures the confidentiality of XML documents. o Example: Encrypting sensitive parts of an XML document, such as credit card information, to protect it from unauthorized access. Hash Functions Definition Hash functions transform input data of arbitrary length into a fixed-size hash value. Properties Deterministic: The same input always produces the same hash. Fast Computation: Hash values are quickly computed. Pre-image Resistance: Difficult to reverse-engineer the original input from the hash. Collision Resistance: Unlikely that two different inputs will produce the same hash. Examples MD5: Produces a 128-bit hash value. Widely used but now considered insecure due to vulnerabilities. o Example: Previously used for hashing passwords and data integrity checks. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 16 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 SHA-1: Produces a 160-bit hash value. More secure than MD5 but still vulnerable to attacks. o Example: Used in digital signatures and certificates. SHA-256: Part of the SHA-2 family, produces a 256-bit hash value. Currently considered secure. o Example: Used in cryptocurrencies like Bitcoin for hashing transactions. Key Pre-distribution Definition Pre-distributing cryptographic keys to entities before communication begins. Purpose Reduces the need for real-time key exchange, enhancing security by ensuring that keys are already in place before communication starts. Example Sensor Networks: Nodes in a sensor network are preloaded with keys to enable secure communication without the need for real-time key exchanges. Blom’s Scheme Description A key pre-distribution scheme ensuring any two nodes can establish a shared key. Mechanism Initialization: A trusted authority generates a secret matrix and distributes secret shares to all nodes. Key Computation: Nodes use their secret shares and public information to compute shared keys. Example Ad-hoc Wireless Networks: In an ad-hoc network, nodes can securely communicate using pre- distributed keys calculated using Blom’s Scheme. Diffie-Hellman Key Pre-distribution Purpose Allows two parties to securely share a secret key over an insecure channel. Mechanism Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 17 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Public Parameters: Agreed-upon prime number ppp and base ggg. Private Keys: Each party generates a private key and corresponding public key. Shared Secret: Both parties compute the shared secret using the other’s public key. Example Alice and Bob: o Alice and Bob agree on p=23p = 23p=23 and g=5g = 5g=5. o Alice chooses a private key a=6a = 6a=6 and computes A=gamod p=56mod 23=8A = g^a \mod p = 5^6 \mod 23 = 8A=gamodp=56mod23=8. o Bob chooses a private key b=15b = 15b=15 and computes B=gbmod p=515mod 23=19B = g^b \mod p = 5^{15} \mod 23 = 19B=gbmodp=515mod23=19. o They exchange AAA and BBB and compute the shared secret: Alice computes s=Bamod p=196mod 23=2s = B^a \mod p = 19^6 \mod 23 = 2s=Bamodp=196mod23=2. Bob computes s=Abmod p=815mod 23=2s = A^b \mod p = 8^{15} \mod 23 = 2s=Abmodp=815mod23=2. Kerberos Definition A network authentication protocol designed for secure client-server interaction. Components KDC (Key Distribution Center): Issues tickets for accessing services. AS (Authentication Server): Authenticates users and issues Ticket Granting Tickets (TGTs). TGS (Ticket Granting Server): Issues service tickets based on TGTs. Process Initial Authentication: User authenticates with AS and receives a TGT. o Example: User logs in with a password, and AS verifies credentials and provides TGT. Service Request: User requests access to a service from TGS using the TGT. o Example: User presents TGT to TGS to access a file server. Service Access: TGS issues a service ticket, allowing access to the requested service. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 18 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 o Example: TGS provides a service ticket, user uses it to access the file server. Multiple Choice Question What component is included in a digital certificate? A) Private Key B) Public Key C) Serial Number D) CRL Which entity issues digital certificates in a PKI system? A) RA B) CA C) KDC D) HSM What does PKCS stand for? A) Public Key Common Standards B) Public Key Cryptography Standards C) Private Key Cryptography Standards D) Public Key Certification System Which PKCS standard is used for RSA Cryptography? A) PKCS#7 B) PKCS#1 C) PKCS#12 D) PKCS#5 Which property of hash functions ensures that the same input always produces the same output? A) Fast Computation B) Deterministic C) Pre-image Resistance D) Collision Resistance What is a primary use of XML Signature? A) Providing integrity and authentication B) Encrypting XML documents Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 19 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 C) Storing private keys D) Distributing public keys What is the main advantage of using Diffie-Hellman Key Exchange? A) Securely sharing a secret key over an insecure channel B) Encrypting large data sets C) Storing keys securely D) Authenticating digital certificates What does the CRL in a PKI system stand for? A) Certificate Registration List B) Certificate Revocation List C) Certificate Renewal List D) Certificate Reassignment List In Kerberos, what is the role of the Ticket Granting Server (TGS)? A) Issuing service tickets based on TGTs B) Authenticating users C) Storing private keys D) Generating public parameters Which of the following is a property of SHA-256? A) 128-bit hash value B) 256-bit hash value C) 160-bit hash value D) 512-bit hash value How does the Registration Authority (RA) function in PKI? A) Authenticates entities requesting certificates B) Issues digital certificates C) Stores private keys D) Generates public parameters Which standard format is used for digital certificates in PKI? A) PKCS#7 B) PKCS#12 C) X.509 D) SHA-256 What is the purpose of key pre-distribution? Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 20 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 A) Increasing encryption speed B) Reducing the need for real-time key exchange C) Enhancing data integrity D) Authenticating users State the importance of private key management. A) Maintains security and integrity of encrypted communication B) Speeds up encryption process C) Reduces the size of encrypted data D) Enhances user authentication Which of the following is a common application of XML Encryption? A) Hashing passwords B) Protecting sensitive parts of XML documents C) Storing digital certificates D) Authenticating users Find the correct description of Blom’s Scheme. A) A key pre-distribution scheme ensuring any two nodes can establish a shared key B) A method for encrypting large data sets C) A protocol for user authentication D) A standard for digital signatures Which process in Kerberos involves the user receiving a Ticket Granting Ticket (TGT)? A) Initial Authentication B) Service Request C) Ticket Validation D) Key Distribution What is the result of a hash function known as? A) Key B) Hash Value C) Signature D) Ciphertext Choose the standard that is commonly used for securing email messages. A) PKCS#7 B) PKCS#1 C) PKCS#12 D) X.509 Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 21 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Give examples of commonly used hash functions. A) RSA, Diffie-Hellman B) MD5, SHA-1, SHA-256 C) AES, DES D) Kerberos, Blom's Scheme Short Type Question: 1.What component is included in a digital certificate? 2.Which entity issues digital certificates in a PKI system? 3.What does PKCS stand for? 4.Which PKCS standard is used for RSA Cryptography? 5.Which property of hash functions ensures that the same input always produces the same output? 6.What is a primary use of XML Signature? 7.What is the main advantage of using Diffie-Hellman Key Exchange? 8.What does CRL stand for in a PKI system? 9.What is the role of the Ticket Granting Server (TGS) in Kerberos? 10.What is the hash value length for SHA-256? 11.How does the Registration Authority (RA) function in PKI? 12.Which standard format is used for digital certificates in PKI? 13.What is the purpose of key pre-distribution? 14.State the importance of private key management. 15.Give a common application of XML Encryption. 16.Describe Blom’s Scheme in brief. 17.In Kerberos, which process involves the user receiving a Ticket Granting Ticket (TGT)? 18.What is the result of a hash function known as? 19.Which PKCS standard is commonly used for securing email messages? Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 22 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 20.Give examples of commonly used hash functions. Long Type Questions: 1.Explain the components of a digital certificate and their significance. 2.Describe the role of a Certificate Authority (CA) in the Public Key Infrastructure (PKI). 3.Discuss the various Public Key Cryptography Standards (PKCS) and their applications. 4.Elaborate on the RSA Cryptography Standard (PKCS#1) and its importance. 5.Describe the key properties of hash functions and their importance in cryptography. 6.Explain how XML Signature is used to provide integrity and authentication in digital communications. 7.Discuss the Diffie-Hellman Key Exchange method and its significance in secure communications. 8.Explain the concept of a Certificate Revocation List (CRL) and its role in PKI. 9.Describe the function and importance of the Ticket Granting Server (TGS) in the Kerberos authentication protocol. 10.Compare and contrast different hash functions, including MD5, SHA-1, and SHA-256. 11.Explain the process and importance of authentication performed by the Registration Authority (RA) in PKI. 12.Discuss the X.509 standard for digital certificates and its applications. 13.Describe the key pre-distribution methods and their benefits in cryptographic systems. 14.Discuss the various methods of private key management and their importance in maintaining security. 15.Explain the role and applications of XML Encryption in securing digital communications. 16.Describe Blom’s Scheme and its application in secure communication systems. 17.Explain the initial authentication process in Kerberos and the importance of the Ticket Granting Ticket (TGT). 18.Discuss the importance of hash functions in cryptography and provide examples of their applications. 19.Explain the use of PKCS#7 in securing email messages and other communications. 20.Compare Blom’s Scheme and Diffie-Hellman Key Pre-distribution in terms of their mechanisms and applications. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 23 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Module III: Network Security, Firewalls and Virtual Private Networks TCP/IP (Transmission Control Protocol/Internet Protocol) Overview: TCP/IP is a set of protocols that allows computers to communicate over a network. It is the foundation of internet communications and consists of multiple layers, each responsible for specific functions. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 24 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Layers of TCP/IP: 1. Application Layer: o This layer contains protocols that enable software applications to communicate with each other. o Examples: HTTP (HyperText Transfer Protocol), FTP (File Transfer Protocol), SMTP (Simple Mail Transfer Protocol), DNS (Domain Name System). 2. Transport Layer: o Responsible for providing end-to-end communication services for applications. o TCP (Transmission Control Protocol): Ensures reliable, ordered, and error-checked delivery of a stream of data between applications. o UDP (User Datagram Protocol): Offers a connectionless service that minimizes latency but does not guarantee delivery or order. 3. Internet Layer: o Handles the addressing, packaging, and routing of data packets. o IP (Internet Protocol): Routes packets of data from source to destination using IP addresses. o ICMP (Internet Control Message Protocol): Used for diagnostic and error-reporting purposes. o ARP (Address Resolution Protocol): Resolves IP addresses to MAC (Media Access Control) addresses. 4. Network Interface Layer: o Deals with the physical transmission of data over network media. o Includes protocols that operate at the link level, such as Ethernet. Functions of TCP/IP: Data Encapsulation: Wrapping data with protocol information at each layer. Packet Routing: Determining the best path for data to travel from source to destination. Error Detection and Correction: Ensuring data integrity through checksums and acknowledgments. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 25 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Flow Control: Managing the rate of data transmission to prevent congestion. Firewalls Overview: A firewall is a network security device or software that monitors and controls incoming and outgoing network traffic based on predetermined security rules. It acts as a barrier between a trusted internal network and untrusted external networks. Types of Firewalls: 1. Packet-Filtering Firewalls: o Examine packets and filter them based on source and destination IP addresses, ports, and protocols. o Operate at the Network Layer (Layer 3). 2. Stateful Inspection Firewalls: o Monitor the state of active connections and make decisions based on the state and context of the traffic. o Operate at the Transport Layer (Layer 4). 3. Proxy Firewalls: o Act as intermediaries between users and the services they access. o Inspect and filter traffic at the application layer (Layer 7). 4. Next-Generation Firewalls (NGFW): o Include advanced features like deep packet inspection, intrusion prevention, and application awareness. Functions of Firewalls: Access Control: Blocking unauthorized access while permitting legitimate communication. Data Protection: Preventing data exfiltration and ensuring confidentiality. Threat Mitigation: Blocking malicious traffic and protecting against cyber-attacks. Logging and Monitoring: Recording and analyzing network traffic for security events. IP Security (IPsec) Overview: IPsec is a suite of protocols that provide security for IP communications by authenticating and encrypting each IP packet in a communication session. Components of IPsec: Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 26 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 1. Authentication Header (AH): o Provides connectionless integrity, data origin authentication, and protection against replay attacks. 2. Encapsulating Security Payload (ESP): o Provides confidentiality, data integrity, and authentication by encrypting the payload of IP packets. Modes of IPsec: 1. Transport Mode: o Encrypts only the payload of the IP packet, leaving the header intact. o Used for end-to-end communication between two hosts. 2. Tunnel Mode: o Encrypts the entire IP packet, including the header, creating a new IP packet with a new header. o Used for network-to-network or host-to-network communications. Functions of IPsec: Data Confidentiality: Encrypts data to protect it from unauthorized access. Data Integrity: Ensures that data has not been altered during transmission. Authentication: Verifies the identity of the communicating parties. Replay Protection: Prevents replay attacks by using sequence numbers and time stamps. Virtual Private Networks (VPN) Overview: A VPN extends a private network across a public network, such as the internet, enabling users to send and receive data as if their computing devices were directly connected to the private network. Types of VPNs: 1. Remote Access VPN: o Allows individual users to connect to a private network remotely using VPN client software. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 27 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 o Typically used by remote workers to access company resources securely. 2. Site-to-Site VPN: o Connects entire networks to each other over the internet. o Typically used to connect branch offices to a central office network. VPN Protocols: 1. PPTP (Point-to-Point Tunneling Protocol): o One of the oldest VPN protocols, now considered less secure. o Easy to set up and use. 2. L2TP (Layer 2 Tunneling Protocol): o Often used with IPsec for enhanced security. o Provides encryption, integrity, and authentication. 3. IPsec: o Provides robust security features and is widely used for VPNs. o Ensures data confidentiality, integrity, and authentication. 4. SSL/TLS: o Used in SSL VPNs to provide secure access to web applications. o Operates at the transport layer, offering flexibility and strong security. Functions of VPNs: Data Encryption: Ensures that data transmitted over the public network is secure. Data Integrity: Ensures that data is not altered during transmission. Authentication: Verifies the identity of users and devices. Anonymity: Hides users' IP addresses, providing privacy. Intrusion Overview: Intrusion refers to unauthorized access or breaches into a network, system, or data, potentially compromising confidentiality, integrity, and availability. Types of Intrusions: 1. Network Intrusion: Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 28 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 o Unauthorized activities targeting network resources. o Examples: Port scanning, Denial of Service (DoS) attacks, man-in-the-middle attacks. 2. Host Intrusion: o Unauthorized access to individual hosts or devices. o Examples: Exploitation of software vulnerabilities, password cracking. Intrusion Detection Systems (IDS) and Intrusion Prevention Systems (IPS): 1. IDS (Intrusion Detection System): o Monitors network or system activities for malicious actions or policy violations. o Types: Network-based IDS (NIDS) and Host-based IDS (HIDS). o Alerts administrators of suspicious activity. 2. IPS (Intrusion Prevention System): o Monitors network traffic for suspicious activity and takes preventive action. o Blocks threats in real-time. o Often integrated with firewalls. Functions of IDS/IPS: Detection: Identifying unauthorized access or malicious activities. Prevention: Blocking or mitigating threats before they cause harm. Logging: Recording events for analysis and investigation. Alerting: Notifying administrators of potential security incidents. Internet Security Protocols: Basic Concepts Overview: Internet security protocols are designed to protect data transmitted over the internet by providing various levels of security, including confidentiality, integrity, authentication, and non- repudiation. Key Concepts: 1. Confidentiality: Ensuring that data is accessible only to authorized parties. 2. Integrity: Ensuring that data is not altered during transmission. 3. Authentication: Verifying the identity of the communicating parties. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 29 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 4. Non-repudiation: Ensuring that a party cannot deny the authenticity of their communication. Secure Socket Layer (SSL) Overview: SSL is a standard security protocol used to establish encrypted links between a web server and a browser, ensuring that all data transmitted remains private and integral. Key Features of SSL: 1. Encryption: o Uses public key encryption to secure data during transmission. o Prevents unauthorized access to sensitive information. 2. Authentication: o Digital certificates are used to authenticate the identity of the parties involved. o Ensures that users are communicating with legitimate servers. 3. Data Integrity: o Ensures that data is not altered during transmission. o Uses checksums and hashing algorithms. Transport Layer Security (TLS) Overview: TLS is an updated, more secure version of SSL. It provides similar functionality but with improved security features. Key Improvements Over SSL: 1. Stronger Encryption Algorithms: o Uses more secure encryption methods, reducing the risk of decryption by unauthorized parties. 2. Enhanced Key Exchange: o Implements more secure mechanisms for exchanging cryptographic keys. o Supports forward secrecy, ensuring that session keys cannot be compromised even if long-term keys are. 3. Better Authentication: o Uses improved methods for authenticating communicating parties. o Supports a wider range of digital certificates and authentication protocols. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 30 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Email Security: Pretty Good Privacy (PGP) Overview: PGP is an encryption program that provides cryptographic privacy and authentication for email and other data communications. Key Features of PGP: 1. Confidentiality: o Uses public key encryption to ensure that only the intended recipient can read the email. o Encrypts the content of the emails to protect against eavesdropping. 2. Authentication: o Digital signatures verify the identity of the sender. o Ensures that the email has not been tampered with. 3. Integrity: o Uses cryptographic hashes to ensure that the content of the email has not been altered during transmission. o Provides a checksum to verify the integrity of the message. Components of PGP: 1. Public Key: o Used to encrypt the email. o Shared with others to enable them to send encrypted messages to the key owner. 2. Private Key: o Used to decrypt the email. o Kept secret by the key owner to ensure that only they can read the encrypted messages. 3. Digital Signature: o Verifies the authenticity and integrity of the message. o Ensures that the email has not been tampered with and is indeed from the claimed sender. Tables Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 31 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Table 1: Comparison of Firewall Types Firewall Type Description Layer Operated Examines packets based on IP addresses, ports, and Network Layer Packet-Filtering Firewall protocols (Layer 3) Stateful Inspection Transport Layer Monitors the state of active connections Firewall (Layer 4) Application Layer Proxy Firewall Acts as intermediaries between users and services (Layer 7) Next-Generation Firewall Includes deep packet inspection, intrusion Multiple Layers (NGFW) prevention, application awareness Table 2: VPN Protocols and Their Features VPN Security Features Common Uses Protocol PPTP Basic encryption, easy to set up Remote access for individual users Strong encryption, data integrity, Enhanced security for remote access and site-to- L2TP/IPsec authentication site connections Robust encryption, data integrity, IPsec Widely used for secure network communications authentication Secure web access, flexible and SSL/TLS Secure access to web applications strong security Multiple Choice Question What does TCP in TCP/IP stand for? A) Transmission Control Protocol B) Transfer Communication Protocol C) Transport Control Protocol D) Transfer Control Protocol Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 32 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Which layer of the TCP/IP model is responsible for routing packets? A) Application Layer B) Transport Layer C) Internet Layer D) Network Interface Layer What type of firewall inspects packets and blocks them based on source and destination addresses? A) Proxy Firewall B) Packet-Filtering Firewall C) Stateful Inspection Firewall D) Next-Generation Firewall Which IPsec component provides data integrity and authentication without encryption? A) Authentication Header (AH) B) Encapsulating Security Payload (ESP) C) Transport Layer Security (TLS) D) Secure Socket Layer (SSL) In VPNs, what does IPsec primarily provide? A) Only encryption B) Confidentiality, integrity, and authentication C) Only authentication D) Only integrity What is a primary function of an Intrusion Detection System (IDS)? A) Preventing intrusions B) Monitoring and alerting on suspicious activities C) Encrypting network traffic D) Managing network bandwidth Which protocol is considered the more secure successor to SSL? A) TLS (Transport Layer Security) B) IPsec C) PPTP (Point-to-Point Tunneling Protocol) D) L2TP (Layer 2 Tunneling Protocol) What does PGP use to ensure the confidentiality of email communication? A) Hashing Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 33 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 B) Public Key Encryption C) Symmetric Key Encryption D) Digital Signatures Which type of firewall can understand and filter traffic based on applications? A) Packet-Filtering Firewall B) Next-Generation Firewall (NGFW) C) Stateful Inspection Firewall D) Proxy Firewall In IPsec, what does Tunnel Mode encrypt? A) Only the payload B) The IP header C) The entire IP packet D) Only the source address Which VPN protocol is known for being one of the oldest and less secure? A) IPsec B) PPTP (Point-to-Point Tunneling Protocol) C) SSL/TLS D) L2TP (Layer 2 Tunneling Protocol) What function does the Transport Layer perform in the TCP/IP model? A) Routing packets B) End-to-end communication services C) Data encryption D) Physical transmission of data What does the Network Interface Layer in TCP/IP handle? A) Address resolution B) Physical transmission of data C) Packet routing D) Data encryption Which component of IPsec provides confidentiality by encrypting data? A) Authentication Header (AH) B) Encapsulating Security Payload (ESP) C) Transport Layer Security (TLS) D) Secure Socket Layer (SSL) Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 34 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 What is the primary purpose of a firewall? A) Encrypting data B) Controlling network traffic based on security rules C) Analyzing network performance D) Providing VPN access Which protocol provides secure web communication by using public key encryption? A) FTP B) SMTP C) HTTPS (HyperText Transfer Protocol Secure) D) DNS What is the main advantage of stateful inspection firewalls over packet-filtering firewalls? A) Faster performance B) Context-aware decision making C) Simpler configuration D) Greater application support In a VPN, what does the L2TP protocol often pair with for enhanced security? A) PPTP B) IPsec C) SSL/TLS D) HTTP Which of the following is NOT a function of the Internet Layer in TCP/IP? A) Addressing B) Data encapsulation C) Packet routing D) Error detection How does an IDS differ from an IPS? A) IDS monitors and alerts, IPS prevents intrusions B) IDS prevents intrusions, IPS monitors and alerts C) IDS encrypts data, IPS decrypts data D) IDS operates at the application layer, IPS at the network layer Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 35 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Short Type Question: 1.What component is included in a digital certificate? 2.Which entity issues digital certificates in a PKI system? 3.What does PKCS stand for? 4.Which PKCS standard is used for RSA Cryptography? 5.Which property of hash functions ensures that the same input always produces the same output? 6.What is a primary use of XML Signature? 7.What is the main advantage of using Diffie-Hellman Key Exchange? 8.What does CRL stand for in a PKI system? 9.What is the role of the Ticket Granting Server (TGS) in Kerberos? 10.What is the hash value length for SHA-256? 11.How does the Registration Authority (RA) function in PKI? 12.Which standard format is used for digital certificates in PKI? 13.What is the purpose of key pre-distribution? 14.State the importance of private key management. 15.Give a common application of XML Encryption. 16.Describe Blom’s Scheme in brief. 17.In Kerberos, which process involves the user receiving a Ticket Granting Ticket (TGT)? 18.What is the result of a hash function known as? 19.Which PKCS standard is commonly used for securing email messages? 20.Give examples of commonly used hash functions. 21.What is TCP/IP? 22.Name the four layers of the TCP/IP model. 23.What does the Application Layer in TCP/IP do? 24.Explain the main function of the Transport Layer in TCP/IP. 25.What is the role of the Internet Layer in TCP/IP? Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 36 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 26.Describe the function of a firewall. 27.What are Packet-Filtering Firewalls? 28.Define IPsec and its main purpose. 29.What is a VPN and its primary function? 30.What is the main difference between Remote Access VPN and Site-to-Site VPN? 31.What does an IDS do? 32.What is the purpose of SSL? 33.How does TLS improve upon SSL? 34.What are the main components of PGP? 35.What does the Authentication Header (AH) in IPsec provide? 36.What is the role of the Encapsulating Security Payload (ESP) in IPsec? 37.Explain the difference between Transport Mode and Tunnel Mode in IPsec. 38.What is the function of ARP in the Internet Layer? 39.Describe the main function of stateful inspection firewalls. 40.What does flow control in TCP/IP ensure? Long Type Questions: 1.Describe the structure and purpose of the TCP/IP model. 2.Explain the roles and functions of the different types of firewalls. 3.Discuss the key components and functions of IPsec. 4.What are Virtual Private Networks (VPNs) and how do they enhance security? 5.Differentiate between Network Intrusion and Host Intrusion, and describe the roles of IDS and IPS. 6.What are the differences between SSL and TLS, and how do they secure data transmission? 7.Describe the importance and components of Pretty Good Privacy (PGP) in email security. 8.Explain the function of the Internet Layer in the TCP/IP model and its key protocols. 9.What are the functions of Data Encapsulation and Packet Routing in TCP/IP? 10.How do firewalls contribute to network security and what are their main functions? Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 37 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 11.Describe the difference between Stateful Inspection Firewalls and Proxy Firewalls. 12.What are the key features and improvements of Transport Layer Security (TLS) over Secure Socket Layer (SSL)? 13.Explain the roles of Authentication Header (AH) and Encapsulating Security Payload (ESP) in IPsec. 14.How does a Virtual Private Network (VPN) ensure secure remote access? 15.Discuss the importance of Intrusion Detection Systems (IDS) and Intrusion Prevention Systems (IPS) in network security. 16.Describe the concept of data confidentiality, integrity, and authentication in internet security protocols. 17.What are the main functions of Secure Socket Layer (SSL) in protecting internet communications? 18.Explain the role of cryptographic hashes and digital signatures in Pretty Good Privacy (PGP). 19.What is the significance of Address Resolution Protocol (ARP) in the Internet Layer of TCP/IP? 20.How do firewalls enhance threat mitigation and data protection in network security? Module IV: User Authentication and Kerberos Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 38 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Authentication Basics Authentication is the process of verifying the identity of a user, device, or entity in a computer system, ensuring that they are who they claim to be. This is a critical aspect of security, as it prevents unauthorized access and ensures that only legitimate users can interact with the system. Components of Authentication: 1. Credential Submission: Users provide credentials such as passwords, tokens, or biometric data. 2. Credential Verification: The system checks the submitted credentials against stored data. 3. Access Grant: If the credentials match, access is granted; otherwise, it is denied. Types of Authentication: 1. Something You Know: Passwords or PINs. 2. Something You Have: Tokens or smart cards. 3. Something You Are: Biometrics like fingerprints or facial recognition. Passwords Passwords are the most common form of authentication, relying on a secret string of characters known only to the user and the system. Characteristics: Complexity: Strong passwords are long and include a mix of letters, numbers, and symbols. Storage: Passwords should be stored using hashing algorithms to prevent plain-text storage. Change Policy: Regular changes are recommended to mitigate the risk of compromised passwords. Best Practices: Use a combination of upper and lower case letters, numbers, and special characters. Avoid using common words or easily guessable information. Enable multi-factor authentication (MFA) where possible. Authentication Tokens Authentication tokens are physical or digital objects that users possess to prove their identity. Types: 1. Hardware Tokens: Physical devices like smart cards or USB keys. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 39 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 2. Software Tokens: Digital tokens generated by applications, often time-based (e.g., Google Authenticator). Benefits: Enhanced security over passwords alone. Tokens are difficult to duplicate or forge. Usage: Often used in conjunction with passwords (two-factor authentication). Can be integrated with various systems and applications for secure access. Certificate-Based Authentication Certificate-based authentication uses digital certificates issued by a trusted Certificate Authority (CA) to verify the identity of users, devices, or entities. Process: 1. Certificate Issuance: A CA issues a digital certificate to the user or device. 2. Certificate Presentation: The user presents the certificate to the system for authentication. 3. Certificate Verification: The system verifies the certificate's validity and the CA's signature. Benefits: Strong security through encryption and digital signatures. Reduces the risk of phishing and man-in-the-middle attacks. Use Cases: Secure web communications (HTTPS). Network access control (VPNs, Wi-Fi networks). Biometric Authentication Biometric authentication uses unique biological characteristics to verify identity. Types: 1. Fingerprint Recognition: Scans and matches fingerprints. 2. Facial Recognition: Analyzes facial features. 3. Iris/Retina Scanning: Examines patterns in the eye. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 40 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 4. Voice Recognition: Identifies users based on voice patterns. Benefits: High security as biometrics are difficult to replicate. Convenient and user-friendly. Considerations: Privacy concerns with biometric data storage. Accuracy can be affected by physical changes or conditions. Kerberos Kerberos is a network authentication protocol designed to provide strong authentication for client-server applications. Key Features: Uses secret-key cryptography and a trusted third party. Prevents eavesdropping and replay attacks. Components: 1. Client: The user or device requesting access. 2. Server: The resource or service the client wants to access. 3. Key Distribution Center (KDC): The trusted third party that issues tickets. Authentication Process: 1. Initial Authentication: The client requests an authentication ticket from the KDC. 2. Ticket Granting: The KDC issues a Ticket Granting Ticket (TGT). 3. Service Access: The client uses the TGT to request access to specific services. Key Distribution Center (KDC) The KDC is a crucial component of the Kerberos protocol, responsible for managing keys and issuing tickets. Functions: 1. Authentication Service (AS): Verifies user credentials and issues TGTs. 2. Ticket Granting Service (TGS): Issues service tickets based on the TGT. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 41 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Security: The KDC must be highly secure, as it is a single point of trust. Compromise of the KDC can lead to a compromise of the entire authentication system. Security Handshake Pitfalls Security handshakes are protocols used to establish secure communications. Common pitfalls include: 1. Man-in-the-Middle Attacks: Interception and manipulation of the handshake process. 2. Replay Attacks: Reusing intercepted credentials or messages to gain unauthorized access. 3. Weak Encryption: Using outdated or easily breakable encryption algorithms. 4. Improper Implementation: Flaws in the protocol implementation can lead to vulnerabilities. Single Sign-On (SSO) Approaches SSO allows users to authenticate once and gain access to multiple systems or applications without re- authenticating. Benefits: Improved user experience with fewer login prompts. Centralized authentication management. Approaches: 1. Kerberos-Based SSO: Uses the Kerberos protocol for authentication across multiple services. 2. Token-Based SSO: Uses tokens like OAuth or SAML to grant access to multiple systems. 3. Federated SSO: Allows authentication across different domains or organizations using a trusted third party. Security Considerations: Ensure strong security measures for the central authentication system. Regularly update and patch SSO software to prevent vulnerabilitie Multiple Choice Question What is authentication primarily concerned with in a computer system? A) Data encryption Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 42 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 B) Verifying identity C) Preventing malware D) Managing network traffic Which type of authentication uses something you know? A) Token B) Biometric C) Password D) Certificate What is a characteristic of strong passwords? A) Single-factor B) Includes letters, numbers, symbols C) Plain-text storage D) Publicly shared Which authentication method involves physical or digital objects? A) Tokens B) Biometrics C) Passwords D) Certificates What is the main benefit of using two-factor authentication (2FA)? A) Convenience B) Single point of failure C) Enhanced security D) Reduced complexity How does certificate-based authentication verify identity? A) Using digital certificates B) Biometric data C) Hashing algorithms D) Token generation What biometric characteristic is commonly used for authentication? A) DNA B) Fingerprint C) Social security number D) Postal address Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 43 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Which protocol is designed to provide strong authentication for client-server applications? A) HTTP B) SSL C) IPsec D) Kerberos What is a function of the Key Distribution Center (KDC) in Kerberos? A) Issuing tickets B) Managing web traffic C) DNS resolution D) Encrypting emails What is a potential pitfall of security handshakes? A) Man-in-the-Middle Attacks B) Single sign-on benefits C) Biometric authentication D) Two-factor authentication What does SSO (Single Sign-On) aim to reduce for users? A) Authentication methods B) Login prompts C) System performance D) Network congestion Which SSO approach uses OAuth or SAML tokens? A) Token-Based SSO B) Federated SSO C) Kerberos-Based SSO D) Biometric SSO What does the authentication service (AS) in Kerberos verify? A) User credentials B) Issues Ticket Granting Tickets (TGTs) C) System availability D) Data integrity What is a crucial consideration for implementing biometric authentication? A) Hardware cost B) Privacy concerns Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 44 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 C) Physical changes affect accuracy D) Static nature of data What makes certificate-based authentication more secure? A) Single-factor B) Encryption and digital signatures C) Username and password D) Social engineering attacks Which authentication factor is often combined with biometric authentication? A) Password B) Something you are C) Token D) Certificate What type of authentication is PGP primarily associated with? A) Token B) Biometric C) Certificate-Based D) Password How does SSL/TLS contribute to authentication on the web? A) Authentication protocols B) Secure web communications C) Token management D) Network routing Which authentication component checks submitted credentials against stored data? A) Ticket Granting Service (TGS) B) Credential Verification C) Service Access D) Key Distribution Center (KDC) In what way does multi-factor authentication (MFA) enhance security? A) Requires multiple forms of verification B) Single authentication step C) Limited access control D) User anonymity Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 45 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Short Type Questions 1. What is authentication? 2. What are the main components of authentication? 3. Name three types of authentication factors. 4. What is a characteristic of strong passwords? 5. Why should passwords be stored using hashing algorithms? 6. What is the purpose of multi-factor authentication (MFA)? 7. What is an authentication token? 8. Give an example of a hardware authentication token. 9. What is certificate-based authentication? 10. What does biometric authentication use to verify identity? 11. What is the role of the Key Distribution Center (KDC) in Kerberos? 12. What does a Ticket Granting Ticket (TGT) do in Kerberos? 13. What is a common pitfall of security handshakes? 14. What is Single Sign-On (SSO)? 15. How does Kerberos-Based SSO work? 16. What is the main benefit of SSO? 17. Name two types of software tokens. 18. What is the primary function of the Authentication Service (AS) in Kerberos? 19. What are digital certificates used for in secure web communications? 20. What is a man-in-the-middle attack? Long Type Questions 1. Explain the process and benefits of multi-factor authentication (MFA). 2. Describe the components and functions of a Key Distribution Center (KDC) in the Kerberos protocol. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 46 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 3. Discuss the importance and implementation of certificate-based authentication. 4. Explain how biometric authentication works and its advantages and considerations. 5. Outline the process and security benefits of using SSL/TLS for web communications. 6. Describe the authentication process in the Kerberos protocol and its key features. 7. Discuss the benefits and challenges of Single Sign-On (SSO) approaches. 8. Explain the concept of authentication tokens and their types and benefits. 9. Discuss the role of hashing algorithms in password storage and their importance. 10. Describe the process and security benefits of using digital certificates in HTTPS. 11. What are the considerations for implementing biometric authentication in a system? 12. Explain the potential pitfalls of security handshakes and how they can be mitigated. 13. Describe how Single Sign-On (SSO) improves user experience and security. 14. Explain the process of certificate issuance and verification in certificate-based authentication. 15. Discuss the advantages and challenges of using hardware tokens for authentication. 16. Explain how Kerberos prevents eavesdropping and replay attacks. 17. Describe the role and security measures of the Authentication Service (AS) in Kerberos. 18. Discuss the security and convenience benefits of using biometric authentication. 19. Explain the importance of regular password changes and the best practices for creating strong passwords. 20. Describe the process and advantages of using software tokens for authentication. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 47 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Module V: IP Security Introduction In this course, we will explore the foundational concepts and practical implementation of a Peer-to-Peer (P2P) server, creating a WebSocket server, connecting to blockchain peers, handling messages from peers, and synchronizing the blockchain across peers. This study material is designed for graduate-level students and is structured into several comprehensive sections. Table of Contents 1. Introduction to P2P Networks o Definition and Characteristics o Advantages and Disadvantages 2. WebSocket Basics o Introduction to WebSockets o WebSocket Protocol o WebSocket Libraries 3. Setting Up a WebSocket Server o Environment Setup o Creating a Simple WebSocket Server o Handling Messages 4. Blockchain Basics o Introduction to Blockchain o Structure of a Blockchain 5. Connecting to Blockchain Peers o P2P Communication o Implementing P2P Connections 6. Handling Messages from Peers o Message Types o Message Handling Logic 7. Synchronizing the Blockchain o Consensus Algorithms o Blockchain Synchronization 1. Introduction to P2P Networks Definition and Characteristics Peer-to-Peer (P2P) Network: A decentralized network where each node (peer) has equal authority and can initiate or complete transactions. Characteristics: o Decentralization: No central authority. o Scalability: Can handle a large number of nodes. o Resilience: Robust against node failures. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 48 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Advantages and Disadvantages Advantages: o Improved resource utilization. o Enhanced fault tolerance. o Better scalability. Disadvantages: o Security risks. o Data consistency challenges. o Complex management. 2. WebSocket Basics Introduction to WebSockets WebSocket: A protocol providing full-duplex communication channels over a single TCP connection. Difference from HTTP: o Persistent connection. o Low latency communication. WebSocket Protocol How it works: o Client initiates a handshake. o Server responds to the handshake. o Full-duplex connection established. Handshake Process: o Client sends an HTTP request with an Upgrade header. o Server responds with an HTTP 101 status code, switching protocols. WebSocket Libraries Popular Libraries: o Node.js: ws library. o Python: websockets library. o Java: Java-WebSocket library. 3. Setting Up a WebSocket Server Environment Setup Node.js: o Install Node.js from nodejs.org. o Install ws library: npm install ws. Creating a Simple WebSocket Server Basic Server Setup: Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 49 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 javascript Copy code const WebSocket = require('ws'); const wss = new WebSocket.Server({ port: 8080 }); wss.on('connection', ws => { ws.on('message', message => { console.log(`Received message => ${message}`); }); ws.send('Hello! Message From Server!!'); }); Handling Connections: o Establish connection using ws.on('connection', callback). Handling Messages Sending and Receiving Messages: o ws.on('message', callback) for receiving. o ws.send(message) for sending. Broadcasting Messages: javascript Copy code wss.clients.forEach(client => { if (client.readyState === WebSocket.OPEN) { client.send(data); } }); 4. Blockchain Basics Introduction to Blockchain Blockchain: A decentralized ledger of all transactions across a network. Key Concepts: o Immutable records. o Distributed ledger. o Cryptographic security. Structure of a Blockchain Blocks: o Contains a list of transactions. o Header includes metadata (e.g., previous block hash). Transactions: o The data recorded in the blockchain. Chains: o Blocks linked together by cryptographic hashes. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 50 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 5. Connecting to Blockchain Peers P2P Communication Connecting to Multiple Peers: o Use WebSockets to establish connections. o Maintain a list of connected peers. Maintaining Peer Lists: o Store information about peers (e.g., IP address, port). o Update the list as peers connect/disconnect. Implementing P2P Connections Establishing Connections: o Initiate connections using WebSockets. o Handle new connections in the WebSocket server. Handling Disconnections: o Detect disconnections. o Remove peers from the list. 6. Handling Messages from Peers Message Types Block Messages: o Contain new blocks to be added to the blockchain. Transaction Messages: o Contain new transactions to be recorded. Peer Messages: o Contain information about new peers. Message Handling Logic Validating Messages: o Check message format and content. o Ensure the integrity of data. Processing Messages: o Add valid blocks to the blockchain. o Record valid transactions. Error Handling and Security: o Handle malformed or invalid messages. o Implement security measures to prevent attacks. 7. Synchronizing the Blockchain Consensus Algorithms Proof of Work (PoW): o Nodes solve computational puzzles to validate transactions. Proof of Stake (PoS): Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 51 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 o Nodes validate transactions based on their stake in the network. Blockchain Synchronization Strategies: o Periodic updates. o Event-driven updates. Handling Forks and Conflicts: o Use consensus algorithms to resolve forks. o Ensure all peers agree on the blockchain state. Practical Implementation Step-by-Step Implementation 1. Setup WebSocket Server: o Follow the setup instructions from Section 3. 2. Implement Blockchain Basics: o Create block and transaction structures. 3. P2P Connection: o Establish connections to multiple peers. 4. Message Handling: o Implement logic to handle different message types. 5. Blockchain Synchronization: o Implement a consensus algorithm. o Ensure the blockchain is synchronized across all peers. Case Studies and Real-World Examples Bitcoin: o Uses PoW for consensus. o Decentralized P2P network. Ethereum: o Uses PoW (transitioning to PoS). o Smart contracts and decentralized applications (dApps).. 1. Introduction to P2P Networks Definition and Characteristics Peer-to-Peer (P2P) Network: A distributed network architecture where each node (peer) has equal responsibilities and capabilities, sharing resources directly without relying on a central server. Characteristics: o Decentralization: Eliminates the need for a central authority, making the network more resilient and scalable. o Resource Sharing: Peers share resources such as bandwidth, storage, and processing power. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 52 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 o Self-Organization: Nodes join and leave the network dynamically, contributing to its robustness. Advantages and Disadvantages Advantages: o Scalability: Can handle a large number of nodes efficiently. o Fault Tolerance: Network can continue to function even if some nodes fail. o Cost Efficiency: Reduces infrastructure costs by leveraging the resources of individual nodes. Disadvantages: o Security Risks: Higher vulnerability to attacks due to decentralized control. o Data Consistency: Maintaining consistent data across all nodes can be challenging. o Management Complexity: Coordinating and managing decentralized nodes is complex. 2. WebSocket Basics Introduction to WebSockets WebSocket: A communication protocol providing full-duplex communication channels over a single TCP connection, enabling real-time data exchange between client and server. Difference from HTTP: o Persistent Connection: Unlike HTTP, WebSocket keeps the connection open, reducing overhead for continuous data exchange. o Low Latency: Enables faster data transmission with minimal delay. WebSocket Protocol How it works: o Handshake: Client sends an HTTP request with an Upgrade header to switch protocols to WebSocket. o Connection Establishment: Server responds with an HTTP 101 status code, establishing a WebSocket connection. Handshake Process: o Client Request: Includes Upgrade: websocket and Connection: Upgrade headers. Server Response: Confirms the protocol upgrade and maintains the WebSocket Libraries Popular Libraries: o Node.js: ws library. o Python: websockets library. o Java: Java-WebSocket library. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 53 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 3. Setting Up a WebSocket Server Environment Setup Node.js: o Download and install Node.js from nodejs.org. o Install the ws library using npm: npm install ws. Basic Server Setup const WebSocket = require('ws'); const wss = new WebSocket.Server({ port: 8080 }); wss.on('connection', ws => { ws.on('message', message => { console.log(`Received message => ${message}`); }); ws.send('Hello! Message From Server!!'); }); Handling Connections: o Use ws.on('connection', callback) to manage new connections. Handling Messages Sending and Receiving Messages: o Use ws.on('message', callback) to receive messages from clients. o Use ws.send(message) to send messages to clients. Broadcasting Messages: wss.clients.forEach(client => { if (client.readyState === WebSocket.OPEN) { client.send(data); } }); Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 54 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 4. Blockchain Basics Introduction to Blockchain Blockchain: A decentralized ledger that records transactions in a secure, transparent, and immutable manner. Key Concepts: o Immutable Records: Once data is recorded, it cannot be altered. o Distributed Ledger: All nodes in the network maintain a copy of the ledger. o Cryptographic Security: Ensures data integrity and authenticity. Structure of a Blockchain Blocks: o Content: Contains a list of transactions. o Header: Includes metadata such as the previous block's hash, timestamp, and a unique nonce. Transactions: o Represent the data entries recorded in the blockchain. Chains: o Blocks are linked together through cryptographic hashes, forming a continuous chain. 5. Connecting to Blockchain Peers P2P Communication Connecting to Multiple Peers: o Establish connections using WebSockets. o Maintain a list of active peers for communication. Maintaining Peer Lists: o Store peer information (e.g., IP addresses, ports). o Update the list dynamically as peers join or leave the network. Debdutta Mandal Assistant Professor, Dept. of Cyber Science & Technology Brainware University, Kolkata P a g e | 55 Bachelor of Science (Honours) in Advanced Networking and Cyber Security – 2022 & Semester- V Cryptography & Network Security & BNCSD502C Section- A, Section- B, Section-C Academic Session – 2024-25 Implementing P2P Connections Establishing Connections: o Initiate WebSocket connections to other peers. o Accept incoming connections in the WebSocket server. Handling Disconnections: o Detect when peers disconnect. o Remove disconnected peers from the list to maintain an updated peer network. 6. Handling Messages from Peers Message Types Block Messages: o Contain information about new blocks to be added to the blockchain. Transaction Messages: o Contain details of new transactions to be recorded. Peer Messages: o Share information about new peers joining the network. Message Handling Logic Validating Messages: o Check the format and content of incoming messages. o Ensure the integrity and authenticity of the data. Processing Messages: o Add valid blocks to the blockchain. o Record valid transactions in the ledger. Error Handling and Security: o Manage malformed or invalid messages. o Implement security measures to prevent attacks (e.g., DDoS, Sybil attacks). 7. Synchronizing the Blockchai