You are on page 1of 34

18CSE435J - Advanced Cryptography

Practical Record

Submitted by

AMAR MEHTA
NILESH GARG(RA2011050010027)
(RA2011050010035)

B.Tech. – Computer Science and Engineering


with specialization in
Blockchain Technology

DEPARTMENT OF DATA SCIENCE AND BUSINESS SYSTEMS


SCHOOL OF COMPUTING
FACULTY OF ENGINEERING AND TECHNOLOGY
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
NOVEMBER 2023
SRM Institute of Science and Technology
Kattankulathur - 603203

BONAFIDE CERTIFICATE

Certified that this is the bonafide record of the work done in the 18CSE435J -
Advanced Cryptography Laboratory during the seventh semester in the
academic year 2023 - 2024.

NILESH
Name: Amar mehta GARG
RA2011050010035
Register Number:RA2011050010027
Year / Semester / Section: IV / VII / U2
Program: Blockchain Technology

Faculty-in-charge Head of the Department

Submitted to the practical examination held on

Examiner 1 Examiner 2
List of Exercises
Sl. Page
No.
Ex. No. Date Title No.
Remarks

Implementation of Substitution Cipher


1 Ex. 1
(Caesar’s cipher & ROT-13)

Implementation of Substitution Cipher


2 Ex. 2 (Poly-alphabetic substitution cipher /
The Vigenere cipher)

Implementation of Transposition Cipher


3 Ex. 3
Techniques

4 Ex. 4 Implementation of DES Algorithm

5 Ex. 5 Implementation of Blowfish Algorithm

6 Ex. 6 Implementation of Rijndael Algorithm

Implementation of Diffie-Hellman
7 Ex. 7
Algorithm

8 Ex. 8 Implementation of RSA Algorithms

Implementation of Digital Signature


9 Ex. 9
Standards

Setup a Honeypot and Honeypot on


10 Ex. 10
Network
18CSE435J - Advanced Cryptography

Name of the student SIDDHARTH


NILESH DUTTA
GARG
Register number of the student RA2011050010035
RA2011050010041 Section U2

Exercise No. 1 Implementation of Substitution Cipher


Date of Exercise 09.08.2023 (a. Caesar’s cipher & b. ROT-13)

Aim:

To implement substitution cipher using python,

a) Caesar’s Cipher
b) ROT-13

Algorithm / Procedure:

● Begin a function named encrypt_text that takes two parameters: plaintext (the text to be
encrypted) and n (the shift value).
● Initialize two empty strings, ans and ans1, to store the encrypted text.
● For each character ch in the plaintext:
a. If ch is a space, append a space character to both ans and ans1.
b. If ch is an uppercase letter:
- Append a character to ans obtained by shifting ch cyclically by n positions within uppercase
letters.
- Append a character to ans1 obtained by shifting ch cyclically by ROT13 positions within
uppercase letters.
c. If ch is a lowercase letter:
- Append a character to ans obtained by shifting ch cyclically by n positions within lowercase
letters.
- Append a character to ans1 obtained by shifting ch cyclically by ROT13 positions within
lowercase letters.

● Return the ans string as the encrypted text.

● Set the plaintext variable to "HELLO EVERYONE".

● Set the n variable to 3.

● Set the ROT13 variable to 13.

● Print "Plain Text is: " followed by the value of plaintext.

● Print "Shift pattern is: " followed by the value of n.

● Print "Cipher Text is(Caesar Cipher): '' followed by the result of calling encrypt_text with
plaintext and n as arguments.
● Print "Cipher Text is(ROT-13): " followed by the result of calling encrypt_text with plaintext
and ROT13 as arguments.

Program / Code:
def encrypt_text(plaintext,n):

ans = ""

ans1 = ""

# iterate over the given text

for i in range(len(plaintext)):

ch = plaintext[i]

# check if space is there then simply add space

if ch==" ":

ans+=" "

ans1+=" "

# check if a character is uppercase then encrypt it accordingly

elif (ch.isupper()):

ans += chr((ord(ch) + n-65) % 26 + 65)

