Appendix B. The Mathematics of RSA

This appendix covers the mathematics used in the Rivest, Shamir, Adelman (RSA) public-key encryption algorithm and provides algorithms for setting up an RSA system, performing encryption and decryption, and computing/verifying signatures.

The Math Behind RSA

In an RSA cryptosystem, two prime numbers, p and q, are generated whose product is n. The encryption key (that is, the public key), e, is a number that is relatively prime to (p–1)(q–1). The decryption key (private key), d, is calculated so that ed mod ((p–1)(q–1)) is 1. The values of p and q are critical to the security of RSA and should be securely discarded after an RSA system is set up.

At this point, you might have a few questions relative to prime numbers, ...

Get Java Security Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.