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 Encode/Decode Content Object</title>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 8 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 9 | <script type="text/javascript" src="../java_socket_bridge.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 10 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 11 | <script type="text/javascript" src="../CCNProtocolDTags.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 12 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 13 | <script type="text/javascript" src="../CCNTime.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 14 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 15 | <script type="text/javascript" src="../ContentName.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 16 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 17 | <script type="text/javascript" src="../ContentObject.js"></script>
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 18 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 19 | <script type="text/javascript" src="../Exclude.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 20 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 21 | <script type="text/javascript" src="../ExcludeAny.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 22 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 23 | <script type="text/javascript" src="../ExcludeComponent.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 24 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 25 | <script type="text/javascript" src="../Interest.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 26 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 27 | <script type="text/javascript" src="../KeyLocator.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 28 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 29 | <script type="text/javascript" src="../KeyName.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 30 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 31 | <script type="text/javascript" src="../PublisherID.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 32 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 33 | <script type="text/javascript" src="../Signature.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 34 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 35 | <script type="text/javascript" src="../SignedInfo.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 36 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 37 | <script type="text/javascript" src="../PublisherPublicKeyDigest.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 38 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 39 | <script type="text/javascript" src="../FaceInstance.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 40 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 41 | <script type="text/javascript" src="../ForwardingEntry.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 42 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 43 | <script type="text/javascript" src="../encoding/BinaryXMLEncoder.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 44 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 45 | <script type="text/javascript" src="../encoding/BinaryXMLCodec.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 46 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 47 | <script type="text/javascript" src="../encoding/BinaryXMLDecoder.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 48 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 49 | <script type="text/javascript" src="../encoding/DataUtils.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 50 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 51 | <script type="text/javascript" src="../encoding/EncodingUtils.js"></script>
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 52 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 53 | <script language="JavaScript" type="text/javascript" src="../security/KeyManager.js"></script>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 54 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 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>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 59 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 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>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 66 |
|
Jeff Thompson | 7ed5ef5 | 2012-08-26 11:28:48 -0700 | [diff] [blame] | 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>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 71 |
|
| 72 | <script type="text/javascript">
|
| 73 |
|
| 74 | function encode(){
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 75 | var contentname = new ContentName( document.getElementById('contentname').value );
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 76 |
|
| 77 | var content = document.getElementById('content').value;
|
| 78 |
|
| 79 | var signedInfo = new SignedInfo();
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 80 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 81 | signedInfo.setFields();
|
| 82 | //var signatureBits = generateSignatureBits(contentname,content,signedInfo);
|
| 83 |
|
| 84 | //witness is null
|
| 85 | var signature = new Signature();
|
| 86 |
|
| 87 |
|
| 88 | var co = new ContentObject(contentname,signedInfo,content,signature);
|
| 89 |
|
| 90 | co.sign();
|
| 91 |
|
| 92 |
|
| 93 | var output = encodeToHexContentObject(co);
|
| 94 |
|
| 95 | document.getElementById('result').innerHTML = output;
|
| 96 |
|
| 97 | }
|
| 98 |
|
| 99 | function decode(){
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 100 | var input = document.getElementById('result').innerHTML;
|
| 101 |
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 102 | input = input.toUpperCase();
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 103 |
|
| 104 | var co = decodeHexContentObject(input);
|
| 105 |
|
| 106 | if(LOG>3)console.log('CONTENT OBJECT DECODED');
|
| 107 | if(LOG>3)console.log(co);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 108 |
|
jeff | cc8b3a9 | 2012-09-03 15:13:27 -0700 | [diff] [blame] | 109 | document.getElementById('result').innerHTML = contentObjectToHtml(co);
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 110 | }
|
| 111 |
|
| 112 | </script>
|
| 113 |
|
| 114 | </head>
|
| 115 | <body >
|
| 116 | <form>
|
| 117 |
|
| 118 | Please Enter a Content Name:<br />
|
| 119 |
|
| 120 | <input id="contentname" type="text" name="CONTENTNAME" value="/PARC/abc" />
|
| 121 |
|
Jeff Thompson | 12b029d | 2012-08-26 11:51:27 -0700 | [diff] [blame] | 122 | <br />Please Enter the Content:<br />
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 123 |
|
| 124 | <textarea id="content" cols="40" rows="5" name="CONTENT" value="SUCCESS" >SUCCESS!</textarea>
|
| 125 |
|
| 126 | </form>
|
| 127 | <button onclick="encode()">Encode</button>
|
| 128 | <button onclick="decode()">Decode</button>
|
| 129 |
|
| 130 |
|
Jeff Thompson | 12b029d | 2012-08-26 11:51:27 -0700 | [diff] [blame] | 131 | <p id="result"></p>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 132 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 133 |
|
| 134 | </body>
|
jeff | cc8b3a9 | 2012-09-03 15:13:27 -0700 | [diff] [blame] | 135 | </html>
|