ans1 += chr((ord(ch) + ROT13-65) % 26 + 65)

# check if a character is lowercase then encrypt it accordingly

else:

ans += chr((ord(ch) + n-97) % 26 + 97)

ans1 += chr((ord(ch) + ROT13-97) % 26 + 97)

return ans

plaintext = "HELLO EVERYONE"

n = 3

ROT13 = 13

print("Plain Text is : " + plaintext)

print("Shift pattern is : " + str(n))


print("Cipher Text is(Caesar Cipher): " + encrypt_text(plaintext,n))

print("Cipher Text is(ROT-13) : " + encrypt_text(plaintext,ROT13))

Output:

Results:

The implementation of substitution ciphers (Caesar Cipher and ROT-13) is executed and verified
successfully.
18CSE435J - Advanced Cryptography

Name of the student NILESH DUTTA


SIDDHARTH GARG
Register number of the student RA2011050010035
RA2011050010041 Section U2

Exercise No. 2 Implementation of Substitution Cipher (Poly-alphabetic


Date of Exercise 09.08.2023 substitution cipher / The Vigenere cipher)

Aim:

To implement Substitution Cipher (Poly-alphabetic substitution cipher / The Vigenere cipher)

Algorithm / Procedure:

generateKey Function:

● Initialize the generateKey function that takes string and key as inputs.
● Convert key into a list of characters.
● If string and key have equal lengths, return key as is.
● If lengths are different, extend the key by appending characters from itself in a circular
manner to match string length.
● Return the modified key as a string.

encryption Function:

● Initialize the encryption function that takes string and key as inputs.
● Generate encrypted text by iterating over each character in string.
● Calculate new character values using modular arithmetic based on key characters.
● Convert calculated values back to alphabetic characters and join them into the encrypted
text.
● Return the encrypted text as a string.

decryption Function:

● Initialize the decryption function that takes encrypt_text and key as inputs.
● Generate original text by iterating over each character in encrypt_text.
● Calculate new character values using modular arithmetic and the original key characters.
● Convert calculated values back to alphabetic characters and join them into the original text.
● Return the original text as a string.

Main Program:

● If the script is run directly (not imported):


● Prompt the user to input a message.
● Prompt the user to input a keyword.
● Generate a modified key using the generateKey function.
● Encrypt the input message using the encryption function and the modified key.
● Print the encrypted message.
● Decrypt the encrypted message using the decryption function and the same modified key.
● Print the decrypted message.
Program / Code:
def generateKey(string, key):

key = list(key)

if len(string) == len(key):

return(key)

else:

for i in range(len(string) -len(key)):

key.append(key[i % len(key)])

return("" . join(key))

def encryption(string, key):

encrypt_text = []

for i in range(len(string)):

x = (ord(string[i]) +ord(key[i])) % 26

x += ord('A')

encrypt_text.append(chr(x))

return("" . join(encrypt_text))

def decryption(encrypt_text, key):

orig_text = []

for i in range(len(encrypt_text)):

x = (ord(encrypt_text[i]) -ord(key[i]) + 26) % 26

x += ord('A')

orig_text.append(chr(x))

return("" . join(orig_text))

if __name__ == "__main__":

string = input("Enter the message: ")

keyword = input("Enter the keyword: ")

key = generateKey(string, keyword)

encrypt_text = encryption(string,key)
print("Encrypted message:", encrypt_text)

print("Decrypted message:", decryption(encrypt_text, key))

Output:

Results:

The implementation of substitution Cipher (Poly-alphabetic substitution cipher / The Vigenere


cipher) is executed and verified successfully.
18CSE435J - Advanced Cryptography

Name of the student NILESH GARG


SIDDHARTH DUTTA

Register number of the student RA2011050010035


RA2011050010041 Section U2

Exercise No. 3
Implementation of Transposition Cipher Techniques
Date of Exercise 09.08.2023

Aim:

To implement transposition cipher techniques i.e, RAIL FENCE CIPHER

Algorithm / Procedure:

encryptMsg Function:

