Replace "YOURNAME" with your own name.
openssl genrsa -out YOURNAMEpkey.pem
cat YOURNAMEpkey.pem
openssl asn1parse -in YOURNAMEpkey.pem
This reveals the RSA parameters,
as labelled below in red.
Capture a full-screen image.
YOU MUST SUBMIT A FULL-SCREEN IMAGE FOR FULL CREDIT!
Save the image with the filename "YOUR NAME Proj 16a", replacing "YOUR NAME" with your real name.
Anyone who receives the message can verify it using Bob's public key, as shown below.
If the result x' matches the original message x, the signature is valid.
Replace "YOURNAME" with your own name.
python
msg = "Project 16 from YOURNAME"
xe = msg.encode("hex")
print xe
print len(xe)
Your encoded message appears,
as highlighted in the image below,
followed by its length.
Since we are using 512-bit RSA, the message must be 64 bytes or less. If it's too long, use a shorter version of your name.
In my example below, the length is 48 bytes, so this message is OK.
Notice the use of the "int" function to convert the hexadecimal strings to integers.
n = int("F78949DDF8808579FE5506052EB86995DF24FC03B40C7ECC1788E1FA4D174322F17BA15A5AC6005CA6150EE194D8E496EA4F0ACE06960ECD535297193EBD8BE3",16)
e = int("010001", 16)
d = int("3A8E387210C9DE494877B66FDD687459A6AAAA0EFA35867D23081764CD7DB63C83C80590713EEE185527E20CE473631E3FFA08CACCC462516A5BFB51F24541A1", 16)
x = int(xe, 16)
s = pow(x, d, n)
se = hex(s)
print se
Your signature appears as a long hexadecimal number,
as shown below.
Notice the stages of converting a numerical x' value back to readable text.
xpn = pow(s, e, n)
print "Numerical x':", xpn
xph = hex(xpn)
print "Hexadecimal string x':", xph
xpt = xph[2:-1]
print "Trimmed hex string x':", xpt
xpa = xpt.decode("hex")
print "ASCII x':", xpa
print "n in hex", hex(n)
The readable message is recovered,
as shown below.
Capture a full-screen image.
YOU MUST SUBMIT A FULL-SCREEN IMAGE FOR FULL CREDIT!
Save the image with the filename "YOUR NAME Proj 16b", replacing "YOUR NAME" with your real name.
We'll use a signature of 0xf -- an unusual value starting with a lot of zeroes.
In the Terminal running Python, execute these commands to calculate x.
s = 0xf
xn = pow(s, e, n)
xh = hex(xn)
print "Hexadecimal string x:", xh
xt = xh[2:-1]
print "Trimmed hex string x:", xt
xa = xt.decode("hex")
print "ASCII x':", xa
The ASCII message is garbled nonsense,
as shown below.
This attack won't fool a human who tries to read the message, but it might fool an automated system that merely validates the signature.
xpn = pow(0xf, e, n)
xph = hex(xpn)
print "Hexadecimal string x':", xph
print "Hexadecimal string x :", xh
print "n in hex", hex(n)
The two hexadecimal "x" values match,
as shown below.
Capture a full-screen image.
YOU MUST SUBMIT A FULL-SCREEN IMAGE FOR FULL CREDIT!
Save the image with the filename "YOUR NAME Proj 16c", replacing "YOUR NAME" with your real name.
-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAK2u1N6ZR6RiW1VXo+QynnveXCmCG7az
AhlXqCfBhcpNNDVBMjvm8cCjFrUdQUobbulGk/L6fImba1cHNF4zEKcCAwEAAQ==
-----END PUBLIC KEY-----
Convert your name to a number, as shown
below.
Create a message that is correctly signed with your name as its signature.
Use the form below to put your name on the WINNERS PAGE.
Create a correctly signed message starting with your initials (3 characters) in the plaintext.
Use the form below to put your name on the WINNERS PAGE.