-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
160 lines (152 loc) · 7.89 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>playascon</title>
<link rel="icon" type="image/x-icon" href="./ascon_sponge.png">
<style>
.rotate-down {
transform: rotate(180deg);
-webkit-transition: all .4s ease-in-out;
transition: all .4s ease-in-out;
}
.rotate-up {
transform: rotate(0deg);
-webkit-transition: all .4s ease-in-out;
transition: all .4s ease-in-out;
}
.ascon_sponge {
padding-top: 0.7em;
width: 2.4em;
height: 2.4em;
}
</style>
</head>
<body>
<!-- Description -->
<center>
<div style="display: flex; justify-content: center;"><img class="ascon_sponge" src="./ascon_sponge.png" alt="ascon_sponge" title="ascon_sponge"><h2>playascon</h2></div>
<br>
<p><< Making <a href="https://ascon.iaik.tugraz.at/" target="_blank">Ascon</a> cipher easier to play with >></p>
<p>===========================================</p>
</center>
<!-- Ascon variants -->
<label for="variants">variant</label>
<select name="variants" id="variants" onchange="change_variant(document.getElementsByName('variants')[0].value)">
<option value="Ascon-128">Ascon-128</option>
<option value="Ascon-128a">Ascon-128a</option>
<option value="Ascon-XOF">Ascon-XOF</option>
<option value="Ascon-XOFa">Ascon-XOFa</option>
</select>
<p id="note">note: key & nonce must be entered in hexadecimal.</p>
<!-- XoF -->
<div style="display: none;" id="xof_section">
<center>
<h4 style="text-decoration-line: underline;">Extendible Output Function (XOF)</h4>
<p>***</p>
</center>
<label for="message">message: </label>
<select name="data_format" id="data_format" onchange="data_format()">
<option value="raw">raw</option>
<option value="hex">hex</option>
</select>
<textarea id="message" type="text" placeholder="text to be authenticated" rows="4" cols="50"></textarea>
<br><br>
<label for="hashlength">output length (bytes):</label>
<input id="hashlength" type="number" size="33" placeholder="32 bytes by default" step="8">
<br><br>
<center><button type="submit" onclick="document.getElementById('XOF_result').innerText = xof(document.getElementById('message').value, document.getElementById('hashlength').value, document.getElementsByName('variants')[0].value)">Hash</button></center>
<br>
<p id="XOF_result"></p>
</div>
<!-- Encrypt -->
<div style="display: block;" id="encrypt_section">
<center>
<h4 style="text-decoration-line: underline;">Encrypt</h4>
<p>***</p>
</center>
<label for="key">key:</label>
<input id="key" type="text" size="33" placeholder="128-bits"> <button onclick="document.getElementById('key').value = get_random_bytes(16)">generate random key</button>
<br><br>
<label for="nonce">nonce:</label>
<input id="nonce" type="text" size="33" placeholder="128-bits"> <button onclick="document.getElementById('nonce').value = get_random_bytes(16)">generate random nonce</button>
<br><br>
<label for="plaintext">plaintext:</label>
<select name="data_format" id="data_format" onchange="data_format()">
<option value="raw">raw</option>
<option value="hex">hex</option>
</select>
<textarea id="plaintext" type="text" placeholder="text to be encrypted" rows="4" cols="50"></textarea><label for="lang"> Non-English</label><input id="lang" type="checkbox" onclick="non_eng()">
<br><br>
<br><br>
<label for="associateddata">associated data:</label>
<textarea id="associateddata" type="text" placeholder="text to be authenticated" rows="4" cols="50"></textarea>
<br><br>
<center><button type="submit" onclick="document.getElementById('encryption_result').innerText = encrypt(document.getElementById('key').value, document.getElementById('nonce').value, document.getElementById('associateddata').value, document.getElementById('plaintext').value, document.getElementsByName('variants')[0].value)">Encrypt</button></center>
<br>
<p id="encryption_result"></p>
</div>
<!-- Decrypt -->
<div style="display: block;" id="decrypt_section">
<center>
<p>===========================================</p>
<h4 style="text-decoration-line: underline;">Decrypt</h4>
<p>***</p>
</center>
<label for="key_d">key:</label>
<input id="key_d" type="text" size="33" placeholder="128-bits">
<br><br>
<label for="nonce_d">nonce:</label>
<input id="nonce_d" type="text" size="33" placeholder="128-bits">
<br><br>
<label for="ciphertext">ciphertext:</label>
<textarea id="ciphertext" type="text" placeholder="text to be decrypted" rows="4" cols="50"></textarea>
<br><br>
<label for="associateddata_d">associated data:</label>
<textarea id="associateddata_d" type="text" placeholder="text to be authenticated" rows="4" cols="50"></textarea>
<br><br>
<center><button type="submit" onclick="document.getElementById('decryption_result').innerText = decrypt(document.getElementById('key_d').value, document.getElementById('nonce_d').value, document.getElementById('associateddata_d').value, document.getElementById('ciphertext').value, document.getElementsByName('variants')[0].value)">Decrypt</button></center>
<br>
<p id="decryption_result"></p>
</div>
<script>
var xof_section = document.getElementById("xof_section");
var encrypt_section = document.getElementById("encrypt_section");
var decrypt_section = document.getElementById("decrypt_section");
var note = document.getElementById("note");
var variant = document.getElementsByName('variants')[0].value;
function change_variant(variant){
variant = variant;
if(variant == "Ascon-XOF" || variant == "Ascon-XOFa"){
xof_section.style.display = "block";
encrypt_section.style.display = "none";
decrypt_section.style.display = "none";
note.style.display = "none";
} else {
xof_section.style.display = "none";
encrypt_section.style.display = "block";
decrypt_section.style.display = "block";
note.style.display = "block";
}
}
</script>
<script type="text/javascript" src="ascon.js"></script>
<!-- Footer -->
<footer>
<center>
<p><b>________________________</b></p>
<!-- ctf -->
<div style="display: flex; justify-content: center; cursor: pointer;" onclick="ctf_toggle()"><p>playascon ctf</p><p id="ctf_arrow"> ▼</p></div>
<div id="ctf"></div>
<!-- Hall of Fame -->
<div style="display: flex; justify-content: center; color: #0000ffe7; cursor: pointer;" onclick="hof_toggle()"><p>Hall of Fame</p><p id="hof_arrow">▼</p></div>
<div id="hof"></div>
<!-- Signature -->
<p><a style="text-decoration:none" href="./KATs/KAT.html">Known Answer Tests (KATs)</a></p>
<p><a style="text-decoration:none" href="https://github.com/playascon/playascon.github.io" target="_blank">source code</a></p>
<center<p>by <a style="text-decoration:none" href="https://medium.com/@motarekk" target="_blank">motarek</a></p>
</center>
</footer>
</body>
</html>