● Initialize encryptMsg function with msg (char array) and key (int).
● Set msgLen to strlen(msg).
● Initialize variables i, j, k = -1, row = 0, col = 0.
● Create a railMatrix 2D array with newline chars.
● Iterate through msg:
● Place the char in railMatrix, move col.
● Toggle k for first/last row, update row.
● Print "Encrypted Message:".
● Print characters from railMatrix without newline chars.

decryptMsg Function:

● Initialize decryptMsg function with enMsg (char array) and key (int).
● Set msgLen to strlen(enMsg).
● Initialize variables i, j, k = -1, row = 0, col = 0, m = 0.
● Create railMatrix 2D array with newline chars.
● Iterate through enMsg:
● Mark cell in railMatrix, move col.
● Toggle k for first/last row, update row.
● Fill marked cells with chars from enMsg sequentially.
● Initialize row, col, k for decryption.
● Print "Decrypted Message:".
● Iterate through railMatrix, print chars and adjust direction.

Main Program:

● Initialize main function.


● Set msg as "Hello World", enMsg as "Horel ollWd", key as 3.
● Print original message.
● Call encryptMsg with msg and key.
● Call decryptMsg with enMsg and key.
● Return 0.
Program / Code:
#include<iostream>

#include<string.h>

using namespace std;

