RSA (Rivest-Shamir-Adleman) Interview Questions and Answers
Top 10 RSA interview questions with Mermaid diagrams, production scenarios, and enterprise security best practices.
RSA (Rivest-Shamir-Adleman) - Interview Questions & Answers
RSA is one of the most popular asymmetric encryption algorithms used in enterprise applications. Unlike AES, RSA uses a Public Key and a Private Key, making it ideal for secure key exchange, digital signatures, SSL/TLS certificates, and secure communication.
Although RSA is slower than symmetric encryption, it plays a critical role in modern security architectures.
Q1. What is RSA?
Answer
RSA (Rivest-Shamir-Adleman) is an asymmetric encryption algorithm that uses two mathematically related keys.
- Public Key
- Private Key
The Public Key encrypts data.
The Private Key decrypts data.
RSA Encryption Flow
flowchart LR
A[Plain Text] --> B[Public Key] --> C[RSA Encryption] --> D[Cipher Text] --> E[Private Key] --> F[RSA Decryption] --> G[Plain Text]
Characteristics
- Asymmetric Encryption
- Public & Private Keys
- Secure Key Exchange
- Digital Signatures
- Widely used in HTTPS
Q2. Why is RSA used?
Answer
RSA solves one of the biggest problems in cryptography:
How do two parties securely exchange a secret key over an untrusted network?
RSA enables:
- Secure key exchange
- Digital signatures
- Certificate authentication
- Identity verification
Production Example
Browser
↓
HTTPS Connection
↓
RSA Key Exchange
↓
AES Session Key
↓
Secure Communication
Q3. How does RSA work?
Answer
RSA works using a pair of keys.
- Generate Public and Private Keys.
- Share the Public Key.
- Encrypt data using the Public Key.
- Decrypt data using the Private Key.
RSA Workflow
flowchart TD
A[Generate Key Pair] --> B[Public Key]
A-->C[Private Key]
B-->D[Encrypt Data]
D-->E[Cipher Text]
E-->F[Private Key]
F-->G[Decrypt Data]
Only the owner of the Private Key can decrypt the encrypted data.
Q4. What is the difference between Public Key and Private Key?
Answer
| Public Key | Private Key |
|---|---|
| Shared openly | Secret |
| Encrypts data | Decrypts data |
| Verifies signatures | Creates signatures |
| Can be distributed | Must never be shared |
Diagram
flowchart LR
A[Sender] --> B[Public Key]
C[Encrypted Message] --> C[Encrypted Message]
D[Receiver] --> D[Receiver]
E[Private Key] --> E[Private Key]
F[Original Message] --> F[Original Message]
Interview Tip
The Private Key should always remain confidential.
Q5. Where is RSA used in enterprise applications?
Answer
RSA is commonly used for:
- HTTPS
- SSL/TLS Certificates
- Digital Signatures
- JWT Signing
- Secure Email
- VPN Authentication
- Certificate Authorities (CA)
Enterprise Architecture
flowchart TD
A[Client] --> B[HTTPS] --> C[RSA Key Exchange] --> D[AES Session Key] --> E[Spring Boot API]
RSA is typically used only during the initial handshake.
Q6. Why isn't RSA used to encrypt large files?
Answer
RSA is computationally expensive.
Encrypting large files with RSA would:
- Consume more CPU
- Increase latency
- Reduce throughput
Instead:
- RSA exchanges the encryption key.
- AES encrypts the actual data.
Hybrid Encryption
flowchart LR
A[RSA] --> B[Exchange AES Key]
B --> C[AES]
C --> D[Encrypt Large Data]
This approach combines security with performance.
Q7. What is Digital Signature in RSA?
Answer
RSA supports digital signatures.
Instead of encrypting data with the Public Key, the sender signs the data using the Private Key.
The receiver verifies the signature using the Public Key.
Digital Signature Flow
flowchart LR
A[Document] --> B[Private Key]
C[Digital Signature] --> C[Digital Signature]
D[Public Key] --> D[Public Key]
E[Signature Verification] --> E[Signature Verification]
Benefits
- Authentication
- Integrity
- Non-Repudiation
Q8. What are common RSA key sizes?
Answer
Common RSA key sizes include:
| Key Size | Recommendation |
|---|---|
| 1024-bit | Not Recommended |
| 2048-bit | Industry Standard |
| 3072-bit | High Security |
| 4096-bit | Very High Security |
Interview Tip
RSA-2048 is currently the most commonly used key size in enterprise systems.
Q9. What are common RSA implementation mistakes?
Answer
Common mistakes include:
- Using RSA for large file encryption.
- Using weak key sizes.
- Hardcoding private keys.
- Storing keys in source code.
- Not rotating certificates.
- Using expired certificates.
- Using outdated TLS versions.
Wrong Design
Application
↓
Private Key
↓
Source Code ❌
Correct Design
Application
↓
AWS KMS / HSM / Vault
↓
Private Key
Private keys should always be stored securely.
Q10. What are the enterprise best practices for RSA?
Answer
Follow these best practices:
- Use RSA-2048 or higher.
- Protect private keys using HSM or Vault.
- Rotate certificates regularly.
- Use RSA only for key exchange or signatures.
- Use AES for bulk data encryption.
- Enable TLS 1.3.
- Monitor certificate expiration.
- Never expose private keys.
- Use trusted Certificate Authorities.
- Keep cryptographic libraries updated.
Enterprise RSA Architecture
flowchart TD
A[Browser] --> B[TLS Handshake] --> C[RSA/ECC] --> D[AES Session Key] --> E[Spring Boot Application] --> F[Encrypted Database]
Enterprise HTTPS Flow
flowchart LR
A[Client] --> B[Public Certificate]
C[RSA Key Exchange] --> C[RSA Key Exchange]
D[AES Session Key] --> D[AES Session Key]
E[Encrypted Communication] --> E[Encrypted Communication]
Senior Interview Tip
RSA is not designed for encrypting application data.
Enterprise applications typically use:
- RSA or ECC for secure key exchange
- AES-256 for encrypting data
- TLS 1.3 for secure communication
- Digital Signatures for integrity and authentication
- AWS KMS, Azure Key Vault, or HSM for secure key management
RSA is one component of a larger enterprise cryptography strategy, working together with symmetric encryption and secure key management.
Quick Revision
- RSA is an asymmetric encryption algorithm.
- RSA uses Public and Private Keys.
- Public Key encrypts data.
- Private Key decrypts data.
- RSA is commonly used for HTTPS.
- RSA is ideal for digital signatures.
- RSA is not suitable for encrypting large files.
- Use RSA-2048 or higher.
- Protect private keys using HSM or Vault.
- Modern enterprise applications combine RSA with AES for secure and efficient encryption.