-
Notifications
You must be signed in to change notification settings - Fork 1
/
exercise_three.html
215 lines (208 loc) · 6.94 KB
/
exercise_three.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html>
<head>
<title>Crypto Exercises</title>
<link rel="stylesheet" href="./cryptoexercises-stylesheet.css" />
<script src="./sjcl/sjcl.js"></script>
<script src="./functions.js"></script>
</head>
<body onload="loadProblem()">
<!----------------------------------------------------------------------------->
<header>
<table class="headerTable" cellspacing="0">
<tr>
<td class="left">
<img class="bannerImage" src="./LLCipher_logo.png" alt="Llcipher logo" />
</td>
<td class="middle">
<p>Cryptography Challenges</p>
</td>
<td class="right">
<img class="lincolnLogo" src="./lincoln_logo.png" alt="Lincoln logo" />
</td>
</tr>
</table>
</header>
<!----------------------------------------------------------------------------->
<nav>
<ul>
<li><a href="./index.html">Home</a></li>
</ul>
<br />
<ul>
<li class="title">Background</li>
<li><a href="./el_gamal_encryption.html">El Gamal Encryption</a>
<li><a href="./rsa_encryption.html">RSA Encryption</a>
</ul>
<br />
<ul>
<li class="title">Challenges</li>
<li><a href="./classical_crypto.html">Classical Crypto</a></li>
<li><a href="./exercise_one.html">RSA Challenge One</a></li>
<li><a href="./exercise_two.html">RSA Challenge Two</a></li>
<li><a href="./exercise_three.html">RSA Challenge Three</a></li>
<li><a href="./exercise_three_a.html">RSA Challenge Three (a)</a></li>
<li><a href="./exercise_four.html">RSA Challenge Four</a></li>
<li><a href="./exercise_five.html">El Gamal Challenge</a></li>
</ul>
<br />
<ul>
<li class="title">Other Stuff</li>
<li><a href="./references.html">References</a></li>
<li><a href="./credits.html">Credits</a></li>
</ul>
</nav>
<!----------------------------------------------------------------------------->
<article>
<table class="exerciseLayoutTable" cellspacing="0">
<tr>
<td class="exerciseDetails">
<h1>RSA Challenge Three: RSA Broadcast Attack</h1>
<div class="exerciseDescription">
<p><b>The Problem:</b> Given RSA ciphertexts with different moduli but the
same low encryption exponent, recover the message.</p>
</div>
<div class="problemStatement">
<p>
Since you thwarted Malland's plots with Horridland, Malland enlisted the help of two more allies - Awfulland and Badland.
Horridland, Awfulland and and Badland made the mistake of all having the same low encryption exponent, e = 3.
Malland sent Horridland, Awfulland and Badland the same message about a plan of attack.
You get your hands on all three copies of the message:
</p>
<ul>
<li>Awfulland's message, encrypted as c<sub>A</sub> =
m<sup>3</sup> mod n<sub>A</sub> (using Awfulland's modulus
n<sub>A</sub>),</li>
<li>Badland's message, encrypted as c<sub>B</sub> = m<sup>3</sup>
mod n<sub>B</sub> (using Badland's modulus n<sub>B</sub>),
and</li>
<li>Horridland's message, encrypted as c<sub>H</sub> =
m<sup>3</sup> mod n<sub>H</sub> (using Horridland's modulus
n<sub>H</sub>).</li>
</ul>
<p>Use the fact that all three emails are encrypted using the
same low encryption exponent to figure out what the evil plot is.</p>
<p>For this exercise, use the following values:</p>
<table class="exerciseValuesTable" cellspacing="0">
<tr class="headerRow">
<td class="name">Name</td>
<td class="value">Value</td>
</tr>
<tr class="oddRow">
<td class="name">Number of ciphertexts:</td>
<td class="value"><div id="ciphertext_number">3</div></td>
</tr>
<tr class="evenRow">
<td class="name">Common public exponent:</td>
<td class="value"><div id="exponent">3</div></td>
</tr>
<tr class="oddRow">
<td class="name">Ciphertext #1</td>
<td class="value"><div id="ciphertext_1"></div></td>
</tr>
<tr class="evenRow">
<td class="name">Modulus #1</td>
<td class="value"><div id="modulus_1"></div></td>
</tr>
<tr class="oddRow">
<td class="name">Ciphertext #2</td>
<td class="value"><div id="ciphertext_2"></div></td>
</tr>
<tr class="evenRow">
<td class="name">Modulus #2</td>
<td class="value"><div id="modulus_2"></div></td>
</tr>
<tr class="oddRow">
<td class="name">Ciphertext #3</td>
<td class="value"><div id="ciphertext_3"></div></td>
</tr>
<tr class="evenRow">
<td class="name">Modulus #3</td>
<td class="value"><div id="modulus_3"></div></td>
</tr>
</table>
<form class="new_exercise">
<table class="answerFormTable" cellspacing="0">
<tr>
<td>
<!--
# The size of this text area is probably much smaller, but may
# also vary from exercise to exercise. The right answer is
# probably to see if this value can be moved into CSS, and
# then change the class name based on the exercise.
-->
<label class="answer" for="exercise_answer">Your Answer:</label>
<textarea class="answer" name="exercise[answer]" id="exercise_answer" cols="100" rows="20">
</textarea>
</td>
</tr>
<tr>
<td>
<!--
# Save the answer hash
-->
<input value="" type="hidden" id="ans_hash" />
<input type="submit" name="commit" value="Check Your Answer" onclick="checkAnswer(); return false;" />
<div id="anscheck_result"></div>
</td>
</tr>
</table>
</form>
</div>
<!-- Create and check problems -->
<script>
function loadProblem() {
let msg = getShortMessage();
let msgval = textToNumber(msg);
for (i = 1; i < 4; i++) {
let rsa = genRSAWithPubExp(rsa_bits, 3);
let modulus = rsa[0];
let exponent = rsa[1];
let ctext = modExp(msgval, exponent, modulus);
document.getElementById('modulus_' + i).innerHTML = modulus;
document.getElementById('exponent').innerHTML = exponent;
document.getElementById('ciphertext_' + i).innerHTML = ctext;
}
let answerhash = sjcl.hash.sha256.hash(msg);
document.getElementById('ans_hash').value = answerhash;
return false;
}
function checkAnswer() {
let ans = document.getElementById('exercise_answer').value;
let anshash = sjcl.hash.sha256.hash(ans);
let realanshash = document.getElementById('ans_hash').value;
if (anshash == realanshash) {
document.getElementById('anscheck_result').innerHTML = "Correct!";
}
else {
document.getElementById('anscheck_result').innerHTML = "Incorrect";
}
return false;
}
</script>
</td>
<!-- start tool panel -->
<td class="cryptoToolkit">
<iframe
src="./toolpanel.html"
frameborder="0"
scrolling="yes"
seamless="seamless"
style="display:block;
width:100%;
height:85vh;"
>
</iframe>
</td>
<!-- end tool panel -->
</tr>
</table>
</article>
<!----------------------------------------------------------------------------->
<footer>
<small>
© 2016, by Uri Blumenthal, Jeff Diewald, and Sophia Yakoubov, and 2024, by David Wilson and Nick Cunningham.
</small>
</footer>
</body>
</html>