blob: 83c08494f1dbafa6deb50f58fd76ea499b98e8ae [file] [log] [blame]
Meki Cherkaoui8f173612012-06-06 01:05:40 -07001<?xml version = "1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3"DTD/xhtml1-strict.dtd">
Jeff Burke92dd8e42012-12-08 11:40:31 -08004<!--
5 See COPYING for copyright and distribution information.
6-->
Meki Cherkaoui8f173612012-06-06 01:05:40 -07007<html xmlns = "http://www.w3.org/1999/xhtml">
8
9<head>
10 <title>NDN Decode Interest + Face Instance</title>
11
Alexander Afanasyev2a2c9d22013-03-13 16:21:32 -070012 <script type="text/javascript" src="../build/ndn-js.js"></script>
Meki Cherkaoui8f173612012-06-06 01:05:40 -070013
14 <script type="text/javascript">
15
16
17
18 function decode(){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070019
20 var input = document.getElementById('result').innerHTML;
21
22
23 var interest = decodeHexInterest(input);
24
25 if(LOG>3)console.log('INTEREST DECODED');
26 if(LOG>3)console.log(interest);
27
28 ///////////////////////////////////////
29
30 var output ="";
31
32
Jeff Thompsone85ff1d2012-09-29 21:21:57 -070033 if(interest.name!=null && interest.name.components!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070034 output+= "NAME: ";
35
Jeff Thompsone85ff1d2012-09-29 21:21:57 -070036 for(var i=0;i<interest.name.components.length;i++){
37 output+= "/"+ DataUtils.toString(interest.name.components[i]);
Meki Cherkaoui8f173612012-06-06 01:05:40 -070038 }
39 output+= "<br />";
40 output+= "<br />";
41 }
42
Jeff Thompson86aea882012-09-29 17:32:48 -070043 if(interest.faceInstance!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070044 output+= "FaceInstance: ";
45
Jeff Thompson86aea882012-09-29 17:32:48 -070046 output+= interest.faceInstance;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070047
48 output+= "<br />";
49 output+= "<br />";
50 }
51
Jeff Thompson86aea882012-09-29 17:32:48 -070052 if(interest.exclude!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070053 output+= "Exclude: ";
54
Jeff Thompson86aea882012-09-29 17:32:48 -070055 output+= interest.exclude;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070056
57 output+= "<br />";
58 output+= "<br />";
59 }
60
Jeff Thompson86aea882012-09-29 17:32:48 -070061 if(interest.childSelector!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070062 output+= "ChildSelector: ";
63
Jeff Thompson86aea882012-09-29 17:32:48 -070064 output+= interest.childSelector;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070065
66 output+= "<br />";
67 output+= "<br />";
68 }
69
Jeff Thompson86aea882012-09-29 17:32:48 -070070 if(interest.answerOriginKind!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070071 output+= "AnswerOriginKind: ";
72
Jeff Thompson86aea882012-09-29 17:32:48 -070073 output+= interest.answerOriginKind;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070074
75 output+= "<br />";
76 output+= "<br />";
77 }
78
Jeff Thompson86aea882012-09-29 17:32:48 -070079 if(interest.interestLifetime!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070080 output+= "InterestLifetime: ";
81
Jeff Thompson86aea882012-09-29 17:32:48 -070082 output+= interest.interestLifetime;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070083
84 output+= "<br />";
85 output+= "<br />";
86 }
87
Jeff Thompson86aea882012-09-29 17:32:48 -070088 if(interest.nonce!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070089 output+= "Nonce: ";
90
Jeff Thompson86aea882012-09-29 17:32:48 -070091 output+= interest.nonce;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070092
93 output+= "<br />";
94 output+= "<br />";
95 }
96
97
Jeff Thompson86aea882012-09-29 17:32:48 -070098 if(interest.scope!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070099 output+= "SCOPE: ";
100
Jeff Thompson86aea882012-09-29 17:32:48 -0700101 output+= interest.scope;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700102
103 output+= "<br />";
104 output+= "<br />";
105 }
106
Jeff Thompson86aea882012-09-29 17:32:48 -0700107 if(interest.publisherPublicKeyDigest!=null ){
108 output+= "PUBLISHER PUBLIC KEY DIGEST: ";
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700109
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700110 output+= interest.publisherPublicKeyDigest.publisherPublicKeyDigest;
Jeff Thompson86aea882012-09-29 17:32:48 -0700111
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700112 output+= "<br />";
113 output+= "<br />";
114 }
115
Jeff Thompson86aea882012-09-29 17:32:48 -0700116 if(interest.maxSuffixComponents!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700117 output+= "MaxSuffixComponents : ";
118
Jeff Thompson86aea882012-09-29 17:32:48 -0700119 output+= interest.maxSuffixComponents;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700120
121 output+= "<br />";
122 output+= "<br />";
123 }
124
Jeff Thompson86aea882012-09-29 17:32:48 -0700125 if(interest.minSuffixComponents!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700126 output+= "MinSuffixComponents : ";
127
Jeff Thompson86aea882012-09-29 17:32:48 -0700128 output+= interest.minSuffixComponents;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700129
130 output+= "<br />";
131 output+= "<br />";
132 }
133
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700134 if(interest.name.components[3] !=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700135
136
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700137 var input = DataUtils.toHex(interest.name.components[3]) ;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700138
139 var contentObject = decodeHexContentObject(input);
140
Jeff Thompson86aea882012-09-29 17:32:48 -0700141 if(contentObject.content!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700142 output+= "Content of content Object: ";
143
Jeff Thompson86aea882012-09-29 17:32:48 -0700144 output+= DataUtils.toHex(contentObject.content);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700145
146 output+= "<br />";
147 output+= "<br />";
148 }
149
150
Jeff Thompson86aea882012-09-29 17:32:48 -0700151 var content = DataUtils.toHex(contentObject.content);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700152
153 var co = contentObject;
154
155
156 ////////////////////////////////////////
157
158
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700159 if(co.name!=null && co.name.components!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700160 output+= "NAME: ";
161
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700162 for(var i=0;i<co.name.components.length;i++){
163 output+= "/"+ DataUtils.toString(co.name.components[i]);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700164 }
165 output+= "<br />";
166 output+= "<br />";
167 }
168
Jeff Thompson86aea882012-09-29 17:32:48 -0700169 if(co.content !=null){
170 output += "CONTENT(ASCII): "+ DataUtils.toString(co.content);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700171
172 output+= "<br />";
173 output+= "<br />";
174 }
Jeff Thompson86aea882012-09-29 17:32:48 -0700175 if(co.content !=null){
176 output += "CONTENT(hex): "+ DataUtils.toHex(co.content);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700177
178 output+= "<br />";
179 output+= "<br />";
180 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700181 if(co.signature !=null && co.signature.signature!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700182
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700183 output += "SIGNATURE(hex): "+ DataUtils.toHex(co.signature.signature);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700184
185 output+= "<br />";
186 output+= "<br />";
187 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700188 if(co.signedInfo !=null && co.signedInfo.publisher!=null && co.signedInfo.publisher.publisherPublicKeyDigest!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700189
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700190 output += "Publisher Public Key Digest(hex): "+ DataUtils.toHex(co.signedInfo.publisher.publisherPublicKeyDigest);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700191
192 output+= "<br />";
193 output+= "<br />";
194 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700195 if(co.signedInfo !=null && co.signedInfo.timestamp!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700196 var d = new Date();
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700197 d.setTime( co.signedInfo.timestamp.msec );
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700198
199 var bytes = [217, 185, 12, 225, 217, 185, 12, 225];
200
201 output += "TimeStamp: "+d;
202 output+= "<br />";
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700203 output += "TimeStamp(number): "+ co.signedInfo.timestamp.msec;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700204
205
206 output+= "<br />";
207 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700208 if(co.signedInfo !=null && co.signedInfo.type!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700209
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700210 output += "Type: "+co.signedInfo.type;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700211 output+= "<br />";
212 output+= "<br />";
213 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700214 if(co.signedInfo !=null && co.signedInfo.locator!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700215
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700216 output += "Locator: "+co.signedInfo.locator.type;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700217 output+= "<br />";
218 output+= "<br />";
219 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700220 if(co.signedInfo !=null && co.signedInfo.freshnessSeconds!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700221
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700222 output += "FreshnessSeconds: "+co.signedInfo.freshnessSeconds;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700223 output+= "<br />";
224 output+= "<br />";
225 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700226 if(co.signedInfo !=null && co.signedInfo.finalBlockID!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700227
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700228 output += "FinalBlockID: "+co.signedInfo.finalBlockID;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700229 output+= "<br />";
230 output+= "<br />";
231 }
232
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700233 if(co.signedInfo!=null && co.signedInfo.locator!=null && co.signedInfo.locator.publicKey!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700234
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700235 var publickey = rstr2b64(DataUtils.toString(co.signedInfo.locator.publicKey));
236 var publickeyHex = DataUtils.toHex(co.signedInfo.locator.publicKey).toLowerCase();
237 var publickeyString = DataUtils.toString(co.signedInfo.locator.publicKey);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700238
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700239 var signature = DataUtils.toHex(co.signature.signature).toLowerCase();
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700240
241
242 var input = DataUtils.toString(co.rawSignatureData);
243
244
245 output += "DER Certificate: "+publickey ;
246
247 output+= "<br />";
248 output+= "<br />";
249
250
251
252 if(LOG>2) console.log(" ContentName + SignedInfo + Content = "+input);
253 if(LOG>2) console.log(" PublicKey = "+publickey );
254 if(LOG>2) console.log(" PublicKeyHex = "+publickeyHex );
255 if(LOG>2) console.log(" PublicKeyString = "+publickeyString );
256
257 if(LOG>2) console.log(" Signature "+signature );
258
259 if(LOG>2) console.log(" Signature NOW IS" );
260
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700261 if(LOG>2) console.log(co.signature.signature);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700262
263
264 /*var x509 = new X509();
265
266 x509.readCertPEM(publickey);
267
268
269 //x509.readCertPEMWithoutRSAInit(publickey);
270
271 var result = x509.subjectPublicKeyRSA.verifyString(input, signature);*/
272 //console.log('result is '+result);
273
274
275 var kp = publickeyHex.slice(56,314);
276
277 output += "PUBLISHER KEY(hex): "+kp ;
278
279 output+= "<br />";
280 output+= "<br />";
281
282 console.log('PUBLIC KEY IN HEX is ');
283 console.log(kp);
284
285 var exp = publickeyHex.slice(318,324);
286
287 console.log('kp size is '+kp.length );
288 output += "exponent: "+exp ;
289
290 output+= "<br />";
291 output+= "<br />";
292
293 console.log('EXPONENT is ');
294 console.log(exp);
295
296
297
298 /*var c1 = hex_sha256(input);
299 var c2 = signature;
300
301 if(LOG>4)console.log('input is ');
302 if(LOG>4)console.log(input);
303 if(LOG>4)console.log('C1 is ');
304 if(LOG>4)console.log(c1);
305 if(LOG>4)console.log('C2 is ');
306 if(LOG>4)console.log(c2);
307 var result = c1 == c2;*/
308
309 var rsakey = new RSAKey();
310
311 rsakey.setPublic(kp,exp);
312
313 var result = rsakey.verifyString(input, signature);
314
315
316
317 console.log('PUBLIC KEY n after is ');
318 console.log(rsakey.n);
319
320 console.log('EXPONENT e after is ');
321 console.log(rsakey.e);
322
323
324 if(result)
325 output += 'SIGNATURE VALID';
326 else
327 output += 'SIGNATURE INVALID';
328
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700329 //output += "VALID: "+ toHex(co.signedInfo.locator.publicKey);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700330
331 output+= "<br />";
332 output+= "<br />";
333
334
335 //if(LOG>4) console.log('str'[1]);
336 }
337
338 ////////////////////////////////////////
339
340
341 var forwardingEntry = decodeHexForwardingEntry(content);
342
343 if(LOG>3)console.log('FORWARDING ENTRY IS PRESENT');
344 if(LOG>3)console.log(forwardingEntry);
345
346 ///////////////////////////////////////
347
348 //var output ="";
349
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700350 if(forwardingEntry.action!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700351 output+= "Action: ";
352
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700353 output+= DataUtils.toHex(forwardingEntry.action);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700354
355 output+= "<br />";
356 output+= "<br />";
357 }
358
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700359 if(forwardingEntry.prefixName!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700360 output+= "PrefixName: ";
361
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700362 output+= forwardingEntry.prefixName.getName();
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700363 output+= "<br />";
364 }
365
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700366 if(forwardingEntry.ccndID!=null){
367 output+= "ccndID: ";
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700368
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700369 output+= forwardingEntry.ccndID;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700370 output+= "<br />";
371 }
372
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700373 if(forwardingEntry.flags!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700374 output+= "Flags: ";
375
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700376 output+= forwardingEntry.flags;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700377 output+= "<br />";
378 }
379
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700380 if(forwardingEntry.lifetime!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700381 output+= "Lifetime: ";
382
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700383 output+= forwardingEntry.lifetime;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700384 output+= "<br />";
385 }
386
387
388 }
389
390
391
392 document.getElementById('result').innerHTML = output;
393
394 }
395
396 </script>
397
398</head>
399<body >
400 <form>
401
Jeff Thompson86aea882012-09-29 17:32:48 -0700402 Please Press Decode:<br />
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700403
404
405 </form>
406 <button onclick="decode()">Decode</button>
407
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700408 <p id="result">01d2f2faa563636e7800fa0285e0a01e093968f9740ce7f4361babf5bb05a4e55aaca5e58f73eddeb8e013aa8f00facd70726566697872656700fa29ad048202aa03b208854ddbf69779cdf4ef74be99474478c8bc3ca0873e0ffa1fa60120aa276db122b83404e595a8a3caeaf09630276658ba4e7beaadb4b91a8cc58e19ac4a42289507ed8d609aa9bef61a5a507f349c83d2944b8c16fecfd90d4a40ddb8687592c0a57517564235b2e359db54f51a37e1ac39e518a2196e3ffda7eb2fb301f3c404dd0000f20001a203e20285ef7c4f5d4743a8b8586ea2e741b7fc39d1dc0dbe1b1930e787cfd1d833ea7a610002bab504fce9e253d70001e2018219fd3082019b30820104020900b7d85c906bad52ee300d06092a864886f70d010105050030123110300e060355040313076178656c636476301e170d3132303432383233343433375a170d3132303532383233343433375a30123110300e060355040313076178656c63647630819f300d06092a864886f70d010101050003818d0030818902818100e17d30a7d828ab1b840b17542dcaf6207afd221e086b2a60d16cb7f54448ba9f3f08bcd099db21dd162a779e61aa89eee554d3a47de230bc7ac590d524067c3898bba6f5dc4360b845eda48cbd9cf126a723445f0e1952d7325a75faf556144f9a98af7186b0278685b8e2c08bea87171b4dee585c1828295b5395eb4a17779f0203010001300d06092a864886f70d010105050003818100cb3ab0357d7cd2ae97ed501e51a3a0e2817d418e47fb17906477af61495a7e8d8789141065b082d001f4b15193d0b43fb661cde20a6498372c6abbd3dcb9f0d12659ef07b3c6dbdf8bdf2f65477eed7adcd457d793b1c27badda7c5ade80ce95b7d8827fe78c8a35f3fb4ba648a081be2cfe84231abab3c2b531746df2e0492b000000019a02d5058a04cabe73656c6672656700f2faa56d656b69000004fa8e330003d2d63231343734383336343700000000000002d28e310000</p>
409
410</body>
411</html>