blob: 704d1335aa81a4f2ea2108ea8f054dd7a29cce7e [file] [log] [blame]
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07001<?xml version = "1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3"DTD/xhtml1-strict.dtd">
4<html xmlns = "http://www.w3.org/1999/xhtml">
5
6<head>
7 <title>NDN Request Example</title>
8 <script type="text/javascript" src="java_socket_bridge.js"></script>
9
10 <script type="text/javascript" src="CCNProtocolDTags.js"></script>
11
12 <script type="text/javascript" src="CCNTime.js"></script>
13
14 <script type="text/javascript" src="ContentName.js"></script>
15
16 <script type="text/javascript" src="ContentObject.js"></script>
17
18 <script type="text/javascript" src="DateFormat.js"></script>
19
20 <script type="text/javascript" src="Exclude.js"></script>
21
22 <script type="text/javascript" src="ExcludeAny.js"></script>
23
24 <script type="text/javascript" src="ExcludeComponent.js"></script>
25
26 <script type="text/javascript" src="Interest.js"></script>
27
28 <script type="text/javascript" src="KeyLocator.js"></script>
29
30 <script type="text/javascript" src="KeyName.js"></script>
31
32 <script type="text/javascript" src="PublisherID.js"></script>
33
34 <script type="text/javascript" src="Signature.js"></script>
35
36 <script type="text/javascript" src="SignedInfo.js"></script>
37
38 <script type="text/javascript" src="PublisherPublicKeyDigest.js"></script>
39
40 <script type="text/javascript" src="FaceInstance.js"></script>
41
42 <script type="text/javascript" src="ForwardingEntry.js"></script>
43
44
45 <script type="text/javascript" src="encoding/BinaryXMLEncoder.js"></script>
46
47 <script type="text/javascript" src="encoding/BinaryXMLCodec.js"></script>
48
49 <script type="text/javascript" src="encoding/BinaryXMLDecoder.js"></script>
50
51 <script type="text/javascript" src="encoding/DataUtils.js"></script>
52
53 <script language="JavaScript" type="text/javascript" src="security/KeyManager.js"></script>
54
55 <script language="JavaScript" type="text/javascript" src="securityLib/jsbn.js"></script>
56 <script language="JavaScript" type="text/javascript" src="securityLib/jsbn2.js"></script>
57 <script language="JavaScript" type="text/javascript" src="securityLib/rsa.js"></script>
58 <script language="JavaScript" type="text/javascript" src="securityLib/rsa2.js"></script>
59
60 <script language="JavaScript" type="text/javascript" src="securityLib/sha1.js"></script>
61 <script language="JavaScript" type="text/javascript" src="securityLib/sha256.js"></script>
62 <script language="JavaScript" type="text/javascript" src="securityLib/sha512.js"></script>
63 <script language="JavaScript" type="text/javascript" src="securityLib/md5.js"></script>
64 <script language="JavaScript" type="text/javascript" src="securityLib/ripemd160.js"></script>
65 <script language="JavaScript" type="text/javascript" src="securityLib/base64.js"></script>
66
67 <script language="JavaScript" type="text/javascript" src="securityLib/rsapem-1.1.js"></script>
68 <script language="JavaScript" type="text/javascript" src="securityLib/rsasign-1.2.js"></script>
69 <script language="JavaScript" type="text/javascript" src="securityLib/asn1hex-1.1.js"></script>
70 <script language="JavaScript" type="text/javascript" src="securityLib/x509-1.1.js"></script>
71
72 <script type="text/javascript">
73 function run(){
74 //console.log(unescape('%04%82%02%AA%03%B2%08%85H%8EY%0C%94p%F1-%C5%E2%23lW%19%8B%0D%25%81%8D%DEBeNX%BA%0D%D0%10W%7D%BA%9F%C6%8C%2AU%BC%B8%BA%5E%F3%D1l%CDmJ%EE%C4%9D%21%0F%0Djhm%1Ah%86P%D91x%26%AC%B8%8Co%C1%CF%29.l6Mc%B4%DC%C8%D4%86%97%8F%D2%1A%7C%A2%ED%93%89%F3%E9%9D%3C%E0%D4%90%28%D4%11%A2%5D%08%EB%A4%AF%96j%15%A5s%C8%D2Jr%96q%0F%87%7F%D5%D7%B3%D3T%96%F3%16L%00%00%F2%00%01%A2%03%E2%02%85%20Ht%04Z%9F%AC%98%EB%B7%DF%AD%C4%BB%D1%AB%15%A6%E4%06SI%C6%C8%3A%84%60%84N%AB1%85%00%02%BA%B5%04%FA%C3%F9%D7%97%00%01%E2%01%DA%0A%950%81%9F0%0D%06%09%2A%86H%86%F7%0D%01%01%01%05%00%03%81%8D%000%81%89%02%81%81%00%BD%95eU%9C%17%95%C0I%A5%EFM%C9%D1%BC%8B%98%1Bf%09~%A2S%F5%D0%F5%0F%1A%1D%F9%08%ACNi%A7%97%DA%DD%2C%05%90%94Jn%84%9E%1F%BBsq%C5%3D%FD%DB%E7%80%26V%E1%D5%F4I%B8S%0D%9C%7D%A8%D6%AB%EB%D9%0E%06%12M%92%7F%2FlW%21%F1%D0%E4%9E%7Fj%11g%CA%F9%60%D9o%F5%AF%AA-%25g3wr%A9D%C8%E6%CE%B8Y%B2Z%23%1D%9E%CA%875t%FF%98%22%5C%85%3F8%EF%02%03%01%00%01%00%00%00%01%9A%06%8D%05%82%04%CA%BEnewface%00%03%E2%02%85%E0%A0%1E%099h%F9t%0C%E7%F46%1B%AB%F5%BB%05%A4%E5Z%AC%A5%E5%8Fs%ED%DE%B8%E0%13%AA%8F%00%04%D2%8E0%00%04%DA%9617%00%04%E2%CE127.0.0.1%00%04%EA%A69695%00%03%D2%D62147483647%00%00%00%00'));
75
76 //var a = escape('%04%82%02%AA%03%B2%08%85L%90%D5X%2C%B06wHi%C5%E2%1C%03%D2M%5DB%BF%A5%8C%C8%E8g%99%EB%A7%84%25l%8EB%92%3E%AA%D8%F6%85t%FF%BB%CE%3D%B1%F4%F8%27%A7%1D.%B0%EEU%A6%06%AB%CD%1F3%C6W%93%A9%10X%28-7%7CW%D4%E4%8A3%CF%2B%E4%95%D6%B2%1D%3B%7C%E8%7C%88%7D%7B%F5%80%BC%F7%28%3A%FC%F5w%5B%8C%24%0E%0A%24%DBk%9B%8D%B5%28d%D0A%1E%BEq%0F%0Cc%DB%15%B6%26%1B%E7%E3%E3XL%00%00%F2%00%01%A2%03%E2%02%85%20Ht%04Z%9F%AC%98%EB%B7%DF%AD%C4%BB%D1%AB%15%A6%E4%06SI%C6%C8%3A%84%60%84N%AB1%85%00%02%BA%B5%04%FA%C4%C7%D3I%00%01%E2%01%DA%0A%950%81%9F0%0D%06%09%2A%86H%86%F7%0D%01%01%01%05%00%03%81%8D%000%81%89%02%81%81%00%BD%95eU%9C%17%95%C0I%A5%EFM%C9%D1%BC%8B%98%1Bf%09~%A2S%F5%D0%F5%0F%1A%1D%F9%08%ACNi%A7%97%DA%DD%2C%05%90%94Jn%84%9E%1F%BBsq%C5%3D%FD%DB%E7%80%26V%E1%D5%F4I%B8S%0D%9C%7D%A8%D6%AB%EB%D9%0E%06%12M%92%7F%2FlW%21%F1%D0%E4%9E%7Fj%11g%CA%F9%60%D9o%F5%AF%AA-%25g3wr%A9D%C8%E6%CE%B8Y%B2Z%23%1D%9E%CA%875t%FF%98%22%5C%85%3F8%EF%02%03%01%00%01%00%00%00%01%9A%06%8D%05%82%04%CA%BEnewface%00%03%E2%02%85%E0%A0%1E%099h%F9t%0C%E7%F46%1B%AB%F5%BB%05%A4%E5Z%AC%A5%E5%8Fs%ED%DE%B8%E0%13%AA%8F%00%04%D2%8E0%00%04%DA%9617%00%04%E2%CE127.0.0.1%00%04%EA%A69695%00%03%D2%D62147483647%00%00%00%00');
77
78 //var n = a.replace("%","");
79
80 //console.log(n);
81
82 var ContentName = document.getElementById('contentname').value;
83
84 ///////////////////////////////////////
85 createRoute('localhost', 9695);
86
87
88 /// /ndn/ucla.edu/apps/hydra/mainvideo
89 //createRoute('131.179.141.15', 9695);
90 //createRoute('borges.metwi.ucla.edu', 9695);
91
92 //content object
93 var co = queryPrefix( ContentName );
94
95 ///////////////////////////////////////
96
97 var output ="";
98
99 if(co==-1)
100 output+= "NO CONTENT FOUND"
101 else if (co==-2)
102 output+= "CONTENT NAME IS EMPTY"
103 else{
104 if(co.Name!=null && co.Name.Components!=null){
105 output+= "NAME: ";
106
107 for(var i=0;i<co.Name.Components.length;i++){
108 output+= "/"+ toString(co.Name.Components[i]);
109 }
110 output+= "<br />";
111 output+= "<br />";
112 }
113
114 if(co.Content !=null){
115 output += "CONTENT(ASCII): "+ toString(co.Content);
116
117 output+= "<br />";
118 output+= "<br />";
119 }
120 if(co.Content !=null){
121 output += "CONTENT(hex): "+ toHex(co.Content);
122
123 output+= "<br />";
124 output+= "<br />";
125 }
126
127 if(co.Signature !=null && co.Signature.Signature!=null){
128
129 output += "SIGNATURE(hex): "+ toHex(co.Signature.Signature);
130
131 output+= "<br />";
132 output+= "<br />";
133 }
134 if(co.SignedInfo !=null && co.SignedInfo.Publisher!=null && co.SignedInfo.Publisher.PublisherPublicKeyDigest!=null){
135
136 output += "Publisher Public Key Digest(hex): "+ toHex(co.SignedInfo.Publisher.PublisherPublicKeyDigest);
137
138 output+= "<br />";
139 output+= "<br />";
140 }
141 if(co.SignedInfo !=null && co.SignedInfo.Timestamp!=null){
142
143 output += "TimeStamp(hex): "+ co.SignedInfo.Timestamp.date;
144
145 output+= "<br />";
146 output+= "<br />";
147 }
148 if(co.SignedInfo!=null && co.SignedInfo.Locator!=null && co.SignedInfo.Locator.PublicKey!=null){
149
150 var publickey = rstr2b64(toString(co.SignedInfo.Locator.PublicKey));
151 var publickeyHex = toHex(co.SignedInfo.Locator.PublicKey).toLowerCase();
152 var publickeyString = toString(co.SignedInfo.Locator.PublicKey);
153
154 var signature = toHex(co.Signature.Signature).toLowerCase();
155
156
157 var input = toString(co.rawSignatureData);
158
159
160 output += "DER Certificate: "+publickey ;
161
162 output+= "<br />";
163 output+= "<br />";
164
165
166
167 if(LOG>2) console.log(" ContentName + SignedInfo + Content = "+input);
168 if(LOG>2) console.log(" PublicKey = "+publickey );
169 if(LOG>2) console.log(" PublicKeyHex = "+publickeyHex );
170 if(LOG>2) console.log(" PublicKeyString = "+publickeyString );
171
172 if(LOG>2) console.log(" Signature "+signature );
173 if(LOG>2) console.log(" Signature NOW IS" );
174 if(LOG>2) console.log(co.Signature.Signature);
175
176
177 /*var x509 = new X509();
178
179 x509.readCertPEM(publickey);
180
181
182 //x509.readCertPEMWithoutRSAInit(publickey);
183
184 var result = x509.subjectPublicKeyRSA.verifyString(input, signature);*/
185 //console.log('result is '+result);
186
187
188 var kp = publickeyHex.slice(56,314);
189
190 output += "PUBLISHER KEY(hex): "+kp ;
191
192 output+= "<br />";
193 output+= "<br />";
194
195 console.log('kp is '+kp);
196
197 var exp = publickeyHex.slice(318,324);
198
199 console.log('kp size is '+kp.length );
200 output += "exponent: "+exp ;
201
202 output+= "<br />";
203 output+= "<br />";
204
205 console.log('exp is '+exp);
206
207 var rsakey = new RSAKey();
208 rsakey.setPublic(kp,exp);
209 var result = rsakey.verifyString(input, signature);
210
211 if(result)
212 output += 'SIGNATURE VALID';
213 else
214 output += 'SIGNATURE INVALID';
215
216
217
218
219 //output += "VALID: "+ toHex(co.SignedInfo.Locator.PublicKey);
220
221 output+= "<br />";
222 output+= "<br />";
223
224
225 if(LOG>4) console.log('str'[1]);
226 }
227 }
228
229 document.getElementById('result').innerHTML = output;
230 }
231
232 </script>
233
234</head>
235<body >
236 <form>
237 Please Enter a Content Name:<br /><input id="contentname" type="text" name="CONTENTNAME" value="/PARC/abc" /> <br />
238 </form>
239 <button onclick="run()">Request Data!</button>
240 <div >
241 <applet id="JavaSocketBridge" archive="JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0">
242 </applet>
243 </div>
244
245 <p id="result"></p>
246
247</body>
248</html>