-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
169 lines (166 loc) · 7.78 KB
/
test.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>JavaScript SigningTest</title>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'></script>
<script type='text/javascript' src='lib/BigInt.js'></script>
<script type='text/javascript' src='lib/base64.js'></script>
<script type='text/javascript' src='lib/gpg_parser.js'></script>
<script type='text/javascript' src='lib/GPGKey.js'></script>
<script type='text/javascript' src='lib/SignedMessage.js'></script>
<script type='text/javascript' src='lib/pidcrypt_util.js'></script>
<script type='text/javascript' src='lib/pidcrypt.js'></script>
<script type='text/javascript' src='lib/sha1.js'></script>
<script type='text/javascript' src='lib/sha256.js'></script>
<script type='text/javascript' src='lib/sha512.js'></script>
<script type='text/javascript' src='lib/md5.js'></script>
<script type='text/javascript' src='lib/ripemd160.js'></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div>
<table>
<tr>
<td>Message:</td>
<td>
<textarea rows='10' cols='64' id='message'>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
this is a test-string
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iQIcBAEBAgAGBQJOntSMAAoJEEH+GXMF1XjpPIIQAMPD+RP9O72+PW86+B8OWtMi
soTGfGgjOj/VznItRRBZiHeg7JvFVEbDiTaITOQd/l2UFbeP+A8/z8Cgmn9Azm28
BmrgDKCbzyf9WzpAIp5aSiMl8e2Se/qph44EDTIEU0ShLiIdl9ZsbpqYnsGHDDcK
SUDmT6uQa8qnBIT/de5nt3JWQvCR+s8N1RZTVBJ/X5GCkI7L64VTNj6J6m2kPux2
1uMoq8azUr2hpbfpJ29UTEDmyvk1YE7xBE4A/lxriJ6BQkc9P2YXk3nz2nu3n0dj
2EUgj888aKsIJhGFH+slOTXxasSoDZjfmlJeByE0dRwPnz3fQU+mXp0Rv/isWSsF
Bh8vFdYesrkF2CjquQVnYSCVTw9OKsWRxQhO+C9Pr7b9Rk+yxptNVNHV9p1Qm4dw
ognnAyacelnDoDOh/J7ypMgwk3+rsdT1d7wWeKSpc5ftTK/Xu5eK70r3k6BlWPPk
wPPxTReAGYTRvRpL1xFGMXQLc4UemFgoadmxV1GG325Fur1NA28xfocn+IbS4XwP
CnrLUwtUWlB0NaunbMYkija31phdQzQvurCk1oC+YMQjd8mjvk1bGSqt5bhXYj9L
F5tf+vJva3UbcTbs6Cq9yH8HTNIPv8WjFC4cWD6DxLTkAMPNcVS9FCveJ/ikV40d
KvMXFDHRYYYbVN7258PV
=1z0X
-----END PGP SIGNATURE-----
</textarea>
</td>
</tr>
<tr>
<td>PGP-Key:</td>
<td>
<textarea rows='10' cols='64' id='key'>
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.10 (GNU/Linux)
mQINBExH/kABEADFn6yMh/piqP0V80039A3j4TO2IeSETptbpsN5YgsKyLjxrTYo
nNwq8xGp5y6P+CZMqY9dU5LGvV27V/AlRLruFyh4dNdhyQr8RxXKgnDgRaTQBHRl
J62Aq0UruEu8N9IarmqmtXLH433/pS7pKHZa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Yho1
TqLVNZn49WQsRMrd7XsXmRKGkLC3kXmSkuy1gZ72b34M5egXoA8MFCEAXf/MyGsI
GqeP4g2Pxy7LPxagXvXUxzAp6MxqH4lenNyKFfeBbCytmtnZB+efpJ6Riu+cHQ2g
o2IXKIL8NTj5hwaMohDhi+Rf/GciU8t68qJYet8l7+eUHL9XQwoXpyoXlKGMrD39
aoblbxWwOEgm3CcRPDtzfUxucpDIk3iaq8aWpuOdu+LzY79IYzqCeW558juvpm2x
I9PRh71eev+i3szP38sABRYjdLUS5pCdw4urnSyQm56ZjK509KaX6hqQdVhmL/SW
88OpJDLBjq/MRJStQSKDGrfWMa8BC+ORAhUbRBIuqP1FRNDBSs+6V1gIPmhrsCdd
=jySd
-----END PGP PUBLIC KEY BLOCK-----
</textarea>
</td>
</tr>
<tr>
<td></td>
<td><button onclick='checkSignature()'>Check Signature!</button></td>
</tr>
</table>
</div>
<div id='result'></div>
<script type="text/javascript">
// <![CDATA[
function checkSignature() {
var message = $("#message").val();
var armorKey = $("#key").val();
$("#result").text("");
$("#result").append("<p id='helfer2'></p>");
try {
var sigMes = SignedMessage.parse(message);
} catch (err) {
$("#helfer2").text("Failure when parsing the Signature: " + err).append("<br />");
return null;
}
$("#helfer2").text("The content of the Message is: " + sigMes.content).append("<br />");
$("#result").append("<p id='helfer1'></p>");
try{
var key = GPGKey.parse(armorKey);
} catch(err) {
$("#helfer1").text("Failure when parsing the Key: " + err).append("<br />");
return null;
}
$("#helfer1").text("Id: " + key.id).append("<br />");
if(sigMes.issuer_id != key.short_id) {
$("#result").append("The Message is signed with the key id " + sigMes.issuer_id + " but you entered a key with id " + key.short_id + "<br />");
} else {
$("#result").append("The fingerprint of the issuer is: " + key.fingerprint + "<br/>");
try{
if (sigMes.verify(key)) {
$("#result").append("The signature seems to be correct!<br />");
} else {
$("#result").append("The message was tampered!<br />");
}
} catch(err) {
$("#result").append("Could not verify the Signature: " + err);
}
}
}
// ]]>
</script>
</body>
</html>