A few comments and very minor fixes
diff --git a/js/PublisherPublicKeyDigest.js b/js/PublisherPublicKeyDigest.js
index adbc25c..a2a8234 100644
--- a/js/PublisherPublicKeyDigest.js
+++ b/js/PublisherPublicKeyDigest.js
@@ -30,6 +30,12 @@
//TODO check if the length of the PublisherPublicKeyDigest is correct ( Security reason)
+ if(LOG>4){
+ console.log('PublisherID.PUBLISHER_ID_LEN = ', PublisherID.PUBLISHER_ID_LEN);
+ console.log('PublisherPublicKeyDigest.length = ', PublisherPublicKeyDigest.length);
+ }
+
+
if (this.PublisherPublicKeyDigest.length != PublisherID.PUBLISHER_ID_LEN) {
console.log('LENGTH OF PUBLISHER ID IS WRONG!');
diff --git a/js/java_socket_bridge.js b/js/java_socket_bridge.js
index 3eccdfc..f0d745d 100644
--- a/js/java_socket_bridge.js
+++ b/js/java_socket_bridge.js
@@ -6,6 +6,7 @@
//var ccndAddr = unescape(%E0%A0%1E%099h%F9t%0C%E7%F46%1B%AB%F5%BB%05%A4%E5Z%AC%A5%E5%8Fs%ED%DE%B8%E0%13%AA%8F);
var ccndAddrHex = '%E0%A0%1E%099h%F9t%0C%E7%F46%1B%AB%F5%BB%05%A4%E5Z%AC%A5%E5%8Fs%ED%DE%B8%E0%13%AA%8F';
+//var LOG = 5;
var LOG = 5;
// Global variables
@@ -50,6 +51,11 @@
// Connect to a given url and port
//Error -1 No countent found
//Error -2 Empty query
+/**
+ * Sends an interest for the given prefix and returns the response (java_socket_bridge.js)
+ * @message the prefix to query for
+ * @return -1 if no content is found,-2 is the array is empty, the content otherwise
+ */
function queryPrefix(message){
if(ndnport!=null && ndnurl!=null){
var newMessage ='';
diff --git a/js/securityLib/rsa.js b/js/securityLib/rsa.js
index 6150003..66baa27 100644
--- a/js/securityLib/rsa.js
+++ b/js/securityLib/rsa.js
@@ -60,7 +60,10 @@
return new BigInteger(ba);
}
-// "empty" RSA key constructor
+/**
+ * "empty" RSA key constructor
+ * @returns {RSAKey}
+ */
function RSAKey() {
this.n = null;
this.e = 0;
@@ -72,7 +75,12 @@
this.coeff = null;
}
-// Set the public key fields N and e from hex strings
+/**
+ * Set the public key fields N and e from hex strings
+ * @param N
+ * @param E
+ * @returns {RSASetPublic}
+ */
function RSASetPublic(N,E) {
if(N != null && E != null && N.length > 0 && E.length > 0) {
this.n = parseBigInt(N,16);
@@ -82,12 +90,18 @@
alert("Invalid RSA public key");
}
-// Perform raw public operation on "x": return x^e (mod n)
+/**
+ * Perform raw public operation on "x": return x^e (mod n)
+ * @param x
+ * @returns x^e (mod n)
+ */
function RSADoPublic(x) {
return x.modPowInt(this.e, this.n);
}
-// Return the PKCS#1 RSA encryption of "text" as an even-length hex string
+/**
+ * Return the PKCS#1 RSA encryption of "text" as an even-length hex string
+ */
function RSAEncrypt(text) {
var m = pkcs1pad2(text,(this.n.bitLength()+7)>>3);
if(m == null) return null;
diff --git a/js/securityLib/sha1.js b/js/securityLib/sha1.js
index eb380c9..0e5b5b7 100644
--- a/js/securityLib/sha1.js
+++ b/js/securityLib/sha1.js
@@ -14,7 +14,7 @@
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
-/*
+/**
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
@@ -28,7 +28,7 @@
function any_hmac_sha1(k, d, e)
{ return rstr2any(rstr_hmac_sha1(str2rstr_utf8(k), str2rstr_utf8(d)), e); }
-/*
+/**
* Perform a simple self-test to see if the VM is working
*/
function sha1_vm_test()
@@ -36,7 +36,7 @@
return hex_sha1("abc").toLowerCase() == "a9993e364706816aba3e25717850c26c9cd0d89d";
}
-/*
+/**
* Calculate the SHA1 of a raw string
*/
function rstr_sha1(s)
@@ -44,7 +44,7 @@
return binb2rstr(binb_sha1(rstr2binb(s), s.length * 8));
}
-/*
+/**
* Calculate the HMAC-SHA1 of a key and some data (raw strings)
*/
function rstr_hmac_sha1(key, data)
@@ -63,7 +63,7 @@
return binb2rstr(binb_sha1(opad.concat(hash), 512 + 160));
}
-/*
+/**
* Convert a raw string to a hex string
*/
function rstr2hex(input)
@@ -81,7 +81,7 @@
return output;
}
-/*
+/**
* Convert a raw string to a base-64 string
*/
function rstr2b64(input)
@@ -104,7 +104,7 @@
return output;
}
-/*
+/**
* Convert a raw string to an arbitrary string encoding
*/
function rstr2any(input, encoding)
@@ -149,14 +149,14 @@
/* Append leading zero equivalents */
var full_length = Math.ceil(input.length * 8 /
- (Math.log(encoding.length) / Math.log(2)))
+ (Math.log(encoding.length) / Math.log(2)));
for(i = output.length; i < full_length; i++)
output = encoding[0] + output;
return output;
}
-/*
+/**
* Encode a string as utf-8.
* For efficiency, this assumes the input is valid utf-16.
*/
@@ -196,7 +196,7 @@
return output;
}
-/*
+/**
* Encode a string as utf-16
*/
function str2rstr_utf16le(input)
@@ -217,7 +217,7 @@
return output;
}
-/*
+/**
* Convert a raw string to an array of big-endian words
* Characters >255 have their high-byte silently ignored.
*/
@@ -231,7 +231,7 @@
return output;
}
-/*
+/**
* Convert an array of big-endian words to a string
*/
function binb2rstr(input)
@@ -242,7 +242,7 @@
return output;
}
-/*
+/**
* Calculate the SHA-1 of an array of big-endian words, and a bit length
*/
function binb_sha1(x, len)
@@ -289,7 +289,7 @@
}
-/*
+/**
* Perform the appropriate triplet combination function for the current
* iteration
*/
@@ -301,7 +301,7 @@
return b ^ c ^ d;
}
-/*
+/**
* Determine the appropriate additive constant for the current iteration
*/
function sha1_kt(t)
@@ -310,7 +310,7 @@
(t < 60) ? -1894007588 : -899497514;
}
-/*
+/**
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
@@ -321,7 +321,7 @@
return (msw << 16) | (lsw & 0xFFFF);
}
-/*
+/**
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt)
diff --git a/js/test-request-data.html b/js/test-request-data.html
index 704d133..0dd63b2 100644
--- a/js/test-request-data.html
+++ b/js/test-request-data.html
@@ -133,6 +133,7 @@
}
if(co.SignedInfo !=null && co.SignedInfo.Publisher!=null && co.SignedInfo.Publisher.PublisherPublicKeyDigest!=null){
+ output += "Publisher Public Key Digest: " + co.SignedInfo.Publisher.PublisherPublicKeyDigest + "<br />";
output += "Publisher Public Key Digest(hex): "+ toHex(co.SignedInfo.Publisher.PublisherPublicKeyDigest);
output+= "<br />";
@@ -207,6 +208,18 @@
var rsakey = new RSAKey();
rsakey.setPublic(kp,exp);
var result = rsakey.verifyString(input, signature);
+
+ var inputBis = toHex(co.Name).concat(toHex(co.SignedInfo), toHex(co.Content));
+
+// if(LOG>0){
+// console.log("Input: ", input);
+// console.log("Input bis: ", inputBis);
+// console.log("Verify input bis: ", rsakey.verifyString(inputBis, signature));
+// }
+
+ //var x509 = new X509();
+ //x509.readCertPEM(publickey);
+ //if(LOG>0) console.log("x509 verif: ", x509.subjectPublicKeyRSA.verifyString(input, signature));
if(result)
output += 'SIGNATURE VALID';