Honesty Boundary
A private key gives away its public half as a fixed text, and that is nearly all these pages show of RSA in practice; the page lists what was left out, from key sizes in use to timing and padding attacks, with what the standard says.
The question
The seven lessons before this one ran real RSA on 512-bit test keys. What do those runs establish, and what do they not? A reader who has seen a signature verify and a ciphertext decrypt may take away more than the runs show. This page says where the line is.
It also does one last piece of work: a public key is a fixed function of the private key, so deriving it is a command with a fixed output. The key used for the demo, from the test chain of other lessons, is test material like all the others.
Work it by hand
The demo's key has eight fields in its dump, the names of the first lesson key anatomy. Two of them make up the public key, modulus and publicExponent, and the other six, privateExponent, prime1, prime2, exponent1, exponent2 and coefficient, are secret. So 6 of the 8 fields must never leave the holder of the key.
What the pages did not show:
- Key sizes in use. 512 bits is the smallest OpenSSL makes and is far too small to use. The pages say nothing about which size to choose.
- How keys are made, stored and protected. The test keys are plain files without a passphrase.
- Timing and side channels. The runs measure nothing about how long an operation takes or what it leaks.
- Attacks on padding. RFC 8017 section 7.2 describes a chosen-ciphertext attack on PKCS#1 v1.5 encryption and says using that scheme for arbitrary messages is not recommended. The attack is named here, not run.
- Which scheme to use. RFC 8017 (November 2016) section 8 says RSASSA-PSS is required in new applications and RSASSA-PKCS1-v1_5 is included for compatibility; the pages ran both to show how they differ.
- Who owns a key. A public key says nothing about whose it is; certificates carry that, see a-certificate-chain-trusts-a-root.
Run it
The program takes the private key as text. The loop on lines 5 to 17 goes through the dump as in the first lesson and keeps the fields of the first column. Lines 10 to 14 sort them: the two names of the public key are collected, every other field is counted as secret.
For this test key the answer is 6, and the extra value public_fields lists modulus and publicExponent. The key has 512 bits.

Public test material, generated for this lesson. Never use it for anything real.
let k = ssl.parse_key(key);
let lines = str_split(k.text(), "\n");
let secret = 0;
let shown = "";
for (i in range(1, lines.len())) {
let line = lines.at(i);
if (str_len(line) > 0) {
if (str_substr(line, 0, 1) != " ") {
let name = str_substr(line, 0, str_find(line, ":"));
let open = 0;
if (name == "modulus") { open = 1; }
if (name == "publicExponent") { open = 1; }
if (open == 1) { shown = shown + name + "\n"; }
if (open == 0) { secret = secret + 1; }
}
}
}
lmcode_return_put("bits", k.bits());
lmcode_return_put("public_fields", shown);
let answer = secret;
{
"answer": 6,
"bits": 512,
"public_fields": "modulus\npublicExponent\n"
}You can change the key. Another RSA private key gives its own count, 6 for every RSA key of these lessons. An elliptic-curve key has other field names, so all four of them count as secret. A public key, an empty text or any other text stops line 1 with "Ssl.parse_key: cannot read private key (encrypted keys need a passphrase): error:1E08010C:DECODER routines::unsupported".
Your turn
The command below reads the private key in in/key.txt. Edit it so that it prints the matching public key as a PEM block, and nothing else. Check runs your command on the key shown and on four others, each in the same file.

Public test material, generated for this lesson. Never use it for anything real.
# Reads the private key in in/key.txt.
# Check runs it with other keys in that file.
rsa -in in/key.txt -noout -text
{
"answer": "Private-Key: (512 bit, 2 primes)\nmodulus:\n c1:47:41:0d:9e:27:0a:2e:34:a1:e9:95:96:6d:60:65:\n 3c:0c:eb:00:67:6d:ae:50:a9:28:aa:c2:1d:fd:8f:e8:\n e0:66:ad:c3:cb:b1:13:35:7f:d1:49:b3:bf:0e:d3:9f:\n 1b:00:e6:3a:54:e7:3d:b6:22:6b:81:49:8f:1a:77:79\npublicExponent: 65537 (0x10001)\nprivateExponent:\n 67:1f:74:77:26:95:df:d9:ad:5d:62:3a:dc:ea:f8:ce:\n aa:ce:9d:a8:36:87:0f:c5:9b:ab:c6:08:12:66:52:9c:\n 58:c4:de:46:4f:dd:c6:ae:b7:ec:22:e4:65:0e:fa:70:\n 0f:cb:84:2a:5f:68:2b:af:63:e2:7a:7f:fa:bc:18:31\nprime1:\n f1:cd:65:2a:8b:1c:29:6a:d3:cf:ea:c3:88:ea:0c:ab:\n 0a:ec:50:0d:76:d8:e4:52:ba:5b:d8:48:b6:10:79:fd\nprime2:\n cc:a0:7a:e1:16:34:bc:f3:fe:de:1d:05:93:38:f7:22:\n 41:ff:d6:b2:9d:2f:b4:2e:7c:19:a8:79:0b:9c:fe:2d\nexponent1:\n 91:31:ed:b2:9b:2f:c0:eb:05:df:4e:b0:35:71:9d:43:\n c3:de:5c:bf:89:02:fa:2f:76:fa:19:a8:a7:b2:c3:1d\nexponent2:\n 35:97:62:17:49:45:8e:a7:28:7c:eb:84:e6:45:e9:13:\n a3:cd:69:61:66:21:74:43:28:65:5f:e6:33:d0:6e:11\ncoefficient:\n ab:12:ce:89:26:c9:fc:04:11:a0:32:24:b5:7f:a9:98:\n b8:ac:ff:98:14:f4:49:a5:6f:96:ed:4d:d3:2c:81:ef"
}Write one command that prints the public key that belongs to the RSA private key in in/key.txt, as a PEM block that starts with -----BEGIN PUBLIC KEY-----, and prints nothing else on standard output. Check runs your command with other keys in that file.
Read the result carefully
The lessons of this book used test keys. A real use needs decisions that no page here makes: a key size, a place and a way to keep the private key, a scheme and its parameters, a way for others to find out whose public key it is, and a plan for when a key is lost. The pages state what the runs show and cite what the standard says; they give no advice for any real system.
The public key printed by the command is derived from the private key's modulus and public exponent, and it is the same text every time. It is public: sharing it reveals nothing the private key's holder needs to hide, which is the point of the scheme. The private key must stay private, and the test keys here must never be used for anything real.
Recap
- A public key is the modulus and the public exponent; the other six fields of the dump are secret.
- A public key can be derived from the private key by a key tool, and the result is a fixed text.
- The pages showed 512-bit test keys only, and say nothing about sizes in use, key storage, timing or attacks beyond what is cited.
- RFC 8017 names the choice of scheme; the lessons ran PKCS#1 v1.5, OAEP and PSS to show their behaviour, not to recommend one.