Computer Networks (UGC NET topics) · Network Security
Public Key Cryptography and RSA
Overview
Public key cryptography, also called asymmetric-key cryptography, uses two related keys per user: a public key that may be announced openly and a private key kept secret.
RSA is the standard public-key cryptosystem for confidentiality and digital signatures; its security depends on the difficulty of factoring a large composite integer.
In the UGC NET Computer Networks syllabus, this topic lies under Network Security and is usually tested through key selection, RSA key generation, modular arithmetic, encryption/decryption, digital signatures, and Diffie–Hellman key agreement.
Before studying it, you should know primes, modular arithmetic, Euler’s totient function, modular inverse, and basic plaintext–ciphertext terminology.
Key concepts
- Plaintext is the original message ; ciphertext is the transformed message ; a key controls encryption and decryption.
An encryption algorithm needs the message and the key; ciphertext is its output, and personal details of the user are not part of the algorithm. - Symmetric cryptography uses one shared secret key for both encryption and decryption, e.g. DES, AES, Caesar cipher. Asymmetric cryptography uses a key pair, e.g. RSA, ElGamal, ECC, DSA, and historically Knapsack.
- In public-key cryptography, each user owns a public key and a private key. The public key is announced; the private key is never announced.
- For confidentiality, the sender encrypts with the receiver’s public key; only the receiver can decrypt with the receiver’s private key.
- For authentication and digital signature, the sender signs with the sender’s private key; anyone verifies with the sender’s public key. This gives integrity, authentication, and non-repudiation, but not confidentiality by itself.
- Non-repudiation means the sender cannot later deny having sent the message. A digital signature provides this property.
- A one-way function is easy to compute in one direction but computationally hard to invert.
In public-key systems it helps make the private key impossible to derive from the public key; RSA uses a trapdoor one-way function based on modular exponentiation. - RSA security is based on the difficulty of integer factorization of , and more precisely on the RSA problem of extracting -th roots modulo .
Diffie–Hellman uses the discrete logarithm problem; Knapsack uses a subset-sum type problem. - In RSA, public key is and private key is . The primes and are secret.
- Diffie–Hellman is a key agreement protocol, not a message-encryption algorithm.
Public values are a prime and a generator ; each party chooses a private exponent and exchanges a public value, then both compute the same shared secret. - Basic Diffie–Hellman without authentication is vulnerable to a man-in-the-middle attack: an active attacker can establish separate shared keys with the two parties.
How it works
RSA key generation
- Choose two distinct large primes and .
- Compute the modulus . This is public.
- Compute Euler’s totient . Keep it secret in practice.
- Choose a public exponent such that and .
- Compute the private exponent as the modular inverse of modulo : .
- Publish ; keep secret. In textbook RSA, the private key is often written as .
Encryption and decryption
- Represent the message as an integer with .
- Encryption: .
- Decryption: .
- Correctness follows from , so under the standard RSA conditions.
Digital signature using RSA
- Sender computes a hash of the message.
- Sender encrypts/signs the hash with the sender’s private key.
- Receiver verifies with the sender’s public key.
- The receiver checks that the recovered hash matches the message hash.
Diffie–Hellman key agreement
- Public parameters: prime and generator .
- Ramesh chooses private , computes .
- Geeta chooses private , computes .
- They exchange and .
- Ramesh computes ; Geeta computes . Both get .
For RSA with words, numbers are assigned to letters by a fixed convention. Many UGC papers use , encrypt each number modulo , and then map the cipher number back to a letter, often reducing modulo 26; always check the convention stated or implied.
Drawing the diagram…
Formulas
- : RSA modulus, product of two distinct primes.
- : Euler’s totient for .
- : condition for a valid public exponent.
- : private exponent condition; is the modular multiplicative inverse of modulo .
- : RSA encryption.
- : RSA decryption.
- for some integer : equivalent form of the inverse condition.
- : Diffie–Hellman public values.
- : Diffie–Hellman shared secret.
- For users, symmetric cryptography needs pairwise keys; asymmetric cryptography needs key pairs, i.e. individual keys.
Worked examples
Example 1: RSA key setup and encryption. Let , , . Find , then encrypt . We need . Since , . Now , , so . Thus and .
Example 2: Finding private exponent. Let , , . Find the smallest positive . Solve . Since , . The public key is and the private key is .
Example 3: RSA encryption with public key. Given public key and , find . First . Then . Hence . So .
Example 4: Two-step inverse problem. Let , , and . Find the public exponent . Need , so . Modulo 13, . Since , . Taking : Check: . Thus .
Example 5: Statement type. Statement I: must be relatively prime to . Statement II: is the inverse of modulo . Statement III: For confidentiality, the sender encrypts with the sender’s private key.
Statement I is true. Statement II is false because is inverse of modulo , not modulo . Statement III is false because confidentiality uses the receiver’s public key; the sender’s private key is used for signatures.
Comparison
| Feature | Symmetric-key cryptography | Asymmetric-key cryptography |
|---|---|---|
| Keys | One shared secret key | Public key and private key pair |
| Key distribution | Needs secure sharing | Public key can be announced, but authenticity must be guaranteed |
| Speed | Fast | Much slower |
| Examples | DES, AES, Caesar cipher | RSA, ElGamal, ECC, DSA, Knapsack |
| Main use | Bulk data encryption | Key exchange, digital signatures, small data encryption |
| Keys for users | pairwise keys | key pairs |
| Goal | Sender uses | Receiver or verifier uses | Provides |
|---|---|---|---|
| Confidentiality | Receiver’s public key | Receiver’s private key | Privacy |
| Digital signature | Sender’s private key | Sender’s public key | Integrity, authentication, non-repudiation |
| RSA item | Meaning |
|---|---|
| Secret distinct primes | |
| Public modulus | |
| Secret totient used in key generation | |
| Public exponent, coprime to | |
| Private exponent, | |
| Public key | |
| Private key |
Revision summary
- Public key may be announced; private key must never be announced.
- Confidentiality: encrypt with the receiver’s public key; decrypt with the receiver’s private key.
- Signature: sign with the sender’s private key; verify with the sender’s public key.
- RSA encryption and decryption are done modulo , not modulo .
- The inverse condition is , not modulo .
- e must satisfy .
- , for distinct primes.
- RSA security relies on factoring or solving the RSA problem; Diffie–Hellman relies on discrete logarithms.
- Diffie–Hellman is key agreement, not encryption; unauthenticated DH suffers man-in-the-middle attack.
- Raw textbook RSA is deterministic; practical systems use padding such as OAEP.
- UGC key-size matches often use DES 56, AES 128/192/256, 3DES 168, and RSA 1024 in older match questions.
Previous-year exam insights
- Direct concept questions ask which key is used for confidentiality, which key is kept private, what non-repudiation means, and why RSA can be used in reverse for digital signatures.
- Numeric RSA questions give or and ask for , , the missing exponent, or ciphertext/plaintext.
Check first whether the inverse is modulo and the exponentiation is modulo . - Statement and matching questions test: is coprime to ; is inverse of modulo ; public key algorithm examples include RSA and Knapsack, while DES/AES are symmetric.
- Diffie–Hellman questions check that are public, that the protocol agrees on a secret key, and that without authentication an active attacker can mount a man-in-the-middle attack.
- Common traps: using modulo to compute , using modulo for ciphertext, encrypting with the sender’s public key for confidentiality, or saying Diffie–Hellman encrypts messages.
- Word-based RSA can appear; use the stated letter-number convention, keep each number less than , and convert back consistently.
- Key-count questions distinguish symmetric from asymmetric key pairs.
- Questions about encryption algorithms themselves may test that a key and message are essential, ciphertext is output, and user details are not required.
Practice at PARIKSHA
You are ready for the PARIKSHA tests of this sub-topic when you can:
- Define asymmetric-key cryptography and state which key is public and which is private.
- Choose the correct key for confidentiality and for a digital signature.
- Generate RSA parameters from or and find the missing exponent using modular inverse.
- Encrypt and decrypt small RSA integers using modulo .
- Explain the roles of and the condition .
- State the hard mathematical problem behind RSA, Diffie–Hellman, and Knapsack.
- Trace Diffie–Hellman key agreement and explain the man-in-the-middle weakness.
- Compare symmetric and asymmetric cryptography, including key counts and typical examples.
- Spot the traps between modulo and modulo , and between encryption for confidentiality and signing for non-repudiation.
Attempt the PARIKSHA sub-topic test first, then the subject test.