Verify makeAttachmentPointer and encryptAttachment arguments

The underlying `crypto.subtle.encrypt` API requires it.
This commit is contained in:
Daniel Gasienica 2018-03-16 15:32:54 -04:00
parent 8218e308cd
commit 32911002d4
2 changed files with 18 additions and 0 deletions

View file

@ -87,6 +87,13 @@
},
encryptAttachment: function(plaintext, keys, iv) {
if (!(plaintext instanceof ArrayBuffer) && !ArrayBuffer.isView(plaintext)) {
throw new TypeError(
'`plaintext` must be an `ArrayBuffer` or `ArrayBufferView`; got: ' +
typeof plaintext
);
}
if (keys.byteLength != 64) {
throw new Error("Got invalid length attachment keys");
}