blob: 5549b17e52ba656c336a20549c0f839dd84fe1d8 [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">
4<html xmlns = "http://www.w3.org/1999/xhtml">
5
6<head>
7 <title>NDN Decode Interest + Face Instance</title>
8
Jeff Thompson38422f42012-11-15 00:20:39 -08009 <script type="text/javascript" src="../Helper.js"></script>
Meki Cherkaoui8f173612012-06-06 01:05:40 -070010
11 <script type="text/javascript">
12
13
14
15 function decode(){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070016
17 var input = document.getElementById('result').innerHTML;
18
19
20 var interest = decodeHexInterest(input);
21
22 if(LOG>3)console.log('INTEREST DECODED');
23 if(LOG>3)console.log(interest);
24
25 ///////////////////////////////////////
26
27 var output ="";
28
29
Jeff Thompsone85ff1d2012-09-29 21:21:57 -070030 if(interest.name!=null && interest.name.components!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070031 output+= "NAME: ";
32
Jeff Thompsone85ff1d2012-09-29 21:21:57 -070033 for(var i=0;i<interest.name.components.length;i++){
34 output+= "/"+ DataUtils.toString(interest.name.components[i]);
Meki Cherkaoui8f173612012-06-06 01:05:40 -070035 }
36 output+= "<br />";
37 output+= "<br />";
38 }
39
Jeff Thompson86aea882012-09-29 17:32:48 -070040 if(interest.faceInstance!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070041 output+= "FaceInstance: ";
42
Jeff Thompson86aea882012-09-29 17:32:48 -070043 output+= interest.faceInstance;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070044
45 output+= "<br />";
46 output+= "<br />";
47 }
48
Jeff Thompson86aea882012-09-29 17:32:48 -070049 if(interest.exclude!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070050 output+= "Exclude: ";
51
Jeff Thompson86aea882012-09-29 17:32:48 -070052 output+= interest.exclude;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070053
54 output+= "<br />";
55 output+= "<br />";
56 }
57
Jeff Thompson86aea882012-09-29 17:32:48 -070058 if(interest.childSelector!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070059 output+= "ChildSelector: ";
60
Jeff Thompson86aea882012-09-29 17:32:48 -070061 output+= interest.childSelector;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070062
63 output+= "<br />";
64 output+= "<br />";
65 }
66
Jeff Thompson86aea882012-09-29 17:32:48 -070067 if(interest.answerOriginKind!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070068 output+= "AnswerOriginKind: ";
69
Jeff Thompson86aea882012-09-29 17:32:48 -070070 output+= interest.answerOriginKind;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070071
72 output+= "<br />";
73 output+= "<br />";
74 }
75
Jeff Thompson86aea882012-09-29 17:32:48 -070076 if(interest.interestLifetime!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070077 output+= "InterestLifetime: ";
78
Jeff Thompson86aea882012-09-29 17:32:48 -070079 output+= interest.interestLifetime;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070080
81 output+= "<br />";
82 output+= "<br />";
83 }
84
Jeff Thompson86aea882012-09-29 17:32:48 -070085 if(interest.nonce!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070086 output+= "Nonce: ";
87
Jeff Thompson86aea882012-09-29 17:32:48 -070088 output+= interest.nonce;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070089
90 output+= "<br />";
91 output+= "<br />";
92 }
93
94
Jeff Thompson86aea882012-09-29 17:32:48 -070095 if(interest.scope!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070096 output+= "SCOPE: ";
97
Jeff Thompson86aea882012-09-29 17:32:48 -070098 output+= interest.scope;
Meki Cherkaoui8f173612012-06-06 01:05:40 -070099
100 output+= "<br />";
101 output+= "<br />";
102 }
103
Jeff Thompson86aea882012-09-29 17:32:48 -0700104 if(interest.publisherPublicKeyDigest!=null ){
105 output+= "PUBLISHER PUBLIC KEY DIGEST: ";
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700106
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700107 output+= interest.publisherPublicKeyDigest.publisherPublicKeyDigest;
Jeff Thompson86aea882012-09-29 17:32:48 -0700108
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700109 output+= "<br />";
110 output+= "<br />";
111 }
112
Jeff Thompson86aea882012-09-29 17:32:48 -0700113 if(interest.maxSuffixComponents!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700114 output+= "MaxSuffixComponents : ";
115
Jeff Thompson86aea882012-09-29 17:32:48 -0700116 output+= interest.maxSuffixComponents;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700117
118 output+= "<br />";
119 output+= "<br />";
120 }
121
Jeff Thompson86aea882012-09-29 17:32:48 -0700122 if(interest.minSuffixComponents!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700123 output+= "MinSuffixComponents : ";
124
Jeff Thompson86aea882012-09-29 17:32:48 -0700125 output+= interest.minSuffixComponents;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700126
127 output+= "<br />";
128 output+= "<br />";
129 }
130
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700131 if(interest.name.components[3] !=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700132
133
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700134 var input = DataUtils.toHex(interest.name.components[3]) ;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700135
136 var contentObject = decodeHexContentObject(input);
137
Jeff Thompson86aea882012-09-29 17:32:48 -0700138 if(contentObject.content!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700139 output+= "Content of content Object: ";
140
Jeff Thompson86aea882012-09-29 17:32:48 -0700141 output+= DataUtils.toHex(contentObject.content);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700142
143 output+= "<br />";
144 output+= "<br />";
145 }
146
147
Jeff Thompson86aea882012-09-29 17:32:48 -0700148 var content = DataUtils.toHex(contentObject.content);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700149
150 var co = contentObject;
151
152
153 ////////////////////////////////////////
154
155
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700156 if(co.name!=null && co.name.components!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700157 output+= "NAME: ";
158
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700159 for(var i=0;i<co.name.components.length;i++){
160 output+= "/"+ DataUtils.toString(co.name.components[i]);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700161 }
162 output+= "<br />";
163 output+= "<br />";
164 }
165
Jeff Thompson86aea882012-09-29 17:32:48 -0700166 if(co.content !=null){
167 output += "CONTENT(ASCII): "+ DataUtils.toString(co.content);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700168
169 output+= "<br />";
170 output+= "<br />";
171 }
Jeff Thompson86aea882012-09-29 17:32:48 -0700172 if(co.content !=null){
173 output += "CONTENT(hex): "+ DataUtils.toHex(co.content);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700174
175 output+= "<br />";
176 output+= "<br />";
177 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700178 if(co.signature !=null && co.signature.signature!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700179
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700180 output += "SIGNATURE(hex): "+ DataUtils.toHex(co.signature.signature);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700181
182 output+= "<br />";
183 output+= "<br />";
184 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700185 if(co.signedInfo !=null && co.signedInfo.publisher!=null && co.signedInfo.publisher.publisherPublicKeyDigest!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700186
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700187 output += "Publisher Public Key Digest(hex): "+ DataUtils.toHex(co.signedInfo.publisher.publisherPublicKeyDigest);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700188
189 output+= "<br />";
190 output+= "<br />";
191 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700192 if(co.signedInfo !=null && co.signedInfo.timestamp!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700193 var d = new Date();
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700194 d.setTime( co.signedInfo.timestamp.msec );
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700195
196 var bytes = [217, 185, 12, 225, 217, 185, 12, 225];
197
198 output += "TimeStamp: "+d;
199 output+= "<br />";
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700200 output += "TimeStamp(number): "+ co.signedInfo.timestamp.msec;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700201
202
203 output+= "<br />";
204 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700205 if(co.signedInfo !=null && co.signedInfo.type!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700206
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700207 output += "Type: "+co.signedInfo.type;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700208 output+= "<br />";
209 output+= "<br />";
210 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700211 if(co.signedInfo !=null && co.signedInfo.locator!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700212
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700213 output += "Locator: "+co.signedInfo.locator.type;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700214 output+= "<br />";
215 output+= "<br />";
216 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700217 if(co.signedInfo !=null && co.signedInfo.freshnessSeconds!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700218
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700219 output += "FreshnessSeconds: "+co.signedInfo.freshnessSeconds;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700220 output+= "<br />";
221 output+= "<br />";
222 }
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700223 if(co.signedInfo !=null && co.signedInfo.finalBlockID!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700224
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700225 output += "FinalBlockID: "+co.signedInfo.finalBlockID;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700226 output+= "<br />";
227 output+= "<br />";
228 }
229
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700230 if(co.signedInfo!=null && co.signedInfo.locator!=null && co.signedInfo.locator.publicKey!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700231
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700232 var publickey = rstr2b64(DataUtils.toString(co.signedInfo.locator.publicKey));
233 var publickeyHex = DataUtils.toHex(co.signedInfo.locator.publicKey).toLowerCase();
234 var publickeyString = DataUtils.toString(co.signedInfo.locator.publicKey);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700235
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700236 var signature = DataUtils.toHex(co.signature.signature).toLowerCase();
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700237
238
239 var input = DataUtils.toString(co.rawSignatureData);
240
241
242 output += "DER Certificate: "+publickey ;
243
244 output+= "<br />";
245 output+= "<br />";
246
247
248
249 if(LOG>2) console.log(" ContentName + SignedInfo + Content = "+input);
250 if(LOG>2) console.log(" PublicKey = "+publickey );
251 if(LOG>2) console.log(" PublicKeyHex = "+publickeyHex );
252 if(LOG>2) console.log(" PublicKeyString = "+publickeyString );
253
254 if(LOG>2) console.log(" Signature "+signature );
255
256 if(LOG>2) console.log(" Signature NOW IS" );
257
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700258 if(LOG>2) console.log(co.signature.signature);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700259
260
261 /*var x509 = new X509();
262
263 x509.readCertPEM(publickey);
264
265
266 //x509.readCertPEMWithoutRSAInit(publickey);
267
268 var result = x509.subjectPublicKeyRSA.verifyString(input, signature);*/
269 //console.log('result is '+result);
270
271
272 var kp = publickeyHex.slice(56,314);
273
274 output += "PUBLISHER KEY(hex): "+kp ;
275
276 output+= "<br />";
277 output+= "<br />";
278
279 console.log('PUBLIC KEY IN HEX is ');
280 console.log(kp);
281
282 var exp = publickeyHex.slice(318,324);
283
284 console.log('kp size is '+kp.length );
285 output += "exponent: "+exp ;
286
287 output+= "<br />";
288 output+= "<br />";
289
290 console.log('EXPONENT is ');
291 console.log(exp);
292
293
294
295 /*var c1 = hex_sha256(input);
296 var c2 = signature;
297
298 if(LOG>4)console.log('input is ');
299 if(LOG>4)console.log(input);
300 if(LOG>4)console.log('C1 is ');
301 if(LOG>4)console.log(c1);
302 if(LOG>4)console.log('C2 is ');
303 if(LOG>4)console.log(c2);
304 var result = c1 == c2;*/
305
306 var rsakey = new RSAKey();
307
308 rsakey.setPublic(kp,exp);
309
310 var result = rsakey.verifyString(input, signature);
311
312
313
314 console.log('PUBLIC KEY n after is ');
315 console.log(rsakey.n);
316
317 console.log('EXPONENT e after is ');
318 console.log(rsakey.e);
319
320
321 if(result)
322 output += 'SIGNATURE VALID';
323 else
324 output += 'SIGNATURE INVALID';
325
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700326 //output += "VALID: "+ toHex(co.signedInfo.locator.publicKey);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700327
328 output+= "<br />";
329 output+= "<br />";
330
331
332 //if(LOG>4) console.log('str'[1]);
333 }
334
335 ////////////////////////////////////////
336
337
338 var forwardingEntry = decodeHexForwardingEntry(content);
339
340 if(LOG>3)console.log('FORWARDING ENTRY IS PRESENT');
341 if(LOG>3)console.log(forwardingEntry);
342
343 ///////////////////////////////////////
344
345 //var output ="";
346
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700347 if(forwardingEntry.action!=null ){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700348 output+= "Action: ";
349
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700350 output+= DataUtils.toHex(forwardingEntry.action);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700351
352 output+= "<br />";
353 output+= "<br />";
354 }
355
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700356 if(forwardingEntry.prefixName!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700357 output+= "PrefixName: ";
358
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700359 output+= forwardingEntry.prefixName.getName();
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700360 output+= "<br />";
361 }
362
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700363 if(forwardingEntry.ccndID!=null){
364 output+= "ccndID: ";
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700365
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700366 output+= forwardingEntry.ccndID;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700367 output+= "<br />";
368 }
369
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700370 if(forwardingEntry.flags!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700371 output+= "Flags: ";
372
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700373 output+= forwardingEntry.flags;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700374 output+= "<br />";
375 }
376
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700377 if(forwardingEntry.lifetime!=null){
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700378 output+= "Lifetime: ";
379
Jeff Thompsone85ff1d2012-09-29 21:21:57 -0700380 output+= forwardingEntry.lifetime;
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700381 output+= "<br />";
382 }
383
384
385 }
386
387
388
389 document.getElementById('result').innerHTML = output;
390
391 }
392
393 </script>
394
395</head>
396<body >
397 <form>
398
Jeff Thompson86aea882012-09-29 17:32:48 -0700399 Please Press Decode:<br />
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700400
401
402 </form>
403 <button onclick="decode()">Decode</button>
404
405 <!-- p id="result-old-from-ccnx">01d2f2faa563636e7800fa0285e0a01e093968f9740ce7f4361babf5bb05a4e55aaca5e58f73eddeb8e013aa8f00fabd73656c6672656700fa1bf5048202aa03b208854a18988c72aee624da28e2e1acbccb209b8e89429041985521ed68f95a1c546872fba3d854b1377dc249b6d8ec5935e5069256c97a7f6d8a62e86222ccd2cfe5097aed3fe5ede6732ce191a8680d78e39d0c5058a2b7bb0f0687994e9f045de346b66c46498547a08da1f2f0cdfafba3afdfe7107931935ede79040137ba94a90000f20001a203e202851a4860caa4991e829bcdc9429fb711d52440968d23560726606050bf147acffc0002bab504fcb3f03aa40001e201da0a9530819f300d06092a864886f70d010101050003818d00308189028181008ed27580e3d1c4c67672208665133a1ba12d8ebf5cad8e054571926b3ff0782a04c71703384021a6cefb6616b66cbd8a679b761d69d6373a851546e26f7105510b4c23be9a3c7f2e652e100ecc1471855730659f1477ce4e8504ad1fd8f44116baaeae2ff67eec33abba790157a79bf5039e5a528a471d9d67c94e70117ed7490203010001000000019a0585058a04cabe73656c6672656700f2faad726f63636f000003e20285e0a01e093968f9740ce7f4361babf5bb05a4e55aaca5e58f73eddeb8e013aa8f0004fa8e330003d2d63231343734383336343700000000000002d28e310000</p-->
406
407 <p id="result">01d2f2faa563636e7800fa0285e0a01e093968f9740ce7f4361babf5bb05a4e55aaca5e58f73eddeb8e013aa8f00facd70726566697872656700fa29ad048202aa03b208854ddbf69779cdf4ef74be99474478c8bc3ca0873e0ffa1fa60120aa276db122b83404e595a8a3caeaf09630276658ba4e7beaadb4b91a8cc58e19ac4a42289507ed8d609aa9bef61a5a507f349c83d2944b8c16fecfd90d4a40ddb8687592c0a57517564235b2e359db54f51a37e1ac39e518a2196e3ffda7eb2fb301f3c404dd0000f20001a203e20285ef7c4f5d4743a8b8586ea2e741b7fc39d1dc0dbe1b1930e787cfd1d833ea7a610002bab504fce9e253d70001e2018219fd3082019b30820104020900b7d85c906bad52ee300d06092a864886f70d010105050030123110300e060355040313076178656c636476301e170d3132303432383233343433375a170d3132303532383233343433375a30123110300e060355040313076178656c63647630819f300d06092a864886f70d010101050003818d0030818902818100e17d30a7d828ab1b840b17542dcaf6207afd221e086b2a60d16cb7f54448ba9f3f08bcd099db21dd162a779e61aa89eee554d3a47de230bc7ac590d524067c3898bba6f5dc4360b845eda48cbd9cf126a723445f0e1952d7325a75faf556144f9a98af7186b0278685b8e2c08bea87171b4dee585c1828295b5395eb4a17779f0203010001300d06092a864886f70d010105050003818100cb3ab0357d7cd2ae97ed501e51a3a0e2817d418e47fb17906477af61495a7e8d8789141065b082d001f4b15193d0b43fb661cde20a6498372c6abbd3dcb9f0d12659ef07b3c6dbdf8bdf2f65477eed7adcd457d793b1c27badda7c5ade80ce95b7d8827fe78c8a35f3fb4ba648a081be2cfe84231abab3c2b531746df2e0492b000000019a02d5058a04cabe73656c6672656700f2faa56d656b69000004fa8e330003d2d63231343734383336343700000000000002d28e310000</p>
408
409</body>
410</html>