blob: 6910e7cd106d6cbb323fb0d5e1a226a458699b1d [file] [log] [blame]
<?xml version = "1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>NDN Decode Interest + Face Instance</title>
<script type="text/javascript" src="java_socket_bridge.js"></script>
<script type="text/javascript" src="CCNProtocolDTags.js"></script>
<script type="text/javascript" src="CCNTime.js"></script>
<script type="text/javascript" src="ContentName.js"></script>
<script type="text/javascript" src="ContentObject.js"></script>
<script type="text/javascript" src="DateFormat.js"></script>
<script type="text/javascript" src="Exclude.js"></script>
<script type="text/javascript" src="ExcludeAny.js"></script>
<script type="text/javascript" src="ExcludeComponent.js"></script>
<script type="text/javascript" src="Interest.js"></script>
<script type="text/javascript" src="KeyLocator.js"></script>
<script type="text/javascript" src="KeyName.js"></script>
<script type="text/javascript" src="PublisherID.js"></script>
<script type="text/javascript" src="Signature.js"></script>
<script type="text/javascript" src="SignedInfo.js"></script>
<script type="text/javascript" src="PublisherPublicKeyDigest.js"></script>
<script type="text/javascript" src="FaceInstance.js"></script>
<script type="text/javascript" src="ForwardingEntry.js"></script>
<script type="text/javascript" src="encoding/BinaryXMLEncoder.js"></script>
<script type="text/javascript" src="encoding/BinaryXMLCodec.js"></script>
<script type="text/javascript" src="encoding/BinaryXMLDecoder.js"></script>
<script type="text/javascript" src="encoding/DataUtils.js"></script>
<script type="text/javascript" src="encoding/EncodingUtils.js"></script>
<script language="JavaScript" type="text/javascript" src="security/KeyManager.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/jsbn.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/jsbn2.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/rsa.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/rsa2.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/sha1.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/sha256.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/sha512.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/md5.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/ripemd160.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/base64.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/rsapem-1.1.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/rsasign-1.2.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/asn1hex-1.1.js"></script>
<script language="JavaScript" type="text/javascript" src="securityLib/x509-1.1.js"></script>
<script type="text/javascript">
function decode(){
var input = document.getElementById('result').innerHTML;
var interest = decodeHexInterest(input);
if(LOG>3)console.log('INTEREST DECODED');
if(LOG>3)console.log(interest);
///////////////////////////////////////
var output ="";
if(interest.Name!=null && interest.Name.Components!=null){
output+= "NAME: ";
for(var i=0;i<interest.Name.Components.length;i++){
output+= "/"+ DataUtils.toString(interest.Name.Components[i]);
}
output+= "<br />";
output+= "<br />";
}
if(interest.FaceInstance!=null ){
output+= "FaceInstance: ";
output+= interest.FaceInstance;
output+= "<br />";
output+= "<br />";
}
if(interest.Exclude!=null ){
output+= "Exclude: ";
output+= interest.Exclude;
output+= "<br />";
output+= "<br />";
}
if(interest.ChildSelector!=null ){
output+= "ChildSelector: ";
output+= interest.ChildSelector;
output+= "<br />";
output+= "<br />";
}
if(interest.AnswerOriginKind!=null ){
output+= "AnswerOriginKind: ";
output+= interest.AnswerOriginKind;
output+= "<br />";
output+= "<br />";
}
if(interest.InterestLifetime!=null ){
output+= "InterestLifetime: ";
output+= interest.InterestLifetime;
output+= "<br />";
output+= "<br />";
}
if(interest.Nonce!=null ){
output+= "Nonce: ";
output+= interest.Nonce;
output+= "<br />";
output+= "<br />";
}
if(interest.Scope!=null ){
output+= "SCOPE: ";
output+= interest.Scope;
output+= "<br />";
output+= "<br />";
}
if(interest.PublisherID!=null ){
output+= "PUBLISHER ID: ";
output+= interest.PublisherID.PublisherID;
output+= "PUBLISHER ID TYPE: ";
output+= interest.PublisherID.PublisherType;
output+= "<br />";
output+= "<br />";
}
if(interest.MaxSuffixComponents!=null ){
output+= "MaxSuffixComponents : ";
output+= interest.MaxSuffixComponents;
output+= "<br />";
output+= "<br />";
}
if(interest.MinSuffixComponents!=null ){
output+= "MinSuffixComponents : ";
output+= interest.MinSuffixComponents;
output+= "<br />";
output+= "<br />";
}
if(interest.MinSuffixComponents!=null ){
output+= "MinSuffixComponents : ";
output+= interest.MinSuffixComponents;
output+= "<br />";
output+= "<br />";
}
if(interest.Name.Components[3] !=null){
var input = DataUtils.toHex(interest.Name.Components[3]) ;
var contentObject = decodeHexContentObject(input);
if(contentObject.Content!=null ){
output+= "Content of content Object: ";
output+= DataUtils.toHex(contentObject.Content);
output+= "<br />";
output+= "<br />";
}
var content = DataUtils.toHex(contentObject.Content);
var co = contentObject;
////////////////////////////////////////
if(co.Name!=null && co.Name.Components!=null){
output+= "NAME: ";
for(var i=0;i<co.Name.Components.length;i++){
output+= "/"+ DataUtils.toString(co.Name.Components[i]);
}
output+= "<br />";
output+= "<br />";
}
if(co.Content !=null){
output += "CONTENT(ASCII): "+ DataUtils.toString(co.Content);
output+= "<br />";
output+= "<br />";
}
if(co.Content !=null){
output += "CONTENT(hex): "+ DataUtils.toHex(co.Content);
output+= "<br />";
output+= "<br />";
}
if(co.Signature !=null && co.Signature.Signature!=null){
output += "SIGNATURE(hex): "+ DataUtils.toHex(co.Signature.Signature);
output+= "<br />";
output+= "<br />";
}
if(co.SignedInfo !=null && co.SignedInfo.Publisher!=null && co.SignedInfo.Publisher.PublisherPublicKeyDigest!=null){
output += "Publisher Public Key Digest(hex): "+ DataUtils.toHex(co.SignedInfo.Publisher.PublisherPublicKeyDigest);
output+= "<br />";
output+= "<br />";
}
if(co.SignedInfo !=null && co.SignedInfo.Timestamp!=null){
var d = new Date();
d.setTime( co.SignedInfo.Timestamp.msec );
var bytes = [217, 185, 12, 225, 217, 185, 12, 225];
output += "TimeStamp: "+d;
output+= "<br />";
output += "TimeStamp(number): "+ co.SignedInfo.Timestamp.msec;
output+= "<br />";
}
if(co.SignedInfo !=null && co.SignedInfo.Type!=null){
output += "Type: "+co.SignedInfo.Type;
output+= "<br />";
output+= "<br />";
}
if(co.SignedInfo !=null && co.SignedInfo.Locator!=null){
output += "Locator: "+co.SignedInfo.Locator.Type;
output+= "<br />";
output+= "<br />";
}
if(co.SignedInfo !=null && co.SignedInfo.FreshnessSeconds!=null){
output += "FreshnessSeconds: "+co.SignedInfo.FreshnessSeconds;
output+= "<br />";
output+= "<br />";
}
if(co.SignedInfo !=null && co.SignedInfo.FinalBlockID!=null){
output += "FinalBlockID: "+co.SignedInfo.FinalBlockID;
output+= "<br />";
output+= "<br />";
}
if(co.SignedInfo!=null && co.SignedInfo.Locator!=null && co.SignedInfo.Locator.PublicKey!=null){
var publickey = rstr2b64(DataUtils.toString(co.SignedInfo.Locator.PublicKey));
var publickeyHex = DataUtils.toHex(co.SignedInfo.Locator.PublicKey).toLowerCase();
var publickeyString = DataUtils.toString(co.SignedInfo.Locator.PublicKey);
var signature = DataUtils.toHex(co.Signature.Signature).toLowerCase();
var input = DataUtils.toString(co.rawSignatureData);
output += "DER Certificate: "+publickey ;
output+= "<br />";
output+= "<br />";
if(LOG>2) console.log(" ContentName + SignedInfo + Content = "+input);
if(LOG>2) console.log(" PublicKey = "+publickey );
if(LOG>2) console.log(" PublicKeyHex = "+publickeyHex );
if(LOG>2) console.log(" PublicKeyString = "+publickeyString );
if(LOG>2) console.log(" Signature "+signature );
if(LOG>2) console.log(" Signature NOW IS" );
if(LOG>2) console.log(co.Signature.Signature);
/*var x509 = new X509();
x509.readCertPEM(publickey);
//x509.readCertPEMWithoutRSAInit(publickey);
var result = x509.subjectPublicKeyRSA.verifyString(input, signature);*/
//console.log('result is '+result);
var kp = publickeyHex.slice(56,314);
output += "PUBLISHER KEY(hex): "+kp ;
output+= "<br />";
output+= "<br />";
console.log('PUBLIC KEY IN HEX is ');
console.log(kp);
var exp = publickeyHex.slice(318,324);
console.log('kp size is '+kp.length );
output += "exponent: "+exp ;
output+= "<br />";
output+= "<br />";
console.log('EXPONENT is ');
console.log(exp);
/*var c1 = hex_sha256(input);
var c2 = signature;
if(LOG>4)console.log('input is ');
if(LOG>4)console.log(input);
if(LOG>4)console.log('C1 is ');
if(LOG>4)console.log(c1);
if(LOG>4)console.log('C2 is ');
if(LOG>4)console.log(c2);
var result = c1 == c2;*/
var rsakey = new RSAKey();
rsakey.setPublic(kp,exp);
var result = rsakey.verifyString(input, signature);
console.log('PUBLIC KEY n after is ');
console.log(rsakey.n);
console.log('EXPONENT e after is ');
console.log(rsakey.e);
if(result)
output += 'SIGNATURE VALID';
else
output += 'SIGNATURE INVALID';
//output += "VALID: "+ toHex(co.SignedInfo.Locator.PublicKey);
output+= "<br />";
output+= "<br />";
//if(LOG>4) console.log('str'[1]);
}
////////////////////////////////////////
var forwardingEntry = decodeHexForwardingEntry(content);
if(LOG>3)console.log('FORWARDING ENTRY IS PRESENT');
if(LOG>3)console.log(forwardingEntry);
///////////////////////////////////////
//var output ="";
if(forwardingEntry.Action!=null ){
output+= "Action: ";
output+= DataUtils.toHex(forwardingEntry.Action);
output+= "<br />";
output+= "<br />";
}
if(forwardingEntry.PrefixName!=null){
output+= "PrefixName: ";
output+= forwardingEntry.PrefixName.getName();
output+= "<br />";
}
if(forwardingEntry.CCNID!=null){
output+= "CCNID: ";
output+= forwardingEntry.CCNID;
output+= "<br />";
}
if(forwardingEntry.Flags!=null){
output+= "Flags: ";
output+= forwardingEntry.Flags;
output+= "<br />";
}
if(forwardingEntry.Lifetime!=null){
output+= "Lifetime: ";
output+= forwardingEntry.Lifetime;
output+= "<br />";
}
}
document.getElementById('result').innerHTML = output;
}
</script>
</head>
<body >
<form>
Please Press decode:<br />
</form>
<button onclick="decode()">Decode</button>
<!-- p id="result-old-from-ccnx">01d2f2faa563636e7800fa0285e0a01e093968f9740ce7f4361babf5bb05a4e55aaca5e58f73eddeb8e013aa8f00fabd73656c6672656700fa1bf5048202aa03b208854a18988c72aee624da28e2e1acbccb209b8e89429041985521ed68f95a1c546872fba3d854b1377dc249b6d8ec5935e5069256c97a7f6d8a62e86222ccd2cfe5097aed3fe5ede6732ce191a8680d78e39d0c5058a2b7bb0f0687994e9f045de346b66c46498547a08da1f2f0cdfafba3afdfe7107931935ede79040137ba94a90000f20001a203e202851a4860caa4991e829bcdc9429fb711d52440968d23560726606050bf147acffc0002bab504fcb3f03aa40001e201da0a9530819f300d06092a864886f70d010101050003818d00308189028181008ed27580e3d1c4c67672208665133a1ba12d8ebf5cad8e054571926b3ff0782a04c71703384021a6cefb6616b66cbd8a679b761d69d6373a851546e26f7105510b4c23be9a3c7f2e652e100ecc1471855730659f1477ce4e8504ad1fd8f44116baaeae2ff67eec33abba790157a79bf5039e5a528a471d9d67c94e70117ed7490203010001000000019a0585058a04cabe73656c6672656700f2faad726f63636f000003e20285e0a01e093968f9740ce7f4361babf5bb05a4e55aaca5e58f73eddeb8e013aa8f0004fa8e330003d2d63231343734383336343700000000000002d28e310000</p-->
<p id="result">01d2f2faa563636e7800fa0285e0a01e093968f9740ce7f4361babf5bb05a4e55aaca5e58f73eddeb8e013aa8f00facd70726566697872656700fa29ad048202aa03b208854ddbf69779cdf4ef74be99474478c8bc3ca0873e0ffa1fa60120aa276db122b83404e595a8a3caeaf09630276658ba4e7beaadb4b91a8cc58e19ac4a42289507ed8d609aa9bef61a5a507f349c83d2944b8c16fecfd90d4a40ddb8687592c0a57517564235b2e359db54f51a37e1ac39e518a2196e3ffda7eb2fb301f3c404dd0000f20001a203e20285ef7c4f5d4743a8b8586ea2e741b7fc39d1dc0dbe1b1930e787cfd1d833ea7a610002bab504fce9e253d70001e2018219fd3082019b30820104020900b7d85c906bad52ee300d06092a864886f70d010105050030123110300e060355040313076178656c636476301e170d3132303432383233343433375a170d3132303532383233343433375a30123110300e060355040313076178656c63647630819f300d06092a864886f70d010101050003818d0030818902818100e17d30a7d828ab1b840b17542dcaf6207afd221e086b2a60d16cb7f54448ba9f3f08bcd099db21dd162a779e61aa89eee554d3a47de230bc7ac590d524067c3898bba6f5dc4360b845eda48cbd9cf126a723445f0e1952d7325a75faf556144f9a98af7186b0278685b8e2c08bea87171b4dee585c1828295b5395eb4a17779f0203010001300d06092a864886f70d010105050003818100cb3ab0357d7cd2ae97ed501e51a3a0e2817d418e47fb17906477af61495a7e8d8789141065b082d001f4b15193d0b43fb661cde20a6498372c6abbd3dcb9f0d12659ef07b3c6dbdf8bdf2f65477eed7adcd457d793b1c27badda7c5ade80ce95b7d8827fe78c8a35f3fb4ba648a081be2cfe84231abab3c2b531746df2e0492b000000019a02d5058a04cabe73656c6672656700f2faa56d656b69000004fa8e330003d2d63231343734383336343700000000000002d28e310000</p>
</body>
</html>