Added decodeSubjectPublicKeyInfo. In contentObjectToHtml, use decodeSubjectPublicKeyInfo and x509.readCertHex.
diff --git a/js/encoding/EncodingUtils.js b/js/encoding/EncodingUtils.js
index d35a8ad..d380e9f 100644
--- a/js/encoding/EncodingUtils.js
+++ b/js/encoding/EncodingUtils.js
@@ -110,6 +110,17 @@
}
+/*
+ * Decode the Uint8Array which holds SubjectPublicKeyInfo and return an RSAKey.
+ */
+function decodeSubjectPublicKeyInfo(array) {
+ var hex = DataUtils.toHex(array).toLowerCase();
+ var a = _x509_getPublicKeyHexArrayFromCertHex(hex, _x509_getSubjectPublicKeyPosFromCertHex(hex, 0));
+ var rsaKey = new RSAKey();
+ rsaKey.setPublic(a[0], a[1]);
+ return rsaKey;
+}
+
/* Return a user friendly HTML string with the contents of co.
This also outputs to console.log.
*/
@@ -169,37 +180,18 @@
output+= "<br />";
}
if(co.signedInfo!=null && co.signedInfo.locator!=null && co.signedInfo.locator.certificate!=null){
- var tmp = DataUtils.toString(co.signedInfo.locator.certificate);
- var publickey = rstr2b64(tmp);
- var publickeyHex = DataUtils.toHex(co.signedInfo.locator.certificate).toLowerCase();
- var publickeyString = DataUtils.toString(co.signedInfo.locator.certificate);
+ var certificateHex = DataUtils.toHex(co.signedInfo.locator.certificate).toLowerCase();
var signature = DataUtils.toHex(co.signature.signature).toLowerCase();
var input = DataUtils.toString(co.rawSignatureData);
- output += "DER Certificate: "+publickey ;
+ output += "Hex Certificate: "+ certificateHex ;
output+= "<br />";
output+= "<br />";
- if(LOG>2) console.log(" ContentName + SignedInfo + Content = "+input);
-
- if(LOG>2) console.log("HEX OF ContentName + SignedInfo + Content = ");
- if(LOG>2) console.log(DataUtils.stringtoBase64(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 is");
- if(LOG>2) console.log( 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.readCertHex(certificateHex);
- //x509.readCertPEMWithoutRSAInit(publickey);
-
var result = x509.subjectPublicKeyRSA.verifyByteArray(co.rawSignatureData, signature);
if(LOG>2) console.log('result is '+result);
@@ -212,35 +204,10 @@
if(LOG>2) console.log('EXPONENT e after is ');
if(LOG>2) console.log(e);
- /*var rsakey = new RSAKey();
-
- var kp = publickeyHex.slice(56,314);
-
- output += "PUBLISHER KEY(hex): "+kp ;
-
- output+= "<br />";
- output+= "<br />";
-
- console.log('kp is '+kp);
-
- var exp = publickeyHex.slice(318,324);
-
- console.log('kp size is '+kp.length );
- output += "exponent: "+exp ;
-
- output+= "<br />";
- output+= "<br />";
-
- console.log('exp is '+exp);
-
- rsakey.setPublic(kp,exp);
-
- var result = rsakey.verifyString(input, signature);*/
-
if(result)
- output += 'SIGNATURE VALID';
+ output += 'SIGNATURE VALID';
else
- output += 'SIGNATURE INVALID';
+ output += 'SIGNATURE INVALID';
//output += "VALID: "+ toHex(co.signedInfo.locator.publicKey);
@@ -250,19 +217,17 @@
//if(LOG>4) console.log('str'[1]);
}
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 += "Public key: " + publickeyHex;
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 );
@@ -271,53 +236,13 @@
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 rsakey = decodeSubjectPublicKeyInfo(co.signedInfo.locator.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 />";
-
- if(LOG>2) console.log('PUBLIC KEY IN HEX is ');
- if(LOG>2) console.log(kp);
-
- var exp = publickeyHex.slice(318,324);
-
- if(LOG>2) console.log('kp size is '+kp.length );
- output += "exponent: "+exp ;
-
- output+= "<br />";
- output+= "<br />";
-
- if(LOG>2) console.log('EXPONENT is ');
- if(LOG>2) 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);
-
+ output += "Public key (hex) modulus: " + rsakey.n.toString(16) + "<br/>";
+ output += "exponent: " + rsakey.e.toString(16) + "<br/>";
+ output += "<br/>";
+
var result = rsakey.verifyByteArray(co.rawSignatureData,signature);
// var result = rsakey.verifyString(input, signature);
@@ -343,3 +268,5 @@
return output;
}
+
+
diff --git a/js/tools/build/ndn-js-uncomp.js b/js/tools/build/ndn-js-uncomp.js
index 3ec855a..a7099c9 100644
--- a/js/tools/build/ndn-js-uncomp.js
+++ b/js/tools/build/ndn-js-uncomp.js
@@ -4359,6 +4359,17 @@
}
+/*
+ * Decode the Uint8Array which holds SubjectPublicKeyInfo and return an RSAKey.
+ */
+function decodeSubjectPublicKeyInfo(array) {
+ var hex = DataUtils.toHex(array).toLowerCase();
+ var a = _x509_getPublicKeyHexArrayFromCertHex(hex, _x509_getSubjectPublicKeyPosFromCertHex(hex, 0));
+ var rsaKey = new RSAKey();
+ rsaKey.setPublic(a[0], a[1]);
+ return rsaKey;
+}
+
/* Return a user friendly HTML string with the contents of co.
This also outputs to console.log.
*/
@@ -4418,37 +4429,18 @@
output+= "<br />";
}
if(co.signedInfo!=null && co.signedInfo.locator!=null && co.signedInfo.locator.certificate!=null){
- var tmp = DataUtils.toString(co.signedInfo.locator.certificate);
- var publickey = rstr2b64(tmp);
- var publickeyHex = DataUtils.toHex(co.signedInfo.locator.certificate).toLowerCase();
- var publickeyString = DataUtils.toString(co.signedInfo.locator.certificate);
+ var certificateHex = DataUtils.toHex(co.signedInfo.locator.certificate).toLowerCase();
var signature = DataUtils.toHex(co.signature.signature).toLowerCase();
var input = DataUtils.toString(co.rawSignatureData);
- output += "DER Certificate: "+publickey ;
+ output += "Hex Certificate: "+ certificateHex ;
output+= "<br />";
output+= "<br />";
- if(LOG>2) console.log(" ContentName + SignedInfo + Content = "+input);
-
- if(LOG>2) console.log("HEX OF ContentName + SignedInfo + Content = ");
- if(LOG>2) console.log(DataUtils.stringtoBase64(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 is");
- if(LOG>2) console.log( 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.readCertHex(certificateHex);
- //x509.readCertPEMWithoutRSAInit(publickey);
-
var result = x509.subjectPublicKeyRSA.verifyByteArray(co.rawSignatureData, signature);
if(LOG>2) console.log('result is '+result);
@@ -4461,35 +4453,10 @@
if(LOG>2) console.log('EXPONENT e after is ');
if(LOG>2) console.log(e);
- /*var rsakey = new RSAKey();
-
- var kp = publickeyHex.slice(56,314);
-
- output += "PUBLISHER KEY(hex): "+kp ;
-
- output+= "<br />";
- output+= "<br />";
-
- console.log('kp is '+kp);
-
- var exp = publickeyHex.slice(318,324);
-
- console.log('kp size is '+kp.length );
- output += "exponent: "+exp ;
-
- output+= "<br />";
- output+= "<br />";
-
- console.log('exp is '+exp);
-
- rsakey.setPublic(kp,exp);
-
- var result = rsakey.verifyString(input, signature);*/
-
if(result)
- output += 'SIGNATURE VALID';
+ output += 'SIGNATURE VALID';
else
- output += 'SIGNATURE INVALID';
+ output += 'SIGNATURE INVALID';
//output += "VALID: "+ toHex(co.signedInfo.locator.publicKey);
@@ -4499,19 +4466,17 @@
//if(LOG>4) console.log('str'[1]);
}
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 += "Public key: " + publickeyHex;
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 );
@@ -4520,57 +4485,13 @@
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 rsakey = decodeSubjectPublicKeyInfo(co.signedInfo.locator.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 />";
-
- if(LOG>2) console.log('PUBLIC KEY IN HEX is ');
- if(LOG>2) console.log(kp);
-
- var exp = publickeyHex.slice(318,324);
-
- if(LOG>2) console.log('kp size is '+kp.length );
- output += "exponent: "+exp ;
-
- output+= "<br />";
- output+= "<br />";
-
- if(LOG>2) console.log('EXPONENT is ');
- if(LOG>2) console.log(exp);
-
- var a = _x509_getPublicKeyHexArrayFromCertHex(publickeyHex, _x509_getSubjectPublicKeyPosFromCertHex(publickeyHex, 0));
- output += "a[0] " + a[0] + "<br/>";
- output += "a[1] " + a[1] + "<br/>";
-
- /*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);
-
+ output += "Public key (hex) modulus: " + rsakey.n.toString(16) + "<br/>";
+ output += "exponent: " + rsakey.e.toString(16) + "<br/>";
+ output += "<br/>";
+
var result = rsakey.verifyByteArray(co.rawSignatureData,signature);
// var result = rsakey.verifyString(input, signature);
diff --git a/js/tools/build/ndn-js.js b/js/tools/build/ndn-js.js
index c3f12d3..4e435c1 100644
--- a/js/tools/build/ndn-js.js
+++ b/js/tools/build/ndn-js.js
@@ -142,14 +142,13 @@
function encodeToBinaryInterest(a){var b=new BinaryXMLEncoder;a.to_ccnb(b);return b.getReducedOstream()}function encodeToHexContentObject(a){return DataUtils.toHex(encodeToBinaryContentObject(a))}function encodeToBinaryContentObject(a){var b=new BinaryXMLEncoder;a.to_ccnb(b);return b.getReducedOstream()}function encodeForwardingEntry(a){var b=new BinaryXMLEncoder;a.to_ccnb(b);return b.getReducedOstream()}
function decodeHexFaceInstance(a){a=DataUtils.toNumbers(a);decoder=new BinaryXMLDecoder(a);3<LOG&&console.log("DECODING HEX FACE INSTANCE \n"+a);a=new FaceInstance;a.from_ccnb(decoder);return a}function decodeHexInterest(a){a=DataUtils.toNumbers(a);decoder=new BinaryXMLDecoder(a);3<LOG&&console.log("DECODING HEX INTERST \n"+a);a=new Interest;a.from_ccnb(decoder);return a}
function decodeHexContentObject(a){a=DataUtils.toNumbers(a);decoder=new BinaryXMLDecoder(a);3<LOG&&console.log("DECODED HEX CONTENT OBJECT \n"+a);co=new ContentObject;co.from_ccnb(decoder);return co}function decodeHexForwardingEntry(a){a=DataUtils.toNumbers(a);decoder=new BinaryXMLDecoder(a);3<LOG&&console.log("DECODED HEX FORWARDING ENTRY \n"+a);forwardingEntry=new ForwardingEntry;forwardingEntry.from_ccnb(decoder);return forwardingEntry}
+function decodeSubjectPublicKeyInfo(a){var a=DataUtils.toHex(a).toLowerCase(),a=_x509_getPublicKeyHexArrayFromCertHex(a,_x509_getSubjectPublicKeyPosFromCertHex(a,0)),b=new RSAKey;b.setPublic(a[0],a[1]);return b}
function contentObjectToHtml(a){var b="";if(-1==a)b+="NO CONTENT FOUND";else if(-2==a)b+="CONTENT NAME IS EMPTY";else{null!=a.name&&null!=a.name.components&&(b+="NAME: "+a.name.to_uri(),b+="<br /><br />");null!=a.content&&(b+="CONTENT(ASCII): "+DataUtils.toString(a.content),b+="<br />",b+="<br />");null!=a.content&&(b+="CONTENT(hex): "+DataUtils.toHex(a.content),b+="<br />",b+="<br />");null!=a.signature&&null!=a.signature.signature&&(b+="SIGNATURE(hex): "+DataUtils.toHex(a.signature.signature),b+=
"<br />",b+="<br />");null!=a.signedInfo&&(null!=a.signedInfo.publisher&&null!=a.signedInfo.publisher.publisherPublicKeyDigest)&&(b+="Publisher Public Key Digest(hex): "+DataUtils.toHex(a.signedInfo.publisher.publisherPublicKeyDigest),b+="<br />",b+="<br />");if(null!=a.signedInfo&&null!=a.signedInfo.timestamp){var c=new Date;c.setTime(a.signedInfo.timestamp.msec);b+="TimeStamp: "+c;b+="<br />";b+="TimeStamp(number): "+a.signedInfo.timestamp.msec;b+="<br />"}null!=a.signedInfo&&null!=a.signedInfo.finalBlockID&&
-(b+="FinalBlockID: "+DataUtils.toHex(a.signedInfo.finalBlockID),b+="<br />");if(null!=a.signedInfo&&null!=a.signedInfo.locator&&null!=a.signedInfo.locator.certificate){var c=DataUtils.toString(a.signedInfo.locator.certificate),d=rstr2b64(c),e=DataUtils.toHex(a.signedInfo.locator.certificate).toLowerCase(),f=DataUtils.toString(a.signedInfo.locator.certificate),c=DataUtils.toHex(a.signature.signature).toLowerCase(),g=DataUtils.toString(a.rawSignatureData),b=b+("DER Certificate: "+d),b=b+"<br />",b=
-b+"<br />";2<LOG&&console.log(" ContentName + SignedInfo + Content = "+g);2<LOG&&console.log("HEX OF ContentName + SignedInfo + Content = ");2<LOG&&console.log(DataUtils.stringtoBase64(g));2<LOG&&console.log(" PublicKey = "+d);2<LOG&&console.log(" PublicKeyHex = "+e);2<LOG&&console.log(" PublicKeyString = "+f);2<LOG&&console.log(" Signature is");2<LOG&&console.log(c);e=new X509;e.readCertPEM(d);c=e.subjectPublicKeyRSA.verifyByteArray(a.rawSignatureData,c);2<LOG&&console.log("result is "+c);d=e.subjectPublicKeyRSA.n;
-e=e.subjectPublicKeyRSA.e;2<LOG&&console.log("PUBLIC KEY n after is ");2<LOG&&console.log(d);2<LOG&&console.log("EXPONENT e after is ");2<LOG&&console.log(e);b=c?b+"SIGNATURE VALID":b+"SIGNATURE INVALID";b+="<br />";b+="<br />"}null!=a.signedInfo&&(null!=a.signedInfo.locator&&null!=a.signedInfo.locator.publicKey)&&(d=rstr2b64(DataUtils.toString(a.signedInfo.locator.publicKey)),e=DataUtils.toHex(a.signedInfo.locator.publicKey).toLowerCase(),f=DataUtils.toString(a.signedInfo.locator.publicKey),c=DataUtils.toHex(a.signature.signature).toLowerCase(),
-g=DataUtils.toString(a.rawSignatureData),b+="DER Certificate: "+d,b+="<br />",b+="<br />",2<LOG&&console.log(" ContentName + SignedInfo + Content = "+g),2<LOG&&console.log(" PublicKey = "+d),2<LOG&&console.log(" PublicKeyHex = "+e),2<LOG&&console.log(" PublicKeyString = "+f),2<LOG&&console.log(" Signature "+c),2<LOG&&console.log(" Signature NOW IS"),2<LOG&&console.log(a.signature.signature),d=e.slice(56,314),b+="PUBLISHER KEY(hex): "+d,b+="<br />",b+="<br />",2<LOG&&console.log("PUBLIC KEY IN HEX is "),
-2<LOG&&console.log(d),f=e.slice(318,324),2<LOG&&console.log("kp size is "+d.length),b+="exponent: "+f,b+="<br />",b+="<br />",2<LOG&&console.log("EXPONENT is "),2<LOG&&console.log(f),e=_x509_getPublicKeyHexArrayFromCertHex(e,_x509_getSubjectPublicKeyPosFromCertHex(e,0)),b+="a[0] "+e[0]+"<br/>",b+="a[1] "+e[1]+"<br/>",e=new RSAKey,e.setPublic(d,f),c=e.verifyByteArray(a.rawSignatureData,c),2<LOG&&console.log("PUBLIC KEY n after is "),2<LOG&&console.log(e.n),2<LOG&&console.log("EXPONENT e after is "),
-2<LOG&&console.log(e.e),b=c?b+"SIGNATURE VALID":b+"SIGNATURE INVALID",b+="<br />",b+="<br />")}return b}
+(b+="FinalBlockID: "+DataUtils.toHex(a.signedInfo.finalBlockID),b+="<br />");if(null!=a.signedInfo&&null!=a.signedInfo.locator&&null!=a.signedInfo.locator.certificate){var d=DataUtils.toHex(a.signedInfo.locator.certificate).toLowerCase(),c=DataUtils.toHex(a.signature.signature).toLowerCase(),e=DataUtils.toString(a.rawSignatureData),b=b+("Hex Certificate: "+d),b=b+"<br />",b=b+"<br />",e=new X509;e.readCertHex(d);c=e.subjectPublicKeyRSA.verifyByteArray(a.rawSignatureData,c);2<LOG&&console.log("result is "+
+c);d=e.subjectPublicKeyRSA.n;e=e.subjectPublicKeyRSA.e;2<LOG&&console.log("PUBLIC KEY n after is ");2<LOG&&console.log(d);2<LOG&&console.log("EXPONENT e after is ");2<LOG&&console.log(e);b=c?b+"SIGNATURE VALID":b+"SIGNATURE INVALID";b+="<br />";b+="<br />"}if(null!=a.signedInfo&&null!=a.signedInfo.locator&&null!=a.signedInfo.locator.publicKey){var d=DataUtils.toHex(a.signedInfo.locator.publicKey).toLowerCase(),f=DataUtils.toString(a.signedInfo.locator.publicKey),c=DataUtils.toHex(a.signature.signature).toLowerCase(),
+e=DataUtils.toString(a.rawSignatureData),b=b+("Public key: "+d),b=b+"<br />",b=b+"<br />";2<LOG&&console.log(" ContentName + SignedInfo + Content = "+e);2<LOG&&console.log(" PublicKeyHex = "+d);2<LOG&&console.log(" PublicKeyString = "+f);2<LOG&&console.log(" Signature "+c);2<LOG&&console.log(" Signature NOW IS");2<LOG&&console.log(a.signature.signature);e=decodeSubjectPublicKeyInfo(a.signedInfo.locator.publicKey);b+="Public key (hex) modulus: "+e.n.toString(16)+"<br/>";b+="exponent: "+e.e.toString(16)+
+"<br/>";b+="<br/>";c=e.verifyByteArray(a.rawSignatureData,c);2<LOG&&console.log("PUBLIC KEY n after is ");2<LOG&&console.log(e.n);2<LOG&&console.log("EXPONENT e after is ");2<LOG&&console.log(e.e);b=c?b+"SIGNATURE VALID":b+"SIGNATURE INVALID";b+="<br />";b+="<br />"}}return b}
var KeyManager=function(){this.certificate="MIIBmzCCAQQCCQC32FyQa61S7jANBgkqhkiG9w0BAQUFADASMRAwDgYDVQQDEwdheGVsY2R2MB4XDTEyMDQyODIzNDQzN1oXDTEyMDUyODIzNDQzN1owEjEQMA4GA1UEAxMHYXhlbGNkdjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA4X0wp9goqxuECxdULcr2IHr9Ih4Iaypg0Wy39URIup8/CLzQmdsh3RYqd55hqonu5VTTpH3iMLx6xZDVJAZ8OJi7pvXcQ2C4Re2kjL2c8SanI0RfDhlS1zJadfr1VhRPmpivcYawJ4aFuOLAi+qHFxtN7lhcGCgpW1OV60oXd58CAwEAATANBgkqhkiG9w0BAQUFAAOBgQDLOrA1fXzSrpftUB5Ro6DigX1Bjkf7F5Bkd69hSVp+jYeJFBBlsILQAfSxUZPQtD+2Yc3iCmSYNyxqu9PcufDRJlnvB7PG29+L3y9lR37tetzUV9eTscJ7rdp8Wt6AzpW32IJ/54yKNfP7S6ZIoIG+LP6EIxq6s8K1MXRt8uBJKw==";this.publicKey=
"30819F300D06092A864886F70D010101050003818D0030818902818100E17D30A7D828AB1B840B17542DCAF6207AFD221E086B2A60D16CB7F54448BA9F3F08BCD099DB21DD162A779E61AA89EEE554D3A47DE230BC7AC590D524067C3898BBA6F5DC4360B845EDA48CBD9CF126A723445F0E1952D7325A75FAF556144F9A98AF7186B0278685B8E2C08BEA87171B4DEE585C1828295B5395EB4A17779F0203010001";this.privateKey="MIICXQIBAAKBgQDhfTCn2CirG4QLF1QtyvYgev0iHghrKmDRbLf1REi6nz8IvNCZ2yHdFip3nmGqie7lVNOkfeIwvHrFkNUkBnw4mLum9dxDYLhF7aSMvZzxJqcjRF8OGVLXMlp1+vVWFE+amK9xhrAnhoW44sCL6ocXG03uWFwYKClbU5XrShd3nwIDAQABAoGAGkv6T6jC3WmhFZYL6CdCWvlc6gysmKrhjarrLTxgavtFY6R5g2ft5BXAsCCVbUkWxkIFSKqxpVNl0gKZCNGEzPDN6mHJOQI/h0rlxNIHAuGfoAbCzALnqmyZivhJAPGijAyKuU9tczsst5+Kpn+bn7ehzHQuj7iwJonS5WbojqECQQD851K8TpW2GrRizNgG4dx6orZxAaon/Jnl8lS7soXhllQty7qG+oDfzznmdMsiznCqEABzHUUKOVGE9RWPN3aRAkEA5D/w9N55d0ibnChFJlc8cUAoaqH+w+U3oQP2Lb6AZHJpLptN4y4b/uf5d4wYU5/i/gC7SSBH3wFhh9bjRLUDLwJAVOx8vN0Kqt7myfKNbCo19jxjVSlA8TKCn1Oznl/BU1I+rC4oUaEW25DjmX6IpAR8kq7S59ThVSCQPjxqY/A08QJBAIRaF2zGPITQk3r/VumemCvLWiRK/yG0noc9dtibqHOWbCtcXtOm/xDWjq+lis2i3ssOvYrvrv0/HcDY+Dv1An0CQQCLJtMsfSg4kvG/FRY5UMhtMuwo8ovYcMXt4Xv/LWaMhndD67b2UGawQCRqr5ghRTABWdDD/HuuMBjrkPsX0861"};
KeyManager.prototype.verify=function(a,b){var c=this.certificate,d=new X509;d.readCertPEM(c);return d.subjectPublicKeyRSA.verifyString(a,b)};KeyManager.prototype.sign=function(a){var b=this.privateKey,c=new RSAKey;c.readPrivateKeyFromPEMString(b);return c.signString(a,"sha256")};var globalKeyManager=new KeyManager,hexcase=0,b64pad="";function hex_sha256_from_bytes(a){return rstr2hex(binb2rstr(binb_sha256(byteArray2binb(a),8*a.length)))}