blob: fa31102bb4b889bc27ba50e8a1878bebdf14475e [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>
jeff0b65e352012-09-16 14:35:14 -07007 <title>NDN Signature - String</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>
jeff0b65e352012-09-16 14:35:14 -070024 <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(){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070029 var keyManager = new KeyManager();
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070030 var input = document.getElementById('contentname').value;
31
jeff0b65e352012-09-16 14:35:14 -070032 var _PEM_PRIVATE_KEY_STRING_ = keyManager.privateKey;
33 //document.getElementById('privateKey').value;
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070034 var rsa = new RSAKey();
35
36 rsa.readPrivateKeyFromPEMString(_PEM_PRIVATE_KEY_STRING_);
37
38 var hSig = rsa.signString(input, "sha256");
39
40 document.getElementById('result').innerHTML = hSig;
41
42 }
43 function verify(){
44 var input = document.getElementById('contentname').value;
45
46 var signature = document.getElementById('result').innerHTML;
jeff0b65e352012-09-16 14:35:14 -070047 var keyManager = new KeyManager();
48 var _PEM_X509CERT_STRING_ = keyManager.certificate;
49 //document.getElementById('certificate').value;
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070050 var x509 = new X509();
51
52 x509.readCertPEM(_PEM_X509CERT_STRING_);
53
54 var result = x509.subjectPublicKeyRSA.verifyString(input, signature);
55
56 if(result)
57 document.getElementById('result').innerHTML = 'SIGNATURE VALID';
58 else
59 document.getElementById('result').innerHTML = 'SIGNATURE INVALID';
60
61
62 }
63
64 </script>
65
66
67</head>
68<body >
69 <form>
70
71 <input id="privateKey" type="hidden" value="-----BEGIN RSA PRIVATE KEY-----
72 MIICWwIBAAKBgQDRhGF7X4A0ZVlEg594WmODVVUIiiPQs04aLmvfg8SborHss5gQ
73 Xu0aIdUT6nb5rTh5hD2yfpF2WIW6M8z0WxRhwicgXwi80H1aLPf6lEPPLvN29EhQ
74 NjBpkFkAJUbS8uuhJEeKw0cE49g80eBBF4BCqSL6PFQbP9/rByxdxEoAIQIDAQAB
75 AoGAA9/q3Zk6ib2GFRpKDLO/O2KMnAfR+b4XJ6zMGeoZ7Lbpi3MW0Nawk9ckVaX0
76 ZVGqxbSIX5Cvp/yjHHpww+QbUFrw/gCjLiiYjM9E8C3uAF5AKJ0r4GBPl4u8K4bp
77 bXeSxSB60/wPQFiQAJVcA5xhZVzqNuF3EjuKdHsw+dk+dPECQQDubX/lVGFgD/xY
78 uchz56Yc7VHX+58BUkNSewSzwJRbcueqknXRWwj97SXqpnYfKqZq78dnEF10SWsr
79 /NMKi+7XAkEA4PVqDv/OZAbWr4syXZNv/Mpl4r5suzYMMUD9U8B2JIRnrhmGZPzL
80 x23N9J4hEJ+Xh8tSKVc80jOkrvGlSv+BxwJAaTOtjA3YTV+gU7Hdza53sCnSw/8F
81 YLrgc6NOJtYhX9xqdevbyn1lkU0zPr8mPYg/F84m6MXixm2iuSz8HZoyzwJARi2p
82 aYZ5/5B2lwroqnKdZBJMGKFpUDn7Mb5hiSgocxnvMkv6NjT66Xsi3iYakJII9q8C
83 Ma1qZvT/cigmdbAh7wJAQNXyoizuGEltiSaBXx4H29EdXNYWDJ9SS5f070BRbAIl
84 dqRh3rcNvpY6BKJqFapda1DjdcncZECMizT/GMrc1w==
85 -----END RSA PRIVATE KEY-----"></input>
86
87
88 <input id="certificate" type="hidden" value="-----BEGIN CERTIFICATE-----
89 MIIBvTCCASYCCQD55fNzc0WF7TANBgkqhkiG9w0BAQUFADAjMQswCQYDVQQGEwJK
90 UDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwHhcNMTAwNTI4MDIwODUxWhcNMjAwNTI1
91 MDIwODUxWjAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwgZ8w
92 DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANGEYXtfgDRlWUSDn3haY4NVVQiKI9Cz
93 Thoua9+DxJuiseyzmBBe7Roh1RPqdvmtOHmEPbJ+kXZYhbozzPRbFGHCJyBfCLzQ
94 fVos9/qUQ88u83b0SFA2MGmQWQAlRtLy66EkR4rDRwTj2DzR4EEXgEKpIvo8VBs/
95 3+sHLF3ESgAhAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAEZ6mXFFq3AzfaqWHmCy1
96 ARjlauYAa8ZmUFnLm0emg9dkVBJ63aEqARhtok6bDQDzSJxiLpCEF6G4b/Nv/M/M
97 LyhP+OoOTmETMegAVQMq71choVJyOFE5BtQa6M/lCHEOya5QUfoRF2HF9EjRF44K
98 3OK+u3ivTSj3zwjtpudY5Xo=
99 -----END CERTIFICATE-----"></input>
100
101 Please Enter a Text to sign:<br /><input id="contentname" type="text" name="CONTENTNAME" value="/PARC/CCNX" /> <br />
102
103 </form>
104 <button onclick="sign()">Sign</button>
105 <button onclick="verify()">Verify</button>
106
107
108
109 <p id="result"></p>
110
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700111
112
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700113</body>
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700114
115</html>