liveBook · Manning

RSA

As explained in Software Security for Developers

RSA is a public-key cryptographic algorithm based on the computational difficulty of factoring large integers.

RSA is a public-key cryptographic algorithm based on the difficulty of factoring large integers. It uses a related public–private key pair: share the public key, but keep the private key secret. This solves the key-distribution problem because services no longer need to share the same secret key. section 6.2 section 6.3

Figure 6.3 A key pair, consisting of a private and a public key. The keys are numbers that are related by means of a mathematical equation. The private key works only with the public key in the same key pair, and the public key works only with the private key from the same key pair. The private key must be kept secret, but the public key can be shared with anyone, including friends, enemies, and hackers. Security in a public key cryptosystem depends on keeping private keys private.
figure

Use the key-pair diagram to distinguish the shareable public key from the secret private key and understand which operations each key performs. section 6.2

Use RSA according to the operation:

  • Encrypt with the recipient’s public key and decrypt with the matching private key. section 6.4
  • Sign with the private key and verify with the matching public key; signatures provide integrity, authenticity, and nonrepudiation. section 6.4 section 6.6
  • Prefer RSA-OAEP for encryption, reject RSAES-PKCS1-v1_5, and choose key sizes according to current security standards; 3,072 or 4,096 bits are recommended for long-term security. section 6.3.1

Warehouse-to-payments encryption

A warehouse service encrypts refunds.json with the payment service’s RSA public key; the payment service decrypts it with the private key. In Java, generate the pair with KeyPairGenerator, configure OAEP, and process data in chunks because RSA cannot encrypt arbitrarily large content. section 6.4

Figure 6.5 Hybrid encryption uses a high-performance symmetric algorithm such as AES to encrypt content. Then the AES CEK is encrypted with the recipient’s RSA public key, allowing the recipient to use their private key to first the CEK and then decrypt the content.
figure

Use the hybrid-encryption diagram to see why RSA normally wraps an AES content-encryption key instead of encrypting large content directly. section 6.3.2

Hybrid encryption combines fast AES for the content with RSA-OAEP for wrapping the randomly generated AES key. TLS, IPsec, JWE, and SSH use this pattern. Protect private keys carefully, replace a compromised pair, and use certificates to validate that a public key belongs to the claimed service. section 6.3.2 section 6.5

How Software Security for Developers covers it

How deep it goes
Explains key pairs, factoring, padding, hybrid workflows, and Java usage while deferring mathematical proofs and production certificates.
Examples
Uses ACME warehouse and payments services, refunds.json, Java key generation, chunked OAEP encryption, and SHA256withRSA signatures.
What it assumes
Assumes HMAC, JCA, AES, and GCM familiarity while introducing public-key concepts without equations.
What you can do after
Apply RSA via Java libraries to generate keys, encrypt and decrypt data, wrap AES keys, and create or verify signatures.
How it connects
Connects public-key cryptography with AES, hybrid encryption, digital signatures, HMAC, TLS, digital certificates, ECC, and quantum computing.

Also explained in

Compare how 4 books explain RSA →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Security for Developers. The section links point to the parts of the book it draws on.