Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed ignoreRevoked option for encryption again, it does not make s…

…ense after all
  • Loading branch information...
commit 0561f893ed19624db3a654b5310fbe919211a81e 1 parent ce86f26
@cdauth authored
Showing with 4 additions and 43 deletions.
  1. +2 −2 encryption.js
  2. +2 −41 keyring.js
View
4 encryption.js
@@ -7,7 +7,7 @@ var consts = require("./consts");
var BufferedStream = require("./bufferedStream");
var async = require("async");
-function encryptData(keyring, toKeyId, data, callback, acceptRevoked) {
+function encryptData(keyring, toKeyId, data, callback) {
if(!Array.isArray(toKeyId))
toKeyId = [ toKeyId ];
@@ -31,7 +31,7 @@ function encryptData(keyring, toKeyId, data, callback, acceptRevoked) {
recipients.push(keyInfo.id);
var packet = packets.generatePacket(consts.PKT.PUBLIC_KEY, keyInfo.binary);
fs.write(res.file, fs.writeFile(res.fname, packet, 0, packet.length, null, next));
- }, [ "id", "binary" ], acceptRevoked);
+ }, [ "id", "binary" ]);
}, next);
} ],
encrypt: [ "write", function(next, res) {
View
43 keyring.js
@@ -747,42 +747,10 @@ Keyring.prototype = {
* @param callback {Function(Error e, Object keyInfo)} keyInfo is the id info of the subkey or the key itself, or
* null if no key was found.
* @param [fields] {Array}
- * @param [ignoreRevoked] {Boolean} If set to true, ignore the revocation and expiration status of keys.
- * Set to 2 to only ignore the expiration status. Non-revoked keys will
- * always be preferred over revoked keys and non-expired keys over expired
- * keys. Expired keys will be preferred over revoked keys.
*/
- getKeyWithFlag : function(keyId, flag, callback, fields, ignoreRevoked) {
- if(ignoreRevoked && ignoreRevoked != -1 && ignoreRevoked != -2)
- {
- return async.waterfall([
- function(next) {
- // Search for non-revoked and non-expired keys
- this.getKeyWithFlag(keyId, flag, next, fields, false);
- }.bind(this),
- function(key, next) {
- if(key)
- return callback(null, key);
-
- // Fallback: search for expired keys
- this.getKeyWithFlag(keyId, flag, next, fields, -1);
- }.bind(this),
- function(key, next) {
- if(key || ignoreRevoked == 2)
- return callback(null, key);
-
- // Fallback: search for revoked keys
- this.getKeyWithFlag(keyId, flag, next, fields, -2);
- }.bind(this)
- ], callback);
- }
-
+ getKeyWithFlag : function(keyId, flag, callback, fields) {
var id = null;
- var filter = { issuer: keyId, verified: true };
- if(ignoreRevoked != -1 && ignoreRevoked != -2)
- filter.expires = new Filter.Not(new Filter.LessThanOrEqual(new Date()));
- if(ignoreRevoked != -2)
- filter.revoked = null;
+ var filter = { issuer: keyId, verified: true, sigtype: [ consts.SIG.KEY, consts.SIG.SUBKEY, consts.SIG.CERT_0, consts.SIG.CERT_1, consts.SIG.CERT_2, consts.SIG.CERT_3 ], expires: new Filter.Not(new Filter.LessThanOrEqual(new Date())), revoked : null };
var isPkalgoRelatedFlag = ([ consts.KEYFLAG.SIGN, consts.KEYFLAG.ENCRYPT_COMM, consts.KEYFLAG.ENCRYPT_FILES, consts.KEYFLAG.AUTH ].indexOf(flag) != -1);
var sigDate = null;
@@ -821,18 +789,11 @@ Keyring.prototype = {
fields2.push("id");
if(fields2.indexOf("pkalgo") == -1)
fields2.push("pkalgo");
- if(fields2.indexOf("revoked") == -1)
- fields2.push("revoked");
- if(fields2.indexOf("expires") == -1)
- fields2.push("expires");
this.getKey(keyId, function(err, keyInfo) {
if(err)
return callback(err);
- if((ignoreRevoked != -2 && keyInfo.revoked) || (ignoreRevoked != -1 && ignoreRevoked != -2 && keyInfo.expires != null && keyInfo.expires.getTime() < (new Date()).getTime()))
- return callback(null, null);
-
if(isPkalgoRelatedFlag && consts.PKALGO_KEYFLAGS[keyInfo.pkalgo] && consts.PKALGO_KEYFLAGS[keyInfo.pkalgo].indexOf(flag) == -1)
return callback(null); // Pkalgo does not support flag

0 comments on commit 0561f89

Please sign in to comment.
Something went wrong with that request. Please try again.