blob: 910b09b40b41700902581243ccfe754f8465251e [file] [log] [blame]
Meki Cherkaoui8f173612012-06-06 01:05:40 -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>
jeff7264ee12012-09-16 17:04:10 -07007 <title>NDN Image Parsing</title>
Meki Cherkaoui8f173612012-06-06 01:05:40 -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
11 <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
Jeff Thompsonbd829262012-11-30 22:28:37 -080085 Please Enter a Text to sign:<br /><input id="contentname" type="text" name="CONTENTNAME" value="/ndn/abc" /> <br />
Meki Cherkaoui8f173612012-06-06 01:05:40 -070086
87 </form>
88 <button onclick="sign()">Encode</button>
89 <button onclick="verify()">Parse</button>
90
91 <script type="text/javascript">
92
jeff7264ee12012-09-16 17:04:10 -070093 var srcString = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IAAAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1JREFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jqch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0vr4MkhoXe0rZigAAAABJRU5ErkJggg==';
Meki Cherkaoui8f173612012-06-06 01:05:40 -070094 var link = document.createElement('img');
jeff7264ee12012-09-16 17:04:10 -070095 link.setAttribute('src', srcString);
Meki Cherkaoui8f173612012-06-06 01:05:40 -070096
97 document.body.appendChild(link);
98
99</script>
100
101 <img src="data:image/png;base64,
102iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP
103C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA
104AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J
105REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq
106ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0
107vr4MkhoXe0rZigAAAABJRU5ErkJggg==" alt="Red dot" />
108
109 <p id="result"></p>
110
111</body>
112</html>