| <?xml version = "1.0" encoding="utf-8" ?> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
| "DTD/xhtml1-strict.dtd"> |
| <html xmlns = "http://www.w3.org/1999/xhtml"> |
| |
| <head> |
| <title>NDN Image Parsing</title> |
| <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn.js"></script> |
| <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn2.js"></script> |
| <script language="JavaScript" type="text/javascript" src="../securityLib/rsa.js"></script> |
| <script language="JavaScript" type="text/javascript" src="../securityLib/rsa2.js"></script> |
| |
| <script language="JavaScript" type="text/javascript" src="../securityLib/sha1.js"></script> |
| <script language="JavaScript" type="text/javascript" src="../securityLib/sha256.js"></script> |
| <script language="JavaScript" type="text/javascript" src="../securityLib/sha512.js"></script> |
| <script language="JavaScript" type="text/javascript" src="../securityLib/md5.js"></script> |
| <script language="JavaScript" type="text/javascript" src="../securityLib/ripemd160.js"></script> |
| <script language="JavaScript" type="text/javascript" src="../securityLib/base64.js"></script> |
| |
| <script language="JavaScript" type="text/javascript" src="../securityLib/rsapem-1.1.min.js"></script> |
| <script language="JavaScript" type="text/javascript" src="../securityLib/rsasign-1.2.min.js"></script> |
| <script language="JavaScript" type="text/javascript" src="../securityLib/asn1hex-1.1.min.js"></script> |
| <script language="JavaScript" type="text/javascript" src="../securityLib/x509-1.1.min.js"></script> |
| |
| |
| <script type="text/javascript"> |
| function sign(){ |
| |
| var input = document.getElementById('contentname').value; |
| |
| var _PEM_PRIVATE_KEY_STRING_ = document.getElementById('privateKey').value; |
| |
| var rsa = new RSAKey(); |
| |
| rsa.readPrivateKeyFromPEMString(_PEM_PRIVATE_KEY_STRING_); |
| |
| var hSig = rsa.signString(input, "sha256"); |
| |
| document.getElementById('result').innerHTML = hSig; |
| |
| } |
| function verify(){ |
| var input = document.getElementById('contentname').value; |
| |
| var signature = document.getElementById('result').innerHTML; |
| |
| var _PEM_X509CERT_STRING_ = document.getElementById('certificate').value; |
| |
| var x509 = new X509(); |
| |
| x509.readCertPEM(_PEM_X509CERT_STRING_); |
| |
| var result = x509.subjectPublicKeyRSA.verifyString(input, signature); |
| |
| if(result) |
| document.getElementById('result').innerHTML = 'SIGNATURE VALID'; |
| else |
| document.getElementById('result').innerHTML = 'SIGNATURE INVALID'; |
| |
| |
| } |
| |
| </script> |
| |
| |
| </head> |
| <body > |
| <form> |
| |
| <input id="privateKey" type="hidden" value="-----BEGIN RSA PRIVATE KEY----- |
| MIICWwIBAAKBgQDRhGF7X4A0ZVlEg594WmODVVUIiiPQs04aLmvfg8SborHss5gQ |
| Xu0aIdUT6nb5rTh5hD2yfpF2WIW6M8z0WxRhwicgXwi80H1aLPf6lEPPLvN29EhQ |
| NjBpkFkAJUbS8uuhJEeKw0cE49g80eBBF4BCqSL6PFQbP9/rByxdxEoAIQIDAQAB |
| AoGAA9/q3Zk6ib2GFRpKDLO/O2KMnAfR+b4XJ6zMGeoZ7Lbpi3MW0Nawk9ckVaX0 |
| ZVGqxbSIX5Cvp/yjHHpww+QbUFrw/gCjLiiYjM9E8C3uAF5AKJ0r4GBPl4u8K4bp |
| bXeSxSB60/wPQFiQAJVcA5xhZVzqNuF3EjuKdHsw+dk+dPECQQDubX/lVGFgD/xY |
| uchz56Yc7VHX+58BUkNSewSzwJRbcueqknXRWwj97SXqpnYfKqZq78dnEF10SWsr |
| /NMKi+7XAkEA4PVqDv/OZAbWr4syXZNv/Mpl4r5suzYMMUD9U8B2JIRnrhmGZPzL |
| x23N9J4hEJ+Xh8tSKVc80jOkrvGlSv+BxwJAaTOtjA3YTV+gU7Hdza53sCnSw/8F |
| YLrgc6NOJtYhX9xqdevbyn1lkU0zPr8mPYg/F84m6MXixm2iuSz8HZoyzwJARi2p |
| aYZ5/5B2lwroqnKdZBJMGKFpUDn7Mb5hiSgocxnvMkv6NjT66Xsi3iYakJII9q8C |
| Ma1qZvT/cigmdbAh7wJAQNXyoizuGEltiSaBXx4H29EdXNYWDJ9SS5f070BRbAIl |
| dqRh3rcNvpY6BKJqFapda1DjdcncZECMizT/GMrc1w== |
| -----END RSA PRIVATE KEY-----"></input> |
| |
| |
| <input id="certificate" type="hidden" value="-----BEGIN CERTIFICATE----- |
| MIIBvTCCASYCCQD55fNzc0WF7TANBgkqhkiG9w0BAQUFADAjMQswCQYDVQQGEwJK |
| UDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwHhcNMTAwNTI4MDIwODUxWhcNMjAwNTI1 |
| MDIwODUxWjAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwgZ8w |
| DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANGEYXtfgDRlWUSDn3haY4NVVQiKI9Cz |
| Thoua9+DxJuiseyzmBBe7Roh1RPqdvmtOHmEPbJ+kXZYhbozzPRbFGHCJyBfCLzQ |
| fVos9/qUQ88u83b0SFA2MGmQWQAlRtLy66EkR4rDRwTj2DzR4EEXgEKpIvo8VBs/ |
| 3+sHLF3ESgAhAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAEZ6mXFFq3AzfaqWHmCy1 |
| ARjlauYAa8ZmUFnLm0emg9dkVBJ63aEqARhtok6bDQDzSJxiLpCEF6G4b/Nv/M/M |
| LyhP+OoOTmETMegAVQMq71choVJyOFE5BtQa6M/lCHEOya5QUfoRF2HF9EjRF44K |
| 3OK+u3ivTSj3zwjtpudY5Xo= |
| -----END CERTIFICATE-----"></input> |
| |
| Please Enter a Text to sign:<br /><input id="contentname" type="text" name="CONTENTNAME" value="/PARC/CCNX" /> <br /> |
| |
| </form> |
| <button onclick="sign()">Encode</button> |
| <button onclick="verify()">Parse</button> |
| |
| <script type="text/javascript"> |
| |
| var srcString = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IAAAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1JREFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jqch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0vr4MkhoXe0rZigAAAABJRU5ErkJggg=='; |
| var link = document.createElement('img'); |
| link.setAttribute('src', srcString); |
| |
| document.body.appendChild(link); |
| |
| </script> |
| |
| <img src="data:image/png;base64, |
| iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP |
| C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA |
| AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J |
| REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq |
| ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0 |
| vr4MkhoXe0rZigAAAABJRU5ErkJggg==" alt="Red dot" /> |
| |
| <p id="result"></p> |
| |
| </body> |
| </html> |