Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -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> |
jeff | 7264ee1 | 2012-09-16 17:04:10 -0700 | [diff] [blame] | 7 | <title>NDN Image Parsing</title> |
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 8 | |
Jeff Thompson | 38422f4 | 2012-11-15 00:20:39 -0800 | [diff] [blame] | 9 | <script type="text/javascript" src="../Helper.js"></script> |
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 10 | |
| 11 | <script type="text/javascript"> |
| 12 | function sign(){ |
| 13 | |
| 14 | var input = document.getElementById('contentname').value; |
| 15 | |
| 16 | var _PEM_PRIVATE_KEY_STRING_ = document.getElementById('privateKey').value; |
| 17 | |
| 18 | var rsa = new RSAKey(); |
| 19 | |
| 20 | rsa.readPrivateKeyFromPEMString(_PEM_PRIVATE_KEY_STRING_); |
| 21 | |
| 22 | var hSig = rsa.signString(input, "sha256"); |
| 23 | |
| 24 | document.getElementById('result').innerHTML = hSig; |
| 25 | |
| 26 | } |
| 27 | function verify(){ |
| 28 | var input = document.getElementById('contentname').value; |
| 29 | |
| 30 | var signature = document.getElementById('result').innerHTML; |
| 31 | |
| 32 | var _PEM_X509CERT_STRING_ = document.getElementById('certificate').value; |
| 33 | |
| 34 | var x509 = new X509(); |
| 35 | |
| 36 | x509.readCertPEM(_PEM_X509CERT_STRING_); |
| 37 | |
| 38 | var result = x509.subjectPublicKeyRSA.verifyString(input, signature); |
| 39 | |
| 40 | if(result) |
| 41 | document.getElementById('result').innerHTML = 'SIGNATURE VALID'; |
| 42 | else |
| 43 | document.getElementById('result').innerHTML = 'SIGNATURE INVALID'; |
| 44 | |
| 45 | |
| 46 | } |
| 47 | |
| 48 | </script> |
| 49 | |
| 50 | |
| 51 | </head> |
| 52 | <body > |
| 53 | <form> |
| 54 | |
| 55 | <input id="privateKey" type="hidden" value="-----BEGIN RSA PRIVATE KEY----- |
| 56 | MIICWwIBAAKBgQDRhGF7X4A0ZVlEg594WmODVVUIiiPQs04aLmvfg8SborHss5gQ |
| 57 | Xu0aIdUT6nb5rTh5hD2yfpF2WIW6M8z0WxRhwicgXwi80H1aLPf6lEPPLvN29EhQ |
| 58 | NjBpkFkAJUbS8uuhJEeKw0cE49g80eBBF4BCqSL6PFQbP9/rByxdxEoAIQIDAQAB |
| 59 | AoGAA9/q3Zk6ib2GFRpKDLO/O2KMnAfR+b4XJ6zMGeoZ7Lbpi3MW0Nawk9ckVaX0 |
| 60 | ZVGqxbSIX5Cvp/yjHHpww+QbUFrw/gCjLiiYjM9E8C3uAF5AKJ0r4GBPl4u8K4bp |
| 61 | bXeSxSB60/wPQFiQAJVcA5xhZVzqNuF3EjuKdHsw+dk+dPECQQDubX/lVGFgD/xY |
| 62 | uchz56Yc7VHX+58BUkNSewSzwJRbcueqknXRWwj97SXqpnYfKqZq78dnEF10SWsr |
| 63 | /NMKi+7XAkEA4PVqDv/OZAbWr4syXZNv/Mpl4r5suzYMMUD9U8B2JIRnrhmGZPzL |
| 64 | x23N9J4hEJ+Xh8tSKVc80jOkrvGlSv+BxwJAaTOtjA3YTV+gU7Hdza53sCnSw/8F |
| 65 | YLrgc6NOJtYhX9xqdevbyn1lkU0zPr8mPYg/F84m6MXixm2iuSz8HZoyzwJARi2p |
| 66 | aYZ5/5B2lwroqnKdZBJMGKFpUDn7Mb5hiSgocxnvMkv6NjT66Xsi3iYakJII9q8C |
| 67 | Ma1qZvT/cigmdbAh7wJAQNXyoizuGEltiSaBXx4H29EdXNYWDJ9SS5f070BRbAIl |
| 68 | dqRh3rcNvpY6BKJqFapda1DjdcncZECMizT/GMrc1w== |
| 69 | -----END RSA PRIVATE KEY-----"></input> |
| 70 | |
| 71 | |
| 72 | <input id="certificate" type="hidden" value="-----BEGIN CERTIFICATE----- |
| 73 | MIIBvTCCASYCCQD55fNzc0WF7TANBgkqhkiG9w0BAQUFADAjMQswCQYDVQQGEwJK |
| 74 | UDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwHhcNMTAwNTI4MDIwODUxWhcNMjAwNTI1 |
| 75 | MDIwODUxWjAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwgZ8w |
| 76 | DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANGEYXtfgDRlWUSDn3haY4NVVQiKI9Cz |
| 77 | Thoua9+DxJuiseyzmBBe7Roh1RPqdvmtOHmEPbJ+kXZYhbozzPRbFGHCJyBfCLzQ |
| 78 | fVos9/qUQ88u83b0SFA2MGmQWQAlRtLy66EkR4rDRwTj2DzR4EEXgEKpIvo8VBs/ |
| 79 | 3+sHLF3ESgAhAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAEZ6mXFFq3AzfaqWHmCy1 |
| 80 | ARjlauYAa8ZmUFnLm0emg9dkVBJ63aEqARhtok6bDQDzSJxiLpCEF6G4b/Nv/M/M |
| 81 | LyhP+OoOTmETMegAVQMq71choVJyOFE5BtQa6M/lCHEOya5QUfoRF2HF9EjRF44K |
| 82 | 3OK+u3ivTSj3zwjtpudY5Xo= |
| 83 | -----END CERTIFICATE-----"></input> |
| 84 | |
Jeff Thompson | bd82926 | 2012-11-30 22:28:37 -0800 | [diff] [blame^] | 85 | Please Enter a Text to sign:<br /><input id="contentname" type="text" name="CONTENTNAME" value="/ndn/abc" /> <br /> |
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 86 | |
| 87 | </form> |
| 88 | <button onclick="sign()">Encode</button> |
| 89 | <button onclick="verify()">Parse</button> |
| 90 | |
| 91 | <script type="text/javascript"> |
| 92 | |
jeff | 7264ee1 | 2012-09-16 17:04:10 -0700 | [diff] [blame] | 93 | var srcString = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IAAAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1JREFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jqch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0vr4MkhoXe0rZigAAAABJRU5ErkJggg=='; |
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 94 | var link = document.createElement('img'); |
jeff | 7264ee1 | 2012-09-16 17:04:10 -0700 | [diff] [blame] | 95 | link.setAttribute('src', srcString); |
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 96 | |
| 97 | document.body.appendChild(link); |
| 98 | |
| 99 | </script> |
| 100 | |
| 101 | <img src="data:image/png;base64, |
| 102 | iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP |
| 103 | C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA |
| 104 | AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J |
| 105 | REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq |
| 106 | ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0 |
| 107 | vr4MkhoXe0rZigAAAABJRU5ErkJggg==" alt="Red dot" /> |
| 108 | |
| 109 | <p id="result"></p> |
| 110 | |
| 111 | </body> |
| 112 | </html> |