Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 1 | <?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>
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 7 | <title>NDN Request </title>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 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 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 53 | <script type="text/javascript" src="encoding/EncodingUtils.js"></script>
|
| 54 |
|
| 55 | <script type="text/javascript" src="lwNDN.js"></script>
|
| 56 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 57 | <script language="JavaScript" type="text/javascript" src="security/KeyManager.js"></script>
|
| 58 |
|
| 59 | <script language="JavaScript" type="text/javascript" src="securityLib/jsbn.js"></script>
|
| 60 | <script language="JavaScript" type="text/javascript" src="securityLib/jsbn2.js"></script>
|
| 61 | <script language="JavaScript" type="text/javascript" src="securityLib/rsa.js"></script>
|
| 62 | <script language="JavaScript" type="text/javascript" src="securityLib/rsa2.js"></script>
|
| 63 |
|
| 64 | <script language="JavaScript" type="text/javascript" src="securityLib/sha1.js"></script>
|
| 65 | <script language="JavaScript" type="text/javascript" src="securityLib/sha256.js"></script>
|
| 66 | <script language="JavaScript" type="text/javascript" src="securityLib/sha512.js"></script>
|
| 67 | <script language="JavaScript" type="text/javascript" src="securityLib/md5.js"></script>
|
| 68 | <script language="JavaScript" type="text/javascript" src="securityLib/ripemd160.js"></script>
|
| 69 | <script language="JavaScript" type="text/javascript" src="securityLib/base64.js"></script>
|
| 70 |
|
| 71 | <script language="JavaScript" type="text/javascript" src="securityLib/rsapem-1.1.js"></script>
|
| 72 | <script language="JavaScript" type="text/javascript" src="securityLib/rsasign-1.2.js"></script>
|
| 73 | <script language="JavaScript" type="text/javascript" src="securityLib/asn1hex-1.1.js"></script>
|
| 74 | <script language="JavaScript" type="text/javascript" src="securityLib/x509-1.1.js"></script>
|
| 75 |
|
| 76 | <script type="text/javascript">
|
| 77 | function run(){
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 78 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 79 |
|
| 80 | var contentName = document.getElementById('contentname').value;
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 81 |
|
| 82 | ///////////////////////////////////////
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 83 | //createRoute('131.179.141.15', 9695);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 84 | //createRoute('borges.metwi.ucla.edu', 9695);
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 85 | /// /ndn/ucla.edu/apps/hydra/mainvideo
|
| 86 | ///////////////////////////////////////
|
| 87 |
|
| 88 | var connector = new lwNDN('127.0.0.1', 9695);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 89 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 90 | var co = connector.get( contentName );
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 91 |
|
| 92 | ///////////////////////////////////////
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 93 | //PRINT OUTPUT
|
| 94 | ///////////////////////////////////////
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 95 |
|
| 96 | var output ="";
|
| 97 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 98 | if(co==null)
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 99 | output+= "NO CONTENT FOUND"
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 100 | else{
|
| 101 | if(co.Name!=null && co.Name.Components!=null){
|
| 102 | output+= "NAME: ";
|
| 103 |
|
| 104 | for(var i=0;i<co.Name.Components.length;i++){
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 105 | output+= "/"+ DataUtils.toString(co.Name.Components[i]);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 106 | }
|
| 107 | output+= "<br />";
|
| 108 | output+= "<br />";
|
| 109 | }
|
| 110 |
|
| 111 | if(co.Content !=null){
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 112 | output += "CONTENT(ASCII): "+ DataUtils.toString(co.Content);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 113 |
|
| 114 | output+= "<br />";
|
| 115 | output+= "<br />";
|
| 116 | }
|
| 117 | if(co.Content !=null){
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 118 | output += "CONTENT(hex): "+ DataUtils.toHex(co.Content);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 119 |
|
| 120 | output+= "<br />";
|
| 121 | output+= "<br />";
|
| 122 | }
|
| 123 |
|
| 124 | if(co.Signature !=null && co.Signature.Signature!=null){
|
| 125 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 126 | output += "SIGNATURE(hex): "+ DataUtils.toHex(co.Signature.Signature);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 127 |
|
| 128 | output+= "<br />";
|
| 129 | output+= "<br />";
|
| 130 | }
|
| 131 | if(co.SignedInfo !=null && co.SignedInfo.Publisher!=null && co.SignedInfo.Publisher.PublisherPublicKeyDigest!=null){
|
| 132 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 133 | output += "Publisher Public Key Digest(hex): "+ DataUtils.toHex(co.SignedInfo.Publisher.PublisherPublicKeyDigest);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 134 |
|
| 135 | output+= "<br />";
|
| 136 | output+= "<br />";
|
| 137 | }
|
| 138 | if(co.SignedInfo !=null && co.SignedInfo.Timestamp!=null){
|
| 139 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 140 | output += "TimeStamp: "+ co.SignedInfo.Timestamp.getJavascriptDate();
|
| 141 |
|
| 142 | output+= "<br />";
|
| 143 | output+= "<br />";
|
| 144 |
|
| 145 | output += "TimeStamp (MILLISECONDS): "+ co.SignedInfo.Timestamp.msec;
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 146 |
|
| 147 | output+= "<br />";
|
| 148 | output+= "<br />";
|
| 149 | }
|
| 150 | if(co.SignedInfo!=null && co.SignedInfo.Locator!=null && co.SignedInfo.Locator.PublicKey!=null){
|
| 151 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 152 | var publickey = rstr2b64(DataUtils.toString(co.SignedInfo.Locator.PublicKey));
|
| 153 | var publickeyHex = DataUtils.toHex(co.SignedInfo.Locator.PublicKey).toLowerCase();
|
| 154 | var publickeyString = DataUtils.toString(co.SignedInfo.Locator.PublicKey);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 155 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 156 | var signature = DataUtils.toHex(co.Signature.Signature).toLowerCase();
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 157 |
|
| 158 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 159 | var input = DataUtils.toString(co.rawSignatureData);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 160 |
|
| 161 |
|
| 162 | output += "DER Certificate: "+publickey ;
|
| 163 |
|
| 164 | output+= "<br />";
|
| 165 | output+= "<br />";
|
| 166 |
|
| 167 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 168 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 169 | if(LOG>2) console.log(" ContentName + SignedInfo + Content = "+input);
|
| 170 | if(LOG>2) console.log(" PublicKey = "+publickey );
|
| 171 | if(LOG>2) console.log(" PublicKeyHex = "+publickeyHex );
|
| 172 | if(LOG>2) console.log(" PublicKeyString = "+publickeyString );
|
| 173 |
|
| 174 | if(LOG>2) console.log(" Signature "+signature );
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 175 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 176 | if(LOG>2) console.log(" Signature NOW IS" );
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 177 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 178 | if(LOG>2) console.log(co.Signature.Signature);
|
| 179 |
|
| 180 |
|
| 181 | /*var x509 = new X509();
|
| 182 |
|
| 183 | x509.readCertPEM(publickey);
|
| 184 |
|
| 185 |
|
| 186 | //x509.readCertPEMWithoutRSAInit(publickey);
|
| 187 |
|
| 188 | var result = x509.subjectPublicKeyRSA.verifyString(input, signature);*/
|
| 189 | //console.log('result is '+result);
|
| 190 |
|
| 191 |
|
| 192 | var kp = publickeyHex.slice(56,314);
|
| 193 |
|
| 194 | output += "PUBLISHER KEY(hex): "+kp ;
|
| 195 |
|
| 196 | output+= "<br />";
|
| 197 | output+= "<br />";
|
| 198 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 199 | console.log('PUBLIC KEY IN HEX is ');
|
| 200 | console.log(kp);
|
| 201 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 202 | var exp = publickeyHex.slice(318,324);
|
| 203 |
|
| 204 | console.log('kp size is '+kp.length );
|
| 205 | output += "exponent: "+exp ;
|
| 206 |
|
| 207 | output+= "<br />";
|
| 208 | output+= "<br />";
|
| 209 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 210 | console.log('EXPONENT is ');
|
| 211 | console.log(exp);
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 | /*var c1 = hex_sha256(input);
|
| 216 | var c2 = signature;
|
| 217 |
|
| 218 | if(LOG>4)console.log('input is ');
|
| 219 | if(LOG>4)console.log(input);
|
| 220 | if(LOG>4)console.log('C1 is ');
|
| 221 | if(LOG>4)console.log(c1);
|
| 222 | if(LOG>4)console.log('C2 is ');
|
| 223 | if(LOG>4)console.log(c2);
|
| 224 | var result = c1 == c2;*/
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 225 |
|
| 226 | var rsakey = new RSAKey();
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 227 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 228 | rsakey.setPublic(kp,exp);
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 229 |
|
| 230 | var result = rsakey.verifyByteArray(co.rawSignatureData,signature);
|
| 231 | // var result = rsakey.verifyString(input, signature);
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 | console.log('PUBLIC KEY n after is ');
|
| 236 | console.log(rsakey.n);
|
| 237 |
|
| 238 | console.log('EXPONENT e after is ');
|
| 239 | console.log(rsakey.e);
|
| 240 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 241 |
|
| 242 | if(result)
|
| 243 | output += 'SIGNATURE VALID';
|
| 244 | else
|
| 245 | output += 'SIGNATURE INVALID';
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 | //output += "VALID: "+ toHex(co.SignedInfo.Locator.PublicKey);
|
| 251 |
|
| 252 | output+= "<br />";
|
| 253 | output+= "<br />";
|
| 254 |
|
| 255 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame^] | 256 | //if(LOG>4) console.log('str'[1]);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 257 | }
|
| 258 | }
|
| 259 |
|
| 260 | document.getElementById('result').innerHTML = output;
|
| 261 | }
|
| 262 |
|
| 263 | </script>
|
| 264 |
|
| 265 | </head>
|
| 266 | <body >
|
| 267 | <form>
|
| 268 | Please Enter a Content Name:<br /><input id="contentname" type="text" name="CONTENTNAME" value="/PARC/abc" /> <br />
|
| 269 | </form>
|
| 270 | <button onclick="run()">Request Data!</button>
|
| 271 | <div >
|
| 272 | <applet id="JavaSocketBridge" archive="JavaSocketBridge.jar" code="JavaSocketBridge.class" width="0" height="0">
|
| 273 | </applet>
|
| 274 | </div>
|
| 275 |
|
| 276 | <p id="result"></p>
|
| 277 |
|
| 278 | </body>
|
| 279 | </html> |