0% found this document useful (0 votes)
8 views5 pages

Assignment 2

This report details a comprehensive lab on RSA cryptography, covering key generation, encryption, decryption, digital signatures, and verification using the OpenSSL BIGNUM API in C. The lab included five tasks that demonstrated the RSA algorithm's functionality and highlighted the importance of secure communications and data integrity. Future work may involve larger key sizes, performance optimization, and hybrid cryptosystems to enhance security.

Uploaded by

jamiltube1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Assignment 2

This report details a comprehensive lab on RSA cryptography, covering key generation, encryption, decryption, digital signatures, and verification using the OpenSSL BIGNUM API in C. The lab included five tasks that demonstrated the RSA algorithm's functionality and highlighted the importance of secure communications and data integrity. Future work may involve larger key sizes, performance optimization, and hybrid cryptosystems to enhance security.

Uploaded by

jamiltube1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Abstract

This report presents an in-depth exploration of RSA cryptography, focusing on key generation,
encryption, decryption, digital signatures, and signature verification using the OpenSSL
BIGNUM API in C. The lab had five tasks, each demonstrating fundamental aspects of the RSA
algorithm. Task 1 involved deriving the private key d from given prime numbers p and q using
the Extended Euclidean Algorithm. Task 2 illustrated the encryption of a plaintext message into
ciphertext, while Task 3 successfully decrypted the ciphertext back into the original message. In
Task 4, the task examined the signing of a message and the impact of minor modifications on the
digital signature, revealing the sensitivity of RSA signatures to even slight changes. Task 5
focused on verifying a signature and observing the effects of a corrupted signature on the
verification process. Through these tasks, significant insights were gained regarding the practical
applications and importance of RSA cryptography in ensuring secure communications and data
integrity. Future explorations could include implementing larger key sizes for enhanced security,
optimizing performance, and investigating hybrid cryptosystems that combine RSA with
symmetric algorithms.

Methodology and Results

Task 1: Deriving the Private Key

1. Objective: Calculate the private key d using the provided prime numbers p, q, and public
exponent e.
2. Steps:
▪ The values for p, q, and e were converted from hexadecimal to decimal for
calculations.
▪ Calculated n as n = p × q.
▪ Calculated ϕ(n) = (p − 1) × (q − 1).
▪ Used the Extended Euclidean Algorithm to compute the modular inverse of eee
modulo ϕ(n) to derive d.
3. Screenshot:
4. Results:
The calculations for deriving the private key were correct, confirming the implementation
of the Extended Euclidean Algorithm.

Task 2: Encrypting a Message

1. Objective: Encrypt the message "A top secret!" using the public key (e, n).
2. Steps:
▪ Converted the message from ASCII to a hexadecimal string.
▪ Transformed the hexadecimal string into a BIGNUM using OpenSSL's
BN_hex2bn().
▪ Performed encryption using the formula C=Me mod n.
3. Screenshot:

4. Results:
The encryption processes yielded accurate results.

Task 3: Decrypting a Message

1. Objective: Decrypt the ciphertext obtained from Task 2 using the private key d.
2. Steps:
▪ The ciphertext was converted from hexadecimal to a BIGNUM.
▪ Decryption was performed using the formula M′ = Cd mod n.
▪ The decrypted BIGNUM was converted to hexadecimal.
▪ Convert the hexadecimal string back to plain ASCII string
Use the following Python command:
$ python3 -c 'print(bytes.fromhex("your_hex_string_here").decode("utf-8"))'
3. Screenshot:

4. Results:
The encryption and decryption processes yielded accurate results, as the original
message was retrieved successfully.

Task 4: Signing a Message

1. Objective: Sign the message "I owe you $2000." and compare it to the signature of the
modified message "I owe you $3000.".
2. Steps:
▪ The original message was signed using the private key d with the formula
S = Md mod n.
▪ A modified version of the message was signed using the same method.
▪ Both signatures were compared to observe differences.
3. Code Snippet:
4. Screenshot:
5. Results:
Signing and verifying messages illustrated the integrity of the RSA signature
mechanism. The difference in signatures for slight message modifications highlighted
the sensitivity of digital signatures to even minor changes.

Task 5: Verifying a Signature

1. Objective: Verify Alice's signature for the message "Launch a missile." and test with a
corrupted signature.
2. Steps:
▪ The original signature was converted from hexadecimal to a BIGNUM.
▪ Verified the signature using the formula M′ = Se mod n and compared it with the
original message.
▪ After altering the last byte of the signature, the verification process was repeated
to demonstrate the impact of a single-bit change.
3. Screenshot:

4. Results:
The verification of a corrupted signature resulted in a failed verification, emphasizing the
importance of data integrity in cryptographic communications.
Conclusion
This lab provided a comprehensive introduction to RSA cryptography and the implementation of
key cryptographic operations using the OpenSSL BIGNUM API in C. The following knowledge
were gained throughout the assignment:

• Understanding RSA: I gained a deeper understanding of how RSA works, including the
mathematical principles behind key generation, encryption, decryption, signing, and
verification.
• Importance of Security: The lab emphasized the significance of secure key
management and the need for robust implementations, especially when dealing with
cryptographic protocols.
• Real-World Applications: This lab highlighted the relevance of RSA in real-world
applications such as secure communications, digital signatures, and data integrity
verification.

Future Directions
• Larger Key Sizes: Exploring the implementation of RSA with larger key sizes (e.g.,
2048 or 4096 bits) to enhance security.
• Performance Optimization: Investigating methods to optimize the performance of RSA
operations, particularly for encryption and decryption of large datasets.
• Hybrid Cryptosystems: Implementing a hybrid cryptographic system that combines
RSA with symmetric key algorithms for practical applications.

This lab provided valuable insights into the workings of RSA cryptography, and I look forward
to further exploration in the field of cryptography and secure communications.

You might also like