blob: 5d39f6f74c8448607a10cc5d5fb6eb4f3f8b218b [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>
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 Cherkaoui8f173612012-06-06 01:05:40 -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 Cherkaoui8f173612012-06-06 01:05:40 -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>
Meki Cherkaoui8f173612012-06-06 01:05:40 -070024
25
26 <script type="text/javascript">
27 function sign(){
28
29 var input = document.getElementById('contentname').value;
30
31 var _PEM_PRIVATE_KEY_STRING_ = document.getElementById('privateKey').value;
32
33 var rsa = new RSAKey();
34
35 rsa.readPrivateKeyFromPEMString(_PEM_PRIVATE_KEY_STRING_);
36
37 var hSig = rsa.signString(input, "sha256");
38
39 document.getElementById('result').innerHTML = hSig;
40
41 }
42 function verify(){
43 var input = document.getElementById('contentname').value;
44
45 var signature = document.getElementById('result').innerHTML;
46
47 var _PEM_X509CERT_STRING_ = document.getElementById('certificate').value;
48
49 var x509 = new X509();
50
51 x509.readCertPEM(_PEM_X509CERT_STRING_);
52
53 var result = x509.subjectPublicKeyRSA.verifyString(input, signature);
54
55 if(result)
56 document.getElementById('result').innerHTML = 'SIGNATURE VALID';
57 else
58 document.getElementById('result').innerHTML = 'SIGNATURE INVALID';
59
60
61 }
62
63 </script>
64
65
66</head>
67<body >
68 <form>
69
70 <input id="privateKey" type="hidden" value="-----BEGIN RSA PRIVATE KEY-----
71 MIICWwIBAAKBgQDRhGF7X4A0ZVlEg594WmODVVUIiiPQs04aLmvfg8SborHss5gQ
72 Xu0aIdUT6nb5rTh5hD2yfpF2WIW6M8z0WxRhwicgXwi80H1aLPf6lEPPLvN29EhQ
73 NjBpkFkAJUbS8uuhJEeKw0cE49g80eBBF4BCqSL6PFQbP9/rByxdxEoAIQIDAQAB
74 AoGAA9/q3Zk6ib2GFRpKDLO/O2KMnAfR+b4XJ6zMGeoZ7Lbpi3MW0Nawk9ckVaX0
75 ZVGqxbSIX5Cvp/yjHHpww+QbUFrw/gCjLiiYjM9E8C3uAF5AKJ0r4GBPl4u8K4bp
76 bXeSxSB60/wPQFiQAJVcA5xhZVzqNuF3EjuKdHsw+dk+dPECQQDubX/lVGFgD/xY
77 uchz56Yc7VHX+58BUkNSewSzwJRbcueqknXRWwj97SXqpnYfKqZq78dnEF10SWsr
78 /NMKi+7XAkEA4PVqDv/OZAbWr4syXZNv/Mpl4r5suzYMMUD9U8B2JIRnrhmGZPzL
79 x23N9J4hEJ+Xh8tSKVc80jOkrvGlSv+BxwJAaTOtjA3YTV+gU7Hdza53sCnSw/8F
80 YLrgc6NOJtYhX9xqdevbyn1lkU0zPr8mPYg/F84m6MXixm2iuSz8HZoyzwJARi2p
81 aYZ5/5B2lwroqnKdZBJMGKFpUDn7Mb5hiSgocxnvMkv6NjT66Xsi3iYakJII9q8C
82 Ma1qZvT/cigmdbAh7wJAQNXyoizuGEltiSaBXx4H29EdXNYWDJ9SS5f070BRbAIl
83 dqRh3rcNvpY6BKJqFapda1DjdcncZECMizT/GMrc1w==
84 -----END RSA PRIVATE KEY-----"></input>
85
86
87 <input id="certificate" type="hidden" value="-----BEGIN CERTIFICATE-----
88 MIIBvTCCASYCCQD55fNzc0WF7TANBgkqhkiG9w0BAQUFADAjMQswCQYDVQQGEwJK
89 UDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwHhcNMTAwNTI4MDIwODUxWhcNMjAwNTI1
90 MDIwODUxWjAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwgZ8w
91 DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANGEYXtfgDRlWUSDn3haY4NVVQiKI9Cz
92 Thoua9+DxJuiseyzmBBe7Roh1RPqdvmtOHmEPbJ+kXZYhbozzPRbFGHCJyBfCLzQ
93 fVos9/qUQ88u83b0SFA2MGmQWQAlRtLy66EkR4rDRwTj2DzR4EEXgEKpIvo8VBs/
94 3+sHLF3ESgAhAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAEZ6mXFFq3AzfaqWHmCy1
95 ARjlauYAa8ZmUFnLm0emg9dkVBJ63aEqARhtok6bDQDzSJxiLpCEF6G4b/Nv/M/M
96 LyhP+OoOTmETMegAVQMq71choVJyOFE5BtQa6M/lCHEOya5QUfoRF2HF9EjRF44K
97 3OK+u3ivTSj3zwjtpudY5Xo=
98 -----END CERTIFICATE-----"></input>
99
100 Please Enter a Text to sign:<br /><input id="contentname" type="text" name="CONTENTNAME" value="/PARC/CCNX" /> <br />
101
102 </form>
103 <button onclick="sign()">Encode</button>
104 <button onclick="verify()">Parse</button>
105
106 <script type="text/javascript">
107
jeff7264ee12012-09-16 17:04:10 -0700108 var srcString = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IAAAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1JREFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jqch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0vr4MkhoXe0rZigAAAABJRU5ErkJggg==';
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700109 var link = document.createElement('img');
jeff7264ee12012-09-16 17:04:10 -0700110 link.setAttribute('src', srcString);
Meki Cherkaoui8f173612012-06-06 01:05:40 -0700111
112 document.body.appendChild(link);
113
114</script>
115
116 <img src="data:image/png;base64,
117iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP
118C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA
119AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J
120REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq
121ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0
122vr4MkhoXe0rZigAAAABJRU5ErkJggg==" alt="Red dot" />
123
124 <p id="result"></p>
125
126</body>
127</html>