- Any Linux or Mac computer with openssl. Kali, Ubuntu, and Mac OS work fine.

You see a PRIVATE KEY, as shown below.

openssl genrsa 512

To parse it, you need to save it in a file and use the "asn1parse" command.

Execute these commands to generate a "key.pem" file, view it, and parse it.

This reveals the RSA parameters, as labelled below in red.

openssl genrsa -out key.pem 512 cat key.pem openssl asn1parse -in key.pem

**n**A long integer called the RSA modulus**e**A positive integer, often small, called the RSA public exponent

Execute these commands to generate the public key from your "key.pem" file.

openssl rsa -in key.pem -pubout

Execute these commands to save the public key in a "public.pem" file, print it out, and parse it:

This displays the "Modulus" (n) and the "Exponent" (e), as shown below.

openssl rsa -in key.pem -out public.pem -pubout cat public.pem openssl rsa -pubin -text < public.pem

Execute these commands to make a 2048-bit private key and display it.

It's much longer, as shown below.

openssl genrsa -out key2.pem 2048 cat key2.pem

Execute these commands to see the public key.

It's much longer, as shown below.

openssl rsa -in key2.pem -out public2.pem -pubout openssl rsa -pubin -text < public2.pem

Execute this command to
make a 2048-bit encrypted private key
file. Enter a password, such as
**P@ssw0rd**, when prompted to.

It's much longer, as shown below.

openssl genrsa -out key3.pem -aes256 2048

Execute this command to see the keyfile:

It's encrypted with AES-CBC, as shown below.

cat key3.pem

Whenever you use this private key file, you'll need to supply the password.

Execute this command to display the public key.

Enter your password to see the public key, as shown below.

openssl rsa -in key3.pem -pubout

The flag is p in hex, like this:

-----BEGIN RSA PRIVATE KEY----- MD0CAQACCQDTPWtAKLuWbwIDAQABAgh2uVRnKpyb0QIFAP2MzVUCBQDVR/SzAgRu u6WZAgQ2tLA1AgR2EBWK -----END RSA PRIVATE KEY-----

**7610158A**

The flag is the public key in Base64, like this:

-----BEGIN RSA PRIVATE KEY----- MD0CAQACCQDTPWtAKLuWbwIDAQABAgh2uVRnKpyb0QIFAP2MzVUCBQDVR/SzAgRu u6WZAgQ2tLA1AgR2EBWK -----END RSA PRIVATE KEY-----

**i810CAwEAAQ==**

-----BEGIN RSA PRIVATE KEY-----
MIIBPAIBAAJBAOz8ZwiRyoTBYCoExLqzlnr1GJ3D1qk+yQXwSEET2mRfbU+B/cNP
cI6eQUnA4rSOHmwhsSwEXhPnzMvVjqIonPsCAwEAAQJBAIfNH3HOsaGfem65qs5e
**xxxxxxxxx**ObZPrKzfYQlT0miNyOrzA65U3yDa6qAZgwXPJuWU6b86PTPFFUQCei9
TFkCIQD2l+VEohU9goQplYkRnpfujZ6flUm96B6biqnPk9tUTQIhAPYGr50vSZqI
**xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx**
jDyz+KS5z68xHakCIEfyCpb/xhlvsIQZPLMj1q0eaydxrS4OxU0WuiKOCSYPAiEA
nahcVY0yHAgXLvm1vSZgzYrcs1ESCKPQ+KWy8+meq80=
-----END RSA PRIVATE KEY-----

The flag is
q in hex, like this:
**7610158A**

-----BEGIN RSA PRIVATE KEY-----
MIIBPAIBAAJBANY4uzFtiUFp5zL5puSWi0UVRj6U1v3uJi23d7p40VgEh1SmR0lx
JjHNgHjqzU+gUeMoipx33kYvFRteCEH36JsCAwEAAQJBAMKsuYi4l0Qn3qBXedA/
**xxxxxxxxxxxxxxxx**D50ZEH2frkuuDlE/IVjIvbd78Rdgdwpt+hcrRh0NPLohTins
dgECIQDr2CcsldtKiBOQ**xxx**cVtM4IZtpqlXV2U8zFgf6/LnPmwIhAOiHgwUpMSty
**xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx**
OUbS4KlR8bN0WwIhAJVYU8JAzp/E2j6pAGJhGbpKUnb9gZpwyXvdxFa8OWQBAiEA
41EhQq90+1NqwpMIBoqYvQvqYPTW/y9KEJDbkyXK2r8=
-----END RSA PRIVATE KEY-----

The flag is
p in hex, like this:
**
EBD8272C95DB4A88139000001C56D338219B69AA55D5D94F331607FAFCB9CF9B
**

Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography Specifications Version 2.1

ASN.1 key structures in DER and PEM

Cryptography Tutorials - Herong's Tutorial Examples

Use OpenSSL To Generate Key Pairs

Generate RSA private key from n, e, d, p, q values in bash with OpenSSL

RSA: Get exponent and modulus given a public key

Posted 3-23-16 by Sam Bowne

Updated to refer to "P" in chal d 11-20-17 3:23 pm

Added to Crypto Hero 4-15-18 9:33 pm

Ported to new scoring engine 7-8-19

Extra credit points specified 9-10-20

512 length added 10-20-20