blob: 025d06569139f369b81a41707b9584995fa13412 [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">
Jeff Burke92dd8e42012-12-08 11:40:31 -08004<!--
5 See COPYING for copyright and distribution information.
6-->
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -07007<html xmlns = "http://www.w3.org/1999/xhtml">
8
9<head>
jeff0b65e352012-09-16 14:35:14 -070010 <title>NDN Signature - String</title>
Jeff Thompson38422f42012-11-15 00:20:39 -080011
12 <script type="text/javascript" src="../Helper.js"></script>
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070013
14 <script type="text/javascript">
15 function sign(){
Meki Cherkaoui8f173612012-06-06 01:05:40 -070016 var keyManager = new KeyManager();
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070017 var input = document.getElementById('contentname').value;
18
jeff0b65e352012-09-16 14:35:14 -070019 var _PEM_PRIVATE_KEY_STRING_ = keyManager.privateKey;
20 //document.getElementById('privateKey').value;
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070021 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;
jeff0b65e352012-09-16 14:35:14 -070034 var keyManager = new KeyManager();
35 var _PEM_X509CERT_STRING_ = keyManager.certificate;
36 //document.getElementById('certificate').value;
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070037 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
Jeff Thompsonbd829262012-11-30 22:28:37 -080088 Please Enter a Text to sign:<br /><input id="contentname" type="text" name="CONTENTNAME" value="/ndn/abc" /> <br />
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -070089
90 </form>
91 <button onclick="sign()">Sign</button>
92 <button onclick="verify()">Verify</button>
93
94
95
96 <p id="result"></p>
97
Meki Cherkaoui8f173612012-06-06 01:05:40 -070098
99
Meki Cherkaoui88d59cd2012-05-14 07:34:58 -0700100</body>
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700101
102</html>