void encryptMsg(char msg[], int key){

int msgLen = strlen(msg), i, j, k = -1, row = 0, col = 0;

char railMatrix[key][msgLen];

for(i = 0; i < key; ++i)

for(j = 0; j < msgLen; ++j)

railMatrix[i][j] = '\n';

for(i = 0; i < msgLen; ++i){

railMatrix[row][col++] = msg[i];

if(row == 0 || row == key-1)

k= k * (-1);

row = row + k;

cout<<"\nEncrypted Message: ";

for(i = 0; i < key; ++i)

for(j = 0; j < msgLen; ++j)

if(railMatrix[i][j] != '\n')

cout<<railMatrix[i][j];

void decryptMsg(char enMsg[], int key){

int msgLen = strlen(enMsg), i, j, k = -1, row = 0, col = 0, m = 0;

char railMatrix[key][msgLen];

for(i = 0; i < key; ++i)

for(j = 0; j < msgLen; ++j)

railMatrix[i][j] = '\n';

for(i = 0; i < msgLen; ++i){

railMatrix[row][col++] = '*';
if(row == 0 || row == key-1)

k= k * (-1);

row = row + k;

for(i = 0; i < key; ++i)

for(j = 0; j < msgLen; ++j)

if(railMatrix[i][j] == '*')

railMatrix[i][j] = enMsg[m++];

row = col = 0;

k = -1;

cout<<"\nDecrypted Message: ";

for(i = 0; i < msgLen; ++i){

cout<<railMatrix[row][col++];

if(row == 0 || row == key-1)

k= k * (-1);

row = row + k;

int main(){

char msg[] = "Hello World";

char enMsg[] = "Horel ollWd";

int key = 3;

cout<<"Original Message: "<<msg;

encryptMsg(msg, key);

decryptMsg(enMsg, key);

return 0;

}
Output:

Results:

The implementation of the rail fence cipher is executed and verified successfully.
18CSE435J - Advanced Cryptography

Name of the student NILESH GARG


MANEPALLI NARAYANA VAMSI

Register number of the student RA2011050010035


RA2011050010001 Section U2

Exercise No. 4
Implementation of DES Algorithm
Date of Exercise 18.08.2023

Aim:

To implement the DES algorithm(Data Encryption Standard, is a symmetric-key block cipher


encryption algorithm. It operates on fixed-size blocks of data (typically 64 bits) and uses a specific key
to perform encryption and decryption. DES was widely used for secure communication and data
protection, but due to its relatively short key length (56 bits), it has become susceptible to modern
cryptanalysis methods)

Algorithm / Procedure:

Import required modules:

● Import the necessary modules from the Crypto library: DES for the encryption algorithm and
get_random_bytes for key generation.

Key Generation:

● Generate a random 8-byte key using the get_random_bytes function.

Cipher Object Creation:

● Create a DES cipher object using the generated key and the ECB (Electronic Codebook) mode.
ECB mode encrypts each block of data independently, which is less secure than other modes
like CBC.

Prepare the Message:

● Define the message to be encrypted (plaintext).


● Pad the message to ensure its length is a multiple of 8 bytes using null bytes.

Encryption:

● Encrypt the padded message using the created DES cipher object.

Output:

● Print the generated key and the encrypted ciphertext.


Program / Code:
Encryption:-

from Crypto.Cipher import DES


from Crypto.Random import get_random_bytes

key = get_random_bytes(8)

cipher = DES.new(key, DES.MODE_ECB)

message = b'This is a secret'

padding = b'\x00' * (8 - len(message) % 8)

padded_message = message + padding


ciphertext = cipher.encrypt(padded_message)

print("Key:", key)

print("Encrypted:", ciphertext)

Decryption:-

from Crypto.Cipher import DES

key = b'\x9c\xdc\x9c\xa2M\xb1Q3'

message = b'This is a secret'

cipher = DES.new(key, DES.MODE_ECB)

padding = b'\x00' * (8 - len(message) % 8)

padded_message = message + padding

ciphertext = cipher.encrypt(padded_message)

print("Key:", key)

print("Encrypted:", ciphertext)

decrypted_padded = cipher.decrypt(ciphertext)

decrypted_message = decrypted_padded.rstrip(b'\x00')
print("Decrypted:", decrypted_message.decode('utf-8'))
Output:

Results:

The implementation of the DES algorithm is executed and verified successfully.


18CSE435J - Advanced Cryptography

Name of the student NILESH GARG


MANEPALLI NARAYANA VAMSI

Register number of the student RA2011050010035


RA2011050010001 Section U2

Exercise No. 5
Implementation of Blowfish Algorithm
Date of Exercise 12.09.2023

Aim:

To implement the blowfish algorithm.

Algorithm / Procedure:

Import Libraries:

● Import the necessary libraries, including Crypto.Cipher from pycryptodome and


Crypto.Random.

Define Padding Functions:

● Create two functions: pad_text and unpad_text.


● pad_text(text) adds padding to the plaintext to make it a multiple of 8 bytes.
● unpad_text(text) removes the padding from decrypted text.

User Input:

● Prompt the user to input the plaintext and encryption key.


● Ensure that the encryption key is exactly 8 bytes long.

Pad the Plaintext:

● Use the pad_text function to pad the plaintext to a multiple of 8 bytes.

Generate Initialization Vector (IV):

● Create a random 8-byte Initialization Vector (IV) using the Crypto.Random.new().read(8)


function.

Encryption Setup:

● Create a Blowfish cipher object using the encryption key and IV in Cipher Block Chaining
(CBC) mode.

Encrypt the Plaintext:

● Use the cipher to encrypt the padded plaintext.

Display Encrypted Text:

● Display the encrypted text in bytes.

Decryption Setup:

● Create a new Blowfish cipher object for decryption using the same encryption key and IV in
CBC mode.

Decrypt the Ciphertext:


● Use the decryption cipher to decrypt the ciphertext.

Remove Padding:

● Use the unpad_text function to remove the padding from the decrypted text.
● Display the decrypted text.

Program / Code:

Step 1:-

pip install pycryptodome

Step 2:-
from Crypto.Cipher import Blowfish

from Crypto import Random

def pad_text(text):

pad_length = 8 - (len(text) % 8)

return text + pad_length.to_bytes(1, byteorder='big') * pad_length

def unpad_text(text):

pad_length = text[-1]

return text[:-pad_length]

plaintext = input("Enter the plaintext: ").encode('utf-8')

key = input("Enter the encryption key (must be 8 bytes long): ").encode('utf-8')

if len(key) != 8:

print("Error: The encryption key must be 8 bytes long.")

exit(1)

plaintext = pad_text(plaintext)

iv = Random.new().read(8)

cipher = Blowfish.new(key, Blowfish.MODE_CBC, iv)

ciphertext = cipher.encrypt(plaintext)

print("Encrypted text (in bytes):", ciphertext)

cipher = Blowfish.new(key, Blowfish.MODE_CBC, iv)

decrypted_text = unpad_text(cipher.decrypt(ciphertext))

print("Decrypted text:", decrypted_text.decode('utf-8'))


Output:

Results:

The implementation of blowfish algorithm is executed and verified successfully.


18CSE435J - Advanced Cryptography

Name of the student NILESH GARG


MANEPALLI NARAYANA VAMSI

Register number of the student RA2011050010035


RA2011050010001 Section U2

Exercise No. 6
Implementation of Rijndael Algorithm
Date of Exercise 12.09.2023

Aim:

To implement the Rijndael algorithm.

Note:- Rijndael is a symmetric key block cipher algorithm designed by Vincent Rijmen and Joan
Daemen. It was selected as the encryption standard by the U.S. National Institute of Standards and
Technology (NIST) in 2001 and is known as AES (Advanced Encryption Standard) when used in that
standardized form.

Algorithm / Procedure:

● We import the required modules, including Crypto.Cipher.AES and


Crypto.Random.get_random_bytes.
● We define two functions, pad_text and unpad_text, to handle text padding and unpadding.
● A random 128-bit (16-byte) encryption key is generated using get_random_bytes.
● We create an AES cipher object in Electronic Codebook (ECB) mode using the generated
encryption key.
● User input for the plaintext is obtained and then padded using the pad_text function.
● The plaintext is encrypted using the AES cipher.
● The encrypted ciphertext is displayed in bytes.
● To decrypt, we create a new AES cipher object for decryption and use it to decrypt the
ciphertext. Then, we remove the padding using the unpad_text function.
● Finally, the decrypted text is displayed.

Program / Code:

from Crypto.Cipher import AES

from Crypto.Random import get_random_bytes

def pad_text(text):

pad_length = 16 - (len(text) % 16)

return text + bytes([pad_length] * pad_length)

def unpad_text(text):

pad_length = text[-1]

return text[:-pad_length]

key = get_random_bytes(16)

cipher = AES.new(key, AES.MODE_ECB)

plaintext = input("Enter the plaintext: ").encode('utf-8')


plaintext = pad_text(plaintext)

ciphertext = cipher.encrypt(plaintext)

print("Encrypted text (in bytes):", ciphertext)

decipher = AES.new(key, AES.MODE_ECB)

decrypted_text = unpad_text(decipher.decrypt(ciphertext))

print("Decrypted text:", decrypted_text.decode('utf-8'))

Output:

Results:

The implementation of Rijndael Algorithm is executed and verified successfully.


18CSE435J - Advanced Cryptography

Name of the student NILESH GARG


MANEPALLI NARAYANA VAMSI

Register number of the student RA2011050010035


RA2011050010001 Section U2

Exercise No. 7
Implementation of Diffie-Hellman Algorithm
Date of Exercise 12.09.2023

Aim:

To implement the Diffie-Hellman Algorithm.

(The Diffie-Hellman key exchange is a cryptographic method that allows two parties to establish a
shared secret key over an insecure communication channel, without directly exchanging their secret
keys. This shared secret key can then be used for secure communication or encryption.)

Algorithm / Procedure:

Choose Public Parameters:

● Select publicly known parameters:


● A large prime number p.
● A primitive root modulo p, denoted as g.

Generate Private Keys:

Alice:

● Generate a private key a_private, a random integer within the range [1, p-1].

Bob:

● Generate a private key b_private, a random integer within the range [1, p-1].

Compute Public Keys:

Alice:

● Compute her public key a_public as (g^a_private) % p.

Bob:

● Compute his public key b_public as (g^b_private) % p.

Exchange Public Keys:

● Alice and Bob exchange their public keys over a secure channel.

Calculate Shared Secret:

Alice:

● Calculate the shared secret as (b_public^a_private) % p.

Bob:

● Calculate the shared secret as (a_public^b_private) % p.


Result:

● Both Alice and Bob now have the same shared secret, which can be used as a secret key for
secure communication.

Program / Code:

# Shared prime (p) and base (g)

p = int(input("Enter the prime number (p): "))

g = int(input("Enter the base (g): "))

# Alice's private key

a_private = int(input("Enter Alice's private key: "))

# Bob's private key

b_private = int(input("Enter Bob's private key: "))

# Calculate Alice's public key

a_public = (g ** a_private) % p

# Calculate Bob's public key

b_public = (g ** b_private) % p

# Alice computes the shared secret

shared_secret_alice = (b_public ** a_private) % p

# Bob computes the shared secret

shared_secret_bob = (a_public ** b_private) % p

# The shared secret should be the same for both Alice and Bob

print("Shared Secret (Alice):", shared_secret_alice)

print("Shared Secret (Bob):", shared_secret_bob)


Output:

Results:

The implementation of Diffie-Hellman Algorithm is executed and verified successfully.


18CSE435J - Advanced Cryptography

Name of the student NILESH GARG


Amar mehta

Register number of the student RA2011050010035


RA2011050010027 Section U2

Exercise No. 8
Implementation of RSA Algorithms
Date of Exercise 20.09.2023

Aim:

To implement RSA algorithms.

Algorithm / Procedure:

Key Generation:

Select two large prime numbers, p and q.

● Compute n = p * q, which will be the modulus for both the public and private keys.
● Calculate φ(n) = (p - 1) * (q - 1), where φ is Euler's totient function.
● Choose a public exponent e, where 1 < e < φ(n), and gcd(e, φ(n)) = 1.
● Calculate the private exponent d, which is the modular multiplicative inverse of e modulo
φ(n), i.e., d * e ≡ 1 (mod φ(n)).

Keys:

● Public Key: (n, e)


● Private Key: (n, d)

Encryption:

● Convert the plaintext message M into an integer m.


● Compute the ciphertext C as C = m^e mod n.

Decryption:

● Use the private key (n, d) to decrypt the ciphertext.


● Compute the plaintext message M as M = C^d mod n.

Program / Code:

import random

import math

def is_prime(num):

if num < 2:

return False

for i in range(2, int(math.sqrt(num)) + 1):

if num % i == 0:

return False
return True

def gcd(a, b):

while b:

a, b = b, a % b

return a

def mod_inverse(a, m):

m0, x0, x1 = m, 0, 1

while a > 1:

q = a // m

m, a = a % m, m

x0, x1 = x1 - q * x0, x0

return x1 + m0 if x1 < 0 else x1

def generate_prime(bits):

while True:

num = random.getrandbits(bits)

if is_prime(num):

return num

def generate_keypair(bits):

p = generate_prime(bits)

q = generate_prime(bits)

n=p*q

phi = (p - 1) * (q - 1)

e = random.randint(2, phi - 1)

while gcd(e, phi) != 1:

e = random.randint(2, phi - 1)

d = mod_inverse(e, phi)

return ((n, e), (n, d))


def encrypt(public_key, plaintext):

n, e = public_key

cipher = [pow(ord(char), e, n) for char in plaintext]

return cipher

def decrypt(private_key, ciphertext):

n, d = private_key

plaintext = [chr(pow(char, d, n)) for char in ciphertext]

return ''.join(plaintext)

if name == " main ":

bits = int(input("Enter the number of bits for the key size: "))

public_key, private_key = generate_keypair(bits)

message = input("Enter the message to encrypt: ")

encrypted_message = encrypt(public_key, message)

decrypted_message = decrypt(private_key, encrypted_message)

print("Original message:", message)

print("Encrypted message:", encrypted_message)

print("Decrypted message:", decrypted_message)


Output:

Results:

The implementation of RSA algorithm is executed and verified successfully.


18CSE435J - Advanced Cryptography

Name of the student NILESH GARG


Amar Mehta

Register number of the student RA2011050010035


RA2011050010027 Section U2

Exercise No. 9
Implementation of Digital Signature Standards
Date of Exercise 16.10.2023

Aim:

To implement digital signature standards.

Digital Signature Standards (DSS) are cryptographic standards that define the algorithms and
protocols used for digital signatures. In the context of DSS, the Digital Signature Algorithm (DSA) is a
widely used algorithm for generating digital signatures.

Algorithm / Procedure:

Key Generation:

Generate a DSA key pair (public key and private key).

Signing:

Accept a message from the user as input.

Hash the input message using the SHA-256 hashing algorithm to create a message digest.

Sign the message digest using the private key to generate a digital signature.

Verification:

Hash the original input message using the SHA-256 hashing algorithm to recreate the message
digest.

Verify the digital signature using the public key and the recreated message digest.

If the verification is successful, the signature is valid; otherwise, it is invalid.

Output:

Display the validity status of the digital signature (Valid/Invalid).

Display the public key (for demonstration purposes).

Display the private key (for demonstration purposes)

Program / Code:

from Crypto.PublicKey import DSA

from Crypto.Signature import DSS

from Crypto.Hash import SHA256


# Step 1: Key Generation

key = DSA.generate(2048) # Generate key pair

public_key = key.publickey().export_key()

private_key = key.export_key()

# Step 2: Signing

message = input("Enter the message to be signed: ").encode() # Message to be signed

hash_object = SHA256.new(message) # Create a hash of the message

signer = DSS.new(key, 'fips-186-3') # Create a digital signature

signature = signer.sign(hash_object)

# Step 3: Verification

hash_object = SHA256.new(message) # Hash the original message again

verifier = DSS.new(key.publickey(), 'fips-186-3') # Create a verifier

try:

verifier.verify(hash_object, signature) # Verify the signature

print("Signature is valid.")

except ValueError:

print("Signature is invalid.")

# Output public and private keys (for demonstration purposes)

print("\nPublic Key:")

print(public_key.decode())

print("\nPrivate Key:")

print(private_key.decode())
Output:

Results:

The implementation of digital signature standards is executed and verified successfully.


18CSE435J - Advanced Cryptography

Name of the student NILESH GARG


Amar mehta

Register number of the student RA2011050010035


RA2011050010027 Section U2

Exercise No. 10
Set Up a Honeypot and Honeypot on Network
Date of Exercise 16.10.2023

Aim:

To set up a honeypot and honeypot on the network.

Algorithm / Procedure:

Prerequisites:

A dedicated machine or virtual machine (VM) for the honeypot.

Basic understanding of networking concepts.

Steps:

Install Honeyd:

Install Honeyd on your dedicated machine or VM. You can find the software at Honeyd's official
website.

Create a Configuration File:

Create a configuration file (e.g., honeypot.conf) to define the services you want to emulate. Here's a
simple example:

create default

set default personality "Microsoft Windows XP Professional SP3"

set default default tcp action reset

set default default udp action reset

# Emulate an HTTP server on port 80

add default tcp port 80 open

# Emulate an FTP server on port 21

add default tcp port 21 open

# Add more services as needed

Configure Network Settings:

Assign a static IP address to your honeypot machine.

Ensure the machine is on a separate network or VLAN, isolated from your production network.
Run Honeyd with the Configuration File:

Open a terminal and run Honeyd with the configuration file:

honeyd -f honeypot.conf -l <honeypot_ip>

Replace <honeypot_ip> with the IP address you assigned to the honeypot.

Monitor Logs:

Honeyd logs activities to the console. Monitor the console for any connection attempts to the
emulated services.

Optional: Use Wireshark for Packet Capture:

Install Wireshark on the honeypot machine to capture network traffic for detailed analysis.

Analysis:

Analyze the logs and captured traffic to understand the nature of connection attempts. Look for port
scans, connection requests, or any other suspicious activities.

Modify Configuration for More Services:

Edit the configuration file to add or modify services based on your experiment goals. For example,
emulate an SSH server, a database server, etc.

Shutdown the Honeypot:

When you're done with the experiment, gracefully shut down the Honeyd process.
Output:

Results:

The implementation of a honeypot and honeypot on the network is executed and verified
successfully.

You might also like