Csci 352 Project 1 Understanding Rsa In This Assignment ✓ Solved
Csci 352 Project 1 Understanding Rsain This Project Assignment You W
Complete a Python program to implement a simplified version of RSA cryptosystems that includes key generation, encryption, and decryption. The program should generate two large prime numbers, find a coprime number, compute the modular inverse, and perform modular exponentiation for encryption and decryption. It must also output the generated key parameters, a sample message, encrypted ciphertext, and decrypted message, verifying the correctness of the process.
Sample Paper For Above instruction
Implementation of RSA Cryptosystem in Python
This paper details the implementation of a simplified RSA cryptosystem using Python, focusing on key generation, encryption, and decryption processes. RSA, established by Rivest, Shamir, and Adleman, forms the backbone of many cryptographic protocols. The implementation covers prime number detection, coprime selection, modular inverse calculation, and modular exponentiation—core components of RSA. The goal is to produce a functional program that generates keys, encrypts a message, and decrypts it, validating the system's correctness.
Introduction to RSA Cryptosystem
RSA encryption relies on the difficulty of factoring large composite numbers. It involves generating a public-private key pair: the public key (n, e) and the private key (n, d). The modulus n is derived from two large primes p and q. The public exponent e is chosen such that it is coprime to ϕ(n), and d is its modular inverse, satisfying ed ≡ 1 mod ϕ(n). The encryption and decryption processes involve modular exponentiation with these keys.
Prime Number Generation
The first step involves identifying two primes, p and q, within a specified range. The implementation requires a function, is_prime, which checks whether a number is prime by testing divisibility up to the square root of the number. Prime generation can be optimized using probabilistic tests for larger numbers, but for simplicity, deterministic tests are used here.
GCD Calculation
To find e, which must be coprime to ϕ(n), the greatest common divisor (gcd) function is necessary. Euclid's algorithm efficiently computes the gcd by iterative division. If gcd(e, ϕ(n)) == 1, then e is suitable for key generation.
Modular Inverse Calculation
The modular inverse d of e modulo ϕ(n) is computed using the Extended Euclidean Algorithm. This algorithm finds d such that ed ≡ 1 mod ϕ(n). It is efficient and reliable for large integers and critical for completing the key pair.
Modular Exponentiation
Encryption and decryption involve modular exponentiation: computing base^exponent mod n. The pow() function in Python is utilized for this purpose, which handles large exponents efficiently with built-in optimizations.
Implementation and Demonstration
The program automatically selects prime numbers greater than 1000 (p) and 2000 (q). It calculates keys, encrypts a sample message, and then decrypts it, checking the integrity of the process. Output includes all key parameters, the original message, the ciphertext, and the decrypted message, confirming the correctness of the implementation.
Conclusion
This implementation demonstrates the fundamental processes underlying RSA cryptography in Python. While simplified, it covers essential steps and tools necessary for understanding and applying RSA encryption. Future improvements could include probabilistic prime testing, larger key sizes, and integration into secure communication protocols.
References
- Rivest, R., Shamir, A., & Adleman, L. (1978). A method for obtaining digital signatures and public-key cryptosystems. Communications of the ACM, 21(2), 120-126.
- Diffie, W., & Hellman, M. (1976). New directions in cryptography. IEEE Transactions on Information Theory, 22(6), 644-654.
- Boneh, D., & Shoup, V. (2020). A Graduate Course in Applied Cryptography. Springer.
- Katz, J., & Lindell, Y. (2014). Introduction to Modern Cryptography. CRC Press.
- Menezes, A. J., van Oorschot, P. C., & Vanstone, S. A. (1996). Handbook of Applied Cryptography. CRC Press.
- Formalization of Prime Checking Algorithms - Prime Number Testing, Wolfram MathWorld.
- Extended Euclidean Algorithm Implementation, GeeksforGeeks.
- Python pow() Function Documentation, Python official documentation.
- Cryptography with RSA: An Introduction, NIST.
- Security considerations of RSA, IEEE Security & Privacy, 2001.