Address comments

This commit is contained in:
KAYLukas 2018-02-17 11:32:45 +01:00
parent 071fc35f38
commit 454ca1d879
3 changed files with 4 additions and 8 deletions

View File

@ -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));
};

View File

@ -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<module:key~Key>} 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);

View File

@ -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.');