Uncomitted stuff from the previous commit
diff --git a/js/PublisherPublicKeyDigest.js b/js/PublisherPublicKeyDigest.js
index 92dec39..adbc25c 100644
--- a/js/PublisherPublicKeyDigest.js
+++ b/js/PublisherPublicKeyDigest.js
@@ -4,24 +4,39 @@
*/
var PublisherPublicKeyDigest = function PublisherPublicKeyDigest(_pkd){
- if( typeof _pkd == "ByteArray") this.PublisherPublicKeyDigest = _pkd; // Byte Array
- else if( typeof _pkd == "PublicKey") ;//TODO...
+
+ this.PUBLISHER_ID_LEN = 256/8;
+
+ this.PublisherPublicKeyDigest = _pkd;
+ //if( typeof _pkd == "object") this.PublisherPublicKeyDigest = _pkd; // Byte Array
+ //else if( typeof _pkd == "PublicKey") ;//TODO...
+
+
};
+
+
+
PublisherPublicKeyDigest.prototype.decode = function( decoder) {
this.PublisherPublicKeyDigest = decoder.readBinaryElement(this.getElementLabel());
+
+ if(LOG>4)console.log('Publisher public key digest is ' + this.PublisherPublicKeyDigest);
+
if (null == this.PublisherPublicKeyDigest) {
throw new Exception("Cannot parse publisher key digest.");
}
//TODO check if the length of the PublisherPublicKeyDigest is correct ( Security reason)
- /*if (this.PublisherPublicKeyDigest.length != PublisherID.PUBLISHER_ID_LEN) {
- console.log('SHOULD NOT GO HERE !!!!!!!!!!!!!!!!!!');
- this.PublisherPublicKeyDigest = new PublisherPublicKeyDigest(this.PublisherPublicKeyDigest).PublisherKeyDigest;
- }*/
+ if (this.PublisherPublicKeyDigest.length != PublisherID.PUBLISHER_ID_LEN) {
+
+ console.log('LENGTH OF PUBLISHER ID IS WRONG!');
+
+ //this.PublisherPublicKeyDigest = new PublisherPublicKeyDigest(this.PublisherPublicKeyDigest).PublisherKeyDigest;
+
+ }
};
PublisherPublicKeyDigest.prototype.encode= function( encoder) {
@@ -29,8 +44,8 @@
/*if (!this.validate()) {
throw new Exception("Cannot encode : field values missing.");
}*/
-
- if (this.PublisherKeyDigest!=null)this.encoder.writeElement(this.getElementLabel(), this.PublisherKeyDigest);
+ if(LOG>3) console.log('PUBLISHER KEY DIGEST IS'+this.PublisherPublicKeyDigest);
+ encoder.writeElement(this.getElementLabel(), this.PublisherPublicKeyDigest);
};
PublisherPublicKeyDigest.prototype.getElementLabel = function() { return CCNProtocolDTags.PublisherPublicKeyDigest; };