blob: d1a7441b896f83599bfe9ea9cb4a8b622badb17e [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>
7 <title>NDN Request Example</title>
Jeff Thompson7ed5ef52012-08-26 11:28:48 -07008 <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn.js"></script>
9 <script language="JavaScript" type="text/javascript" src="../securityLib/jsbn2.js"></script>
10 <script language="JavaScript" type="text/javascript" src="../securityLib/rsa.js"></script>
11 <script language="JavaScript" type="text/javascript" src="../securityLib/rsa2.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070012
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070013 <script language="JavaScript" type="text/javascript" src="../securityLib/sha1.js"></script>
14 <script language="JavaScript" type="text/javascript" src="../securityLib/sha256.js"></script>
15 <script language="JavaScript" type="text/javascript" src="../securityLib/sha512.js"></script>
16 <script language="JavaScript" type="text/javascript" src="../securityLib/md5.js"></script>
17 <script language="JavaScript" type="text/javascript" src="../securityLib/ripemd160.js"></script>
18 <script language="JavaScript" type="text/javascript" src="../securityLib/base64.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070019
Jeff Thompson7ed5ef52012-08-26 11:28:48 -070020 <script language="JavaScript" type="text/javascript" src="../securityLib/rsapem-1.1.min.js"></script>
21 <script language="JavaScript" type="text/javascript" src="../securityLib/rsasign-1.2.min.js"></script>
22 <script language="JavaScript" type="text/javascript" src="../securityLib/asn1hex-1.1.min.js"></script>
23 <script language="JavaScript" type="text/javascript" src="../securityLib/x509-1.1.min.js"></script>
24<script language="JavaScript" type="text/javascript" src="../security/KeyManager.js"></script>
Meki Cherkaoui8f173612012-06-06 01:05:40 -070025
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070026
27 <script type="text/javascript">
28 function sign(){
29
Meki Cherkaoui8f173612012-06-06 01:05:40 -070030
31 var keyManager = new KeyManager();
32
33
34
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070035 var input = document.getElementById('contentname').value;
36
Meki Cherkaoui8f173612012-06-06 01:05:40 -070037 var _PEM_PRIVATE_KEY_STRING_ = keyManager.privateKey;//document.getElementById('privateKey').value;
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070038
39 var rsa = new RSAKey();
40
41 rsa.readPrivateKeyFromPEMString(_PEM_PRIVATE_KEY_STRING_);
42
43 var hSig = rsa.signString(input, "sha256");
44
45 document.getElementById('result').innerHTML = hSig;
46
47 }
48 function verify(){
49 var input = document.getElementById('contentname').value;
50
51 var signature = document.getElementById('result').innerHTML;
52
53 var _PEM_X509CERT_STRING_ = document.getElementById('certificate').value;
54
55 var x509 = new X509();
56
57 x509.readCertPEM(_PEM_X509CERT_STRING_);
58
59 var result = x509.subjectPublicKeyRSA.verifyString(input, signature);
60
61 if(result)
62 document.getElementById('result').innerHTML = 'SIGNATURE VALID';
63 else
64 document.getElementById('result').innerHTML = 'SIGNATURE INVALID';
65
66
67 }
68
69 </script>
70
71
72</head>
73<body >
74 <form>
75
76 <input id="privateKey" type="hidden" value="-----BEGIN RSA PRIVATE KEY-----
77 MIICWwIBAAKBgQDRhGF7X4A0ZVlEg594WmODVVUIiiPQs04aLmvfg8SborHss5gQ
78 Xu0aIdUT6nb5rTh5hD2yfpF2WIW6M8z0WxRhwicgXwi80H1aLPf6lEPPLvN29EhQ
79 NjBpkFkAJUbS8uuhJEeKw0cE49g80eBBF4BCqSL6PFQbP9/rByxdxEoAIQIDAQAB
80 AoGAA9/q3Zk6ib2GFRpKDLO/O2KMnAfR+b4XJ6zMGeoZ7Lbpi3MW0Nawk9ckVaX0
81 ZVGqxbSIX5Cvp/yjHHpww+QbUFrw/gCjLiiYjM9E8C3uAF5AKJ0r4GBPl4u8K4bp
82 bXeSxSB60/wPQFiQAJVcA5xhZVzqNuF3EjuKdHsw+dk+dPECQQDubX/lVGFgD/xY
83 uchz56Yc7VHX+58BUkNSewSzwJRbcueqknXRWwj97SXqpnYfKqZq78dnEF10SWsr
84 /NMKi+7XAkEA4PVqDv/OZAbWr4syXZNv/Mpl4r5suzYMMUD9U8B2JIRnrhmGZPzL
85 x23N9J4hEJ+Xh8tSKVc80jOkrvGlSv+BxwJAaTOtjA3YTV+gU7Hdza53sCnSw/8F
86 YLrgc6NOJtYhX9xqdevbyn1lkU0zPr8mPYg/F84m6MXixm2iuSz8HZoyzwJARi2p
87 aYZ5/5B2lwroqnKdZBJMGKFpUDn7Mb5hiSgocxnvMkv6NjT66Xsi3iYakJII9q8C
88 Ma1qZvT/cigmdbAh7wJAQNXyoizuGEltiSaBXx4H29EdXNYWDJ9SS5f070BRbAIl
89 dqRh3rcNvpY6BKJqFapda1DjdcncZECMizT/GMrc1w==
90 -----END RSA PRIVATE KEY-----"></input>
91
92
93 <input id="certificate" type="hidden" value="-----BEGIN CERTIFICATE-----
94 MIIBvTCCASYCCQD55fNzc0WF7TANBgkqhkiG9w0BAQUFADAjMQswCQYDVQQGEwJK
95 UDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwHhcNMTAwNTI4MDIwODUxWhcNMjAwNTI1
96 MDIwODUxWjAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwgZ8w
97 DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANGEYXtfgDRlWUSDn3haY4NVVQiKI9Cz
98 Thoua9+DxJuiseyzmBBe7Roh1RPqdvmtOHmEPbJ+kXZYhbozzPRbFGHCJyBfCLzQ
99 fVos9/qUQ88u83b0SFA2MGmQWQAlRtLy66EkR4rDRwTj2DzR4EEXgEKpIvo8VBs/
100 3+sHLF3ESgAhAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAEZ6mXFFq3AzfaqWHmCy1
101 ARjlauYAa8ZmUFnLm0emg9dkVBJ63aEqARhtok6bDQDzSJxiLpCEF6G4b/Nv/M/M
102 LyhP+OoOTmETMegAVQMq71choVJyOFE5BtQa6M/lCHEOya5QUfoRF2HF9EjRF44K
103 3OK+u3ivTSj3zwjtpudY5Xo=
104 -----END CERTIFICATE-----"></input>
105
106 Please Enter a Text to sign:<br /><input id="contentname" type="text" name="CONTENTNAME" value="/PARC/CCNX" /> <br />
107
108 </form>
109 <button onclick="sign()">Sign</button>
110 <button onclick="verify()">Verify</button>
111
112
113
114 <p id="result"></p>
115
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700116
117
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700118</body>
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700119
120</html>