blob: 28015129aa1e50b9535e85a11527526317fcaf3c [file] [log] [blame]
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07001<?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 Thompsonf676c422012-08-26 11:57:33 -07007 <title>NDN Signature - Binary</title>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07008
Jeff Thompson38422f42012-11-15 00:20:39 -08009 <script type="text/javascript" src="../Helper.js"></script>
Meki Cherkaoui8f173612012-06-06 01:05:40 -070010
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070011 <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
85 Please Enter a Text to sign:<br /><input id="contentname" type="text" name="CONTENTNAME" value="ª²…s–\nXñ­å ’ŠàÄՋk...\…?8ï����šµhello\n�" /> <br />
86
87 </form>
88 <button onclick="sign()">Sign</button>
89 <button onclick="verify()">Verify</button>
90
91
92
93 <p id="result"></p>
94
95</body>
96</html>