Use promise api in sym_encrypted_* packets

This commit is contained in:
Tankred Hase 2016-03-22 14:09:07 +08:00
parent ded8926b27
commit 149f5d5191
2 changed files with 9 additions and 2 deletions

View File

@ -108,6 +108,8 @@ SymEncryptedIntegrityProtected.prototype.encrypt = function (sessionKeyAlgorithm
this.encrypted = crypto.cfb.encrypt(prefixrandom, sessionKeyAlgorithm, tohash, key, false) this.encrypted = crypto.cfb.encrypt(prefixrandom, sessionKeyAlgorithm, tohash, key, false)
.subarray(0, prefix.length + tohash.length); .subarray(0, prefix.length + tohash.length);
} }
return Promise.resolve();
}; };
/** /**
@ -153,4 +155,6 @@ SymEncryptedIntegrityProtected.prototype.decrypt = function (sessionKeyAlgorithm
} else { } else {
this.packets.read(decrypted.subarray(0, decrypted.length - 22)); this.packets.read(decrypted.subarray(0, decrypted.length - 22));
} }
return Promise.resolve();
}; };

View File

@ -73,11 +73,14 @@ SymmetricallyEncrypted.prototype.decrypt = function (sessionKeyAlgorithm, key) {
throw new Error('Decryption failed due to missing MDC in combination with modern cipher.'); throw new Error('Decryption failed due to missing MDC in combination with modern cipher.');
} }
this.packets.read(decrypted); this.packets.read(decrypted);
return Promise.resolve();
}; };
SymmetricallyEncrypted.prototype.encrypt = function (algo, key) { SymmetricallyEncrypted.prototype.encrypt = function (algo, key) {
var data = this.packets.write(); var data = this.packets.write();
this.encrypted = crypto.cfb.encrypt( this.encrypted = crypto.cfb.encrypt(crypto.getPrefixRandom(algo), algo, data, key, true);
crypto.getPrefixRandom(algo), algo, data, key, true);
return Promise.resolve();
}; };