← Cryptography guide

K035 / Asymmetric encryption, signatures and key exchange

RSA

RSA cryptosystem · Survey date 2026-12-05

RSA is a prominent asymmetric cryptosystem named after Rivest, Shamir and Adleman.

CRYPTOGRAPHY LAB / K035

Cryptography Lab · RSA

Run real computations and inspect intermediate states step by step.

Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.

Scope: Toy educational example

RSA (p=61, q=53; raw integer)

See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.

Open lab →

Definition and overview
RSA is a prominent asymmetric cryptosystem named after Rivest, Shamir and Adleman. Source document ↗
Classification and reversibility
An RSA-based asymmetric cryptosystem in which the private key is used for signing and decryption. Source document ↗
Key or secret requirements
The private key uses a pair of large prime numbers as secret values. Source document ↗
Operating principle and structure
Represents the message as a number M, raises it to the public exponent e, then uses the remainder modulo the public modulus n. Source document ↗
Key size, block size and parameters
Keys of 1024 bits or less are weak; 2048 or 4096 bits are reasonable defaults for new keys. Source document ↗
Security strength and recommendation
RSA-2048 provides approximately 112 bits of security strength according to NIST SP 800-57. Source document ↗
Known attacks and vulnerabilities
A large quantum computer could factor the RSA modulus in polynomial time using Shor's algorithm. Source document ↗
Standards and certification
RSA implementations follow PKCS #1 and RFC 8017 specifications. Source document ↗
Typical uses
Used for digital signatures and encryption of small amounts of data. Source document ↗
Implementations, libraries and tools
The node-rsa library for Node.js and browsers. Source document ↗
Decryption or decoding
Uses the private exponent d to recover m from ciphertext c. Source document ↗
Advantages
The private key is not exposed by publishing the public key, facilitating key distribution. Source document ↗
Limitations and cautions
Asymmetric encryption is generally not recommended for bulk data encryption. Source document ↗
Distinguishing encryption, encoding and hashing
RSA signing applies a private-key operation to a message hash; it must be distinguished from simple encoding or hashing. Source document ↗

Practical examples

Examples are illustrative; they are not execution-tested implementations or operational recommendations.

Example

Generate a key pair and encrypt a short message with the public key; only the private-key holder can decrypt it. Signing involves signing the message hash with the private key and verifying with the public key. Actual keys and secrets are not included in the example.

Procedure

Encryption: generate a key pair, encrypt with the recipient's public key using padding such as OAEP, then decrypt with the recipient's private key. Signing: hash the message, sign with the private key using a scheme such as PSS, and verify with the public key. Encoding/decoding is a separate, keyless representation transformation.

Scenario

Used for TLS/SSL handshake session-key exchange and certificate signature verification, software-distribution signature verification and transfer of small secrets. Bulk data is generally protected with hybrid encryption, using RSA to protect a symmetric key instead of directly encrypting the data.

Pitfalls and alternatives

Avoid unpadded RSA, new uses of PKCS#1 v1.5 and direct encryption of large data. Use OAEP/PSS and hybrid encryption. Consider keys of at least 2048 bits, preferably 3072/4096, and a post-quantum migration plan.

Diagram source ↗

References