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">
|
Jeff Burke | 92dd8e4 | 2012-12-08 11:40:31 -0800 | [diff] [blame] | 4 | <!--
|
| 5 | See COPYING for copyright and distribution information.
|
| 6 | -->
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 7 | <html xmlns = "http://www.w3.org/1999/xhtml">
|
| 8 |
|
| 9 | <head>
|
Jeff Thompson | f676c42 | 2012-08-26 11:57:33 -0700 | [diff] [blame] | 10 | <title>NDN Signature - Binary</title>
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 11 |
|
Alexander Afanasyev | 2a2c9d2 | 2013-03-13 16:21:32 -0700 | [diff] [blame^] | 12 | <script type="text/javascript" src="../build/ndn-js.js"></script>
|
Meki Cherkaoui | 8f17361 | 2012-06-06 01:05:40 -0700 | [diff] [blame] | 13 |
|
Meki Cherkaoui | 88d59cd | 2012-05-14 07:34:58 -0700 | [diff] [blame] | 14 | <script type="text/javascript">
|
| 15 | function sign(){
|
| 16 |
|
| 17 | var input = document.getElementById('contentname').value;
|
| 18 |
|
| 19 | var _PEM_PRIVATE_KEY_STRING_ = document.getElementById('privateKey').value;
|
| 20 |
|
| 21 | var rsa = new RSAKey();
|
| 22 |
|
| 23 | rsa.readPrivateKeyFromPEMString(_PEM_PRIVATE_KEY_STRING_);
|
| 24 |
|
| 25 | var hSig = rsa.signString(input, "sha256");
|
| 26 |
|
| 27 | document.getElementById('result').innerHTML = hSig;
|
| 28 |
|
| 29 | }
|
| 30 | function verify(){
|
| 31 | var input = document.getElementById('contentname').value;
|
| 32 |
|
| 33 | var signature = document.getElementById('result').innerHTML;
|
| 34 |
|
| 35 | var _PEM_X509CERT_STRING_ = document.getElementById('certificate').value;
|
| 36 |
|
| 37 | var x509 = new X509();
|
| 38 |
|
| 39 | x509.readCertPEM(_PEM_X509CERT_STRING_);
|
| 40 |
|
| 41 | var result = x509.subjectPublicKeyRSA.verifyString(input, signature);
|
| 42 |
|
| 43 | if(result)
|
| 44 | document.getElementById('result').innerHTML = 'SIGNATURE VALID';
|
| 45 | else
|
| 46 | document.getElementById('result').innerHTML = 'SIGNATURE INVALID';
|
| 47 |
|
| 48 |
|
| 49 | }
|
| 50 |
|
| 51 | </script>
|
| 52 |
|
| 53 |
|
| 54 | </head>
|
| 55 | <body >
|
| 56 | <form>
|
| 57 |
|
| 58 | <input id="privateKey" type="hidden" value="-----BEGIN RSA PRIVATE KEY-----
|
| 59 | MIICWwIBAAKBgQDRhGF7X4A0ZVlEg594WmODVVUIiiPQs04aLmvfg8SborHss5gQ
|
| 60 | Xu0aIdUT6nb5rTh5hD2yfpF2WIW6M8z0WxRhwicgXwi80H1aLPf6lEPPLvN29EhQ
|
| 61 | NjBpkFkAJUbS8uuhJEeKw0cE49g80eBBF4BCqSL6PFQbP9/rByxdxEoAIQIDAQAB
|
| 62 | AoGAA9/q3Zk6ib2GFRpKDLO/O2KMnAfR+b4XJ6zMGeoZ7Lbpi3MW0Nawk9ckVaX0
|
| 63 | ZVGqxbSIX5Cvp/yjHHpww+QbUFrw/gCjLiiYjM9E8C3uAF5AKJ0r4GBPl4u8K4bp
|
| 64 | bXeSxSB60/wPQFiQAJVcA5xhZVzqNuF3EjuKdHsw+dk+dPECQQDubX/lVGFgD/xY
|
| 65 | uchz56Yc7VHX+58BUkNSewSzwJRbcueqknXRWwj97SXqpnYfKqZq78dnEF10SWsr
|
| 66 | /NMKi+7XAkEA4PVqDv/OZAbWr4syXZNv/Mpl4r5suzYMMUD9U8B2JIRnrhmGZPzL
|
| 67 | x23N9J4hEJ+Xh8tSKVc80jOkrvGlSv+BxwJAaTOtjA3YTV+gU7Hdza53sCnSw/8F
|
| 68 | YLrgc6NOJtYhX9xqdevbyn1lkU0zPr8mPYg/F84m6MXixm2iuSz8HZoyzwJARi2p
|
| 69 | aYZ5/5B2lwroqnKdZBJMGKFpUDn7Mb5hiSgocxnvMkv6NjT66Xsi3iYakJII9q8C
|
| 70 | Ma1qZvT/cigmdbAh7wJAQNXyoizuGEltiSaBXx4H29EdXNYWDJ9SS5f070BRbAIl
|
| 71 | dqRh3rcNvpY6BKJqFapda1DjdcncZECMizT/GMrc1w==
|
| 72 | -----END RSA PRIVATE KEY-----"></input>
|
| 73 |
|
| 74 |
|
| 75 | <input id="certificate" type="hidden" value="-----BEGIN CERTIFICATE-----
|
| 76 | MIIBvTCCASYCCQD55fNzc0WF7TANBgkqhkiG9w0BAQUFADAjMQswCQYDVQQGEwJK
|
| 77 | UDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwHhcNMTAwNTI4MDIwODUxWhcNMjAwNTI1
|
| 78 | MDIwODUxWjAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwgZ8w
|
| 79 | DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANGEYXtfgDRlWUSDn3haY4NVVQiKI9Cz
|
| 80 | Thoua9+DxJuiseyzmBBe7Roh1RPqdvmtOHmEPbJ+kXZYhbozzPRbFGHCJyBfCLzQ
|
| 81 | fVos9/qUQ88u83b0SFA2MGmQWQAlRtLy66EkR4rDRwTj2DzR4EEXgEKpIvo8VBs/
|
| 82 | 3+sHLF3ESgAhAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAEZ6mXFFq3AzfaqWHmCy1
|
| 83 | ARjlauYAa8ZmUFnLm0emg9dkVBJ63aEqARhtok6bDQDzSJxiLpCEF6G4b/Nv/M/M
|
| 84 | LyhP+OoOTmETMegAVQMq71choVJyOFE5BtQa6M/lCHEOya5QUfoRF2HF9EjRF44K
|
| 85 | 3OK+u3ivTSj3zwjtpudY5Xo=
|
| 86 | -----END CERTIFICATE-----"></input>
|
| 87 |
|
| 88 | Please Enter a Text to sign:<br /><input id="contentname" type="text" name="CONTENTNAME" value="ª²
s\nXñå àÄÕk...\
?8ï����µhello\n�" /> <br />
|
| 89 |
|
| 90 | </form>
|
| 91 | <button onclick="sign()">Sign</button>
|
| 92 | <button onclick="verify()">Verify</button>
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 | <p id="result"></p>
|
| 97 |
|
| 98 | </body>
|
| 99 | </html> |