Permalink
Browse files

Bugfixing

  • Loading branch information...
1 parent 42fe0a3 commit 8f0dd8e2c4cad80568e86929b97b55e531c11695 @cdauth committed Nov 5, 2012
Showing with 140 additions and 76 deletions.
  1. +3 −0 bufferedStream.js
  2. +42 −2 fifo.js
  3. +19 −27 keyring.js
  4. +42 −25 keyringFile.js
  5. +6 −5 keyringFilters.js
  6. +7 −11 packets.js
  7. +6 −3 signing.js
  8. +15 −3 utils.js
View
@@ -39,6 +39,9 @@ module.exports = function(stream) {
stream.on("end", function() {
endData();
});
+ stream.on("error", function(err) {
+ endData(err);
+ });
}
function checkRead() {
View
44 fifo.js
@@ -39,7 +39,7 @@ Fifo.prototype = {
* Adds all the values from the items array. items is an array of arrays, and each array in it is an array of arguments to pass to the next()
* callback function.
*/
- _addAllMulti : function(items) {
+ _addAllMultiple : function(items) {
this.__items = this.__items.concat(items);
this.__check();
},
@@ -90,6 +90,36 @@ Fifo.prototype = {
}
});
}
+ },
+
+ toArraySingle : function(callback) {
+ var ret = [ ];
+ this.forEachSeries(function() {
+ var args = utils.toProperArray(arguments);
+ var next = args.pop();
+ ret.push(args[0]);
+ next();
+ }, function(err) {
+ if(err)
+ callback(err);
+ else
+ callback(null, ret);
+ });
+ },
+
+ toArrayMultiple : function(callback) {
+ var ret = [ ];
+ this.forEachSeries(function() {
+ var args = utils.toProperArray(arguments);
+ var next = args.pop();
+ ret.push(args);
+ next();
+ }, function(err) {
+ if(err)
+ callback(err);
+ else
+ callback(null, ret);
+ });
}
};
@@ -106,6 +136,10 @@ utils.extend(ArraySingle.prototype, {
callback(true);
else
callback(null, this.__array[this.__i++]);
+ },
+
+ toArraySingle : function(callback) {
+ callback(null, [ ].concat(this.__array));
}
});
@@ -123,6 +157,12 @@ utils.extend(ArrayMultiple.prototype, {
else
callback.apply(null, [ null ].concat(items));
});
+ },
+
+ toArraySingle : Fifo.prototype.toArraySingle,
+
+ toArrayMultiple : function(callback) {
+ callback(null, this.__array);
}
});
@@ -171,7 +211,7 @@ utils.extend(Grep.prototype, {
if(err)
callback(err);
else if(doAdd)
- callback(null, [ null ].concat(args));
+ callback.apply(null, [ null ].concat(args));
else
this.next(callback);
}) ]));
View
@@ -1,6 +1,9 @@
var utils = require("./utils");
var signing = require("./signing");
var consts = require("./consts");
+var packets = require("./packets");
+var packetContent = require("./packetContent");
+var Fifo = require("./fifo");
var Filter = require("./keyringFilters");
var async = require("async");
@@ -170,10 +173,7 @@ Keyring.prototype = {
if(err)
callback(err);
else
- {
this._addKeySignature(keyId, signatureInfo, callback);
- callback();
- }
}), false);
}
}));
@@ -236,10 +236,7 @@ Keyring.prototype = {
if(err)
callback(err);
else
- {
this._addSubkeySignature(keyId, subkeyId, signatureInfo, callback);
- callback();
- }
}));
}
}));
@@ -302,10 +299,7 @@ Keyring.prototype = {
if(err)
callback(err);
else
- {
this._addIdentitySignature(keyId, identityId, signatureInfo, callback);
- callback();
- }
}));
}
}));
@@ -368,10 +362,7 @@ Keyring.prototype = {
if(err)
callback(err);
else
- {
this._addAttributeSignature(keyId, attributeId, signatureInfo, callback);
- callback();
- }
}));
}
}));
@@ -434,7 +425,7 @@ Keyring.prototype = {
var lastAttributeImported = null;
packets.splitPackets(keyData).forEachSeries(function(tag, header, body, next) {
- getPacketInfo(tag, body, function(err, info) {
+ packetContent.getPacketInfo(tag, body, function(err, info) {
if(err)
return callback(err);
@@ -627,16 +618,14 @@ function _filter(list, filter) {
});
}
-function _strip(list, fieldList) {
+function _strip(item, fieldList) {
if(fieldList == null)
- return list;
+ return item;
- return Fifo.map(list, function(item, callback) {
- var newItem = { };
- for(var i in fieldList)
- newItem[i] = item[i];
- callback(null, newItem);
- });
+ var newItem = { };
+ for(var i=0; i<fieldList.length; i++)
+ newItem[fieldList[i]] = item[fieldList[i]];
+ return newItem;
}
function _add(existsFunc, addFunc, removeFunc, funcs, callback) {
@@ -765,7 +754,7 @@ function _subkeySignatureVerified(keyring, keyId, subkeyId, signatureInfo, callb
// Check 3a, 3b
if(signatureInfo.sigtype == consts.SIG.SUBKEY_REVOK)
- checks.push(async.apply(_checkSubkeyRevocationStatus, keyring, keyId, subkeyId));
+ checks.push(async.apply(_checkSubkeyRevocationStatus, keyring, keyId, subkeyId, false));
// Check 5b
if(signatureInfo.sigtype == consts.SIG.SUBKEY && signatureInfo.hashedSubPackets[consts.SIGSUBPKT.KEY_EXPIRE])
@@ -800,6 +789,7 @@ function _verifySignaturesByKey(keyring, keyId, callback) {
keyring.getKeySignatureListByIssuer(keyId, { verified: false }).forEachSeries(function(sig, next2) {
async.waterfall([
function(next3) {
+ console.log(sig);
keyring.getKeySignature(sig.keyId, sig.signatureId, next3, [ "issuer", "security" ]);
},
function(signatureInfo, next3) {
@@ -895,7 +885,7 @@ function _verifySignaturesByKey(keyring, keyId, callback) {
], callback);
}
-function _checkKeyRevocationStatus(keyring, keyId, callback, remove) {
+function _checkKeyRevocationStatus(keyring, keyId, remove, callback) {
keyring.getKeySignatures(keyId, { sigtype: consts.SIG.KEY_REVOK, verified: true }).forEachSeries(function(signatureInfo, next) {
async.waterfall([
function(next) {
@@ -920,7 +910,7 @@ function _checkKeyRevocationStatus(keyring, keyId, callback, remove) {
}, callback);
}
-function _checkSubkeyRevocationStatus(keyring, keyId, subkeyId, callback) {
+function _checkSubkeyRevocationStatus(keyring, keyId, subkeyId, remove, callback) {
keyring.getSubkeySignatures(keyId, subkeyId, { sigtype: consts.SIG.SUBKEY_REVOK, verified: true }).forEachSeries(function(signatureInfo, next) {
async.waterfall([
function(next) {
@@ -998,7 +988,7 @@ function _isAuthorisedRevoker(keyring, keyId, issuerId, callback) {
}
// Check 4: Find verified revocation signatures on the specified key and its sub-objects and revoke all earlier signatures by the same issuer on the same object
-function _checkSignatureRevocationStatus(keyring, keyId, callback, remove) {
+function _checkSignatureRevocationStatus(keyring, keyId, remove, callback) {
async.series([
function(next) {
if(remove)
@@ -1054,7 +1044,7 @@ function _resetSignatureRevocationStatus(keyring, keyId, callback) {
}, next);
},
function(next) {
- keyring.getIdentityList(keyId, function(identityId, next) {
+ keyring.getIdentityList(keyId).forEachSeries(function(identityId, next) {
keyring.getIdentitySignatures(keyId, identityId, { sigtype: [ consts.SIG.CERT_0, consts.SIG.CERT_1, consts.SIG.CERT_2, consts.SIG.CERT_3 ] }, [ "id", "revoked" ]).forEachSeries(function(signatureInfo, next) {
if(signatureInfo.revoked)
keyring._updateIdentitySignature(keyId, identityId, signatureInfo.id, { revoked: null }, next);
@@ -1064,7 +1054,7 @@ function _resetSignatureRevocationStatus(keyring, keyId, callback) {
}, next);
},
function(next) {
- keyring.getAttributeList(keyId, function(attributeId, next) {
+ keyring.getAttributeList(keyId).forEachSeries(function(attributeId, next) {
keyring.getAttributeSignatures(keyId, attributeId, { sigtype: [ consts.SIG.CERT_0, consts.SIG.CERT_1, consts.SIG.CERT_2, consts.SIG.CERT_3 ] }, [ "id", "revoked" ]).forEachSeries(function(signatureInfo, next) {
if(signatureInfo.revoked)
keyring._updateAttributeSignature(keyId, attributeId, signatureInfo.id, { revoked: null }, next);
@@ -1115,6 +1105,8 @@ function _checkSelfSignatures(keyring, keyId, callback) {
checkExpire(signatureInfo, next);
}
+ var filter = { verified: true, issuer: keyId, sigtype: [ consts.SIG.KEY, consts.SIG.CERT_0, consts.SIG.CERT_1, consts.SIG.CERT_2, consts.SIG.CERT_3 ] };
+
async.series([
function(next) {
keyring.getKeySignatures(keyId, filter, [ "hashedSubPackets", "date" ]).forEachSeries(checkExpire, next);
Oops, something went wrong.

0 comments on commit 8f0dd8e

Please sign in to comment.