https://colab.research.google.com/If you see a blue "Sign In" button at the top right, click it and log into a Google account.
From the menu, click File, "New notebook".
In Colab, execute this command:
!openssl genrsa 512
You see a PRIVATE KEY,
as shown below.
To parse it, you need to save it in a file and use the "rsa" command.
Execute these commands to generate a "key.pem" file, view it, and parse it.
!openssl genrsa -out key.pem 512
!cat key.pem
!openssl rsa -in key.pem -text
You see the PEM file,
followed by the parsed contents.
The important fields are as labelled below in red.
Execute this command 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:
!openssl rsa -in key.pem -out public.pem -pubout
!cat public.pem
!openssl rsa -pubin -text < public.pem
This displays the "Modulus" n and the
"Exponent" e,
as shown below.
Execute these commands to make a 2048-bit private key and display it.
!openssl genrsa -out key2.pem 2048
!cat key2.pem
It's much longer,
as shown below.
Execute these commands to see the public key.
!openssl rsa -in key2.pem -out public2.pem -pubout
!openssl rsa -pubin -text < public2.pem
The public key is also much longer,
as shown below.
Execute these commands to generate a 2048-bit encrypted private key file. Enter a password, such as P@ssw0rd, when prompted to.
!openssl genrsa -out key3.pem -aes256 2048
!cat key3.pem
The first line now says the key is encrypted,
as shown below.
Whenever you use this private key file, you'll need to supply the password.
Execute this command to display the public key.
!openssl rsa -in key3.pem -pubout
Enter your password to see the public
key,
as shown below.
C 403.1: Find p (5 pts)
Find p from the key below.The flag is p in hex, like this:
-----BEGIN RSA PRIVATE KEY----- MD0CAQACCQDTPWtAKLuWbwIDAQABAgh2uVRnKpyb0QIFAP2MzVUCBQDVR/SzAgRu u6WZAgQ2tLA1AgR2EBWK -----END RSA PRIVATE KEY-----
7610158A
C 403.2: Find Public Key (5 pts)
Find the Public Key from the key below.The flag is the public key in Base64, like this:
-----BEGIN RSA PRIVATE KEY----- MD0CAQACCQDTPWtAKLuWbwIDAQABAgh2uVRnKpyb0QIFAP2MzVUCBQDVR/SzAgRu u6WZAgQ2tLA1AgR2EBWK -----END RSA PRIVATE KEY-----
i810CAwEAAQ==
C 403.3: Find q (10 pts extra)
Find q from the key below. Portions of the key have been redacted, as shown in bold below.The flag is q in hex, like this:
-----BEGIN RSA PRIVATE KEY----- MIIBPAIBAAJBAOz8ZwiRyoTBYCoExLqzlnr1GJ3D1qk+yQXwSEET2mRfbU+B/cNP cI6eQUnA4rSOHmwhsSwEXhPnzMvVjqIonPsCAwEAAQJBAIfNH3HOsaGfem65qs5e xxxxxxxxxObZPrKzfYQlT0miNyOrzA65U3yDa6qAZgwXPJuWU6b86PTPFFUQCei9 TFkCIQD2l+VEohU9goQplYkRnpfujZ6flUm96B6biqnPk9tUTQIhAPYGr50vSZqI xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx jDyz+KS5z68xHakCIEfyCpb/xhlvsIQZPLMj1q0eaydxrS4OxU0WuiKOCSYPAiEA nahcVY0yHAgXLvm1vSZgzYrcs1ESCKPQ+KWy8+meq80= -----END RSA PRIVATE KEY-----
7610158A
C 403.4: Find p (20 pts extra)
Find p from the key below. Portions of the key have been redacted, as shown in bold below.The flag is p in hex, like this:
-----BEGIN RSA PRIVATE KEY----- MIIBPAIBAAJBANY4uzFtiUFp5zL5puSWi0UVRj6U1v3uJi23d7p40VgEh1SmR0lx JjHNgHjqzU+gUeMoipx33kYvFRteCEH36JsCAwEAAQJBAMKsuYi4l0Qn3qBXedA/ xxxxxxxxxxxxxxxxD50ZEH2frkuuDlE/IVjIvbd78Rdgdwpt+hcrRh0NPLohTins dgECIQDr2CcsldtKiBOQxxxcVtM4IZtpqlXV2U8zFgf6/LnPmwIhAOiHgwUpMSty xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx OUbS4KlR8bN0WwIhAJVYU8JAzp/E2j6pAGJhGbpKUnb9gZpwyXvdxFa8OWQBAiEA 41EhQq90+1NqwpMIBoqYvQvqYPTW/y9KEJDbkyXK2r8= -----END RSA PRIVATE KEY-----
EBD8272C95DB4A88139000001C56D338219B69AA55D5D94F331607FAFCB9CF9B