From 454ca1d8797bef1c0a1582c090f43fe7b144918e Mon Sep 17 00:00:00 2001 From: KAYLukas Date: Sat, 17 Feb 2018 11:32:45 +0100 Subject: [PATCH] Address comments --- src/cleartext.js | 3 +-- src/key.js | 7 +++---- src/message.js | 2 -- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/cleartext.js b/src/cleartext.js index 562d1527..36bf6f6b 100644 --- a/src/cleartext.js +++ b/src/cleartext.js @@ -24,7 +24,6 @@ * @module cleartext */ -import util from './util.js'; import config from './config'; import armor from './encoding/armor'; import enums from './enums'; @@ -72,7 +71,7 @@ CleartextMessage.prototype.getSigningKeyIds = function() { * @param {Date} date (optional) The creation time of the signature that should be created * @return {module:message~CleartextMessage} new cleartext message with signed content */ -CleartextMessage.prototype.sign = async function(privateKeys, signature = null, date=new Date()) { +CleartextMessage.prototype.sign = async function(privateKeys, signature=null, date=new Date()) { return new CleartextMessage(this.text, await this.signDetached(privateKeys, signature, date)); }; diff --git a/src/key.js b/src/key.js index 105ff69c..857f0fde 100644 --- a/src/key.js +++ b/src/key.js @@ -677,7 +677,6 @@ Key.prototype.signAllUsers = async function(privateKeys) { * - if no arguments are given, verifies the self certificates; * - otherwise, verifies all certificates signed with given keys. * @param {Array} keys array of keys to verify certificate signatures - * @param {Date} date (optional) use the given date for verification instead of the current time * @return {Array<({keyid: module:type/keyid, valid: Boolean})>} list of signer's keyid and validity of signature */ Key.prototype.verifyPrimaryUser = async function(keys) { @@ -957,7 +956,7 @@ SubKey.prototype.toPacketlist = function() { * @return {Boolean} */ SubKey.prototype.isValidEncryptionKey = async function(primaryKey, date=new Date()) { - if (await this.verify(primaryKey) !== enums.keyStatus.valid) { + if (await this.verify(primaryKey, date) !== enums.keyStatus.valid) { return false; } for (let i = 0; i < this.bindingSignatures.length; i++) { @@ -975,7 +974,7 @@ SubKey.prototype.isValidEncryptionKey = async function(primaryKey, date=new Date * @return {Boolean} */ SubKey.prototype.isValidSigningKey = async function(primaryKey, date=new Date()) { - if (await this.verify(primaryKey) !== enums.keyStatus.valid) { + if (await this.verify(primaryKey, date) !== enums.keyStatus.valid) { return false; } for (let i = 0; i < this.bindingSignatures.length; i++) { @@ -1290,7 +1289,7 @@ async function wrapKeyObject(secretKeyPacket, secretSubkeyPacket, options) { const dataToSign = {}; dataToSign.userid = userIdPacket; dataToSign.key = secretKeyPacket; - const signaturePacket = new packet.Signature(new Date(1000)); + const signaturePacket = new packet.Signature(); signaturePacket.signatureType = enums.signature.cert_generic; signaturePacket.publicKeyAlgorithm = options.keyType; signaturePacket.hashAlgorithm = getPreferredHashAlgo(secretKeyPacket); diff --git a/src/message.js b/src/message.js index ddc34746..612a6417 100644 --- a/src/message.js +++ b/src/message.js @@ -452,8 +452,6 @@ Message.prototype.compress = function(compression) { * @return {module:signature~Signature} new detached signature of message content */ Message.prototype.signDetached = async function(privateKeys=[], signature=null, date=new Date()) { - const packetlist = new packet.List(); - const literalDataPacket = this.packets.findPacket(enums.packet.literal); if (!literalDataPacket) { throw new Error('No literal data packet to sign.');